linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/kexec: Make kexec work in 5-level paging mode
@ 2018-01-29 11:08 Kirill A. Shutemov
  2018-01-29 11:19 ` Baoquan He
  2018-01-29 11:59 ` Matthew Wilcox
  0 siblings, 2 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2018-01-29 11:08 UTC (permalink / raw)
  To: Ingo Molnar, x86, Thomas Gleixner, H. Peter Anvin
  Cc: Borislav Petkov, linux-mm, linux-kernel, Kirill A. Shutemov

I've missed that we need to change relocate_kernel() to set CR4.LA57
flag if the kernel has 5-level paging enabled.

I avoided to use ifdef CONFIG_X86_5LEVEL here and inferred if we need to
enabled 5-level paging from previous CR4 value. This way the code is
ready for boot-time switching between paging modes.

Fixes: 77ef56e4f0fb ("x86: Enable 5-level paging support via CONFIG_X86_5LEVEL=y")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Baoquan He <bhe@redhat.com>
---
 arch/x86/kernel/relocate_kernel_64.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 307d3bac5f04..11eda21eb697 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -68,6 +68,9 @@ relocate_kernel:
 	movq	%cr4, %rax
 	movq	%rax, CR4(%r11)
 
+	/* Save CR4. Required to enable the right paging mode later. */
+	movq	%rax, %r13
+
 	/* zero out flags, and disable interrupts */
 	pushq $0
 	popfq
@@ -126,8 +129,13 @@ identity_mapped:
 	/*
 	 * Set cr4 to a known state:
 	 *  - physical address extension enabled
+	 *  - 5-level paging, if it was enabled before
 	 */
 	movl	$X86_CR4_PAE, %eax
+	testq	$X86_CR4_LA57, %r13
+	jz	1f
+	orl	$X86_CR4_LA57, %eax
+1:
 	movq	%rax, %cr4
 
 	jmp 1f
-- 
2.15.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-29 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29 11:08 [PATCH] x86/kexec: Make kexec work in 5-level paging mode Kirill A. Shutemov
2018-01-29 11:19 ` Baoquan He
2018-01-29 13:00   ` Baoquan He
2018-01-29 11:59 ` Matthew Wilcox
2018-01-29 13:48   ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox