[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/28] linux-user/i386: Honor xfeatures in xrstor_sigcontext
From: |
Richard Henderson |
Subject: |
[PULL 23/28] linux-user/i386: Honor xfeatures in xrstor_sigcontext |
Date: |
Sun, 26 May 2024 17:49:56 -0700 |
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 47e6c0ff0d..e716ec8989 100644
--- a/linux-user/i386/signal.c
+++ b/linux-user/i386/signal.c
@@ -613,6 +613,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:
@@ -629,10 +630,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
@@ -645,7 +661,8 @@ static bool xrstor_sigcontext(CPUX86State *env, FPStateKind
fpkind,
if (magic2 != TARGET_FP_XSTATE_MAGIC2) {
break;
}
- cpu_x86_xrstor(env, fxstate_addr, -1);
+
+ cpu_x86_xrstor(env, fxstate_addr, xfeatures);
return true;
default:
--
2.34.1
- [PULL 13/28] target/i386: Add rbfm argument to cpu_x86_{xsave, xrstor}, (continued)
- [PULL 13/28] target/i386: Add rbfm argument to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/05/26
- [PULL 20/28] linux-user/i386: Return boolean success from restore_sigcontext, Richard Henderson, 2024/05/26
- [PULL 19/28] linux-user/i386: Fix -mregparm=3 for signal delivery, Richard Henderson, 2024/05/26
- [PULL 18/28] linux-user/i386: Split out struct target_fregs_state, Richard Henderson, 2024/05/26
- [PULL 07/28] target/i386: Convert do_xsave_{fpu, mxcr, sse} to X86Access, Richard Henderson, 2024/05/26
- [PULL 17/28] linux-user/i386: Replace target_fpstate_fxsave with X86LegacyXSaveArea, Richard Henderson, 2024/05/26
- [PULL 24/28] target/i386: Convert do_xsave to X86Access, Richard Henderson, 2024/05/26
- [PULL 27/28] target/i386: Pass host pointer and size to cpu_x86_{fxsave, fxrstor}, Richard Henderson, 2024/05/26
- [PULL 26/28] target/i386: Pass host pointer and size to cpu_x86_{fsave, frstor}, Richard Henderson, 2024/05/26
- [PULL 06/28] target/i386: Convert do_fsave, do_frstor to X86Access, Richard Henderson, 2024/05/26
- [PULL 23/28] linux-user/i386: Honor xfeatures in xrstor_sigcontext,
Richard Henderson <=
- [PULL 22/28] linux-user/i386: Fix allocation and alignment of fp state, Richard Henderson, 2024/05/26
- [PULL 25/28] target/i386: Convert do_xrstor to X86Access, Richard Henderson, 2024/05/26
- [PULL 05/28] target/i386: Convert do_fstenv to X86Access, Richard Henderson, 2024/05/26
- [PULL 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access, Richard Henderson, 2024/05/26
- [PULL 15/28] linux-user/i386: Drop xfeatures_size from sigcontext arithmetic, Richard Henderson, 2024/05/26
- [PULL 16/28] linux-user/i386: Remove xfeatures from target_fpstate_fxsave, Richard Henderson, 2024/05/26
- [PULL 14/28] target/i386: Add {hw,sw}_reserved to X86LegacyXSaveArea, Richard Henderson, 2024/05/26
- [PULL 21/28] linux-user/i386: Return boolean success from xrstor_sigcontext, Richard Henderson, 2024/05/26
- [PULL 11/28] target/i386: Convert do_xrstor_* to X86Access, Richard Henderson, 2024/05/26
- [PULL 28/28] target/i386: Pass host pointer and size to cpu_x86_{xsave, xrstor}, Richard Henderson, 2024/05/26