xref: /OK3568_Linux_fs/kernel/arch/x86/include/asm/tlb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _ASM_X86_TLB_H
3*4882a593Smuzhiyun #define _ASM_X86_TLB_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #define tlb_start_vma(tlb, vma) do { } while (0)
6*4882a593Smuzhiyun #define tlb_end_vma(tlb, vma) do { } while (0)
7*4882a593Smuzhiyun #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #define tlb_flush tlb_flush
10*4882a593Smuzhiyun static inline void tlb_flush(struct mmu_gather *tlb);
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <asm-generic/tlb.h>
13*4882a593Smuzhiyun 
tlb_flush(struct mmu_gather * tlb)14*4882a593Smuzhiyun static inline void tlb_flush(struct mmu_gather *tlb)
15*4882a593Smuzhiyun {
16*4882a593Smuzhiyun 	unsigned long start = 0UL, end = TLB_FLUSH_ALL;
17*4882a593Smuzhiyun 	unsigned int stride_shift = tlb_get_unmap_shift(tlb);
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	if (!tlb->fullmm && !tlb->need_flush_all) {
20*4882a593Smuzhiyun 		start = tlb->start;
21*4882a593Smuzhiyun 		end = tlb->end;
22*4882a593Smuzhiyun 	}
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	flush_tlb_mm_range(tlb->mm, start, end, stride_shift, tlb->freed_tables);
25*4882a593Smuzhiyun }
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun  * While x86 architecture in general requires an IPI to perform TLB
29*4882a593Smuzhiyun  * shootdown, enablement code for several hypervisors overrides
30*4882a593Smuzhiyun  * .flush_tlb_others hook in pv_mmu_ops and implements it by issuing
31*4882a593Smuzhiyun  * a hypercall. To keep software pagetable walkers safe in this case we
32*4882a593Smuzhiyun  * switch to RCU based table free (MMU_GATHER_RCU_TABLE_FREE). See the comment
33*4882a593Smuzhiyun  * below 'ifdef CONFIG_MMU_GATHER_RCU_TABLE_FREE' in include/asm-generic/tlb.h
34*4882a593Smuzhiyun  * for more details.
35*4882a593Smuzhiyun  */
__tlb_remove_table(void * table)36*4882a593Smuzhiyun static inline void __tlb_remove_table(void *table)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun 	free_page_and_swap_cache(table);
39*4882a593Smuzhiyun }
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #endif /* _ASM_X86_TLB_H */
42