xref: /openbmc/linux/arch/x86/include/asm/hugetlb.h (revision 1965aae3)
11965aae3SH. Peter Anvin #ifndef _ASM_X86_HUGETLB_H
21965aae3SH. Peter Anvin #define _ASM_X86_HUGETLB_H
3bb898558SAl Viro 
4bb898558SAl Viro #include <asm/page.h>
5bb898558SAl Viro 
6bb898558SAl Viro 
7bb898558SAl Viro static inline int is_hugepage_only_range(struct mm_struct *mm,
8bb898558SAl Viro 					 unsigned long addr,
9bb898558SAl Viro 					 unsigned long len) {
10bb898558SAl Viro 	return 0;
11bb898558SAl Viro }
12bb898558SAl Viro 
13bb898558SAl Viro /*
14bb898558SAl Viro  * If the arch doesn't supply something else, assume that hugepage
15bb898558SAl Viro  * size aligned regions are ok without further preparation.
16bb898558SAl Viro  */
17bb898558SAl Viro static inline int prepare_hugepage_range(struct file *file,
18bb898558SAl Viro 			unsigned long addr, unsigned long len)
19bb898558SAl Viro {
20bb898558SAl Viro 	struct hstate *h = hstate_file(file);
21bb898558SAl Viro 	if (len & ~huge_page_mask(h))
22bb898558SAl Viro 		return -EINVAL;
23bb898558SAl Viro 	if (addr & ~huge_page_mask(h))
24bb898558SAl Viro 		return -EINVAL;
25bb898558SAl Viro 	return 0;
26bb898558SAl Viro }
27bb898558SAl Viro 
28bb898558SAl Viro static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) {
29bb898558SAl Viro }
30bb898558SAl Viro 
31bb898558SAl Viro static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
32bb898558SAl Viro 					  unsigned long addr, unsigned long end,
33bb898558SAl Viro 					  unsigned long floor,
34bb898558SAl Viro 					  unsigned long ceiling)
35bb898558SAl Viro {
36bb898558SAl Viro 	free_pgd_range(tlb, addr, end, floor, ceiling);
37bb898558SAl Viro }
38bb898558SAl Viro 
39bb898558SAl Viro static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
40bb898558SAl Viro 				   pte_t *ptep, pte_t pte)
41bb898558SAl Viro {
42bb898558SAl Viro 	set_pte_at(mm, addr, ptep, pte);
43bb898558SAl Viro }
44bb898558SAl Viro 
45bb898558SAl Viro static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
46bb898558SAl Viro 					    unsigned long addr, pte_t *ptep)
47bb898558SAl Viro {
48bb898558SAl Viro 	return ptep_get_and_clear(mm, addr, ptep);
49bb898558SAl Viro }
50bb898558SAl Viro 
51bb898558SAl Viro static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
52bb898558SAl Viro 					 unsigned long addr, pte_t *ptep)
53bb898558SAl Viro {
54bb898558SAl Viro }
55bb898558SAl Viro 
56bb898558SAl Viro static inline int huge_pte_none(pte_t pte)
57bb898558SAl Viro {
58bb898558SAl Viro 	return pte_none(pte);
59bb898558SAl Viro }
60bb898558SAl Viro 
61bb898558SAl Viro static inline pte_t huge_pte_wrprotect(pte_t pte)
62bb898558SAl Viro {
63bb898558SAl Viro 	return pte_wrprotect(pte);
64bb898558SAl Viro }
65bb898558SAl Viro 
66bb898558SAl Viro static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
67bb898558SAl Viro 					   unsigned long addr, pte_t *ptep)
68bb898558SAl Viro {
69bb898558SAl Viro 	ptep_set_wrprotect(mm, addr, ptep);
70bb898558SAl Viro }
71bb898558SAl Viro 
72bb898558SAl Viro static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
73bb898558SAl Viro 					     unsigned long addr, pte_t *ptep,
74bb898558SAl Viro 					     pte_t pte, int dirty)
75bb898558SAl Viro {
76bb898558SAl Viro 	return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
77bb898558SAl Viro }
78bb898558SAl Viro 
79bb898558SAl Viro static inline pte_t huge_ptep_get(pte_t *ptep)
80bb898558SAl Viro {
81bb898558SAl Viro 	return *ptep;
82bb898558SAl Viro }
83bb898558SAl Viro 
84bb898558SAl Viro static inline int arch_prepare_hugepage(struct page *page)
85bb898558SAl Viro {
86bb898558SAl Viro 	return 0;
87bb898558SAl Viro }
88bb898558SAl Viro 
89bb898558SAl Viro static inline void arch_release_hugepage(struct page *page)
90bb898558SAl Viro {
91bb898558SAl Viro }
92bb898558SAl Viro 
931965aae3SH. Peter Anvin #endif /* _ASM_X86_HUGETLB_H */
94