18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci#ifndef _UAPI_ASM_X86_SIGCONTEXT_H 38c2ecf20Sopenharmony_ci#define _UAPI_ASM_X86_SIGCONTEXT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Linux signal context definitions. The sigcontext includes a complex 78c2ecf20Sopenharmony_ci * hierarchy of CPU and FPU state, available to user-space (on the stack) when 88c2ecf20Sopenharmony_ci * a signal handler is executed. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * As over the years this ABI grew from its very simple roots towards 118c2ecf20Sopenharmony_ci * supporting more and more CPU state organically, some of the details (which 128c2ecf20Sopenharmony_ci * were rather clever hacks back in the days) became a bit quirky by today. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * The current ABI includes flexible provisions for future extensions, so we 158c2ecf20Sopenharmony_ci * won't have to grow new quirks for quite some time. Promise! 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/compiler.h> 198c2ecf20Sopenharmony_ci#include <linux/types.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define FP_XSTATE_MAGIC1 0x46505853U 228c2ecf20Sopenharmony_ci#define FP_XSTATE_MAGIC2 0x46505845U 238c2ecf20Sopenharmony_ci#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame 278c2ecf20Sopenharmony_ci * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes are 288c2ecf20Sopenharmony_ci * used to extend the fpstate pointer in the sigcontext, which now includes the 298c2ecf20Sopenharmony_ci * extended state information along with fpstate information. 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a 328c2ecf20Sopenharmony_ci * sw_reserved.extended_size bytes large extended context area present. (The 338c2ecf20Sopenharmony_ci * last 32-bit word of this extended area (at the 348c2ecf20Sopenharmony_ci * fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to 358c2ecf20Sopenharmony_ci * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.) 368c2ecf20Sopenharmony_ci * 378c2ecf20Sopenharmony_ci * This extended area typically grows with newer CPUs that have larger and 388c2ecf20Sopenharmony_ci * larger XSAVE areas. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_cistruct _fpx_sw_bytes { 418c2ecf20Sopenharmony_ci /* 428c2ecf20Sopenharmony_ci * If set to FP_XSTATE_MAGIC1 then this is an xstate context. 438c2ecf20Sopenharmony_ci * 0 if a legacy frame. 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci __u32 magic1; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci /* 488c2ecf20Sopenharmony_ci * Total size of the fpstate area: 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * - if magic1 == 0 then it's sizeof(struct _fpstate) 518c2ecf20Sopenharmony_ci * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) 528c2ecf20Sopenharmony_ci * plus extensions (if any) 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci __u32 extended_size; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* 578c2ecf20Sopenharmony_ci * Feature bit mask (including FP/SSE/extended state) that is present 588c2ecf20Sopenharmony_ci * in the memory layout: 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci __u64 xfeatures; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* 638c2ecf20Sopenharmony_ci * Actual XSAVE state size, based on the xfeatures saved in the layout. 648c2ecf20Sopenharmony_ci * 'extended_size' is greater than 'xstate_size': 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci __u32 xstate_size; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci /* For future use: */ 698c2ecf20Sopenharmony_ci __u32 padding[7]; 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* 738c2ecf20Sopenharmony_ci * As documented in the iBCS2 standard: 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * The first part of "struct _fpstate" is just the normal i387 hardware setup, 768c2ecf20Sopenharmony_ci * the extra "status" word is used to save the coprocessor status word before 778c2ecf20Sopenharmony_ci * entering the handler. 788c2ecf20Sopenharmony_ci * 798c2ecf20Sopenharmony_ci * The FPU state data structure has had to grow to accommodate the extended FPU 808c2ecf20Sopenharmony_ci * state required by the Streaming SIMD Extensions. There is no documented 818c2ecf20Sopenharmony_ci * standard to accomplish this at the moment. 828c2ecf20Sopenharmony_ci */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* 10-byte legacy floating point register: */ 858c2ecf20Sopenharmony_cistruct _fpreg { 868c2ecf20Sopenharmony_ci __u16 significand[4]; 878c2ecf20Sopenharmony_ci __u16 exponent; 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* 16-byte floating point register: */ 918c2ecf20Sopenharmony_cistruct _fpxreg { 928c2ecf20Sopenharmony_ci __u16 significand[4]; 938c2ecf20Sopenharmony_ci __u16 exponent; 948c2ecf20Sopenharmony_ci __u16 padding[3]; 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* 16-byte XMM register: */ 988c2ecf20Sopenharmony_cistruct _xmmreg { 998c2ecf20Sopenharmony_ci __u32 element[4]; 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define X86_FXSR_MAGIC 0x0000 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* 1058c2ecf20Sopenharmony_ci * The 32-bit FPU frame: 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_cistruct _fpstate_32 { 1088c2ecf20Sopenharmony_ci /* Legacy FPU environment: */ 1098c2ecf20Sopenharmony_ci __u32 cw; 1108c2ecf20Sopenharmony_ci __u32 sw; 1118c2ecf20Sopenharmony_ci __u32 tag; 1128c2ecf20Sopenharmony_ci __u32 ipoff; 1138c2ecf20Sopenharmony_ci __u32 cssel; 1148c2ecf20Sopenharmony_ci __u32 dataoff; 1158c2ecf20Sopenharmony_ci __u32 datasel; 1168c2ecf20Sopenharmony_ci struct _fpreg _st[8]; 1178c2ecf20Sopenharmony_ci __u16 status; 1188c2ecf20Sopenharmony_ci __u16 magic; /* 0xffff: regular FPU data only */ 1198c2ecf20Sopenharmony_ci /* 0x0000: FXSR FPU data */ 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci /* FXSR FPU environment */ 1228c2ecf20Sopenharmony_ci __u32 _fxsr_env[6]; /* FXSR FPU env is ignored */ 1238c2ecf20Sopenharmony_ci __u32 mxcsr; 1248c2ecf20Sopenharmony_ci __u32 reserved; 1258c2ecf20Sopenharmony_ci struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ 1268c2ecf20Sopenharmony_ci struct _xmmreg _xmm[8]; /* First 8 XMM registers */ 1278c2ecf20Sopenharmony_ci union { 1288c2ecf20Sopenharmony_ci __u32 padding1[44]; /* Second 8 XMM registers plus padding */ 1298c2ecf20Sopenharmony_ci __u32 padding[44]; /* Alias name for old user-space */ 1308c2ecf20Sopenharmony_ci }; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci union { 1338c2ecf20Sopenharmony_ci __u32 padding2[12]; 1348c2ecf20Sopenharmony_ci struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ 1358c2ecf20Sopenharmony_ci }; 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci/* 1398c2ecf20Sopenharmony_ci * The 64-bit FPU frame. (FXSAVE format and later) 1408c2ecf20Sopenharmony_ci * 1418c2ecf20Sopenharmony_ci * Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is 1428c2ecf20Sopenharmony_ci * larger: 'struct _xstate'. Note that 'struct _xstate' embedds 1438c2ecf20Sopenharmony_ci * 'struct _fpstate' so that you can always assume the _fpstate portion 1448c2ecf20Sopenharmony_ci * exists so that you can check the magic value. 1458c2ecf20Sopenharmony_ci * 1468c2ecf20Sopenharmony_ci * Note2: Reserved fields may someday contain valuable data. Always 1478c2ecf20Sopenharmony_ci * save/restore them when you change signal frames. 1488c2ecf20Sopenharmony_ci */ 1498c2ecf20Sopenharmony_cistruct _fpstate_64 { 1508c2ecf20Sopenharmony_ci __u16 cwd; 1518c2ecf20Sopenharmony_ci __u16 swd; 1528c2ecf20Sopenharmony_ci /* Note this is not the same as the 32-bit/x87/FSAVE twd: */ 1538c2ecf20Sopenharmony_ci __u16 twd; 1548c2ecf20Sopenharmony_ci __u16 fop; 1558c2ecf20Sopenharmony_ci __u64 rip; 1568c2ecf20Sopenharmony_ci __u64 rdp; 1578c2ecf20Sopenharmony_ci __u32 mxcsr; 1588c2ecf20Sopenharmony_ci __u32 mxcsr_mask; 1598c2ecf20Sopenharmony_ci __u32 st_space[32]; /* 8x FP registers, 16 bytes each */ 1608c2ecf20Sopenharmony_ci __u32 xmm_space[64]; /* 16x XMM registers, 16 bytes each */ 1618c2ecf20Sopenharmony_ci __u32 reserved2[12]; 1628c2ecf20Sopenharmony_ci union { 1638c2ecf20Sopenharmony_ci __u32 reserved3[12]; 1648c2ecf20Sopenharmony_ci struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ 1658c2ecf20Sopenharmony_ci }; 1668c2ecf20Sopenharmony_ci}; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci#ifdef __i386__ 1698c2ecf20Sopenharmony_ci# define _fpstate _fpstate_32 1708c2ecf20Sopenharmony_ci#else 1718c2ecf20Sopenharmony_ci# define _fpstate _fpstate_64 1728c2ecf20Sopenharmony_ci#endif 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistruct _header { 1758c2ecf20Sopenharmony_ci __u64 xfeatures; 1768c2ecf20Sopenharmony_ci __u64 reserved1[2]; 1778c2ecf20Sopenharmony_ci __u64 reserved2[5]; 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_cistruct _ymmh_state { 1818c2ecf20Sopenharmony_ci /* 16x YMM registers, 16 bytes each: */ 1828c2ecf20Sopenharmony_ci __u32 ymmh_space[64]; 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* 1868c2ecf20Sopenharmony_ci * Extended state pointed to by sigcontext::fpstate. 1878c2ecf20Sopenharmony_ci * 1888c2ecf20Sopenharmony_ci * In addition to the fpstate, information encoded in _xstate::xstate_hdr 1898c2ecf20Sopenharmony_ci * indicates the presence of other extended state information supported 1908c2ecf20Sopenharmony_ci * by the CPU and kernel: 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_cistruct _xstate { 1938c2ecf20Sopenharmony_ci struct _fpstate fpstate; 1948c2ecf20Sopenharmony_ci struct _header xstate_hdr; 1958c2ecf20Sopenharmony_ci struct _ymmh_state ymmh; 1968c2ecf20Sopenharmony_ci /* New processor state extensions go here: */ 1978c2ecf20Sopenharmony_ci}; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* 2008c2ecf20Sopenharmony_ci * The 32-bit signal frame: 2018c2ecf20Sopenharmony_ci */ 2028c2ecf20Sopenharmony_cistruct sigcontext_32 { 2038c2ecf20Sopenharmony_ci __u16 gs, __gsh; 2048c2ecf20Sopenharmony_ci __u16 fs, __fsh; 2058c2ecf20Sopenharmony_ci __u16 es, __esh; 2068c2ecf20Sopenharmony_ci __u16 ds, __dsh; 2078c2ecf20Sopenharmony_ci __u32 di; 2088c2ecf20Sopenharmony_ci __u32 si; 2098c2ecf20Sopenharmony_ci __u32 bp; 2108c2ecf20Sopenharmony_ci __u32 sp; 2118c2ecf20Sopenharmony_ci __u32 bx; 2128c2ecf20Sopenharmony_ci __u32 dx; 2138c2ecf20Sopenharmony_ci __u32 cx; 2148c2ecf20Sopenharmony_ci __u32 ax; 2158c2ecf20Sopenharmony_ci __u32 trapno; 2168c2ecf20Sopenharmony_ci __u32 err; 2178c2ecf20Sopenharmony_ci __u32 ip; 2188c2ecf20Sopenharmony_ci __u16 cs, __csh; 2198c2ecf20Sopenharmony_ci __u32 flags; 2208c2ecf20Sopenharmony_ci __u32 sp_at_signal; 2218c2ecf20Sopenharmony_ci __u16 ss, __ssh; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci /* 2248c2ecf20Sopenharmony_ci * fpstate is really (struct _fpstate *) or (struct _xstate *) 2258c2ecf20Sopenharmony_ci * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved 2268c2ecf20Sopenharmony_ci * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end 2278c2ecf20Sopenharmony_ci * of extended memory layout. See comments at the definition of 2288c2ecf20Sopenharmony_ci * (struct _fpx_sw_bytes) 2298c2ecf20Sopenharmony_ci */ 2308c2ecf20Sopenharmony_ci __u32 fpstate; /* Zero when no FPU/extended context */ 2318c2ecf20Sopenharmony_ci __u32 oldmask; 2328c2ecf20Sopenharmony_ci __u32 cr2; 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci/* 2368c2ecf20Sopenharmony_ci * The 64-bit signal frame: 2378c2ecf20Sopenharmony_ci */ 2388c2ecf20Sopenharmony_cistruct sigcontext_64 { 2398c2ecf20Sopenharmony_ci __u64 r8; 2408c2ecf20Sopenharmony_ci __u64 r9; 2418c2ecf20Sopenharmony_ci __u64 r10; 2428c2ecf20Sopenharmony_ci __u64 r11; 2438c2ecf20Sopenharmony_ci __u64 r12; 2448c2ecf20Sopenharmony_ci __u64 r13; 2458c2ecf20Sopenharmony_ci __u64 r14; 2468c2ecf20Sopenharmony_ci __u64 r15; 2478c2ecf20Sopenharmony_ci __u64 di; 2488c2ecf20Sopenharmony_ci __u64 si; 2498c2ecf20Sopenharmony_ci __u64 bp; 2508c2ecf20Sopenharmony_ci __u64 bx; 2518c2ecf20Sopenharmony_ci __u64 dx; 2528c2ecf20Sopenharmony_ci __u64 ax; 2538c2ecf20Sopenharmony_ci __u64 cx; 2548c2ecf20Sopenharmony_ci __u64 sp; 2558c2ecf20Sopenharmony_ci __u64 ip; 2568c2ecf20Sopenharmony_ci __u64 flags; 2578c2ecf20Sopenharmony_ci __u16 cs; 2588c2ecf20Sopenharmony_ci __u16 gs; 2598c2ecf20Sopenharmony_ci __u16 fs; 2608c2ecf20Sopenharmony_ci __u16 ss; 2618c2ecf20Sopenharmony_ci __u64 err; 2628c2ecf20Sopenharmony_ci __u64 trapno; 2638c2ecf20Sopenharmony_ci __u64 oldmask; 2648c2ecf20Sopenharmony_ci __u64 cr2; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* 2678c2ecf20Sopenharmony_ci * fpstate is really (struct _fpstate *) or (struct _xstate *) 2688c2ecf20Sopenharmony_ci * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved 2698c2ecf20Sopenharmony_ci * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end 2708c2ecf20Sopenharmony_ci * of extended memory layout. See comments at the definition of 2718c2ecf20Sopenharmony_ci * (struct _fpx_sw_bytes) 2728c2ecf20Sopenharmony_ci */ 2738c2ecf20Sopenharmony_ci __u64 fpstate; /* Zero when no FPU/extended context */ 2748c2ecf20Sopenharmony_ci __u64 reserved1[8]; 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci/* 2788c2ecf20Sopenharmony_ci * Create the real 'struct sigcontext' type: 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 2818c2ecf20Sopenharmony_ci# ifdef __i386__ 2828c2ecf20Sopenharmony_ci# define sigcontext sigcontext_32 2838c2ecf20Sopenharmony_ci# else 2848c2ecf20Sopenharmony_ci# define sigcontext sigcontext_64 2858c2ecf20Sopenharmony_ci# endif 2868c2ecf20Sopenharmony_ci#endif 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci/* 2898c2ecf20Sopenharmony_ci * The old user-space sigcontext definition, just in case user-space still 2908c2ecf20Sopenharmony_ci * relies on it. The kernel definition (in asm/sigcontext.h) has unified 2918c2ecf20Sopenharmony_ci * field names but otherwise the same layout. 2928c2ecf20Sopenharmony_ci */ 2938c2ecf20Sopenharmony_ci#ifndef __KERNEL__ 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci#define _fpstate_ia32 _fpstate_32 2968c2ecf20Sopenharmony_ci#define sigcontext_ia32 sigcontext_32 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci# ifdef __i386__ 3008c2ecf20Sopenharmony_cistruct sigcontext { 3018c2ecf20Sopenharmony_ci __u16 gs, __gsh; 3028c2ecf20Sopenharmony_ci __u16 fs, __fsh; 3038c2ecf20Sopenharmony_ci __u16 es, __esh; 3048c2ecf20Sopenharmony_ci __u16 ds, __dsh; 3058c2ecf20Sopenharmony_ci __u32 edi; 3068c2ecf20Sopenharmony_ci __u32 esi; 3078c2ecf20Sopenharmony_ci __u32 ebp; 3088c2ecf20Sopenharmony_ci __u32 esp; 3098c2ecf20Sopenharmony_ci __u32 ebx; 3108c2ecf20Sopenharmony_ci __u32 edx; 3118c2ecf20Sopenharmony_ci __u32 ecx; 3128c2ecf20Sopenharmony_ci __u32 eax; 3138c2ecf20Sopenharmony_ci __u32 trapno; 3148c2ecf20Sopenharmony_ci __u32 err; 3158c2ecf20Sopenharmony_ci __u32 eip; 3168c2ecf20Sopenharmony_ci __u16 cs, __csh; 3178c2ecf20Sopenharmony_ci __u32 eflags; 3188c2ecf20Sopenharmony_ci __u32 esp_at_signal; 3198c2ecf20Sopenharmony_ci __u16 ss, __ssh; 3208c2ecf20Sopenharmony_ci struct _fpstate __user *fpstate; 3218c2ecf20Sopenharmony_ci __u32 oldmask; 3228c2ecf20Sopenharmony_ci __u32 cr2; 3238c2ecf20Sopenharmony_ci}; 3248c2ecf20Sopenharmony_ci# else /* __x86_64__: */ 3258c2ecf20Sopenharmony_cistruct sigcontext { 3268c2ecf20Sopenharmony_ci __u64 r8; 3278c2ecf20Sopenharmony_ci __u64 r9; 3288c2ecf20Sopenharmony_ci __u64 r10; 3298c2ecf20Sopenharmony_ci __u64 r11; 3308c2ecf20Sopenharmony_ci __u64 r12; 3318c2ecf20Sopenharmony_ci __u64 r13; 3328c2ecf20Sopenharmony_ci __u64 r14; 3338c2ecf20Sopenharmony_ci __u64 r15; 3348c2ecf20Sopenharmony_ci __u64 rdi; 3358c2ecf20Sopenharmony_ci __u64 rsi; 3368c2ecf20Sopenharmony_ci __u64 rbp; 3378c2ecf20Sopenharmony_ci __u64 rbx; 3388c2ecf20Sopenharmony_ci __u64 rdx; 3398c2ecf20Sopenharmony_ci __u64 rax; 3408c2ecf20Sopenharmony_ci __u64 rcx; 3418c2ecf20Sopenharmony_ci __u64 rsp; 3428c2ecf20Sopenharmony_ci __u64 rip; 3438c2ecf20Sopenharmony_ci __u64 eflags; /* RFLAGS */ 3448c2ecf20Sopenharmony_ci __u16 cs; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* 3478c2ecf20Sopenharmony_ci * Prior to 2.5.64 ("[PATCH] x86-64 updates for 2.5.64-bk3"), 3488c2ecf20Sopenharmony_ci * Linux saved and restored fs and gs in these slots. This 3498c2ecf20Sopenharmony_ci * was counterproductive, as fsbase and gsbase were never 3508c2ecf20Sopenharmony_ci * saved, so arch_prctl was presumably unreliable. 3518c2ecf20Sopenharmony_ci * 3528c2ecf20Sopenharmony_ci * These slots should never be reused without extreme caution: 3538c2ecf20Sopenharmony_ci * 3548c2ecf20Sopenharmony_ci * - Some DOSEMU versions stash fs and gs in these slots manually, 3558c2ecf20Sopenharmony_ci * thus overwriting anything the kernel expects to be preserved 3568c2ecf20Sopenharmony_ci * in these slots. 3578c2ecf20Sopenharmony_ci * 3588c2ecf20Sopenharmony_ci * - If these slots are ever needed for any other purpose, 3598c2ecf20Sopenharmony_ci * there is some risk that very old 64-bit binaries could get 3608c2ecf20Sopenharmony_ci * confused. I doubt that many such binaries still work, 3618c2ecf20Sopenharmony_ci * though, since the same patch in 2.5.64 also removed the 3628c2ecf20Sopenharmony_ci * 64-bit set_thread_area syscall, so it appears that there 3638c2ecf20Sopenharmony_ci * is no TLS API beyond modify_ldt that works in both pre- 3648c2ecf20Sopenharmony_ci * and post-2.5.64 kernels. 3658c2ecf20Sopenharmony_ci * 3668c2ecf20Sopenharmony_ci * If the kernel ever adds explicit fs, gs, fsbase, and gsbase 3678c2ecf20Sopenharmony_ci * save/restore, it will most likely need to be opt-in and use 3688c2ecf20Sopenharmony_ci * different context slots. 3698c2ecf20Sopenharmony_ci */ 3708c2ecf20Sopenharmony_ci __u16 gs; 3718c2ecf20Sopenharmony_ci __u16 fs; 3728c2ecf20Sopenharmony_ci union { 3738c2ecf20Sopenharmony_ci __u16 ss; /* If UC_SIGCONTEXT_SS */ 3748c2ecf20Sopenharmony_ci __u16 __pad0; /* Alias name for old (!UC_SIGCONTEXT_SS) user-space */ 3758c2ecf20Sopenharmony_ci }; 3768c2ecf20Sopenharmony_ci __u64 err; 3778c2ecf20Sopenharmony_ci __u64 trapno; 3788c2ecf20Sopenharmony_ci __u64 oldmask; 3798c2ecf20Sopenharmony_ci __u64 cr2; 3808c2ecf20Sopenharmony_ci struct _fpstate __user *fpstate; /* Zero when no FPU context */ 3818c2ecf20Sopenharmony_ci# ifdef __ILP32__ 3828c2ecf20Sopenharmony_ci __u32 __fpstate_pad; 3838c2ecf20Sopenharmony_ci# endif 3848c2ecf20Sopenharmony_ci __u64 reserved1[8]; 3858c2ecf20Sopenharmony_ci}; 3868c2ecf20Sopenharmony_ci# endif /* __x86_64__ */ 3878c2ecf20Sopenharmony_ci#endif /* !__KERNEL__ */ 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci#endif /* _UAPI_ASM_X86_SIGCONTEXT_H */ 390