* [PATCH v2] x86/xsave: simplify xcomp_bv initialization
@ 2016-01-13 7:30 Jan Beulich
2016-01-13 10:59 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-01-13 7:30 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Keir Fraser, Shuai Ruan
[-- Attachment #1: Type: text/plain, Size: 2504 bytes --]
This simplifies a number of pointless conditionals: Bits 0 and 1 of
xcomp_bv don't matter anyway, and as long as none of bits 2..62 are
set, setting bit 63 is pointless too unless XSAVES is in use.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Retain setting of bit 63 on XSAVES-capable systems.
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -922,9 +922,8 @@ int arch_set_info_guest(
if ( v->arch.xsave_area )
{
v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE |
- XSTATE_COMPACTION_ENABLED;
+ v->arch.xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
}
else if ( v->arch.xsave_area )
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2094,9 +2094,8 @@ static int hvm_load_cpu_ctxt(struct doma
memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));
xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE |
- XSTATE_COMPACTION_ENABLED;
+ xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
else
memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));
@@ -5455,9 +5454,8 @@ void hvm_vcpu_reset_state(struct vcpu *v
if ( v->arch.xsave_area )
{
v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP |
- XSTATE_COMPACTION_ENABLED;
+ v->arch.xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
v->arch.vgc_flags = VGCF_online;
--- a/xen/arch/x86/i387.c
+++ b/xen/arch/x86/i387.c
@@ -272,7 +272,7 @@ int vcpu_init_fpu(struct vcpu *v)
if ( v->arch.xsave_area )
{
v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
- if ( cpu_has_xsaves || cpu_has_xsavec )
+ if ( cpu_has_xsaves )
v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED;
}
else
[-- Attachment #2: x86-xcomp_bv-simplify.patch --]
[-- Type: text/plain, Size: 2545 bytes --]
x86/xsave: simplify xcomp_bv initialization
This simplifies a number of pointless conditionals: Bits 0 and 1 of
xcomp_bv don't matter anyway, and as long as none of bits 2..62 are
set, setting bit 63 is pointless too unless XSAVES is in use.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Retain setting of bit 63 on XSAVES-capable systems.
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -922,9 +922,8 @@ int arch_set_info_guest(
if ( v->arch.xsave_area )
{
v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE |
- XSTATE_COMPACTION_ENABLED;
+ v->arch.xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
}
else if ( v->arch.xsave_area )
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -2094,9 +2094,8 @@ static int hvm_load_cpu_ctxt(struct doma
memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));
xsave_area->xsave_hdr.xstate_bv = XSTATE_FP_SSE;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP_SSE |
- XSTATE_COMPACTION_ENABLED;
+ xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
else
memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));
@@ -5455,9 +5454,8 @@ void hvm_vcpu_reset_state(struct vcpu *v
if ( v->arch.xsave_area )
{
v->arch.xsave_area->xsave_hdr.xstate_bv = XSTATE_FP;
- if ( cpu_has_xsaves || cpu_has_xsavec )
- v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_FP |
- XSTATE_COMPACTION_ENABLED;
+ v->arch.xsave_area->xsave_hdr.xcomp_bv =
+ cpu_has_xsaves ? XSTATE_COMPACTION_ENABLED : 0;
}
v->arch.vgc_flags = VGCF_online;
--- a/xen/arch/x86/i387.c
+++ b/xen/arch/x86/i387.c
@@ -272,7 +272,7 @@ int vcpu_init_fpu(struct vcpu *v)
if ( v->arch.xsave_area )
{
v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
- if ( cpu_has_xsaves || cpu_has_xsavec )
+ if ( cpu_has_xsaves )
v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED;
}
else
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] x86/xsave: simplify xcomp_bv initialization
2016-01-13 7:30 [PATCH v2] x86/xsave: simplify xcomp_bv initialization Jan Beulich
@ 2016-01-13 10:59 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2016-01-13 10:59 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Keir Fraser, Shuai Ruan
On 13/01/16 07:30, Jan Beulich wrote:
> This simplifies a number of pointless conditionals: Bits 0 and 1 of
> xcomp_bv don't matter anyway, and as long as none of bits 2..62 are
> set, setting bit 63 is pointless too unless XSAVES is in use.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-13 10:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13 7:30 [PATCH v2] x86/xsave: simplify xcomp_bv initialization Jan Beulich
2016-01-13 10:59 ` Andrew Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).