summaryrefslogtreecommitdiff
path: root/arch/x86/mm/tlb.c
diff options
context:
space:
mode:
authorYosry Ahmed <yosry.ahmed@linux.dev>2025-02-27 01:27:07 +0000
committerIngo Molnar <mingo@kernel.org>2025-02-27 10:57:20 +0100
commit549435aab49ae83d60a08795de6cf0e866f3b2ec (patch)
tree7fd85471fdc9d3db5bde57d47f70160c059601b0 /arch/x86/mm/tlb.c
parent8442df2b49ed9bcd67833ad4f091d15ac91efd00 (diff)
x86/bugs: Move the X86_FEATURE_USE_IBPB check into callers
indirect_branch_prediction_barrier() only performs the MSR write if X86_FEATURE_USE_IBPB is set, using alternative_msr_write(). In preparation for removing X86_FEATURE_USE_IBPB, move the feature check into the callers so that they can be addressed one-by-one, and use X86_FEATURE_IBPB instead to guard the MSR write. Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Acked-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20250227012712.3193063-2-yosry.ahmed@linux.dev
Diffstat (limited to 'arch/x86/mm/tlb.c')
-rw-r--r--arch/x86/mm/tlb.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 6cf881a942bb..4f61d11de041 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -437,7 +437,8 @@ static void cond_mitigation(struct task_struct *next)
* both have the IBPB bit set.
*/
if (next_mm != prev_mm &&
- (next_mm | prev_mm) & LAST_USER_MM_IBPB)
+ (next_mm | prev_mm) & LAST_USER_MM_IBPB &&
+ cpu_feature_enabled(X86_FEATURE_USE_IBPB))
indirect_branch_prediction_barrier();
}
@@ -447,8 +448,8 @@ static void cond_mitigation(struct task_struct *next)
* different context than the user space task which ran
* last on this CPU.
*/
- if ((prev_mm & ~LAST_USER_MM_SPEC_MASK) !=
- (unsigned long)next->mm)
+ if ((prev_mm & ~LAST_USER_MM_SPEC_MASK) != (unsigned long)next->mm &&
+ cpu_feature_enabled(X86_FEATURE_USE_IBPB))
indirect_branch_prediction_barrier();
}