From: Peter Zijlstra Date: Fri, 18 Apr 2025 09:50:34 +0000 (+0200) Subject: x86/mm: Fix {,un}use_temporary_mm() IRQ state X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aef1d0209ddf127a8069aca5fa3a062be4136b76;p=users%2Fdwmw2%2Flinux.git x86/mm: Fix {,un}use_temporary_mm() IRQ state As the function switch_mm_irqs_off() implies, it ought to be called with IRQs *off*. Commit 58f8ffa91766 ("x86/mm: Allow temporary MMs when IRQs are on") caused this to not be the case for EFI. Ensure IRQs are off where it matters. Fixes: 58f8ffa91766 ("x86/mm: Allow temporary MMs when IRQs are on") Reported-by: Borislav Petkov (AMD) Tested-by: Borislav Petkov (AMD) Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Cc: H. Peter Anvin Cc: Andrew Morton Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Rik van Riel Link: https://lore.kernel.org/r/20250418095034.GR38216@noisy.programming.kicks-ass.net --- diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 79c124f6f3f22..39761c7765bdd 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -986,6 +986,7 @@ struct mm_struct *use_temporary_mm(struct mm_struct *temp_mm) struct mm_struct *prev_mm; lockdep_assert_preemption_disabled(); + guard(irqsave)(); /* * Make sure not to be in TLB lazy mode, as otherwise we'll end up @@ -1018,6 +1019,7 @@ struct mm_struct *use_temporary_mm(struct mm_struct *temp_mm) void unuse_temporary_mm(struct mm_struct *prev_mm) { lockdep_assert_preemption_disabled(); + guard(irqsave)(); /* Clear the cpumask, to indicate no TLB flushing is needed anywhere */ cpumask_clear_cpu(smp_processor_id(), mm_cpumask(this_cpu_read(cpu_tlbstate.loaded_mm)));