From 438ecf9cb08f8e5681ef39df7f6709b8fdec2d50 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Tue, 23 Oct 2018 13:33:12 +0100 Subject: [PATCH] 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 --- src/arch/arm/isa/insts/misc64.isa | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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)); } -- 2.30.2