Skip to content

Commit 85d724d

Browse files
dwmw2bp3tk0v
authored andcommitted
x86/kexec: Use correct swap page in swap_pages function
The swap_pages function expects the swap page to be in %r10, but there was no documentation to that effect. Once upon a time the setup code used to load its value from a kernel virtual address and save it to an address which is accessible in the identity-mapped page tables, and *happened* to use %r10 to do so, with no comment that it was left there on *purpose* instead of just being a scratch register. Once that was no longer necessary, %r10 just holds whatever the kernel happened to leave in it. Now that the original value passed by the kernel is accessible via %rip-relative addressing, load directly from there instead of using %r10 for it. But document the other parameters that the swap_pages function *does* expect in registers. Fixes: b3adaba ("x86/kexec: Drop page_list argument from relocate_kernel()") Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4d5f1da commit 85d724d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kernel/relocate_kernel_64.S

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ SYM_CODE_END(virtual_mapped)
264264
/* Do the copies */
265265
SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
266266
UNWIND_HINT_END_OF_STACK
267+
/*
268+
* %rdi indirection page
269+
* %r11 preserve_context
270+
*/
267271
movq %rdi, %rcx /* Put the indirection_page in %rcx */
268272
xorl %edi, %edi
269273
xorl %esi, %esi
@@ -302,7 +306,7 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
302306
jz .Lnoswap
303307

304308
/* copy source page to swap page */
305-
movq %r10, %rdi
309+
movq kexec_pa_swap_page(%rip), %rdi
306310
movl $512, %ecx
307311
rep ; movsq
308312

@@ -314,7 +318,7 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
314318

315319
/* copy swap page to destination page */
316320
movq %rdx, %rdi
317-
movq %r10, %rsi
321+
movq kexec_pa_swap_page(%rip), %rsi
318322
.Lnoswap:
319323
movl $512, %ecx
320324
rep ; movsq

0 commit comments

Comments
 (0)