From 85b7e37d013ef2f1a505ffc00d142f26dcf81d80 Mon Sep 17 00:00:00 2001 From: Abhinay Kayastha Date: Mon, 6 Jul 2020 17:02:05 -0700 Subject: If n_pmp=0, then pmp is not implemented hence raise trap --- riscv/processor.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/riscv/processor.cc b/riscv/processor.cc index d6348a8..9dc5911 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -1047,6 +1047,9 @@ reg_t processor_t::get_csr(int which) return 0; if (which >= CSR_PMPADDR0 && which < CSR_PMPADDR0 + state.max_pmp) { + // If n_pmp is zero, that means pmp is not implemented hence raise trap if it tries to access the csr + if (n_pmp == 0) + throw trap_illegal_instruction(0); reg_t i = which - CSR_PMPADDR0; if ((state.pmpcfg[i] & PMP_A) >= PMP_NAPOT) return state.pmpaddr[i] | (~pmp_tor_mask() >> 1); -- cgit v1.1