blob: fd5c0873a57d8f0018721de508f94a033227ed31 [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
David Gibson0895ecd2009-10-26 19:24:31 +000016void flush_dcache_icache_hugepage(struct page *page);
17
Nicholas Piggin014a32b2018-03-07 11:37:17 +100018int slice_is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
Gerald Schaefer6d779072008-04-28 02:13:27 -070019 unsigned long len);
Nicholas Piggin014a32b2018-03-07 11:37:17 +100020
Becky Bruce41151e72011-06-28 09:54:48 +000021static inline int is_hugepage_only_range(struct mm_struct *mm,
22 unsigned long addr,
23 unsigned long len)
24{
Nicholas Piggin014a32b2018-03-07 11:37:17 +100025 if (IS_ENABLED(CONFIG_PPC_MM_SLICES) && !radix_enabled())
26 return slice_is_hugepage_only_range(mm, addr, len);
Becky Bruce41151e72011-06-28 09:54:48 +000027 return 0;
28}
Becky Bruce41151e72011-06-28 09:54:48 +000029
Becky Bruced93e4d72011-11-28 14:43:33 +000030void book3e_hugetlb_preload(struct vm_area_struct *vma, unsigned long ea,
31 pte_t pte);
Gerald Schaefer6d779072008-04-28 02:13:27 -070032
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{
Becky Bruce41151e72011-06-28 09:54:48 +000042#ifdef CONFIG_PPC64
Aneesh Kumar K.V88247e82014-02-12 09:13:36 +053043 return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 1));
Becky Bruce41151e72011-06-28 09:54:48 +000044#else
45 return __pte(pte_update(ptep, ~0UL, 0));
46#endif
David Gibson0895ecd2009-10-26 19:24:31 +000047}
48
Alexandre Ghitife632222018-10-26 15:08:17 -070049#define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH
Gerald Schaefer8fe627e2008-04-28 02:13:28 -070050static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
51 unsigned long addr, pte_t *ptep)
52{
Christophe Leroy584dbc72018-10-18 05:22:06 +000053 huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
Aneesh Kumar K.V13dce032016-07-13 15:06:38 +053054 flush_hugetlb_page(vma, addr);
Gerald Schaefer8fe627e2008-04-28 02:13:28 -070055}
56
Alexandre Ghitifacf6d52018-10-26 15:08:39 -070057#define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS
Breno Leitaobce85a12018-10-31 11:24:11 -030058int huge_ptep_set_access_flags(struct vm_area_struct *vma,
59 unsigned long addr, pte_t *ptep,
60 pte_t pte, int dirty);
Gerald Schaefer7f2e9522008-04-28 02:13:29 -070061
Will Deacon5d3a5512012-10-08 16:29:32 -070062static inline void arch_clear_hugepage_flags(struct page *page)
63{
64}
65
Alexandre Ghiti1e5f50f2018-10-26 15:08:03 -070066#include <asm-generic/hugetlb.h>
67
Becky Bruce41151e72011-06-28 09:54:48 +000068#else /* ! CONFIG_HUGETLB_PAGE */
Becky Bruce41151e72011-06-28 09:54:48 +000069static inline void flush_hugetlb_page(struct vm_area_struct *vma,
70 unsigned long vmaddr)
71{
72}
Becky Brucea6146882011-10-10 10:50:43 +000073
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053074#define hugepd_shift(x) 0
Aneesh Kumar K.Vb30e7592014-11-05 21:57:41 +053075static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053076 unsigned pdshift)
77{
Mathieu Malaterred8731522018-04-13 20:41:43 +020078 return NULL;
Aneesh Kumar K.V29409992013-06-20 14:30:16 +053079}
80#endif /* CONFIG_HUGETLB_PAGE */
Becky Brucea6146882011-10-10 10:50:43 +000081
Gerald Schaefer6d779072008-04-28 02:13:27 -070082#endif /* _ASM_POWERPC_HUGETLB_H */