]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/mm: Hide mm_free_global_asid() definition under CONFIG_BROADCAST_TLB_FLUSH
authorHou Wenlong <houwenlong.hwl@antgroup.com>
Thu, 15 Jan 2026 03:38:34 +0000 (11:38 +0800)
committerBorislav Petkov (AMD) <bp@alien8.de>
Fri, 16 Jan 2026 21:16:32 +0000 (22:16 +0100)
When CONFIG_BROADCAST_TLB_FLUSH is not enabled, mm_free_global_asid() remains
a globally visible symbol and generates a useless function call to it in
destroy_context(). Therefore, hide the mm_free_global_asid() definition under
CONFIG_BROADCAST_TLB_FLUSH and provide a static inline empty version when it
is not enabled to remove the function call.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Rik van Riel <riel@surriel.com>
Link: https://patch.msgid.link/b262a8ec8076fb26bb692aaf113848b1e6f40e40.1768448079.git.houwenlong.hwl@antgroup.com
arch/x86/include/asm/mmu_context.h
arch/x86/include/asm/tlbflush.h
arch/x86/mm/tlb.c

index 73bf3b1b44e8508de18ca1ccf1ae6adaaea04550..1acafb1c6a9329a0d0383ab3ddc3c75fc90d4250 100644 (file)
@@ -139,9 +139,7 @@ static inline void mm_reset_untag_mask(struct mm_struct *mm)
 #define enter_lazy_tlb enter_lazy_tlb
 extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk);
 
-#define mm_init_global_asid mm_init_global_asid
 extern void mm_init_global_asid(struct mm_struct *mm);
-
 extern void mm_free_global_asid(struct mm_struct *mm);
 
 /*
index 00daedfefc1b02e7e000676bbf6ee5a4c2a74ebb..5114bf50c91130416d74b86d4cc12385c4a6f5f9 100644 (file)
@@ -292,9 +292,12 @@ static inline bool mm_in_asid_transition(struct mm_struct *mm)
 
        return mm && READ_ONCE(mm->context.asid_transition);
 }
+
+extern void mm_free_global_asid(struct mm_struct *mm);
 #else
 static inline u16 mm_global_asid(struct mm_struct *mm) { return 0; }
 static inline void mm_init_global_asid(struct mm_struct *mm) { }
+static inline void mm_free_global_asid(struct mm_struct *mm) { }
 static inline void mm_assign_global_asid(struct mm_struct *mm, u16 asid) { }
 static inline void mm_clear_asid_transition(struct mm_struct *mm) { }
 static inline bool mm_in_asid_transition(struct mm_struct *mm) { return false; }
index f5b93e01e3472b019c69cf3312a18b3ff41d34af..621e09d049cb93a7b85667a457842d54b115158b 100644 (file)
@@ -401,6 +401,7 @@ static void use_global_asid(struct mm_struct *mm)
        mm_assign_global_asid(mm, asid);
 }
 
+#ifdef CONFIG_BROADCAST_TLB_FLUSH
 void mm_free_global_asid(struct mm_struct *mm)
 {
        if (!cpu_feature_enabled(X86_FEATURE_INVLPGB))
@@ -412,13 +413,12 @@ void mm_free_global_asid(struct mm_struct *mm)
        guard(raw_spinlock_irqsave)(&global_asid_lock);
 
        /* The global ASID can be re-used only after flush at wrap-around. */
-#ifdef CONFIG_BROADCAST_TLB_FLUSH
        __set_bit(mm->context.global_asid, global_asid_freed);
 
        mm->context.global_asid = 0;
        global_asid_available++;
-#endif
 }
+#endif
 
 /*
  * Is the mm transitioning from a CPU-local ASID to a global ASID?