From c0f7d3cd7760f6021a87027a2bb95039daa92c4a Mon Sep 17 00:00:00 2001 From: Yunsup Lee Date: Mon, 16 Mar 2015 02:01:26 -0700 Subject: [PATCH] bugfix in raising accelerator interrupts --- hwacha/hwacha.cc | 2 +- riscv/extension.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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() -- 2.30.2