Be verbose, since output is going to a log file.
[riscv-tests.git] / debug / programs / mprv.S
1 #include "../../env/encoding.h"
2 #define PGSHIFT 12
3
4 .global main
5
6 .section .text
7 main:
8 # Set up a page table entry that maps 0x0... to 0x8...
9 la t0, page_table
10 srli t0, t0, PGSHIFT
11 csrw CSR_SPTBR, t0
12
13 # update mstatus
14 csrr t1, CSR_MSTATUS
15 li t0, (MSTATUS_MPRV | (VM_SV39 << 24))
16 #li t0, ((VM_SV39 << 24))
17 or t1, t0, t1
18 csrw CSR_MSTATUS, t1
19
20 la t0, (loop - 0x80000000)
21 csrw CSR_MEPC, t0
22
23 # Exit supervisor mode, entering user mode at loop.
24 mret
25
26 loop:
27 la t0, data
28 lw t1, 0(t0)
29 j loop
30
31 .section .data
32 data:
33 .word 0xbead
34
35 .balign 0x1000
36 page_table:
37 .word ((0x80000000 >> 2) | PTE_V | PTE_TYPE_URWX_SRWX)
38 .word 0