6 #define BASE 0x20000000
7 #define TLB_BASE 0x80000000
11 .macro clean_tlb_way way, page_size, n_entries
23 clean_tlb_way 0, 0x00001000, 4
24 clean_tlb_way 1, 0x00001000, 4
25 clean_tlb_way 2, 0x00001000, 4
26 clean_tlb_way 3, 0x00001000, 4
27 clean_tlb_way 4, 0x00100000, 4
34 #if XCHAL_HAVE_SPANNING_WAY
35 movi a2, BASE | XCHAL_SPANNING_WAY
38 movi a2, TLB_BASE | XCHAL_SPANNING_WAY
47 movi a2, 0x04000002 /* PPN */
48 movi a3, BASE + 0x01200004 /* VPN */
54 movi a3, BASE + 0x01000001
63 movi a3, BASE + 0x01234567
66 movi a3, BASE + 0x01234014
68 movi a3, BASE + 0x0123400c
73 movi a3, BASE + 0x01234567
87 movi a3, BASE + 0x00100000
101 movi a3, BASE + 0x00100000
113 set_vector kernel, 1f
115 movi a2, 0x04000002 /* PPN */
116 movi a3, 0xf0000004 /* VPN */
128 set_vector kernel, 1f
130 movi a2, 0x04000002 /* PPN */
131 movi a3, BASE + 0x01200004 /* VPN */
133 movi a3, BASE + 0x01200007 /* VPN */
135 movi a3, BASE + 0x01200000
144 test inst_fetch_privilege
145 set_vector kernel, 3f
171 test load_store_privilege
172 set_vector kernel, 2f
191 movi a2, 0x04000003 /* PPN */
192 movi a3, BASE + 0x01200004 /* VPN */
194 movi a3, BASE + 0x01200001
220 test cring_load_store_privilege
222 set_vector double, 2f
224 movi a2, 0x04000003 /* PPN */
225 movi a3, BASE + 0x01200004 /* VPN */
227 movi a3, BASE + 0x01200004
228 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
231 l8ui a2, a3, 0 /* cring used */
233 l32e a2, a3, -4 /* ring used */
250 test inst_fetch_prohibited
251 set_vector kernel, 2f
287 set_vector kernel, 2f
289 movi a2, 0x0400000c /* PPN */
290 movi a3, BASE + 0x01200004 /* VPN */
292 movi a3, BASE + 0x01200002
307 test store_prohibited
308 set_vector kernel, 2f
310 movi a2, 0x04000001 /* PPN */
311 movi a3, BASE + 0x01200004 /* VPN */
313 movi a3, BASE + 0x01200003
329 /* Set up page table entry vaddr->paddr, ring=pte_ring, attr=pte_attr
330 * and DTLB way 7 to cover this PTE, ring=pt_ring, attr=pt_attr
332 .macro pt_setup pt_ring, pt_attr, pte_ring, vaddr, paddr, pte_attr
336 movi a3, TLB_BASE | 7 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
337 movi a4, 0x04000003 | ((\pt_ring) << 4) /* PADDR 64M */
341 movi a3, ((\paddr) & 0xfffff000) | ((\pte_ring) << 4) | (\pte_attr)
342 movi a1, ((\vaddr) >> 12) << 2
346 movi a3, TLB_BASE | 7 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
347 movi a4, 0x04000000 | ((\pt_ring) << 4) | (\pt_attr) /* PADDR 64M */
354 /* out: PS.RING=ring, PS.EXCM=excm, a3=vaddr */
355 .macro go_ring ring, excm, vaddr
377 movi a2, 0x4000f | ((\ring) << 6) | ((\excm) << 4)
384 /* in: a3 -- virtual address to test */
385 .macro assert_auto_tlb
400 /* in: a3 -- virtual address to test */
401 .macro assert_no_auto_tlb
411 .macro assert_sr sr, v
417 .macro assert_epc1_1m vaddr
430 pt_setup 0, 3, 1, BASE + 0x1000, 0x1000, 3
441 test autoload_load_store_privilege
443 set_vector double, 2f
445 pt_setup 0, 3, 0, BASE + 0x2000, 0x2000, 3
446 movi a3, BASE + 0x2004
449 movi a2, 0x4005f /* ring 1 + excm => cring == 0 */
453 l32e a2, a3, -4 /* ring used */
462 assert_sr exccause, 26
465 test autoload_pte_load_prohibited
466 set_vector kernel, 2f
468 pt_setup 0, 3, 0, BASE + 0x3000, 0, 0xc
479 assert_sr exccause, 28
482 test autoload_pt_load_prohibited
483 set_vector kernel, 2f
485 pt_setup 0, 0xc, 0, BASE + 0x4000, 0x4000, 3
496 assert_sr exccause, 24
499 test autoload_pt_privilege
500 set_vector kernel, 2f
501 pt_setup 0, 3, 1, BASE + 0x5000, 0, 3
502 go_ring 1, 0, BASE + 0x5001
513 assert_sr exccause, 1
516 test autoload_pte_privilege
517 set_vector kernel, 2f
518 pt_setup 0, 3, 0, BASE + 0x6000, 0, 3
519 go_ring 1, 0, BASE + 0x6001
529 assert_sr exccause, 26
532 test autoload_3_level_pt
533 set_vector kernel, 2f
534 pt_setup 1, 3, 1, BASE + 0x00400000, 0, 3
535 pt_setup 1, 3, 1, TLB_BASE + ((BASE + 0x00400000) >> 10), 0x2000000, 3
536 go_ring 1, 0, BASE + 0x00400001
546 assert_sr exccause, 24
550 set_vector kernel, 2f
552 movi a2, 0x04000003 /* PPN */
553 movi a3, BASE + 0x00007000 /* VPN */
556 movi a3, BASE + 0x00008000 /* VPN */
560 movi a2, BASE + 0x00007fff
570 movi a2, BASE + 0x00007fff
571 movi a3, BASE + 0x00008000
572 /* DTLB: OK, ITLB: OK */
587 movi a3, BASE + 0x8002
590 movi a3, BASE + 0x00007fff
594 set_vector kernel, 3f
596 movi a2, 0x0400000c /* PPN */
597 movi a3, BASE + 0x00008000 /* VPN */
599 movi a2, BASE + 0x00007fff
600 movi a3, BASE + 0x00008000
601 /* DTLB: FAIL, ITLB: OK */
608 movi a3, BASE + 0x7fff
611 movi a3, BASE + 0x00007fff
615 set_vector kernel, 4f
617 movi a2, 0x0400000c /* PPN */
618 movi a3, BASE + 0x00008000 /* VPN */
620 movi a2, 0x04000003 /* PPN */
622 movi a2, BASE + 0x00007fff
623 movi a3, BASE + 0x00008000
624 /* DTLB: OK, ITLB: FAIL */
631 movi a3, BASE + 0x7fff
634 movi a3, BASE + 0x00007fff
638 set_vector kernel, 5f
640 movi a2, 0x0400000c /* PPN */
641 movi a3, BASE + 0x00008000 /* VPN */
643 movi a2, BASE + 0x00007fff
644 movi a3, BASE + 0x00008000
645 /* DTLB: FAIL, ITLB: FAIL */
652 movi a3, BASE + 0x7fff
655 movi a3, BASE + 0x00007fff
660 set_vector kernel, 2f
662 movi a2, 0x04000003 /* PPN */
663 movi a3, BASE + 0x00007000 /* VPN */
666 movi a3, BASE + 0x00008000 /* VPN */
670 movi a2, BASE + 0x00007ffc
680 movi a2, BASE + 0x00007ffc
681 movi a3, BASE + 0x00008000
682 /* DTLB: OK, ITLB: OK */
697 movi a3, BASE + 0x7fff
700 movi a3, BASE + 0x00007ffc
704 set_vector kernel, 3f
706 movi a2, 0x0400000c /* PPN */
707 movi a3, BASE + 0x00008000 /* VPN */
709 movi a2, BASE + 0x00007ffc
710 movi a3, BASE + 0x00008000
711 /* DTLB: FAIL, ITLB: OK */
718 movi a3, BASE + 0x7ffc
721 movi a3, BASE + 0x00007ffc
725 set_vector kernel, 4f
727 movi a2, 0x0400000c /* PPN */
728 movi a3, BASE + 0x00008000 /* VPN */
730 movi a2, 0x04000003 /* PPN */
732 movi a2, BASE + 0x00007ffc
733 movi a3, BASE + 0x00008000
734 /* DTLB: OK, ITLB: FAIL */
741 movi a3, BASE + 0x7fff
744 movi a3, BASE + 0x00007ffc
748 set_vector kernel, 5f
750 movi a2, 0x0400000c /* PPN */
751 movi a3, BASE + 0x00008000 /* VPN */
753 movi a2, BASE + 0x00007ffc
754 movi a3, BASE + 0x00008000
755 /* DTLB: FAIL, ITLB: FAIL */
762 movi a3, BASE + 0x7ffc
765 movi a3, BASE + 0x00007ffc