From: "Jan Beulich" Subject: [PATCH] x86/xsave: simplify xcomp_bv initialization Date: Thu, 17 Dec 2015 09:58:38 -0700 Message-ID: <5672F7CE02000078000C0D8F@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part0B3C22AE.2__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9bt5-0005BS-BZ for xen-devel@lists.xenproject.org; Thu, 17 Dec 2015 16:58:43 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser , Shuai Ruan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part0B3C22AE.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This eliminates 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. Signed-off-by: Jan Beulich --- Noticed while working on XSA-165. --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -912,9 +912,7 @@ int arch_set_info_guest( if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv =3D XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv =3D XSTATE_FP_SSE = | - XSTATE_COMPACTION= _ENABLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv =3D 0; } } else if ( v->arch.xsave_area ) --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2092,9 +2092,7 @@ static int hvm_load_cpu_ctxt(struct doma =20 memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); xsave_area->xsave_hdr.xstate_bv =3D XSTATE_FP_SSE; - if ( cpu_has_xsaves || cpu_has_xsavec ) - xsave_area->xsave_hdr.xcomp_bv =3D XSTATE_FP_SSE | - XSTATE_COMPACTION_ENABLED; + xsave_area->xsave_hdr.xcomp_bv =3D 0; } else memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, sizeof(ctxt.fpu_regs)); @@ -5562,9 +5560,7 @@ void hvm_vcpu_reset_state(struct vcpu *v if ( v->arch.xsave_area ) { v->arch.xsave_area->xsave_hdr.xstate_bv =3D XSTATE_FP; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv =3D XSTATE_FP | - XSTATE_COMPACTION_ENA= BLED; + v->arch.xsave_area->xsave_hdr.xcomp_bv =3D 0; } =20 v->arch.vgc_flags =3D VGCF_online; --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -270,11 +270,7 @@ int vcpu_init_fpu(struct vcpu *v) return rc; =20 if ( v->arch.xsave_area ) - { v->arch.fpu_ctxt =3D &v->arch.xsave_area->fpu_sse; - if ( cpu_has_xsaves || cpu_has_xsavec ) - v->arch.xsave_area->xsave_hdr.xcomp_bv =3D XSTATE_COMPACTION_E= NABLED; - } else { v->arch.fpu_ctxt =3D _xzalloc(sizeof(v->arch.xsave_area->fpu_sse),= 16); --=__Part0B3C22AE.2__= Content-Type: text/plain; name="x86-xcomp_bv-simplify.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-xcomp_bv-simplify.patch" x86/xsave: simplify xcomp_bv initialization=0A=0AThis eliminates a number = of pointless conditionals: Bits 0 and 1 of=0Axcomp_bv don't matter anyway, = and as long as none of bits 2..62 are=0Aset, setting bit 63 is pointless = too.=0A=0ASigned-off-by: Jan Beulich =0A---=0ANoticed = while working on XSA-165.=0A=0A--- a/xen/arch/x86/domain.c=0A+++ b/xen/arch= /x86/domain.c=0A@@ -912,9 +912,7 @@ int arch_set_info_guest(=0A if = ( v->arch.xsave_area )=0A {=0A v->arch.xsave_area->xsav= e_hdr.xstate_bv =3D XSTATE_FP_SSE;=0A- if ( cpu_has_xsaves || = cpu_has_xsavec )=0A- v->arch.xsave_area->xsave_hdr.xcomp_bv = =3D XSTATE_FP_SSE |=0A- = XSTATE_COMPACTION_ENABLED;=0A+ v->arch.xsave_area->xsave_hd= r.xcomp_bv =3D 0;=0A }=0A }=0A else if ( v->arch.xsave_area= )=0A--- a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ = -2092,9 +2092,7 @@ static int hvm_load_cpu_ctxt(struct doma=0A =0A = memcpy(v->arch.xsave_area, ctxt.fpu_regs, sizeof(ctxt.fpu_regs));=0A = xsave_area->xsave_hdr.xstate_bv =3D XSTATE_FP_SSE;=0A- if ( = cpu_has_xsaves || cpu_has_xsavec )=0A- xsave_area->xsave_hdr.xco= mp_bv =3D XSTATE_FP_SSE |=0A- = XSTATE_COMPACTION_ENABLED;=0A+ xsave_area->xsave_hdr.xcomp_bv =3D = 0;=0A }=0A else=0A memcpy(v->arch.fpu_ctxt, ctxt.fpu_regs, = sizeof(ctxt.fpu_regs));=0A@@ -5562,9 +5560,7 @@ void hvm_vcpu_reset_state(s= truct vcpu *v=0A if ( v->arch.xsave_area )=0A {=0A = v->arch.xsave_area->xsave_hdr.xstate_bv =3D XSTATE_FP;=0A- if ( = cpu_has_xsaves || cpu_has_xsavec )=0A- v->arch.xsave_area->xsave= _hdr.xcomp_bv =3D XSTATE_FP |=0A- = XSTATE_COMPACTION_ENABLED;=0A+ v->arch.xsave_area->xsave_= hdr.xcomp_bv =3D 0;=0A }=0A =0A v->arch.vgc_flags =3D VGCF_online;= =0A--- a/xen/arch/x86/i387.c=0A+++ b/xen/arch/x86/i387.c=0A@@ -270,11 = +270,7 @@ int vcpu_init_fpu(struct vcpu *v)=0A return rc;=0A =0A = if ( v->arch.xsave_area )=0A- {=0A v->arch.fpu_ctxt =3D = &v->arch.xsave_area->fpu_sse;=0A- if ( cpu_has_xsaves || cpu_has_xsa= vec )=0A- v->arch.xsave_area->xsave_hdr.xcomp_bv =3D XSTATE_COMP= ACTION_ENABLED;=0A- }=0A else=0A {=0A v->arch.fpu_ctxt = =3D _xzalloc(sizeof(v->arch.xsave_area->fpu_sse), 16);=0A --=__Part0B3C22AE.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part0B3C22AE.2__=--