All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/xsave: Expose xsave_cntxt_size to avoid reloading xcr0
@ 2014-06-04 11:56 Andrew Cooper
  2014-06-04 12:32 ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2014-06-04 11:56 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Keir Fraser, Jan Beulich

xstate_ctxt_size(xfeature_mask) is runtime constant after boot.  There is no
need to reload xcr0 twice for this basic bounds check.  Also annotate
xfeature_mask as __read_mostly as it is only ever written once.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/domctl.c        |    3 +--
 xen/arch/x86/xstate.c        |    4 ++--
 xen/include/asm-x86/xstate.h |    1 +
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 8f5b287..75b0522 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1145,8 +1145,7 @@ long arch_do_domctl(
 
             ret = -EINVAL;
             if ( evc->size < 2 * sizeof(uint64_t) ||
-                 evc->size > 2 * sizeof(uint64_t) +
-                             xstate_ctxt_size(xfeature_mask) )
+                 evc->size > 2 * sizeof(uint64_t) + xsave_cntxt_size )
                 goto vcpuextstate_out;
 
             receive_buf = xmalloc_bytes(evc->size);
diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index e202344..86ea244 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -21,10 +21,10 @@ bool_t __read_mostly cpu_has_xsaveopt;
  * the supported and enabled features on the processor, including the
  * XSAVE.HEADER. We only enable XCNTXT_MASK that we have known.
  */
-static u32 __read_mostly xsave_cntxt_size;
+u32 __read_mostly xsave_cntxt_size;
 
 /* A 64-bit bitmask of the XSAVE/XRSTOR features supported by processor. */
-u64 xfeature_mask;
+u64 __read_mostly xfeature_mask;
 
 /* Cached xcr0 for fast read */
 static DEFINE_PER_CPU(uint64_t, xcr0);
diff --git a/xen/include/asm-x86/xstate.h b/xen/include/asm-x86/xstate.h
index 8d21349..e0abeef 100644
--- a/xen/include/asm-x86/xstate.h
+++ b/xen/include/asm-x86/xstate.h
@@ -39,6 +39,7 @@
 #define XSTATE_NONLAZY (XSTATE_LWP | XSTATE_BNDREGS | XSTATE_BNDCSR)
 #define XSTATE_LAZY    (XSTATE_ALL & ~XSTATE_NONLAZY)
 
+extern u32 xsave_cntxt_size;
 extern u64 xfeature_mask;
 
 /* extended state save area */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-04 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04 11:56 [PATCH] x86/xsave: Expose xsave_cntxt_size to avoid reloading xcr0 Andrew Cooper
2014-06-04 12:32 ` Jan Beulich
2014-06-04 12:39   ` Andrew Cooper
2014-06-04 12:48     ` Jan Beulich

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.