18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_PAGE_H
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_PAGE_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * Copyright (C) 2001,2005 IBM Corporation.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
108c2ecf20Sopenharmony_ci#include <linux/types.h>
118c2ecf20Sopenharmony_ci#include <linux/kernel.h>
128c2ecf20Sopenharmony_ci#else
138c2ecf20Sopenharmony_ci#include <asm/types.h>
148c2ecf20Sopenharmony_ci#endif
158c2ecf20Sopenharmony_ci#include <asm/asm-const.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages
198c2ecf20Sopenharmony_ci * on PPC44x and 4K/16K on 8xx). For PPC64 we support either 4K or 64K software
208c2ecf20Sopenharmony_ci * page size. When using 64K pages however, whether we are really supporting
218c2ecf20Sopenharmony_ci * 64K pages in HW or not is irrelevant to those definitions.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#define PAGE_SHIFT		CONFIG_PPC_PAGE_SHIFT
248c2ecf20Sopenharmony_ci#define PAGE_SIZE		(ASM_CONST(1) << PAGE_SHIFT)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
278c2ecf20Sopenharmony_ci#ifndef CONFIG_HUGETLB_PAGE
288c2ecf20Sopenharmony_ci#define HPAGE_SHIFT PAGE_SHIFT
298c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_BOOK3S_64)
308c2ecf20Sopenharmony_ciextern unsigned int hpage_shift;
318c2ecf20Sopenharmony_ci#define HPAGE_SHIFT hpage_shift
328c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_8xx)
338c2ecf20Sopenharmony_ci#define HPAGE_SHIFT		19	/* 512k pages */
348c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_FSL_BOOK3E)
358c2ecf20Sopenharmony_ci#define HPAGE_SHIFT		22	/* 4M pages */
368c2ecf20Sopenharmony_ci#endif
378c2ecf20Sopenharmony_ci#define HPAGE_SIZE		((1UL) << HPAGE_SHIFT)
388c2ecf20Sopenharmony_ci#define HPAGE_MASK		(~(HPAGE_SIZE - 1))
398c2ecf20Sopenharmony_ci#define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
408c2ecf20Sopenharmony_ci#define HUGE_MAX_HSTATE		(MMU_PAGE_COUNT-1)
418c2ecf20Sopenharmony_ci#endif
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
458c2ecf20Sopenharmony_ci * assign PAGE_MASK to a larger type it gets extended the way we want
468c2ecf20Sopenharmony_ci * (i.e. with 1s in the high bits)
478c2ecf20Sopenharmony_ci */
488c2ecf20Sopenharmony_ci#define PAGE_MASK      (~((1 << PAGE_SHIFT) - 1))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * KERNELBASE is the virtual address of the start of the kernel, it's often
528c2ecf20Sopenharmony_ci * the same as PAGE_OFFSET, but _might not be_.
538c2ecf20Sopenharmony_ci *
548c2ecf20Sopenharmony_ci * The kdump dump kernel is one example where KERNELBASE != PAGE_OFFSET.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * PAGE_OFFSET is the virtual address of the start of lowmem.
578c2ecf20Sopenharmony_ci *
588c2ecf20Sopenharmony_ci * PHYSICAL_START is the physical address of the start of the kernel.
598c2ecf20Sopenharmony_ci *
608c2ecf20Sopenharmony_ci * MEMORY_START is the physical address of the start of lowmem.
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci * KERNELBASE, PAGE_OFFSET, and PHYSICAL_START are all configurable on
638c2ecf20Sopenharmony_ci * ppc32 and based on how they are set we determine MEMORY_START.
648c2ecf20Sopenharmony_ci *
658c2ecf20Sopenharmony_ci * For the linear mapping the following equation should be true:
668c2ecf20Sopenharmony_ci * KERNELBASE - PAGE_OFFSET = PHYSICAL_START - MEMORY_START
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * Also, KERNELBASE >= PAGE_OFFSET and PHYSICAL_START >= MEMORY_START
698c2ecf20Sopenharmony_ci *
708c2ecf20Sopenharmony_ci * There are two ways to determine a physical address from a virtual one:
718c2ecf20Sopenharmony_ci * va = pa + PAGE_OFFSET - MEMORY_START
728c2ecf20Sopenharmony_ci * va = pa + KERNELBASE - PHYSICAL_START
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * If you want to know something's offset from the start of the kernel you
758c2ecf20Sopenharmony_ci * should subtract KERNELBASE.
768c2ecf20Sopenharmony_ci *
778c2ecf20Sopenharmony_ci * If you want to test if something's a kernel address, use is_kernel_addr().
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define KERNELBASE      ASM_CONST(CONFIG_KERNEL_START)
818c2ecf20Sopenharmony_ci#define PAGE_OFFSET	ASM_CONST(CONFIG_PAGE_OFFSET)
828c2ecf20Sopenharmony_ci#define LOAD_OFFSET	ASM_CONST((CONFIG_KERNEL_START-CONFIG_PHYSICAL_START))
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#if defined(CONFIG_NONSTATIC_KERNEL)
858c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciextern phys_addr_t memstart_addr;
888c2ecf20Sopenharmony_ciextern phys_addr_t kernstart_addr;
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_PPC32)
918c2ecf20Sopenharmony_ciextern long long virt_phys_offset;
928c2ecf20Sopenharmony_ci#endif
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
958c2ecf20Sopenharmony_ci#define PHYSICAL_START	kernstart_addr
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#else	/* !CONFIG_NONSTATIC_KERNEL */
988c2ecf20Sopenharmony_ci#define PHYSICAL_START	ASM_CONST(CONFIG_PHYSICAL_START)
998c2ecf20Sopenharmony_ci#endif
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* See Description below for VIRT_PHYS_OFFSET */
1028c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC32) && defined(CONFIG_BOOKE)
1038c2ecf20Sopenharmony_ci#ifdef CONFIG_RELOCATABLE
1048c2ecf20Sopenharmony_ci#define VIRT_PHYS_OFFSET virt_phys_offset
1058c2ecf20Sopenharmony_ci#else
1068c2ecf20Sopenharmony_ci#define VIRT_PHYS_OFFSET (KERNELBASE - PHYSICAL_START)
1078c2ecf20Sopenharmony_ci#endif
1088c2ecf20Sopenharmony_ci#endif
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
1118c2ecf20Sopenharmony_ci#define MEMORY_START	0UL
1128c2ecf20Sopenharmony_ci#elif defined(CONFIG_NONSTATIC_KERNEL)
1138c2ecf20Sopenharmony_ci#define MEMORY_START	memstart_addr
1148c2ecf20Sopenharmony_ci#else
1158c2ecf20Sopenharmony_ci#define MEMORY_START	(PHYSICAL_START + PAGE_OFFSET - KERNELBASE)
1168c2ecf20Sopenharmony_ci#endif
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#ifdef CONFIG_FLATMEM
1198c2ecf20Sopenharmony_ci#define ARCH_PFN_OFFSET		((unsigned long)(MEMORY_START >> PAGE_SHIFT))
1208c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
1218c2ecf20Sopenharmony_ciextern unsigned long max_mapnr;
1228c2ecf20Sopenharmony_cistatic inline bool pfn_valid(unsigned long pfn)
1238c2ecf20Sopenharmony_ci{
1248c2ecf20Sopenharmony_ci	unsigned long min_pfn = ARCH_PFN_OFFSET;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	return pfn >= min_pfn && pfn < max_mapnr;
1278c2ecf20Sopenharmony_ci}
1288c2ecf20Sopenharmony_ci#endif
1298c2ecf20Sopenharmony_ci#endif
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)
1328c2ecf20Sopenharmony_ci#define virt_to_page(kaddr)	pfn_to_page(virt_to_pfn(kaddr))
1338c2ecf20Sopenharmony_ci#define pfn_to_kaddr(pfn)	__va((pfn) << PAGE_SHIFT)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define virt_addr_valid(vaddr)	({					\
1368c2ecf20Sopenharmony_ci	unsigned long _addr = (unsigned long)vaddr;			\
1378c2ecf20Sopenharmony_ci	_addr >= PAGE_OFFSET && _addr < (unsigned long)high_memory &&	\
1388c2ecf20Sopenharmony_ci	pfn_valid(virt_to_pfn(_addr));					\
1398c2ecf20Sopenharmony_ci})
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/*
1428c2ecf20Sopenharmony_ci * On Book-E parts we need __va to parse the device tree and we can't
1438c2ecf20Sopenharmony_ci * determine MEMORY_START until then.  However we can determine PHYSICAL_START
1448c2ecf20Sopenharmony_ci * from information at hand (program counter, TLB lookup).
1458c2ecf20Sopenharmony_ci *
1468c2ecf20Sopenharmony_ci * On BookE with RELOCATABLE && PPC32
1478c2ecf20Sopenharmony_ci *
1488c2ecf20Sopenharmony_ci *   With RELOCATABLE && PPC32,  we support loading the kernel at any physical
1498c2ecf20Sopenharmony_ci *   address without any restriction on the page alignment.
1508c2ecf20Sopenharmony_ci *
1518c2ecf20Sopenharmony_ci *   We find the runtime address of _stext and relocate ourselves based on
1528c2ecf20Sopenharmony_ci *   the following calculation:
1538c2ecf20Sopenharmony_ci *
1548c2ecf20Sopenharmony_ci *  	  virtual_base = ALIGN_DOWN(KERNELBASE,256M) +
1558c2ecf20Sopenharmony_ci *  				MODULO(_stext.run,256M)
1568c2ecf20Sopenharmony_ci *   and create the following mapping:
1578c2ecf20Sopenharmony_ci *
1588c2ecf20Sopenharmony_ci * 	  ALIGN_DOWN(_stext.run,256M) => ALIGN_DOWN(KERNELBASE,256M)
1598c2ecf20Sopenharmony_ci *
1608c2ecf20Sopenharmony_ci *   When we process relocations, we cannot depend on the
1618c2ecf20Sopenharmony_ci *   existing equation for the __va()/__pa() translations:
1628c2ecf20Sopenharmony_ci *
1638c2ecf20Sopenharmony_ci * 	   __va(x) = (x)  - PHYSICAL_START + KERNELBASE
1648c2ecf20Sopenharmony_ci *
1658c2ecf20Sopenharmony_ci *   Where:
1668c2ecf20Sopenharmony_ci *   	 PHYSICAL_START = kernstart_addr = Physical address of _stext
1678c2ecf20Sopenharmony_ci *  	 KERNELBASE = Compiled virtual address of _stext.
1688c2ecf20Sopenharmony_ci *
1698c2ecf20Sopenharmony_ci *   This formula holds true iff, kernel load address is TLB page aligned.
1708c2ecf20Sopenharmony_ci *
1718c2ecf20Sopenharmony_ci *   In our case, we need to also account for the shift in the kernel Virtual
1728c2ecf20Sopenharmony_ci *   address.
1738c2ecf20Sopenharmony_ci *
1748c2ecf20Sopenharmony_ci *   E.g.,
1758c2ecf20Sopenharmony_ci *
1768c2ecf20Sopenharmony_ci *   Let the kernel be loaded at 64MB and KERNELBASE be 0xc0000000 (same as PAGE_OFFSET).
1778c2ecf20Sopenharmony_ci *   In this case, we would be mapping 0 to 0xc0000000, and kernstart_addr = 64M
1788c2ecf20Sopenharmony_ci *
1798c2ecf20Sopenharmony_ci *   Now __va(1MB) = (0x100000) - (0x4000000) + 0xc0000000
1808c2ecf20Sopenharmony_ci *                 = 0xbc100000 , which is wrong.
1818c2ecf20Sopenharmony_ci *
1828c2ecf20Sopenharmony_ci *   Rather, it should be : 0xc0000000 + 0x100000 = 0xc0100000
1838c2ecf20Sopenharmony_ci *      	according to our mapping.
1848c2ecf20Sopenharmony_ci *
1858c2ecf20Sopenharmony_ci *   Hence we use the following formula to get the translations right:
1868c2ecf20Sopenharmony_ci *
1878c2ecf20Sopenharmony_ci * 	  __va(x) = (x) - [ PHYSICAL_START - Effective KERNELBASE ]
1888c2ecf20Sopenharmony_ci *
1898c2ecf20Sopenharmony_ci * 	  Where :
1908c2ecf20Sopenharmony_ci * 		PHYSICAL_START = dynamic load address.(kernstart_addr variable)
1918c2ecf20Sopenharmony_ci * 		Effective KERNELBASE = virtual_base =
1928c2ecf20Sopenharmony_ci * 				     = ALIGN_DOWN(KERNELBASE,256M) +
1938c2ecf20Sopenharmony_ci * 						MODULO(PHYSICAL_START,256M)
1948c2ecf20Sopenharmony_ci *
1958c2ecf20Sopenharmony_ci * 	To make the cost of __va() / __pa() more light weight, we introduce
1968c2ecf20Sopenharmony_ci * 	a new variable virt_phys_offset, which will hold :
1978c2ecf20Sopenharmony_ci *
1988c2ecf20Sopenharmony_ci * 	virt_phys_offset = Effective KERNELBASE - PHYSICAL_START
1998c2ecf20Sopenharmony_ci * 			 = ALIGN_DOWN(KERNELBASE,256M) -
2008c2ecf20Sopenharmony_ci * 			 	ALIGN_DOWN(PHYSICALSTART,256M)
2018c2ecf20Sopenharmony_ci *
2028c2ecf20Sopenharmony_ci * 	Hence :
2038c2ecf20Sopenharmony_ci *
2048c2ecf20Sopenharmony_ci * 	__va(x) = x - PHYSICAL_START + Effective KERNELBASE
2058c2ecf20Sopenharmony_ci * 		= x + virt_phys_offset
2068c2ecf20Sopenharmony_ci *
2078c2ecf20Sopenharmony_ci * 		and
2088c2ecf20Sopenharmony_ci * 	__pa(x) = x + PHYSICAL_START - Effective KERNELBASE
2098c2ecf20Sopenharmony_ci * 		= x - virt_phys_offset
2108c2ecf20Sopenharmony_ci *
2118c2ecf20Sopenharmony_ci * On non-Book-E PPC64 PAGE_OFFSET and MEMORY_START are constants so use
2128c2ecf20Sopenharmony_ci * the other definitions for __va & __pa.
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC32) && defined(CONFIG_BOOKE)
2158c2ecf20Sopenharmony_ci#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + VIRT_PHYS_OFFSET))
2168c2ecf20Sopenharmony_ci#define __pa(x) ((phys_addr_t)(unsigned long)(x) - VIRT_PHYS_OFFSET)
2178c2ecf20Sopenharmony_ci#else
2188c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci#define VIRTUAL_WARN_ON(x)	WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && (x))
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci/*
2238c2ecf20Sopenharmony_ci * gcc miscompiles (unsigned long)(&static_var) - PAGE_OFFSET
2248c2ecf20Sopenharmony_ci * with -mcmodel=medium, so we use & and | instead of - and + on 64-bit.
2258c2ecf20Sopenharmony_ci * This also results in better code generation.
2268c2ecf20Sopenharmony_ci */
2278c2ecf20Sopenharmony_ci#define __va(x)								\
2288c2ecf20Sopenharmony_ci({									\
2298c2ecf20Sopenharmony_ci	VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET);		\
2308c2ecf20Sopenharmony_ci	(void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET);	\
2318c2ecf20Sopenharmony_ci})
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define __pa(x)								\
2348c2ecf20Sopenharmony_ci({									\
2358c2ecf20Sopenharmony_ci	VIRTUAL_WARN_ON((unsigned long)(x) < PAGE_OFFSET);		\
2368c2ecf20Sopenharmony_ci	(unsigned long)(x) & 0x0fffffffffffffffUL;			\
2378c2ecf20Sopenharmony_ci})
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#else /* 32-bit, non book E */
2408c2ecf20Sopenharmony_ci#define __va(x) ((void *)(unsigned long)((phys_addr_t)(x) + PAGE_OFFSET - MEMORY_START))
2418c2ecf20Sopenharmony_ci#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + MEMORY_START)
2428c2ecf20Sopenharmony_ci#endif
2438c2ecf20Sopenharmony_ci#endif
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci/*
2468c2ecf20Sopenharmony_ci * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI,
2478c2ecf20Sopenharmony_ci * and needs to be executable.  This means the whole heap ends
2488c2ecf20Sopenharmony_ci * up being executable.
2498c2ecf20Sopenharmony_ci */
2508c2ecf20Sopenharmony_ci#define VM_DATA_DEFAULT_FLAGS32	VM_DATA_FLAGS_TSK_EXEC
2518c2ecf20Sopenharmony_ci#define VM_DATA_DEFAULT_FLAGS64	VM_DATA_FLAGS_NON_EXEC
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci#ifdef __powerpc64__
2548c2ecf20Sopenharmony_ci#include <asm/page_64.h>
2558c2ecf20Sopenharmony_ci#else
2568c2ecf20Sopenharmony_ci#include <asm/page_32.h>
2578c2ecf20Sopenharmony_ci#endif
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/*
2608c2ecf20Sopenharmony_ci * Don't compare things with KERNELBASE or PAGE_OFFSET to test for
2618c2ecf20Sopenharmony_ci * "kernelness", use is_kernel_addr() - it should do what you want.
2628c2ecf20Sopenharmony_ci */
2638c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3E_64
2648c2ecf20Sopenharmony_ci#define is_kernel_addr(x)	((x) >= 0x8000000000000000ul)
2658c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_BOOK3S_64)
2668c2ecf20Sopenharmony_ci#define is_kernel_addr(x)	((x) >= PAGE_OFFSET)
2678c2ecf20Sopenharmony_ci#else
2688c2ecf20Sopenharmony_ci#define is_kernel_addr(x)	((x) >= TASK_SIZE)
2698c2ecf20Sopenharmony_ci#endif
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#ifndef CONFIG_PPC_BOOK3S_64
2728c2ecf20Sopenharmony_ci/*
2738c2ecf20Sopenharmony_ci * Use the top bit of the higher-level page table entries to indicate whether
2748c2ecf20Sopenharmony_ci * the entries we point to contain hugepages.  This works because we know that
2758c2ecf20Sopenharmony_ci * the page tables live in kernel space.  If we ever decide to support having
2768c2ecf20Sopenharmony_ci * page tables at arbitrary addresses, this breaks and will have to change.
2778c2ecf20Sopenharmony_ci */
2788c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
2798c2ecf20Sopenharmony_ci#define PD_HUGE 0x8000000000000000UL
2808c2ecf20Sopenharmony_ci#else
2818c2ecf20Sopenharmony_ci#define PD_HUGE 0x80000000
2828c2ecf20Sopenharmony_ci#endif
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#else	/* CONFIG_PPC_BOOK3S_64 */
2858c2ecf20Sopenharmony_ci/*
2868c2ecf20Sopenharmony_ci * Book3S 64 stores real addresses in the hugepd entries to
2878c2ecf20Sopenharmony_ci * avoid overlaps with _PAGE_PRESENT and _PAGE_PTE.
2888c2ecf20Sopenharmony_ci */
2898c2ecf20Sopenharmony_ci#define HUGEPD_ADDR_MASK	(0x0ffffffffffffffful & ~HUGEPD_SHIFT_MASK)
2908c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC_BOOK3S_64 */
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/*
2938c2ecf20Sopenharmony_ci * Some number of bits at the level of the page table that points to
2948c2ecf20Sopenharmony_ci * a hugepte are used to encode the size.  This masks those bits.
2958c2ecf20Sopenharmony_ci * On 8xx, HW assistance requires 4k alignment for the hugepte.
2968c2ecf20Sopenharmony_ci */
2978c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_8xx
2988c2ecf20Sopenharmony_ci#define HUGEPD_SHIFT_MASK     0xfff
2998c2ecf20Sopenharmony_ci#else
3008c2ecf20Sopenharmony_ci#define HUGEPD_SHIFT_MASK     0x3f
3018c2ecf20Sopenharmony_ci#endif
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_64
3068c2ecf20Sopenharmony_ci#include <asm/pgtable-be-types.h>
3078c2ecf20Sopenharmony_ci#else
3088c2ecf20Sopenharmony_ci#include <asm/pgtable-types.h>
3098c2ecf20Sopenharmony_ci#endif
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci#ifndef CONFIG_HUGETLB_PAGE
3138c2ecf20Sopenharmony_ci#define is_hugepd(pdep)		(0)
3148c2ecf20Sopenharmony_ci#define pgd_huge(pgd)		(0)
3158c2ecf20Sopenharmony_ci#endif /* CONFIG_HUGETLB_PAGE */
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistruct page;
3188c2ecf20Sopenharmony_ciextern void clear_user_page(void *page, unsigned long vaddr, struct page *pg);
3198c2ecf20Sopenharmony_ciextern void copy_user_page(void *to, void *from, unsigned long vaddr,
3208c2ecf20Sopenharmony_ci		struct page *p);
3218c2ecf20Sopenharmony_ciextern int devmem_is_allowed(unsigned long pfn);
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_SMLPAR
3248c2ecf20Sopenharmony_civoid arch_free_page(struct page *page, int order);
3258c2ecf20Sopenharmony_ci#define HAVE_ARCH_FREE_PAGE
3268c2ecf20Sopenharmony_ci#endif
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistruct vm_area_struct;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ciextern unsigned long kernstart_virt_addr;
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic inline unsigned long kaslr_offset(void)
3338c2ecf20Sopenharmony_ci{
3348c2ecf20Sopenharmony_ci	return kernstart_virt_addr - KERNELBASE;
3358c2ecf20Sopenharmony_ci}
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci#include <asm-generic/memory_model.h>
3388c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
3398c2ecf20Sopenharmony_ci#include <asm/slice.h>
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_PAGE_H */
342