1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 .text
19#include <linux/linkage.h>
20#include <asm/segment.h>
21#include <asm/page_types.h>
22#include <asm/asm-offsets.h>
23#include <asm/processor-flags.h>
24#include <asm/frame.h>
25
26ENTRY(swsusp_arch_suspend)
27 FRAME_BEGIN
28 movq $saved_context, %rax
29 movq %rsp, pt_regs_sp(%rax)
30 movq %rbp, pt_regs_bp(%rax)
31 movq %rsi, pt_regs_si(%rax)
32 movq %rdi, pt_regs_di(%rax)
33 movq %rbx, pt_regs_bx(%rax)
34 movq %rcx, pt_regs_cx(%rax)
35 movq %rdx, pt_regs_dx(%rax)
36 movq %r8, pt_regs_r8(%rax)
37 movq %r9, pt_regs_r9(%rax)
38 movq %r10, pt_regs_r10(%rax)
39 movq %r11, pt_regs_r11(%rax)
40 movq %r12, pt_regs_r12(%rax)
41 movq %r13, pt_regs_r13(%rax)
42 movq %r14, pt_regs_r14(%rax)
43 movq %r15, pt_regs_r15(%rax)
44 pushfq
45 popq pt_regs_flags(%rax)
46
47
48 movq $restore_registers, %rax
49 movq %rax, restore_jump_address(%rip)
50
51 movq %cr3, %rax
52 movq %rax, restore_cr3(%rip)
53
54 call swsusp_save
55 FRAME_END
56 ret
57ENDPROC(swsusp_arch_suspend)
58
59ENTRY(restore_image)
60
61 movq $__PAGE_OFFSET, %rdx
62 movq temp_level4_pgt(%rip), %rax
63 subq %rdx, %rax
64 movq %rax, %cr3
65
66 movq mmu_cr4_features(%rip), %rax
67 movq %rax, %rdx
68 andq $~(X86_CR4_PGE), %rdx
69 movq %rdx, %cr4;
70 movq %cr3, %rcx;
71 movq %rcx, %cr3;
72 movq %rax, %cr4;
73
74
75 movq restore_jump_address(%rip), %rax
76 movq restore_cr3(%rip), %rbx
77
78
79 movq restore_pblist(%rip), %rdx
80 movq relocated_restore_code(%rip), %rcx
81 jmpq *%rcx
82
83
84ENTRY(core_restore_code)
85.Lloop:
86 testq %rdx, %rdx
87 jz .Ldone
88
89
90 movq pbe_address(%rdx), %rsi
91 movq pbe_orig_address(%rdx), %rdi
92 movq $(PAGE_SIZE >> 3), %rcx
93 rep
94 movsq
95
96
97 movq pbe_next(%rdx), %rdx
98 jmp .Lloop
99.Ldone:
100
101 jmpq *%rax
102
103
104
105
106
107
108
109
110
111
112
113ENTRY(restore_registers)
114 FRAME_BEGIN
115
116 movq %rbx, %cr3
117
118
119 movq mmu_cr4_features(%rip), %rax
120 movq %rax, %rdx
121 andq $~(X86_CR4_PGE), %rdx
122 movq %rdx, %cr4;
123 movq %cr3, %rcx;
124 movq %rcx, %cr3
125 movq %rax, %cr4;
126
127
128 movq $saved_context, %rax
129 movq pt_regs_sp(%rax), %rsp
130 movq pt_regs_bp(%rax), %rbp
131 movq pt_regs_si(%rax), %rsi
132 movq pt_regs_di(%rax), %rdi
133 movq pt_regs_bx(%rax), %rbx
134 movq pt_regs_cx(%rax), %rcx
135 movq pt_regs_dx(%rax), %rdx
136 movq pt_regs_r8(%rax), %r8
137 movq pt_regs_r9(%rax), %r9
138 movq pt_regs_r10(%rax), %r10
139 movq pt_regs_r11(%rax), %r11
140 movq pt_regs_r12(%rax), %r12
141 movq pt_regs_r13(%rax), %r13
142 movq pt_regs_r14(%rax), %r14
143 movq pt_regs_r15(%rax), %r15
144 pushq pt_regs_flags(%rax)
145 popfq
146
147
148 lgdt saved_context_gdt_desc(%rax)
149
150 xorq %rax, %rax
151
152
153 movq %rax, in_suspend(%rip)
154
155 FRAME_END
156 ret
157ENDPROC(restore_registers)
158