|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.21] x86/fpu: Initialise FTW in xstate_alloc_save_area()
commit e2981e073fa9a8f073e3c1c767685ba69c3d813c
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Apr 20 12:25:10 2026 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Apr 20 12:25:10 2026 +0200
x86/fpu: Initialise FTW in xstate_alloc_save_area()
Right now, xstate_alloc_save_area() leaves both XSTATE_BV and FTW clear.
This
causes a difference in behaviour between FXRSTOR and XRSTOR.
Switch to using using XSTATE's idea of initial configuration which will
behave
the same even on pre-XSAVE hardware. Expand the comment to explain why.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
master commit: 639de2aafa437fd50abc16a46c8a8dd0d0e9e6a7
master date: 2026-03-30 15:48:13 +0100
---
xen/arch/x86/xstate.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index e990abc9d1..defe9b3f0c 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -550,11 +550,22 @@ int xstate_alloc_save_area(struct vcpu *v)
return -ENOMEM;
/*
- * Set the memory image to default values, but don't force the context
- * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv
- * clear).
+ * We're creating a vCPU, so conceptually we should be choosing the
+ * architectural #RESET values.
+ *
+ * However for historical reasons of configuring the external
+ * co-processor, FCW's #RESET state is different to what F(N)INIT and
+ * XSTATE consider the "initial configuration".
+ *
+ * Guests won't care about the difference; all software tends to executes
+ * FNINIT very early during setup.
+ *
+ * Use XSTATE's idea of initial configuration. This allows XSTATE_BV to
+ * remain clear and for CPUs to use the INIT optimisation where
+ * applicable.
*/
save_area->fpu_sse.fcw = FCW_DEFAULT;
+ save_area->fpu_sse.ftw = FXSAVE_FTW_RESET;
save_area->fpu_sse.mxcsr = MXCSR_DEFAULT;
v->arch.xsave_area = save_area;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.21
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |