Cui Jin has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/39035 )
Change subject: arch-riscv: fix incorrect interrupt checking logic
......................................................................
arch-riscv: fix incorrect interrupt checking logic
Whether global interrupt enabling or not is not simply decided by
xIE bit in mstatus, it also depends on current privilige level.
All level lower/higher than current should be disabled/enabled
regardless of the xIE bit. xIE bit is only control the enabling
of interrupt in current privilige level.
The fix is verified in FS.
Jira Issue: https://gem5.atlassian.net/browse/GEM5-883
Change-Id: I37f83ab77af2efbf1da9b81845828d322e49bf5f
---
M src/arch/riscv/interrupts.hh
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/src/arch/riscv/interrupts.hh b/src/arch/riscv/interrupts.hh
index fba925e..e1460ab 100644
--- a/src/arch/riscv/interrupts.hh
+++ b/src/arch/riscv/interrupts.hh
@@ -72,12 +72,31 @@
{
INTERRUPT mask = 0;
STATUS status = tc->readMiscReg(MISCREG_STATUS);
- if (status.mie)
- mask.mei = mask.mti = mask.msi = 1;
- if (status.sie)
- mask.sei = mask.sti = mask.ssi = 1;
- if (status.uie)
- mask.uei = mask.uti = mask.usi = 1;
+ PrivilegeMode prv = (PrivilegeMode)tc->readMiscReg(MISCREG_PRV);
+ switch (prv) {
+ case PRV_U:
+ mask.mei = mask.mti = mask.msi = 1;
+ mask.sei = mask.sti = mask.ssi = 1;
+ if (status.uie)
+ mask.uei = mask.uti = mask.usi = 1;
+ break;
+ case PRV_S:
+ mask.mei = mask.mti = mask.msi = 1;
+ if (status.sie)
+ mask.sei = mask.sti = mask.ssi = 1;
+ mask.uei = mask.uti = mask.usi = 0;
+ break;
+ case PRV_M:
+ if (status.mie)
+ mask.mei = mask.mti = mask.msi = 1;
+ mask.sei = mask.sti = mask.ssi = 0;
+ mask.uei = mask.uti = mask.usi = 0;
+ break;
+ default:
+ panic("Unknown privilege mode %d.", prv);
+ break;
+ }
+
return std::bitset<NumInterruptTypes>(mask);
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39035
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I37f83ab77af2efbf1da9b81845828d322e49bf5f
Gerrit-Change-Number: 39035
Gerrit-PatchSet: 1
Gerrit-Owner: Cui Jin <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s