Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 2 | #ifndef _ASM_POWERPC_PGTABLE_H |
| 3 | #define _ASM_POWERPC_PGTABLE_H |
| 4 | |
David Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 5 | #ifndef __ASSEMBLY__ |
Aneesh Kumar K.V | c34a51c | 2013-11-18 14:58:13 +0530 | [diff] [blame] | 6 | #include <linux/mmdebug.h> |
Scott Wood | 1c98025 | 2014-08-08 18:40:42 -0500 | [diff] [blame] | 7 | #include <linux/mmzone.h> |
David Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 8 | #include <asm/processor.h> /* For TASK_SIZE */ |
| 9 | #include <asm/mmu.h> |
| 10 | #include <asm/page.h> |
Aneesh Kumar K.V | bd5050e | 2018-05-29 19:58:41 +0530 | [diff] [blame] | 11 | #include <asm/tlbflush.h> |
Benjamin Herrenschmidt | 8d30c14 | 2009-02-10 16:02:37 +0000 | [diff] [blame] | 12 | |
David Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 13 | struct mm_struct; |
Benjamin Herrenschmidt | 8d30c14 | 2009-02-10 16:02:37 +0000 | [diff] [blame] | 14 | |
David Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 15 | #endif /* !__ASSEMBLY__ */ |
| 16 | |
Aneesh Kumar K.V | 3dfcb315 | 2015-12-01 09:06:28 +0530 | [diff] [blame] | 17 | #ifdef CONFIG_PPC_BOOK3S |
| 18 | #include <asm/book3s/pgtable.h> |
| 19 | #else |
Aneesh Kumar K.V | 17ed9e3 | 2015-12-01 09:06:38 +0530 | [diff] [blame] | 20 | #include <asm/nohash/pgtable.h> |
Aneesh Kumar K.V | 3dfcb315 | 2015-12-01 09:06:28 +0530 | [diff] [blame] | 21 | #endif /* !CONFIG_PPC_BOOK3S */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | #ifndef __ASSEMBLY__ |
Benjamin Herrenschmidt | 64b3d0e | 2008-12-18 19:13:51 +0000 | [diff] [blame] | 24 | |
Aneesh Kumar K.V | 78f1dbd | 2012-09-10 02:52:57 +0000 | [diff] [blame] | 25 | #include <asm/tlbflush.h> |
| 26 | |
Benjamin Herrenschmidt | 7108700 | 2009-03-19 19:34:09 +0000 | [diff] [blame] | 27 | /* 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 Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 31 | /* |
| 32 | * ZERO_PAGE is a global shared page that is always zero: used |
| 33 | * for zero-mapped memory areas etc.. |
| 34 | */ |
| 35 | extern unsigned long empty_zero_page[]; |
| 36 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) |
| 37 | |
| 38 | extern pgd_t swapper_pg_dir[]; |
| 39 | |
Scott Wood | 1c98025 | 2014-08-08 18:40:42 -0500 | [diff] [blame] | 40 | void limit_zone_pfn(enum zone_type zone, unsigned long max_pfn); |
| 41 | int dma_pfn_limit_to_zone(u64 pfn_limit); |
David Gibson | 9c709f3 | 2007-06-13 14:52:56 +1000 | [diff] [blame] | 42 | extern 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <asm-generic/pgtable.h> |
Benjamin Herrenschmidt | 1e3519f | 2008-07-25 16:21:11 +1000 | [diff] [blame] | 52 | |
| 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 King | 4b3073e | 2009-12-18 16:40:18 +0000 | [diff] [blame] | 63 | extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *); |
Benjamin Herrenschmidt | 1e3519f | 2008-07-25 16:21:11 +1000 | [diff] [blame] | 64 | |
Aneesh Kumar K.V | e2b3d20 | 2013-04-28 09:37:30 +0000 | [diff] [blame] | 65 | extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, |
Aneesh Kumar K.V | b30e759 | 2014-11-05 21:57:41 +0530 | [diff] [blame] | 66 | unsigned long end, int write, |
| 67 | struct page **pages, int *nr); |
Aneesh Kumar K.V | 074c2ea | 2013-06-20 14:30:15 +0530 | [diff] [blame] | 68 | #ifndef CONFIG_TRANSPARENT_HUGEPAGE |
| 69 | #define pmd_large(pmd) 0 |
Aneesh Kumar K.V | 074c2ea | 2013-06-20 14:30:15 +0530 | [diff] [blame] | 70 | #endif |
Alexey Kardashevskiy | e9ab1a1 | 2016-02-15 12:55:03 +1100 | [diff] [blame] | 71 | |
Aneesh Kumar K.V | 94171b1 | 2017-07-27 11:54:53 +0530 | [diff] [blame] | 72 | /* can we use this in kvm */ |
Alexey Kardashevskiy | e9ab1a1 | 2016-02-15 12:55:03 +1100 | [diff] [blame] | 73 | unsigned long vmalloc_to_phys(void *vmalloc_addr); |
| 74 | |
Christophe Leroy | 9b081e1 | 2016-12-07 08:47:24 +0100 | [diff] [blame] | 75 | void pgtable_cache_add(unsigned shift, void (*ctor)(void *)); |
| 76 | void pgtable_cache_init(void); |
Michael Ellerman | 029d925 | 2017-07-14 16:51:23 +1000 | [diff] [blame] | 77 | |
Christophe Leroy | 3184cc4 | 2017-08-02 15:51:03 +0200 | [diff] [blame] | 78 | #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32) |
Michael Ellerman | 029d925 | 2017-07-14 16:51:23 +1000 | [diff] [blame] | 79 | void mark_initmem_nx(void); |
| 80 | #else |
| 81 | static inline void mark_initmem_nx(void) { } |
| 82 | #endif |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #endif /* __ASSEMBLY__ */ |
| 85 | |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 86 | #endif /* _ASM_POWERPC_PGTABLE_H */ |