Received: from eggs.gnu.org ([2001:4830:134:3::10]:54979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5WM-00020U-Pk for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn5WL-0000k6-TD for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:10 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:35158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5WL-0000ht-MV for qemu-devel@nongnu.org; Fri, 16 Oct 2015 09:58:09 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Zn5WK-0003mo-2k for qemu-devel@nongnu.org; Fri, 16 Oct 2015 14:58:08 +0100 From: Peter Maydell Date: Fri, 16 Oct 2015 14:58:05 +0100 Message-Id: <1445003887-14475-12-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> References: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 11/13] target-arm: implement arm_debug_target_el() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Sergey Fedorov Implement debug exception routing according to ARM ARM D2.3.1 Pseudocode description of routing debug exceptions. Signed-off-by: Sergey Fedorov Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target-arm/cpu.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index e555122..3daa7f5 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -1702,7 +1702,22 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) */ static inline int arm_debug_target_el(CPUARMState *env) { - return 1; + bool secure = arm_is_secure(env); + bool route_to_el2 = false; + + if (arm_feature(env, ARM_FEATURE_EL2) && !secure) { + route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || + env->cp15.mdcr_el2 & (1 << 8); + } + + if (route_to_el2) { + return 2; + } else if (arm_feature(env, ARM_FEATURE_EL3) && + !arm_el_is_aa64(env, 3) && secure) { + return 3; + } else { + return 1; + } } static inline bool aa64_generate_debug_exceptions(CPUARMState *env) -- 1.9.1