1 /* SPDX-License-Identifier: GPL-2.0 */
3 * This may not use any stack, nor any variable that is not "NoSave":
5 * Its rewriting one kernel image with another. What is stack in "old"
6 * image could very well be data page in "new" image, and overwriting
7 * your own stack under you is bad idea.
10 #include <linux/linkage.h>
11 #include <asm/segment.h>
12 #include <asm/page_types.h>
13 #include <asm/asm-offsets.h>
14 #include <asm/processor-flags.h>
15 #include <asm/frame.h>
19 ENTRY(swsusp_arch_suspend)
20 movl %esp, saved_context_esp
21 movl %ebx, saved_context_ebx
22 movl %ebp, saved_context_ebp
23 movl %esi, saved_context_esi
24 movl %edi, saved_context_edi
26 popl saved_context_eflags
30 movl %eax, restore_cr3
36 ENDPROC(swsusp_arch_suspend)
39 /* prepare to jump to the image kernel */
40 movl restore_jump_address, %ebx
41 movl restore_cr3, %ebp
43 movl mmu_cr4_features, %ecx
45 /* jump to relocated restore code */
46 movl relocated_restore_code, %eax
49 /* code below has been relocated to a safe page */
50 ENTRY(core_restore_code)
54 jecxz 1f # cr4 Pentium and higher, skip if zero
55 andl $~(X86_CR4_PGE), %ecx
56 movl %ecx, %cr4; # turn off PGE
57 movl %cr3, %eax; # flush TLB
60 movl restore_pblist, %edx
67 movl pbe_address(%edx), %esi
68 movl pbe_orig_address(%edx), %edi
70 movl $(PAGE_SIZE >> 2), %ecx
74 movl pbe_next(%edx), %edx
81 /* code below belongs to the image kernel */
83 ENTRY(restore_registers)
84 /* go back to the original page tables */
86 movl mmu_cr4_features, %ecx
87 jecxz 1f # cr4 Pentium and higher, skip if zero
88 movl %ecx, %cr4; # turn PGE back on
91 movl saved_context_esp, %esp
92 movl saved_context_ebp, %ebp
93 movl saved_context_ebx, %ebx
94 movl saved_context_esi, %esi
95 movl saved_context_edi, %edi
97 pushl saved_context_eflags
100 /* Saved in save_processor_state. */
101 movl $saved_context, %eax
102 lgdt saved_context_gdt_desc(%eax)
106 /* tell the hibernation core that we've just restored the memory */
107 movl %eax, in_suspend
110 ENDPROC(restore_registers)