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