From: "tip-bot for Kirill A. Shutemov" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bp@suse.de, hpa@zytor.com, kirill.shutemov@linux.intel.com,
linux-kernel@vger.kernel.org, peterz@infradead.org,
bhe@redhat.com, tglx@linutronix.de,
torvalds@linux-foundation.org, mingo@kernel.org
Subject: [tip:x86/urgent] x86/kexec: Make kexec (mostly) work in 5-level paging mode
Date: Wed, 31 Jan 2018 01:13:40 -0800 [thread overview]
Message-ID: <tip-5bf30316991d5bcda046343ee77d823cf16fdd03@git.kernel.org> (raw)
In-Reply-To: <20180129110845.26633-1-kirill.shutemov@linux.intel.com>
Commit-ID: 5bf30316991d5bcda046343ee77d823cf16fdd03
Gitweb: https://git.kernel.org/tip/5bf30316991d5bcda046343ee77d823cf16fdd03
Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
AuthorDate: Mon, 29 Jan 2018 14:08:45 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 31 Jan 2018 08:39:40 +0100
x86/kexec: Make kexec (mostly) work in 5-level paging mode
Currently kexec() will crash when switching into a 5-level paging
enabled kernel.
I missed that we need to change relocate_kernel() to set CR4.LA57
flag if the kernel has 5-level paging enabled.
I avoided using #ifdef CONFIG_X86_5LEVEL here and inferred if we need to
enable 5-level paging from previous CR4 value. This way the code is
ready for boot-time switching between paging modes.
With this patch applied, in addition to kexec 4-to-4 which always worked,
we can kexec 4-to-5 and 5-to-5 - while 5-to-4 will need more work.
Reported-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tested-by: Baoquan He <bhe@redhat.com>
Cc: <stable@vger.kernel.org> # v4.14+
Cc: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mm@kvack.org
Fixes: 77ef56e4f0fb ("x86: Enable 5-level paging support via CONFIG_X86_5LEVEL=y")
Link: http://lkml.kernel.org/r/20180129110845.26633-1-kirill.shutemov@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
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 307d3ba..11eda21e 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
prev parent reply other threads:[~2018-01-31 9:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2018-01-31 9:13 ` tip-bot for Kirill A. Shutemov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-5bf30316991d5bcda046343ee77d823cf16fdd03@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bhe@redhat.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).