summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw@amazon.co.uk>2024-12-05 18:05:17 +0300
committerIngo Molnar <mingo@kernel.org>2024-12-06 12:42:00 +0300
commitb7155dfd4999211247cce40be2665c71235ab094 (patch)
tree377933655a074aa2813273182f305abefe66078f
parentb3adabae8a96fee62184f4236bf60313b35244e9 (diff)
downloadlinux-b7155dfd4999211247cce40be2665c71235ab094.tar.xz
x86/kexec: Eliminate writes through kernel mapping of relocate_kernel page
All writes to the relocate_kernel control page are now done *after* the %cr3 switch via simple %rip-relative addressing, which means the DATA() macro with its pointer arithmetic can also now be removed. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Baoquan He <bhe@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Dave Young <dyoung@redhat.com> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Link: https://lore.kernel.org/r/20241205153343.3275139-12-dwmw2@infradead.org
-rw-r--r--arch/x86/kernel/relocate_kernel_64.S29
1 files changed, 14 insertions, 15 deletions
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index d52c3bb25b5e..739041c5bca3 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -61,21 +61,24 @@ SYM_CODE_START_NOALIGN(relocate_kernel)
pushq %r15
pushf
- movq %rsp, saved_rsp(%rip)
- movq %cr0, %rax
- movq %rax, saved_cr0(%rip)
- movq %cr3, %rax
- movq %rax, saved_cr3(%rip)
- movq %cr4, %rax
- movq %rax, saved_cr4(%rip)
-
- /* Save CR4. Required to enable the right paging mode later. */
- movq %rax, %r13
-
/* zero out flags, and disable interrupts */
pushq $0
popfq
+ /* Switch to the identity mapped page tables */
+ movq %cr3, %rax
+ movq kexec_pa_table_page(%rip), %r9
+ movq %r9, %cr3
+
+ /* Save %rsp and CRs. */
+ movq %rsp, saved_rsp(%rip)
+ movq %rax, saved_cr3(%rip)
+ movq %cr0, %rax
+ movq %rax, saved_cr0(%rip)
+ /* Leave CR4 in %r13 to enable the right paging mode later. */
+ movq %cr4, %r13
+ movq %r13, saved_cr4(%rip)
+
/* Save SME active flag */
movq %r8, %r12
@@ -85,10 +88,6 @@ SYM_CODE_START_NOALIGN(relocate_kernel)
/* Save the preserve_context to %r11 as swap_pages clobbers %rcx. */
movq %rcx, %r11
- /* Switch to the identity mapped page tables */
- movq kexec_pa_table_page(%rip), %r9
- movq %r9, %cr3
-
/* Physical address of control page */
movq %rsi, %r8