mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 639de2aafa
master date: 2026-03-30 15:48:13 +0100
This commit is contained in:
1 parent
761aba980a
commit
e2981e073f
1 file changed
+14
-3
+14
-3
@@ -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;
|
||||
|
||||