Skip to content

Commit dfaed3e

Browse files
npigginmpe
authored andcommitted
powerpc/64s/radix: Fix exit lazy tlb mm switch with irqs enabled
Switching mm and tinkering with current->active_mm should be done with irqs disabled. There is a path where exit_lazy_flush_tlb can be called with irqs enabled: exit_lazy_flush_tlb flush_type_needed __flush_all_mm tlb_finish_mmu exit_mmap Which results in the switching being done with irqs enabled, which is incorrect. Fixes: a665eec ("powerpc/64s/radix: Fix mm_cpumask trimming race vs kthread_use_mm") Cc: [email protected] # v5.10+ Reported-by: Sachin Sant <[email protected]> Link: https://lore.kernel.org/linuxppc-dev/[email protected]/ Tested-by: Sachin Sant <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 719dfd5 commit dfaed3e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/powerpc/mm/book3s64/radix_tlb.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,20 @@ void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush)
795795
goto out;
796796

797797
if (current->active_mm == mm) {
798+
unsigned long flags;
799+
798800
WARN_ON_ONCE(current->mm != NULL);
799-
/* Is a kernel thread and is using mm as the lazy tlb */
801+
/*
802+
* It is a kernel thread and is using mm as the lazy tlb, so
803+
* switch it to init_mm. This is not always called from IPI
804+
* (e.g., flush_type_needed), so must disable irqs.
805+
*/
806+
local_irq_save(flags);
800807
mmgrab_lazy_tlb(&init_mm);
801808
current->active_mm = &init_mm;
802809
switch_mm_irqs_off(mm, &init_mm, current);
803810
mmdrop_lazy_tlb(mm);
811+
local_irq_restore(flags);
804812
}
805813

806814
/*

0 commit comments

Comments
 (0)