}
}
+bool
+HaveVirtHostExt(ThreadContext *tc)
+{
+ AA64MMFR1 id_aa64mmfr1 = tc->readMiscReg(MISCREG_ID_AA64MMFR1_EL1);
+ return id_aa64mmfr1.vh;
+}
+
bool
HaveSecureEL2Ext(ThreadContext *tc)
{
bool
ELIsInHost(ThreadContext *tc, ExceptionLevel el)
{
- if (!ArmSystem::haveVirtualization(tc)) {
- return false;
- }
- HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
- return (!isSecureBelowEL3(tc) && !ELIs32(tc, EL2) && hcr.e2h == 1 &&
+ const HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
+ return ((IsSecureEL2Enabled(tc) || !isSecureBelowEL3(tc)) &&
+ HaveVirtHostExt(tc) && !ELIs32(tc, EL2) && hcr.e2h == 1 &&
(el == EL2 || (el == EL0 && hcr.tge == 1)));
}