blob: ab7f44475b1febd2f7bbfcd6d09afbb6292a313d [file] [log] [blame]
Paul Mackerras047ea782005-11-19 20:17:32 +11001#ifndef _ASM_POWERPC_PGTABLE_H
2#define _ASM_POWERPC_PGTABLE_H
3
David Gibson9c709f32007-06-13 14:52:56 +10004#ifndef __ASSEMBLY__
Aneesh Kumar K.Vc34a51c2013-11-18 14:58:13 +05305#include <linux/mmdebug.h>
Scott Wood1c980252014-08-08 18:40:42 -05006#include <linux/mmzone.h>
David Gibson9c709f32007-06-13 14:52:56 +10007#include <asm/processor.h> /* For TASK_SIZE */
8#include <asm/mmu.h>
9#include <asm/page.h>
Benjamin Herrenschmidt8d30c142009-02-10 16:02:37 +000010
David Gibson9c709f32007-06-13 14:52:56 +100011struct mm_struct;
Benjamin Herrenschmidt8d30c142009-02-10 16:02:37 +000012
David Gibson9c709f32007-06-13 14:52:56 +100013#endif /* !__ASSEMBLY__ */
14
Aneesh Kumar K.V3dfcb3152015-12-01 09:06:28 +053015#ifdef CONFIG_PPC_BOOK3S
16#include <asm/book3s/pgtable.h>
17#else
Aneesh Kumar K.V17ed9e32015-12-01 09:06:38 +053018#include <asm/nohash/pgtable.h>
Aneesh Kumar K.V3dfcb3152015-12-01 09:06:28 +053019#endif /* !CONFIG_PPC_BOOK3S */
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#ifndef __ASSEMBLY__
Benjamin Herrenschmidt64b3d0e2008-12-18 19:13:51 +000022
Aneesh Kumar K.V78f1dbd2012-09-10 02:52:57 +000023#include <asm/tlbflush.h>
24
Benjamin Herrenschmidt71087002009-03-19 19:34:09 +000025/* Keep these as a macros to avoid include dependency mess */
26#define pte_page(x) pfn_to_page(pte_pfn(x))
27#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
28
David Gibson9c709f32007-06-13 14:52:56 +100029/*
30 * ZERO_PAGE is a global shared page that is always zero: used
31 * for zero-mapped memory areas etc..
32 */
33extern unsigned long empty_zero_page[];
34#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
35
36extern pgd_t swapper_pg_dir[];
37
Scott Wood1c980252014-08-08 18:40:42 -050038void limit_zone_pfn(enum zone_type zone, unsigned long max_pfn);
39int dma_pfn_limit_to_zone(u64 pfn_limit);
David Gibson9c709f32007-06-13 14:52:56 +100040extern void paging_init(void);
41
42/*
43 * kern_addr_valid is intended to indicate whether an address is a valid
44 * kernel address. Most 32-bit archs define it as always true (like this)
45 * but most 64-bit archs actually perform a test. What should we do here?
46 */
47#define kern_addr_valid(addr) (1)
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <asm-generic/pgtable.h>
Benjamin Herrenschmidt1e3519f2008-07-25 16:21:11 +100050
51
52/*
53 * This gets called at the end of handling a page fault, when
54 * the kernel has put a new PTE into the page table for the process.
55 * We use it to ensure coherency between the i-cache and d-cache
56 * for the page which has just been mapped in.
57 * On machines which use an MMU hash table, we use this to put a
58 * corresponding HPTE into the hash table ahead of time, instead of
59 * waiting for the inevitable extra hash-table miss exception.
60 */
Russell King4b3073e2009-12-18 16:40:18 +000061extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
Benjamin Herrenschmidt1e3519f2008-07-25 16:21:11 +100062
Aneesh Kumar K.Ve2b3d202013-04-28 09:37:30 +000063extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
Aneesh Kumar K.Vb30e7592014-11-05 21:57:41 +053064 unsigned long end, int write,
65 struct page **pages, int *nr);
Aneesh Kumar K.V074c2ea2013-06-20 14:30:15 +053066#ifndef CONFIG_TRANSPARENT_HUGEPAGE
67#define pmd_large(pmd) 0
Aneesh Kumar K.V074c2ea2013-06-20 14:30:15 +053068#endif
Aneesh Kumar K.V691e95f2015-03-30 10:41:03 +053069pte_t *__find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
Aneesh Kumar K.V891121e2015-10-09 08:32:21 +053070 bool *is_thp, unsigned *shift);
Aneesh Kumar K.V691e95f2015-03-30 10:41:03 +053071static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
Aneesh Kumar K.V891121e2015-10-09 08:32:21 +053072 bool *is_thp, unsigned *shift)
Aneesh Kumar K.V691e95f2015-03-30 10:41:03 +053073{
Aneesh Kumar K.V9af3f562016-07-26 15:22:39 -070074 VM_WARN(!arch_irqs_disabled(),
75 "%s called with irq enabled\n", __func__);
Aneesh Kumar K.V891121e2015-10-09 08:32:21 +053076 return __find_linux_pte_or_hugepte(pgdir, ea, is_thp, shift);
Aneesh Kumar K.V691e95f2015-03-30 10:41:03 +053077}
Alexey Kardashevskiye9ab1a12016-02-15 12:55:03 +110078
79unsigned long vmalloc_to_phys(void *vmalloc_addr);
80
Christophe Leroy9b081e12016-12-07 08:47:24 +010081void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
82void pgtable_cache_init(void);
Michael Ellerman029d9252017-07-14 16:51:23 +100083
Christophe Leroy3184cc42017-08-02 15:51:03 +020084#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
Michael Ellerman029d9252017-07-14 16:51:23 +100085void mark_initmem_nx(void);
86#else
87static inline void mark_initmem_nx(void) { }
88#endif
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#endif /* __ASSEMBLY__ */
91
Paul Mackerras047ea782005-11-19 20:17:32 +110092#endif /* _ASM_POWERPC_PGTABLE_H */