blob: 14c79a7dc855062e65ff314b2e28961f47538bbf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Paul Mackerras047ea782005-11-19 20:17:32 +11002#ifndef _ASM_POWERPC_PGTABLE_H
3#define _ASM_POWERPC_PGTABLE_H
4
David Gibson9c709f32007-06-13 14:52:56 +10005#ifndef __ASSEMBLY__
Aneesh Kumar K.Vc34a51c2013-11-18 14:58:13 +05306#include <linux/mmdebug.h>
Scott Wood1c980252014-08-08 18:40:42 -05007#include <linux/mmzone.h>
David Gibson9c709f32007-06-13 14:52:56 +10008#include <asm/processor.h> /* For TASK_SIZE */
9#include <asm/mmu.h>
10#include <asm/page.h>
Aneesh Kumar K.Vbd5050e2018-05-29 19:58:41 +053011#include <asm/tlbflush.h>
Benjamin Herrenschmidt8d30c142009-02-10 16:02:37 +000012
David Gibson9c709f32007-06-13 14:52:56 +100013struct mm_struct;
Benjamin Herrenschmidt8d30c142009-02-10 16:02:37 +000014
David Gibson9c709f32007-06-13 14:52:56 +100015#endif /* !__ASSEMBLY__ */
16
Aneesh Kumar K.V3dfcb3152015-12-01 09:06:28 +053017#ifdef CONFIG_PPC_BOOK3S
18#include <asm/book3s/pgtable.h>
19#else
Aneesh Kumar K.V17ed9e32015-12-01 09:06:38 +053020#include <asm/nohash/pgtable.h>
Aneesh Kumar K.V3dfcb3152015-12-01 09:06:28 +053021#endif /* !CONFIG_PPC_BOOK3S */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#ifndef __ASSEMBLY__
Benjamin Herrenschmidt64b3d0e2008-12-18 19:13:51 +000024
Aneesh Kumar K.V78f1dbd2012-09-10 02:52:57 +000025#include <asm/tlbflush.h>
26
Benjamin Herrenschmidt71087002009-03-19 19:34:09 +000027/* Keep these as a macros to avoid include dependency mess */
28#define pte_page(x) pfn_to_page(pte_pfn(x))
29#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
30
David Gibson9c709f32007-06-13 14:52:56 +100031/*
32 * ZERO_PAGE is a global shared page that is always zero: used
33 * for zero-mapped memory areas etc..
34 */
35extern unsigned long empty_zero_page[];
36#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
37
38extern pgd_t swapper_pg_dir[];
39
Scott Wood1c980252014-08-08 18:40:42 -050040void limit_zone_pfn(enum zone_type zone, unsigned long max_pfn);
41int dma_pfn_limit_to_zone(u64 pfn_limit);
David Gibson9c709f32007-06-13 14:52:56 +100042extern void paging_init(void);
43
44/*
45 * kern_addr_valid is intended to indicate whether an address is a valid
46 * kernel address. Most 32-bit archs define it as always true (like this)
47 * but most 64-bit archs actually perform a test. What should we do here?
48 */
49#define kern_addr_valid(addr) (1)
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <asm-generic/pgtable.h>
Benjamin Herrenschmidt1e3519f2008-07-25 16:21:11 +100052
53
54/*
55 * This gets called at the end of handling a page fault, when
56 * the kernel has put a new PTE into the page table for the process.
57 * We use it to ensure coherency between the i-cache and d-cache
58 * for the page which has just been mapped in.
59 * On machines which use an MMU hash table, we use this to put a
60 * corresponding HPTE into the hash table ahead of time, instead of
61 * waiting for the inevitable extra hash-table miss exception.
62 */
Russell King4b3073e2009-12-18 16:40:18 +000063extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
Benjamin Herrenschmidt1e3519f2008-07-25 16:21:11 +100064
Aneesh Kumar K.Ve2b3d202013-04-28 09:37:30 +000065extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
Aneesh Kumar K.Vb30e7592014-11-05 21:57:41 +053066 unsigned long end, int write,
67 struct page **pages, int *nr);
Aneesh Kumar K.V074c2ea2013-06-20 14:30:15 +053068#ifndef CONFIG_TRANSPARENT_HUGEPAGE
69#define pmd_large(pmd) 0
Aneesh Kumar K.V074c2ea2013-06-20 14:30:15 +053070#endif
Alexey Kardashevskiye9ab1a12016-02-15 12:55:03 +110071
Aneesh Kumar K.V94171b12017-07-27 11:54:53 +053072/* can we use this in kvm */
Alexey Kardashevskiye9ab1a12016-02-15 12:55:03 +110073unsigned long vmalloc_to_phys(void *vmalloc_addr);
74
Christophe Leroy9b081e12016-12-07 08:47:24 +010075void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
76void pgtable_cache_init(void);
Michael Ellerman029d9252017-07-14 16:51:23 +100077
Christophe Leroy3184cc42017-08-02 15:51:03 +020078#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
Michael Ellerman029d9252017-07-14 16:51:23 +100079void mark_initmem_nx(void);
80#else
81static inline void mark_initmem_nx(void) { }
82#endif
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#endif /* __ASSEMBLY__ */
85
Paul Mackerras047ea782005-11-19 20:17:32 +110086#endif /* _ASM_POWERPC_PGTABLE_H */