From 4fabfb4e0d3eacc1dc791da70e342e4b68ea7e46 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 16 Mar 2023 17:02:49 -0700 Subject: [PATCH] Cope with presence of Smrnmi extension Enable RNMIs if the extension is present, as the feature affects trap behavior when RNMIs are masked. --- p/riscv_test.h | 8 ++++++++ v/entry.S | 2 ++ 2 files changed, 10 insertions(+) diff --git a/p/riscv_test.h b/p/riscv_test.h index a8c50c7a5..7bf35cf34 100644 --- a/p/riscv_test.h +++ b/p/riscv_test.h @@ -107,6 +107,13 @@ .align 2; \ 1: +#define INIT_RNMI \ + la t0, 1f; \ + csrw mtvec, t0; \ + csrwi CSR_MNSTATUS, MNSTATUS_NMIE; \ + .align 2; \ +1: + #define INIT_SATP \ la t0, 1f; \ csrw mtvec, t0; \ @@ -197,6 +204,7 @@ handle_exception: \ reset_vector: \ INIT_XREG; \ RISCV_MULTICORE_DISABLE; \ + INIT_RNMI; \ INIT_SATP; \ INIT_PMP; \ DELEGATE_NO_TRAPS; \ diff --git a/v/entry.S b/v/entry.S index 3388ffb40..13d46a349 100644 --- a/v/entry.S +++ b/v/entry.S @@ -60,6 +60,8 @@ handle_reset: li x30, 0 li x31, 0 + INIT_RNMI + la t0, trap_vector csrw mtvec, t0 la sp, STACK_TOP - SIZEOF_TRAPFRAME_T