suspend_64.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2001-2003 Pavel Machek <[email protected]>
  4. * Based on code
  5. * Copyright 2001 Patrick Mochel <[email protected]>
  6. */
  7. #ifndef _ASM_X86_SUSPEND_64_H
  8. #define _ASM_X86_SUSPEND_64_H
  9. #include <asm/desc.h>
  10. #include <asm/fpu/api.h>
  11. /*
  12. * Image of the saved processor state, used by the low level ACPI suspend to
  13. * RAM code and by the low level hibernation code.
  14. *
  15. * If you modify it, check how it is used in arch/x86/kernel/acpi/wakeup_64.S
  16. * and make sure that __save/__restore_processor_state(), defined in
  17. * arch/x86/power/cpu.c, still work as required.
  18. *
  19. * Because the structure is packed, make sure to avoid unaligned members. For
  20. * optimisation purposes but also because tools like kmemleak only search for
  21. * pointers that are aligned.
  22. */
  23. struct saved_context {
  24. struct pt_regs regs;
  25. /*
  26. * User CS and SS are saved in current_pt_regs(). The rest of the
  27. * segment selectors need to be saved and restored here.
  28. */
  29. u16 ds, es, fs, gs;
  30. /*
  31. * Usermode FSBASE and GSBASE may not match the fs and gs selectors,
  32. * so we save them separately. We save the kernelmode GSBASE to
  33. * restore percpu access after resume.
  34. */
  35. unsigned long kernelmode_gs_base, usermode_gs_base, fs_base;
  36. unsigned long cr0, cr2, cr3, cr4;
  37. u64 misc_enable;
  38. struct saved_msrs saved_msrs;
  39. unsigned long efer;
  40. u16 gdt_pad; /* Unused */
  41. struct desc_ptr gdt_desc;
  42. u16 idt_pad;
  43. struct desc_ptr idt;
  44. u16 ldt;
  45. u16 tss;
  46. unsigned long tr;
  47. unsigned long safety;
  48. unsigned long return_address;
  49. bool misc_enable_saved;
  50. } __attribute__((packed));
  51. #define loaddebug(thread,register) \
  52. set_debugreg((thread)->debugreg##register, register)
  53. /* routines for saving/restoring kernel state */
  54. extern char core_restore_code[];
  55. extern char restore_registers[];
  56. #endif /* _ASM_X86_SUSPEND_64_H */