162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_POWERPC_TLBFLUSH_RADIX_H
362306a36Sopenharmony_ci#define _ASM_POWERPC_TLBFLUSH_RADIX_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/hvcall.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#define RIC_FLUSH_TLB 0
862306a36Sopenharmony_ci#define RIC_FLUSH_PWC 1
962306a36Sopenharmony_ci#define RIC_FLUSH_ALL 2
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct vm_area_struct;
1262306a36Sopenharmony_cistruct mm_struct;
1362306a36Sopenharmony_cistruct mmu_gather;
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistatic inline u64 psize_to_rpti_pgsize(unsigned long psize)
1662306a36Sopenharmony_ci{
1762306a36Sopenharmony_ci	if (psize == MMU_PAGE_4K)
1862306a36Sopenharmony_ci		return H_RPTI_PAGE_4K;
1962306a36Sopenharmony_ci	if (psize == MMU_PAGE_64K)
2062306a36Sopenharmony_ci		return H_RPTI_PAGE_64K;
2162306a36Sopenharmony_ci	if (psize == MMU_PAGE_2M)
2262306a36Sopenharmony_ci		return H_RPTI_PAGE_2M;
2362306a36Sopenharmony_ci	if (psize == MMU_PAGE_1G)
2462306a36Sopenharmony_ci		return H_RPTI_PAGE_1G;
2562306a36Sopenharmony_ci	return H_RPTI_PAGE_ALL;
2662306a36Sopenharmony_ci}
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic inline int mmu_get_ap(int psize)
2962306a36Sopenharmony_ci{
3062306a36Sopenharmony_ci	return mmu_psize_defs[psize].ap;
3162306a36Sopenharmony_ci}
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifdef CONFIG_PPC_RADIX_MMU
3462306a36Sopenharmony_ciextern void radix__tlbiel_all(unsigned int action);
3562306a36Sopenharmony_ciextern void radix__flush_tlb_lpid_page(unsigned int lpid,
3662306a36Sopenharmony_ci					unsigned long addr,
3762306a36Sopenharmony_ci					unsigned long page_size);
3862306a36Sopenharmony_ciextern void radix__flush_pwc_lpid(unsigned int lpid);
3962306a36Sopenharmony_ciextern void radix__flush_all_lpid(unsigned int lpid);
4062306a36Sopenharmony_ciextern void radix__flush_all_lpid_guest(unsigned int lpid);
4162306a36Sopenharmony_ci#else
4262306a36Sopenharmony_cistatic inline void radix__tlbiel_all(unsigned int action) { WARN_ON(1); }
4362306a36Sopenharmony_cistatic inline void radix__flush_tlb_lpid_page(unsigned int lpid,
4462306a36Sopenharmony_ci					unsigned long addr,
4562306a36Sopenharmony_ci					unsigned long page_size)
4662306a36Sopenharmony_ci{
4762306a36Sopenharmony_ci	WARN_ON(1);
4862306a36Sopenharmony_ci}
4962306a36Sopenharmony_cistatic inline void radix__flush_pwc_lpid(unsigned int lpid)
5062306a36Sopenharmony_ci{
5162306a36Sopenharmony_ci	WARN_ON(1);
5262306a36Sopenharmony_ci}
5362306a36Sopenharmony_cistatic inline void radix__flush_all_lpid(unsigned int lpid)
5462306a36Sopenharmony_ci{
5562306a36Sopenharmony_ci	WARN_ON(1);
5662306a36Sopenharmony_ci}
5762306a36Sopenharmony_cistatic inline void radix__flush_all_lpid_guest(unsigned int lpid)
5862306a36Sopenharmony_ci{
5962306a36Sopenharmony_ci	WARN_ON(1);
6062306a36Sopenharmony_ci}
6162306a36Sopenharmony_ci#endif
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciextern void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma,
6462306a36Sopenharmony_ci					   unsigned long start, unsigned long end);
6562306a36Sopenharmony_ciextern void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start,
6662306a36Sopenharmony_ci					 unsigned long end, int psize);
6762306a36Sopenharmony_civoid radix__flush_tlb_pwc_range_psize(struct mm_struct *mm, unsigned long start,
6862306a36Sopenharmony_ci				      unsigned long end, int psize);
6962306a36Sopenharmony_ciextern void radix__flush_pmd_tlb_range(struct vm_area_struct *vma,
7062306a36Sopenharmony_ci				       unsigned long start, unsigned long end);
7162306a36Sopenharmony_ciextern void radix__flush_pud_tlb_range(struct vm_area_struct *vma,
7262306a36Sopenharmony_ci				       unsigned long start, unsigned long end);
7362306a36Sopenharmony_ciextern void radix__flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
7462306a36Sopenharmony_ci			    unsigned long end);
7562306a36Sopenharmony_ciextern void radix__flush_tlb_kernel_range(unsigned long start, unsigned long end);
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciextern void radix__local_flush_tlb_mm(struct mm_struct *mm);
7862306a36Sopenharmony_ciextern void radix__local_flush_all_mm(struct mm_struct *mm);
7962306a36Sopenharmony_ciextern void radix__local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
8062306a36Sopenharmony_ciextern void radix__local_flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
8162306a36Sopenharmony_ci					      int psize);
8262306a36Sopenharmony_ciextern void radix__tlb_flush(struct mmu_gather *tlb);
8362306a36Sopenharmony_ci#ifdef CONFIG_SMP
8462306a36Sopenharmony_ciextern void radix__flush_tlb_mm(struct mm_struct *mm);
8562306a36Sopenharmony_ciextern void radix__flush_all_mm(struct mm_struct *mm);
8662306a36Sopenharmony_ciextern void radix__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
8762306a36Sopenharmony_ciextern void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr,
8862306a36Sopenharmony_ci					int psize);
8962306a36Sopenharmony_ci#else
9062306a36Sopenharmony_ci#define radix__flush_tlb_mm(mm)		radix__local_flush_tlb_mm(mm)
9162306a36Sopenharmony_ci#define radix__flush_all_mm(mm)		radix__local_flush_all_mm(mm)
9262306a36Sopenharmony_ci#define radix__flush_tlb_page(vma,addr)	radix__local_flush_tlb_page(vma,addr)
9362306a36Sopenharmony_ci#define radix__flush_tlb_page_psize(mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p)
9462306a36Sopenharmony_ci#endif
9562306a36Sopenharmony_ciextern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr);
9662306a36Sopenharmony_ciextern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr);
9762306a36Sopenharmony_ciextern void radix__flush_tlb_all(void);
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#endif
100