updated tests to use test title instead of number encoding

This commit is contained in:
Kip Macsai-Goren 2022-01-30 22:56:03 +00:00
parent 3f5f5e48fa
commit e3ea593ed8
9 changed files with 445 additions and 446 deletions

View File

@ -44,52 +44,52 @@
# test 12.3.1.1.1 write page tables / entries to phyiscal memory # test 12.3.1.1.1 write page tables / entries to phyiscal memory
# sv32 Page table (See Figure 12.12***): # sv32 Page table (See Figure 12.12***):
# Level 1 page table, situated at 0x8000D000 # Level 1 page table, situated at 0x8000D000
.4byte 0x8000D000, 0x20004C01, 0x0 # points to level 0 page table A .4byte 0x8000D000, 0x20004C01, write32_test # points to level 0 page table A
.4byte 0x8000D004, 0x200000CB, 0x0 # Vaddr 0x400000 Paddr 0x80000000: aligned megapage, W=0, used for execute tests .4byte 0x8000D004, 0x200000CB, write32_test # Vaddr 0x400000 Paddr 0x80000000: aligned megapage, W=0, used for execute tests
.4byte 0x8000D008, 0x20005401, 0x0 # points to level 0 page table B .4byte 0x8000D008, 0x20005401, write32_test # points to level 0 page table B
.4byte 0x8000D00C, 0x000800C7, 0x0 # Vaddr 0xC00000: misaligned megapage .4byte 0x8000D00C, 0x000800C7, write32_test # Vaddr 0xC00000: misaligned megapage
.4byte 0x8000D800, 0x200000CF, 0x0 # Vaddr 0x80000000 Paddr 0x80000000: aligned megapage (program and data memory) .4byte 0x8000D800, 0x200000CF, write32_test # Vaddr 0x80000000 Paddr 0x80000000: aligned megapage (program and data memory)
.4byte 0x8000D804, 0x200000DF, 0x0 # Vaddr 0x80400000 Paddr 0x80000000: aligned megapage, U=1 (aliased with program and data memory) .4byte 0x8000D804, 0x200000DF, write32_test # Vaddr 0x80400000 Paddr 0x80000000: aligned megapage, U=1 (aliased with program and data memory)
# Level 0 page table A # Level 0 page table A
.4byte 0x80013000, 0x20007001, 0x0 # Vaddr 0x0000: bad PTE points to level -1 table .4byte 0x80013000, 0x20007001, write32_test # Vaddr 0x0000: bad PTE points to level -1 table
.4byte 0x80013004, 0x202000DF, 0x0 # Vaddr 0x1000 Paddr 0x80800000: aligned kilopage, U=1 .4byte 0x80013004, 0x202000DF, write32_test # Vaddr 0x1000 Paddr 0x80800000: aligned kilopage, U=1
.4byte 0x80013008, 0x202010D5, 0x0 # Vaddr 0x2000: pad PTE has W but not R .4byte 0x80013008, 0x202010D5, write32_test # Vaddr 0x2000: pad PTE has W but not R
.4byte 0x8001300C, 0x20200817, 0x0 # Vaddr 0x3000: A=0, should cause read fault .4byte 0x8001300C, 0x20200817, write32_test # Vaddr 0x3000: A=0, should cause read fault
.4byte 0x80013010, 0x20200C57, 0x0 # Vaddr 0x4000: D=0, should cause write fault .4byte 0x80013010, 0x20200C57, write32_test # Vaddr 0x4000: D=0, should cause write fault
.4byte 0x80013014, 0x202014C9, 0x0 # Vaddr 0x5000 Paddr 80805000: aligned kilopage, W=R=0 .4byte 0x80013014, 0x202014C9, write32_test # Vaddr 0x5000 Paddr 80805000: aligned kilopage, W=R=0
.4byte 0x80013018, 0x0, 0x0 # Vaddr 0x6000: invalid page .4byte 0x80013018, 0x0, write32_test # Vaddr 0x6000: invalid page
# Level 0 page table B # Level 0 page table B
.4byte 0x80015FFC, 0x202004C7, 0x0 # Vaddr 0xBFF000 Paddr 0x80801000: aligned kilopage with X=0, U=0 .4byte 0x80015FFC, 0x202004C7, write32_test # Vaddr 0xBFF000 Paddr 0x80801000: aligned kilopage with X=0, U=0
# test 12.3.1.1.2 write values to Paddrs in each page # test 12.3.1.1.2 write values to Paddrs in each page
# each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments. # each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments.
# when a test is supposed to fault, nothing is written into where it'll be reading/executing since it should fault before getting there. # when a test is supposed to fault, nothing is written into where it'll be reading/executing since it should fault before getting there.
.4byte 0x800AAAA8, 0xBEEF0055, 0x0 # 12.3.1.1.4 megapage .4byte 0x800AAAA8, 0xBEEF0055, write32_test # 12.3.1.1.4 megapage
.4byte 0x800FFAC0, 0xBEEF0033, 0x0 # 12.3.1.3.2 .4byte 0x800FFAC0, 0xBEEF0033, write32_test # 12.3.1.3.2
.4byte 0x800E3130, 0xBEEF0077, 0x0 # 12.3.1.3.2 .4byte 0x800E3130, 0xBEEF0077, write32_test # 12.3.1.3.2
.4byte 0x808017E0, 0xBEEF0099, 0x0 # 12.3.1.1.4 kilopage .4byte 0x808017E0, 0xBEEF0099, write32_test # 12.3.1.1.4 kilopage
.4byte 0x80805EA0, 0xBEEF0440, 0x0 # 12.3.1.3.3 .4byte 0x80805EA0, 0xBEEF0440, write32_test # 12.3.1.3.3
.4byte 0x80803AA0, 0xBEEF0BB0, 0x0 # 12.3.1.3.7 .4byte 0x80803AA0, 0xBEEF0BB0, write32_test # 12.3.1.3.7
.4byte 0x8000FFA0, 0x11100393, 0x0 # write executable code for "li x7, 0x111; ret" to executable region. .4byte 0x8000FFA0, 0x11100393, write32_test # write executable code for "li x7, 0x111; ret" to executable region.
.4byte 0x8000FFA4, 0x00008067, 0x0 # Used for 12.3.1.3.1, 12.3.1.3.2 .4byte 0x8000FFA4, 0x00008067, write32_test # Used for 12.3.1.3.1, 12.3.1.3.2
# test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test) # test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test)
.4byte 0x0, 0x0, 0x4 # satp.MODE = baremetal / no translation. .4byte 0x0, 0x0, goto_baremetal # satp.MODE = baremetal / no translation.
.4byte 0x0, 0x0, 0x9 # change to S mode, 0xb written to output .4byte 0x0, 0x0, goto_s_mode # change to S mode, 0xb written to output
.4byte 0x800AAAA8, 0xBEEF0055, 0x1 .4byte 0x800AAAA8, 0xBEEF0055, read32_test
.4byte 0x800FFAC0, 0xBEEF0033, 0x1 .4byte 0x800FFAC0, 0xBEEF0033, read32_test
.4byte 0x800E3130, 0xBEEF0077, 0x1 .4byte 0x800E3130, 0xBEEF0077, read32_test
.4byte 0x808017E0, 0xBEEF0099, 0x1 .4byte 0x808017E0, 0xBEEF0099, read32_test
.4byte 0x80805EA0, 0xBEEF0440, 0x1 .4byte 0x80805EA0, 0xBEEF0440, read32_test
.4byte 0x80803AA0, 0xBEEF0BB0, 0x1 .4byte 0x80803AA0, 0xBEEF0BB0, read32_test
.4byte 0x8000FFA0, 0x11100393, 0x1 .4byte 0x8000FFA0, 0x11100393, read32_test
.4byte 0x8000FFA4, 0x00008067, 0x1 .4byte 0x8000FFA4, 0x00008067, read32_test
# test 12.3.1.1.4 check translation works in sv48, read the same values from previous tests, this time with Vaddrs # test 12.3.1.1.4 check translation works in sv48, read the same values from previous tests, this time with Vaddrs
.4byte 0x0, 0x0, 0x5 # satp.MODE = sv32, Nothing written to output .4byte 0x0, 0x0, goto_sv32 # satp.MODE = sv32, Nothing written to output
.4byte 0x4AAAA8, 0xBEEF0055, 0x1 # megapage at Vaddr 0x400000, Paddr 0x80000000 .4byte 0x4AAAA8, 0xBEEF0055, read32_test # megapage at Vaddr 0x400000, Paddr 0x80000000
.4byte 0xBFF7E0, 0xBEEF0099, 0x1 # kilopage at Vaddr 0xBFF000, Paddr 0x80201000 .4byte 0xBFF7E0, 0xBEEF0099, read32_test # kilopage at Vaddr 0xBFF000, Paddr 0x80201000
# =========== test 12.3.1.2 page fault tests =========== # =========== test 12.3.1.2 page fault tests ===========
@ -97,59 +97,59 @@
# Not tested in rv32/sv32 # Not tested in rv32/sv32
# test 12.3.1.2.2 load page fault when reading an address where the valid flag is zero # test 12.3.1.2.2 load page fault when reading an address where the valid flag is zero
.4byte 0x6000, 0x0, 0x1 .4byte 0x6000, 0x0, read32_test
# test 12.3.1.2.3 store page fault if PTE has W and ~R flags set # test 12.3.1.2.3 store page fault if PTE has W and ~R flags set
.4byte 0x2000, 0x0, 0x0 .4byte 0x2000, 0x0, write32_test
# test 12.3.1.2.4 Fault if last level PTE is a pointer # test 12.3.1.2.4 Fault if last level PTE is a pointer
.4byte 0x0200, 0x0, 0x1 .4byte 0x0200, 0x0, read32_test
# test 12.3.1.2.5 load page fault on misaligned pages # test 12.3.1.2.5 load page fault on misaligned pages
.4byte 0xC00000, 0x0, 0x1 # misaligned megapage .4byte 0xC00000, 0x0, read32_test # misaligned megapage
# =========== test 12.3.1.3 PTE Protection flags =========== # =========== test 12.3.1.3 PTE Protection flags ===========
# test 12.3.1.3.1 User flag == 0 # test 12.3.1.3.1 User flag == 0
# *** reads on pages with U=0 already tested in 12.3.1.1.4 # *** reads on pages with U=0 already tested in 12.3.1.1.4
.4byte 0x40FFA0, 0x111, 0x2 # fetch success when U=0, priv=S .4byte 0x40FFA0, 0x111, executable_test # fetch success when U=0, priv=S
.4byte 0x80400000, 0x1, 0xA # go to U mode, return to VPN 0x80400000 where PTE.U = 1. 0x9 written to output .4byte 0x80400000, 0x1, goto_u_mode # go to U mode, return to VPN 0x80400000 where PTE.U = 1. 0x9 written to output
.4byte 0xBFFC80, 0xBEEF0550, 0x1 # load page fault when U=0, priv=U .4byte 0xBFFC80, 0xBEEF0550, read32_test # load page fault when U=0, priv=U
.4byte 0x40FFA0, 0xbad, 0x2 # instr page fault when U=0, priv=U .4byte 0x40FFA0, 0xbad, executable_test # instr page fault when U=0, priv=U
# test 12.3.1.3.2 User flag == 1 # test 12.3.1.3.2 User flag == 1
.4byte 0x804FFAC0, 0xBEEF0033, 0x1 # read success when U=1, priv=U .4byte 0x804FFAC0, 0xBEEF0033, read32_test # read success when U=1, priv=U
.4byte 0x80000000, 0x1, 0x9 # go back to S mode, return to VPN 0x80000000 where PTE.U = 0. 0x8 written to output .4byte 0x80000000, 0x1, goto_s_mode # go back to S mode, return to VPN 0x80000000 where PTE.U = 0. 0x8 written to output
.4byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11 .4byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11
.4byte 0x804E3130, 0xBEEF0077, 0x1 # read success when U=1, priv=S, sstatus.SUM=1 .4byte 0x804E3130, 0xBEEF0077, read32_test # read success when U=1, priv=S, sstatus.SUM=1
.4byte 0x8040FFA0, 0xbad, 0x2 # instr page fault when U=1, priv=S (with any sstatus.SUM) .4byte 0x8040FFA0, 0xbad, executable_test # instr page fault when U=1, priv=S (with any sstatus.SUM)
.4byte 0x0, 0x2, 0x7 # set sstatus.[MXR, SUM] = 10. .4byte 0x0, 0x2, write_mxr_sum # set sstatus.[MXR, SUM] = 10.
.4byte 0x804FFAC0, 0xBEEF0033, 0x1 # load page fault when U-1, priv=S, sstatus.SUM=0 .4byte 0x804FFAC0, 0xBEEF0033, read32_test # load page fault when U-1, priv=S, sstatus.SUM=0
# test 12.3.1.3.3 Read flag # test 12.3.1.3.3 Read flag
# *** reads on pages with R=1 already tested in 12.3.1.1.4 # *** reads on pages with R=1 already tested in 12.3.1.1.4
.4byte 0x0, 0x1, 0x7 # set sstatus.[MXR, SUM] = 01. .4byte 0x0, 0x1, write_mxr_sum # set sstatus.[MXR, SUM] = 01.
.4byte 0x5EA0, 0xBEEF0440, 0x1 # load page fault when R=0, sstatus.MXR=0 .4byte 0x5EA0, 0xBEEF0440, read32_test # load page fault when R=0, sstatus.MXR=0
.4byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11. .4byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11.
.4byte 0x5EA0, 0xBEEF0440, 0x1 # read success when R=0, MXR=1, X=1 .4byte 0x5EA0, 0xBEEF0440, read32_test # read success when R=0, MXR=1, X=1
# test 12.3.1.3.4 Write flag # test 12.3.1.3.4 Write flag
.4byte 0xBFF290, 0xBEEF0110, 0x0 # write success when W=1 .4byte 0xBFF290, 0xBEEF0110, write32_test # write success when W=1
.4byte 0xBFF290, 0xBEEF0110, 0x1 # check write success by reading .4byte 0xBFF290, 0xBEEF0110, read32_test # check write success by reading
.4byte 0x5B78, 0xBEEF0CC0, 0x0 # store page fault when W=0 .4byte 0x5B78, 0xBEEF0CC0, write32_test # store page fault when W=0
# test 12.3.1.3.5 eXecute flag # test 12.3.1.3.5 eXecute flag
# *** fetches on pages with X = 1 already tested in 12.3.1.3.1 # *** fetches on pages with X = 1 already tested in 12.3.1.3.1
.4byte 0xBFFDE0, 0xbad, 0x2 # instr page fault when X=0 .4byte 0xBFFDE0, 0xbad, executable_test # instr page fault when X=0
# test 12.3.1.3.6 Accessed flag == 0 # test 12.3.1.3.6 Accessed flag == 0
.4byte 0x3020, 0xBEEF0770, 0x0 # store page fault when A=0 .4byte 0x3020, 0xBEEF0770, write32_test # store page fault when A=0
.4byte 0x3808, 0xBEEF0990, 0x1 # load page fault when A=0 .4byte 0x3808, 0xBEEF0990, read32_test # load page fault when A=0
# test 12.3.1.3.7 Dirty flag == 0 # test 12.3.1.3.7 Dirty flag == 0
.4byte 0x4658, 0xBEEF0AA0, 0x0 # store page fault when D=0 .4byte 0x4658, 0xBEEF0AA0, write32_test # store page fault when D=0
.4byte 0x4AA0, 0xBEEF0BB0, 0x1 # read success when D=0 .4byte 0x4AA0, 0xBEEF0BB0, read32_test # read success when D=0
# terminate tests # terminate tests
.4byte 0x0, 0x0, 0x3 # brings us back into machine mode with a final ecall, writing 0x9 to the output. .4byte 0x0, 0x0, terminate_test # brings us back into machine mode with a final ecall, writing 0x9 to the output.

