Skip to content

Commit c11ca45

Browse files
jgross1bp3tk0v
authored andcommitted
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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d800169 commit c11ca45

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/mm/pat/memtype.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,13 @@ void __init pat_bp_init(void)
296296
/*
297297
* Xen PV doesn't allow to set PAT MSR, but all cache modes are
298298
* supported.
299+
* When running as TDX guest setting the PAT MSR won't work either
300+
* due to the requirement to set CR0.CD when doing so. Rely on
301+
* firmware to have set the PAT MSR correctly.
299302
*/
300-
if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) {
303+
if (pat_disabled ||
304+
cpu_feature_enabled(X86_FEATURE_XENPV) ||
305+
cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
301306
init_cache_modes(pat_msr_val);
302307
return;
303308
}

0 commit comments

Comments
 (0)