summaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
blob: a46616937d20572af9f7062bea70bc7b6fb6f531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
#define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H

#define PAGE_SHIFT_8M		23

static inline pte_t *hugepd_page(hugepd_t hpd)
{
	BUG_ON(!hugepd_ok(hpd));

	return (pte_t *)__va(hpd_val(hpd) & ~HUGEPD_SHIFT_MASK);
}

static inline unsigned int hugepd_shift(hugepd_t hpd)
{
	return ((hpd_val(hpd) & _PMD_PAGE_MASK) >> 1) + 17;
}

static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
				    unsigned int pdshift)
{
	unsigned long idx = (addr & ((1UL << pdshift) - 1)) >> PAGE_SHIFT;

	return hugepd_page(hpd) + idx;
}

static inline void flush_hugetlb_page(struct vm_area_struct *vma,
				      unsigned long vmaddr)
{
	flush_tlb_page(vma, vmaddr);
}

static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
{
	*hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT |
			 (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : _PMD_PAGE_512K));
}

static inline int check_and_get_huge_psize(int shift)
{
	return shift_to_mmu_psize(shift);
}

#endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */