aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/include/asm/hugetlb.h114
-rw-r--r--arch/mips/mm/Makefile1
-rw-r--r--arch/mips/mm/hugetlbpage.c101
3 files changed, 216 insertions, 0 deletions
diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
new file mode 100644
index 000000000000..f5e856015329
--- /dev/null
+++ b/arch/mips/include/asm/hugetlb.h
@@ -0,0 +1,114 @@
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>
13
14
15static inline int is_hugepage_only_range(struct mm_struct *mm,
16 unsigned long addr,
17 unsigned long len)
18{
19 return 0;
20}
21
22static 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
40static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
41{
42}
43
44static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
45 unsigned long addr,
46 unsigned long end,
47 unsigned long floor,
48 unsigned long ceiling)
49{
50 free_pgd_range(tlb, addr, end, floor, ceiling);
51}
52
53static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
54 pte_t *ptep, pte_t pte)
55{
56 set_pte_at(mm, addr, ptep, pte);
57}
58
59static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
60 unsigned long addr, pte_t *ptep)
61{
62 pte_t clear;
63 pte_t pte = *ptep;
64
65 pte_val(clear) = (unsigned long)invalid_pte_table;
66 set_pte_at(mm, addr, ptep, clear);
67 return pte;
68}
69
70static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
71 unsigned long addr, pte_t *ptep)
72{
73}
74
75static inline int huge_pte_none(pte_t pte)
76{
77 unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
78 return !val || (val == (unsigned long)invalid_pte_table);
79}
80
81static inline pte_t huge_pte_wrprotect(pte_t pte)
82{
83 return pte_wrprotect(pte);
84}
85
86static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
87 unsigned long addr, pte_t *ptep)
88{
89 ptep_set_wrprotect(mm, addr, ptep);
90}
91
92static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
93 unsigned long addr,
94 pte_t *ptep, pte_t pte,
95 int dirty)
96{
97 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
98}
99
100static inline pte_t huge_ptep_get(pte_t *ptep)
101{
102 return *ptep;
103}
104
105static inline int arch_prepare_hugepage(struct page *page)
106{
107 return 0;
108}
109
110static inline void arch_release_hugepage(struct page *page)
111{
112}
113
114#endif /* __ASM_HUGETLB_H */
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index d7ec95522292..f0e435599707 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -8,6 +8,7 @@ obj-y += cache.o dma-default.o extable.o fault.o \
8obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o 8obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
9obj-$(CONFIG_64BIT) += pgtable-64.o 9obj-$(CONFIG_64BIT) += pgtable-64.o
10obj-$(CONFIG_HIGHMEM) += highmem.o 10obj-$(CONFIG_HIGHMEM) += highmem.o
11obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
11 12
12obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o 13obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o
13obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o 14obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o
diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c
new file mode 100644
index 000000000000..471c09aa1614
--- /dev/null
+++ b/arch/mips/mm/hugetlbpage.c
@@ -0,0 +1,101 @@
1/*
2 * MIPS Huge TLB Page Support for Kernel.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com>
9 * Copyright 2005, Embedded Alley Solutions, Inc.
10 * Matt Porter <mporter@embeddedalley.com>
11 * Copyright (C) 2008, 2009 Cavium Networks, Inc.
12 */
13
14#include <linux/init.h>
15#include <linux/fs.h>
16#include <linux/mm.h>
17#include <linux/hugetlb.h>
18#include <linux/pagemap.h>
19#include <linux/smp_lock.h>
20#include <linux/slab.h>
21#include <linux/err.h>
22#include <linux/sysctl.h>
23#include <asm/mman.h>
24#include <asm/tlb.h>
25#include <asm/tlbflush.h>
26
27pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr,
28 unsigned long sz)
29{
30 pgd_t *pgd;
31 pud_t *pud;
32 pte_t *pte = NULL;
33
34 pgd = pgd_offset(mm, addr);
35 pud = pud_alloc(mm, pgd, addr);
36 if (pud)
37 pte = (pte_t *)pmd_alloc(mm, pud, addr);
38
39 return pte;
40}
41
42pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
43{
44 pgd_t *pgd;
45 pud_t *pud;
46 pmd_t *pmd = NULL;
47
48 pgd = pgd_offset(mm, addr);
49 if (pgd_present(*pgd)) {
50 pud = pud_offset(pgd, addr);
51 if (pud_present(*pud))
52 pmd = pmd_offset(pud, addr);
53 }
54 return (pte_t *) pmd;
55}
56
57int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
58{
59 return 0;
60}
61
62/*
63 * This function checks for proper alignment of input addr and len parameters.
64 */
65int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
66{
67 if (len & ~HPAGE_MASK)
68 return -EINVAL;
69 if (addr & ~HPAGE_MASK)
70 return -EINVAL;
71 return 0;
72}
73
74struct page *
75follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
76{
77 return ERR_PTR(-EINVAL);
78}
79
80int pmd_huge(pmd_t pmd)
81{
82 return (pmd_val(pmd) & _PAGE_HUGE) != 0;
83}
84
85int pud_huge(pud_t pud)
86{
87 return (pud_val(pud) & _PAGE_HUGE) != 0;
88}
89
90struct page *
91follow_huge_pmd(struct mm_struct *mm, unsigned long address,
92 pmd_t *pmd, int write)
93{
94 struct page *page;
95
96 page = pte_page(*(pte_t *)pmd);
97 if (page)
98 page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
99 return page;
100}
101