summaryrefslogtreecommitdiffstats
path: root/arch/x86/mm
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2022-12-05 09:04:32 +0100
committerBorislav Petkov (AMD) <bp@alien8.de>2022-12-05 11:03:27 +0100
commitc11ca45441d56ed6d353548cad660e04f0b6605d (patch)
treefa69986276c098ec3c9efdc564b75d52a6cc6e38 /arch/x86/mm
parentd800169041c0e035160c8b81f30d4b7e8f8ef777 (diff)
downloadlinux-c11ca45441d56ed6d353548cad660e04f0b6605d.tar.bz2
x86/pat: Handle TDX guest PAT initialization
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. [ bp: Align conditions for better readability. ] Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20221205080433.16643-2-jgross@suse.com
Diffstat (limited to 'arch/x86/mm')
-rw-r--r--arch/x86/mm/pat/memtype.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 9aab17d660cd..46de9cf5c91d 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -296,8 +296,13 @@ 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;
}