From: Andy Lutomirski <luto@kernel.org>
To: X86 ML <x86@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>
Subject: [PATCH 2/2] x86/mm: Document how CR4.PCIDE restore works
Date: Wed, 6 Sep 2017 19:54:54 -0700 [thread overview]
Message-ID: <c2a4d790ebe866321c5da80402f83c2f37c1c879.1504752689.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1504752689.git.luto@kernel.org>
In-Reply-To: <cover.1504752689.git.luto@kernel.org>
While debugging a problem, I thought that using
cr4_set_bits_and_update_boot() to restore CR4.PCIDE would be
helpful. It turns out to be counterproductive.
Add a comment documenting how this works.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/kernel/cpu/common.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 40cb4d0a5982..4c31a6585333 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -333,6 +333,19 @@ static void setup_pcid(struct cpuinfo_x86 *c)
{
if (cpu_has(c, X86_FEATURE_PCID)) {
if (cpu_has(c, X86_FEATURE_PGE)) {
+ /*
+ * We'd like to use cr4_set_bits_and_update_boot(),
+ * but we can't. CR4.PCIDE is special and can only
+ * be set in long mode, and the early CPU init code
+ * doesn't know this and would try to restore CR4.PCIDE
+ * prior to entering long mode.
+ *
+ * Instead, we rely on the fact that hotplug, resume,
+ * etc all fully restore CR4 before they write anything
+ * that could have nonzero PCID bits to CR3. CR4.PCIDE
+ * has no effect on the page tables themselves, so we
+ * don't need it top be restored early.
+ */
cr4_set_bits(X86_CR4_PCIDE);
} else {
/*
--
2.13.5
next prev parent reply other threads:[~2017-09-07 2:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-07 2:54 [PATCH 0/2] Fix resume failure due to PCID Andy Lutomirski
2017-09-07 2:54 ` [PATCH 1/2] x86/mm: Reinitialize TLB state on hotplug and resume Andy Lutomirski
2017-09-07 7:01 ` [PATCH] mm/debug: Change BUG_ON() crashes to survivable WARN_ON() warnings Ingo Molnar
2017-09-07 20:50 ` Linus Torvalds
2017-09-07 7:31 ` [PATCH 1/2] x86/mm: Reinitialize TLB state on hotplug and resume Jiri Kosina
2017-09-07 7:48 ` Ingo Molnar
2017-09-07 19:55 ` Jiri Kosina
2017-09-08 1:23 ` Andy Lutomirski
2017-09-07 9:54 ` Borislav Petkov
2017-09-07 9:59 ` Ingo Molnar
2017-09-07 10:10 ` Borislav Petkov
2017-09-07 2:54 ` Andy Lutomirski [this message]
2017-09-07 3:25 ` [PATCH 0/2] Fix resume failure due to PCID Linus Torvalds
2017-09-07 4:15 ` Andy Lutomirski
2017-09-15 6:59 ` x60: warnings on boot and resume, arch/x86/mm/tlb.c:257 initialize_ ... was " Pavel Machek
2017-09-15 8:39 ` Ingo Molnar
2017-09-15 9:16 ` Pavel Machek
2017-09-15 9:35 ` Ingo Molnar
2017-09-15 10:22 ` [4.14-rc0 regression] " Pavel Machek
2017-09-15 18:47 ` Linus Torvalds
2017-09-15 19:29 ` Andy Lutomirski
2017-09-15 21:06 ` Andy Lutomirski
2017-09-07 8:59 ` Borislav Petkov
2017-09-15 11:01 ` Pavel Machek
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=c2a4d790ebe866321c5da80402f83c2f37c1c879.1504752689.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=bpetkov@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.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).