View File

@ -71,49 +71,49 @@
# ----------------- CLINT --------------------- # ----------------- CLINT ---------------------
# Use timecmp register as readable and writable section of the CLINT # Use timecmp register as readable and writable section of the CLINT
.4byte CLINT_BASE + 0x4000, 0xBEEF00B5, 0x0 # 32-bit write: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B5, write32_test # 32-bit write: success
.4byte CLINT_BASE + 0x4000, 0xBEEF00B5, 0x1 # 32-bit read: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B5, read32_test # 32-bit read: success
.4byte CLINT_BASE + 0x4000, 0xBEEF00B6, 0x12 # 16-bit write: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B6, write16_test# 16-bit write: success
.4byte CLINT_BASE + 0x4000, 0xBEEF00B6, 0x15 # 16-bit read: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B6, read16_test# 16-bit read: success
.4byte CLINT_BASE + 0x4000, 0xBEEF00B7, 0x13 # 08-bit write: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B7, write08_test# 08-bit write: success
.4byte CLINT_BASE + 0x4000, 0xBEEF00B7, 0x16 # 08-bit read: success .4byte CLINT_BASE + 0x4000, 0xBEEF00B7, read08_test# 08-bit read: success
.4byte CLINT_BASE, 0xbad, 0x2 # execute: instruction access fault .4byte CLINT_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- PLIC --------------------- # ----------------- PLIC ---------------------
# Write 0x2 instead of wider value to plic address because the register width might change. # Write 0x2 instead of wider value to plic address because the register width might change.
.4byte PLIC_BASE + 0x2000, 0x2, 0x0 # 32-bit write: success .4byte PLIC_BASE + 0x2000, 0x2, write32_test # 32-bit write: success
.4byte PLIC_BASE + 0x2000, 0x2, 0x1 # 32-bit read: success .4byte PLIC_BASE + 0x2000, 0x2, read32_test # 32-bit read: success
.4byte PLIC_BASE, 0xBEEF00BA, 0x12 # 16-bit write: store access fault .4byte PLIC_BASE, 0xBEEF00BA, write16_test # 16-bit write: store access fault
.4byte PLIC_BASE, 0xBEEF00BA, 0x15 # 16-bit read: load access fault .4byte PLIC_BASE, 0xBEEF00BA, read16_test # 16-bit read: load access fault
.4byte PLIC_BASE, 0xBEEF00BB, 0x13 # 08-bit write: store access fault .4byte PLIC_BASE, 0xBEEF00BB, write08_test # 08-bit write: store access fault
.4byte PLIC_BASE, 0xBEEF00BB, 0x16 # 08-bit read: load access fault .4byte PLIC_BASE, 0xBEEF00BB, read08_test # 08-bit read: load access fault
.4byte PLIC_BASE, 0xbad, 0x2 # execute: instruction access fault .4byte PLIC_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- UART0 --------------------- # ----------------- UART0 ---------------------
.4byte UART_BASE, 0xBEEF00BD, 0x0 # 32-bit write: store access fault .4byte UART_BASE, 0xBEEF00BD, write32_test # 32-bit write: store access fault
.4byte UART_BASE, 0xBEEF00BD, 0x1 # 32-bit read: load access fault .4byte UART_BASE, 0xBEEF00BD, read32_test # 32-bit read: load access fault
.4byte UART_BASE, 0xBEEF00BE, 0x12 # 16-bit write: store access fault .4byte UART_BASE, 0xBEEF00BE, write16_test# 16-bit write: store access fault
.4byte UART_BASE, 0xBEEF00BE, 0x15 # 16-bit read: load access fault .4byte UART_BASE, 0xBEEF00BE, read16_test# 16-bit read: load access fault
# Different address for this test so that we write into a writable register in the uart. # Different address for this test so that we write into a writable register in the uart.
.4byte UART_BASE + 0x3, 0xBEEF00BF, 0x13 # 08-bit write: success .4byte UART_BASE + 0x3, 0xBEEF00BF, write08_test# 08-bit write: success
.4byte UART_BASE + 0x3, 0xBEEF00BF, 0x16 # 08-bit read: success .4byte UART_BASE + 0x3, 0xBEEF00BF, read08_test# 08-bit read: success
.4byte UART_BASE, 0xbad, 0x2 # execute: instruction access fault .4byte UART_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- GPIO --------------------- # ----------------- GPIO ---------------------
.4byte GPIO_BASE + 0x8, 0xBEEF00C1, 0x0 # 32-bit write: success .4byte GPIO_BASE + 0x8, 0xBEEF00C1, write32_test # 32-bit write: success
.4byte GPIO_BASE + 0x8, 0xBEEF00C1, 0x1 # 32-bit read: success .4byte GPIO_BASE + 0x8, 0xBEEF00C1, read32_test# 32-bit read: success
.4byte GPIO_BASE, 0xBEEF00C2, 0x12 # 16-bit write: store access fault .4byte GPIO_BASE, 0xBEEF00C2, write16_test # 16-bit write: store access fault
.4byte GPIO_BASE, 0xBEEF00C2, 0x15 # 16-bit read: load access fault .4byte GPIO_BASE, 0xBEEF00C2, read16_test # 16-bit read: load access fault
.4byte GPIO_BASE, 0xBEEF00C3, 0x13 # 08-bit write: store access fault .4byte GPIO_BASE, 0xBEEF00C3, write08_test # 08-bit write: store access fault
.4byte GPIO_BASE, 0xBEEF00C3, 0x16 # 08-bit read: load access fault .4byte GPIO_BASE, 0xBEEF00C3, read08_test # 08-bit read: load access fault
.4byte GPIO_BASE, 0xbad, 0x2 # execute: instruction access fault .4byte GPIO_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- Inaccessible --------------------- # ----------------- Inaccessible ---------------------
@ -121,32 +121,32 @@
# show that load, store, and jalr cause faults in a region not defined by PMAs. # show that load, store, and jalr cause faults in a region not defined by PMAs.
# Tests 'random' place in unimplemented memory # Tests 'random' place in unimplemented memory
.4byte 0x40000000, 0xBEEF00C7, 0x0 # 32-bit write: store access fault .4byte 0x40000000, 0xBEEF00C7, write32_test # 32-bit write: store access fault
.4byte 0x40000000, 0xBEEF00C7, 0x1 # 32-bit read: load access fault .4byte 0x40000000, 0xBEEF00C7, read32_test # 32-bit read: load access fault
.4byte 0x40000000, 0x111, 0x2 # execute: instruction access fault .4byte 0x40000000, 0x111, executable_test # execute: instruction access fault
# Tests just past the end of each peripheral # Tests just past the end of each peripheral
.4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0xBEEF00C8, 0x0 # 32-bit write: store access fault .4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0xBEEF00C8, write32_test # 32-bit write: store access fault
.4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0xBEEF00C8, 0x1 # 32-bit read: load access fault .4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0xBEEF00C8, read32_test # 32-bit read: load access fault
.4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x111, 0x2 # execute: instruction access fault .4byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x111, executable_test # execute: instruction access fault
.4byte (CLINT_BASE+CLINT_RANGE+1), 0xBEEF00C9, 0x0 # 32-bit write: store access fault .4byte (CLINT_BASE+CLINT_RANGE+1), 0xBEEF00C9, write32_test # 32-bit write: store access fault
.4byte (CLINT_BASE+CLINT_RANGE+1), 0xBEEF00C9, 0x1 # 32-bit read: load access fault .4byte (CLINT_BASE+CLINT_RANGE+1), 0xBEEF00C9, read32_test # 32-bit read: load access fault
.4byte (CLINT_BASE+CLINT_RANGE+1), 0x111, 0x2 # execute: instruction access fault .4byte (CLINT_BASE+CLINT_RANGE+1), 0x111, executable_test # execute: instruction access fault
.4byte (PLIC_BASE+PLIC_RANGE+1), 0xBEEF00CA, 0x0 # 32-bit write: store access fault .4byte (PLIC_BASE+PLIC_RANGE+1), 0xBEEF00CA, write32_test # 32-bit write: store access fault
.4byte (PLIC_BASE+PLIC_RANGE+1), 0xBEEF00CA, 0x1 # 32-bit read: load access fault .4byte (PLIC_BASE+PLIC_RANGE+1), 0xBEEF00CA, read32_test # 32-bit read: load access fault
.4byte (PLIC_BASE+PLIC_RANGE+1), 0x111, 0x2 # execute: instruction access fault .4byte (PLIC_BASE+PLIC_RANGE+1), 0x111, executable_test # execute: instruction access fault
.4byte (UART_BASE+UART_RANGE+1), 0xBEEF00CB, 0x13 # 08-bit write: store access fault .4byte (UART_BASE+UART_RANGE+1), 0xBEEF00CB, write08_test # 08-bit write: store access fault
.4byte (UART_BASE+UART_RANGE+1), 0xBEEF00CB, 0x16 # 08-bit read: load access fault .4byte (UART_BASE+UART_RANGE+1), 0xBEEF00CB, read08_test # 08-bit read: load access fault
.4byte (UART_BASE+UART_RANGE+1), 0x111, 0x2 # execute: instruction access fault .4byte (UART_BASE+UART_RANGE+1), 0x111, executable_test # execute: instruction access fault
.4byte (GPIO_BASE+GPIO_RANGE+1), 0xBEEF00CC, 0x0 # 32-bit write: store access fault .4byte (GPIO_BASE+GPIO_RANGE+1), 0xBEEF00CC, write32_test # 32-bit write: store access fault
.4byte (GPIO_BASE+GPIO_RANGE+1), 0xBEEF00CC, 0x1 # 32-bit read: load access fault .4byte (GPIO_BASE+GPIO_RANGE+1), 0xBEEF00CC, read32_test # 32-bit read: load access fault
.4byte (GPIO_BASE+GPIO_RANGE+1), 0x111, 0x2 # execute: instruction access fault .4byte (GPIO_BASE+GPIO_RANGE+1), 0x111, executable_test # execute: instruction access fault
.4byte 0x0, 0x0, 0x3 # terminate tests .4byte 0x0, 0x0, terminate_test # terminate tests

View File

