Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 2 | #ifndef _ASM_POWERPC_HUGETLB_H |
| 3 | #define _ASM_POWERPC_HUGETLB_H |
| 4 | |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 5 | #ifdef CONFIG_HUGETLB_PAGE |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 6 | #include <asm/page.h> |
| 7 | |
Aneesh Kumar K.V | cf9427b | 2013-04-28 09:37:29 +0000 | [diff] [blame] | 8 | #ifdef CONFIG_PPC_BOOK3S_64 |
Aneesh Kumar K.V | bee8b3b | 2016-11-28 11:46:58 +0530 | [diff] [blame] | 9 | #include <asm/book3s/64/hugetlb.h> |
Christophe Leroy | 8197af2 | 2019-04-26 05:59:44 +0000 | [diff] [blame^] | 10 | #elif defined(CONFIG_PPC_FSL_BOOK3E) |
| 11 | #include <asm/nohash/hugetlb-book3e.h> |
| 12 | #elif defined(CONFIG_PPC_8xx) |
| 13 | #include <asm/nohash/32/hugetlb-8xx.h> |
Aneesh Kumar K.V | cf9427b | 2013-04-28 09:37:29 +0000 | [diff] [blame] | 14 | #endif /* CONFIG_PPC_BOOK3S_64 */ |
| 15 | |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 16 | void flush_dcache_icache_hugepage(struct page *page); |
| 17 | |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 18 | int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 19 | unsigned long len); |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 20 | |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 21 | static inline int is_hugepage_only_range(struct mm_struct *mm, |
| 22 | unsigned long addr, |
| 23 | unsigned long len) |
| 24 | { |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 25 | if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) |
| 26 | return slice_is_hugepage_only_range(mm, addr, len); |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 27 | return 0; |
| 28 | } |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 29 | |
Becky Bruce | d93e4d7 | 2011-11-28 14:43:33 +0000 | [diff] [blame] | 30 | void book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea, |
| 31 | pte_t pte); |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 32 | |
Alexandre Ghiti | 1e5f50f | 2018-10-26 15:08:03 -0700 | [diff] [blame] | 33 | #define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE |
Jan Beulich | 42b7772 | 2008-07-23 21:27:10 -0700 | [diff] [blame] | 34 | void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr, |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 35 | unsigned long end, unsigned long floor, |
| 36 | unsigned long ceiling); |
| 37 | |
Alexandre Ghiti | a4d8385 | 2018-10-26 15:08:12 -0700 | [diff] [blame] | 38 | #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 39 | static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, |
| 40 | unsigned long addr, pte_t *ptep) |
| 41 | { |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 42 | #ifdef CONFIG_PPC64 |
Aneesh Kumar K.V | 88247e8 | 2014-02-12 09:13:36 +0530 | [diff] [blame] | 43 | return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 1)); |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 44 | #else |
| 45 | return __pte(pte_update(ptep, ~0UL, 0)); |
| 46 | #endif |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Alexandre Ghiti | fe63222 | 2018-10-26 15:08:17 -0700 | [diff] [blame] | 49 | #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 50 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, |
| 51 | unsigned long addr, pte_t *ptep) |
| 52 | { |
Christophe Leroy | 584dbc7 | 2018-10-18 05:22:06 +0000 | [diff] [blame] | 53 | huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); |
Aneesh Kumar K.V | 13dce03 | 2016-07-13 15:06:38 +0530 | [diff] [blame] | 54 | flush_hugetlb_page(vma, addr); |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Alexandre Ghiti | facf6d5 | 2018-10-26 15:08:39 -0700 | [diff] [blame] | 57 | #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS |
Breno Leitao | bce85a1 | 2018-10-31 11:24:11 -0300 | [diff] [blame] | 58 | int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 59 | unsigned long addr, pte_t *ptep, |
| 60 | pte_t pte, int dirty); |
Gerald Schaefer | 7f2e952 | 2008-04-28 02:13:29 -0700 | [diff] [blame] | 61 | |
Will Deacon | 5d3a551 | 2012-10-08 16:29:32 -0700 | [diff] [blame] | 62 | static inline void arch_clear_hugepage_flags(struct page *page) |
| 63 | { |
| 64 | } |
| 65 | |
Alexandre Ghiti | 1e5f50f | 2018-10-26 15:08:03 -0700 | [diff] [blame] | 66 | #include <asm-generic/hugetlb.h> |
| 67 | |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 68 | #else /* ! CONFIG_HUGETLB_PAGE */ |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 69 | static inline void flush_hugetlb_page(struct vm_area_struct *vma, |
| 70 | unsigned long vmaddr) |
| 71 | { |
| 72 | } |
Becky Bruce | a614688 | 2011-10-10 10:50:43 +0000 | [diff] [blame] | 73 | |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 74 | #define hugepd_shift(x) 0 |
Aneesh Kumar K.V | b30e759 | 2014-11-05 21:57:41 +0530 | [diff] [blame] | 75 | static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 76 | unsigned pdshift) |
| 77 | { |
Mathieu Malaterre | d873152 | 2018-04-13 20:41:43 +0200 | [diff] [blame] | 78 | return NULL; |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 79 | } |
| 80 | #endif /* CONFIG_HUGETLB_PAGE */ |
Becky Bruce | a614688 | 2011-10-10 10:50:43 +0000 | [diff] [blame] | 81 | |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 82 | #endif /* _ASM_POWERPC_HUGETLB_H */ |