x86/bugs: Remove X86_FEATURE_USE_IBPB
authorYosry Ahmed <yosry.ahmed@linux.dev>
Thu, 27 Feb 2025 01:27:12 +0000 (01:27 +0000)
committerIngo Molnar <mingo@kernel.org>
Thu, 27 Feb 2025 09:57:21 +0000 (10:57 +0100)
X86_FEATURE_USE_IBPB was introduced in:

  2961298efe1e ("x86/cpufeatures: Clean up Spectre v2 related CPUID flags")

to have separate flags for when the CPU supports IBPB (i.e. X86_FEATURE_IBPB)
and when an IBPB is actually used to mitigate Spectre v2.

Ever since then, the uses of IBPB expanded. The name became confusing
because it does not control all IBPB executions in the kernel.
Furthermore, because its name is generic and it's buried within
indirect_branch_prediction_barrier(), it's easy to use it not knowing
that it is specific to Spectre v2.

X86_FEATURE_USE_IBPB is no longer needed because all the IBPB executions
it used to control are now controlled through other means (e.g.
switch_mm_*_ibpb static branches).

Remove the unused feature bit.

Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20250227012712.3193063-7-yosry.ahmed@linux.dev
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/bugs.c
tools/arch/x86/include/asm/cpufeatures.h

index 43653f2704c938bcc602ef4b9713ce8cf16dbd7a..c8701abb77524b4ed2c67dbda5f3e985bcff8059 100644 (file)
 #define X86_FEATURE_MBA                        ( 7*32+18) /* "mba" Memory Bandwidth Allocation */
 #define X86_FEATURE_RSB_CTXSW          ( 7*32+19) /* Fill RSB on context switches */
 #define X86_FEATURE_PERFMON_V2         ( 7*32+20) /* "perfmon_v2" AMD Performance Monitoring Version 2 */
-#define X86_FEATURE_USE_IBPB           ( 7*32+21) /* Indirect Branch Prediction Barrier enabled */
 #define X86_FEATURE_USE_IBRS_FW                ( 7*32+22) /* Use IBRS during runtime firmware calls */
 #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE  ( 7*32+23) /* Disable Speculative Store Bypass. */
 #define X86_FEATURE_LS_CFG_SSBD                ( 7*32+24)  /* AMD SSBD implementation via LS_CFG MSR */
index 7f904d0b0b04fb27354d4cec6c2115fba188320e..5397d0afac0891146f77195aaf69172c7a3252eb 100644 (file)
@@ -1368,7 +1368,6 @@ spectre_v2_user_select_mitigation(void)
 
        /* Initialize Indirect Branch Prediction Barrier */
        if (boot_cpu_has(X86_FEATURE_IBPB)) {
-               setup_force_cpu_cap(X86_FEATURE_USE_IBPB);
                static_branch_enable(&switch_vcpu_ibpb);
 
                spectre_v2_user_ibpb = mode;
index 17b6590748c00cc11f4a527255679d3eb2475a31..ec9911379c6178c0feae9a160a6541335e696b0c 100644 (file)
 #define X86_FEATURE_MBA                        ( 7*32+18) /* "mba" Memory Bandwidth Allocation */
 #define X86_FEATURE_RSB_CTXSW          ( 7*32+19) /* Fill RSB on context switches */
 #define X86_FEATURE_PERFMON_V2         ( 7*32+20) /* "perfmon_v2" AMD Performance Monitoring Version 2 */
-#define X86_FEATURE_USE_IBPB           ( 7*32+21) /* Indirect Branch Prediction Barrier enabled */
 #define X86_FEATURE_USE_IBRS_FW                ( 7*32+22) /* Use IBRS during runtime firmware calls */
 #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE  ( 7*32+23) /* Disable Speculative Store Bypass. */
 #define X86_FEATURE_LS_CFG_SSBD                ( 7*32+24)  /* AMD SSBD implementation via LS_CFG MSR */