x86_64: Save registers in saved_context during suspend and hibernation
PATCH 1/1 x86_64: Save registers in saved_context during suspend and hibernation
From: Rafael J. Wysocki <[email protected]>
During hibernation and suspend on x86_64 save CPU registers in the saved_context structure rather than in a handful of separate variables.
Looks-ok-to: Pavel Machek <[email protected]>
--- arch/x86_64/kernel/acpi/wakeup.S | 101 ++++++++++++++++++++------------------- arch/x86_64/kernel/asm-offsets.c | 28 ++++++++++ arch/x86_64/kernel/suspend.c | 6 -- arch/x86_64/kernel/suspend_asm.S | 72 ++++++++++++++------------- include/asm-x86_64/suspend.h | 23 ++------ 5 files changed, 125 insertions(+), 105 deletions(-)
arch/x86_64/kernel/asm-offsets.c +28 -0
@@ -76,6 +76,34 @@ int main(void)DEFINE (pbe_orig_address, offsetof(struct pbe , orig_address));DEFINE (pbe_next, offsetof(struct pbe , next));BLANK (); +#define ENTRY (entry) DEFINE(pt_regs_ ## entry, offsetof(struct pt_regs, entry)) +ENTRY (rbx); +ENTRY (rbx); +ENTRY (rcx); +ENTRY (rdx); +ENTRY (rsp); +ENTRY (rbp); +ENTRY (rsi); +ENTRY (rdi); +ENTRY (r8); +ENTRY (r9); +ENTRY (r10); +ENTRY (r11); +ENTRY (r12); +ENTRY (r13); +ENTRY (r14); +ENTRY (r15); +ENTRY (eflags); +BLANK (); +#undef ENTRY +#define ENTRY (entry) DEFINE(saved_context_ ## entry, offsetof(struct saved_context, entry)) +ENTRY (cr0); +ENTRY (cr2); +ENTRY (cr3); +ENTRY (cr4); +ENTRY (cr8); +BLANK (); +#undef ENTRYDEFINE (TSS_ist, offsetof(struct tss_struct , ist));BLANK ();DEFINE (crypto_tfm_ctx_offset, offsetof(struct crypto_tfm , __crt_ctx));
include/asm-x86_64/suspend.h +7 -16
@@ -3,6 +3,9 @@* Based on code * Copyright 2001 Patrick Mochel <[email protected]> */ +#ifndef __ASM_X86_64_SUSPEND_H +#define __ASM_X86_64_SUSPEND_H +#include <asm/desc.h> #include <asm/i387.h>
@@ -12,8 +15,9 @@ arch_prepare_suspend(void)return 0 ; } -/* Image of the saved processor state. If you touch this, fix acpi_wakeup.S. */ +/* Image of the saved processor state. If you touch this, fix acpi/wakeup.S. */ struct saved_context { +struct pt_regs regs;u16 ds, es, fs, gs, ss;unsigned long gs_base, gs_kernel_base, fs_base;unsigned long cr0, cr2, cr3, cr4, cr8;
@@ -29,27 +33,14 @@ struct saved_context {unsigned long tr;unsigned long safety;unsigned long return_address; -unsigned long eflags; } __attribute__((packed)); -/* We'll access these from assembly, so we'd better have them outside struct */ -extern unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx; -extern unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi; -extern unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11; -extern unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15; -extern unsigned long saved_context_eflags; -#define loaddebug (thread,register) \ set_debugreg((thread)->debugreg##register, register)extern void fix_processor_context (void ); -extern unsigned long saved_rip; -extern unsigned long saved_rsp; -extern unsigned long saved_rbp; -extern unsigned long saved_rbx; -extern unsigned long saved_rsi; -extern unsigned long saved_rdi; -/* routines for saving/restoring kernel state */ extern int acpi_save_state_mem (void ); + +#endif /* __ASM_X86_64_SUSPEND_H */
arch/x86_64/kernel/suspend.c +0 -6
@@ -19,12 +19,6 @@ extern const void __nosave_begin, __nosastruct saved_context saved_context; -unsigned long saved_context_eax, saved_context_ebx, saved_context_ecx, saved_context_edx; -unsigned long saved_context_esp, saved_context_ebp, saved_context_esi, saved_context_edi; -unsigned long saved_context_r08, saved_context_r09, saved_context_r10, saved_context_r11; -unsigned long saved_context_r12, saved_context_r13, saved_context_r14, saved_context_r15; -unsigned long saved_context_eflags; -void __save_processor_state (struct saved_context *ctxt) {kernel_fpu_begin ();
arch/x86_64/kernel/suspend_asm.S +37 -35
84 lines not on this page · raw message
arch/x86_64/kernel/acpi/wakeup.S +53 -48
122 lines not on this page · raw message
Quoted 2 lines · On Fri, 17 Aug 2007 15:26:22 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
During hibernation and suspend on
x86_64save CPU registers in thesaved_contextstructure rather than in a handful of separate variables.
You have "-mm" in the subject but afaict this patch is not dependent upon anything in -mm?
Quoted 2 lines · On Fri, 17 Aug 2007 15:26:22 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
During hibernation and suspend on
x86_64save CPU registers in thesaved_contextstructure rather than in a handful of separate variables.
You have "-mm" in the subject but afaict this patch is not dependent upon anything in -mm?
Quoted 8 lines · Andrew Morton
Quoted 2 lines · On Fri, 17 Aug 2007 15:26:22 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
During hibernation and suspend on
x86_64save CPU registers in thesaved_contextstructure rather than in a handful of separate variables.You have "-mm" in the subject but afaict this patch is not dependent upon anything in -mm?
It shouldn't be. The -mm means that I regard it as -mm material.
Quoted 8 lines · Andrew Morton
Quoted 2 lines · On Fri, 17 Aug 2007 15:26:22 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
During hibernation and suspend on
x86_64save CPU registers in thesaved_contextstructure rather than in a handful of separate variables.You have "-mm" in the subject but afaict this patch is not dependent upon anything in -mm?
It shouldn't be. The -mm means that I regard it as -mm material.