18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_TLB_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_TLB_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define tlb_start_vma(tlb, vma) do { } while (0)
68c2ecf20Sopenharmony_ci#define tlb_end_vma(tlb, vma) do { } while (0)
78c2ecf20Sopenharmony_ci#define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0)
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define tlb_flush tlb_flush
108c2ecf20Sopenharmony_cistatic inline void tlb_flush(struct mmu_gather *tlb);
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <asm-generic/tlb.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistatic inline void tlb_flush(struct mmu_gather *tlb)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	unsigned long start = 0UL, end = TLB_FLUSH_ALL;
178c2ecf20Sopenharmony_ci	unsigned int stride_shift = tlb_get_unmap_shift(tlb);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	if (!tlb->fullmm && !tlb->need_flush_all) {
208c2ecf20Sopenharmony_ci		start = tlb->start;
218c2ecf20Sopenharmony_ci		end = tlb->end;
228c2ecf20Sopenharmony_ci	}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	flush_tlb_mm_range(tlb->mm, start, end, stride_shift, tlb->freed_tables);
258c2ecf20Sopenharmony_ci}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci * While x86 architecture in general requires an IPI to perform TLB
298c2ecf20Sopenharmony_ci * shootdown, enablement code for several hypervisors overrides
308c2ecf20Sopenharmony_ci * .flush_tlb_others hook in pv_mmu_ops and implements it by issuing
318c2ecf20Sopenharmony_ci * a hypercall. To keep software pagetable walkers safe in this case we
328c2ecf20Sopenharmony_ci * switch to RCU based table free (MMU_GATHER_RCU_TABLE_FREE). See the comment
338c2ecf20Sopenharmony_ci * below 'ifdef CONFIG_MMU_GATHER_RCU_TABLE_FREE' in include/asm-generic/tlb.h
348c2ecf20Sopenharmony_ci * for more details.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_cistatic inline void __tlb_remove_table(void *table)
378c2ecf20Sopenharmony_ci{
388c2ecf20Sopenharmony_ci	free_page_and_swap_cache(table);
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#endif /* _ASM_X86_TLB_H */
42