[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access
From: |
Richard Henderson |
Subject: |
[PATCH v3 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access |
Date: |
Wed, 15 May 2024 17:08:18 +0200 |
Move the alignment fault from do_* to helper_*, as it need
not apply to usage from within user-only signal handling.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/fpu_helper.c | 84 ++++++++++++++++++++----------------
1 file changed, 48 insertions(+), 36 deletions(-)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index f21cdb45ea..4dcb0b92ff 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -2619,8 +2619,25 @@ static void do_xsave_pkru(CPUX86State *env, target_ulong
ptr, uintptr_t ra)
cpu_stq_data_ra(env, ptr, env->pkru, ra);
}
-static void do_fxsave(CPUX86State *env, target_ulong ptr, uintptr_t ra)
+static void do_fxsave(X86Access *ac, target_ulong ptr)
{
+ CPUX86State *env = ac->env;
+
+ do_xsave_fpu(ac, ptr);
+ if (env->cr[4] & CR4_OSFXSR_MASK) {
+ do_xsave_mxcsr(ac, ptr);
+ /* Fast FXSAVE leaves out the XMM registers */
+ if (!(env->efer & MSR_EFER_FFXSR)
+ || (env->hflags & HF_CPL_MASK)
+ || !(env->hflags & HF_LMA_MASK)) {
+ do_xsave_sse(ac, ptr);
+ }
+ }
+}
+
+void helper_fxsave(CPUX86State *env, target_ulong ptr)
+{
+ uintptr_t ra = GETPC();
X86Access ac;
/* The operand must be 16 byte aligned */
@@ -2630,22 +2647,7 @@ static void do_fxsave(CPUX86State *env, target_ulong
ptr, uintptr_t ra)
access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea),
MMU_DATA_STORE, ra);
- do_xsave_fpu(&ac, ptr);
-
- if (env->cr[4] & CR4_OSFXSR_MASK) {
- do_xsave_mxcsr(&ac, ptr);
- /* Fast FXSAVE leaves out the XMM registers */
- if (!(env->efer & MSR_EFER_FFXSR)
- || (env->hflags & HF_CPL_MASK)
- || !(env->hflags & HF_LMA_MASK)) {
- do_xsave_sse(&ac, ptr);
- }
- }
-}
-
-void helper_fxsave(CPUX86State *env, target_ulong ptr)
-{
- do_fxsave(env, ptr, GETPC());
+ do_fxsave(&ac, ptr);
}
static uint64_t get_xinuse(CPUX86State *env)
@@ -2850,8 +2852,25 @@ static void do_xrstor_pkru(CPUX86State *env,
target_ulong ptr, uintptr_t ra)
env->pkru = cpu_ldq_data_ra(env, ptr, ra);
}
-static void do_fxrstor(CPUX86State *env, target_ulong ptr, uintptr_t ra)
+static void do_fxrstor(X86Access *ac, target_ulong ptr)
{
+ CPUX86State *env = ac->env;
+
+ do_xrstor_fpu(ac, ptr);
+ if (env->cr[4] & CR4_OSFXSR_MASK) {
+ do_xrstor_mxcsr(ac, ptr);
+ /* Fast FXRSTOR leaves out the XMM registers */
+ if (!(env->efer & MSR_EFER_FFXSR)
+ || (env->hflags & HF_CPL_MASK)
+ || !(env->hflags & HF_LMA_MASK)) {
+ do_xrstor_sse(ac, ptr);
+ }
+ }
+}
+
+void helper_fxrstor(CPUX86State *env, target_ulong ptr)
+{
+ uintptr_t ra = GETPC();
X86Access ac;
/* The operand must be 16 byte aligned */
@@ -2861,22 +2880,7 @@ static void do_fxrstor(CPUX86State *env, target_ulong
ptr, uintptr_t ra)
access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea),
MMU_DATA_LOAD, ra);
- do_xrstor_fpu(&ac, ptr);
-
- if (env->cr[4] & CR4_OSFXSR_MASK) {
- do_xrstor_mxcsr(&ac, ptr);
- /* Fast FXRSTOR leaves out the XMM registers */
- if (!(env->efer & MSR_EFER_FFXSR)
- || (env->hflags & HF_CPL_MASK)
- || !(env->hflags & HF_LMA_MASK)) {
- do_xrstor_sse(&ac, ptr);
- }
- }
-}
-
-void helper_fxrstor(CPUX86State *env, target_ulong ptr)
-{
- do_fxrstor(env, ptr, GETPC());
+ do_fxrstor(&ac, ptr);
}
static void do_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm,
uintptr_t ra)
@@ -3008,12 +3012,20 @@ void cpu_x86_frstor(CPUX86State *env, target_ulong ptr,
int data32)
void cpu_x86_fxsave(CPUX86State *env, target_ulong ptr)
{
- do_fxsave(env, ptr, 0);
+ X86Access ac;
+
+ access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea),
+ MMU_DATA_STORE, 0);
+ do_fxsave(&ac, ptr);
}
void cpu_x86_fxrstor(CPUX86State *env, target_ulong ptr)
{
- do_fxrstor(env, ptr, 0);
+ X86Access ac;
+
+ access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea),
+ MMU_DATA_LOAD, 0);
+ do_fxrstor(&ac, ptr);
}
void cpu_x86_xsave(CPUX86State *env, target_ulong ptr)
--
2.34.1
- [PATCH v3 06/28] target/i386: Convert do_fsave, do_frstor to X86Access, (continued)
- [PATCH v3 06/28] target/i386: Convert do_fsave, do_frstor to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 05/28] target/i386: Convert do_fstenv to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 04/28] target/i386: Convert do_fldenv to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 07/28] target/i386: Convert do_xsave_{fpu, mxcr, sse} to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 10/28] target/i386: Convert do_xsave_* to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 12/28] target/i386: Split out do_xsave_chk, Richard Henderson, 2024/05/15
- [PATCH v3 13/28] target/i386: Add rbfm argument to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/05/15
- [PATCH v3 15/28] linux-user/i386: Drop xfeatures_size from sigcontext arithmetic, Richard Henderson, 2024/05/15
- [PATCH v3 14/28] target/i386: Add {hw, sw}_reserved to X86LegacyXSaveArea, Richard Henderson, 2024/05/15
- [PATCH v3 08/28] target/i386: Convert do_xrstor_{fpu, mxcr, sse} to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access,
Richard Henderson <=
- [PATCH v3 11/28] target/i386: Convert do_xrstor_* to X86Access, Richard Henderson, 2024/05/15
- [PATCH v3 17/28] linux-user/i386: Replace target_fpstate_fxsave with X86LegacyXSaveArea, Richard Henderson, 2024/05/15
- [PATCH v3 20/28] linux-user/i386: Return boolean success from restore_sigcontext, Richard Henderson, 2024/05/15
- [PATCH v3 19/28] linux-user/i386: Fix -mregparm=3 for signal delivery, Richard Henderson, 2024/05/15
- [PATCH v3 26/28] target/i386: Pass host pointer and size to cpu_x86_{fsave, frstor}, Richard Henderson, 2024/05/15
- [PATCH v3 28/28] target/i386: Pass host pointer and size to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/05/15
- [PATCH v3 23/28] target/i386: Honor xfeatures in xrstor_sigcontext, Richard Henderson, 2024/05/15
- [PATCH v3 18/28] linux-user/i386: Split out struct target_fregs_state, Richard Henderson, 2024/05/15
- [PATCH v3 22/28] linux-user/i386: Fix allocation and alignment of fp state, Richard Henderson, 2024/05/15
- [PATCH v3 25/28] target/i386: Convert do_xrstor to X86Access, Richard Henderson, 2024/05/15