ucontext.h 2.0 KB

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