@ -46,69 +46,69 @@
# write pmpaddr regs # write pmpaddr regs
# | Reg | pmpaddr | pmpcfg | L | A | X | W | R | Comments | # | Reg | pmpaddr | pmpcfg | L | A | X | W | R | Comments |
.4byte 0x0, 0x0FFFFFFF, 0xE # | 0 | 0x0FFFFFFF | 1F | 0 | NAPOT | 0 | 1 | 1 | I/O 00000000-7FFFFFFF RW | .4byte 0x0, 0x0FFFFFFF, write_pmpaddr_0 # | 0 | 0x0FFFFFFF | 1F | 0 | NAPOT | 0 | 1 | 1 | I/O 00000000-7FFFFFFF RW |
.4byte 0x1, 0x20040000, 0xE # | 1 | 0x20040000 | 00 | 0 | OFF | 0 | 0 | 0 | | .4byte 0x1, 0x20040000, write_pmpaddr_0 # | 1 | 0x20040000 | 00 | 0 | OFF | 0 | 0 | 0 | |
.4byte 0x2, 0x2004003F, 0xE # | 2 | 0x2004003F | 09 | 0 | TOR | 0 | 0 | 1 | 80100000-801000FF R | .4byte 0x2, 0x2004003F, write_pmpaddr_0 # | 2 | 0x2004003F | 09 | 0 | TOR | 0 | 0 | 1 | 80100000-801000FF R |
.4byte 0x3, 0x20040080, 0xE # | 3 | 0x20040080 | 00 | 0 | OFF | 0 | 0 | 0 | | .4byte 0x3, 0x20040080, write_pmpaddr_0 # | 3 | 0x20040080 | 00 | 0 | OFF | 0 | 0 | 0 | |
.4byte 0x4, 0x20040084, 0xE # | 4 | 0x20040084 | 0C | 0 | TOR | 1 | 0 | 0 | 80100200-80100210 X | .4byte 0x4, 0x20040084, write_pmpaddr_0 # | 4 | 0x20040084 | 0C | 0 | TOR | 1 | 0 | 0 | 80100200-80100210 X |
.4byte 0x5, 0x200400C0, 0xE # | 5 | 0x200400C0 | 90 | 1 | NA4 | 0 | 0 | 0 | 80100300-80100303 locked out | .4byte 0x5, 0x200400C0, write_pmpaddr_0 # | 5 | 0x200400C0 | 90 | 1 | NA4 | 0 | 0 | 0 | 80100300-80100303 locked out |
.4byte 0x6, 0x2004013F, 0xE # | 6 | 0x2004013F | 18 | 0 | NAPOT | 0 | 0 | 0 | 80100400-801004FF no access | .4byte 0x6, 0x2004013F, write_pmpaddr_0 # | 6 | 0x2004013F | 18 | 0 | NAPOT | 0 | 0 | 0 | 80100400-801004FF no access |
# Pmpaddr 7-14 are all zeroed out in this test, so they don't need writes. # Pmpaddr 7-14 are all zeroed out in this test, so they don't need writes.
.4byte 0xF, 0x2FFFFFFF, 0xE # | 15 | 0x2FFFFFFF | 1F | 0 | NAPOT | 1 | 1 | 1 | Main mem 80000000-FFFFFFFF RWX| .4byte 0xF, 0x2FFFFFFF, write_pmpaddr_0 # | 15 | 0x2FFFFFFF | 1F | 0 | NAPOT | 1 | 1 | 1 | Main mem 80000000-FFFFFFFF RWX|
# write pmpcfg regs with the information in the table above. this should also write the value of these registers to the output. # write pmpcfg regs with the information in the table above. this should also write the value of these registers to the output.
.4byte 0x0, 0x0009001F, 0xD # write pmpcfg0, output 0x0009001F .4byte 0x0, 0x0009001F, write_pmpcfg_0 # write pmpcfg0, output 0x0009001F
.4byte 0x1, 0x0018900C, 0xD # write pmpcfg1, output 0x0018900C .4byte 0x1, 0x0018900C, write_pmpcfg_0 # write pmpcfg1, output 0x0018900C
# pmpcfg2 is zeroed out, so it doesn't need a write # pmpcfg2 is zeroed out, so it doesn't need a write
.4byte 0x3, 0x1F000000, 0xD # write pmpcfg3, output 0x1F000000 .4byte 0x3, 0x1F000000, write_pmpcfg_0 # write pmpcfg3, output 0x1F000000
# write known values to memory where W=0. This should be possible since we're in machine mode. # write known values to memory where W=0. This should be possible since we're in machine mode.
.4byte 0x80100010, 0x600DAA, 0x0 # write to pmpaddr 1-2 range .4byte 0x80100010, 0x600DAA, write32_test # write to pmpaddr 1-2 range
.4byte 0x80100400, 0x600DBB, 0x0 # write to pmpaddr 6 range .4byte 0x80100400, 0x600DBB, write32_test # write to pmpaddr 6 range
# Write executable code to regions where X = 0, 1 in main memory # Write executable code to regions where X = 0, 1 in main memory
.4byte 0x80100200, 0x11100393, 0x0 # write executable code for "li x7, 0x111; ret" to region with X=1 (PMP4) .4byte 0x80100200, 0x11100393, write32_test # write executable code for "li x7, 0x111; ret" to region with X=1 (PMP4)
.4byte 0x80100204, 0x00008067, 0x0 .4byte 0x80100204, 0x00008067, write32_test
.4byte 0x80100020, 0x11100393, 0x0 # write same executable code to region with X=0 (PMP2) .4byte 0x80100020, 0x11100393, write32_test # write same executable code to region with X=0 (PMP2)
.4byte 0x80100024, 0x00008067, 0x0 .4byte 0x80100024, 0x00008067, write32_test
# attempt to write to pmpaddr5 and pmp5cfg after lockout # attempt to write to pmpaddr5 and pmp5cfg after lockout
.4byte 0x1, 0x0018FF0C, 0xD # attempt to edit only pmp5cfg (pmpcfg1[8:15]) after lockout. .4byte 0x1, 0x0018FF0C, write_pmpcfg_0 # attempt to edit only pmp5cfg (pmpcfg1[8:15]) after lockout.
# instruction ignored, output is 0x0018900C, NOT 0x0018FF0C # instruction ignored, output is 0x0018900C, NOT 0x0018FF0C
.4byte 0x5, 0xFFFFFFFF, 0xE # attempt to edit pmpaddr5 after lockout. .4byte 0x5, 0xFFFFFFFF, write_pmpaddr_0 # attempt to edit pmpaddr5 after lockout.
# instruction ignored, output is 0x200400C0, NOT 0xFFFFFFFF # instruction ignored, output is 0x200400C0, NOT 0xFFFFFFFF
# Test 12.3.2.2.2 Machine mode access # Test 12.3.2.2.2 Machine mode access
.4byte 0x80100300, 0x0, 0x1 # access fault to region with L=1, R=0. This one writes 0x5 as the mcause, not 0xd. .4byte 0x80100300, 0x0, read32_test # access fault to region with L=1, R=0. This one writes 0x5 as the mcause, not 0xd.
.4byte 0x80100400, 0x0, 0x1 # successful access to region with L=X=W=R=0 .4byte 0x80100400, 0x0, read32_test # successful access to region with L=X=W=R=0
# Test 12.3.2.2.3 System mode access # Test 12.3.2.2.3 System mode access
.4byte 0x0, 0x0, 0x9 # go to S mode. 0xb written to output .4byte 0x0, 0x0, goto_s_mode # go to S mode. 0xb written to output
# test a write followed by a read to each region with R=W=1 # test a write followed by a read to each region with R=W=1
.4byte 0x80200000, 0x600D15, 0x0 # Write "good value" to RW range (PMP15) .4byte 0x80200000, 0x600D15, write32_test # Write "good value" to RW range (PMP15)
.4byte 0x80200000, 0x600D15, 0x1 # confirm write with read .4byte 0x80200000, 0x600D15, read32_test # confirm write with read
# test a write followed by a read on the edges of a read-only range # test a write followed by a read on the edges of a read-only range
.4byte 0x800FFFF8, 0x600D02, 0x0 # Write "good value" just below read-only range (PMP2) .4byte 0x800FFFF8, 0x600D02, write32_test # Write "good value" just below read-only range (PMP2)
.4byte 0x800FFFF8, 0x600D02, 0x1 # confirm write with read .4byte 0x800FFFF8, 0x600D02, read32_test # confirm write with read
.4byte 0x80100100, 0x600D12, 0x0 # Write "good value" just above read-only range (PMP2) .4byte 0x80100100, 0x600D12, write32_test # Write "good value" just above read-only range (PMP2)
.4byte 0x80100100, 0x600D12, 0x1 # confirm write with read .4byte 0x80100100, 0x600D12, read32_test # confirm write with read
# test a read from each read only range verify a write causes an access fault # test a read from each read only range verify a write causes an access fault
.4byte 0x80100010, 0xBAD, 0x0 # Write fault in read-only range (PMP2) .4byte 0x80100010, 0xBAD, write32_test # Write fault in read-only range (PMP2)
.4byte 0x80100010, 0x600DAA, 0x1 # read correct value out .4byte 0x80100010, 0x600DAA, read32_test # read correct value out
# test read and write fault on region with no access # test read and write fault on region with no access
.4byte 0x80100208, 0x600D15, 0x0 # Write fault on no-access range (PMP6) .4byte 0x80100208, 0x600D15, write32_test # Write fault on no-access range (PMP6)
.4byte 0x80100208, 0x600D15, 0x1 # read fault on no-access range (PMP6) .4byte 0x80100208, 0x600D15, read32_test # read fault on no-access range (PMP6)
# test jalr to region with X=0 causes access fault # test jalr to region with X=0 causes access fault
.4byte 0x80100020, 0xbad, 0x2 # execute fault on no-execute range (PMP2) .4byte 0x80100020, 0xbad, executable_test # execute fault on no-execute range (PMP2)
# test jalr to region with X=1 returns successfully # test jalr to region with X=1 returns successfully
.4byte 0x80100200, 0x111, 0x2 # execute success when X=1 .4byte 0x80100200, 0x111, executable_test # execute success when X=1
.4byte 0x0, 0x0, 0x3 // terminate tests .4byte 0x0, 0x0, terminate_test // terminate tests

View File

@ -288,37 +288,35 @@ test_loop:
lw x30, 8(x5) # fetch test case flag lw x30, 8(x5) # fetch test case flag
addi x5, x5, 12 # set x5 to next test case addi x5, x5, 12 # set x5 to next test case
slli x30, x30, 2 # multiply test type by 4 to index into jump table # x5 has the symbol for a test's location in the assembly
la x7, test_jump_table # load base address of jump table li x7, 0x3FFFFF
add x7, x7, x30 # get address of jump table entry and x30, x30, x7 # This program is always on at least a megapage, so this masks out the megapage offset.
jr x7 # jump to relevant test auipc x7, 0x0
srli x7, x7, 22
slli x7, x7, 22 # zero out the bottom 22 bits so the megapage offset of the symbol can be placed there
or x30, x7, x30 # x30 = virtual address of the symbol for this type of test.
jr x30
# Test Name : Description : Fault output value : Normal output values
# ----------------------:---------------------------------------:------------------------:------------------------------------------------------
# write32_test : Write 32 bits to address : 0xf : None
# write16_test : Write 16 bits to address : 0xf : None
# write08_test : Write 8 bits to address : 0xf : None
# read32_test : Read 32 bits from address : 0xd, 0xbad : readvalue in hex
# read16_test : Read 16 bits from address : 0xd, 0xbad : readvalue in hex
# read08_test : Read 8 bits from address : 0xd, 0xbad : readvalue in hex
# executable_test : test executable at address : 0xc, 0xbad : leading 12 bits of the li instr written to address. In general this is 0x111. (be sure to also write a return instruction)
# terminate_test : terminate tests : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_baremetal : satp.MODE = bare metal : None : None
# goto_sv32 : satp.MODE = sv32 : None : None
# write_mxr_sum : write sstatus.[19:18] = MXR, SUM bits : None : None
# goto_m_mode : go to mahcine mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_s_mode : go to supervisor mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_u_mode : go to user mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# write_pmpcfg_x : Write one of the pmpcfg csr's : mstatuses?, 0xD : readback of pmpcfg value
# write_pmpaddr_x : Write one of the pmpaddr csr's : None : readback of pmpaddr value
test_jump_table:
# x30 Value : Function : Fault output value : Normal output values
# ----------:---------------------------------------:------------------------:------------------------------------------------------
j write32_test # 0x0 : Write 32 bits to address : 0xf : None
j read32_test # 0x1 : Read 32 bits from address : 0xd, 0xbad : readvalue in hex
j executable_test # 0x2 : test executable at address : 0xc, 0xbad : leading 12 bits of the li instr written to address. In general this is 0x111. (be sure to also write a return instruction)
j terminate_test # 0x3 : terminate tests : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_baremetal # 0x4 : satp.MODE = bare metal : None : None
j goto_sv32 # 0x5 : satp.MODE = sv32 : None : None
j segfault # 0x6 : Segfault, undefined test
j write_mxr_sum # 0x7 : write sstatus.[19:18] = MXR, SUM bits : None : None
j goto_m_mode # 0x8 : go to mahcine mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_s_mode # 0x9 : go to supervisor mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_u_mode # 0xA : go to user mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j segfault # 0xB : Segfault, undefined test
j segfault # 0xC : Segfault, undefined test
j write_pmpcfg_0 # 0xD : Write one of the pmpcfg csr's : mstatuses?, 0xD : readback of pmpcfg value
j write_pmpaddr_0 # 0xE : Write one of the pmpaddr csr's : None : readback of pmpaddr value
j segfault # 0xF : Segfault, undefined test
j segfault # 0x10 : Segfault, undefined test
j segfault # 0x11 : Segfault, undefined test
j write16_test # 0x12 : Write 16 bits to address : 0xf : None
j write08_test # 0x13 : Write 8 bits to address : 0xf : None
j segfault # 0x14 : Segfault, undefined test
j read16_test # 0x15 : Read 16 bits from address : 0xd, 0xbad : readvalue in hex
j read08_test # 0x16 : Read 8 bits from address : 0xd, 0xbad : readvalue in hex
write32_test: write32_test:
# address to write in x28, word value in x29 # address to write in x28, word value in x29

View File

