[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 23/28] target/i386: Honor xfeatures in xrstor_sigcontext
From: |
Richard Henderson |
Subject: |
[PATCH v2 23/28] target/i386: Honor xfeatures in xrstor_sigcontext |
Date: |
Mon, 8 Apr 2024 19:02:57 -1000 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/i386/signal.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
index d015fe520a..fd09c973d4 100644
--- a/linux-user/i386/signal.c
+++ b/linux-user/i386/signal.c
@@ -612,6 +612,7 @@ static bool xrstor_sigcontext(CPUX86State *env, FPStateKind
fpkind,
struct target_fpx_sw_bytes *sw = (void *)&fxstate->sw_reserved;
uint32_t magic1, magic2;
uint32_t extended_size, xstate_size, min_size, max_size;
+ uint64_t xfeatures;
switch (fpkind) {
case FPSTATE_XSAVE:
@@ -628,10 +629,25 @@ static bool xrstor_sigcontext(CPUX86State *env,
FPStateKind fpkind,
xstate_size > extended_size) {
break;
}
+
+ /*
+ * Restore the features indicated in the frame, masked by
+ * those currently enabled. Re-check the frame size.
+ * ??? It is not clear where the kernel does this, but it
+ * is not in check_xstate_in_sigframe, and so (probably)
+ * does not fall back to fxrstor.
+ */
+ xfeatures = tswap64(sw->xfeatures) & env->xcr0;
+ min_size = xsave_area_size(xfeatures, false);
+ if (xstate_size < min_size) {
+ return false;
+ }
+
if (!access_ok(env_cpu(env), VERIFY_READ, fxstate_addr,
xstate_size + TARGET_FP_XSTATE_MAGIC2_SIZE)) {
return false;
}
+
/*
* Check for the presence of second magic word at the end of memory
* layout. This detects the case where the user just copied the legacy
@@ -644,7 +660,8 @@ static bool xrstor_sigcontext(CPUX86State *env, FPStateKind
fpkind,
if (magic2 != FP_XSTATE_MAGIC2) {
break;
}
- cpu_x86_xrstor(env, fxstate_addr, -1);
+
+ cpu_x86_xrstor(env, fxstate_addr, xfeatures);
return true;
default:
--
2.34.1
- [PATCH v2 13/28] target/i386: Add rbfm argument to cpu_x86_{xsave, xrstor}, (continued)
- [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
- [PATCH v2 23/28] target/i386: Honor xfeatures in xrstor_sigcontext,
Richard Henderson <=
- [PATCH v2 22/28] linux-user/i386: Fix allocation and alignment of fp state, Richard Henderson, 2024/04/09
- [PATCH v2 24/28] target/i386: Convert do_xsave to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 25/28] target/i386: Convert do_xrstor to X86Access, Richard Henderson, 2024/04/09
- [PATCH v2 26/28] target/i386: Pass host pointer and size to cpu_x86_{fsave, frstor}, Richard Henderson, 2024/04/09
- [PATCH v2 27/28] target/i386: Pass host pointer and size to cpu_x86_{fxsave, fxrstor}, Richard Henderson, 2024/04/09
- [PATCH v2 28/28] target/i386: Pass host pointer and size to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/04/09
- Re: [PATCH for-9.1 v2 00/28] linux-user/i386: Properly align signal frame, Paolo Bonzini, 2024/04/09