All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Keir Fraser <keir@xen.org>,
	Shuai Ruan <shuai.ruan@linux.intel.com>
Subject: [PATCH] x86/xsave: simplify xcomp_bv initialization
Date: Thu, 17 Dec 2015 09:58:38 -0700	[thread overview]
Message-ID: <5672F7CE02000078000C0D8F@prv-mh.provo.novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2358 bytes --]

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 <jbeulich@suse.com>
---
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 = 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 = 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
 
         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 = 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 = 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 = 0;
     }
 
     v->arch.vgc_flags = 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;
 
     if ( v->arch.xsave_area )
-    {
         v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
-        if ( cpu_has_xsaves || cpu_has_xsavec )
-            v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED;
-    }
     else
     {
         v->arch.fpu_ctxt = _xzalloc(sizeof(v->arch.xsave_area->fpu_sse), 16);




[-- Attachment #2: x86-xcomp_bv-simplify.patch --]
[-- Type: text/plain, Size: 2399 bytes --]

x86/xsave: simplify xcomp_bv initialization

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 <jbeulich@suse.com>
---
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 = 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 = 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
 
         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 = 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 = 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 = 0;
     }
 
     v->arch.vgc_flags = 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;
 
     if ( v->arch.xsave_area )
-    {
         v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
-        if ( cpu_has_xsaves || cpu_has_xsavec )
-            v->arch.xsave_area->xsave_hdr.xcomp_bv = XSTATE_COMPACTION_ENABLED;
-    }
     else
     {
         v->arch.fpu_ctxt = _xzalloc(sizeof(v->arch.xsave_area->fpu_sse), 16);

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

             reply	other threads:[~2015-12-17 16:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 16:58 Jan Beulich [this message]
2015-12-17 17:46 ` [PATCH] x86/xsave: simplify xcomp_bv initialization Andrew Cooper
2015-12-18 10:53 ` Shuai Ruan
     [not found] ` <20151218105339.GA24875@shuai.ruan@linux.intel.com>
2015-12-18 11:09   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5672F7CE02000078000C0D8F@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=keir@xen.org \
    --cc=shuai.ruan@linux.intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.