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