diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:23:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:23:15 -0400 |
commit | 9e2d8656f5e8aa214e66b462680cf86b210b74a8 (patch) | |
tree | f67d62e896cedf75599ea45f9ecf9999c6ad24cd /arch/sparc/include | |
parent | 1ea4f4f8405cc1ceec23f2d261bc3775785e6712 (diff) | |
parent | 9e695d2ecc8451cc2c1603d60b5c8e7f5581923a (diff) |
Merge branch 'akpm' (Andrew's patch-bomb)
Merge patches from Andrew Morton:
"A few misc things and very nearly all of the MM tree. A tremendous
amount of stuff (again), including a significant rbtree library
rework."
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (160 commits)
sparc64: Support transparent huge pages.
mm: thp: Use more portable PMD clearing sequenece in zap_huge_pmd().
mm: Add and use update_mmu_cache_pmd() in transparent huge page code.
sparc64: Document PGD and PMD layout.
sparc64: Eliminate PTE table memory wastage.
sparc64: Halve the size of PTE tables
sparc64: Only support 4MB huge pages and 8KB base pages.
memory-hotplug: suppress "Trying to free nonexistent resource <XXXXXXXXXXXXXXXX-YYYYYYYYYYYYYYYY>" warning
mm: memcg: clean up mm_match_cgroup() signature
mm: document PageHuge somewhat
mm: use %pK for /proc/vmallocinfo
mm, thp: fix mlock statistics
mm, thp: fix mapped pages avoiding unevictable list on mlock
memory-hotplug: update memory block's state and notify userspace
memory-hotplug: preparation to notify memory block's state at memory hot remove
mm: avoid section mismatch warning for memblock_type_name
make GFP_NOTRACK definition unconditional
cma: decrease cc.nr_migratepages after reclaiming pagelist
CMA: migrate mlocked pages
kpageflags: fix wrong KPF_THP on non-huge compound pages
...
Diffstat (limited to 'arch/sparc/include')
-rw-r--r-- | arch/sparc/include/asm/hugetlb.h | 9 | ||||
-rw-r--r-- | arch/sparc/include/asm/mmu_64.h | 19 | ||||
-rw-r--r-- | arch/sparc/include/asm/mmu_context_64.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/asm/page_64.h | 21 | ||||
-rw-r--r-- | arch/sparc/include/asm/pgalloc_64.h | 56 | ||||
-rw-r--r-- | arch/sparc/include/asm/pgtable_64.h | 253 | ||||
-rw-r--r-- | arch/sparc/include/asm/tsb.h | 106 |
7 files changed, 318 insertions, 148 deletions
diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h index 177061064ee6..8c5eed6d267f 100644 --- a/arch/sparc/include/asm/hugetlb.h +++ b/arch/sparc/include/asm/hugetlb.h | |||
@@ -10,7 +10,10 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, | |||
10 | pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, | 10 | pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, |
11 | pte_t *ptep); | 11 | pte_t *ptep); |
12 | 12 | ||
13 | void hugetlb_prefault_arch_hook(struct mm_struct *mm); | 13 | static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm) |
14 | { | ||
15 | hugetlb_setup(mm); | ||
16 | } | ||
14 | 17 | ||
15 | static inline int is_hugepage_only_range(struct mm_struct *mm, | 18 | static inline int is_hugepage_only_range(struct mm_struct *mm, |
16 | unsigned long addr, | 19 | unsigned long addr, |
@@ -82,4 +85,8 @@ static inline void arch_release_hugepage(struct page *page) | |||
82 | { | 85 | { |
83 | } | 86 | } |
84 | 87 | ||
88 | static inline void arch_clear_hugepage_flags(struct page *page) | ||
89 | { | ||
90 | } | ||
91 | |||
85 | #endif /* _ASM_SPARC64_HUGETLB_H */ | 92 | #endif /* _ASM_SPARC64_HUGETLB_H */ |
diff --git a/arch/sparc/include/asm/mmu_64.h b/arch/sparc/include/asm/mmu_64.h index 9067dc500535..76092c4dd277 100644 --- a/arch/sparc/include/asm/mmu_64.h +++ b/arch/sparc/include/asm/mmu_64.h | |||
@@ -30,22 +30,8 @@ | |||
30 | #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \ | 30 | #define CTX_PGSZ_MASK ((CTX_PGSZ_BITS << CTX_PGSZ0_SHIFT) | \ |
31 | (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT)) | 31 | (CTX_PGSZ_BITS << CTX_PGSZ1_SHIFT)) |
32 | 32 | ||
33 | #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB) | ||
34 | #define CTX_PGSZ_BASE CTX_PGSZ_8KB | 33 | #define CTX_PGSZ_BASE CTX_PGSZ_8KB |
35 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB) | 34 | #define CTX_PGSZ_HUGE CTX_PGSZ_4MB |
36 | #define CTX_PGSZ_BASE CTX_PGSZ_64KB | ||
37 | #else | ||
38 | #error No page size specified in kernel configuration | ||
39 | #endif | ||
40 | |||
41 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) | ||
42 | #define CTX_PGSZ_HUGE CTX_PGSZ_4MB | ||
43 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K) | ||
44 | #define CTX_PGSZ_HUGE CTX_PGSZ_512KB | ||
45 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | ||
46 | #define CTX_PGSZ_HUGE CTX_PGSZ_64KB | ||
47 | #endif | ||
48 | |||
49 | #define CTX_PGSZ_KERN CTX_PGSZ_4MB | 35 | #define CTX_PGSZ_KERN CTX_PGSZ_4MB |
50 | 36 | ||
51 | /* Thus, when running on UltraSPARC-III+ and later, we use the following | 37 | /* Thus, when running on UltraSPARC-III+ and later, we use the following |
@@ -96,7 +82,7 @@ struct tsb_config { | |||
96 | 82 | ||
97 | #define MM_TSB_BASE 0 | 83 | #define MM_TSB_BASE 0 |
98 | 84 | ||
99 | #ifdef CONFIG_HUGETLB_PAGE | 85 | #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) |
100 | #define MM_TSB_HUGE 1 | 86 | #define MM_TSB_HUGE 1 |
101 | #define MM_NUM_TSBS 2 | 87 | #define MM_NUM_TSBS 2 |
102 | #else | 88 | #else |
@@ -107,6 +93,7 @@ typedef struct { | |||
107 | spinlock_t lock; | 93 | spinlock_t lock; |
108 | unsigned long sparc64_ctx_val; | 94 | unsigned long sparc64_ctx_val; |
109 | unsigned long huge_pte_count; | 95 | unsigned long huge_pte_count; |
96 | struct page *pgtable_page; | ||
110 | struct tsb_config tsb_block[MM_NUM_TSBS]; | 97 | struct tsb_config tsb_block[MM_NUM_TSBS]; |
111 | struct hv_tsb_descr tsb_descr[MM_NUM_TSBS]; | 98 | struct hv_tsb_descr tsb_descr[MM_NUM_TSBS]; |
112 | } mm_context_t; | 99 | } mm_context_t; |
diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h index a97fd085cebe..9191ca62ed9c 100644 --- a/arch/sparc/include/asm/mmu_context_64.h +++ b/arch/sparc/include/asm/mmu_context_64.h | |||
@@ -36,7 +36,7 @@ static inline void tsb_context_switch(struct mm_struct *mm) | |||
36 | { | 36 | { |
37 | __tsb_context_switch(__pa(mm->pgd), | 37 | __tsb_context_switch(__pa(mm->pgd), |
38 | &mm->context.tsb_block[0], | 38 | &mm->context.tsb_block[0], |
39 | #ifdef CONFIG_HUGETLB_PAGE | 39 | #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) |
40 | (mm->context.tsb_block[1].tsb ? | 40 | (mm->context.tsb_block[1].tsb ? |
41 | &mm->context.tsb_block[1] : | 41 | &mm->context.tsb_block[1] : |
42 | NULL) | 42 | NULL) |
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h index f0d09b401036..4b39f74d6ca0 100644 --- a/arch/sparc/include/asm/page_64.h +++ b/arch/sparc/include/asm/page_64.h | |||
@@ -3,13 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/const.h> | 4 | #include <linux/const.h> |
5 | 5 | ||
6 | #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB) | ||
7 | #define PAGE_SHIFT 13 | 6 | #define PAGE_SHIFT 13 |
8 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB) | ||
9 | #define PAGE_SHIFT 16 | ||
10 | #else | ||
11 | #error No page size specified in kernel configuration | ||
12 | #endif | ||
13 | 7 | ||
14 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) | 8 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) |
15 | #define PAGE_MASK (~(PAGE_SIZE-1)) | 9 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
@@ -21,15 +15,9 @@ | |||
21 | #define DCACHE_ALIASING_POSSIBLE | 15 | #define DCACHE_ALIASING_POSSIBLE |
22 | #endif | 16 | #endif |
23 | 17 | ||
24 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) | ||
25 | #define HPAGE_SHIFT 22 | 18 | #define HPAGE_SHIFT 22 |
26 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K) | ||
27 | #define HPAGE_SHIFT 19 | ||
28 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | ||
29 | #define HPAGE_SHIFT 16 | ||
30 | #endif | ||
31 | 19 | ||
32 | #ifdef CONFIG_HUGETLB_PAGE | 20 | #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) |
33 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) | 21 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) |
34 | #define HPAGE_MASK (~(HPAGE_SIZE - 1UL)) | 22 | #define HPAGE_MASK (~(HPAGE_SIZE - 1UL)) |
35 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | 23 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
@@ -38,6 +26,11 @@ | |||
38 | 26 | ||
39 | #ifndef __ASSEMBLY__ | 27 | #ifndef __ASSEMBLY__ |
40 | 28 | ||
29 | #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) | ||
30 | struct mm_struct; | ||
31 | extern void hugetlb_setup(struct mm_struct *mm); | ||
32 | #endif | ||
33 | |||
41 | #define WANT_PAGE_VIRTUAL | 34 | #define WANT_PAGE_VIRTUAL |
42 | 35 | ||
43 | extern void _clear_page(void *page); | 36 | extern void _clear_page(void *page); |
@@ -98,7 +91,7 @@ typedef unsigned long pgprot_t; | |||
98 | 91 | ||
99 | #endif /* (STRICT_MM_TYPECHECKS) */ | 92 | #endif /* (STRICT_MM_TYPECHECKS) */ |
100 | 93 | ||
101 | typedef struct page *pgtable_t; | 94 | typedef pte_t *pgtable_t; |
102 | 95 | ||
103 | #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ | 96 | #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ |
104 | (_AC(0x0000000070000000,UL)) : \ | 97 | (_AC(0x0000000070000000,UL)) : \ |
diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h index 40b2d7a7023d..bcfe063bce23 100644 --- a/arch/sparc/include/asm/pgalloc_64.h +++ b/arch/sparc/include/asm/pgalloc_64.h | |||
@@ -38,51 +38,20 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) | |||
38 | kmem_cache_free(pgtable_cache, pmd); | 38 | kmem_cache_free(pgtable_cache, pmd); |
39 | } | 39 | } |
40 | 40 | ||
41 | static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, | 41 | extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, |
42 | unsigned long address) | 42 | unsigned long address); |
43 | { | 43 | extern pgtable_t pte_alloc_one(struct mm_struct *mm, |
44 | return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); | 44 | unsigned long address); |
45 | } | 45 | extern void pte_free_kernel(struct mm_struct *mm, pte_t *pte); |
46 | 46 | extern void pte_free(struct mm_struct *mm, pgtable_t ptepage); | |
47 | static inline pgtable_t pte_alloc_one(struct mm_struct *mm, | ||
48 | unsigned long address) | ||
49 | { | ||
50 | struct page *page; | ||
51 | pte_t *pte; | ||
52 | |||
53 | pte = pte_alloc_one_kernel(mm, address); | ||
54 | if (!pte) | ||
55 | return NULL; | ||
56 | page = virt_to_page(pte); | ||
57 | pgtable_page_ctor(page); | ||
58 | return page; | ||
59 | } | ||
60 | |||
61 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) | ||
62 | { | ||
63 | free_page((unsigned long)pte); | ||
64 | } | ||
65 | |||
66 | static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) | ||
67 | { | ||
68 | pgtable_page_dtor(ptepage); | ||
69 | __free_page(ptepage); | ||
70 | } | ||
71 | 47 | ||
72 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) | 48 | #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(MM, PMD, PTE) |
73 | #define pmd_populate(MM,PMD,PTE_PAGE) \ | 49 | #define pmd_populate(MM, PMD, PTE) pmd_set(MM, PMD, PTE) |
74 | pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) | 50 | #define pmd_pgtable(PMD) ((pte_t *)__pmd_page(PMD)) |
75 | #define pmd_pgtable(pmd) pmd_page(pmd) | ||
76 | 51 | ||
77 | #define check_pgt_cache() do { } while (0) | 52 | #define check_pgt_cache() do { } while (0) |
78 | 53 | ||
79 | static inline void pgtable_free(void *table, bool is_page) | 54 | extern void pgtable_free(void *table, bool is_page); |
80 | { | ||
81 | if (is_page) | ||
82 | free_page((unsigned long)table); | ||
83 | else | ||
84 | kmem_cache_free(pgtable_cache, table); | ||
85 | } | ||
86 | 55 | ||
87 | #ifdef CONFIG_SMP | 56 | #ifdef CONFIG_SMP |
88 | 57 | ||
@@ -113,11 +82,10 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is | |||
113 | } | 82 | } |
114 | #endif /* !CONFIG_SMP */ | 83 | #endif /* !CONFIG_SMP */ |
115 | 84 | ||
116 | static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage, | 85 | static inline void __pte_free_tlb(struct mmu_gather *tlb, pte_t *pte, |
117 | unsigned long address) | 86 | unsigned long address) |
118 | { | 87 | { |
119 | pgtable_page_dtor(ptepage); | 88 | pgtable_free_tlb(tlb, pte, true); |
120 | pgtable_free_tlb(tlb, page_address(ptepage), true); | ||
121 | } | 89 | } |
122 | 90 | ||
123 | #define __pmd_free_tlb(tlb, pmd, addr) \ | 91 | #define __pmd_free_tlb(tlb, pmd, addr) \ |
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 61210db139fb..95515f1e7cef 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h | |||
@@ -45,40 +45,59 @@ | |||
45 | 45 | ||
46 | #define vmemmap ((struct page *)VMEMMAP_BASE) | 46 | #define vmemmap ((struct page *)VMEMMAP_BASE) |
47 | 47 | ||
48 | /* XXX All of this needs to be rethought so we can take advantage | ||
49 | * XXX cheetah's full 64-bit virtual address space, ie. no more hole | ||
50 | * XXX in the middle like on spitfire. -DaveM | ||
51 | */ | ||
52 | /* | ||
53 | * Given a virtual address, the lowest PAGE_SHIFT bits determine offset | ||
54 | * into the page; the next higher PAGE_SHIFT-3 bits determine the pte# | ||
55 | * in the proper pagetable (the -3 is from the 8 byte ptes, and each page | ||
56 | * table is a single page long). The next higher PMD_BITS determine pmd# | ||
57 | * in the proper pmdtable (where we must have PMD_BITS <= (PAGE_SHIFT-2) | ||
58 | * since the pmd entries are 4 bytes, and each pmd page is a single page | ||
59 | * long). Finally, the higher few bits determine pgde#. | ||
60 | */ | ||
61 | |||
62 | /* PMD_SHIFT determines the size of the area a second-level page | 48 | /* PMD_SHIFT determines the size of the area a second-level page |
63 | * table can map | 49 | * table can map |
64 | */ | 50 | */ |
65 | #define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3)) | 51 | #define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-4)) |
66 | #define PMD_SIZE (_AC(1,UL) << PMD_SHIFT) | 52 | #define PMD_SIZE (_AC(1,UL) << PMD_SHIFT) |
67 | #define PMD_MASK (~(PMD_SIZE-1)) | 53 | #define PMD_MASK (~(PMD_SIZE-1)) |
68 | #define PMD_BITS (PAGE_SHIFT - 2) | 54 | #define PMD_BITS (PAGE_SHIFT - 2) |
69 | 55 | ||
70 | /* PGDIR_SHIFT determines what a third-level page table entry can map */ | 56 | /* PGDIR_SHIFT determines what a third-level page table entry can map */ |
71 | #define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3) + PMD_BITS) | 57 | #define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-4) + PMD_BITS) |
72 | #define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT) | 58 | #define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT) |
73 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) | 59 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) |
74 | #define PGDIR_BITS (PAGE_SHIFT - 2) | 60 | #define PGDIR_BITS (PAGE_SHIFT - 2) |
75 | 61 | ||
62 | #if (PGDIR_SHIFT + PGDIR_BITS) != 44 | ||
63 | #error Page table parameters do not cover virtual address space properly. | ||
64 | #endif | ||
65 | |||
66 | #if (PMD_SHIFT != HPAGE_SHIFT) | ||
67 | #error PMD_SHIFT must equal HPAGE_SHIFT for transparent huge pages. | ||
68 | #endif | ||
69 | |||
70 | /* PMDs point to PTE tables which are 4K aligned. */ | ||
71 | #define PMD_PADDR _AC(0xfffffffe,UL) | ||
72 | #define PMD_PADDR_SHIFT _AC(11,UL) | ||
73 | |||
74 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
75 | #define PMD_ISHUGE _AC(0x00000001,UL) | ||
76 | |||
77 | /* This is the PMD layout when PMD_ISHUGE is set. With 4MB huge | ||
78 | * pages, this frees up a bunch of bits in the layout that we can | ||
79 | * use for the protection settings and software metadata. | ||
80 | */ | ||
81 | #define PMD_HUGE_PADDR _AC(0xfffff800,UL) | ||
82 | #define PMD_HUGE_PROTBITS _AC(0x000007ff,UL) | ||
83 | #define PMD_HUGE_PRESENT _AC(0x00000400,UL) | ||
84 | #define PMD_HUGE_WRITE _AC(0x00000200,UL) | ||
85 | #define PMD_HUGE_DIRTY _AC(0x00000100,UL) | ||
86 | #define PMD_HUGE_ACCESSED _AC(0x00000080,UL) | ||
87 | #define PMD_HUGE_EXEC _AC(0x00000040,UL) | ||
88 | #define PMD_HUGE_SPLITTING _AC(0x00000020,UL) | ||
89 | #endif | ||
90 | |||
91 | /* PGDs point to PMD tables which are 8K aligned. */ | ||
92 | #define PGD_PADDR _AC(0xfffffffc,UL) | ||
93 | #define PGD_PADDR_SHIFT _AC(11,UL) | ||
94 | |||
76 | #ifndef __ASSEMBLY__ | 95 | #ifndef __ASSEMBLY__ |
77 | 96 | ||
78 | #include <linux/sched.h> | 97 | #include <linux/sched.h> |
79 | 98 | ||
80 | /* Entries per page directory level. */ | 99 | /* Entries per page directory level. */ |
81 | #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3)) | 100 | #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-4)) |
82 | #define PTRS_PER_PMD (1UL << PMD_BITS) | 101 | #define PTRS_PER_PMD (1UL << PMD_BITS) |
83 | #define PTRS_PER_PGD (1UL << PGDIR_BITS) | 102 | #define PTRS_PER_PGD (1UL << PGDIR_BITS) |
84 | 103 | ||
@@ -160,26 +179,11 @@ | |||
160 | #define _PAGE_SZ8K_4V _AC(0x0000000000000000,UL) /* 8K Page */ | 179 | #define _PAGE_SZ8K_4V _AC(0x0000000000000000,UL) /* 8K Page */ |
161 | #define _PAGE_SZALL_4V _AC(0x0000000000000007,UL) /* All pgsz bits */ | 180 | #define _PAGE_SZALL_4V _AC(0x0000000000000007,UL) /* All pgsz bits */ |
162 | 181 | ||
163 | #if PAGE_SHIFT == 13 | ||
164 | #define _PAGE_SZBITS_4U _PAGE_SZ8K_4U | 182 | #define _PAGE_SZBITS_4U _PAGE_SZ8K_4U |
165 | #define _PAGE_SZBITS_4V _PAGE_SZ8K_4V | 183 | #define _PAGE_SZBITS_4V _PAGE_SZ8K_4V |
166 | #elif PAGE_SHIFT == 16 | ||
167 | #define _PAGE_SZBITS_4U _PAGE_SZ64K_4U | ||
168 | #define _PAGE_SZBITS_4V _PAGE_SZ64K_4V | ||
169 | #else | ||
170 | #error Wrong PAGE_SHIFT specified | ||
171 | #endif | ||
172 | 184 | ||
173 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) | ||
174 | #define _PAGE_SZHUGE_4U _PAGE_SZ4MB_4U | 185 | #define _PAGE_SZHUGE_4U _PAGE_SZ4MB_4U |
175 | #define _PAGE_SZHUGE_4V _PAGE_SZ4MB_4V | 186 | #define _PAGE_SZHUGE_4V _PAGE_SZ4MB_4V |
176 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K) | ||
177 | #define _PAGE_SZHUGE_4U _PAGE_SZ512K_4U | ||
178 | #define _PAGE_SZHUGE_4V _PAGE_SZ512K_4V | ||
179 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K) | ||
180 | #define _PAGE_SZHUGE_4U _PAGE_SZ64K_4U | ||
181 | #define _PAGE_SZHUGE_4V _PAGE_SZ64K_4V | ||
182 | #endif | ||
183 | 187 | ||
184 | /* These are actually filled in at boot time by sun4{u,v}_pgprot_init() */ | 188 | /* These are actually filled in at boot time by sun4{u,v}_pgprot_init() */ |
185 | #define __P000 __pgprot(0) | 189 | #define __P000 __pgprot(0) |
@@ -218,7 +222,6 @@ extern unsigned long _PAGE_CACHE; | |||
218 | 222 | ||
219 | extern unsigned long pg_iobits; | 223 | extern unsigned long pg_iobits; |
220 | extern unsigned long _PAGE_ALL_SZ_BITS; | 224 | extern unsigned long _PAGE_ALL_SZ_BITS; |
221 | extern unsigned long _PAGE_SZBITS; | ||
222 | 225 | ||
223 | extern struct page *mem_map_zero; | 226 | extern struct page *mem_map_zero; |
224 | #define ZERO_PAGE(vaddr) (mem_map_zero) | 227 | #define ZERO_PAGE(vaddr) (mem_map_zero) |
@@ -231,25 +234,25 @@ extern struct page *mem_map_zero; | |||
231 | static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot) | 234 | static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot) |
232 | { | 235 | { |
233 | unsigned long paddr = pfn << PAGE_SHIFT; | 236 | unsigned long paddr = pfn << PAGE_SHIFT; |
234 | unsigned long sz_bits; | 237 | |
235 | 238 | BUILD_BUG_ON(_PAGE_SZBITS_4U != 0UL || _PAGE_SZBITS_4V != 0UL); | |
236 | sz_bits = 0UL; | 239 | return __pte(paddr | pgprot_val(prot)); |
237 | if (_PAGE_SZBITS_4U != 0UL || _PAGE_SZBITS_4V != 0UL) { | ||
238 | __asm__ __volatile__( | ||
239 | "\n661: sethi %%uhi(%1), %0\n" | ||
240 | " sllx %0, 32, %0\n" | ||
241 | " .section .sun4v_2insn_patch, \"ax\"\n" | ||
242 | " .word 661b\n" | ||
243 | " mov %2, %0\n" | ||
244 | " nop\n" | ||
245 | " .previous\n" | ||
246 | : "=r" (sz_bits) | ||
247 | : "i" (_PAGE_SZBITS_4U), "i" (_PAGE_SZBITS_4V)); | ||
248 | } | ||
249 | return __pte(paddr | sz_bits | pgprot_val(prot)); | ||
250 | } | 240 | } |
251 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) | 241 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) |
252 | 242 | ||
243 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
244 | extern pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot); | ||
245 | #define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot)) | ||
246 | |||
247 | extern pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot); | ||
248 | |||
249 | static inline pmd_t pmd_mkhuge(pmd_t pmd) | ||
250 | { | ||
251 | /* Do nothing, mk_pmd() does this part. */ | ||
252 | return pmd; | ||
253 | } | ||
254 | #endif | ||
255 | |||
253 | /* This one can be done with two shifts. */ | 256 | /* This one can be done with two shifts. */ |
254 | static inline unsigned long pte_pfn(pte_t pte) | 257 | static inline unsigned long pte_pfn(pte_t pte) |
255 | { | 258 | { |
@@ -286,6 +289,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t prot) | |||
286 | * Note: We encode this into 3 sun4v 2-insn patch sequences. | 289 | * Note: We encode this into 3 sun4v 2-insn patch sequences. |
287 | */ | 290 | */ |
288 | 291 | ||
292 | BUILD_BUG_ON(_PAGE_SZBITS_4U != 0UL || _PAGE_SZBITS_4V != 0UL); | ||
289 | __asm__ __volatile__( | 293 | __asm__ __volatile__( |
290 | "\n661: sethi %%uhi(%2), %1\n" | 294 | "\n661: sethi %%uhi(%2), %1\n" |
291 | " sethi %%hi(%2), %0\n" | 295 | " sethi %%hi(%2), %0\n" |
@@ -307,10 +311,10 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t prot) | |||
307 | : "=r" (mask), "=r" (tmp) | 311 | : "=r" (mask), "=r" (tmp) |
308 | : "i" (_PAGE_PADDR_4U | _PAGE_MODIFIED_4U | _PAGE_ACCESSED_4U | | 312 | : "i" (_PAGE_PADDR_4U | _PAGE_MODIFIED_4U | _PAGE_ACCESSED_4U | |
309 | _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U | _PAGE_PRESENT_4U | | 313 | _PAGE_CP_4U | _PAGE_CV_4U | _PAGE_E_4U | _PAGE_PRESENT_4U | |
310 | _PAGE_SZBITS_4U | _PAGE_SPECIAL), | 314 | _PAGE_SPECIAL), |
311 | "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V | | 315 | "i" (_PAGE_PADDR_4V | _PAGE_MODIFIED_4V | _PAGE_ACCESSED_4V | |
312 | _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V | _PAGE_PRESENT_4V | | 316 | _PAGE_CP_4V | _PAGE_CV_4V | _PAGE_E_4V | _PAGE_PRESENT_4V | |
313 | _PAGE_SZBITS_4V | _PAGE_SPECIAL)); | 317 | _PAGE_SPECIAL)); |
314 | 318 | ||
315 | return __pte((pte_val(pte) & mask) | (pgprot_val(prot) & ~mask)); | 319 | return __pte((pte_val(pte) & mask) | (pgprot_val(prot) & ~mask)); |
316 | } | 320 | } |
@@ -618,19 +622,130 @@ static inline unsigned long pte_special(pte_t pte) | |||
618 | return pte_val(pte) & _PAGE_SPECIAL; | 622 | return pte_val(pte) & _PAGE_SPECIAL; |
619 | } | 623 | } |
620 | 624 | ||
621 | #define pmd_set(pmdp, ptep) \ | 625 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
622 | (pmd_val(*(pmdp)) = (__pa((unsigned long) (ptep)) >> 11UL)) | 626 | static inline int pmd_young(pmd_t pmd) |
627 | { | ||
628 | return pmd_val(pmd) & PMD_HUGE_ACCESSED; | ||
629 | } | ||
630 | |||
631 | static inline int pmd_write(pmd_t pmd) | ||
632 | { | ||
633 | return pmd_val(pmd) & PMD_HUGE_WRITE; | ||
634 | } | ||
635 | |||
636 | static inline unsigned long pmd_pfn(pmd_t pmd) | ||
637 | { | ||
638 | unsigned long val = pmd_val(pmd) & PMD_HUGE_PADDR; | ||
639 | |||
640 | return val >> (PAGE_SHIFT - PMD_PADDR_SHIFT); | ||
641 | } | ||
642 | |||
643 | static inline int pmd_large(pmd_t pmd) | ||
644 | { | ||
645 | return (pmd_val(pmd) & (PMD_ISHUGE | PMD_HUGE_PRESENT)) == | ||
646 | (PMD_ISHUGE | PMD_HUGE_PRESENT); | ||
647 | } | ||
648 | |||
649 | static inline int pmd_trans_splitting(pmd_t pmd) | ||
650 | { | ||
651 | return (pmd_val(pmd) & (PMD_ISHUGE|PMD_HUGE_SPLITTING)) == | ||
652 | (PMD_ISHUGE|PMD_HUGE_SPLITTING); | ||
653 | } | ||
654 | |||
655 | static inline int pmd_trans_huge(pmd_t pmd) | ||
656 | { | ||
657 | return pmd_val(pmd) & PMD_ISHUGE; | ||
658 | } | ||
659 | |||
660 | #define has_transparent_hugepage() 1 | ||
661 | |||
662 | static inline pmd_t pmd_mkold(pmd_t pmd) | ||
663 | { | ||
664 | pmd_val(pmd) &= ~PMD_HUGE_ACCESSED; | ||
665 | return pmd; | ||
666 | } | ||
667 | |||
668 | static inline pmd_t pmd_wrprotect(pmd_t pmd) | ||
669 | { | ||
670 | pmd_val(pmd) &= ~PMD_HUGE_WRITE; | ||
671 | return pmd; | ||
672 | } | ||
673 | |||
674 | static inline pmd_t pmd_mkdirty(pmd_t pmd) | ||
675 | { | ||
676 | pmd_val(pmd) |= PMD_HUGE_DIRTY; | ||
677 | return pmd; | ||
678 | } | ||
679 | |||
680 | static inline pmd_t pmd_mkyoung(pmd_t pmd) | ||
681 | { | ||
682 | pmd_val(pmd) |= PMD_HUGE_ACCESSED; | ||
683 | return pmd; | ||
684 | } | ||
685 | |||
686 | static inline pmd_t pmd_mkwrite(pmd_t pmd) | ||
687 | { | ||
688 | pmd_val(pmd) |= PMD_HUGE_WRITE; | ||
689 | return pmd; | ||
690 | } | ||
691 | |||
692 | static inline pmd_t pmd_mknotpresent(pmd_t pmd) | ||
693 | { | ||
694 | pmd_val(pmd) &= ~PMD_HUGE_PRESENT; | ||
695 | return pmd; | ||
696 | } | ||
697 | |||
698 | static inline pmd_t pmd_mksplitting(pmd_t pmd) | ||
699 | { | ||
700 | pmd_val(pmd) |= PMD_HUGE_SPLITTING; | ||
701 | return pmd; | ||
702 | } | ||
703 | |||
704 | extern pgprot_t pmd_pgprot(pmd_t entry); | ||
705 | #endif | ||
706 | |||
707 | static inline int pmd_present(pmd_t pmd) | ||
708 | { | ||
709 | return pmd_val(pmd) != 0U; | ||
710 | } | ||
711 | |||
712 | #define pmd_none(pmd) (!pmd_val(pmd)) | ||
713 | |||
714 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
715 | extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, | ||
716 | pmd_t *pmdp, pmd_t pmd); | ||
717 | #else | ||
718 | static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, | ||
719 | pmd_t *pmdp, pmd_t pmd) | ||
720 | { | ||
721 | *pmdp = pmd; | ||
722 | } | ||
723 | #endif | ||
724 | |||
725 | static inline void pmd_set(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep) | ||
726 | { | ||
727 | unsigned long val = __pa((unsigned long) (ptep)) >> PMD_PADDR_SHIFT; | ||
728 | |||
729 | pmd_val(*pmdp) = val; | ||
730 | } | ||
731 | |||
623 | #define pud_set(pudp, pmdp) \ | 732 | #define pud_set(pudp, pmdp) \ |
624 | (pud_val(*(pudp)) = (__pa((unsigned long) (pmdp)) >> 11UL)) | 733 | (pud_val(*(pudp)) = (__pa((unsigned long) (pmdp)) >> PGD_PADDR_SHIFT)) |
625 | #define __pmd_page(pmd) \ | 734 | static inline unsigned long __pmd_page(pmd_t pmd) |
626 | ((unsigned long) __va((((unsigned long)pmd_val(pmd))<<11UL))) | 735 | { |
736 | unsigned long paddr = (unsigned long) pmd_val(pmd); | ||
737 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
738 | if (pmd_val(pmd) & PMD_ISHUGE) | ||
739 | paddr &= PMD_HUGE_PADDR; | ||
740 | #endif | ||
741 | paddr <<= PMD_PADDR_SHIFT; | ||
742 | return ((unsigned long) __va(paddr)); | ||
743 | } | ||
627 | #define pmd_page(pmd) virt_to_page((void *)__pmd_page(pmd)) | 744 | #define pmd_page(pmd) virt_to_page((void *)__pmd_page(pmd)) |
628 | #define pud_page_vaddr(pud) \ | 745 | #define pud_page_vaddr(pud) \ |
629 | ((unsigned long) __va((((unsigned long)pud_val(pud))<<11UL))) | 746 | ((unsigned long) __va((((unsigned long)pud_val(pud))<<PGD_PADDR_SHIFT))) |
630 | #define pud_page(pud) virt_to_page((void *)pud_page_vaddr(pud)) | 747 | #define pud_page(pud) virt_to_page((void *)pud_page_vaddr(pud)) |
631 | #define pmd_none(pmd) (!pmd_val(pmd)) | ||
632 | #define pmd_bad(pmd) (0) | 748 | #define pmd_bad(pmd) (0) |
633 | #define pmd_present(pmd) (pmd_val(pmd) != 0U) | ||
634 | #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0U) | 749 | #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0U) |
635 | #define pud_none(pud) (!pud_val(pud)) | 750 | #define pud_none(pud) (!pud_val(pud)) |
636 | #define pud_bad(pud) (0) | 751 | #define pud_bad(pud) (0) |
@@ -664,6 +779,16 @@ static inline unsigned long pte_special(pte_t pte) | |||
664 | extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, | 779 | extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, |
665 | pte_t *ptep, pte_t orig, int fullmm); | 780 | pte_t *ptep, pte_t orig, int fullmm); |
666 | 781 | ||
782 | #define __HAVE_ARCH_PMDP_GET_AND_CLEAR | ||
783 | static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, | ||
784 | unsigned long addr, | ||
785 | pmd_t *pmdp) | ||
786 | { | ||
787 | pmd_t pmd = *pmdp; | ||
788 | set_pmd_at(mm, addr, pmdp, __pmd(0U)); | ||
789 | return pmd; | ||
790 | } | ||
791 | |||
667 | static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, | 792 | static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, |
668 | pte_t *ptep, pte_t pte, int fullmm) | 793 | pte_t *ptep, pte_t pte, int fullmm) |
669 | { | 794 | { |
@@ -719,6 +844,16 @@ extern void mmu_info(struct seq_file *); | |||
719 | 844 | ||
720 | struct vm_area_struct; | 845 | struct vm_area_struct; |
721 | extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *); | 846 | extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *); |
847 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
848 | extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr, | ||
849 | pmd_t *pmd); | ||
850 | |||
851 | #define __HAVE_ARCH_PGTABLE_DEPOSIT | ||
852 | extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable); | ||
853 | |||
854 | #define __HAVE_ARCH_PGTABLE_WITHDRAW | ||
855 | extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm); | ||
856 | #endif | ||
722 | 857 | ||
723 | /* Encode and de-code a swap entry */ | 858 | /* Encode and de-code a swap entry */ |
724 | #define __swp_type(entry) (((entry).val >> PAGE_SHIFT) & 0xffUL) | 859 | #define __swp_type(entry) (((entry).val >> PAGE_SHIFT) & 0xffUL) |
diff --git a/arch/sparc/include/asm/tsb.h b/arch/sparc/include/asm/tsb.h index 1a8afd1ad04f..b4c258de4443 100644 --- a/arch/sparc/include/asm/tsb.h +++ b/arch/sparc/include/asm/tsb.h | |||
@@ -147,20 +147,96 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end; | |||
147 | brz,pn REG1, FAIL_LABEL; \ | 147 | brz,pn REG1, FAIL_LABEL; \ |
148 | sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \ | 148 | sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \ |
149 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ | 149 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ |
150 | sllx REG1, 11, REG1; \ | 150 | sllx REG1, PGD_PADDR_SHIFT, REG1; \ |
151 | andn REG2, 0x3, REG2; \ | 151 | andn REG2, 0x3, REG2; \ |
152 | lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \ | 152 | lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \ |
153 | brz,pn REG1, FAIL_LABEL; \ | 153 | brz,pn REG1, FAIL_LABEL; \ |
154 | sllx VADDR, 64 - PMD_SHIFT, REG2; \ | 154 | sllx VADDR, 64 - PMD_SHIFT, REG2; \ |
155 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ | 155 | srlx REG2, 64 - (PAGE_SHIFT - 1), REG2; \ |
156 | sllx REG1, 11, REG1; \ | 156 | sllx REG1, PMD_PADDR_SHIFT, REG1; \ |
157 | andn REG2, 0x7, REG2; \ | 157 | andn REG2, 0x7, REG2; \ |
158 | add REG1, REG2, REG1; | 158 | add REG1, REG2, REG1; |
159 | 159 | ||
160 | /* Do a user page table walk in MMU globals. Leaves physical PTE | 160 | /* This macro exists only to make the PMD translator below easier |
161 | * pointer in REG1. Jumps to FAIL_LABEL on early page table walk | 161 | * to read. It hides the ELF section switch for the sun4v code |
162 | * termination. Physical base of page tables is in PHYS_PGD which | 162 | * patching. |
163 | * will not be modified. | 163 | */ |
164 | #define OR_PTE_BIT(REG, NAME) \ | ||
165 | 661: or REG, _PAGE_##NAME##_4U, REG; \ | ||
166 | .section .sun4v_1insn_patch, "ax"; \ | ||
167 | .word 661b; \ | ||
168 | or REG, _PAGE_##NAME##_4V, REG; \ | ||
169 | .previous; | ||
170 | |||
171 | /* Load into REG the PTE value for VALID, CACHE, and SZHUGE. */ | ||
172 | #define BUILD_PTE_VALID_SZHUGE_CACHE(REG) \ | ||
173 | 661: sethi %uhi(_PAGE_VALID|_PAGE_SZHUGE_4U), REG; \ | ||
174 | .section .sun4v_1insn_patch, "ax"; \ | ||
175 | .word 661b; \ | ||
176 | sethi %uhi(_PAGE_VALID), REG; \ | ||
177 | .previous; \ | ||
178 | sllx REG, 32, REG; \ | ||
179 | 661: or REG, _PAGE_CP_4U|_PAGE_CV_4U, REG; \ | ||
180 | .section .sun4v_1insn_patch, "ax"; \ | ||
181 | .word 661b; \ | ||
182 | or REG, _PAGE_CP_4V|_PAGE_CV_4V|_PAGE_SZHUGE_4V, REG; \ | ||
183 | .previous; | ||
184 | |||
185 | /* PMD has been loaded into REG1, interpret the value, seeing | ||
186 | * if it is a HUGE PMD or a normal one. If it is not valid | ||
187 | * then jump to FAIL_LABEL. If it is a HUGE PMD, and it | ||
188 | * translates to a valid PTE, branch to PTE_LABEL. | ||
189 | * | ||
190 | * We translate the PMD by hand, one bit at a time, | ||
191 | * constructing the huge PTE. | ||
192 | * | ||
193 | * So we construct the PTE in REG2 as follows: | ||
194 | * | ||
195 | * 1) Extract the PMD PFN from REG1 and place it into REG2. | ||
196 | * | ||
197 | * 2) Translate PMD protection bits in REG1 into REG2, one bit | ||
198 | * at a time using andcc tests on REG1 and OR's into REG2. | ||
199 | * | ||
200 | * Only two bits to be concerned with here, EXEC and WRITE. | ||
201 | * Now REG1 is freed up and we can use it as a temporary. | ||
202 | * | ||
203 | * 3) Construct the VALID, CACHE, and page size PTE bits in | ||
204 | * REG1, OR with REG2 to form final PTE. | ||
205 | */ | ||
206 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
207 | #define USER_PGTABLE_CHECK_PMD_HUGE(VADDR, REG1, REG2, FAIL_LABEL, PTE_LABEL) \ | ||
208 | brz,pn REG1, FAIL_LABEL; \ | ||
209 | andcc REG1, PMD_ISHUGE, %g0; \ | ||
210 | be,pt %xcc, 700f; \ | ||
211 | and REG1, PMD_HUGE_PRESENT|PMD_HUGE_ACCESSED, REG2; \ | ||
212 | cmp REG2, PMD_HUGE_PRESENT|PMD_HUGE_ACCESSED; \ | ||
213 | bne,pn %xcc, FAIL_LABEL; \ | ||
214 | andn REG1, PMD_HUGE_PROTBITS, REG2; \ | ||
215 | sllx REG2, PMD_PADDR_SHIFT, REG2; \ | ||
216 | /* REG2 now holds PFN << PAGE_SHIFT */ \ | ||
217 | andcc REG1, PMD_HUGE_EXEC, %g0; \ | ||
218 | bne,a,pt %xcc, 1f; \ | ||
219 | OR_PTE_BIT(REG2, EXEC); \ | ||
220 | 1: andcc REG1, PMD_HUGE_WRITE, %g0; \ | ||
221 | bne,a,pt %xcc, 1f; \ | ||
222 | OR_PTE_BIT(REG2, W); \ | ||
223 | /* REG1 can now be clobbered, build final PTE */ \ | ||
224 | 1: BUILD_PTE_VALID_SZHUGE_CACHE(REG1); \ | ||
225 | ba,pt %xcc, PTE_LABEL; \ | ||
226 | or REG1, REG2, REG1; \ | ||
227 | 700: | ||
228 | #else | ||
229 | #define USER_PGTABLE_CHECK_PMD_HUGE(VADDR, REG1, REG2, FAIL_LABEL, PTE_LABEL) \ | ||
230 | brz,pn REG1, FAIL_LABEL; \ | ||
231 | nop; | ||
232 | #endif | ||
233 | |||
234 | /* Do a user page table walk in MMU globals. Leaves final, | ||
235 | * valid, PTE value in REG1. Jumps to FAIL_LABEL on early | ||
236 | * page table walk termination or if the PTE is not valid. | ||
237 | * | ||
238 | * Physical base of page tables is in PHYS_PGD which will not | ||
239 | * be modified. | ||
164 | * | 240 | * |
165 | * VADDR will not be clobbered, but REG1 and REG2 will. | 241 | * VADDR will not be clobbered, but REG1 and REG2 will. |
166 | */ | 242 | */ |
@@ -172,15 +248,19 @@ extern struct tsb_phys_patch_entry __tsb_phys_patch, __tsb_phys_patch_end; | |||
172 | brz,pn REG1, FAIL_LABEL; \ | 248 | brz,pn REG1, FAIL_LABEL; \ |
173 | sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \ | 249 | sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \ |
174 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ | 250 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ |
175 | sllx REG1, 11, REG1; \ | 251 | sllx REG1, PGD_PADDR_SHIFT, REG1; \ |
176 | andn REG2, 0x3, REG2; \ | 252 | andn REG2, 0x3, REG2; \ |
177 | lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \ | 253 | lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \ |
178 | brz,pn REG1, FAIL_LABEL; \ | 254 | USER_PGTABLE_CHECK_PMD_HUGE(VADDR, REG1, REG2, FAIL_LABEL, 800f) \ |
179 | sllx VADDR, 64 - PMD_SHIFT, REG2; \ | 255 | sllx VADDR, 64 - PMD_SHIFT, REG2; \ |
180 | srlx REG2, 64 - PAGE_SHIFT, REG2; \ | 256 | srlx REG2, 64 - (PAGE_SHIFT - 1), REG2; \ |
181 | sllx REG1, 11, REG1; \ | 257 | sllx REG1, PMD_PADDR_SHIFT, REG1; \ |
182 | andn REG2, 0x7, REG2; \ | 258 | andn REG2, 0x7, REG2; \ |
183 | add REG1, REG2, REG1; | 259 | add REG1, REG2, REG1; \ |
260 | ldxa [REG1] ASI_PHYS_USE_EC, REG1; \ | ||
261 | brgez,pn REG1, FAIL_LABEL; \ | ||
262 | nop; \ | ||
263 | 800: | ||
184 | 264 | ||
185 | /* Lookup a OBP mapping on VADDR in the prom_trans[] table at TL>0. | 265 | /* Lookup a OBP mapping on VADDR in the prom_trans[] table at TL>0. |
186 | * If no entry is found, FAIL_LABEL will be branched to. On success | 266 | * If no entry is found, FAIL_LABEL will be branched to. On success |