From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: kirill@shutemov.name, Juergen Gross <jgross@suse.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 1/2] x86/pat: fix TDX guest PAT initialization
Date: Mon, 5 Dec 2022 09:04:32 +0100 [thread overview]
Message-ID: <20221205080433.16643-2-jgross@suse.com> (raw)
In-Reply-To: <20221205080433.16643-1-jgross@suse.com>
With the decoupling of PAT and MTRR initialization, PAT will be used
even with MTRRs disabled. This seems to break booting up as TDX guest,
as the recommended sequence to set the PAT MSR across CPUs can't work
in TDX guests due to disabling caches via setting CR0.CD isn't allowed
in TDX mode.
This is an inconsistency in the Intel documentation between the SDM
and the TDX specification. For now handle TDX mode the same way as Xen
PV guest mode by just accepting the current PAT MSR setting without
trying to modify it.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/mm/pat/memtype.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 9aab17d660cd..4e50add760ad 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -296,8 +296,12 @@ void __init pat_bp_init(void)
/*
* Xen PV doesn't allow to set PAT MSR, but all cache modes are
* supported.
+ * When running as TDX guest setting the PAT MSR won't work either
+ * due to the requirement to set CR0.CD when doing so. Rely on
+ * firmware to have set the PAT MSR correctly.
*/
- if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) {
+ if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV) ||
+ cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
init_cache_modes(pat_msr_val);
return;
}
--
2.35.3
next prev parent reply other threads:[~2022-12-05 8:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 8:04 [PATCH 0/2] x86: fixes for MTRR/PAT decoupling Juergen Gross
2022-12-05 8:04 ` Juergen Gross [this message]
2022-12-05 10:16 ` [tip: x86/cpu] x86/pat: Handle TDX guest PAT initialization tip-bot2 for Juergen Gross
2022-12-05 12:26 ` [PATCH 1/2] x86/pat: fix " kirill
2022-12-05 8:04 ` [PATCH 2/2] x86/mtrr: make message for disabled MTRRs more descriptive Juergen Gross
2022-12-05 10:16 ` [tip: x86/cpu] x86/mtrr: Make " tip-bot2 for Juergen Gross
2022-12-05 12:26 ` [PATCH 2/2] x86/mtrr: make " kirill
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=20221205080433.16643-2-jgross@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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