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 | |
Christophe Leroy | 45d0ba5 | 2019-04-26 05:59:47 +0000 | [diff] [blame] | 16 | extern bool hugetlb_disabled; |
| 17 | |
Nick Child | c13f2b2 | 2021-12-16 17:00:18 -0500 | [diff] [blame] | 18 | void __init hugetlbpage_init_default(void); |
Christophe Leroy | c5710cd2 | 2019-04-26 05:59:48 +0000 | [diff] [blame] | 19 | |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 20 | 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] | 21 | unsigned long len); |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 22 | |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 23 | static inline int is_hugepage_only_range(struct mm_struct *mm, |
| 24 | unsigned long addr, |
| 25 | unsigned long len) |
| 26 | { |
Nicholas Piggin | 014a32b | 2018-03-07 11:37:17 +1000 | [diff] [blame] | 27 | if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled()) |
| 28 | return slice_is_hugepage_only_range(mm, addr, len); |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 29 | return 0; |
| 30 | } |
Anshuman Khandual | b0eae98 | 2020-06-03 16:01:01 -0700 | [diff] [blame] | 31 | #define is_hugepage_only_range is_hugepage_only_range |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [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 | { |
Aneesh Kumar K.V | 88247e8 | 2014-02-12 09:13:36 +0530 | [diff] [blame] | 42 | return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 1)); |
David Gibson | 0895ecd | 2009-10-26 19:24:31 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Alexandre Ghiti | fe63222 | 2018-10-26 15:08:17 -0700 | [diff] [blame] | 45 | #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 46 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, |
| 47 | unsigned long addr, pte_t *ptep) |
| 48 | { |
Christophe Leroy | 584dbc7 | 2018-10-18 05:22:06 +0000 | [diff] [blame] | 49 | huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); |
Aneesh Kumar K.V | 13dce03 | 2016-07-13 15:06:38 +0530 | [diff] [blame] | 50 | flush_hugetlb_page(vma, addr); |
Gerald Schaefer | 8fe627e | 2008-04-28 02:13:28 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Alexandre Ghiti | facf6d5 | 2018-10-26 15:08:39 -0700 | [diff] [blame] | 53 | #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS |
Breno Leitao | bce85a1 | 2018-10-31 11:24:11 -0300 | [diff] [blame] | 54 | int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 55 | unsigned long addr, pte_t *ptep, |
| 56 | pte_t pte, int dirty); |
Gerald Schaefer | 7f2e952 | 2008-04-28 02:13:29 -0700 | [diff] [blame] | 57 | |
Aneesh Kumar K.V | ef26b76 | 2020-07-13 20:37:48 +0530 | [diff] [blame] | 58 | void gigantic_hugetlb_cma_reserve(void) __init; |
Alexandre Ghiti | 1e5f50f | 2018-10-26 15:08:03 -0700 | [diff] [blame] | 59 | #include <asm-generic/hugetlb.h> |
| 60 | |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 61 | #else /* ! CONFIG_HUGETLB_PAGE */ |
Becky Bruce | 41151e7 | 2011-06-28 09:54:48 +0000 | [diff] [blame] | 62 | static inline void flush_hugetlb_page(struct vm_area_struct *vma, |
| 63 | unsigned long vmaddr) |
| 64 | { |
| 65 | } |
Becky Bruce | a614688 | 2011-10-10 10:50:43 +0000 | [diff] [blame] | 66 | |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 67 | #define hugepd_shift(x) 0 |
Aneesh Kumar K.V | b30e759 | 2014-11-05 21:57:41 +0530 | [diff] [blame] | 68 | 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] | 69 | unsigned pdshift) |
| 70 | { |
Mathieu Malaterre | d873152 | 2018-04-13 20:41:43 +0200 | [diff] [blame] | 71 | return NULL; |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 72 | } |
Aneesh Kumar K.V | ef26b76 | 2020-07-13 20:37:48 +0530 | [diff] [blame] | 73 | |
| 74 | |
| 75 | static inline void __init gigantic_hugetlb_cma_reserve(void) |
| 76 | { |
| 77 | } |
| 78 | |
Aneesh Kumar K.V | 2940999 | 2013-06-20 14:30:16 +0530 | [diff] [blame] | 79 | #endif /* CONFIG_HUGETLB_PAGE */ |
Becky Bruce | a614688 | 2011-10-10 10:50:43 +0000 | [diff] [blame] | 80 | |
Gerald Schaefer | 6d77907 | 2008-04-28 02:13:27 -0700 | [diff] [blame] | 81 | #endif /* _ASM_POWERPC_HUGETLB_H */ |