From: David Woodhouse Date: Sat, 2 Nov 2024 23:27:33 +0000 (+0000) Subject: x86/kexec: Only swap pages for preserve_context mode X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=496fd4967a2097b38c0ec536c8527568bc2dfef0;p=users%2Fdwmw2%2Flinux.git x86/kexec: Only swap pages for preserve_context mode There's no need to swap pages (which involves three memcopies for each page) in the plain kexec case. Just do a single copy from source to destination page. Signed-off-by: David Woodhouse --- diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index ca01e3e2f097c..2848d086ceb0f 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -303,6 +303,9 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) movq %rdi, %rdx /* Save destination page to %rdx */ movq %rsi, %rax /* Save source page to %rax */ + testq %r11, %r11 /* Only actually swap for preserve_context */ + jnz .Lnoswap + /* copy source page to swap page */ movq %r10, %rdi movl $512, %ecx @@ -317,6 +320,7 @@ SYM_CODE_START_LOCAL_NOALIGN(swap_pages) /* copy swap page to destination page */ movq %rdx, %rdi movq %r10, %rsi +.Lnoswap: movl $512, %ecx rep ; movsq