arch-arm, dev-arm: Move inSecureState helper to ISA class
The helper function should be really part of the Arm ISA class Change-Id: Ida0393a12426c8973a9b8171ec2922c2dcec9f5a Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53268 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -2531,6 +2531,30 @@ ISA::getGICv3CPUInterface()
|
||||
return *gicv3CpuInterface.get();
|
||||
}
|
||||
|
||||
bool
|
||||
ISA::inSecureState() const
|
||||
{
|
||||
if (!release->has(ArmExtension::SECURITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SCR scr = miscRegs[MISCREG_SCR];
|
||||
CPSR cpsr = miscRegs[MISCREG_CPSR];
|
||||
|
||||
switch ((OperatingMode) (uint8_t) cpsr.mode) {
|
||||
case MODE_MON:
|
||||
case MODE_EL3T:
|
||||
case MODE_EL3H:
|
||||
return true;
|
||||
case MODE_HYP:
|
||||
case MODE_EL2T:
|
||||
case MODE_EL2H:
|
||||
return false;
|
||||
default:
|
||||
return !scr.ns;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned
|
||||
ISA::getCurSveVecLenInBits() const
|
||||
{
|
||||
|
||||
@@ -844,15 +844,11 @@ namespace ArmISA
|
||||
}
|
||||
} else {
|
||||
if (miscRegInfo[reg][MISCREG_BANKED]) {
|
||||
bool secure_reg = release->has(ArmExtension::SECURITY) &&
|
||||
!highestELIs64 &&
|
||||
inSecureState(miscRegs[MISCREG_SCR],
|
||||
miscRegs[MISCREG_CPSR]);
|
||||
bool secure_reg = !highestELIs64 && inSecureState();
|
||||
flat_idx += secure_reg ? 2 : 1;
|
||||
} else {
|
||||
flat_idx = snsBankedIndex64((MiscRegIndex)reg,
|
||||
!inSecureState(miscRegs[MISCREG_SCR],
|
||||
miscRegs[MISCREG_CPSR]));
|
||||
!inSecureState());
|
||||
}
|
||||
}
|
||||
return flat_idx;
|
||||
@@ -952,9 +948,8 @@ namespace ArmISA
|
||||
}
|
||||
|
||||
// do additional S/NS flattenings if mapped to NS while in S
|
||||
bool S = release->has(ArmExtension::SECURITY) && !highestELIs64 &&
|
||||
inSecureState(miscRegs[MISCREG_SCR],
|
||||
miscRegs[MISCREG_CPSR]);
|
||||
bool S = !highestELIs64 && inSecureState();
|
||||
|
||||
int lower = lookUpMiscReg[flat_idx].lower;
|
||||
int upper = lookUpMiscReg[flat_idx].upper;
|
||||
// upper == 0, which is CPSR, is not MISCREG_BANKED_CHILD (no-op)
|
||||
@@ -963,6 +958,9 @@ namespace ArmISA
|
||||
return std::make_pair(lower, upper);
|
||||
}
|
||||
|
||||
/** Return true if the PE is in Secure state */
|
||||
bool inSecureState() const;
|
||||
|
||||
unsigned getCurSveVecLenInBits() const;
|
||||
|
||||
unsigned getCurSveVecLenInBitsAtReset() const { return sveVL * 128; }
|
||||
|
||||
@@ -491,10 +491,9 @@ PMU::CounterState::isFiltered() const
|
||||
assert(pmu.isa);
|
||||
|
||||
const PMEVTYPER_t filter(this->filter);
|
||||
const SCR scr(pmu.isa->readMiscRegNoEffect(MISCREG_SCR));
|
||||
const CPSR cpsr(pmu.isa->readMiscRegNoEffect(MISCREG_CPSR));
|
||||
const ExceptionLevel el(currEL(cpsr));
|
||||
const bool secure(inSecureState(scr, cpsr));
|
||||
const bool secure(pmu.isa->inSecureState());
|
||||
|
||||
switch (el) {
|
||||
case EL0:
|
||||
|
||||
@@ -217,23 +217,6 @@ Addr purifyTaggedAddr(Addr addr, ThreadContext *tc, ExceptionLevel el,
|
||||
int computeAddrTop(ThreadContext *tc, bool selbit, bool isInstr,
|
||||
TCR tcr, ExceptionLevel el);
|
||||
|
||||
static inline bool
|
||||
inSecureState(SCR scr, CPSR cpsr)
|
||||
{
|
||||
switch ((OperatingMode) (uint8_t) cpsr.mode) {
|
||||
case MODE_MON:
|
||||
case MODE_EL3T:
|
||||
case MODE_EL3H:
|
||||
return true;
|
||||
case MODE_HYP:
|
||||
case MODE_EL2T:
|
||||
case MODE_EL2H:
|
||||
return false;
|
||||
default:
|
||||
return !scr.ns;
|
||||
}
|
||||
}
|
||||
|
||||
bool isSecureBelowEL3(ThreadContext *tc);
|
||||
|
||||
bool longDescFormatInUse(ThreadContext *tc);
|
||||
|
||||
@@ -2333,13 +2333,7 @@ Gicv3CPUInterface::groupEnabled(Gicv3::GroupId group) const
|
||||
bool
|
||||
Gicv3CPUInterface::inSecureState() const
|
||||
{
|
||||
if (!gic->getSystem()->has(ArmExtension::SECURITY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CPSR cpsr = isa->readMiscRegNoEffect(MISCREG_CPSR);
|
||||
SCR scr = isa->readMiscRegNoEffect(MISCREG_SCR);
|
||||
return gem5::inSecureState(scr, cpsr);
|
||||
return isa->inSecureState();
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user