From: Giacomo Travaglini Date: Tue, 23 Oct 2018 12:33:12 +0000 (+0100) Subject: arch-arm: Fix HVC trapping beahviour X-Git-Tag: v19.0.0.0~1457 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=438ecf9cb08f8e5681ef39df7f6709b8fdec2d50;p=gem5.git arch-arm: Fix HVC trapping beahviour This patch is fixing HVC trapping behaviour, reusing the pseudocode implementation provided in the arm arm. Change-Id: I0bc81478400b99d84534c1c8871f894722f547c5 Signed-off-by: Giacomo Travaglini Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/13776 Maintainer: Andreas Sandberg --- diff --git a/src/arch/arm/isa/insts/misc64.isa b/src/arch/arm/isa/insts/misc64.isa index 2621905c7..6d40dd913 100644 --- a/src/arch/arm/isa/insts/misc64.isa +++ b/src/arch/arm/isa/insts/misc64.isa @@ -51,10 +51,20 @@ let {{ hvcCode = ''' SCR scr = Scr64; + HCR hcr = Hcr64; + CPSR cpsr = Cpsr; - if (!ArmSystem::haveVirtualization(xc->tcBase()) || - (ArmSystem::haveSecurity(xc->tcBase()) && (!scr.ns || !scr.hce))) { - fault = disabledFault(); + auto tc = xc->tcBase(); + ExceptionLevel pstate_EL = (ExceptionLevel)(uint8_t)(cpsr.el); + + bool unalloc_encod = !ArmSystem::haveEL(tc, EL2) || pstate_EL == EL0 || + (pstate_EL == EL1 && inSecureState(tc)); + + bool hvc_enable = ArmSystem::haveEL(tc, EL3) ? + scr.hce : !hcr.hcd; + + if (unalloc_encod || !hvc_enable) { + fault = undefinedFault64(tc, pstate_EL); } else { fault = std::make_shared(machInst, bits(machInst, 20, 5)); }