Go to the documentation of this file.
47 #define TSB_TAG_LOCK_BIT 47
48 #define TSB_TAG_LOCK_HIGH (1 << (TSB_TAG_LOCK_BIT - 32))
50 #define TSB_TAG_INVALID_BIT 46
51 #define TSB_TAG_INVALID_HIGH (1 << (TSB_TAG_INVALID_BIT - 32))
76 #define TSB_LOAD_QUAD(TSB, REG) \
77 661: ldda [TSB] ASI_NUCLEUS_QUAD_LDD, REG; \
78 .section .tsb_ldquad_phys_patch, "ax"; \
80 ldda [TSB] ASI_QUAD_LDD_PHYS, REG; \
81 ldda [TSB] ASI_QUAD_LDD_PHYS_4V, REG; \
84 #define TSB_LOAD_TAG_HIGH(TSB, REG) \
85 661: lduwa [TSB] ASI_N, REG; \
86 .section .tsb_phys_patch, "ax"; \
88 lduwa [TSB] ASI_PHYS_USE_EC, REG; \
91 #define TSB_LOAD_TAG(TSB, REG) \
92 661: ldxa [TSB] ASI_N, REG; \
93 .section .tsb_phys_patch, "ax"; \
95 ldxa [TSB] ASI_PHYS_USE_EC, REG; \
98 #define TSB_CAS_TAG_HIGH(TSB, REG1, REG2) \
99 661: casa [TSB] ASI_N, REG1, REG2; \
100 .section .tsb_phys_patch, "ax"; \
102 casa [TSB] ASI_PHYS_USE_EC, REG1, REG2; \
105 #define TSB_CAS_TAG(TSB, REG1, REG2) \
106 661: casxa [TSB] ASI_N, REG1, REG2; \
107 .section .tsb_phys_patch, "ax"; \
109 casxa [TSB] ASI_PHYS_USE_EC, REG1, REG2; \
112 #define TSB_STORE(ADDR, VAL) \
113 661: stxa VAL, [ADDR] ASI_N; \
114 .section .tsb_phys_patch, "ax"; \
116 stxa VAL, [ADDR] ASI_PHYS_USE_EC; \
119 #define TSB_LOCK_TAG(TSB, REG1, REG2) \
120 99: TSB_LOAD_TAG_HIGH(TSB, REG1); \
121 sethi %hi(TSB_TAG_LOCK_HIGH), REG2;\
122 andcc REG1, REG2, %g0; \
125 TSB_CAS_TAG_HIGH(TSB, REG1, REG2); \
130 #define TSB_WRITE(TSB, TTE, TAG) \
132 TSB_STORE(TSB, TTE); \
140 #define KERN_PGTABLE_WALK(VADDR, REG1, REG2, FAIL_LABEL) \
141 sethi %hi(swapper_pg_dir), REG1; \
142 or REG1, %lo(swapper_pg_dir), REG1; \
143 sllx VADDR, 64 - (PGDIR_SHIFT + PGDIR_BITS), REG2; \
144 srlx REG2, 64 - PAGE_SHIFT, REG2; \
145 andn REG2, 0x3, REG2; \
146 lduw [REG1 + REG2], REG1; \
147 brz,pn REG1, FAIL_LABEL; \
148 sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \
149 srlx REG2, 64 - PAGE_SHIFT, REG2; \
150 sllx REG1, PGD_PADDR_SHIFT, REG1; \
151 andn REG2, 0x3, REG2; \
152 lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
153 brz,pn REG1, FAIL_LABEL; \
154 sllx VADDR, 64 - PMD_SHIFT, REG2; \
155 srlx REG2, 64 - (PAGE_SHIFT - 1), REG2; \
156 sllx REG1, PMD_PADDR_SHIFT, REG1; \
157 andn REG2, 0x7, REG2; \
158 add REG1, REG2, REG1;
164 #define OR_PTE_BIT(REG, NAME) \
165 661: or REG, _PAGE_##NAME##_4U, REG; \
166 .section .sun4v_1insn_patch, "ax"; \
168 or REG, _PAGE_##NAME##_4V, REG; \
172 #define BUILD_PTE_VALID_SZHUGE_CACHE(REG) \
173 661: sethi %uhi(_PAGE_VALID|_PAGE_SZHUGE_4U), REG; \
174 .section .sun4v_1insn_patch, "ax"; \
176 sethi %uhi(_PAGE_VALID), REG; \
179 661: or REG, _PAGE_CP_4U|_PAGE_CV_4U, REG; \
180 .section .sun4v_1insn_patch, "ax"; \
182 or REG, _PAGE_CP_4V|_PAGE_CV_4V|_PAGE_SZHUGE_4V, REG; \
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; \
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; \
217 andcc REG1, PMD_HUGE_EXEC, %g0; \
219 OR_PTE_BIT(REG2, EXEC); \
220 1: andcc REG1, PMD_HUGE_WRITE, %g0; \
222 OR_PTE_BIT(REG2, W); \
224 1: BUILD_PTE_VALID_SZHUGE_CACHE(REG1); \
225 ba,pt %xcc, PTE_LABEL; \
226 or REG1, REG2, REG1; \
229 #define USER_PGTABLE_CHECK_PMD_HUGE(VADDR, REG1, REG2, FAIL_LABEL, PTE_LABEL) \
230 brz,pn REG1, FAIL_LABEL; \
243 #define USER_PGTABLE_WALK_TL1(VADDR, PHYS_PGD, REG1, REG2, FAIL_LABEL) \
244 sllx VADDR, 64 - (PGDIR_SHIFT + PGDIR_BITS), REG2; \
245 srlx REG2, 64 - PAGE_SHIFT, REG2; \
246 andn REG2, 0x3, REG2; \
247 lduwa [PHYS_PGD + REG2] ASI_PHYS_USE_EC, REG1; \
248 brz,pn REG1, FAIL_LABEL; \
249 sllx VADDR, 64 - (PMD_SHIFT + PMD_BITS), REG2; \
250 srlx REG2, 64 - PAGE_SHIFT, REG2; \
251 sllx REG1, PGD_PADDR_SHIFT, REG1; \
252 andn REG2, 0x3, REG2; \
253 lduwa [REG1 + REG2] ASI_PHYS_USE_EC, REG1; \
254 USER_PGTABLE_CHECK_PMD_HUGE(VADDR, REG1, REG2, FAIL_LABEL, 800f) \
255 sllx VADDR, 64 - PMD_SHIFT, REG2; \
256 srlx REG2, 64 - (PAGE_SHIFT - 1), REG2; \
257 sllx REG1, PMD_PADDR_SHIFT, REG1; \
258 andn REG2, 0x7, REG2; \
259 add REG1, REG2, REG1; \
260 ldxa [REG1] ASI_PHYS_USE_EC, REG1; \
261 brgez,pn REG1, FAIL_LABEL; \
270 #define OBP_TRANS_LOOKUP(VADDR, REG1, REG2, REG3, FAIL_LABEL) \
271 sethi %hi(prom_trans), REG1; \
272 or REG1, %lo(prom_trans), REG1; \
273 97: ldx [REG1 + 0x00], REG2; \
274 brz,pn REG2, FAIL_LABEL; \
276 ldx [REG1 + 0x08], REG3; \
277 add REG2, REG3, REG3; \
282 ldx [REG1 + 0x10], REG3; \
283 sub VADDR, REG2, REG2; \
285 add REG3, REG2, REG1; \
286 98: ba,pt %xcc, 97b; \
287 add REG1, (3 * 8), REG1; \
294 #define KERNEL_TSB_SIZE_BYTES (32 * 1024)
295 #define KERNEL_TSB_NENTRIES \
296 (KERNEL_TSB_SIZE_BYTES / 16)
297 #define KERNEL_TSB4M_NENTRIES 4096
299 #define KTSB_PHYS_SHIFT 15
308 #define KERN_TSB_LOOKUP_TL1(VADDR, TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
309 661: sethi %hi(swapper_tsb), REG1; \
310 or REG1, %lo(swapper_tsb), REG1; \
311 .section .swapper_tsb_phys_patch, "ax"; \
315 .section .tsb_ldquad_phys_patch, "ax"; \
317 sllx REG1, KTSB_PHYS_SHIFT, REG1; \
318 sllx REG1, KTSB_PHYS_SHIFT, REG1; \
320 srlx VADDR, PAGE_SHIFT, REG2; \
321 and REG2, (KERNEL_TSB_NENTRIES - 1), REG2; \
322 sllx REG2, 4, REG2; \
323 add REG1, REG2, REG2; \
324 TSB_LOAD_QUAD(REG2, REG3); \
326 be,a,pt %xcc, OK_LABEL; \
329 #ifndef CONFIG_DEBUG_PAGEALLOC
333 #define KERN_TSB4M_LOOKUP_TL1(TAG, REG1, REG2, REG3, REG4, OK_LABEL) \
334 661: sethi %hi(swapper_4m_tsb), REG1; \
335 or REG1, %lo(swapper_4m_tsb), REG1; \
336 .section .swapper_4m_tsb_phys_patch, "ax"; \
340 .section .tsb_ldquad_phys_patch, "ax"; \
342 sllx REG1, KTSB_PHYS_SHIFT, REG1; \
343 sllx REG1, KTSB_PHYS_SHIFT, REG1; \
345 and TAG, (KERNEL_TSB4M_NENTRIES - 1), REG2; \
346 sllx REG2, 4, REG2; \
347 add REG1, REG2, REG2; \
348 TSB_LOAD_QUAD(REG2, REG3); \
350 be,a,pt %xcc, OK_LABEL; \