5 #if XCHAL_HAVE_PTP_MMU && !XCHAL_HAVE_SPANNING_WAY
9 .macro clean_tlb_way way, page_size, n_entries
21 clean_tlb_way 0, 0x00001000, 4
22 clean_tlb_way 1, 0x00001000, 4
23 clean_tlb_way 2, 0x00001000, 4
24 clean_tlb_way 3, 0x00001000, 4
25 clean_tlb_way 4, 0x00100000, 4
35 movi a2, 0x04000002 /* PPN */
36 movi a3, 0x01200004 /* VPN */
101 set_vector kernel, 1f
103 movi a2, 0x04000002 /* PPN */
104 movi a3, 0xf0000004 /* VPN */
116 set_vector kernel, 1f
118 movi a2, 0x04000002 /* PPN */
119 movi a3, 0x01200004 /* VPN */
121 movi a3, 0x01200007 /* VPN */
132 test inst_fetch_privilege
133 set_vector kernel, 3f
159 test load_store_privilege
160 set_vector kernel, 2f
176 movi a2, 0x04000003 /* PPN */
177 movi a3, 0x01200004 /* VPN */
204 test cring_load_store_privilege
206 set_vector double, 2f
208 movi a2, 0x04000003 /* PPN */
209 movi a3, 0x01200004 /* VPN */
212 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
215 l8ui a2, a3, 0 /* cring used */
217 l32e a2, a3, -4 /* ring used */
234 test inst_fetch_prohibited
235 set_vector kernel, 2f
268 set_vector kernel, 2f
270 movi a2, 0x0400000c /* PPN */
271 movi a3, 0x01200004 /* VPN */
288 test store_prohibited
289 set_vector kernel, 2f
291 movi a2, 0x04000001 /* PPN */
292 movi a3, 0x01200004 /* VPN */
310 /* Set up page table entry vaddr->paddr, ring=pte_ring, attr=pte_attr
311 * and DTLB way 7 to cover this PTE, ring=pt_ring, attr=pt_attr
313 .macro pt_setup pt_ring, pt_attr, pte_ring, vaddr, paddr, pte_attr
317 movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
318 movi a4, 0x04000003 | ((\pt_ring) << 4) /* PADDR 64M */
322 movi a3, ((\paddr) & 0xfffff000) | ((\pte_ring) << 4) | (\pte_attr)
323 movi a1, ((\vaddr) >> 12) << 2
327 movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
328 movi a4, 0x04000000 | ((\pt_ring) << 4) | (\pt_attr) /* PADDR 64M */
335 /* out: PS.RING=ring, PS.EXCM=excm, a3=vaddr */
336 .macro go_ring ring, excm, vaddr
355 movi a2, 0x4000f | ((\ring) << 6) | ((\excm) << 4)
362 /* in: a3 -- virtual address to test */
363 .macro assert_auto_tlb
378 /* in: a3 -- virtual address to test */
379 .macro assert_no_auto_tlb
389 .macro assert_sr sr, v
395 .macro assert_epc1_1m vaddr
406 pt_setup 0, 3, 1, 0x1000, 0x1000, 3
417 test autoload_load_store_privilege
419 set_vector double, 2f
421 pt_setup 0, 3, 0, 0x2000, 0x2000, 3
425 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
429 l32e a2, a3, -4 /* ring used */
438 assert_sr exccause, 26
441 test autoload_pte_load_prohibited
442 set_vector kernel, 2f
444 pt_setup 0, 3, 0, 0x3000, 0, 0xc
455 assert_sr exccause, 28
458 test autoload_pt_load_prohibited
459 set_vector kernel, 2f
461 pt_setup 0, 0xc, 0, 0x4000, 0x4000, 3
472 assert_sr exccause, 24
475 test autoload_pt_privilege
476 set_vector kernel, 2f
477 pt_setup 0, 3, 1, 0x5000, 0, 3
489 assert_sr exccause, 1
492 test autoload_pte_privilege
493 set_vector kernel, 2f
494 pt_setup 0, 3, 0, 0x6000, 0, 3
505 assert_sr exccause, 26
508 test autoload_3_level_pt
509 set_vector kernel, 2f
510 pt_setup 1, 3, 1, 0x00400000, 0, 3
511 pt_setup 1, 3, 1, 0x80001000, 0x2000000, 3
512 go_ring 1, 0, 0x00400001
522 assert_sr exccause, 24
526 set_vector kernel, 2f
528 movi a2, 0x04000003 /* PPN */
529 movi a3, 0x00007000 /* VPN */
532 movi a3, 0x00008000 /* VPN */
548 /* DTLB: OK, ITLB: OK */
570 set_vector kernel, 3f
572 movi a2, 0x0400000c /* PPN */
573 movi a3, 0x00008000 /* VPN */
577 /* DTLB: FAIL, ITLB: OK */
591 set_vector kernel, 4f
593 movi a2, 0x0400000c /* PPN */
594 movi a3, 0x00008000 /* VPN */
596 movi a2, 0x04000003 /* PPN */
600 /* DTLB: OK, ITLB: FAIL */
614 set_vector kernel, 5f
616 movi a2, 0x0400000c /* PPN */
617 movi a3, 0x00008000 /* VPN */
621 /* DTLB: FAIL, ITLB: FAIL */
636 set_vector kernel, 2f
638 movi a2, 0x04000003 /* PPN */
639 movi a3, 0x00007000 /* VPN */
642 movi a3, 0x00008000 /* VPN */
658 /* DTLB: OK, ITLB: OK */
680 set_vector kernel, 3f
682 movi a2, 0x0400000c /* PPN */
683 movi a3, 0x00008000 /* VPN */
687 /* DTLB: FAIL, ITLB: OK */
701 set_vector kernel, 4f
703 movi a2, 0x0400000c /* PPN */
704 movi a3, 0x00008000 /* VPN */
706 movi a2, 0x04000003 /* PPN */
710 /* DTLB: OK, ITLB: FAIL */
724 set_vector kernel, 5f
726 movi a2, 0x0400000c /* PPN */
727 movi a3, 0x00008000 /* VPN */
731 /* DTLB: FAIL, ITLB: FAIL */