From: David Woodhouse Date: Thu, 5 Dec 2024 15:05:10 +0000 (+0000) Subject: x86/kexec: Only swap pages for ::preserve_context mode X-Git-Tag: v6.14-rc1~119^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e5683e2d0b5584c51993908c5d0afa78e613492;p=thirdparty%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 Signed-off-by: Ingo Molnar Cc: Baoquan He Cc: Vivek Goyal Cc: Dave Young Cc: Eric Biederman Cc: Ard Biesheuvel Cc: "H. Peter Anvin" Link: https://lore.kernel.org/r/20241205153343.3275139-5-dwmw2@infradead.org --- diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index fea650f926066..ca7f1e1d5b114 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -310,6 +310,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 */ + jz .Lnoswap + /* copy source page to swap page */ movq %r10, %rdi movl $512, %ecx @@ -324,6 +327,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