[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/28] target/i386: Split out do_xsave_chk
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v2 12/28] target/i386: Split out do_xsave_chk |
|
Date: |
Mon, 8 Apr 2024 19:02:46 -1000 |
This path is not required by user-only, and can in fact
be shared between xsave and xrstor.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/fpu_helper.c | 51 +++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index 883002dc22..11c60152de 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -2674,16 +2674,6 @@ static void do_xsave(CPUX86State *env, target_ulong ptr,
uint64_t rfbm,
X86Access ac;
unsigned size;
- /* The OS must have enabled XSAVE. */
- if (!(env->cr[4] & CR4_OSXSAVE_MASK)) {
- raise_exception_ra(env, EXCP06_ILLOP, ra);
- }
-
- /* The operand must be 64 byte aligned. */
- if (ptr & 63) {
- raise_exception_ra(env, EXCP0D_GPF, ra);
- }
-
/* Never save anything not enabled by XCR0. */
rfbm &= env->xcr0;
opt &= rfbm;
@@ -2720,15 +2710,35 @@ static void do_xsave(CPUX86State *env, target_ulong
ptr, uint64_t rfbm,
access_stq(&ac, ptr + XO(header.xstate_bv), new_bv);
}
+static void do_xsave_chk(CPUX86State *env, target_ulong ptr, uintptr_t ra)
+{
+ /* The OS must have enabled XSAVE. */
+ if (!(env->cr[4] & CR4_OSXSAVE_MASK)) {
+ raise_exception_ra(env, EXCP06_ILLOP, ra);
+ }
+
+ /* The operand must be 64 byte aligned. */
+ if (ptr & 63) {
+ raise_exception_ra(env, EXCP0D_GPF, ra);
+ }
+}
+
void helper_xsave(CPUX86State *env, target_ulong ptr, uint64_t rfbm)
{
- do_xsave(env, ptr, rfbm, get_xinuse(env), -1, GETPC());
+ uintptr_t ra = GETPC();
+
+ do_xsave_chk(env, ptr, ra);
+ do_xsave(env, ptr, rfbm, get_xinuse(env), -1, ra);
}
void helper_xsaveopt(CPUX86State *env, target_ulong ptr, uint64_t rfbm)
{
- uint64_t inuse = get_xinuse(env);
- do_xsave(env, ptr, rfbm, inuse, inuse, GETPC());
+ uintptr_t ra = GETPC();
+ uint64_t inuse;
+
+ do_xsave_chk(env, ptr, ra);
+ inuse = get_xinuse(env);
+ do_xsave(env, ptr, rfbm, inuse, inuse, ra);
}
static void do_xrstor_fpu(X86Access *ac, target_ulong ptr)
@@ -2899,16 +2909,6 @@ static void do_xrstor(CPUX86State *env, target_ulong
ptr, uint64_t rfbm, uintptr
rfbm &= env->xcr0;
- /* The OS must have enabled XSAVE. */
- if (!(env->cr[4] & CR4_OSXSAVE_MASK)) {
- raise_exception_ra(env, EXCP06_ILLOP, ra);
- }
-
- /* The operand must be 64 byte aligned. */
- if (ptr & 63) {
- raise_exception_ra(env, EXCP0D_GPF, ra);
- }
-
size = sizeof(X86LegacyXSaveArea) + sizeof(X86XSaveHeader);
access_prepare(&ac, env, ptr, size, MMU_DATA_LOAD, ra);
@@ -3003,7 +3003,10 @@ static void do_xrstor(CPUX86State *env, target_ulong
ptr, uint64_t rfbm, uintptr
void helper_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm)
{
- do_xrstor(env, ptr, rfbm, GETPC());
+ uintptr_t ra = GETPC();
+
+ do_xsave_chk(env, ptr, ra);
+ do_xrstor(env, ptr, rfbm, ra);
}
#if defined(CONFIG_USER_ONLY)
--
2.34.1
- [PATCH v2 01/28] target/i386: Add tcg/access.[ch], (continued)
- [PATCH v2 01/28] target/i386: Add tcg/access.[ch], Richard Henderson, 2024/04/09
- [PATCH v2 04/28] target/i386: Convert do_fldenv to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 05/28] target/i386: Convert do_fstenv to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 06/28] target/i386: Convert do_fsave, do_frstor to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 07/28] target/i386: Convert do_xsave_{fpu, mxcr, sse} to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 08/28] target/i386: Convert do_xrstor_{fpu, mxcr, sse} to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 10/28] target/i386: Convert do_xsave_* to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 11/28] target/i386: Convert do_xrstor_* to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 12/28] target/i386: Split out do_xsave_chk,
Richard Henderson <=
- [PATCH v2 13/28] target/i386: Add rbfm argument to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/04/09
- [PATCH v2 15/28] linux-user/i386: Drop xfeatures_size from sigcontext arithmetic, Richard Henderson, 2024/04/09
- [PATCH v2 14/28] target/i386: Add {hw, sw}_reserved to X86LegacyXSaveArea, Richard Henderson, 2024/04/09
- [PATCH v2 16/28] linux-user/i386: Remove xfeatures from target_fpstate_fxsave, Richard Henderson, 2024/04/09
- [PATCH v2 17/28] linux-user/i386: Replace target_fpstate_fxsave with X86LegacyXSaveArea, Richard Henderson, 2024/04/09
- [PATCH v2 18/28] linux-user/i386: Split out struct target_fregs_state, Richard Henderson, 2024/04/09
- [PATCH v2 20/28] linux-user/i386: Return boolean success from restore_sigcontext, Richard Henderson, 2024/04/09
- [PATCH v2 19/28] linux-user/i386: Fix -mregparm=3 for signal delivery, Richard Henderson, 2024/04/09
- [PATCH v2 21/28] linux-user/i386: Return boolean success from xrstor_sigcontext, Richard Henderson, 2024/04/09