ucontext_x86.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _ASM_X86_UCONTEXT_H
  3. #define _ASM_X86_UCONTEXT_H
  4. /*
  5. * Indicates the presence of extended state information in the memory
  6. * layout pointed by the fpstate pointer in the ucontext's sigcontext
  7. * struct (uc_mcontext).
  8. */
  9. #define UC_FP_XSTATE 0x1
  10. #ifdef __x86_64__
  11. /*
  12. * UC_SIGCONTEXT_SS will be set when delivering 64-bit or x32 signals on
  13. * kernels that save SS in the sigcontext. All kernels that set
  14. * UC_SIGCONTEXT_SS will correctly restore at least the low 32 bits of esp
  15. * regardless of SS (i.e. they implement espfix).
  16. *
  17. * Kernels that set UC_SIGCONTEXT_SS will also set UC_STRICT_RESTORE_SS
  18. * when delivering a signal that came from 64-bit code.
  19. *
  20. * Sigreturn restores SS as follows:
  21. *
  22. * if (saved SS is valid || UC_STRICT_RESTORE_SS is set ||
  23. * saved CS is not 64-bit)
  24. * new SS = saved SS (will fail IRET and signal if invalid)
  25. * else
  26. * new SS = a flat 32-bit data segment
  27. *
  28. * This behavior serves three purposes:
  29. *
  30. * - Legacy programs that construct a 64-bit sigcontext from scratch
  31. * with zero or garbage in the SS slot (e.g. old CRIU) and call
  32. * sigreturn will still work.
  33. *
  34. * - Old DOSEMU versions sometimes catch a signal from a segmented
  35. * context, delete the old SS segment (with modify_ldt), and change
  36. * the saved CS to a 64-bit segment. These DOSEMU versions expect
  37. * sigreturn to send them back to 64-bit mode without killing them,
  38. * despite the fact that the SS selector when the signal was raised is
  39. * no longer valid. UC_STRICT_RESTORE_SS will be clear, so the kernel
  40. * will fix up SS for these DOSEMU versions.
  41. *
  42. * - Old and new programs that catch a signal and return without
  43. * modifying the saved context will end up in exactly the state they
  44. * started in, even if they were running in a segmented context when
  45. * the signal was raised.. Old kernels would lose track of the
  46. * previous SS value.
  47. */
  48. #define UC_SIGCONTEXT_SS 0x2
  49. #define UC_STRICT_RESTORE_SS 0x4
  50. #endif
  51. #include <asm-generic/ucontext.h>
  52. #endif /* _ASM_X86_UCONTEXT_H */