Skip to content

Commit bfdb395

Browse files
committed
Merge tag 'x86_mtrr_for_v6.9_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 MTRR update from Borislav Petkov: - Relax the PAT MSR programming which was unnecessarily using the MTRR programming protocol of disabling the cache around the changes. The reason behind this is the current algorithm triggering a #VE exception for TDX guests and unnecessarily complicating things * tag 'x86_mtrr_for_v6.9_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/pat: Simplify the PAT programming protocol
2 parents 742582a + ffc92cf commit bfdb395

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

arch/x86/kernel/cpu/cacheinfo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,15 +1118,16 @@ static void cache_cpu_init(void)
11181118
unsigned long flags;
11191119

11201120
local_irq_save(flags);
1121-
cache_disable();
11221121

1123-
if (memory_caching_control & CACHE_MTRR)
1122+
if (memory_caching_control & CACHE_MTRR) {
1123+
cache_disable();
11241124
mtrr_generic_set_state();
1125+
cache_enable();
1126+
}
11251127

11261128
if (memory_caching_control & CACHE_PAT)
11271129
pat_cpu_init();
11281130

1129-
cache_enable();
11301131
local_irq_restore(flags);
11311132
}
11321133

arch/x86/mm/pat/memtype.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ void pat_cpu_init(void)
240240
}
241241

242242
wrmsrl(MSR_IA32_CR_PAT, pat_msr_val);
243+
244+
__flush_tlb_all();
243245
}
244246

245247
/**
@@ -296,13 +298,8 @@ void __init pat_bp_init(void)
296298
/*
297299
* Xen PV doesn't allow to set PAT MSR, but all cache modes are
298300
* 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.
302301
*/
303-
if (pat_disabled ||
304-
cpu_feature_enabled(X86_FEATURE_XENPV) ||
305-
cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
302+
if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) {
306303
init_cache_modes(pat_msr_val);
307304
return;
308305
}

0 commit comments

Comments
 (0)