arch/powerpc/mm/hugetlb: NestMMU workaround for hugetlb mprotect RW upgrade
[linux-2.6-block.git] / arch / powerpc / include / asm / book3s / 64 / hugetlb.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
bee8b3b5
AK
2#ifndef _ASM_POWERPC_BOOK3S_64_HUGETLB_H
3#define _ASM_POWERPC_BOOK3S_64_HUGETLB_H
48483760
AK
4/*
5 * For radix we want generic code to handle hugetlb. But then if we want
6 * both hash and radix to be enabled together we need to workaround the
7 * limitations.
8 */
9void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
10void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
11extern unsigned long
12radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
13 unsigned long len, unsigned long pgoff,
14 unsigned long flags);
fbfa26d8 15
8ef5cbde
AK
16extern void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
17 unsigned long addr, pte_t *ptep,
18 pte_t old_pte, pte_t pte);
19
fbfa26d8
AK
20static inline int hstate_get_psize(struct hstate *hstate)
21{
22 unsigned long shift;
23
24 shift = huge_page_shift(hstate);
25 if (shift == mmu_psize_defs[MMU_PAGE_2M].shift)
26 return MMU_PAGE_2M;
27 else if (shift == mmu_psize_defs[MMU_PAGE_1G].shift)
28 return MMU_PAGE_1G;
ccf17c8b
AK
29 else if (shift == mmu_psize_defs[MMU_PAGE_16M].shift)
30 return MMU_PAGE_16M;
31 else if (shift == mmu_psize_defs[MMU_PAGE_16G].shift)
32 return MMU_PAGE_16G;
fbfa26d8
AK
33 else {
34 WARN(1, "Wrong huge page shift\n");
35 return mmu_virtual_psize;
36 }
37}
049d567a 38
40692eb5
AK
39#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
40static inline bool gigantic_page_supported(void)
41{
4ae279c2 42 return true;
40692eb5
AK
43}
44#endif
45
f1981b5b
AK
46/* hugepd entry valid bit */
47#define HUGEPD_VAL_BITS (0x8000000000000000UL)
48
8ef5cbde
AK
49#define huge_ptep_modify_prot_start huge_ptep_modify_prot_start
50extern pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma,
51 unsigned long addr, pte_t *ptep);
52
53#define huge_ptep_modify_prot_commit huge_ptep_modify_prot_commit
54extern void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
55 unsigned long addr, pte_t *ptep,
56 pte_t old_pte, pte_t new_pte);
48483760 57#endif