xref: /OK3568_Linux_fs/kernel/arch/x86/include/asm/user.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _ASM_X86_USER_H
3*4882a593Smuzhiyun #define _ASM_X86_USER_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #ifdef CONFIG_X86_32
6*4882a593Smuzhiyun # include <asm/user_32.h>
7*4882a593Smuzhiyun #else
8*4882a593Smuzhiyun # include <asm/user_64.h>
9*4882a593Smuzhiyun #endif
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <asm/types.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun struct user_ymmh_regs {
14*4882a593Smuzhiyun 	/* 16 * 16 bytes for each YMMH-reg */
15*4882a593Smuzhiyun 	__u32 ymmh_space[64];
16*4882a593Smuzhiyun };
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun struct user_xstate_header {
19*4882a593Smuzhiyun 	__u64 xfeatures;
20*4882a593Smuzhiyun 	__u64 reserved1[2];
21*4882a593Smuzhiyun 	__u64 reserved2[5];
22*4882a593Smuzhiyun };
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  * The structure layout of user_xstateregs, used for exporting the
26*4882a593Smuzhiyun  * extended register state through ptrace and core-dump (NT_X86_XSTATE note)
27*4882a593Smuzhiyun  * interfaces will be same as the memory layout of xsave used by the processor
28*4882a593Smuzhiyun  * (except for the bytes 464..511, which can be used by the software) and hence
29*4882a593Smuzhiyun  * the size of this structure varies depending on the features supported by the
30*4882a593Smuzhiyun  * processor and OS. The size of the structure that users need to use can be
31*4882a593Smuzhiyun  * obtained by doing:
32*4882a593Smuzhiyun  *     cpuid_count(0xd, 0, &eax, &ptrace_xstateregs_struct_size, &ecx, &edx);
33*4882a593Smuzhiyun  * i.e., cpuid.(eax=0xd,ecx=0).ebx will be the size that user (debuggers, etc.)
34*4882a593Smuzhiyun  * need to use.
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * For now, only the first 8 bytes of the software usable bytes[464..471] will
37*4882a593Smuzhiyun  * be used and will be set to OS enabled xstate mask (which is same as the
38*4882a593Smuzhiyun  * 64bit mask returned by the xgetbv's xCR0).  Users (analyzing core dump
39*4882a593Smuzhiyun  * remotely, etc.) can use this mask as well as the mask saved in the
40*4882a593Smuzhiyun  * xstate_hdr bytes and interpret what states the processor/OS supports
41*4882a593Smuzhiyun  * and what states are in modified/initialized conditions for the
42*4882a593Smuzhiyun  * particular process/thread.
43*4882a593Smuzhiyun  *
44*4882a593Smuzhiyun  * Also when the user modifies certain state FP/SSE/etc through the
45*4882a593Smuzhiyun  * ptrace interface, they must ensure that the header.xfeatures
46*4882a593Smuzhiyun  * bytes[512..519] of the memory layout are updated correspondingly.
47*4882a593Smuzhiyun  * i.e., for example when FP state is modified to a non-init state,
48*4882a593Smuzhiyun  * header.xfeatures's bit 0 must be set to '1', when SSE is modified to
49*4882a593Smuzhiyun  * non-init state, header.xfeatures's bit 1 must to be set to '1', etc.
50*4882a593Smuzhiyun  */
51*4882a593Smuzhiyun #define USER_XSTATE_FX_SW_WORDS 6
52*4882a593Smuzhiyun #define USER_XSTATE_XCR0_WORD	0
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun struct user_xstateregs {
55*4882a593Smuzhiyun 	struct {
56*4882a593Smuzhiyun 		__u64 fpx_space[58];
57*4882a593Smuzhiyun 		__u64 xstate_fx_sw[USER_XSTATE_FX_SW_WORDS];
58*4882a593Smuzhiyun 	} i387;
59*4882a593Smuzhiyun 	struct user_xstate_header header;
60*4882a593Smuzhiyun 	struct user_ymmh_regs ymmh;
61*4882a593Smuzhiyun 	/* further processor state extensions go here */
62*4882a593Smuzhiyun };
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun #endif /* _ASM_X86_USER_H */
65