Path: blob/master/arch/powerpc/include/asm/book3s/64/hugetlb.h
26519 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_POWERPC_BOOK3S_64_HUGETLB_H2#define _ASM_POWERPC_BOOK3S_64_HUGETLB_H34#include <asm/firmware.h>56/*7* For radix we want generic code to handle hugetlb. But then if we want8* both hash and radix to be enabled together we need to workaround the9* limitations.10*/11void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);12void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);1314extern void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma,15unsigned long addr, pte_t *ptep,16pte_t old_pte, pte_t pte);1718static inline int hstate_get_psize(struct hstate *hstate)19{20unsigned long shift;2122shift = huge_page_shift(hstate);23if (shift == mmu_psize_defs[MMU_PAGE_2M].shift)24return MMU_PAGE_2M;25else if (shift == mmu_psize_defs[MMU_PAGE_1G].shift)26return MMU_PAGE_1G;27else if (shift == mmu_psize_defs[MMU_PAGE_16M].shift)28return MMU_PAGE_16M;29else if (shift == mmu_psize_defs[MMU_PAGE_16G].shift)30return MMU_PAGE_16G;31else {32WARN(1, "Wrong huge page shift\n");33return mmu_virtual_psize;34}35}3637#define __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED38static inline bool gigantic_page_runtime_supported(void)39{40/*41* We used gigantic page reservation with hypervisor assist in some case.42* We cannot use runtime allocation of gigantic pages in those platforms43* This is hash translation mode LPARs.44*/45if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled())46return false;4748return true;49}5051#define huge_ptep_modify_prot_start huge_ptep_modify_prot_start52extern pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,53unsigned long addr, pte_t *ptep);5455#define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit56extern void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,57unsigned long addr, pte_t *ptep,58pte_t old_pte, pte_t new_pte);5960static inline void flush_hugetlb_page(struct vm_area_struct *vma,61unsigned long vmaddr)62{63if (radix_enabled())64return radix__flush_hugetlb_page(vma, vmaddr);65}6667void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);6869static inline int check_and_get_huge_psize(int shift)70{71int mmu_psize;7273if (shift > SLICE_HIGH_SHIFT)74return -EINVAL;7576mmu_psize = shift_to_mmu_psize(shift);7778/*79* We need to make sure that for different page sizes reported by80* firmware we only add hugetlb support for page sizes that can be81* supported by linux page table layout.82* For now we have83* Radix: 2M and 1G84* Hash: 16M and 16G85*/86if (radix_enabled()) {87if (mmu_psize != MMU_PAGE_2M && mmu_psize != MMU_PAGE_1G)88return -EINVAL;89} else {90if (mmu_psize != MMU_PAGE_16M && mmu_psize != MMU_PAGE_16G)91return -EINVAL;92}93return mmu_psize;94}9596#define arch_has_huge_bootmem_alloc arch_has_huge_bootmem_alloc9798static inline bool arch_has_huge_bootmem_alloc(void)99{100return (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled());101}102#endif103104105