From b47e8c0a190ac17d2622d5554b21bc871d56847a Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 20 Feb 2017 17:17:17 -0800 Subject: [PATCH] Take M-mode interrupts over S-mode interrupts --- riscv/processor.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riscv/processor.cc b/riscv/processor.cc index 706c0bc..29307fd 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -172,7 +172,8 @@ void processor_t::take_interrupt(reg_t pending_interrupts) reg_t sie = get_field(state.mstatus, MSTATUS_SIE); reg_t s_enabled = state.prv < PRV_S || (state.prv == PRV_S && sie); - enabled_interrupts |= pending_interrupts & state.mideleg & -s_enabled; + if (enabled_interrupts == 0) + enabled_interrupts = pending_interrupts & state.mideleg & -s_enabled; if (enabled_interrupts) throw trap_t(((reg_t)1 << (max_xlen-1)) | ctz(enabled_interrupts)); -- 2.30.2