Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1299ef1d authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Ingo Molnar
Browse files

x86/mm: Rename flush_tlb_single() and flush_tlb_one() to __flush_tlb_one_[user|kernel]()



flush_tlb_single() and flush_tlb_one() sound almost identical, but
they really mean "flush one user translation" and "flush one kernel
translation".  Rename them to flush_tlb_one_user() and
flush_tlb_one_kernel() to make the semantics more obvious.

[ I was looking at some PTI-related code, and the flush-one-address code
  is unnecessarily hard to understand because the names of the helpers are
  uninformative.  This came up during PTI review, but no one got around to
  doing it. ]

Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Eduardo Valentin <eduval@amazon.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux-MM <linux-mm@kvack.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/3303b02e3c3d049dc5235d5651e0ae6d29a34354.1517414378.git.luto@kernel.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent ea00f301
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -297,9 +297,9 @@ static inline void __flush_tlb_global(void)
{
{
	PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel);
	PVOP_VCALL0(pv_mmu_ops.flush_tlb_kernel);
}
}
static inline void __flush_tlb_single(unsigned long addr)
static inline void __flush_tlb_one_user(unsigned long addr)
{
{
	PVOP_VCALL1(pv_mmu_ops.flush_tlb_single, addr);
	PVOP_VCALL1(pv_mmu_ops.flush_tlb_one_user, addr);
}
}


static inline void flush_tlb_others(const struct cpumask *cpumask,
static inline void flush_tlb_others(const struct cpumask *cpumask,
+1 −1
Original line number Original line Diff line number Diff line
@@ -217,7 +217,7 @@ struct pv_mmu_ops {
	/* TLB operations */
	/* TLB operations */
	void (*flush_tlb_user)(void);
	void (*flush_tlb_user)(void);
	void (*flush_tlb_kernel)(void);
	void (*flush_tlb_kernel)(void);
	void (*flush_tlb_single)(unsigned long addr);
	void (*flush_tlb_one_user)(unsigned long addr);
	void (*flush_tlb_others)(const struct cpumask *cpus,
	void (*flush_tlb_others)(const struct cpumask *cpus,
				 const struct flush_tlb_info *info);
				 const struct flush_tlb_info *info);


+1 −1
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ void paging_init(void);
#define kpte_clear_flush(ptep, vaddr)		\
#define kpte_clear_flush(ptep, vaddr)		\
do {						\
do {						\
	pte_clear(&init_mm, (vaddr), (ptep));	\
	pte_clear(&init_mm, (vaddr), (ptep));	\
	__flush_tlb_one((vaddr));		\
	__flush_tlb_one_kernel((vaddr));		\
} while (0)
} while (0)


#endif /* !__ASSEMBLY__ */
#endif /* !__ASSEMBLY__ */
+20 −7
Original line number Original line Diff line number Diff line
@@ -140,7 +140,7 @@ static inline unsigned long build_cr3_noflush(pgd_t *pgd, u16 asid)
#else
#else
#define __flush_tlb() __native_flush_tlb()
#define __flush_tlb() __native_flush_tlb()
#define __flush_tlb_global() __native_flush_tlb_global()
#define __flush_tlb_global() __native_flush_tlb_global()
#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
#define __flush_tlb_one_user(addr) __native_flush_tlb_one_user(addr)
#endif
#endif


static inline bool tlb_defer_switch_to_init_mm(void)
static inline bool tlb_defer_switch_to_init_mm(void)
@@ -400,7 +400,7 @@ static inline void __native_flush_tlb_global(void)
/*
/*
 * flush one page in the user mapping
 * flush one page in the user mapping
 */
 */
static inline void __native_flush_tlb_single(unsigned long addr)
static inline void __native_flush_tlb_one_user(unsigned long addr)
{
{
	u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid);
	u32 loaded_mm_asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid);


@@ -437,18 +437,31 @@ static inline void __flush_tlb_all(void)
/*
/*
 * flush one page in the kernel mapping
 * flush one page in the kernel mapping
 */
 */
static inline void __flush_tlb_one(unsigned long addr)
static inline void __flush_tlb_one_kernel(unsigned long addr)
{
{
	count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);
	count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ONE);
	__flush_tlb_single(addr);

	/*
	 * If PTI is off, then __flush_tlb_one_user() is just INVLPG or its
	 * paravirt equivalent.  Even with PCID, this is sufficient: we only
	 * use PCID if we also use global PTEs for the kernel mapping, and
	 * INVLPG flushes global translations across all address spaces.
	 *
	 * If PTI is on, then the kernel is mapped with non-global PTEs, and
	 * __flush_tlb_one_user() will flush the given address for the current
	 * kernel address space and for its usermode counterpart, but it does
	 * not flush it for other address spaces.
	 */
	__flush_tlb_one_user(addr);


	if (!static_cpu_has(X86_FEATURE_PTI))
	if (!static_cpu_has(X86_FEATURE_PTI))
		return;
		return;


	/*
	/*
	 * __flush_tlb_single() will have cleared the TLB entry for this ASID,
	 * See above.  We need to propagate the flush to all other address
	 * but since kernel space is replicated across all, we must also
	 * spaces.  In principle, we only need to propagate it to kernelmode
	 * invalidate all others.
	 * address spaces, but the extra bookkeeping we would need is not
	 * worth it.
	 */
	 */
	invalidate_other_asid();
	invalidate_other_asid();
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -200,9 +200,9 @@ static void native_flush_tlb_global(void)
	__native_flush_tlb_global();
	__native_flush_tlb_global();
}
}


static void native_flush_tlb_single(unsigned long addr)
static void native_flush_tlb_one_user(unsigned long addr)
{
{
	__native_flush_tlb_single(addr);
	__native_flush_tlb_one_user(addr);
}
}


struct static_key paravirt_steal_enabled;
struct static_key paravirt_steal_enabled;
@@ -401,7 +401,7 @@ struct pv_mmu_ops pv_mmu_ops __ro_after_init = {


	.flush_tlb_user = native_flush_tlb,
	.flush_tlb_user = native_flush_tlb,
	.flush_tlb_kernel = native_flush_tlb_global,
	.flush_tlb_kernel = native_flush_tlb_global,
	.flush_tlb_single = native_flush_tlb_single,
	.flush_tlb_one_user = native_flush_tlb_one_user,
	.flush_tlb_others = native_flush_tlb_others,
	.flush_tlb_others = native_flush_tlb_others,


	.pgd_alloc = __paravirt_pgd_alloc,
	.pgd_alloc = __paravirt_pgd_alloc,
Loading