@ -44,126 +44,126 @@
# test 12.3.1.1.1 write page tables / entries to phyiscal memory # test 12.3.1.1.1 write page tables / entries to phyiscal memory
# sv39 page table (See Figure 12.12***): # sv39 page table (See Figure 12.12***):
# Level 2 page table, situated at 0x8000D000 # Level 2 page table, situated at 0x8000D000
.8byte 0x000000008000D000, 0x0000000020004C01, 0x0 # points to level 1 page table A .8byte 0x000000008000D000, 0x0000000020004C01, write64_test# points to level 1 page table A
.8byte 0x000000008000D008, 0x0000000020005001, 0x0 # points to level 1 page table B #*** replacing all the pointers DAU bits with 0. .8byte 0x000000008000D008, 0x0000000020005001, write64_test# points to level 1 page table B #*** replacing all the pointers DAU bits with 0.
.8byte 0x000000008000D010, 0x00000000200000CF, 0x0 # Vaddr 0x8000_0000, Paddr 0x80000000: aligned gigapage (program and data memory) .8byte 0x000000008000D010, 0x00000000200000CF, write64_test# Vaddr 0x8000_0000, Paddr 0x80000000: aligned gigapage (program and data memory)
.8byte 0x000000008000D018, 0x00004000004000C7, 0x0 # Vaddr 0xC000_0000: misaligned gigapage .8byte 0x000000008000D018, 0x00004000004000C7, write64_test# Vaddr 0xC000_0000: misaligned gigapage
.8byte 0x000000008000DFF8, 0x0000000020005401, 0x0 # points to level 1 page table C .8byte 0x000000008000DFF8, 0x0000000020005401, write64_test # points to level 1 page table C
# Level 1 page table A # Level 1 page table A
.8byte 0x0000000080013000, 0x0000000020006001, 0x0 # points to level 0 page table A .8byte 0x0000000080013000, 0x0000000020006001, write64_test# points to level 0 page table A
# Level 1 page table B # Level 1 page table B
.8byte 0x0000000080014000, 0x00000000200000CB, 0x0 # Vaddr 0x4000_0000, Paddr 0x80000000: aligned megapage, W=0, used for execution tests .8byte 0x0000000080014000, 0x00000000200000CB, write64_test# Vaddr 0x4000_0000, Paddr 0x80000000: aligned megapage, W=0, used for execution tests
.8byte 0x0000000080014008, 0x00000400000080C3, 0x0 # Vaddr 0x4020_0000: misaligned megapage .8byte 0x0000000080014008, 0x00000400000080C3, write64_test# Vaddr 0x4020_0000: misaligned megapage
.8byte 0x0000000080014010, 0x00000000200000DF, 0x0 # Vaddr 0x4040_0000, Paddr 0x80000000: aligned megapage, aliased with program, U=1 .8byte 0x0000000080014010, 0x00000000200000DF, write64_test# Vaddr 0x4040_0000, Paddr 0x80000000: aligned megapage, aliased with program, U=1
.8byte 0x0000000080014018, 0x00000000210800C9, 0x0 # Vaddr 0x4060_0000, Paddr 0x84200000: R=0, reads should fault .8byte 0x0000000080014018, 0x00000000210800C9, write64_test# Vaddr 0x4060_0000, Paddr 0x84200000: R=0, reads should fault
# Level 1 page table C # Level 1 page table C
.8byte 0x0000000080015FF8, 0x0000000020005801, 0x0 # points to level 0 page table B .8byte 0x0000000080015FF8, 0x0000000020005801, write64_test# points to level 0 page table B
# Level 0 page table A # Level 0 page table A
.8byte 0x0000000080018000, 0x00000000200070D1, 0x0 # Vaddr 0x0000: bad PTE points to level -1 table .8byte 0x0000000080018000, 0x00000000200070D1, write64_test# Vaddr 0x0000: bad PTE points to level -1 table
.8byte 0x0000000080018008, 0x00000000200800DF, 0x0 # Vaddr 0x1000, Paddr = 0x80200000: aligned kilopage .8byte 0x0000000080018008, 0x00000000200800DF, write64_test# Vaddr 0x1000, Paddr = 0x80200000: aligned kilopage
.8byte 0x0000000080018010, 0x00000000200810D5, 0x0 # Vaddr 0x2000: bad PTE has W but not R .8byte 0x0000000080018010, 0x00000000200810D5, write64_test# Vaddr 0x2000: bad PTE has W but not R
.8byte 0x0000000080018018, 0x0000000020080817, 0x0 # Vaddr 0x3000 Paddr 0x80202000: A=0, should cause read fault .8byte 0x0000000080018018, 0x0000000020080817, write64_test# Vaddr 0x3000 Paddr 0x80202000: A=0, should cause read fault
.8byte 0x0000000080018020, 0x0000000020080C57, 0x0 # Vaddr 0x4000 Paddr 0x80203000: D=0, should cause write fault .8byte 0x0000000080018020, 0x0000000020080C57, write64_test# Vaddr 0x4000 Paddr 0x80203000: D=0, should cause write fault
.8byte 0x0000000080018028, 0x00000000200814C7, 0x0 # Vaddr 0x5000 Paddr 0x80205000: X=0, fetches should fault .8byte 0x0000000080018028, 0x00000000200814C7, write64_test# Vaddr 0x5000 Paddr 0x80205000: X=0, fetches should fault
.8byte 0x0000000080018030, 0x00000000200814C0, 0x0 # Vaddr 0x6000: invalid page .8byte 0x0000000080018030, 0x00000000200814C0, write64_test# Vaddr 0x6000: invalid page
# Level 0 page table B # Level 0 page table B
.8byte 0x0000000080016FF8, 0x00000000200804CF, 0x0 # Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000 aligned kilopage .8byte 0x0000000080016FF8, 0x00000000200804CF, write64_test# Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000 aligned kilopage
# test 12.3.1.1.2 write values to Paddrs in each page # test 12.3.1.1.2 write values to Paddrs in each page
# each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments. # each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments.
# when a test is supposed to fault, nothing is written into where it'll be reading/executing since it shuold fault before getting there. # when a test is supposed to fault, nothing is written into where it'll be reading/executing since it shuold fault before getting there.
.8byte 0x80200AB0, 0x0000DEADBEEF0000, 0x0 # 12.3.1.1.4 .8byte 0x80200AB0, 0x0000DEADBEEF0000, write64_test# 12.3.1.1.4
.8byte 0x800FFAB8, 0x0880DEADBEEF0055, 0x0 # 12.3.1.1.4 .8byte 0x800FFAB8, 0x0880DEADBEEF0055, write64_test# 12.3.1.1.4
.8byte 0x80200AC0, 0x0990DEADBEEF0033, 0x0 # 12.3.1.3.2 .8byte 0x80200AC0, 0x0990DEADBEEF0033, write64_test# 12.3.1.3.2
.8byte 0x80203130, 0x0110DEADBEEF0077, 0x0 # 12.3.1.3.2 .8byte 0x80203130, 0x0110DEADBEEF0077, write64_test# 12.3.1.3.2
.8byte 0x80099000, 0x0000806711100393, 0x0 # 12.3.1.3.1 and 12.3.1.3.2 write executable code for "li x7, 0x111; ret" .8byte 0x80099000, 0x0000806711100393, write64_test# 12.3.1.3.1 and 12.3.1.3.2 write executable code for "li x7, 0x111; ret"
.8byte 0x80205AA0, 0x0000806711100393, 0x0 # 12.3.1.3.5 write same executable code .8byte 0x80205AA0, 0x0000806711100393, write64_test# 12.3.1.3.5 write same executable code
.8byte 0x80201888, 0x0220DEADBEEF0099, 0x0 # 12.3.1.1.4 .8byte 0x80201888, 0x0220DEADBEEF0099, write64_test# 12.3.1.1.4
.8byte 0x84212348, 0x0330DEADBEEF0440, 0x0 # 12.3.1.3.3 .8byte 0x84212348, 0x0330DEADBEEF0440, write64_test# 12.3.1.3.3
.8byte 0x80203AA0, 0x0440DEADBEEF0BB0, 0x0 # 12.3.1.3.7 .8byte 0x80203AA0, 0x0440DEADBEEF0BB0, write64_test# 12.3.1.3.7
# test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test) # test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test)
.8byte 0x0, 0x0, 0x4 # satp.MODE = baremetal / no translation. .8byte 0x0, 0x0, goto_baremetal# satp.MODE = baremetal / no translation.
.8byte 0x0, 0x0, 0x9 # change to S mode, 0xb written to output .8byte 0x0, 0x0, goto_s_mode # change to S mode, 0xb written to output
.8byte 0x80200AB0, 0x0000DEADBEEF0000, 0x1 .8byte 0x80200AB0, 0x0000DEADBEEF0000, read64_test
.8byte 0x800FFAB8, 0x0880DEADBEEF0055, 0x1 .8byte 0x800FFAB8, 0x0880DEADBEEF0055, read64_test
.8byte 0x80200AC0, 0x0990DEADBEEF0033, 0x1 .8byte 0x80200AC0, 0x0990DEADBEEF0033, read64_test
.8byte 0x80203130, 0x0110DEADBEEF0077, 0x1 .8byte 0x80203130, 0x0110DEADBEEF0077, read64_test
.8byte 0x80201888, 0x0220DEADBEEF0099, 0x1 .8byte 0x80201888, 0x0220DEADBEEF0099, read64_test
.8byte 0x84212348, 0x0330DEADBEEF0440, 0x1 .8byte 0x84212348, 0x0330DEADBEEF0440, read64_test
.8byte 0x80203AA0, 0x0440DEADBEEF0BB0, 0x1 .8byte 0x80203AA0, 0x0440DEADBEEF0BB0, read64_test
# test 12.3.1.1.4 check translation works in sv39, read the same values from previous tests, this time with Vaddrs # test 12.3.1.1.4 check translation works in sv39, read the same values from previous tests, this time with Vaddrs
.8byte 0x0, 0x0, 0x5 # satp.MODE = sv39, current VPN: gigapage at 0x80000000. Nothing written to output .8byte 0x0, 0x0, goto_sv39 # satp.MODE = sv39, current VPN: gigapage at 0x80000000. Nothing written to output
.8byte 0x80200AB0, 0x0000DEADBEEF0000, 0x1 # gigapage at Vaddr 0x80000000, Paddr 0x80000000 .8byte 0x80200AB0, 0x0000DEADBEEF0000, read64_test # gigapage at Vaddr 0x80000000, Paddr 0x80000000
.8byte 0x400FFAB8, 0x0880DEADBEEF0055, 0x1 # megapage at Vaddr 0x40400000, Paddr 0x80000000 .8byte 0x400FFAB8, 0x0880DEADBEEF0055, read64_test # megapage at Vaddr 0x40400000, Paddr 0x80000000
.8byte 0xFFFFFFFFFFFFF888, 0x0220DEADBEEF0099, 0x1 # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000 .8byte 0xFFFFFFFFFFFFF888, 0x0220DEADBEEF0099, read64_test # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000
# =========== test 12.3.1.2 page fault tests =========== # =========== test 12.3.1.2 page fault tests ===========
# test 12.3.1.2.1 load page fault if upper bits of Vaddr are not the same # test 12.3.1.2.1 load page fault if upper bits of Vaddr are not the same
.8byte 0x0010000080000AB0, 0x0, 0x1 # gigapage at Vaddr 0x80000000, Paddr 0x80000000, bad 1 in upper bits .8byte 0x0010000080000AB0, 0x0, read64_test# gigapage at Vaddr 0x80000000, Paddr 0x80000000, bad 1 in upper bits
.8byte 0xFF0FFFFFFFFFF888, 0x0, 0x1 # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000, bad 0000 in upper bits .8byte 0xFF0FFFFFFFFFF888, 0x0, read64_test# kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000, bad 0000 in upper bits
# test 12.3.1.2.2 load page fault when reading an address where the valid flag is zero # test 12.3.1.2.2 load page fault when reading an address where the valid flag is zero
.8byte 0x6000, 0x0, 0x1 .8byte 0x6000, 0x0, read64_test
# test 12.3.1.2.3 store page fault if PTE has W and ~R flags set # test 12.3.1.2.3 store page fault if PTE has W and ~R flags set
.8byte 0x2000, 0x0, 0x0 .8byte 0x2000, 0x0, write64_test
# test 12.3.1.2.4 Fault if last level PTE is a pointer # test 12.3.1.2.4 Fault if last level PTE is a pointer
.8byte 0x0020, 0x0, 0x1 .8byte 0x0020, 0x0, read64_test
# test 12.3.1.2.5 load page fault on misaligned pages # test 12.3.1.2.5 load page fault on misaligned pages
.8byte 0xC0000000, 0x0, 0x1 # misaligned gigapage .8byte 0xC0000000, 0x0, read64_test# misaligned gigapage
.8byte 0x40200000, 0x0, 0x1 # misaligned megapage .8byte 0x40200000, 0x0, read64_test# misaligned megapage
# =========== test 12.3.1.3 PTE Protection flags =========== # =========== test 12.3.1.3 PTE Protection flags ===========
# test 12.3.1.3.1 User flag == 0 # test 12.3.1.3.1 User flag == 0
# *** reads on pages with U=0 already tested in 12.3.1.1.4 # *** reads on pages with U=0 already tested in 12.3.1.1.4
.8byte 0x40099000, 0x111, 0x2 # execute success when U=0, priv=S .8byte 0x40099000, 0x111, executable_test # execute success when U=0, priv=S
.8byte 0x40400000, 0x2, 0xA # go to U mode, return to megapage at 0x40400000 where U = 1. 0x9 written to output .8byte 0x40400000, 0x2, goto_u_mode # go to U mode, return to megapage at 0x40400000 where U = 1. 0x9 written to output
.8byte 0xFFFFFFFFFFFFFC80, 0x0880DEADBEEF0550, 0x1 # load page fault when U=0, priv=U .8byte 0xFFFFFFFFFFFFFC80, 0x0880DEADBEEF0550, read64_test # load page fault when U=0, priv=U
.8byte 0x40099000, 0xbad, 0x2 # execute fault when U=0, priv=U .8byte 0x40099000, 0xbad, executable_test # execute fault when U=0, priv=U
# test 12.3.1.3.2 User flag == 1 # test 12.3.1.3.2 User flag == 1
.8byte 0x1AC0, 0x0990DEADBEEF0033, 0x1 # read success when U=1, priv=U .8byte 0x1AC0, 0x0990DEADBEEF0033, read64_test # read success when U=1, priv=U
.8byte 0x80000000, 0x1, 0x9 # go back to S mode, return to gigapage at 0x80000000 where U = 0. 0x8 written to output .8byte 0x80000000, 0x1, goto_s_mode # go back to S mode, return to gigapage at 0x80000000 where U = 0. 0x8 written to output
.8byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11 .8byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11
.8byte 0x4130, 0x0110DEADBEEF0077, 0x1 # read success when U=1, priv=S, sstatus.SUM=1 .8byte 0x4130, 0x0110DEADBEEF0077, read64_test # read success when U=1, priv=S, sstatus.SUM=1
.8byte 0x40499000, 0xbad, 0x2 # instr page fault when U=1, priv=S (with any sstatus.SUM) .8byte 0x40499000, 0xbad, executable_test # instr page fault when U=1, priv=S (with any sstatus.SUM)
.8byte 0x0, 0x2, 0x7 # set sstatus.[MXR, SUM] = 10. .8byte 0x0, 0x2, write_mxr_sum # set sstatus.[MXR, SUM] = 10.
.8byte 0x1AC0, 0x0990DEADBEEF0033, 0x1 # load page fault when U-1, priv=S, sstatus.SUM=0 .8byte 0x1AC0, 0x0990DEADBEEF0033, read64_test # load page fault when U-1, priv=S, sstatus.SUM=0
# test 12.3.1.3.3 Read flag # test 12.3.1.3.3 Read flag
# *** reads on pages with R=1 already tested in 12.3.1.1.4 # *** reads on pages with R=1 already tested in 12.3.1.1.4
.8byte 0x0, 0x1, 0x7 # set sstatus.[MXR, SUM] = 01. .8byte 0x0, 0x1, write_mxr_sum # set sstatus.[MXR, SUM] = 01.
.8byte 0x40612348, 0x0330DEADBEEF0440, 0x1 # load page fault when R=0, sstatus.MXR=0 .8byte 0x40612348, 0x0330DEADBEEF0440, read64_test # load page fault when R=0, sstatus.MXR=0
.8byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11. .8byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11.
.8byte 0x40612348, 0x0330DEADBEEF0440, 0x1 # read success when MXR=1, X=1 .8byte 0x40612348, 0x0330DEADBEEF0440, read64_test # read success when MXR=1, X=1
# test 12.3.1.3.4 Write flag # test 12.3.1.3.4 Write flag
.8byte 0x80AAAAA0, 0x0440DEADBEEF0110, 0x0 # write success when W=1 .8byte 0x80AAAAA0, 0x0440DEADBEEF0110, write64_test# write success when W=1
.8byte 0x80AAAAA0, 0x0440DEADBEEF0110, 0x1 # check write success by reading the same address .8byte 0x80AAAAA0, 0x0440DEADBEEF0110, read64_test# check write success by reading the same address
.8byte 0x40000000, 0x0220DEADBEEF0BB0, 0x0 # store page fault when W=0 .8byte 0x40000000, 0x0220DEADBEEF0BB0, write64_test# store page fault when W=0
# test 12.3.1.3.5 eXecute flag # test 12.3.1.3.5 eXecute flag
# *** fetches on pages with X = 1 already tested in 12.3.1.3.1 # *** fetches on pages with X = 1 already tested in 12.3.1.3.1
.8byte 0x5AA0, 0x1, 0x2 # instr page fault when X=0 .8byte 0x5AA0, 0x1, executable_test # instr page fault when X=0
# test 12.3.1.3.6 Accessed flag == 0 # test 12.3.1.3.6 Accessed flag == 0
.8byte 0x36D0, 0x0990DEADBEEF0770, 0x0 # store page fault when A=0 .8byte 0x36D0, 0x0990DEADBEEF0770, write64_test# store page fault when A=0
.8byte 0x3AB8, 0x0990DEADBEEF0990, 0x1 # load page fault when A=0 .8byte 0x3AB8, 0x0990DEADBEEF0990, read64_test# load page fault when A=0
# test 12.3.1.3.7 Dirty flag == 0 # test 12.3.1.3.7 Dirty flag == 0
.8byte 0x4658, 0x0440DEADBEEF0AA0, 0x0 # store page fault when D=0 .8byte 0x4658, 0x0440DEADBEEF0AA0, write64_test# store page fault when D=0
.8byte 0x4AA0, 0x0440DEADBEEF0BB0, 0x1 # read success when D=0 .8byte 0x4AA0, 0x0440DEADBEEF0BB0, read64_test# read success when D=0
# terminate tests # terminate tests
.8byte 0x0, 0x0, 0x3 # brings us back into machine mode with a final ecall, writing 0x9 to the output. .8byte 0x0, 0x0, terminate_test # brings us back into machine mode with a final ecall, writing 0x9 to the output.

