aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/i387.h
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2010-12-17 09:25:00 +0000
committerKeir Fraser <keir@xen.org>2010-12-17 09:25:00 +0000
commitee8ac49677904c14b69b7fe65d79b57af964edc5 (patch)
tree4f2cb3e3431c568770c57b27dff78d67ad03a2e6 /xen/include/asm-x86/i387.h
parent5ec363dfe9654d3be6d3e9a0105ebe53577913fe (diff)
downloadxen-ee8ac49677904c14b69b7fe65d79b57af964edc5.tar.gz
xen-ee8ac49677904c14b69b7fe65d79b57af964edc5.tar.bz2
xen-ee8ac49677904c14b69b7fe65d79b57af964edc5.zip
x86:xsaveopt: Enable xsaveopt feature in Xen and guest
This patch uses "xsaveopt" instead of "xsave" if the feature is supported in hardware to optimize task switch performance in Xen. It also exposes the feature to guest VMs. Signed-off-by: Zhang Fengzhe <fengzhe.zhang@intel.com>
Diffstat (limited to 'xen/include/asm-x86/i387.h')
-rw-r--r--xen/include/asm-x86/i387.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/xen/include/asm-x86/i387.h b/xen/include/asm-x86/i387.h
index 0e01d1604d..471747c7c4 100644
--- a/xen/include/asm-x86/i387.h
+++ b/xen/include/asm-x86/i387.h
@@ -16,6 +16,7 @@
extern unsigned int xsave_cntxt_size;
extern u64 xfeature_mask;
+extern bool_t cpu_has_xsaveopt;
void xsave_init(void);
int xsave_alloc_save_area(struct vcpu *v);
@@ -28,6 +29,7 @@ void xsave_free_save_area(struct vcpu *v);
#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
#define XSTATE_YMM_OFFSET (512 + 64)
#define XSTATE_YMM_SIZE 256
+#define XSAVEOPT (1 << 0)
struct xsave_struct
{
@@ -84,6 +86,18 @@ static inline void xsave(struct vcpu *v)
: "memory");
}
+static inline void xsaveopt(struct vcpu *v)
+{
+ struct xsave_struct *ptr;
+
+ ptr =(struct xsave_struct *)v->arch.xsave_area;
+
+ asm volatile (".byte " REX_PREFIX "0x0f,0xae,0x37"
+ :
+ : "a" (-1), "d" (-1), "D"(ptr)
+ : "memory");
+}
+
static inline void xrstor(struct vcpu *v)
{
struct xsave_struct *ptr;