Jordi Vaquero has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/30620 )
Change subject: arch-arm: Fix routeToHyp conditions for Excp Type
......................................................................
arch-arm: Fix routeToHyp conditions for Excp Type
Change-Id: I8eadd8e1f8c53d5e61969b492d9f2cbd12110188
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30620
Reviewed-by: Giacomo Travaglini <[email protected]>
Maintainer: Giacomo Travaglini <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/arch/arm/faults.cc
1 file changed, 10 insertions(+), 43 deletions(-)
Approvals:
Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/faults.cc b/src/arch/arm/faults.cc
index ecc9e4d..743e08d 100644
--- a/src/arch/arm/faults.cc
+++ b/src/arch/arm/faults.cc
@@ -884,17 +884,8 @@
bool
SupervisorCall::routeToHyp(ThreadContext *tc) const
{
- bool toHyp;
-
- SCR scr = tc->readMiscRegNoEffect(MISCREG_SCR);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR);
- CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
-
- // if in Hyp mode then stay in Hyp mode
- toHyp = scr.ns && (cpsr.mode == MODE_HYP);
- // if HCR.TGE is set to 1, take to Hyp mode through Hyp Trap vector
- toHyp |= !inSecureState(scr, cpsr) && hcr.tge && (currEL(tc) == EL0);
- return toHyp;
+ return EL2Enabled(tc) && currEL(tc) == EL0 && hcr.tge == 1;
}
ExceptionClass
@@ -1028,15 +1019,8 @@
bool
SupervisorTrap::routeToHyp(ThreadContext *tc) const
{
- bool toHyp = false;
-
- SCR scr = tc->readMiscRegNoEffect(MISCREG_SCR_EL3);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR_EL2);
- CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
-
- // if HCR.TGE is set to 1, take to Hyp mode through Hyp Trap vector
- toHyp |= !inSecureState(scr, cpsr) && hcr.tge && (currEL(tc) == EL0);
- return toHyp;
+ return EL2Enabled(tc) && currEL(tc) <= EL1 && hcr.tge;
}
uint32_t
@@ -1323,6 +1307,7 @@
// if in Hyp mode then stay in Hyp mode
toHyp = scr.ns && (currEL(tc) == EL2);
+ toHyp |= (currEL(tc) <= EL1) && hcr.tge;
// otherwise, check whether to take to Hyp mode through Hyp Trap vector
toHyp |= (stage2 ||
((source == DebugEvent) && (hdcr.tde || hcr.tge) &&
@@ -1384,6 +1369,7 @@
// if in Hyp mode then stay in Hyp mode
toHyp = scr.ns && (currEL(tc) == EL2);
+ toHyp |= (currEL(tc) <= EL1 && hcr.tge==1);
// otherwise, check whether to take to Hyp mode through Hyp Trap vector
toHyp |= (stage2 ||
((currEL(tc) != EL2) &&
@@ -1484,15 +1470,9 @@
bool
Interrupt::routeToHyp(ThreadContext *tc) const
{
- bool toHyp;
-
- SCR scr = tc->readMiscRegNoEffect(MISCREG_SCR);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR);
- CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
- // Determine whether IRQs are routed to Hyp mode.
- toHyp = (!scr.irq && hcr.imo && !inSecureState(tc)) ||
- (cpsr.mode == MODE_HYP);
- return toHyp;
+ return fromEL == EL2 ||
+ (EL2Enabled(tc) && fromEL <= EL1 && (hcr.tge == 1 || hcr.imo));
}
bool
@@ -1523,15 +1503,9 @@
bool
FastInterrupt::routeToHyp(ThreadContext *tc) const
{
- bool toHyp;
-
- SCR scr = tc->readMiscRegNoEffect(MISCREG_SCR);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR);
- CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
- // Determine whether IRQs are routed to Hyp mode.
- toHyp = (!scr.fiq && hcr.fmo && !inSecureState(tc)) ||
- (cpsr.mode == MODE_HYP);
- return toHyp;
+ return fromEL == EL2 ||
+ (EL2Enabled(tc) && fromEL <= EL1 && (hcr.tge == 1 || hcr.fmo));
}
bool
@@ -1571,15 +1545,8 @@
bool
PCAlignmentFault::routeToHyp(ThreadContext *tc) const
{
- bool toHyp = false;
-
- SCR scr = tc->readMiscRegNoEffect(MISCREG_SCR_EL3);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR_EL2);
- CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
-
- // if HCR.TGE is set to 1, take to Hyp mode through Hyp Trap vector
- toHyp |= !inSecureState(scr, cpsr) && hcr.tge && (currEL(tc) == EL0);
- return toHyp;
+ return EL2Enabled(tc) && currEL(tc) <= EL1 && hcr.tge == 1;
}
SPAlignmentFault::SPAlignmentFault()
@@ -1590,7 +1557,7 @@
{
assert(from64);
HCR hcr = tc->readMiscRegNoEffect(MISCREG_HCR_EL2);
- return EL2Enabled(tc) && hcr.tge==1;
+ return EL2Enabled(tc) && currEL(tc) <= EL1 && hcr.tge == 1;
}
SystemError::SystemError()
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/30620
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: I8eadd8e1f8c53d5e61969b492d9f2cbd12110188
Gerrit-Change-Number: 30620
Gerrit-PatchSet: 4
Gerrit-Owner: Jordi Vaquero <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jordi Vaquero <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s