Skip to content

Commit 29def59

Browse files
KAGA-KOKOsuryasaimadhu
authored andcommitted
x86/tlb: Move flush_tlb_others() out of line
cpu_tlbstate is exported because various TLB-related functions need access to it, but cpu_tlbstate is sensitive information which should only be accessed by well-contained kernel functions and not be directly exposed to modules. As a last step, move __flush_tlb_others() out of line and hide the native function. The latter can be static when CONFIG_PARAVIRT is disabled. No functional change. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 58430c5 commit 29def59

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

arch/x86/include/asm/paravirt.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ static inline void slow_down_io(void)
5050
void native_flush_tlb_local(void);
5151
void native_flush_tlb_global(void);
5252
void native_flush_tlb_one_user(unsigned long addr);
53+
void native_flush_tlb_others(const struct cpumask *cpumask,
54+
const struct flush_tlb_info *info);
5355

5456
static inline void __flush_tlb_local(void)
5557
{
@@ -66,8 +68,8 @@ static inline void __flush_tlb_one_user(unsigned long addr)
6668
PVOP_VCALL1(mmu.flush_tlb_one_user, addr);
6769
}
6870

69-
static inline void flush_tlb_others(const struct cpumask *cpumask,
70-
const struct flush_tlb_info *info)
71+
static inline void __flush_tlb_others(const struct cpumask *cpumask,
72+
const struct flush_tlb_info *info)
7173
{
7274
PVOP_VCALL2(mmu.flush_tlb_others, cpumask, info);
7375
}

arch/x86/include/asm/tlbflush.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,14 @@ static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid)
140140
return __sme_pa(pgd) | kern_pcid(asid) | CR3_NOFLUSH;
141141
}
142142

143+
struct flush_tlb_info;
144+
143145
void flush_tlb_local(void);
144146
void flush_tlb_global(void);
145147
void flush_tlb_one_user(unsigned long addr);
146148
void flush_tlb_one_kernel(unsigned long addr);
149+
void flush_tlb_others(const struct cpumask *cpumask,
150+
const struct flush_tlb_info *info);
147151

148152
#ifdef CONFIG_PARAVIRT
149153
#include <asm/paravirt.h>
@@ -418,9 +422,6 @@ static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long a)
418422
flush_tlb_mm_range(vma->vm_mm, a, a + PAGE_SIZE, PAGE_SHIFT, false);
419423
}
420424

421-
void native_flush_tlb_others(const struct cpumask *cpumask,
422-
const struct flush_tlb_info *info);
423-
424425
static inline u64 inc_mm_tlb_gen(struct mm_struct *mm)
425426
{
426427
/*
@@ -442,9 +443,6 @@ static inline void arch_tlbbatch_add_mm(struct arch_tlbflush_unmap_batch *batch,
442443
extern void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch);
443444

444445
#ifndef CONFIG_PARAVIRT
445-
#define flush_tlb_others(mask, info) \
446-
native_flush_tlb_others(mask, info)
447-
448446
#define paravirt_tlb_remove_table(tlb, page) \
449447
tlb_remove_page(tlb, (void *)(page))
450448
#endif

arch/x86/mm/tlb.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# define __flush_tlb_local native_flush_tlb_local
2626
# define __flush_tlb_global native_flush_tlb_global
2727
# define __flush_tlb_one_user(addr) native_flush_tlb_one_user(addr)
28+
# define __flush_tlb_others(msk, info) native_flush_tlb_others(msk, info)
2829
#endif
2930

3031
/*
@@ -715,8 +716,8 @@ static bool tlb_is_not_lazy(int cpu, void *data)
715716
return !per_cpu(cpu_tlbstate.is_lazy, cpu);
716717
}
717718

718-
void native_flush_tlb_others(const struct cpumask *cpumask,
719-
const struct flush_tlb_info *info)
719+
STATIC_NOPV void native_flush_tlb_others(const struct cpumask *cpumask,
720+
const struct flush_tlb_info *info)
720721
{
721722
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH);
722723
if (info->end == TLB_FLUSH_ALL)
@@ -766,6 +767,12 @@ void native_flush_tlb_others(const struct cpumask *cpumask,
766767
(void *)info, 1, cpumask);
767768
}
768769

770+
void flush_tlb_others(const struct cpumask *cpumask,
771+
const struct flush_tlb_info *info)
772+
{
773+
__flush_tlb_others(cpumask, info);
774+
}
775+
769776
/*
770777
* See Documentation/x86/tlb.rst for details. We choose 33
771778
* because it is large enough to cover the vast majority (at

0 commit comments

Comments
 (0)