18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_UCONTEXT_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_UCONTEXT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Indicates the presence of extended state information in the memory 78c2ecf20Sopenharmony_ci * layout pointed by the fpstate pointer in the ucontext's sigcontext 88c2ecf20Sopenharmony_ci * struct (uc_mcontext). 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#define UC_FP_XSTATE 0x1 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifdef __x86_64__ 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * UC_SIGCONTEXT_SS will be set when delivering 64-bit or x32 signals on 158c2ecf20Sopenharmony_ci * kernels that save SS in the sigcontext. All kernels that set 168c2ecf20Sopenharmony_ci * UC_SIGCONTEXT_SS will correctly restore at least the low 32 bits of esp 178c2ecf20Sopenharmony_ci * regardless of SS (i.e. they implement espfix). 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * Kernels that set UC_SIGCONTEXT_SS will also set UC_STRICT_RESTORE_SS 208c2ecf20Sopenharmony_ci * when delivering a signal that came from 64-bit code. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Sigreturn restores SS as follows: 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * if (saved SS is valid || UC_STRICT_RESTORE_SS is set || 258c2ecf20Sopenharmony_ci * saved CS is not 64-bit) 268c2ecf20Sopenharmony_ci * new SS = saved SS (will fail IRET and signal if invalid) 278c2ecf20Sopenharmony_ci * else 288c2ecf20Sopenharmony_ci * new SS = a flat 32-bit data segment 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * This behavior serves three purposes: 318c2ecf20Sopenharmony_ci * 328c2ecf20Sopenharmony_ci * - Legacy programs that construct a 64-bit sigcontext from scratch 338c2ecf20Sopenharmony_ci * with zero or garbage in the SS slot (e.g. old CRIU) and call 348c2ecf20Sopenharmony_ci * sigreturn will still work. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * - Old DOSEMU versions sometimes catch a signal from a segmented 378c2ecf20Sopenharmony_ci * context, delete the old SS segment (with modify_ldt), and change 388c2ecf20Sopenharmony_ci * the saved CS to a 64-bit segment. These DOSEMU versions expect 398c2ecf20Sopenharmony_ci * sigreturn to send them back to 64-bit mode without killing them, 408c2ecf20Sopenharmony_ci * despite the fact that the SS selector when the signal was raised is 418c2ecf20Sopenharmony_ci * no longer valid. UC_STRICT_RESTORE_SS will be clear, so the kernel 428c2ecf20Sopenharmony_ci * will fix up SS for these DOSEMU versions. 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * - Old and new programs that catch a signal and return without 458c2ecf20Sopenharmony_ci * modifying the saved context will end up in exactly the state they 468c2ecf20Sopenharmony_ci * started in, even if they were running in a segmented context when 478c2ecf20Sopenharmony_ci * the signal was raised.. Old kernels would lose track of the 488c2ecf20Sopenharmony_ci * previous SS value. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci#define UC_SIGCONTEXT_SS 0x2 518c2ecf20Sopenharmony_ci#define UC_STRICT_RESTORE_SS 0x4 528c2ecf20Sopenharmony_ci#endif 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#include <asm-generic/ucontext.h> 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#endif /* _ASM_X86_UCONTEXT_H */ 57