Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _ASM_X86_UCONTEXT_H
0003 #define _ASM_X86_UCONTEXT_H
0004 
0005 /*
0006  * Indicates the presence of extended state information in the memory
0007  * layout pointed by the fpstate pointer in the ucontext's sigcontext
0008  * struct (uc_mcontext).
0009  */
0010 #define UC_FP_XSTATE    0x1
0011 
0012 #ifdef __x86_64__
0013 /*
0014  * UC_SIGCONTEXT_SS will be set when delivering 64-bit or x32 signals on
0015  * kernels that save SS in the sigcontext.  All kernels that set
0016  * UC_SIGCONTEXT_SS will correctly restore at least the low 32 bits of esp
0017  * regardless of SS (i.e. they implement espfix).
0018  *
0019  * Kernels that set UC_SIGCONTEXT_SS will also set UC_STRICT_RESTORE_SS
0020  * when delivering a signal that came from 64-bit code.
0021  *
0022  * Sigreturn restores SS as follows:
0023  *
0024  * if (saved SS is valid || UC_STRICT_RESTORE_SS is set ||
0025  *     saved CS is not 64-bit)
0026  *         new SS = saved SS  (will fail IRET and signal if invalid)
0027  * else
0028  *         new SS = a flat 32-bit data segment
0029  *
0030  * This behavior serves three purposes:
0031  *
0032  * - Legacy programs that construct a 64-bit sigcontext from scratch
0033  *   with zero or garbage in the SS slot (e.g. old CRIU) and call
0034  *   sigreturn will still work.
0035  *
0036  * - Old DOSEMU versions sometimes catch a signal from a segmented
0037  *   context, delete the old SS segment (with modify_ldt), and change
0038  *   the saved CS to a 64-bit segment.  These DOSEMU versions expect
0039  *   sigreturn to send them back to 64-bit mode without killing them,
0040  *   despite the fact that the SS selector when the signal was raised is
0041  *   no longer valid.  UC_STRICT_RESTORE_SS will be clear, so the kernel
0042  *   will fix up SS for these DOSEMU versions.
0043  *
0044  * - Old and new programs that catch a signal and return without
0045  *   modifying the saved context will end up in exactly the state they
0046  *   started in, even if they were running in a segmented context when
0047  *   the signal was raised..  Old kernels would lose track of the
0048  *   previous SS value.
0049  */
0050 #define UC_SIGCONTEXT_SS    0x2
0051 #define UC_STRICT_RESTORE_SS    0x4
0052 #endif
0053 
0054 #include <asm-generic/ucontext.h>
0055 
0056 #endif /* _ASM_X86_UCONTEXT_H */