View File

@ -46,136 +46,136 @@
# test 12.3.1.1.1 write page tables / entries to phyiscal memory # test 12.3.1.1.1 write page tables / entries to phyiscal memory
# sv48 page table (See Figure 12.12***): # sv48 page table (See Figure 12.12***):
# Level 3 page table, situated at 0x8000D000 # Level 3 page table, situated at 0x8000D000
.8byte 0x000000008000D000, 0x0000000020004C01, 0x0 # points to level 2 page table A .8byte 0x000000008000D000, 0x0000000020004C01, write64_test # points to level 2 page table A
.8byte 0x000000008000D008, 0x0000000020005001, 0x0 # points to level 2 page table B # Changing DAU bits of each pointer to zero .8byte 0x000000008000D008, 0x0000000020005001, write64_test # points to level 2 page table B # Changing DAU bits of each pointer to zero
.8byte 0x000000008000D010, 0x00000000000000C7, 0x0 # Vaddr 0x010000000000, Paddr 0x00000000: aligned terapage .8byte 0x000000008000D010, 0x00000000000000C7, write64_test # Vaddr 0x010000000000, Paddr 0x00000000: aligned terapage
.8byte 0x000000008000D018, 0x00004000004000C7, 0x0 # Vaddr 0x018000000000, misaligned terapage .8byte 0x000000008000D018, 0x00004000004000C7, write64_test # Vaddr 0x018000000000, misaligned terapage
.8byte 0x000000008000DFF8, 0x0000000020005401, 0x0 # points to level 2 page table C .8byte 0x000000008000DFF8, 0x0000000020005401, write64_test # points to level 2 page table C
# Level 2 page table A # Level 2 page table A
.8byte 0x0000000080013010, 0x0000000020006001, 0x0 # points to level 1 page table A .8byte 0x0000000080013010, 0x0000000020006001, write64_test # points to level 1 page table A
# Level 2 page table B # Level 2 page table B
.8byte 0x0000000080014000, 0x00000000200000CB, 0x0 # Vaddr 0x008000000000, Paddr 0x80000000: aligned gigapage used for execution tests .8byte 0x0000000080014000, 0x00000000200000CB, write64_test # Vaddr 0x008000000000, Paddr 0x80000000: aligned gigapage used for execution tests
.8byte 0x0000000080014008, 0x00000000200000DF, 0x0 # Vaddr 0x008040000000, Paddr 0x80000000: aligned gigapage (aliased with data and instr memory) U bit set. .8byte 0x0000000080014008, 0x00000000200000DF, write64_test # Vaddr 0x008040000000, Paddr 0x80000000: aligned gigapage (aliased with data and instr memory) U bit set.
.8byte 0x0000000080014010, 0x00000400080000C3, 0x0 # Vaddr 0x008080000000, misaligned gigapage .8byte 0x0000000080014010, 0x00000400080000C3, write64_test # Vaddr 0x008080000000, misaligned gigapage
# Level 2 page table C # Level 2 page table C
.8byte 0x0000000080015FF8, 0x0000000020005801, 0x0 # points to level 1 page table B .8byte 0x0000000080015FF8, 0x0000000020005801, write64_test # points to level 1 page table B
# Level 1 page table A # Level 1 page table A
.8byte 0x0000000080018000, 0x00000000200000CF, 0x0 # Vaddr 0x80000000, Paddr 0x80000000: aligned megapage (data and instr memory) .8byte 0x0000000080018000, 0x00000000200000CF, write64_test # Vaddr 0x80000000, Paddr 0x80000000: aligned megapage (data and instr memory)
.8byte 0x0000000080018008, 0x0000000020006401, 0x0 # points to level 0 page table A .8byte 0x0000000080018008, 0x0000000020006401, write64_test # points to level 0 page table A
.8byte 0x0000000080018010, 0x000000C0000400CF, 0x0 # Vaddr 0x80400000, misaligned megapage .8byte 0x0000000080018010, 0x000000C0000400CF, write64_test # Vaddr 0x80400000, misaligned megapage
.8byte 0x0000000080018018, 0x00000000214800C9, 0x0 # Vaddr 0x80600000, Paddr 0x85200000: aligned megapage, R=0 .8byte 0x0000000080018018, 0x00000000214800C9, write64_test # Vaddr 0x80600000, Paddr 0x85200000: aligned megapage, R=0
# Level 1 page table B # Level 1 page table B
.8byte 0x0000000080016FF8, 0x0000000020006801, 0x0 # points to level 0 page table B .8byte 0x0000000080016FF8, 0x0000000020006801, write64_test # points to level 0 page table B
# Level 0 page table A # Level 0 page table A
.8byte 0x0000000080019000, 0x00000000200070D1, 0x0 # Vaddr 0x80200000, Paddr 0x8001C000: bad PTE points to level -1 table .8byte 0x0000000080019000, 0x00000000200070D1, write64_test # Vaddr 0x80200000, Paddr 0x8001C000: bad PTE points to level -1 table
.8byte 0x0000000080019008, 0x00000000200800DF, 0x0 # Vaddr 0x80201000, Paddr 0x80200000: aligned kilopage .8byte 0x0000000080019008, 0x00000000200800DF, write64_test # Vaddr 0x80201000, Paddr 0x80200000: aligned kilopage
.8byte 0x0000000080019010, 0x00000000200810DF, 0x0 # Vaddr 0x80202000, Paddr 0x80204000: bad PTE has W but not R .8byte 0x0000000080019010, 0x00000000200810DF, write64_test # Vaddr 0x80202000, Paddr 0x80204000: bad PTE has W but not R
.8byte 0x0000000080019018, 0x0000000020080817, 0x0 # Vaddr 0x80203000, Paddr 0x80202000: A=0, should cause read fault .8byte 0x0000000080019018, 0x0000000020080817, write64_test # Vaddr 0x80203000, Paddr 0x80202000: A=0, should cause read fault
.8byte 0x0000000080019020, 0x0000000020080C57, 0x0 # Vaddr 0x80204000, Paddr 0x80203000: D=0, should cause write fault .8byte 0x0000000080019020, 0x0000000020080C57, write64_test # Vaddr 0x80204000, Paddr 0x80203000: D=0, should cause write fault
.8byte 0x0000000080019028, 0x0000000020333000, 0x0 # Vaddr 0x80205000, Paddr 0x80CCC000, invalid page. .8byte 0x0000000080019028, 0x0000000020333000, write64_test # Vaddr 0x80205000, Paddr 0x80CCC000, invalid page.
# Level 0 page table B # Level 0 page table B
.8byte 0x000000008001AFF8, 0x00000000200804CF, 0x0 # Vaddr 0xFFFFFFFFF000, Paddr 0x80201000: aligned kilopage .8byte 0x000000008001AFF8, 0x00000000200804CF, write64_test # Vaddr 0xFFFFFFFFF000, Paddr 0x80201000: aligned kilopage
# test 12.3.1.1.2 write values to Paddrs in each page # test 12.3.1.1.2 write values to Paddrs in each page
# each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments. # each of these values is used for 12.3.1.1.3 and some other tests, specified in the comments.
# when a test is supposed to fault, nothing is written into where it'll be reading/executing since it should fault before getting there. # when a test is supposed to fault, nothing is written into where it'll be reading/executing since it should fault before getting there.
.8byte 0x82777778, 0x0EE0DEADBEEF0CC0, 0x0 # 12.3.1.1.4 terapage .8byte 0x82777778, 0x0EE0DEADBEEF0CC0, write64_test # 12.3.1.1.4 terapage
.8byte 0x85BC0AB0, 0x0000DEADBEEF0000, 0x0 # 12.3.1.1.4 gigapage .8byte 0x85BC0AB0, 0x0000DEADBEEF0000, write64_test # 12.3.1.1.4 gigapage
.8byte 0x800F0AB8, 0x0880DEADBEEF0055, 0x0 # 12.3.1.1.4 megapage .8byte 0x800F0AB8, 0x0880DEADBEEF0055, write64_test # 12.3.1.1.4 megapage
.8byte 0x80201888, 0x0220DEADBEEF0099, 0x0 # 12.3.1.1.4 kilopage .8byte 0x80201888, 0x0220DEADBEEF0099, write64_test # 12.3.1.1.4 kilopage
.8byte 0x80099000, 0x0000806711100393, 0x0 # 12.3.1.3.1 write executable code for "li x7, 0x111; ret" .8byte 0x80099000, 0x0000806711100393, write64_test # 12.3.1.3.1 write executable code for "li x7, 0x111; ret"
.8byte 0x80200400, 0x0000806711100393, 0x0 # 12.3.1.3.2 write same executable code .8byte 0x80200400, 0x0000806711100393, write64_test # 12.3.1.3.2 write same executable code
.8byte 0x80200AC0, 0x0990DEADBEEF0033, 0x0 # 12.3.1.3.2 .8byte 0x80200AC0, 0x0990DEADBEEF0033, write64_test # 12.3.1.3.2
.8byte 0x80200130, 0x0110DEADBEEF0077, 0x0 # 12.3.1.3.2 .8byte 0x80200130, 0x0110DEADBEEF0077, write64_test # 12.3.1.3.2
.8byte 0x85212348, 0x0330DEADBEEF0440, 0x0 # 12.3.1.3.3 .8byte 0x85212348, 0x0330DEADBEEF0440, write64_test # 12.3.1.3.3
.8byte 0x88888000, 0x0000806711100393, 0x0 # 12.3.1.3.5 write same executable code .8byte 0x88888000, 0x0000806711100393, write64_test # 12.3.1.3.5 write same executable code
.8byte 0x80203AA0, 0x0440DEADBEEF0BB0, 0x0 # 12.3.1.3.7 .8byte 0x80203AA0, 0x0440DEADBEEF0BB0, write64_test # 12.3.1.3.7
# test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test) # test 12.3.1.1.3 read values back from Paddrs without translation (this also verifies the previous test)
.8byte 0x0, 0x0, 0x4 # satp.MODE = baremetal / no translation. .8byte 0x0, 0x0, goto_baremetal # satp.MODE = baremetal / no translation.
.8byte 0x0, 0x0, 0x9 # change to S mode, 0xb written to output .8byte 0x0, 0x0, goto_s_mode # change to S mode, 0xb written to output
.8byte 0x82777778, 0x0EE0DEADBEEF0CC0, 0x1 .8byte 0x82777778, 0x0EE0DEADBEEF0CC0, read64_test
.8byte 0x85BC0AB0, 0x0000DEADBEEF0000, 0x1 .8byte 0x85BC0AB0, 0x0000DEADBEEF0000, read64_test
.8byte 0x800F0AB8, 0x0880DEADBEEF0055, 0x1 .8byte 0x800F0AB8, 0x0880DEADBEEF0055, read64_test
.8byte 0x80200AC0, 0x0990DEADBEEF0033, 0x1 .8byte 0x80200AC0, 0x0990DEADBEEF0033, read64_test
.8byte 0x80200130, 0x0110DEADBEEF0077, 0x1 .8byte 0x80200130, 0x0110DEADBEEF0077, read64_test
.8byte 0x80201888, 0x0220DEADBEEF0099, 0x1 .8byte 0x80201888, 0x0220DEADBEEF0099, read64_test
.8byte 0x85212348, 0x0330DEADBEEF0440, 0x1 .8byte 0x85212348, 0x0330DEADBEEF0440, read64_test
.8byte 0x80203AA0, 0x0440DEADBEEF0BB0, 0x1 .8byte 0x80203AA0, 0x0440DEADBEEF0BB0, read64_test
# test 12.3.1.1.4 check translation works in sv48, read the same values from previous tests, this time with Vaddrs # test 12.3.1.1.4 check translation works in sv48, read the same values from previous tests, this time with Vaddrs
.8byte 0x0, 0x0, 0x6 # satp.MODE = sv48, current VPN: megapage at 0x80000000. Nothing written to output .8byte 0x0, 0x0, goto_sv48 # satp.MODE = sv48, current VPN: megapage at 0x80000000. Nothing written to output
.8byte 0x10082777778, 0x0EE0DEADBEEF0CC0, 0x1 # terapage at Vaddr 0x010000000000, Paddr 0x0 .8byte 0x10082777778, 0x0EE0DEADBEEF0CC0, read64_test # terapage at Vaddr 0x010000000000, Paddr 0x0
.8byte 0x8005BC0AB0, 0x0000DEADBEEF0000, 0x1 # gigapage at Vaddr 0x008000000000, Paddr 0x80000000 .8byte 0x8005BC0AB0, 0x0000DEADBEEF0000, read64_test # gigapage at Vaddr 0x008000000000, Paddr 0x80000000
.8byte 0x800F0AB8, 0x0880DEADBEEF0055, 0x1 # megapage at Vaddr 0x80000000, Paddr 0x80000000 .8byte 0x800F0AB8, 0x0880DEADBEEF0055, read64_test # megapage at Vaddr 0x80000000, Paddr 0x80000000
.8byte 0xFFFFFFFFFFFFF888, 0x0220DEADBEEF0099, 0x1 # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000 .8byte 0xFFFFFFFFFFFFF888, 0x0220DEADBEEF0099, read64_test # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000
# =========== test 12.3.1.2 page fault tests =========== # =========== test 12.3.1.2 page fault tests ===========
# test 12.3.1.2.1 page fault if upper bits of Vaddr are not the same # test 12.3.1.2.1 page fault if upper bits of Vaddr are not the same
.8byte 0x001000800ABC0AB0, 0x0, 0x1 # gigapage at Vaddr 0x008000000000, Paddr 0x80000000, bad 1 in upper bits .8byte 0x001000800ABC0AB0, 0x0, read64_test# gigapage at Vaddr 0x008000000000, Paddr 0x80000000, bad 1 in upper bits
.8byte 0xFF0FFFFFFFFFF888, 0x0, 0x1 # kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000, bad 0000 in upper bits .8byte 0xFF0FFFFFFFFFF888, 0x0, read64_test# kilopage at Vaddr 0xFFFFFFFFFFFFF000, Paddr 0x80201000, bad 0000 in upper bits
# test 12.3.1.2.2 read fault when reading an address where the valid flag is zero # test 12.3.1.2.2 read fault when reading an address where the valid flag is zero
.8byte 0x80205000, 0x0, 0x1 .8byte 0x80205000, 0x0, read64_test
# test 12.3.1.2.3 write fault if PTE has W and ~R flags set # test 12.3.1.2.3 write fault if PTE has W and ~R flags set
.8byte 0x80202000, 0x0, 0x0 .8byte 0x80202000, 0x0, write64_test
# test 12.3.1.2.4 Fault if last level PTE is a pointer # test 12.3.1.2.4 Fault if last level PTE is a pointer
.8byte 0x80200000, 0x0, 0x1 .8byte 0x80200000, 0x0, read64_test
# test 12.3.1.2.5 read fault on misaligned pages # test 12.3.1.2.5 read fault on misaligned pages
.8byte 0x18000000000, 0x0, 0x1 # misaligned terapage .8byte 0x18000000000, 0x0, read64_test # misaligned terapage
.8byte 0x8080000000, 0x0, 0x1 # misaligned gigapage .8byte 0x8080000000, 0x0, read64_test # misaligned gigapage
.8byte 0x80400000, 0x0, 0x1 # misaligned megapage .8byte 0x80400000, 0x0, read64_test # misaligned megapage
# =========== test 12.3.1.3 PTE Protection flags =========== # =========== test 12.3.1.3 PTE Protection flags ===========
# test 12.3.1.3.1 User flag == 0 # test 12.3.1.3.1 User flag == 0
# reads on pages with U=0 already tested in 12.3.1.1.4 # reads on pages with U=0 already tested in 12.3.1.1.4
.8byte 0x008000099000, 0x111, 0x2 # execute success when U=0, priv=S .8byte 0x008000099000, 0x111, executable_test # execute success when U=0, priv=S
.8byte 0x008040000000, 0x1, 0xA # go to U mode, return to gigapage at 0x008040000000 where PTE.U = 1. 0x9 written to output .8byte 0x008040000000, 0x1, goto_u_mode # go to U mode, return to gigapage at 0x008040000000 where PTE.U = 1. 0x9 written to output
.8byte 0xFFFFFFFFFFFFFC80, 0x0880DEADBEEF0550, 0x1 # read fault when U=0, priv=U .8byte 0xFFFFFFFFFFFFFC80, 0x0880DEADBEEF0550, read64_test # read fault when U=0, priv=U
.8byte 0x008000099000, 0xbad, 0x2 # execute fault when U=0, priv=U .8byte 0x008000099000, 0xbad, executable_test # execute fault when U=0, priv=U
# test 12.3.1.3.2 User flag == 1 # test 12.3.1.3.2 User flag == 1
.8byte 0x80201AC0, 0x0990DEADBEEF0033, 0x1 # read success when U=1, priv=U .8byte 0x80201AC0, 0x0990DEADBEEF0033, read64_test # read success when U=1, priv=U
.8byte 0x80000000, 0x2, 0x9 # go back to S mode, return to megapage at 0x80000000 where PTE.U = 0. 0x8 written to output .8byte 0x80000000, 0x2, goto_s_mode
.8byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11 .8byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11
.8byte 0x80201130, 0x0110DEADBEEF0077, 0x1 # read success when U=1, priv=S, sstatus.SUM=1 .8byte 0x80201130, 0x0110DEADBEEF0077, read64_test # read success when U=1, priv=S, sstatus.SUM=1
.8byte 0x80201400, 0xbad, 0x2 # execute fault when U=1, priv=S (with any sstatus.SUM) .8byte 0x80201400, 0xbad, executable_test # execute fault when U=1, priv=S (with any sstatus.SUM)
.8byte 0x0, 0x2, 0x7 # set sstatus.[MXR, SUM] = 10. .8byte 0x0, 0x2, write_mxr_sum # set sstatus.[MXR, SUM] = 10.
.8byte 0x80201AC0, 0x0990DEADBEEF0033, 0x1 # read fault when U=1, priv=S, sstatus.SUM=0 .8byte 0x80201AC0, 0x0990DEADBEEF0033, read64_test # read fault when U=1, priv=S, sstatus.SUM=0
# test 12.3.1.3.3 Read flag # test 12.3.1.3.3 Read flag
# reads on pages with R=1 already tested in 12.3.1.1.4 # reads on pages with R=1 already tested in 12.3.1.1.4
.8byte 0x0, 0x1, 0x7 # set sstatus.[MXR, SUM] = 01. .8byte 0x0, 0x1, write_mxr_sum # set sstatus.[MXR, SUM] = 01.
.8byte 0x80612348, 0x0330DEADBEEF0440, 0x1 # read fault when R=0, sstatus.MXR=0 .8byte 0x80612348, 0x0330DEADBEEF0440, read64_test # read fault when R=0, sstatus.MXR=0
.8byte 0x0, 0x3, 0x7 # set sstatus.[MXR, SUM] = 11. .8byte 0x0, 0x3, write_mxr_sum # set sstatus.[MXR, SUM] = 11.
.8byte 0x80612348, 0x0330DEADBEEF0440, 0x1 # read success when MXR=1, X=1 .8byte 0x80612348, 0x0330DEADBEEF0440, read64_test # read success when MXR=1, X=1
# test 12.3.1.3.4 Write flag # test 12.3.1.3.4 Write flag
.8byte 0x10080BCDED8, 0x0440DEADBEEF0110, 0x0 # write success when W=1 (corresponding Paddr = 0x80BCDED8) .8byte 0x10080BCDED8, 0x0440DEADBEEF0110, write64_test # write success when W=1 (corresponding Paddr = 0x80BCDED8)
.8byte 0x10080BCDED8, 0x0440DEADBEEF0110, 0x1 # check write success by reading value back .8byte 0x10080BCDED8, 0x0440DEADBEEF0110, read64_test # check write success by reading value back
.8byte 0x8000009E88, 0x0220DEADBEEF0BB0, 0x0 # write fault when W=0 .8byte 0x8000009E88, 0x0220DEADBEEF0BB0, write64_test # write fault when W=0
# test 12.3.1.3.5 eXecute flag # test 12.3.1.3.5 eXecute flag
# executes on pages with X = 1 already tested in 12.3.1.3.1 # executes on pages with X = 1 already tested in 12.3.1.3.1
.8byte 0x010088888000, 0x2, 0x2 # execute fault when X=0 .8byte 0x010088888000, 0x2, executable_test # execute fault when X=0
# test 12.3.1.3.6 Accessed flag == 0 # test 12.3.1.3.6 Accessed flag == 0
.8byte 0x802036D0, 0x0990DEADBEEF0770, 0x0 # write fault when A=0 .8byte 0x802036D0, 0x0990DEADBEEF0770, write64_test # write fault when A=0
.8byte 0x80203AB8, 0x0990DEADBEEF0990, 0x1 # read fault when A=0 .8byte 0x80203AB8, 0x0990DEADBEEF0990, read64_test# read fault when A=0
# test 12.3.1.3.7 Dirty flag == 0 # test 12.3.1.3.7 Dirty flag == 0
.8byte 0x80204658, 0x0440DEADBEEF0AA0, 0x0 # write fault when D=0 .8byte 0x80204658, 0x0440DEADBEEF0AA0, write64_test # write fault when D=0
.8byte 0x80204AA0, 0x0440DEADBEEF0BB0, 0x1 # read success when D=0 .8byte 0x80204AA0, 0x0440DEADBEEF0BB0, read64_test# read success when D=0
# terminate tests # terminate tests
.8byte 0x0, 0x0, 0x3 # brings us back into machine mode with a final ecall, writing 0x9 to the output. .8byte 0x0, 0x0, terminate_test # brings us back into machine mode with a final ecall, writing 0x9 to the output.

