From: "tip-bot2 for Jan Beulich" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Jan Beulich <jbeulich@suse.com>, Borislav Petkov <bp@suse.de>,
Ingo Molnar <mingo@kernel.org>, <stable@vger.kernel.org>,
Juergen Gross <jgross@suse.com>,
Lucas De Marchi <lucas.demarchi@intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/PAT: Have pat_enabled() properly reflect state when running on Xen
Date: Mon, 15 Aug 2022 10:20:42 -0000 [thread overview]
Message-ID: <166055884287.401.612271624942869534.tip-bot2@tip-bot2> (raw)
In-Reply-To: <9385fa60-fa5d-f559-a137-6608408f88b0@suse.com>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 72cbc8f04fe2fa93443c0fcccb7ad91dfea3d9ce
Gitweb: https://git.kernel.org/tip/72cbc8f04fe2fa93443c0fcccb7ad91dfea3d9ce
Author: Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu, 28 Apr 2022 16:50:29 +02:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Mon, 15 Aug 2022 10:51:23 +02:00
x86/PAT: Have pat_enabled() properly reflect state when running on Xen
After commit ID in the Fixes: tag, pat_enabled() returns false (because
of PAT initialization being suppressed in the absence of MTRRs being
announced to be available).
This has become a problem: the i915 driver now fails to initialize when
running PV on Xen (i915_gem_object_pin_map() is where I located the
induced failure), and its error handling is flaky enough to (at least
sometimes) result in a hung system.
Yet even beyond that problem the keying of the use of WC mappings to
pat_enabled() (see arch_can_pci_mmap_wc()) means that in particular
graphics frame buffer accesses would have been quite a bit less optimal
than possible.
Arrange for the function to return true in such environments, without
undermining the rest of PAT MSR management logic considering PAT to be
disabled: specifically, no writes to the PAT MSR should occur.
For the new boolean to live in .init.data, init_cache_modes() also needs
moving to .init.text (where it could/should have lived already before).
[ bp: This is the "small fix" variant for stable. It'll get replaced
with a proper PAT and MTRR detection split upstream but that is too
involved for a stable backport.
- additional touchups to commit msg. Use cpu_feature_enabled(). ]
Fixes: bdd8b6c98239 ("drm/i915: replace X86_FEATURE_PAT with pat_enabled()")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: <stable@vger.kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/9385fa60-fa5d-f559-a137-6608408f88b0@suse.com
---
arch/x86/mm/pat/memtype.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index d5ef64d..66a209f 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -62,6 +62,7 @@
static bool __read_mostly pat_bp_initialized;
static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
+static bool __initdata pat_force_disabled = !IS_ENABLED(CONFIG_X86_PAT);
static bool __read_mostly pat_bp_enabled;
static bool __read_mostly pat_cm_initialized;
@@ -86,6 +87,7 @@ void pat_disable(const char *msg_reason)
static int __init nopat(char *str)
{
pat_disable("PAT support disabled via boot option.");
+ pat_force_disabled = true;
return 0;
}
early_param("nopat", nopat);
@@ -272,7 +274,7 @@ static void pat_ap_init(u64 pat)
wrmsrl(MSR_IA32_CR_PAT, pat);
}
-void init_cache_modes(void)
+void __init init_cache_modes(void)
{
u64 pat = 0;
@@ -313,6 +315,12 @@ void init_cache_modes(void)
*/
pat = PAT(0, WB) | PAT(1, WT) | PAT(2, UC_MINUS) | PAT(3, UC) |
PAT(4, WB) | PAT(5, WT) | PAT(6, UC_MINUS) | PAT(7, UC);
+ } else if (!pat_force_disabled && cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) {
+ /*
+ * Clearly PAT is enabled underneath. Allow pat_enabled() to
+ * reflect this.
+ */
+ pat_bp_enabled = true;
}
__init_cache_modes(pat);
prev parent reply other threads:[~2022-08-15 10:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 14:50 [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen Jan Beulich
2022-05-03 12:54 ` Juergen Gross
2022-05-11 13:32 ` Juergen Gross
2022-05-21 13:56 ` Chuck Zmudzinski
2022-05-25 8:55 ` Ping: " Jan Beulich
2022-07-04 11:58 ` Thorsten Leemhuis
2022-07-04 12:26 ` Jan Beulich
2022-07-05 10:57 ` Thorsten Leemhuis
2022-07-05 11:02 ` Jan Beulich
2022-07-05 13:36 ` Borislav Petkov
2022-07-05 13:38 ` Juergen Gross
2022-07-14 17:17 ` Chuck Zmudzinski
2022-07-14 22:33 ` Chuck Zmudzinski
2022-07-14 22:45 ` Chuck Zmudzinski
2022-07-19 14:26 ` Chuck Zmudzinski
2022-07-05 15:04 ` Borislav Petkov
2022-07-05 15:56 ` Jan Beulich
2022-07-05 16:14 ` Borislav Petkov
2022-07-06 6:17 ` Jan Beulich
2022-07-06 17:01 ` Borislav Petkov
2022-07-07 6:38 ` Jan Beulich
2022-07-11 10:40 ` Borislav Petkov
2022-07-11 11:38 ` Chuck Zmudzinski
2022-07-11 12:28 ` [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen, with corrected patch Chuck Zmudzinski
2022-07-11 14:18 ` [PATCH] x86/PAT: have pat_enabled() properly reflect state when running on e.g. Xen Chuck Zmudzinski
2022-07-11 14:31 ` Juergen Gross
2022-07-11 17:41 ` Chuck Zmudzinski
2022-07-12 5:49 ` Juergen Gross
2022-07-12 6:04 ` Jan Beulich
2022-07-12 13:22 ` Chuck Zmudzinski
2022-07-12 13:32 ` Juergen Gross
2022-07-12 15:09 ` Chuck Zmudzinski
2022-07-12 15:30 ` Juergen Gross
2022-07-12 16:34 ` Chuck Zmudzinski
2022-08-15 10:20 ` tip-bot2 for Jan Beulich [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=166055884287.401.612271624942869534.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@suse.de \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.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
all inboxes | Powered by JetHome®