Skip to content

Commit 93e489a

Browse files
dwmw2Ingo Molnar
authored andcommitted
x86/kexec: Clean up register usage in relocate_kernel()
The memory encryption flag is passed in %r8 because that's where the calling convention puts it. Instead of moving it to %r12 and then using %r8 for other things, just leave it in %r8 and use other registers instead. Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Baoquan He <[email protected]> Cc: Vivek Goyal <[email protected]> Cc: Dave Young <[email protected]> Cc: Eric Biederman <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b7155df commit 93e489a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

arch/x86/kernel/relocate_kernel_64.S

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,18 @@ SYM_CODE_START_NOALIGN(relocate_kernel)
7979
movq %cr4, %r13
8080
movq %r13, saved_cr4(%rip)
8181

82-
/* Save SME active flag */
83-
movq %r8, %r12
84-
8582
/* save indirection list for jumping back */
8683
movq %rdi, pa_backup_pages_map(%rip)
8784

8885
/* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */
8986
movq %rcx, %r11
9087

91-
/* Physical address of control page */
92-
movq %rsi, %r8
93-
9488
/* setup a new stack at the end of the physical control page */
95-
lea PAGE_SIZE(%r8), %rsp
89+
lea PAGE_SIZE(%rsi), %rsp
9690

9791
/* jump to identity mapped page */
98-
addq $(identity_mapped - relocate_kernel), %r8
99-
pushq %r8
92+
addq $(identity_mapped - relocate_kernel), %rsi
93+
pushq %rsi
10094
ANNOTATE_UNRET_SAFE
10195
ret
10296
int3
@@ -107,8 +101,9 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
107101
/*
108102
* %rdi indirection page
109103
* %rdx start address
104+
* %r8 host_mem_enc_active
105+
* %r9 page table page
110106
* %r11 preserve_context
111-
* %r12 host_mem_enc_active
112107
* %r13 original CR4 when relocate_kernel() was invoked
113108
*/
114109

@@ -161,7 +156,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
161156
* entries that will conflict with the now unencrypted memory
162157
* used by kexec. Flush the caches before copying the kernel.
163158
*/
164-
testq %r12, %r12
159+
testq %r8, %r8
165160
jz .Lsme_off
166161
wbinvd
167162
.Lsme_off:

0 commit comments

Comments
 (0)