From: Yunsup Lee Date: Mon, 16 Mar 2015 09:01:26 +0000 (-0700) Subject: bugfix in raising accelerator interrupts X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0f7d3cd7760f6021a87027a2bb95039daa92c4a;p=riscv-isa-sim.git bugfix in raising accelerator interrupts --- diff --git a/hwacha/hwacha.cc b/hwacha/hwacha.cc index 972e151..820faab 100644 --- a/hwacha/hwacha.cc +++ b/hwacha/hwacha.cc @@ -103,5 +103,5 @@ void hwacha_t::take_exception(reg_t c, reg_t a) cause = c; aux = a; raise_interrupt(); - throw std::logic_error("a hwacha exception was posted, but interrupts are disabled!"); + throw std::logic_error("unreachable!"); } diff --git a/riscv/extension.cc b/riscv/extension.cc index c2bea2e..0977139 100644 --- a/riscv/extension.cc +++ b/riscv/extension.cc @@ -12,7 +12,14 @@ void extension_t::illegal_instruction() void extension_t::raise_interrupt() { - p->raise_interrupt(IRQ_COP); + int priv = get_field(p->get_state()->mstatus, MSTATUS_PRV); + int ie = get_field(p->get_state()->mstatus, MSTATUS_IE); + + if (priv < PRV_M || (priv == PRV_M && ie)) { + p->raise_interrupt(IRQ_COP); + } + + throw std::logic_error("a COP exception was posted, but interrupts are disabled!"); } void extension_t::clear_interrupt()