xref: /openbmc/linux/arch/x86/include/asm/fpu/xstate.h (revision ca55b2fe)
1 #ifndef __ASM_X86_XSAVE_H
2 #define __ASM_X86_XSAVE_H
3 
4 #include <linux/types.h>
5 #include <asm/processor.h>
6 #include <linux/uaccess.h>
7 
8 /* Bit 63 of XCR0 is reserved for future expansion */
9 #define XSTATE_EXTEND_MASK	(~(XSTATE_FPSSE | (1ULL << 63)))
10 
11 #define XSTATE_CPUID		0x0000000d
12 
13 #define FXSAVE_SIZE	512
14 
15 #define XSAVE_HDR_SIZE	    64
16 #define XSAVE_HDR_OFFSET    FXSAVE_SIZE
17 
18 #define XSAVE_YMM_SIZE	    256
19 #define XSAVE_YMM_OFFSET    (XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET)
20 
21 /* Supported features which support lazy state saving */
22 #define XSTATE_LAZY	(XSTATE_FP | XSTATE_SSE | XSTATE_YMM		      \
23 			| XSTATE_OPMASK | XSTATE_ZMM_Hi256 | XSTATE_Hi16_ZMM)
24 
25 /* Supported features which require eager state saving */
26 #define XSTATE_EAGER	(XSTATE_BNDREGS | XSTATE_BNDCSR)
27 
28 /* All currently supported features */
29 #define XCNTXT_MASK	(XSTATE_LAZY | XSTATE_EAGER)
30 
31 #ifdef CONFIG_X86_64
32 #define REX_PREFIX	"0x48, "
33 #else
34 #define REX_PREFIX
35 #endif
36 
37 extern unsigned int xstate_size;
38 extern u64 xfeatures_mask;
39 extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
40 
41 extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
42 
43 void *get_xsave_addr(struct xregs_state *xsave, int xstate);
44 const void *get_xsave_field_ptr(int xstate_field);
45 
46 #endif
47