/root/src/xen/xen/include/asm/xstate.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * include/asm-i386/xstate.h |
3 | | * |
4 | | * x86 extended state (xsave/xrstor) related definitions |
5 | | * |
6 | | */ |
7 | | |
8 | | #ifndef __ASM_XSTATE_H |
9 | | #define __ASM_XSTATE_H |
10 | | |
11 | | #include <xen/sched.h> |
12 | | #include <asm/cpufeature.h> |
13 | | |
14 | 24 | #define FCW_DEFAULT 0x037f |
15 | 11 | #define FCW_RESET 0x0040 |
16 | 35 | #define MXCSR_DEFAULT 0x1f80 |
17 | | |
18 | | extern uint32_t mxcsr_mask; |
19 | | |
20 | 105 | #define XSTATE_CPUID 0x0000000d |
21 | | |
22 | 1.20k | #define XCR_XFEATURE_ENABLED_MASK 0x00000000 /* index of XCR0 */ |
23 | | |
24 | 4 | #define XSAVE_HDR_SIZE 64 |
25 | 0 | #define XSAVE_SSE_OFFSET 160 |
26 | | #define XSTATE_YMM_SIZE 256 |
27 | 4 | #define FXSAVE_SIZE 512 |
28 | | #define XSAVE_HDR_OFFSET FXSAVE_SIZE |
29 | 4 | #define XSTATE_AREA_MIN_SIZE (FXSAVE_SIZE + XSAVE_HDR_SIZE) |
30 | | |
31 | 34.8k | #define _XSTATE_FP 0 |
32 | 34.8k | #define XSTATE_FP (1ULL << _XSTATE_FP) |
33 | 33.9k | #define _XSTATE_SSE 1 |
34 | 33.9k | #define XSTATE_SSE (1ULL << _XSTATE_SSE) |
35 | 27 | #define _XSTATE_YMM 2 |
36 | 27 | #define XSTATE_YMM (1ULL << _XSTATE_YMM) |
37 | 586 | #define _XSTATE_BNDREGS 3 |
38 | 586 | #define XSTATE_BNDREGS (1ULL << _XSTATE_BNDREGS) |
39 | 586 | #define _XSTATE_BNDCSR 4 |
40 | 586 | #define XSTATE_BNDCSR (1ULL << _XSTATE_BNDCSR) |
41 | 23 | #define _XSTATE_OPMASK 5 |
42 | 23 | #define XSTATE_OPMASK (1ULL << _XSTATE_OPMASK) |
43 | 23 | #define _XSTATE_ZMM 6 |
44 | 23 | #define XSTATE_ZMM (1ULL << _XSTATE_ZMM) |
45 | 23 | #define _XSTATE_HI_ZMM 7 |
46 | 23 | #define XSTATE_HI_ZMM (1ULL << _XSTATE_HI_ZMM) |
47 | 575 | #define _XSTATE_PKRU 9 |
48 | 575 | #define XSTATE_PKRU (1ULL << _XSTATE_PKRU) |
49 | 586 | #define _XSTATE_LWP 62 |
50 | 586 | #define XSTATE_LWP (1ULL << _XSTATE_LWP) |
51 | | |
52 | 71.5k | #define XSTATE_FP_SSE (XSTATE_FP | XSTATE_SSE) |
53 | 12 | #define XCNTXT_MASK (XSTATE_FP | XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | \ |
54 | 12 | XSTATE_ZMM | XSTATE_HI_ZMM | XSTATE_NONLAZY) |
55 | | |
56 | 552 | #define XSTATE_ALL (~(1ULL << 63)) |
57 | 586 | #define XSTATE_NONLAZY (XSTATE_LWP | XSTATE_BNDREGS | XSTATE_BNDCSR | \ |
58 | 575 | XSTATE_PKRU) |
59 | 828 | #define XSTATE_LAZY (XSTATE_ALL & ~XSTATE_NONLAZY) |
60 | 579 | #define XSTATE_XSAVES_ONLY 0 |
61 | 0 | #define XSTATE_COMPACTION_ENABLED (1ULL << 63) |
62 | | |
63 | 1 | #define XSTATE_ALIGN64 (1U << 1) |
64 | | |
65 | | extern u64 xfeature_mask; |
66 | | extern u64 xstate_align; |
67 | | extern unsigned int *xstate_offsets; |
68 | | extern unsigned int *xstate_sizes; |
69 | | |
70 | | /* extended state save area */ |
71 | | struct __attribute__((aligned (64))) xsave_struct |
72 | | { |
73 | | union __attribute__((aligned(16))) { /* FPU/MMX, SSE */ |
74 | | char x[512]; |
75 | | struct { |
76 | | uint16_t fcw; |
77 | | uint16_t fsw; |
78 | | uint8_t ftw; |
79 | | uint8_t rsvd1; |
80 | | uint16_t fop; |
81 | | union { |
82 | | uint64_t addr; |
83 | | struct { |
84 | | uint32_t offs; |
85 | | uint16_t sel; |
86 | | uint16_t rsvd; |
87 | | }; |
88 | | } fip, fdp; |
89 | | uint32_t mxcsr; |
90 | | uint32_t mxcsr_mask; |
91 | | /* data registers follow here */ |
92 | | }; |
93 | | } fpu_sse; |
94 | | |
95 | | struct xsave_hdr { |
96 | | u64 xstate_bv; |
97 | | u64 xcomp_bv; |
98 | | u64 reserved[6]; |
99 | | } xsave_hdr; /* The 64-byte header */ |
100 | | |
101 | | char data[]; /* Variable layout states */ |
102 | | }; |
103 | | |
104 | | struct xstate_bndcsr { |
105 | | uint64_t bndcfgu; |
106 | | uint64_t bndstatus; |
107 | | }; |
108 | | |
109 | | /* extended state operations */ |
110 | | bool __must_check set_xcr0(u64 xfeatures); |
111 | | uint64_t get_xcr0(void); |
112 | | void set_msr_xss(u64 xss); |
113 | | uint64_t get_msr_xss(void); |
114 | | uint64_t read_bndcfgu(void); |
115 | | void xsave(struct vcpu *v, uint64_t mask); |
116 | | void xrstor(struct vcpu *v, uint64_t mask); |
117 | | void xstate_set_init(uint64_t mask); |
118 | | bool xsave_enabled(const struct vcpu *v); |
119 | | int __must_check validate_xstate(u64 xcr0, u64 xcr0_accum, |
120 | | const struct xsave_hdr *); |
121 | | int __must_check handle_xsetbv(u32 index, u64 new_bv); |
122 | | void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size); |
123 | | void compress_xsave_states(struct vcpu *v, const void *src, unsigned int size); |
124 | | |
125 | | /* extended state init and cleanup functions */ |
126 | | void xstate_free_save_area(struct vcpu *v); |
127 | | int xstate_alloc_save_area(struct vcpu *v); |
128 | | void xstate_init(struct cpuinfo_x86 *c); |
129 | | unsigned int xstate_ctxt_size(u64 xcr0); |
130 | | |
131 | | static inline bool xstate_all(const struct vcpu *v) |
132 | 0 | { |
133 | 0 | /* |
134 | 0 | * XSTATE_FP_SSE may be excluded, because the offsets of XSTATE_FP_SSE |
135 | 0 | * (in the legacy region of xsave area) are fixed, so saving |
136 | 0 | * XSTATE_FP_SSE will not cause overwriting problem with XSAVES/XSAVEC. |
137 | 0 | */ |
138 | 0 | return (v->arch.xsave_area->xsave_hdr.xcomp_bv & |
139 | 0 | XSTATE_COMPACTION_ENABLED) && |
140 | 0 | (v->arch.xcr0_accum & XSTATE_LAZY & ~XSTATE_FP_SSE); |
141 | 0 | } Unexecuted instantiation: cpuid.c:xstate_all Unexecuted instantiation: domctl.c:xstate_all Unexecuted instantiation: domain.c:xstate_all Unexecuted instantiation: i387.c:xstate_all Unexecuted instantiation: traps.c:xstate_all Unexecuted instantiation: x86_emulate.c:xstate_all Unexecuted instantiation: xstate.c:xstate_all Unexecuted instantiation: suspend.c:xstate_all Unexecuted instantiation: common.c:xstate_all Unexecuted instantiation: emulate.c:xstate_all Unexecuted instantiation: hvm.c:xstate_all Unexecuted instantiation: svm.c:xstate_all Unexecuted instantiation: vmcs.c:xstate_all |
142 | | |
143 | | static inline bool __nonnull(1) |
144 | | xsave_area_compressed(const struct xsave_struct *xsave_area) |
145 | 0 | { |
146 | 0 | return xsave_area->xsave_hdr.xcomp_bv & XSTATE_COMPACTION_ENABLED; |
147 | 0 | } Unexecuted instantiation: cpuid.c:xsave_area_compressed Unexecuted instantiation: domctl.c:xsave_area_compressed Unexecuted instantiation: domain.c:xsave_area_compressed Unexecuted instantiation: i387.c:xsave_area_compressed Unexecuted instantiation: traps.c:xsave_area_compressed Unexecuted instantiation: x86_emulate.c:xsave_area_compressed Unexecuted instantiation: xstate.c:xsave_area_compressed Unexecuted instantiation: suspend.c:xsave_area_compressed Unexecuted instantiation: common.c:xsave_area_compressed Unexecuted instantiation: emulate.c:xsave_area_compressed Unexecuted instantiation: hvm.c:xsave_area_compressed Unexecuted instantiation: svm.c:xsave_area_compressed Unexecuted instantiation: vmcs.c:xsave_area_compressed |
148 | | |
149 | | #endif /* __ASM_XSTATE_H */ |