Skip to content

Commit eb077c9

Browse files
RISC-V: Skip setting up PMPs on traps
The RISC-V ISA manual says that PMPs are WARL, but it appears the K210 doesn't implement them and instead traps on the unsupported accesses. This patch handles those traps by just skipping the PMP initialization entirely, under the theory that machines that trap on PMP accesses must allow memory accesses as otherwise they're pretty useless. Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 045c654 commit eb077c9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/riscv/kernel/head.S

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,20 @@ ENTRY(_start_kernel)
161161
/* Reset all registers except ra, a0, a1 */
162162
call reset_regs
163163

164-
/* Setup a PMP to permit access to all of memory. */
164+
/*
165+
* Setup a PMP to permit access to all of memory. Some machines may
166+
* not implement PMPs, so we set up a quick trap handler to just skip
167+
* touching the PMPs on any trap.
168+
*/
169+
la a0, pmp_done
170+
csrw CSR_TVEC, a0
171+
165172
li a0, -1
166173
csrw CSR_PMPADDR0, a0
167174
li a0, (PMP_A_NAPOT | PMP_R | PMP_W | PMP_X)
168175
csrw CSR_PMPCFG0, a0
176+
.align 2
177+
pmp_done:
169178

170179
/*
171180
* The hartid in a0 is expected later on, and we have no firmware

0 commit comments

Comments
 (0)