1af170c50SDavid Howells #ifndef _ASM_X86_UCONTEXT_H 2af170c50SDavid Howells #define _ASM_X86_UCONTEXT_H 3af170c50SDavid Howells 46c25da5aSAndy Lutomirski /* 56c25da5aSAndy Lutomirski * Indicates the presence of extended state information in the memory 66c25da5aSAndy Lutomirski * layout pointed by the fpstate pointer in the ucontext's sigcontext 76c25da5aSAndy Lutomirski * struct (uc_mcontext). 8af170c50SDavid Howells */ 96c25da5aSAndy Lutomirski #define UC_FP_XSTATE 0x1 106c25da5aSAndy Lutomirski 116c25da5aSAndy Lutomirski #ifdef __x86_64__ 126c25da5aSAndy Lutomirski /* 136c25da5aSAndy Lutomirski * UC_SIGCONTEXT_SS will be set when delivering 64-bit or x32 signals on 146c25da5aSAndy Lutomirski * kernels that save SS in the sigcontext. All kernels that set 156c25da5aSAndy Lutomirski * UC_SIGCONTEXT_SS will correctly restore at least the low 32 bits of esp 166c25da5aSAndy Lutomirski * regardless of SS (i.e. they implement espfix). 176c25da5aSAndy Lutomirski * 186c25da5aSAndy Lutomirski * Kernels that set UC_SIGCONTEXT_SS will also set UC_STRICT_RESTORE_SS 196c25da5aSAndy Lutomirski * when delivering a signal that came from 64-bit code. 206c25da5aSAndy Lutomirski * 216c25da5aSAndy Lutomirski * Sigreturn restores SS as follows: 226c25da5aSAndy Lutomirski * 236c25da5aSAndy Lutomirski * if (saved SS is valid || UC_STRICT_RESTORE_SS is set || 246c25da5aSAndy Lutomirski * saved CS is not 64-bit) 256c25da5aSAndy Lutomirski * new SS = saved SS (will fail IRET and signal if invalid) 266c25da5aSAndy Lutomirski * else 276c25da5aSAndy Lutomirski * new SS = a flat 32-bit data segment 286c25da5aSAndy Lutomirski * 296c25da5aSAndy Lutomirski * This behavior serves three purposes: 306c25da5aSAndy Lutomirski * 316c25da5aSAndy Lutomirski * - Legacy programs that construct a 64-bit sigcontext from scratch 326c25da5aSAndy Lutomirski * with zero or garbage in the SS slot (e.g. old CRIU) and call 336c25da5aSAndy Lutomirski * sigreturn will still work. 346c25da5aSAndy Lutomirski * 356c25da5aSAndy Lutomirski * - Old DOSEMU versions sometimes catch a signal from a segmented 366c25da5aSAndy Lutomirski * context, delete the old SS segment (with modify_ldt), and change 376c25da5aSAndy Lutomirski * the saved CS to a 64-bit segment. These DOSEMU versions expect 386c25da5aSAndy Lutomirski * sigreturn to send them back to 64-bit mode without killing them, 396c25da5aSAndy Lutomirski * despite the fact that the SS selector when the signal was raised is 406c25da5aSAndy Lutomirski * no longer valid. UC_STRICT_RESTORE_SS will be clear, so the kernel 416c25da5aSAndy Lutomirski * will fix up SS for these DOSEMU versions. 426c25da5aSAndy Lutomirski * 436c25da5aSAndy Lutomirski * - Old and new programs that catch a signal and return without 446c25da5aSAndy Lutomirski * modifying the saved context will end up in exactly the state they 456c25da5aSAndy Lutomirski * started in, even if they were running in a segmented context when 466c25da5aSAndy Lutomirski * the signal was raised.. Old kernels would lose track of the 476c25da5aSAndy Lutomirski * previous SS value. 486c25da5aSAndy Lutomirski */ 496c25da5aSAndy Lutomirski #define UC_SIGCONTEXT_SS 0x2 506c25da5aSAndy Lutomirski #define UC_STRICT_RESTORE_SS 0x4 516c25da5aSAndy Lutomirski #endif 52af170c50SDavid Howells 53af170c50SDavid Howells #include <asm-generic/ucontext.h> 54af170c50SDavid Howells 55af170c50SDavid Howells #endif /* _ASM_X86_UCONTEXT_H */ 56