]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/mm: Fix {,un}use_temporary_mm() IRQ state
authorPeter Zijlstra <peterz@infradead.org>
Fri, 18 Apr 2025 09:50:34 +0000 (11:50 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 18 Apr 2025 12:36:18 +0000 (14:36 +0200)
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) <bp@alien8.de>
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rik van Riel <riel@surriel.com>
Link: https://lore.kernel.org/r/20250418095034.GR38216@noisy.programming.kicks-ass.net
arch/x86/mm/tlb.c

index 79c124f6f3f222800f049516264f2224347a14bd..39761c7765bdd2569a3fde4c9a9b7c8eb371bf24 100644 (file)
@@ -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)));