162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_POWERPC_BOOK3S_PGTABLE_H
362306a36Sopenharmony_ci#define _ASM_POWERPC_BOOK3S_PGTABLE_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifdef CONFIG_PPC64
662306a36Sopenharmony_ci#include <asm/book3s/64/pgtable.h>
762306a36Sopenharmony_ci#else
862306a36Sopenharmony_ci#include <asm/book3s/32/pgtable.h>
962306a36Sopenharmony_ci#endif
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1262306a36Sopenharmony_ci#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
1362306a36Sopenharmony_ciextern int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address,
1462306a36Sopenharmony_ci				 pte_t *ptep, pte_t entry, int dirty);
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistruct file;
1762306a36Sopenharmony_ciextern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
1862306a36Sopenharmony_ci				     unsigned long size, pgprot_t vma_prot);
1962306a36Sopenharmony_ci#define __HAVE_PHYS_MEM_ACCESS_PROT
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_civoid __update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep);
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/*
2462306a36Sopenharmony_ci * This gets called at the end of handling a page fault, when
2562306a36Sopenharmony_ci * the kernel has put a new PTE into the page table for the process.
2662306a36Sopenharmony_ci * We use it to ensure coherency between the i-cache and d-cache
2762306a36Sopenharmony_ci * for the page which has just been mapped in.
2862306a36Sopenharmony_ci * On machines which use an MMU hash table, we use this to put a
2962306a36Sopenharmony_ci * corresponding HPTE into the hash table ahead of time, instead of
3062306a36Sopenharmony_ci * waiting for the inevitable extra hash-table miss exception.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_cistatic inline void update_mmu_cache_range(struct vm_fault *vmf,
3362306a36Sopenharmony_ci		struct vm_area_struct *vma, unsigned long address,
3462306a36Sopenharmony_ci		pte_t *ptep, unsigned int nr)
3562306a36Sopenharmony_ci{
3662306a36Sopenharmony_ci	if (IS_ENABLED(CONFIG_PPC32) && !mmu_has_feature(MMU_FTR_HPTE_TABLE))
3762306a36Sopenharmony_ci		return;
3862306a36Sopenharmony_ci	if (radix_enabled())
3962306a36Sopenharmony_ci		return;
4062306a36Sopenharmony_ci	__update_mmu_cache(vma, address, ptep);
4162306a36Sopenharmony_ci}
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
4462306a36Sopenharmony_ci#endif
45