x86/fpu: Lazy FPU removal prep
cover x86/fpu: Lazy FPU removal prep
Two patches to go ahead of Ross's removal series to simplify things a bit.
Andrew Cooper (2):
docs/hypfs: Adjust the hypfs layout example
x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
docs/misc/hypfs-paths.pandoc | 37 +++++++----------------------------- xen/arch/x86/xstate.c | 3 ++- 2 files changed, 9 insertions(+), 31 deletions(-)
Signature · 1 line
2.39.5
PATCH 1/2 docs/hypfs: Adjust the hypfs layout example
The controls for cpu-bugs were ultimately not taken. As the paths are documented fully below, pick only a small subset for the example. Include cpupool/ as it exists now.
---
CC: Juergen Gross <[email protected]>
CC: Ross Lagerwall <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
This is mainly so the patch making eager-fpu unconditional doesn't contain a hunk editing this file with no associated hypfs logic changes.
--- docs/misc/hypfs-paths.pandoc | 37 +++++++----------------------------- 1 file changed, 7 insertions(+), 30 deletions(-)
docs/misc/hypfs-paths.pandoc +7 -30
@@ -89,36 +89,13 @@ the hypervisors, and in different configurations. Specifically: A populated Xen hypervisor file system might look like the following example: / - buildinfo/ directory containing build-time data - config contents of .config file used to build Xen - cpu-bugs/ x86: directory of cpu bug information - l1tf "Vulnerable" or "Not vulnerable" - mds "Vulnerable" or "Not vulnerable" - meltdown "Vulnerable" or "Not vulnerable" - spec-store-bypass "Vulnerable" or "Not vulnerable" - spectre-v1 "Vulnerable" or "Not vulnerable" - spectre-v2 "Vulnerable" or "Not vulnerable" - mitigations/ directory of mitigation settings - bti-thunk "N/A", "RETPOLINE", "LFENCE" or "JMP" - spec-ctrl "No", "IBRS+" or "IBRS-" - ibpb "No" or "Yes" - l1d-flush "No" or "Yes" - md-clear "No" or "VERW" - l1tf-barrier "No" or "Yes" - active-hvm/ directory for mitigations active in hvm doamins - msr-spec-ctrl "No" or "Yes" - rsb "No" or "Yes" - eager-fpu "No" or "Yes" - md-clear "No" or "Yes" - active-pv/ directory for mitigations active in pv doamins - msr-spec-ctrl "No" or "Yes" - rsb "No" or "Yes" - eager-fpu "No" or "Yes" - md-clear "No" or "Yes" - xpti "No" or list of "dom0", "domU", "PCID-on" - l1tf-shadow "No" or list of "dom0", "domU" - params/ directory with hypervisor parameter values - (boot/runtime parameters) + buildinfo/ directory containing build-time data + config contents of .config file used to build Xen + cpupool/ directory containing CPU Pool data + 0/ directory for cpupool 0 + sched-gran "cpu", "core" or "socket" + params/ directory with hypervisor parameter values + loglvl "none", "error", "warning", "info", "all" ## General Paths
Signature · 1 line
2.39.5
Re: [PATCH 1/2] docs/hypfs: Adjust the hypfs layout example
Quoted 5 lines · Andrew Cooper
The controls for cpu-bugs were ultimately not taken. As the paths are documented fully below, pick only a small subset for the example. Include cpupool/ as it exists now.
Signed-off-by Andrew Cooper <[email protected]>
Juergen
PATCH 2/2 x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
In reply to Andrew Cooperxstate_alloc_save_area() configures FCW and MXCSR to #RESET values but misses FTW. Fixing this means that the backing memory always has an architecturally correct value.
Adjust the comment to state that it's the #RESET values which we care about.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ross Lagerwall <[email protected]>
I don't understand what the rest of the comment is trying to say, so have left it alone. There's still a lot of cleanup to be done to merge i387 and xstate.
--- xen/arch/x86/xstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/xstate.c +2 -1
@@ -550,11 +550,12 @@ int xstate_alloc_save_area(struct vcpu *v)return -ENOMEM ;/* -* Set the memory image to default values, but don't force the context +* Set the memory image to #RESET values, but don't force the context * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv * clear). */ 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;
Signature · 1 line
2.39.5
Re: [PATCH 2/2] x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
Quoted 26 lines · Andrew Cooper
xstate_alloc_save_area()configures FCW and MXCSR to #RESET values but misses FTW. Fixing this means that the backing memory always has an architecturally correct value.Adjust the comment to state that it's the #RESET values which we care about.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ross Lagerwall <[email protected]>I don't understand what the rest of the comment is trying to say, so have left it alone. There's still a lot of cleanup to be done to merge i387 and xstate.
--- xen/arch/x86/xstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/x86/xstate.c +0
-0@@ -550,11 +550,12 @@ int xstate_alloc_save_area(struct vcpu *v)return -ENOMEM ;/*
xen/arch/x86/xstate.c int xstate_alloc_save_area(struct vcpu *v) · line 561
Quoted 10 lines
xen/arch/x86/xstate.c +2
-1-* Set the memory image to default values, but don't force the context +* Set the memory image to #RESET values, but don't force the context * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv * clear). */ 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;
Is this comment correct given that it is initializing FCW to FCW_DEFAULT which is different from FCW_RESET?
As they seem to be mostly doing the same thing, could we call vcpu_reset_fpu() here instead?
Ross
Re: [PATCH 2/2] x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
Quoted 36 lines · Ross Lagerwall
Quoted 35 lines · Andrew Cooper
xstate_alloc_save_area()configures FCW and MXCSR to #RESET values but misses FTW. Fixing this means that the backing memory always has an architecturally correct value.Adjust the comment to state that it's the #RESET values which we care about.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ross Lagerwall <[email protected]>I don't understand what the rest of the comment is trying to say, so have left it alone. There's still a lot of cleanup to be done to merge i387 and xstate.
--- xen/arch/x86/xstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/x86/xstate.c +2
-1@@ -550,11 +550,12 @@ int xstate_alloc_save_area(struct vcpu *v)return -ENOMEM ;/* -* Set the memory image to default values, but don't force the context +* Set the memory image to #RESET values, but don't force the context * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv * clear). */ save_area->fpu_sse.fcw =FCW_DEFAULT ; + save_area->fpu_sse.ftw =FXSAVE_FTW_RESET ; save_area->fpu_sse.mxcsr =MXCSR_DEFAULT ;
Quoted 4 lines
xen/arch/x86/xstate.c int xstate_alloc_save_area(struct vcpu *v) · line 561
Quoted 1 line
xen/arch/x86/xstate.c +0
-0v->arch.xsave_area = save_area;Is this comment correct given that it is initializing FCW to
FCW_DEFAULTwhich is different fromFCW_RESET?
Is the goal here to represent XSAVE init-state in memory, or do we truly mean #RESET state (in which case FCW_RESET would need using, and in which case leaving xstate_bv bit 0 clear would be wrong).
Jan
Re: [PATCH 2/2] x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
Quoted 37 lines · Jan Beulich
Quoted 36 lines · Ross Lagerwall
Quoted 35 lines · Andrew Cooper
xstate_alloc_save_area()configures FCW and MXCSR to #RESET values but misses FTW. Fixing this means that the backing memory always has an architecturally correct value.Adjust the comment to state that it's the #RESET values which we care about.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ross Lagerwall <[email protected]>I don't understand what the rest of the comment is trying to say, so have left it alone. There's still a lot of cleanup to be done to merge i387 and xstate.
--- xen/arch/x86/xstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)xen/arch/x86/xstate.c +2
-1@@ -550,11 +550,12 @@ int xstate_alloc_save_area(struct vcpu *v)return -ENOMEM ;/* -* Set the memory image to default values, but don't force the context +* Set the memory image to #RESET values, but don't force the context * to be loaded from memory (i.e. keep save_area->xsave_hdr.xstate_bv * clear). */ save_area->fpu_sse.fcw =FCW_DEFAULT ; + save_area->fpu_sse.ftw =FXSAVE_FTW_RESET ; save_area->fpu_sse.mxcsr =MXCSR_DEFAULT ;
Quoted 6 lines
Quoted 3 lines
xen/arch/x86/xstate.c int xstate_alloc_save_area(struct vcpu *v) · line 561
Quoted 1 line
xen/arch/x86/xstate.c +0
-0v->arch.xsave_area = save_area;Is this comment correct given that it is initializing FCW to
FCW_DEFAULTwhich is different fromFCW_RESET?Is the goal here to represent XSAVE init-state in memory, or do we truly mean #RESET state (in which case
FCW_RESETwould need using, and in which case leavingxstate_bvbit 0 clear would be wrong).
We're creating the vCPU, so conceptually I think #RESET state is what we want.
But, I'd forgotten that #RESET and #INIT FCW are different. Also, we don't really want to be taking the overhead of keeping this properly at the #RESET state until the guest executes an FNINIT/etc.
I think it's better to keep using DEFAULT here. I'll rework the comment and commit message.
This also suggests that we want to rethink vcpu_reset_fpu(), but we can leave that for later.
~Andrew
Re: [PATCH 2/2] x86/fpu: Initialise FTW as well as FCW in xstate_alloc_save_area()
In reply to Andrew CooperQuoted 7 lines · Andrew Cooper
xstate_alloc_save_area()configures FCW and MXCSR to #RESET values but misses FTW. Fixing this means that the backing memory always has an architecturally correct value.Adjust the comment to state that it's the #RESET values which we care about.
Signed-off-by Andrew Cooper <[email protected]>
The title using "as well as" reads to me as if both are being fixed, when really you bring FTW in line with FCW. Preferably with this adjusted to be unambiguous:
Quoted 2 lines
I don't understand what the rest of the comment is trying to say, so have left it alone. There's still a lot of cleanup to be done to merge i387 and xstate.
I think it tries to say that the values put in memory aren't actually going to be used by a subsequent XRSTOR, by it putting the respective registers into init-state without reading memory.
Jan
PATCH v2 2/2 x86/fpu: Initialise FTW in xstate_alloc_save_area()
In reply to Andrew CooperRight 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.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ross Lagerwall <[email protected]>
v2:
* Rewrite the commmit message and comment.
--- xen/arch/x86/xstate.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/x86/xstate.c +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;
Signature · 1 line
2.39.5