Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2001-2003 Pavel Machek <pavel@suse.cz>
0004  * Based on code
0005  * Copyright 2001 Patrick Mochel <mochel@osdl.org>
0006  */
0007 #ifndef _ASM_X86_SUSPEND_64_H
0008 #define _ASM_X86_SUSPEND_64_H
0009 
0010 #include <asm/desc.h>
0011 #include <asm/fpu/api.h>
0012 
0013 /*
0014  * Image of the saved processor state, used by the low level ACPI suspend to
0015  * RAM code and by the low level hibernation code.
0016  *
0017  * If you modify it, check how it is used in arch/x86/kernel/acpi/wakeup_64.S
0018  * and make sure that __save/__restore_processor_state(), defined in
0019  * arch/x86/power/cpu.c, still work as required.
0020  *
0021  * Because the structure is packed, make sure to avoid unaligned members. For
0022  * optimisation purposes but also because tools like kmemleak only search for
0023  * pointers that are aligned.
0024  */
0025 struct saved_context {
0026     struct pt_regs regs;
0027 
0028     /*
0029      * User CS and SS are saved in current_pt_regs().  The rest of the
0030      * segment selectors need to be saved and restored here.
0031      */
0032     u16 ds, es, fs, gs;
0033 
0034     /*
0035      * Usermode FSBASE and GSBASE may not match the fs and gs selectors,
0036      * so we save them separately.  We save the kernelmode GSBASE to
0037      * restore percpu access after resume.
0038      */
0039     unsigned long kernelmode_gs_base, usermode_gs_base, fs_base;
0040 
0041     unsigned long cr0, cr2, cr3, cr4;
0042     u64 misc_enable;
0043     struct saved_msrs saved_msrs;
0044     unsigned long efer;
0045     u16 gdt_pad; /* Unused */
0046     struct desc_ptr gdt_desc;
0047     u16 idt_pad;
0048     struct desc_ptr idt;
0049     u16 ldt;
0050     u16 tss;
0051     unsigned long tr;
0052     unsigned long safety;
0053     unsigned long return_address;
0054     bool misc_enable_saved;
0055 } __attribute__((packed));
0056 
0057 #define loaddebug(thread,register) \
0058     set_debugreg((thread)->debugreg##register, register)
0059 
0060 /* routines for saving/restoring kernel state */
0061 extern char core_restore_code[];
0062 extern char restore_registers[];
0063 
0064 #endif /* _ASM_X86_SUSPEND_64_H */