From: Peter Zijlstra Date: Wed, 2 Apr 2025 09:45:37 +0000 (+0200) Subject: x86/mm: Remove 'mm' argument from unuse_temporary_mm() again X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4873f494bbe4670f353a9b76ce44e6028c811cbb;p=users%2Fdwmw2%2Flinux.git x86/mm: Remove 'mm' argument from unuse_temporary_mm() again Now that unuse_temporary_mm() lives in tlb.c it can access cpu_tlbstate.loaded_mm. [ mingo: Merged it on top of x86/alternatives ] Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Cc: Andy Lutomirski Cc: Rik van Riel Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Andrew Morton Link: https://lore.kernel.org/r/20250402094540.3586683-5-mingo@kernel.org --- diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index b103e1709a674..988c117926341 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -273,6 +273,6 @@ unsigned long __get_current_cr3_fast(void); #include extern struct mm_struct *use_temporary_mm(struct mm_struct *temp_mm); -extern void unuse_temporary_mm(struct mm_struct *mm, struct mm_struct *prev_mm); +extern void unuse_temporary_mm(struct mm_struct *prev_mm); #endif /* _ASM_X86_MMU_CONTEXT_H */ diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index bdbdfa0e4d060..ddbc303e41e36 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -2211,7 +2211,7 @@ static void *__text_poke(text_poke_f func, void *addr, const void *src, size_t l * instruction that already allows the core to see the updated version. * Xen-PV is assumed to serialize execution in a similar manner. */ - unuse_temporary_mm(text_poke_mm, prev_mm); + unuse_temporary_mm(prev_mm); /* * Flushing the TLB might involve IPIs, which would require enabled diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index f3da20bfcf0e1..38fdcf875d5fa 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1018,14 +1018,14 @@ struct mm_struct *use_temporary_mm(struct mm_struct *temp_mm) return prev_mm; } -void unuse_temporary_mm(struct mm_struct *mm, struct mm_struct *prev_mm) +void unuse_temporary_mm(struct mm_struct *prev_mm) { lockdep_assert_irqs_disabled(); - switch_mm_irqs_off(NULL, prev_mm, current); - /* Clear the cpumask, to indicate no TLB flushing is needed anywhere */ - cpumask_clear_cpu(raw_smp_processor_id(), mm_cpumask(mm)); + cpumask_clear_cpu(smp_processor_id(), mm_cpumask(this_cpu_read(cpu_tlbstate.loaded_mm))); + + switch_mm_irqs_off(NULL, prev_mm, current); /* * Restore the breakpoints if they were disabled before the temporary mm