1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_X86_XSAVE_H
3 #define __ASM_X86_XSAVE_H
5 #include <linux/uaccess.h>
6 #include <linux/types.h>
8 #include <asm/processor.h>
11 /* Bit 63 of XCR0 is reserved for future expansion */
12 #define XFEATURE_MASK_EXTEND (~(XFEATURE_MASK_FPSSE | (1ULL << 63)))
14 #define XSTATE_CPUID 0x0000000d
16 #define FXSAVE_SIZE 512
18 #define XSAVE_HDR_SIZE 64
19 #define XSAVE_HDR_OFFSET FXSAVE_SIZE
21 #define XSAVE_YMM_SIZE 256
22 #define XSAVE_YMM_OFFSET (XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET)
24 /* Supervisor features */
25 #define XFEATURE_MASK_SUPERVISOR (XFEATURE_MASK_PT)
27 /* All currently supported features */
28 #define XCNTXT_MASK (XFEATURE_MASK_FP | \
31 XFEATURE_MASK_OPMASK | \
32 XFEATURE_MASK_ZMM_Hi256 | \
33 XFEATURE_MASK_Hi16_ZMM | \
34 XFEATURE_MASK_PKRU | \
35 XFEATURE_MASK_BNDREGS | \
39 #define REX_PREFIX "0x48, "
44 extern u64 xfeatures_mask
;
45 extern u64 xstate_fx_sw_bytes
[USER_XSTATE_FX_SW_WORDS
];
47 extern void __init
update_regset_xstate_info(unsigned int size
,
50 void *get_xsave_addr(struct xregs_state
*xsave
, int xfeature_nr
);
51 const void *get_xsave_field_ptr(int xfeature_nr
);
52 int using_compacted_format(void);
53 int copy_xstate_to_kernel(void *kbuf
, struct xregs_state
*xsave
, unsigned int offset
, unsigned int size
);
54 int copy_xstate_to_user(void __user
*ubuf
, struct xregs_state
*xsave
, unsigned int offset
, unsigned int size
);
55 int copy_kernel_to_xstate(struct xregs_state
*xsave
, const void *kbuf
);
56 int copy_user_to_xstate(struct xregs_state
*xsave
, const void __user
*ubuf
);
58 /* Validate an xstate header supplied by userspace (ptrace or sigreturn) */
59 extern int validate_xstate_header(const struct xstate_header
*hdr
);