0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 .text
0018 #include <linux/linkage.h>
0019 #include <asm/segment.h>
0020 #include <asm/page_types.h>
0021 #include <asm/asm-offsets.h>
0022 #include <asm/processor-flags.h>
0023 #include <asm/frame.h>
0024 #include <asm/nospec-branch.h>
0025
0026
0027 .align PAGE_SIZE
0028 SYM_FUNC_START(restore_registers)
0029
0030 movq %r9, %cr3
0031
0032
0033 movq mmu_cr4_features(%rip), %rax
0034 movq %rax, %rdx
0035 andq $~(X86_CR4_PGE), %rdx
0036 movq %rdx, %cr4; # turn off PGE
0037 movq %cr3, %rcx; # flush TLB
0038 movq %rcx, %cr3
0039 movq %rax, %cr4; # turn PGE back on
0040
0041
0042 movq $saved_context, %rax
0043 movq pt_regs_sp(%rax), %rsp
0044 movq pt_regs_bp(%rax), %rbp
0045 movq pt_regs_si(%rax), %rsi
0046 movq pt_regs_di(%rax), %rdi
0047 movq pt_regs_bx(%rax), %rbx
0048 movq pt_regs_cx(%rax), %rcx
0049 movq pt_regs_dx(%rax), %rdx
0050 movq pt_regs_r8(%rax), %r8
0051 movq pt_regs_r9(%rax), %r9
0052 movq pt_regs_r10(%rax), %r10
0053 movq pt_regs_r11(%rax), %r11
0054 movq pt_regs_r12(%rax), %r12
0055 movq pt_regs_r13(%rax), %r13
0056 movq pt_regs_r14(%rax), %r14
0057 movq pt_regs_r15(%rax), %r15
0058 pushq pt_regs_flags(%rax)
0059 popfq
0060
0061
0062 lgdt saved_context_gdt_desc(%rax)
0063
0064 xorl %eax, %eax
0065
0066
0067 movq %rax, in_suspend(%rip)
0068
0069 RET
0070 SYM_FUNC_END(restore_registers)
0071
0072 SYM_FUNC_START(swsusp_arch_suspend)
0073 movq $saved_context, %rax
0074 movq %rsp, pt_regs_sp(%rax)
0075 movq %rbp, pt_regs_bp(%rax)
0076 movq %rsi, pt_regs_si(%rax)
0077 movq %rdi, pt_regs_di(%rax)
0078 movq %rbx, pt_regs_bx(%rax)
0079 movq %rcx, pt_regs_cx(%rax)
0080 movq %rdx, pt_regs_dx(%rax)
0081 movq %r8, pt_regs_r8(%rax)
0082 movq %r9, pt_regs_r9(%rax)
0083 movq %r10, pt_regs_r10(%rax)
0084 movq %r11, pt_regs_r11(%rax)
0085 movq %r12, pt_regs_r12(%rax)
0086 movq %r13, pt_regs_r13(%rax)
0087 movq %r14, pt_regs_r14(%rax)
0088 movq %r15, pt_regs_r15(%rax)
0089 pushfq
0090 popq pt_regs_flags(%rax)
0091
0092
0093 movq %cr3, %rax
0094 movq %rax, restore_cr3(%rip)
0095
0096 FRAME_BEGIN
0097 call swsusp_save
0098 FRAME_END
0099 RET
0100 SYM_FUNC_END(swsusp_arch_suspend)
0101
0102 SYM_FUNC_START(restore_image)
0103
0104 movq restore_jump_address(%rip), %r8
0105 movq restore_cr3(%rip), %r9
0106
0107
0108 movq temp_pgt(%rip), %rax
0109 movq mmu_cr4_features(%rip), %rbx
0110
0111
0112 movq restore_pblist(%rip), %rdx
0113
0114
0115 movq relocated_restore_code(%rip), %rcx
0116 ANNOTATE_RETPOLINE_SAFE
0117 jmpq *%rcx
0118 SYM_FUNC_END(restore_image)
0119
0120
0121 SYM_FUNC_START(core_restore_code)
0122
0123 movq %rax, %cr3
0124
0125 movq %rbx, %rcx
0126 andq $~(X86_CR4_PGE), %rcx
0127 movq %rcx, %cr4; # turn off PGE
0128 movq %cr3, %rcx; # flush TLB
0129 movq %rcx, %cr3;
0130 movq %rbx, %cr4; # turn PGE back on
0131 .Lloop:
0132 testq %rdx, %rdx
0133 jz .Ldone
0134
0135
0136 movq pbe_address(%rdx), %rsi
0137 movq pbe_orig_address(%rdx), %rdi
0138 movq $(PAGE_SIZE >> 3), %rcx
0139 rep
0140 movsq
0141
0142
0143 movq pbe_next(%rdx), %rdx
0144 jmp .Lloop
0145
0146 .Ldone:
0147
0148 ANNOTATE_RETPOLINE_SAFE
0149 jmpq *%r8
0150 SYM_FUNC_END(core_restore_code)