]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/bugs: Rename mmio_stale_data_clear to cpu_buf_vm_clear
authorPawan Gupta <pawan.kumar.gupta@linux.intel.com>
Wed, 16 Apr 2025 13:47:51 +0000 (06:47 -0700)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 16 Apr 2025 17:40:01 +0000 (19:40 +0200)
The static key mmio_stale_data_clear controls the KVM-only mitigation for MMIO
Stale Data vulnerability. Rename it to reflect its purpose.

No functional change.

Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250416-mmio-rename-v2-1-ad1f5488767c@linux.intel.com
arch/x86/include/asm/nospec-branch.h
arch/x86/kernel/cpu/bugs.c
arch/x86/kvm/vmx/vmx.c

index 5c43f145454ddda781e21806752737b42789c86d..81c4a13e4c0d4ace02b0948eef79377a68252e63 100644 (file)
@@ -561,7 +561,7 @@ DECLARE_STATIC_KEY_FALSE(mds_idle_clear);
 
 DECLARE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
 
-DECLARE_STATIC_KEY_FALSE(mmio_stale_data_clear);
+DECLARE_STATIC_KEY_FALSE(cpu_buf_vm_clear);
 
 extern u16 mds_verw_sel;
 
index 362602b705cc43bd5e9df7c2157f44e7bfb304b9..9131e612de170a6b2bf27c35651f8e824f3d016c 100644 (file)
@@ -127,9 +127,13 @@ EXPORT_SYMBOL_GPL(mds_idle_clear);
  */
 DEFINE_STATIC_KEY_FALSE(switch_mm_cond_l1d_flush);
 
-/* Controls CPU Fill buffer clear before KVM guest MMIO accesses */
-DEFINE_STATIC_KEY_FALSE(mmio_stale_data_clear);
-EXPORT_SYMBOL_GPL(mmio_stale_data_clear);
+/*
+ * Controls CPU Fill buffer clear before VMenter. This is a subset of
+ * X86_FEATURE_CLEAR_CPU_BUF, and should only be enabled when KVM-only
+ * mitigation is required.
+ */
+DEFINE_STATIC_KEY_FALSE(cpu_buf_vm_clear);
+EXPORT_SYMBOL_GPL(cpu_buf_vm_clear);
 
 void __init cpu_select_mitigations(void)
 {
@@ -449,9 +453,9 @@ static void __init mmio_select_mitigation(void)
         * mitigations, disable KVM-only mitigation in that case.
         */
        if (boot_cpu_has(X86_FEATURE_CLEAR_CPU_BUF))
-               static_branch_disable(&mmio_stale_data_clear);
+               static_branch_disable(&cpu_buf_vm_clear);
        else
-               static_branch_enable(&mmio_stale_data_clear);
+               static_branch_enable(&cpu_buf_vm_clear);
 
        /*
         * If Processor-MMIO-Stale-Data bug is present and Fill Buffer data can
@@ -571,7 +575,7 @@ static void __init md_clear_update_mitigation(void)
                taa_select_mitigation();
        }
        /*
-        * MMIO_MITIGATION_OFF is not checked here so that mmio_stale_data_clear
+        * MMIO_MITIGATION_OFF is not checked here so that cpu_buf_vm_clear
         * gets updated correctly as per X86_FEATURE_CLEAR_CPU_BUF state.
         */
        if (boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA)) {
index 5c5766467a61d434ba2baa79a5faba99bcbd9997..a1754f7ba889853eca919f090794b0dc54229a1a 100644 (file)
@@ -7358,10 +7358,14 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu,
         * mitigation for MDS is done late in VMentry and is still
         * executed in spite of L1D Flush. This is because an extra VERW
         * should not matter much after the big hammer L1D Flush.
+        *
+        * cpu_buf_vm_clear is used when system is not vulnerable to MDS/TAA,
+        * and is affected by MMIO Stale Data. In such cases mitigation in only
+        * needed against an MMIO capable guest.
         */
        if (static_branch_unlikely(&vmx_l1d_should_flush))
                vmx_l1d_flush(vcpu);
-       else if (static_branch_unlikely(&mmio_stale_data_clear) &&
+       else if (static_branch_unlikely(&cpu_buf_vm_clear) &&
                 kvm_arch_has_assigned_device(vcpu->kvm))
                mds_clear_cpu_buffers();