Commit | Line | Data |
---|---|---|
48483760 AK |
1 | #include <linux/mm.h> |
2 | #include <linux/hugetlb.h> | |
3 | #include <asm/pgtable.h> | |
4 | #include <asm/pgalloc.h> | |
5 | #include <asm/cacheflush.h> | |
6 | #include <asm/machdep.h> | |
7 | #include <asm/mman.h> | |
fbfa26d8 | 8 | #include <asm/tlb.h> |
48483760 AK |
9 | |
10 | void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr) | |
11 | { | |
fbfa26d8 | 12 | int psize; |
48483760 AK |
13 | struct hstate *hstate = hstate_file(vma->vm_file); |
14 | ||
fbfa26d8 AK |
15 | psize = hstate_get_psize(hstate); |
16 | radix__flush_tlb_page_psize(vma->vm_mm, vmaddr, psize); | |
48483760 AK |
17 | } |
18 | ||
19 | void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr) | |
20 | { | |
fbfa26d8 | 21 | int psize; |
48483760 AK |
22 | struct hstate *hstate = hstate_file(vma->vm_file); |
23 | ||
fbfa26d8 AK |
24 | psize = hstate_get_psize(hstate); |
25 | radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, psize); | |
48483760 AK |
26 | } |
27 | ||
28 | /* | |
29 | * A vairant of hugetlb_get_unmapped_area doing topdown search | |
30 | * FIXME!! should we do as x86 does or non hugetlb area does ? | |
31 | * ie, use topdown or not based on mmap_is_legacy check ? | |
32 | */ | |
33 | unsigned long | |
34 | radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr, | |
35 | unsigned long len, unsigned long pgoff, | |
36 | unsigned long flags) | |
37 | { | |
38 | struct mm_struct *mm = current->mm; | |
39 | struct vm_area_struct *vma; | |
40 | struct hstate *h = hstate_file(file); | |
41 | struct vm_unmapped_area_info info; | |
42 | ||
43 | if (len & ~huge_page_mask(h)) | |
44 | return -EINVAL; | |
45 | if (len > TASK_SIZE) | |
46 | return -ENOMEM; | |
47 | ||
48 | if (flags & MAP_FIXED) { | |
49 | if (prepare_hugepage_range(file, addr, len)) | |
50 | return -EINVAL; | |
51 | return addr; | |
52 | } | |
53 | ||
54 | if (addr) { | |
55 | addr = ALIGN(addr, huge_page_size(h)); | |
56 | vma = find_vma(mm, addr); | |
57 | if (TASK_SIZE - len >= addr && | |
58 | (!vma || addr + len <= vma->vm_start)) | |
59 | return addr; | |
60 | } | |
61 | /* | |
62 | * We are always doing an topdown search here. Slice code | |
63 | * does that too. | |
64 | */ | |
65 | info.flags = VM_UNMAPPED_AREA_TOPDOWN; | |
66 | info.length = len; | |
67 | info.low_limit = PAGE_SIZE; | |
68 | info.high_limit = current->mm->mmap_base; | |
69 | info.align_mask = PAGE_MASK & ~huge_page_mask(h); | |
70 | info.align_offset = 0; | |
71 | return vm_unmapped_area(&info); | |
72 | } |