Take M-mode interrupts over S-mode interrupts
authorAndrew Waterman <andrew@sifive.com>
Tue, 21 Feb 2017 01:17:17 +0000 (17:17 -0800)
committerAndrew Waterman <andrew@sifive.com>
Tue, 21 Feb 2017 01:17:17 +0000 (17:17 -0800)
riscv/processor.cc

index 706c0bcd050f065bfde559b6ebb17981d115ea4e..29307fd5ba9b5aa604bc184aadfc8238bb9fcbbb 100644 (file)
@@ -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));