From patchwork Tue Mar 16 18:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudio Fontana X-Patchwork-Id: 401718 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4552419jai; Tue, 16 Mar 2021 11:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+jpHTsJFR19ZEkaadB3SsIitC+d+vfpIl+RQeBjE+aHrn6oI/wdlhl0Z83r5HfGSspa6W X-Received: by 2002:a6b:d60e:: with SMTP id w14mr4389720ioa.187.1615919595122; Tue, 16 Mar 2021 11:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615919595; cv=none; d=google.com; s=arc-20160816; b=y7v0fYblQ9yNJFp/9ZQCOCSDIoMIkyymjoL5i9cy0lRhn9EjdMuuI0tRe4ZWCZkwpK PW7wxiBXQZ49SAeIFeXbzCAgup55IXxXVYpX3l+iFo5e0KC4l11ycM2bYq+Hm7gWKzRU UZSqdmJKfLZpcZII/TujXQLv9oP7P8qAGV4AZWpDGy4sd+YeHFykXhJ4uBO4pU2woDj6 oOG7sp37T4YTOsly/4JHEa24F3QBjagQ8N4c+kpAFmhlR3LX3Ecj7RWTdJbIXD2vzEG9 Q5MHd3/7/DtJN6GFHA54jst1xLB2z0frycnqVVYsTRMtAYZ1dW808C6g4NcIC/Mazj89 SL0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=5B5AlfiJHc8St6uU91vEGKVnXmh0y17asi7Yk1ujxhA=; b=wWXLNxJ4fBkKZ6NPsPCehSXlb4sKe/KStqhUtBPgaYcVQdAw/D+Pj+wrhWx2/ibIAv Yo5H6ik5fmMKbqifMwvnYSa66t5ZeA+KOvAF3OO7n/whEhve2kPDm6EJ14A/suWvzlfh 8yxLnrasEbWyvCmuozs57PK43G0hV+i29sWVh1l1R6s6z2JIM4Zy98trdWYp9QR91gvD OPFsew2YDjm1LmDkzIKSXd4P6lxXUzRXd9fE4iZ3nN+NS9pJ6jRH6n8vT8wU6xpPRAC7 gEDJwb0Ivc6ta938XJ4V8arXVxjWPzvK5ml+wgF5aQs7rBZ8zBnfk3njEsR0HMVv3uMu e9qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w9si14388103jad.47.2021.03.16.11.33.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Mar 2021 11:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:42270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMEVG-0004hQ-FN for patch@linaro.org; Tue, 16 Mar 2021 14:33:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMESt-0004dr-EI for qemu-devel@nongnu.org; Tue, 16 Mar 2021 14:30:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:32912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMESo-0004nT-Cc for qemu-devel@nongnu.org; Tue, 16 Mar 2021 14:30:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DF21FAD3B; Tue, 16 Mar 2021 18:30:37 +0000 (UTC) From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v27 01/20] target/i386: Rename helper_fldt, helper_fstt Date: Tue, 16 Mar 2021 19:30:16 +0100 Message-Id: <20210316183035.9424-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210316183035.9424-1-cfontana@suse.de> References: <20210316183035.9424-1-cfontana@suse.de> MIME-Version: 1.0 Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Roman Bolshakov , Claudio Fontana Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Change the prefix from "helper" to "do". The former should be reserved for those functions that are called from TCG; the latter is in use within the file already for those functions that are called from the helper functions, adding a "retaddr" argument. Signed-off-by: Richard Henderson Reviewed-by: Claudio Fontana Tested-by: Claudio Fontana Reviewed-by: Philippe Mathieu-Daudé --- target/i386/tcg/fpu_helper.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) -- 2.26.2 diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index 60ed93520a..3d9b192901 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -117,8 +117,7 @@ static inline void fpop(CPUX86State *env) env->fpstt = (env->fpstt + 1) & 7; } -static inline floatx80 helper_fldt(CPUX86State *env, target_ulong ptr, - uintptr_t retaddr) +static floatx80 do_fldt(CPUX86State *env, target_ulong ptr, uintptr_t retaddr) { CPU_LDoubleU temp; @@ -127,8 +126,8 @@ static inline floatx80 helper_fldt(CPUX86State *env, target_ulong ptr, return temp.d; } -static inline void helper_fstt(CPUX86State *env, floatx80 f, target_ulong ptr, - uintptr_t retaddr) +static void do_fstt(CPUX86State *env, floatx80 f, target_ulong ptr, + uintptr_t retaddr) { CPU_LDoubleU temp; @@ -405,14 +404,14 @@ void helper_fldt_ST0(CPUX86State *env, target_ulong ptr) int new_fpstt; new_fpstt = (env->fpstt - 1) & 7; - env->fpregs[new_fpstt].d = helper_fldt(env, ptr, GETPC()); + env->fpregs[new_fpstt].d = do_fldt(env, ptr, GETPC()); env->fpstt = new_fpstt; env->fptags[new_fpstt] = 0; /* validate stack entry */ } void helper_fstt_ST0(CPUX86State *env, target_ulong ptr) { - helper_fstt(env, ST0, ptr, GETPC()); + do_fstt(env, ST0, ptr, GETPC()); } void helper_fpush(CPUX86State *env) @@ -2468,7 +2467,7 @@ void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) ptr += (14 << data32); for (i = 0; i < 8; i++) { tmp = ST(i); - helper_fstt(env, tmp, ptr, GETPC()); + do_fstt(env, tmp, ptr, GETPC()); ptr += 10; } @@ -2495,7 +2494,7 @@ void helper_frstor(CPUX86State *env, target_ulong ptr, int data32) ptr += (14 << data32); for (i = 0; i < 8; i++) { - tmp = helper_fldt(env, ptr, GETPC()); + tmp = do_fldt(env, ptr, GETPC()); ST(i) = tmp; ptr += 10; } @@ -2539,7 +2538,7 @@ static void do_xsave_fpu(CPUX86State *env, target_ulong ptr, uintptr_t ra) addr = ptr + XO(legacy.fpregs); for (i = 0; i < 8; i++) { floatx80 tmp = ST(i); - helper_fstt(env, tmp, addr, ra); + do_fstt(env, tmp, addr, ra); addr += 16; } } @@ -2703,7 +2702,7 @@ static void do_xrstor_fpu(CPUX86State *env, target_ulong ptr, uintptr_t ra) addr = ptr + XO(legacy.fpregs); for (i = 0; i < 8; i++) { - floatx80 tmp = helper_fldt(env, addr, ra); + floatx80 tmp = do_fldt(env, addr, ra); ST(i) = tmp; addr += 16; } From patchwork Tue Mar 16 18:30:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudio Fontana X-Patchwork-Id: 401720 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4559664jai; Tue, 16 Mar 2021 11:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2pQ8v2xh1JFzXfCz5zndrWzPY7QaL1n53x0nyR4NhU2QEUQVStbKfn7OrRnHHTFoAcyPv X-Received: by 2002:a05:6602:3314:: with SMTP id b20mr4535644ioz.78.1615920260890; Tue, 16 Mar 2021 11:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615920260; cv=none; d=google.com; s=arc-20160816; b=QnDOoWhpArLoI53gakwzrdkDYR7LbC60vu5eO9OGhjoLT89SajC1F5hng24LoAUb2h PEZvQdaHcABVfCfN3jPpYbp7FzADoLkJMDAVpPvoEA/y740oQquyIJrGTp+Vj8UBMK2E BQt6uHqPB2oULlQ3uDp3xVM1uAGDplNinBi0xnYMQ77CwF3vZianE3/rnCeX/e9c9HSX dmGiOCPRu3plFwEJmvqDapBu+PuO6hzvSZKtRUyj9T1Ce96X4XMltNaNMHp5PiKm4qTk wHzzkN2t4QgXKP9HrM7lJo3V9w5oRwVj7td4W9hw8x8l6eAlmTO4ZBxzrlsATY7gOQpc qfzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=Cp5RCTIsznWoWsNmzfAchzNJIUbX9vX8jH5Qk2Qy0zE=; b=arN740E0yr376MqnvY0vMuIufqpmlfmF/VCWrEC6kKzRKBaXJfwwTQrMrrN/8knKS5 vKa0F8q+2UX7mLoITIUa/BnUdpW6z6hna2Mjwqkb2q+Qk381QhAL4Y7/iz0WOjEY1cfV 3x44GMVb04fPC0SN7bx9iDmO3SCa8eHZkBpfvFjh4t5kTh+UlWWyMTPLeLttb/U+zm8c lBvMyGRl6l2xKcWVCIHKG2Cf0YCnpvrXmyllz7DKmTm9RdcZ1YJRU/O3aB3w837DLWTD 2G+yXsTPudX8gotPcGHF+NYkjhZXp8Gi6ROgX1NjIjOP90JNOVPo9fWtUtteJ5TIGFaH //KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v19si13540934iom.33.2021.03.16.11.44.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Mar 2021 11:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:41988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMEg0-0000GZ-C1 for patch@linaro.org; Tue, 16 Mar 2021 14:44:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMET4-0004jA-AI for qemu-devel@nongnu.org; Tue, 16 Mar 2021 14:30:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:32936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMESo-0004oM-Gu for qemu-devel@nongnu.org; Tue, 16 Mar 2021 14:30:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 575B5AE89; Tue, 16 Mar 2021 18:30:38 +0000 (UTC) From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eduardo Habkost , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v27 02/20] target/i386: Split out do_fsave, do_frstor, do_fxsave, do_fxrstor Date: Tue, 16 Mar 2021 19:30:17 +0100 Message-Id: <20210316183035.9424-3-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210316183035.9424-1-cfontana@suse.de> References: <20210316183035.9424-1-cfontana@suse.de> MIME-Version: 1.0 Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Roman Bolshakov , Claudio Fontana Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The helper_* functions must use GETPC() to unwind from TCG. The cpu_x86_* functions cannot, and directly calling the helper_* functions is a bug. Split out new functions that perform the work and can be used by both. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Claudio Fontana Tested-by: Claudio Fontana --- target/i386/tcg/fpu_helper.c | 66 +++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 24 deletions(-) -- 2.26.2 diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index 3d9b192901..20e4d2e715 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -2457,17 +2457,18 @@ void helper_fldenv(CPUX86State *env, target_ulong ptr, int data32) do_fldenv(env, ptr, data32, GETPC()); } -void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) +static void do_fsave(CPUX86State *env, target_ulong ptr, int data32, + uintptr_t retaddr) { floatx80 tmp; int i; - do_fstenv(env, ptr, data32, GETPC()); + do_fstenv(env, ptr, data32, retaddr); ptr += (14 << data32); for (i = 0; i < 8; i++) { tmp = ST(i); - do_fstt(env, tmp, ptr, GETPC()); + do_fstt(env, tmp, ptr, retaddr); ptr += 10; } @@ -2485,30 +2486,41 @@ void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) env->fptags[7] = 1; } +void helper_fsave(CPUX86State *env, target_ulong ptr, int data32) +{ + do_fsave(env, ptr, data32, GETPC()); +} + +static void do_frstor(CPUX86State *env, target_ulong ptr, int data32, + uintptr_t retaddr) +{ + floatx80 tmp; + int i; + + do_fldenv(env, ptr, data32, retaddr); + ptr += (14 << data32); + + for (i = 0; i < 8; i++) { + tmp = do_fldt(env, ptr, retaddr); + ST(i) = tmp; + ptr += 10; + } +} + void helper_frstor(CPUX86State *env, target_ulong ptr, int data32) { - floatx80 tmp; - int i; - - do_fldenv(env, ptr, data32, GETPC()); - ptr += (14 << data32); - - for (i = 0; i < 8; i++) { - tmp = do_fldt(env, ptr, GETPC()); - ST(i) = tmp; - ptr += 10; - } + do_frstor(env, ptr, data32, GETPC()); } #if defined(CONFIG_USER_ONLY) void cpu_x86_fsave(CPUX86State *env, target_ulong ptr, int data32) { - helper_fsave(env, ptr, data32); + do_fsave(env, ptr, data32, 0); } void cpu_x86_frstor(CPUX86State *env, target_ulong ptr, int data32) { - helper_frstor(env, ptr, data32); + do_frstor(env, ptr, data32, 0); } #endif @@ -2593,10 +2605,8 @@ static void do_xsave_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) cpu_stq_data_ra(env, ptr, env->pkru, ra); } -void helper_fxsave(CPUX86State *env, target_ulong ptr) +static void do_fxsave(CPUX86State *env, target_ulong ptr, uintptr_t ra) { - uintptr_t ra = GETPC(); - /* The operand must be 16 byte aligned */ if (ptr & 0xf) { raise_exception_ra(env, EXCP0D_GPF, ra); @@ -2615,6 +2625,11 @@ void helper_fxsave(CPUX86State *env, target_ulong ptr) } } +void helper_fxsave(CPUX86State *env, target_ulong ptr) +{ + do_fxsave(env, ptr, GETPC()); +} + static uint64_t get_xinuse(CPUX86State *env) { uint64_t inuse = -1; @@ -2757,10 +2772,8 @@ static void do_xrstor_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) env->pkru = cpu_ldq_data_ra(env, ptr, ra); } -void helper_fxrstor(CPUX86State *env, target_ulong ptr) +static void do_fxrstor(CPUX86State *env, target_ulong ptr, uintptr_t ra) { - uintptr_t ra = GETPC(); - /* The operand must be 16 byte aligned */ if (ptr & 0xf) { raise_exception_ra(env, EXCP0D_GPF, ra); @@ -2779,15 +2792,20 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr) } } +void helper_fxrstor(CPUX86State *env, target_ulong ptr) +{ + do_fxrstor(env, ptr, GETPC()); +} + #if defined(CONFIG_USER_ONLY) void cpu_x86_fxsave(CPUX86State *env, target_ulong ptr) { - helper_fxsave(env, ptr); + do_fxsave(env, ptr, 0); } void cpu_x86_fxrstor(CPUX86State *env, target_ulong ptr) { - helper_fxrstor(env, ptr); + do_fxrstor(env, ptr, 0); } #endif