View File

@ -71,89 +71,89 @@
# ----------------- CLINT --------------------- # ----------------- CLINT ---------------------
# Use timecmp register as readable and writable section of the CLINT # Use timecmp register as readable and writable section of the CLINT
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B4, 0x0 # 64-bit write: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B4, write64_test # 64-bit write: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B4, 0x1 # 64-bit read: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B4, read64_test # 64-bit read: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B5, 0x11 # 32-bit write: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B5, write32_test # 32-bit write: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B5, 0x14 # 32-bit read: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B5, read32_test # 32-bit read: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B6, 0x12 # 16-bit write: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B6, write16_test # 16-bit write: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B6, 0x15 # 16-bit read: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B6, read16_test # 16-bit read: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B7, 0x13 # 08-bit write: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B7, write08_test # 08-bit write: success
.8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B7, 0x16 # 08-bit read: success .8byte CLINT_BASE + 0x4000, 0x0000DEADBEEF00B7, read08_test # 08-bit read: success
.8byte CLINT_BASE, 0xbad, 0x2 # execute: instruction access fault .8byte CLINT_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- PLIC --------------------- # ----------------- PLIC ---------------------
.8byte PLIC_BASE, 0x0000DEADBEEF00B8, 0x0 # 64-bit write: store access fault .8byte PLIC_BASE, 0x0000DEADBEEF00B8, write64_test # 64-bit write: store access fault
.8byte PLIC_BASE, 0x0000DEADBEEF00B8, 0x1 # 64-bit read: load access fault .8byte PLIC_BASE, 0x0000DEADBEEF00B8, read64_test # 64-bit read: load access fault
# Write 0x2 instead of wider value to plic address because the register width might change. # Write 0x2 instead of wider value to plic address because the register width might change.
.8byte PLIC_BASE + 0x2000, 0x2, 0x11 # 32-bit write: success .8byte PLIC_BASE + 0x2000, 0x2, write32_test # 32-bit write: success
.8byte PLIC_BASE + 0x2000, 0x2, 0x14 # 32-bit read: success .8byte PLIC_BASE + 0x2000, 0x2, read32_test # 32-bit read: success
.8byte PLIC_BASE, 0x0000DEADBEEF00BA, 0x12 # 16-bit write: store access fault .8byte PLIC_BASE, 0x0000DEADBEEF00BA, write16_test # 16-bit write: store access fault
.8byte PLIC_BASE, 0x0000DEADBEEF00BA, 0x15 # 16-bit read: load access fault .8byte PLIC_BASE, 0x0000DEADBEEF00BA, read16_test # 16-bit read: load access fault
.8byte PLIC_BASE, 0x0000DEADBEEF00BB, 0x13 # 08-bit write: store access fault .8byte PLIC_BASE, 0x0000DEADBEEF00BB, write08_test # 08-bit write: store access fault
.8byte PLIC_BASE, 0x0000DEADBEEF00BB, 0x16 # 08-bit read: load access fault .8byte PLIC_BASE, 0x0000DEADBEEF00BB, read08_test # 08-bit read: load access fault
.8byte PLIC_BASE, 0xbad, 0x2 # execute: instruction access fault .8byte PLIC_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- UART0 --------------------- # ----------------- UART0 ---------------------
.8byte UART_BASE, 0x0000DEADBEEF00BC, 0x0 # 64-bit write: store access fault .8byte UART_BASE, 0x0000DEADBEEF00BC, write64_test # 64-bit write: store access fault
.8byte UART_BASE, 0x0000DEADBEEF00BC, 0x1 # 64-bit read: load access fault .8byte UART_BASE, 0x0000DEADBEEF00BC, read64_test # 64-bit read: load access fault
.8byte UART_BASE, 0x0000DEADBEEF00BD, 0x11 # 32-bit write: store access fault .8byte UART_BASE, 0x0000DEADBEEF00BD, write32_test # 32-bit write: store access fault
.8byte UART_BASE, 0x0000DEADBEEF00BD, 0x14 # 32-bit read: load access fault .8byte UART_BASE, 0x0000DEADBEEF00BD, read32_test # 32-bit read: load access fault
.8byte UART_BASE, 0x0000DEADBEEF00BE, 0x12 # 16-bit write: store access fault .8byte UART_BASE, 0x0000DEADBEEF00BE, write16_test # 16-bit write: store access fault
.8byte UART_BASE, 0x0000DEADBEEF00BE, 0x15 # 16-bit read: load access fault .8byte UART_BASE, 0x0000DEADBEEF00BE, read16_test # 16-bit read: load access fault
# Different address for this test so that we write into a writable register in the uart. # Different address for this test so that we write into a writable register in the uart.
.8byte UART_BASE + 0x3, 0x0000DEADBEEF00BF, 0x13 # 08-bit write: success .8byte UART_BASE + 0x3, 0x0000DEADBEEF00BF, write08_test # 08-bit write: success
.8byte UART_BASE + 0x3, 0x0000DEADBEEF00BF, 0x16 # 08-bit read: success .8byte UART_BASE + 0x3, 0x0000DEADBEEF00BF, read08_test # 08-bit read: success
.8byte UART_BASE, 0xbad, 0x2 # execute: instruction access fault .8byte UART_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- GPIO --------------------- # ----------------- GPIO ---------------------
.8byte GPIO_BASE, 0x0000DEADBEEF00C0, 0x0 # 64-bit write: store access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C0, write64_test # 64-bit write: store access fault
.8byte GPIO_BASE, 0x0000DEADBEEF00C0, 0x1 # 64-bit read: load access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C0, read64_test # 64-bit read: load access fault
.8byte GPIO_BASE + 0x8, 0x0000DEADBEEF00C1, 0x11 # 32-bit write: success .8byte GPIO_BASE + 0x8, 0x0000DEADBEEF00C1, write32_test # 32-bit write: success
.8byte GPIO_BASE + 0x8, 0x0000DEADBEEF00C1, 0x14 # 32-bit read: success .8byte GPIO_BASE + 0x8, 0x0000DEADBEEF00C1, read32_test # 32-bit read: success
.8byte GPIO_BASE, 0x0000DEADBEEF00C2, 0x12 # 16-bit write: store access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C2, write16_test # 16-bit write: store access fault
.8byte GPIO_BASE, 0x0000DEADBEEF00C2, 0x15 # 16-bit read: load access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C2, read16_test # 16-bit read: load access fault
.8byte GPIO_BASE, 0x0000DEADBEEF00C3, 0x13 # 08-bit write: store access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C3, write08_test # 08-bit write: store access fault
.8byte GPIO_BASE, 0x0000DEADBEEF00C3, 0x16 # 08-bit read: load access fault .8byte GPIO_BASE, 0x0000DEADBEEF00C3, read08_test # 08-bit read: load access fault
.8byte GPIO_BASE, 0xbad, 0x2 # execute: instruction access fault .8byte GPIO_BASE, 0xbad, executable_test# execute: instruction access fault
# ----------------- Inaccessible --------------------- # ----------------- Inaccessible ---------------------
# show that load, store, and jalr cause faults in regions not defined by PMAs. # show that load, store, and jalr cause faults in regions not defined by PMAs.
# Tests 'random' place in unimplemented memory # Tests 'random' place in unimplemented memory
.8byte 0x40000000, 0x0000DEADBEEF00C7, 0x0 # 64-bit write: store access fault .8byte 0x40000000, 0x0000DEADBEEF00C7, write64_test # 64-bit write: store access fault
.8byte 0x40000000, 0x0000DEADBEEF00C7, 0x1 # 64-bit read: load access fault .8byte 0x40000000, 0x0000DEADBEEF00C7, read64_test # 64-bit read: load access fault
.8byte 0x40000000, 0x111, 0x2 # execute: instruction access fault .8byte 0x40000000, 0x111, executable_test # execute: instruction access fault
# Tests just past the end of each peripheral # Tests just past the end of each peripheral
.8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x0000DEADBEEF00C8, 0x0 # 64-bit write: store access fault .8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x0000DEADBEEF00C8, write64_test # 64-bit write: store access fault
.8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x0000DEADBEEF00C8, 0x1 # 64-bit read: load access fault .8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x0000DEADBEEF00C8, read64_test # 64-bit read: load access fault
.8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x111, 0x2 # execute: instruction access fault .8byte (BOOTROM_BASE+BOOTROM_RANGE+1), 0x111, executable_test # execute: instruction access fault
.8byte (CLINT_BASE+CLINT_RANGE+1), 0x0000DEADBEEF00C9, 0x0 # 64-bit write: store access fault .8byte (CLINT_BASE+CLINT_RANGE+1), 0x0000DEADBEEF00C9, write64_test # 64-bit write: store access fault
.8byte (CLINT_BASE+CLINT_RANGE+1), 0x0000DEADBEEF00C9, 0x1 # 64-bit read: load access fault .8byte (CLINT_BASE+CLINT_RANGE+1), 0x0000DEADBEEF00C9, read64_test # 64-bit read: load access fault
.8byte (CLINT_BASE+CLINT_RANGE+1), 0x111, 0x2 # execute: instruction access fault .8byte (CLINT_BASE+CLINT_RANGE+1), 0x111, executable_test # execute: instruction access fault
.8byte (PLIC_BASE+PLIC_RANGE+1), 0x0000DEADBEEF00CA, 0x11 # 32-bit write: store access fault .8byte (PLIC_BASE+PLIC_RANGE+1), 0x0000DEADBEEF00CA, write32_test # 32-bit write: store access fault
.8byte (PLIC_BASE+PLIC_RANGE+1), 0x0000DEADBEEF00CA, 0x14 # 32-bit read: load access fault .8byte (PLIC_BASE+PLIC_RANGE+1), 0x0000DEADBEEF00CA, read32_test # 32-bit read: load access fault
.8byte (PLIC_BASE+PLIC_RANGE+1), 0x111, 0x2 # execute: instruction access fault .8byte (PLIC_BASE+PLIC_RANGE+1), 0x111, executable_test # execute: instruction access fault
.8byte (UART_BASE+UART_RANGE+1), 0x0000DEADBEEF00CB, 0x13 # 08-bit write: store access fault .8byte (UART_BASE+UART_RANGE+1), 0x0000DEADBEEF00CB, write08_test # 08-bit write: store access fault
.8byte (UART_BASE+UART_RANGE+1), 0x0000DEADBEEF00CB, 0x16 # 08-bit read: load access fault .8byte (UART_BASE+UART_RANGE+1), 0x0000DEADBEEF00CB, read08_test # 08-bit read: load access fault
.8byte (UART_BASE+UART_RANGE+1), 0x111, 0x2 # execute: instruction access fault .8byte (UART_BASE+UART_RANGE+1), 0x111, executable_test # execute: instruction access fault
.8byte (GPIO_BASE+GPIO_RANGE+1), 0x0000DEADBEEF00CC, 0x11 # 32-bit write: store access fault .8byte (GPIO_BASE+GPIO_RANGE+1), 0x0000DEADBEEF00CC, write32_test # 32-bit write: store access fault
.8byte (GPIO_BASE+GPIO_RANGE+1), 0x0000DEADBEEF00CC, 0x14 # 32-bit read: load access fault .8byte (GPIO_BASE+GPIO_RANGE+1), 0x0000DEADBEEF00CC, read32_test # 32-bit read: load access fault
.8byte (GPIO_BASE+GPIO_RANGE+1), 0x111, 0x2 # execute: instruction access fault .8byte (GPIO_BASE+GPIO_RANGE+1), 0x111, executable_test # execute: instruction access fault
.8byte 0x0, 0x0, 0x3 # terminate tests .8byte 0x0, 0x0, terminate_test# terminate tests

