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 XFEATURE_MASK_EXTEND (~(XFEATURE_MASK_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 /* Supervisor features */ 22 #define XFEATURE_MASK_SUPERVISOR (XFEATURE_MASK_PT) 23 24 /* All currently supported features */ 25 #define XCNTXT_MASK (XFEATURE_MASK_FP | \ 26 XFEATURE_MASK_SSE | \ 27 XFEATURE_MASK_YMM | \ 28 XFEATURE_MASK_OPMASK | \ 29 XFEATURE_MASK_ZMM_Hi256 | \ 30 XFEATURE_MASK_Hi16_ZMM | \ 31 XFEATURE_MASK_PKRU | \ 32 XFEATURE_MASK_BNDREGS | \ 33 XFEATURE_MASK_BNDCSR) 34 35 #ifdef CONFIG_X86_64 36 #define REX_PREFIX "0x48, " 37 #else 38 #define REX_PREFIX 39 #endif 40 41 extern u64 xfeatures_mask; 42 extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS]; 43 44 extern void __init update_regset_xstate_info(unsigned int size, 45 u64 xstate_mask); 46 47 void fpu__xstate_clear_all_cpu_caps(void); 48 void *get_xsave_addr(struct xregs_state *xsave, int xstate); 49 const void *get_xsave_field_ptr(int xstate_field); 50 int using_compacted_format(void); 51 int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset, unsigned int size); 52 int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned int offset, unsigned int size); 53 int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf); 54 int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf); 55 56 /* Validate an xstate header supplied by userspace (ptrace or sigreturn) */ 57 extern int validate_xstate_header(const struct xstate_header *hdr); 58 59 #endif 60