David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2008, 2009 Cavium Networks, Inc. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __ASM_HUGETLB_H |
| 10 | #define __ASM_HUGETLB_H |
| 11 | |
| 12 | #include <asm/page.h> |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 13 | |
| 14 | static inline int is_hugepage_only_range(struct mm_struct *mm, |
| 15 | unsigned long addr, |
| 16 | unsigned long len) |
| 17 | { |
| 18 | return 0; |
| 19 | } |
| 20 | |
Alexandre Ghiti | 78d6e4e | 2018-10-26 15:08:31 -0700 | [diff] [blame] | 21 | #define __HAVE_ARCH_PREPARE_HUGEPAGE_RANGE |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 22 | static inline int prepare_hugepage_range(struct file *file, |
| 23 | unsigned long addr, |
| 24 | unsigned long len) |
| 25 | { |
| 26 | unsigned long task_size = STACK_TOP; |
| 27 | struct hstate *h = hstate_file(file); |
| 28 | |
| 29 | if (len & ~huge_page_mask(h)) |
| 30 | return -EINVAL; |
| 31 | if (addr & ~huge_page_mask(h)) |
| 32 | return -EINVAL; |
| 33 | if (len > task_size) |
| 34 | return -ENOMEM; |
| 35 | if (task_size - len < addr) |
| 36 | return -EINVAL; |
| 37 | return 0; |
| 38 | } |
| 39 | |
Alexandre Ghiti | a4d8385 | 2018-10-26 15:08:12 -0700 | [diff] [blame] | 40 | #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 41 | static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, |
| 42 | unsigned long addr, pte_t *ptep) |
| 43 | { |
| 44 | pte_t clear; |
| 45 | pte_t pte = *ptep; |
| 46 | |
| 47 | pte_val(clear) = (unsigned long)invalid_pte_table; |
| 48 | set_pte_at(mm, addr, ptep, clear); |
| 49 | return pte; |
| 50 | } |
| 51 | |
Alexandre Ghiti | fe63222 | 2018-10-26 15:08:17 -0700 | [diff] [blame] | 52 | #define __HAVE_ARCH_HUGE_PTEP_CLEAR_FLUSH |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 53 | static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, |
| 54 | unsigned long addr, pte_t *ptep) |
| 55 | { |
Hillf Danton | 5639bc4 | 2011-11-22 14:38:02 +0000 | [diff] [blame] | 56 | flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma))); |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Alexandre Ghiti | cae72ab | 2018-10-26 15:08:22 -0700 | [diff] [blame] | 59 | #define __HAVE_ARCH_HUGE_PTE_NONE |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 60 | static inline int huge_pte_none(pte_t pte) |
| 61 | { |
| 62 | unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL; |
| 63 | return !val || (val == (unsigned long)invalid_pte_table); |
| 64 | } |
| 65 | |
Alexandre Ghiti | facf6d5 | 2018-10-26 15:08:39 -0700 | [diff] [blame] | 66 | #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 67 | static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 68 | unsigned long addr, |
| 69 | pte_t *ptep, pte_t pte, |
| 70 | int dirty) |
| 71 | { |
David Daney | ac53c4f | 2012-12-03 12:44:26 -0800 | [diff] [blame] | 72 | int changed = !pte_same(*ptep, pte); |
| 73 | |
| 74 | if (changed) { |
| 75 | set_pte_at(vma->vm_mm, addr, ptep, pte); |
| 76 | /* |
| 77 | * There could be some standard sized pages in there, |
| 78 | * get them all. |
| 79 | */ |
| 80 | flush_tlb_range(vma, addr, addr + HPAGE_SIZE); |
| 81 | } |
| 82 | return changed; |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Will Deacon | 5d3a551 | 2012-10-08 16:29:32 -0700 | [diff] [blame] | 85 | static inline void arch_clear_hugepage_flags(struct page *page) |
| 86 | { |
| 87 | } |
| 88 | |
Alexandre Ghiti | 1e5f50f | 2018-10-26 15:08:03 -0700 | [diff] [blame] | 89 | #include <asm-generic/hugetlb.h> |
| 90 | |
David Daney | 50a41ff | 2009-05-27 17:47:42 -0700 | [diff] [blame] | 91 | #endif /* __ASM_HUGETLB_H */ |