aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/xstate.h
diff options
context:
space:
mode:
authorWei Huang <wei.huang2@amd.com>2011-05-09 11:37:03 +0100
committerWei Huang <wei.huang2@amd.com>2011-05-09 11:37:03 +0100
commite39609c4502b7abab4133f77587084047a6c3e79 (patch)
tree6d720a443a479fd902afad778222c94876afca96 /xen/include/asm-x86/xstate.h
parentf94fcdbf7f4946952f9c22af307b10b088724a15 (diff)
downloadxen-e39609c4502b7abab4133f77587084047a6c3e79.tar.gz
xen-e39609c4502b7abab4133f77587084047a6c3e79.tar.bz2
xen-e39609c4502b7abab4133f77587084047a6c3e79.zip
x86/fpu: extract extended related code into xstate.h and xstate.c
Current extended code is mixing with FPU code in i387.c. As part of FPU code cleanup, this patch moves all extended state code into independent files. Not much semantic are changed and most function names are kept untouched, except for xsave() and xsaveopt(). These two functions are combined into a single function. Signed-off-by: Wei Huang <wei.huang2@amd.com>
Diffstat (limited to 'xen/include/asm-x86/xstate.h')
-rw-r--r--xen/include/asm-x86/xstate.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/xen/include/asm-x86/xstate.h b/xen/include/asm-x86/xstate.h
new file mode 100644
index 0000000000..a0677173fd
--- /dev/null
+++ b/xen/include/asm-x86/xstate.h
@@ -0,0 +1,68 @@
+/*
+ * include/asm-i386/xstate.h
+ *
+ * x86 extended state (xsave/xrstor) related definitions
+ *
+ */
+
+#ifndef __ASM_XSTATE_H
+#define __ASM_XSTATE_H
+
+#include <xen/types.h>
+#include <xen/percpu.h>
+
+#define XSTATE_CPUID 0x0000000d
+#define XSTATE_FEATURE_XSAVEOPT (1 << 0) /* sub-leaf 1, eax[bit 0] */
+
+#define XCR_XFEATURE_ENABLED_MASK 0x00000000 /* index of XCR0 */
+
+#define XSTATE_YMM_SIZE 256
+#define XSTATE_YMM_OFFSET XSAVE_AREA_MIN_SIZE
+#define XSTATE_AREA_MIN_SIZE (512 + 64) /* FP/SSE + XSAVE.HEADER */
+
+#define XSTATE_FP (1ULL << 0)
+#define XSTATE_SSE (1ULL << 1)
+#define XSTATE_YMM (1ULL << 2)
+#define XSTATE_LWP (1ULL << 62) /* AMD lightweight profiling */
+#define XSTATE_FP_SSE (XSTATE_FP | XSTATE_SSE)
+#define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_LWP)
+
+#ifdef CONFIG_X86_64
+#define REX_PREFIX "0x48, "
+#else
+#define REX_PREFIX
+#endif
+
+/* extended state variables */
+DECLARE_PER_CPU(uint64_t, xcr0);
+
+extern unsigned int xsave_cntxt_size;
+extern u64 xfeature_mask;
+
+/* extended state save area */
+struct xsave_struct
+{
+ struct { char x[512]; } fpu_sse; /* FPU/MMX, SSE */
+
+ struct {
+ u64 xstate_bv;
+ u64 reserved[7];
+ } xsave_hdr; /* The 64-byte header */
+
+ struct { char x[XSTATE_YMM_SIZE]; } ymm; /* YMM */
+ char data[]; /* Future new states */
+} __attribute__ ((packed, aligned (64)));
+
+/* extended state operations */
+void set_xcr0(u64 xfeatures);
+uint64_t get_xcr0(void);
+void xsave(struct vcpu *v);
+void xrstor(struct vcpu *v);
+bool_t xsave_enabled(const struct vcpu *v);
+
+/* extended state init and cleanup functions */
+void xstate_free_save_area(struct vcpu *v);
+int xstate_alloc_save_area(struct vcpu *v);
+void xstate_init(void);
+
+#endif /* __ASM_XSTATE_H */