Re: [PATCH v4 05/16] x86/mtrr: split MTRR specific handling from cache dis/enabling

From: Borislav Petkov
Date: Wed Oct 26 2022 - 05:25:07 EST


On Tue, Oct 04, 2022 at 10:10:12AM +0200, Juergen Gross wrote:
> @@ -764,11 +779,8 @@ void cache_disable(void) __acquires(cache_disable_lock)
> count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);
> flush_tlb_local();
>
> - /* Save MTRR state */
> - rdmsr(MSR_MTRRdefType, deftype_lo, deftype_hi);
> -
> - /* Disable MTRRs, and set the default type to uncached */
> - mtrr_wrmsr(MSR_MTRRdefType, deftype_lo & ~0xcff, deftype_hi);
> + if (boot_cpu_has(X86_FEATURE_MTRR))

check_for_deprecated_apis: Warning: arch/x86/kernel/cpu/mtrr/generic.c:782: Do not use boot_cpu_has() - use cpu_feature_enabled() instead.

> + mtrr_disable();
>
> /* Again, only flush caches if we have to. */
> if (!static_cpu_has(X86_FEATURE_SELFSNOOP))
> @@ -781,8 +793,8 @@ void cache_enable(void) __releases(cache_disable_lock)
> count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);
> flush_tlb_local();
>
> - /* Intel (P6) standard MTRRs */
> - mtrr_wrmsr(MSR_MTRRdefType, deftype_lo, deftype_hi);
> + if (boot_cpu_has(X86_FEATURE_MTRR))

Ditto.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette