7 .macro clean_tlb_way way, page_size, n_entries
19 clean_tlb_way 0, 0x00001000, 4
20 clean_tlb_way 1, 0x00001000, 4
21 clean_tlb_way 2, 0x00001000, 4
22 clean_tlb_way 3, 0x00001000, 4
23 clean_tlb_way 4, 0x00100000, 4
33 movi a2, 0x04000002 /* PPN */
34 movi a3, 0x01200004 /* VPN */
101 movi a2, 0x04000002 /* PPN */
102 movi a3, 0xf0000004 /* VPN */
114 set_vector kernel, 1f
116 movi a2, 0x04000002 /* PPN */
117 movi a3, 0x01200004 /* VPN */
119 movi a3, 0x01200007 /* VPN */
130 test inst_fetch_privilege
131 set_vector kernel, 3f
157 test load_store_privilege
158 set_vector kernel, 2f
174 movi a2, 0x04000003 /* PPN */
175 movi a3, 0x01200004 /* VPN */
202 test cring_load_store_privilege
204 set_vector double, 2f
206 movi a2, 0x04000003 /* PPN */
207 movi a3, 0x01200004 /* VPN */
210 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
213 l8ui a2, a3, 0 /* cring used */
215 l32e a2, a3, -4 /* ring used */
232 test inst_fetch_prohibited
233 set_vector kernel, 2f
266 set_vector kernel, 2f
268 movi a2, 0x0400000c /* PPN */
269 movi a3, 0x01200004 /* VPN */
286 test store_prohibited
287 set_vector kernel, 2f
289 movi a2, 0x04000001 /* PPN */
290 movi a3, 0x01200004 /* VPN */
308 /* Set up page table entry vaddr->paddr, ring=pte_ring, attr=pte_attr
309 * and DTLB way 7 to cover this PTE, ring=pt_ring, attr=pt_attr
311 .macro pt_setup pt_ring, pt_attr, pte_ring, vaddr, paddr, pte_attr
315 movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
316 movi a4, 0x04000003 | ((\pt_ring) << 4) /* PADDR 64M */
320 movi a3, ((\paddr) & 0xfffff000) | ((\pte_ring) << 4) | (\pte_attr)
321 movi a1, ((\vaddr) >> 12) << 2
325 movi a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
326 movi a4, 0x04000000 | ((\pt_ring) << 4) | (\pt_attr) /* PADDR 64M */
333 /* out: PS.RING=ring, PS.EXCM=excm, a3=vaddr */
334 .macro go_ring ring, excm, vaddr
353 movi a2, 0x4000f | ((\ring) << 6) | ((\excm) << 4)
360 /* in: a3 -- virtual address to test */
361 .macro assert_auto_tlb
376 /* in: a3 -- virtual address to test */
377 .macro assert_no_auto_tlb
387 .macro assert_sr sr, v
393 .macro assert_epc1_1m vaddr
404 pt_setup 0, 3, 1, 0x1000, 0x1000, 3
415 test autoload_load_store_privilege
417 set_vector double, 2f
419 pt_setup 0, 3, 0, 0x2000, 0x2000, 3
423 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
427 l32e a2, a3, -4 /* ring used */
436 assert_sr exccause, 26
439 test autoload_pte_load_prohibited
440 set_vector kernel, 2f
442 pt_setup 0, 3, 0, 0x3000, 0, 0xc
453 assert_sr exccause, 28
456 test autoload_pt_load_prohibited
457 set_vector kernel, 2f
459 pt_setup 0, 0xc, 0, 0x4000, 0x4000, 3
470 assert_sr exccause, 24
473 test autoload_pt_privilege
474 set_vector kernel, 2f
475 pt_setup 0, 3, 1, 0x5000, 0, 3
487 assert_sr exccause, 1
490 test autoload_pte_privilege
491 set_vector kernel, 2f
492 pt_setup 0, 3, 0, 0x6000, 0, 3
503 assert_sr exccause, 26
506 test autoload_3_level_pt
507 set_vector kernel, 2f
508 pt_setup 1, 3, 1, 0x00400000, 0, 3
509 pt_setup 1, 3, 1, 0x80001000, 0x2000000, 3
510 go_ring 1, 0, 0x00400001
520 assert_sr exccause, 24
524 set_vector kernel, 2f
526 movi a2, 0x04000003 /* PPN */
527 movi a3, 0x00007000 /* VPN */
530 movi a3, 0x00008000 /* VPN */
546 /* DTLB: OK, ITLB: OK */
568 set_vector kernel, 3f
570 movi a2, 0x0400000c /* PPN */
571 movi a3, 0x00008000 /* VPN */
575 /* DTLB: FAIL, ITLB: OK */
589 set_vector kernel, 4f
591 movi a2, 0x0400000c /* PPN */
592 movi a3, 0x00008000 /* VPN */
594 movi a2, 0x04000003 /* PPN */
598 /* DTLB: OK, ITLB: FAIL */
612 set_vector kernel, 5f
614 movi a2, 0x0400000c /* PPN */
615 movi a3, 0x00008000 /* VPN */
619 /* DTLB: FAIL, ITLB: FAIL */
634 set_vector kernel, 2f
636 movi a2, 0x04000003 /* PPN */
637 movi a3, 0x00007000 /* VPN */
640 movi a3, 0x00008000 /* VPN */
656 /* DTLB: OK, ITLB: OK */
678 set_vector kernel, 3f
680 movi a2, 0x0400000c /* PPN */
681 movi a3, 0x00008000 /* VPN */
685 /* DTLB: FAIL, ITLB: OK */
699 set_vector kernel, 4f
701 movi a2, 0x0400000c /* PPN */
702 movi a3, 0x00008000 /* VPN */
704 movi a2, 0x04000003 /* PPN */
708 /* DTLB: OK, ITLB: FAIL */
722 set_vector kernel, 5f
724 movi a2, 0x0400000c /* PPN */
725 movi a3, 0x00008000 /* VPN */
729 /* DTLB: FAIL, ITLB: FAIL */