View File

@ -45,65 +45,65 @@
# Test 12.3.2.2.1 Config: Write known values and set PMP config according to table 12.4 in the *** riscv book, copied below # Test 12.3.2.2.1 Config: Write known values and set PMP config according to table 12.4 in the *** riscv book, copied below
# write pmpaddr regs. Each of these should output the value of the pmpaddr after being written. # write pmpaddr regs. Each of these should output the value of the pmpaddr after being written.
# | Reg | pmpaddr | pmpcfg | L | A | X | W | R | Comments | # *** change the pmpcfg and addr commands to the right number # | Reg | pmpaddr | pmpcfg | L | A | X | W | R | Comments |
.8byte 0x0, 0x0FFFFFFF, 0xE # | 0 | 0x0FFFFFFF | 1F | 0 | NAPOT | 0 | 1 | 1 | I/O 00000000-7FFFFFFF RW | .8byte 0x0, 0x0FFFFFFF, write_pmpaddr_0 # | 0 | 0x0FFFFFFF | 1F | 0 | NAPOT | 0 | 1 | 1 | I/O 00000000-7FFFFFFF RW |
.8byte 0x1, 0x20040000, 0xE # | 1 | 0x20040000 | 00 | 0 | OFF | 0 | 0 | 0 | | .8byte 0x1, 0x20040000, write_pmpaddr_1 # | 1 | 0x20040000 | 00 | 0 | OFF | 0 | 0 | 0 | |
.8byte 0x2, 0x2004003F, 0xE # | 2 | 0x2004003F | 09 | 0 | TOR | 0 | 0 | 1 | 80100000-801000FF R | .8byte 0x2, 0x2004003F, write_pmpaddr_2 # | 2 | 0x2004003F | 09 | 0 | TOR | 0 | 0 | 1 | 80100000-801000FF R |
.8byte 0x3, 0x20040080, 0xE # | 3 | 0x20040080 | 00 | 0 | OFF | 0 | 0 | 0 | | .8byte 0x3, 0x20040080, write_pmpaddr_3 # | 3 | 0x20040080 | 00 | 0 | OFF | 0 | 0 | 0 | |
.8byte 0x4, 0x20040084, 0xE # | 4 | 0x20040084 | 0C | 0 | TOR | 1 | 0 | 0 | 80100200-80100210 X | .8byte 0x4, 0x20040084, write_pmpaddr_4 # | 4 | 0x20040084 | 0C | 0 | TOR | 1 | 0 | 0 | 80100200-80100210 X |
.8byte 0x5, 0x200400C0, 0xE # | 5 | 0x200400C0 | 90 | 1 | NA4 | 0 | 0 | 0 | 80100300-80100303 locked out | .8byte 0x5, 0x200400C0, write_pmpaddr_5 # | 5 | 0x200400C0 | 90 | 1 | NA4 | 0 | 0 | 0 | 80100300-80100303 locked out |
.8byte 0x6, 0x2004013F, 0xE # | 6 | 0x2004013F | 18 | 0 | NAPOT | 0 | 0 | 0 | 80100400-801004FF no access | .8byte 0x6, 0x2004013F, write_pmpaddr_6 # | 6 | 0x2004013F | 18 | 0 | NAPOT | 0 | 0 | 0 | 80100400-801004FF no access |
# Pmpaddr 7-14 are all zeroed out in this test, so they don't need writes. # Pmpaddr 7-14 are all zeroed out in this test, so they don't need writes.
.8byte 0xF, 0x2FFFFFFF, 0xE # | 15 | 0x2FFFFFFF | 1F | 0 | NAPOT | 1 | 1 | 1 | Main mem 80000000-FFFFFFFF RWX| .8byte 0xF, 0x2FFFFFFF, write_pmpaddr_15 # | 15 | 0x2FFFFFFF | 1F | 0 | NAPOT | 1 | 1 | 1 | Main mem 80000000-FFFFFFFF RWX|
# write pmpcfg regs with the information in the table above. this should also write the value of these registers to the output. # write pmpcfg regs with the information in the table above. this should also write the value of these registers to the output.
.8byte 0x0, 0x0018900C0009001F, 0xD # write pmpcfg0, output 0x0018900C0009001F .8byte 0x0, 0x0018900C0009001F, write_pmpcfg_0 # write pmpcfg0, output 0x0018900C0009001F
.8byte 0x2, 0x1F00000000000000, 0xD # write pmpcfg2, output 0x1F00000000000000 .8byte 0x2, 0x1F00000000000000, write_pmpcfg_2 # write pmpcfg2, output 0x1F00000000000000
# write known values to memory where W=0. This should be possible since we're in machine mode. # write known values to memory where W=0. This should be possible since we're in machine mode.
.8byte 0x80100010, 0x600DAA, 0x0 # write to pmpaddr 1-2 range .8byte 0x80100010, 0x600DAA, write64_test # write to pmpaddr 1-2 range
.8byte 0x80100400, 0x600DBB, 0x0 # write to pmpaddr 6 range .8byte 0x80100400, 0x600DBB, write64_test # write to pmpaddr 6 range
# Write executable code to regions where X = 0, 1 in main memory # Write executable code to regions where X = 0, 1 in main memory
.8byte 0x80100200, 0x0000806711100393, 0x0 # write executable code for "li x7, 0x111; ret" to region with X=1 (PMP4) .8byte 0x80100200, 0x0000806711100393, write64_test # write executable code for "li x7, 0x111; ret" to region with X=1 (PMP4)
.8byte 0x80100020, 0x0000806711100393, 0x0 # Write same executable code to region with X=0 (PMP2) .8byte 0x80100020, 0x0000806711100393, write64_test # Write same executable code to region with X=0 (PMP2)
# attempt to write to pmpaddr5 and pmp5cfg after lockout # attempt to write to pmpaddr5 and pmp5cfg after lockout
.8byte 0x0, 0x0018FF0C0009001F, 0xD # attempt to edit only pmp5cfg (pmpcfg0[47:40]) after lockout. .8byte 0x0, 0x0018FF0C0009001F, write_pmpcfg_0 # attempt to edit only pmp5cfg (pmpcfg0[47:40]) after lockout.
# instruction ignored, output is 0x0018900C0009001F, NOT 0x0018FF0C0009001F # instruction ignored, output is 0x0018900C0009001F, NOT 0x0018FF0C0009001F
.8byte 0x5, 0xFFFFFFFF, 0xE # attempt to edit pmpaddr5 after lockout. .8byte 0x5, 0xFFFFFFFF, write_pmpaddr_5 # attempt to edit pmpaddr5 after lockout.
# instruction ignored, output is 0x80100300, NOT 0xFFFFFFFF # instruction ignored, output is 0x80100300, NOT 0xFFFFFFFF
# Test 12.3.2.2.2 Machine mode access # Test 12.3.2.2.2 Machine mode access
.8byte 0x80100300, 0x0, 0x1 # access fault to region with L=1, R=0 .8byte 0x80100300, 0x0, read64_test # access fault to region with L=1, R=0
.8byte 0x80100400, 0x0, 0x1 # successful access to region with L=X=W=R=0 .8byte 0x80100400, 0x0, read64_test # successful access to region with L=X=W=R=0
# Test 12.3.2.2.3 System mode access # Test 12.3.2.2.3 System mode access
.8byte 0x0, 0x0, 0x9 # go to S mode. 0xb written to output .8byte 0x0, 0x0, goto_s_mode # go to S mode. 0xb written to output
# test a write followed by a read to each region with R=W=1 # test a write followed by a read to each region with R=W=1
.8byte 0x80200000, 0x600D15, 0x0 # Write "good value" to RW range (PMP15) .8byte 0x80200000, 0x600D15, write64_test # Write "good value" to RW range (PMP15)
.8byte 0x80200000, 0x600D15, 0x1 # confirm write with read .8byte 0x80200000, 0x600D15, read64_test # confirm write with read
# test a write followed by a read on the edges of a read-only range # test a write followed by a read on the edges of a read-only range
.8byte 0x800FFFF8, 0x600D02, 0x0 # Write "good value" just below read-only range (PMP2) .8byte 0x800FFFF8, 0x600D02, write64_test # Write "good value" just below read-only range (PMP2)
.8byte 0x800FFFF8, 0x600D02, 0x1 # confirm write with read .8byte 0x800FFFF8, 0x600D02, read64_test # confirm write with read
.8byte 0x80100100, 0x600D12, 0x0 # Write "good value" just above read-only range (PMP2) .8byte 0x80100100, 0x600D12, write64_test # Write "good value" just above read-only range (PMP2)
.8byte 0x80100100, 0x600D12, 0x1 # confirm write with read .8byte 0x80100100, 0x600D12, read64_test # confirm write with read
# test a read from each read only range verify a write causes an access fault # test a read from each read only range verify a write causes an access fault
.8byte 0x80100010, 0xBAD, 0x0 # Write fault in read-only range (PMP2) .8byte 0x80100010, 0xBAD, write64_test # Write fault in read-only range (PMP2)
.8byte 0x80100010, 0x600DAA, 0x1 # read correct value out .8byte 0x80100010, 0x600DAA, read64_test # read correct value out
# test read and write fault on region with no access # test read and write fault on region with no access
.8byte 0x80100208, 0x600D15, 0x0 # Write fault on no-access range (PMP6) .8byte 0x80100208, 0x600D15, write64_test # Write fault on no-access range (PMP6)
.8byte 0x80100208, 0x600D15, 0x1 # read fault on no-access range (PMP6) .8byte 0x80100208, 0x600D15, read64_test # read fault on no-access range (PMP6)
# test jalr to region with X=0 causes access fault # test jalr to region with X=0 causes access fault
.8byte 0x80100020, 0xbad, 0x2 # execute fault on no-execute range (PMP2) .8byte 0x80100020, 0xbad, executable_test # execute fault on no-execute range (PMP2)
# test jalr to region with X=1 returns successfully # test jalr to region with X=1 returns successfully
.8byte 0x80100200, 0x111, 0x2 # execute success when X=1 .8byte 0x80100200, 0x111, executable_test # execute success when X=1
.8byte 0x0, 0x0, 0x3 // terminate tests .8byte 0x0, 0x0, terminate_test // terminate tests

