blob: 962708fa1017823e9be09e8fd7a7917625272298 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Gerald Schaefer6d779072008-04-28 02:13:27 -07002#ifndef _ASM_POWERPC_HUGETLB_H
3#define _ASM_POWERPC_HUGETLB_H
4
Becky Bruce41151e72011-06-28 09:54:48 +00005#ifdef CONFIG_HUGETLB_PAGE
Gerald Schaefer6d779072008-04-28 02:13:27 -07006#include <asm/page.h>
7
Aneesh Kumar K.Vcf9427b2013-04-28 09:37:29 +00008#ifdef CONFIG_PPC_BOOK3S_64
Aneesh Kumar K.Vbee8b3b2016-11-28 11:46:58 +05309#include <asm/book3s/64/hugetlb.h>
Christophe Leroy8197af22019-04-26 05:59:44 +000010#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.Vcf9427b2013-04-28 09:37:29 +000014#endif /* CONFIG_PPC_BOOK3S_64 */
15
Christophe Leroy45d0ba52019-04-26 05:59:47 +000016extern bool hugetlb_disabled;
17
Nick Childc13f2b22021-12-16 17:00:18 -050018void __init hugetlbpage_init_default(void);
Christophe Leroyc5710cd22019-04-26 05:59:48 +000019
Nicholas Piggin014a32b2018-03-07 11:37:17 +100020int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
Gerald Schaefer6d779072008-04-28 02:13:27 -070021 unsigned long len);
Nicholas Piggin014a32b2018-03-07 11:37:17 +100022
Becky Bruce41151e72011-06-28 09:54:48 +000023static inline int is_hugepage_only_range(struct mm_struct *mm,
24 unsigned long addr,
25 unsigned long len)
26{
Nicholas Piggin014a32b2018-03-07 11:37:17 +100027 if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled())
28 return slice_is_hugepage_only_range(mm, addr, len);
Becky Bruce41151e72011-06-28 09:54:48 +000029 return 0;
30}
Anshuman Khandualb0eae982020-06-03 16:01:01 -070031#define is_hugepage_only_range is_hugepage_only_range
Becky Bruce41151e72011-06-28 09:54:48 +000032
Alexandre Ghiti1e5f50f2018-10-26 15:08:03 -070033#define __HAVE_ARCH_HUGETLB_FREE_PGD_RANGE
Jan Beulich42b77722008-07-23 21:27:10 -070034void hugetlb_free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
Gerald Schaefer6d779072008-04-28 02:13:27 -070035 unsigned long end, unsigned long floor,
36 unsigned long ceiling);
37
Alexandre Ghitia4d83852018-10-26 15:08:12 -070038#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
David Gibson0895ecd2009-10-26 19:24:31 +000039static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
40 unsigned long addr, pte_t *ptep)
41{
Aneesh Kumar K.V88247e82014-02-12 09:13:36 +053042 return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 1));
David Gibson0895ecd2009-10-26 19:24:31 +000043}
44
Alexandre Ghitife632222018-10-26 15:08:17 -070045#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
Gerald Schaefer8fe627e2008-04-28 02:13:28 -070046static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
47 unsigned long addr, pte_t *ptep)
48{
Christophe Leroy584dbc72018-10-18 05:22:06 +000049 huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
Aneesh Kumar K.V13dce032016-07-13 15:06:38 +053050 flush_hugetlb_page(vma, addr);
Gerald Schaefer8fe627e2008-04-28 02:13:28 -070051}
52
Alexandre Ghitifacf6d52018-10-26 15:08:39 -070053#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
Breno Leitaobce85a12018-10-31 11:24:11 -030054int huge_ptep_set_access_flags(struct vm_area_struct *vma,
55 unsigned long addr, pte_t *ptep,
56 pte_t pte, int dirty);
Gerald Schaefer7f2e9522008-04-28 02:13:29 -070057
Aneesh Kumar K.Vef26b762020-07-13 20:37:48 +053058void gigantic_hugetlb_cma_reserve(void) __init;
Alexandre Ghiti1e5f50f2018-10-26 15:08:03 -070059#include <asm-generic/hugetlb.h>
60
Becky Bruce41151e72011-06-28 09:54:48 +000061#else /* ! CONFIG_HUGETLB_PAGE */
Becky Bruce41151e72011-06-28 09:54:48 +000062static inline void flush_hugetlb_page(struct vm_area_struct *vma,
63 unsigned long vmaddr)
64{
65}
Becky Brucea6146882011-10-10 10:50:43 +000066
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053067#define hugepd_shift(x) 0
Aneesh Kumar K.Vb30e7592014-11-05 21:57:41 +053068static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053069 unsigned pdshift)
70{
Mathieu Malaterred8731522018-04-13 20:41:43 +020071 return NULL;
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053072}
Aneesh Kumar K.Vef26b762020-07-13 20:37:48 +053073
74
75static inline void __init gigantic_hugetlb_cma_reserve(void)
76{
77}
78
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053079#endif /* CONFIG_HUGETLB_PAGE */
Becky Brucea6146882011-10-10 10:50:43 +000080
Gerald Schaefer6d779072008-04-28 02:13:27 -070081#endif /* _ASM_POWERPC_HUGETLB_H */