View File

@ -293,38 +293,39 @@ test_loop:
ld x30, 16(x5) # fetch test case flag ld x30, 16(x5) # fetch test case flag
addi x5, x5, 24 # set x5 to next test case addi x5, x5, 24 # set x5 to next test case
slli x30, x30, 2 # multiply test type by 4 to index into jump table # x5 has the symbol for a test's location in the assembly
la x7, test_jump_table # load base address of jump table li x7, 0x1FFFFF
add x7, x7, x30 # get address of jump table entry and x30, x30, x7 # This program is always on at least a megapage, so this masks out the megapage offset.
jr x7 # jump to relevant test auipc x7, 0x0
srli x7, x7, 21
slli x7, x7, 21 # zero out the bottom 21 bits so the megapage offset of the symbol can be placed there
or x30, x7, x30 # x30 = virtual address of the symbol for this type of test.
jr x30
# Test Name : Description : Fault output value : Normal output values
# ----------------------:-------------------------------------------:------------------------:------------------------------------------------------
# write64_test : Write 64 bits to address : 0xf : None
# write32_test : Write 32 bits to address : 0xf : None
# write16_test : Write 16 bits to address : 0xf : None
# write08_test : Write 8 bits to address : 0xf : None
# read64_test : Read 64 bits from address : 0xd, 0xbad : readvalue in hex
# read32_test : Read 32 bitsfrom address : 0xd, 0xbad : readvalue in hex
# read16_test : Read 16 bitsfrom address : 0xd, 0xbad : readvalue in hex
# read08_test : Read 8 bitsfrom address : 0xd, 0xbad : readvalue in hex
# executable_test : test executable on virtual page : 0xc, 0xbad : value of x7 modified by exectuion code (usually 0x111)
# terminate_test : terminate tests : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_baremetal : satp.MODE = bare metal : None : None
# goto_sv39 : satp.MODE = sv39 : None : None
# goto_sv48 : satp.MODE = sv48 : None : None
# write_mxr_sum : write sstatus.[19:18] = MXR, SUM bits : None : None
# goto_m_mode : go to mahcine mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_s_mode : go to supervisor mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# goto_u_mode : go to user mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
# write_pmpcfg_x : Write one of the pmpcfg csr's : mstatuses?, 0xD : readback of pmpcfg value
# write_pmpaddr_x : Write one of the pmpaddr csr's : None : readback of pmpaddr value
test_jump_table:
# x30 Value : Function : Fault output value : Normal output values
# ----------:---------------------------------------:------------------------:------------------------------------------------------
j write64_test # 0x0 : Write 64 bits to address : 0xf : None
j read64_test # 0x1 : Read 64 bits from address : 0xd, 0xbad : readvalue in hex
j executable_test # 0x2 : test executable on virtual page : 0xc, 0xbad : value of x7 modified by exectuion code (usually 0x111)
j terminate_test # 0x3 : terminate tests : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_baremetal # 0x4 : satp.MODE = bare metal : None : None
j goto_sv39 # 0x5 : satp.MODE = sv39 : None : None
j goto_sv48 # 0x6 : satp.MODE = sv48 : None : None
j write_mxr_sum # 0x7 : write sstatus.[19:18] = MXR, SUM bits : None : None
j goto_m_mode # 0x8 : go to mahcine mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_s_mode # 0x9 : go to supervisor mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j goto_u_mode # 0xA : go to user mode : mcause value for fault : from M 0xb, from S 0x9, from U 0x8
j segfault # 0xB : Segfault, undefined test
j segfault # 0xC : Segfault, undefined test
j write_pmpcfg_0 # 0xD : Write one of the pmpcfg csr's : mstatuses?, 0xD : readback of pmpcfg value
j write_pmpaddr_0 # 0xE : Write one of the pmpaddr csr's : None : None
j segfault # 0xF : Segfault, undefined test
j segfault # 0x10 : Segfault, undefined test
j write32_test # 0x11 : Write 32 bits to address : 0xf : None
j write16_test # 0x12 : Write 16 bits to address : 0xf : None
j write08_test # 0x13 : Write 8 bits to address : 0xf : None
j read32_test # 0x14 : Read 32 bitsfrom address : 0xd, 0xbad : readvalue in hex
j read16_test # 0x15 : Read 16 bitsfrom address : 0xd, 0xbad : readvalue in hex
j read08_test # 0x16 : Read 8 bitsfrom address : 0xd, 0xbad : readvalue in hex
write64_test: write64_test:
# address to write in x28, double value in x29 # address to write in x28, double value in x29
sd x29, 0(x28) sd x29, 0(x28)