From patchwork Fri Oct 16 13:58:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 55109 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 75A7F22EAC for ; Fri, 16 Oct 2015 14:01:52 +0000 (UTC) Received: by lffy185 with SMTP id y185sf18383659lff.2 for ; Fri, 16 Oct 2015 07:01:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=xs46g//W1cVDqjzwF91GS70yxTkn6nr0K+vmtiAOpBU=; b=AqQtPznmYFnLCuuwtWSre76H5SZ2Sqxp3b9zy8DvRxo4Ep3ukcIvjLROrbhLBHVMu7 Bvjzoi1SzoKLwKe5HCHHHTkFlIsh8BFhK9ek3mSYdahSHuUBFcIvCHZPcjUFgq7ksyc3 wooS6Knt5M9EaeNI0FIysp2XqDPZjFCa3BoAVOd7fOft5Oq7elsO1HLBzsLKm2+Ztg0e ILAhd/OzmL/zfR8BlsKynKZO3umccDYTt+MvccZllXsO2qHqid/ea4O6yi9H/A1e+ACl Btq8TYG4H241ov6QAqLMw0lxkPtwO5/F76zYIK7wTCIt9U2jsX96nWss8GGAfrUdKlc3 8Y4w== X-Gm-Message-State: ALoCoQmKmJ+EMkqp+afvAt/IMDiB3Lb5bLsCS/Nf89TiEyPUp4NZ6AUG7GziPSQTz+aCxy/BCnAY X-Received: by 10.180.35.132 with SMTP id h4mr1181031wij.5.1445004111412; Fri, 16 Oct 2015 07:01:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.147.66 with SMTP id v63ls322347lfd.22.gmail; Fri, 16 Oct 2015 07:01:51 -0700 (PDT) X-Received: by 10.112.146.231 with SMTP id tf7mr8406473lbb.103.1445004111228; Fri, 16 Oct 2015 07:01:51 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id xp1si12990086lbb.134.2015.10.16.07.01.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 07:01:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbcao8 with SMTP id ao8so100813871lbc.3 for ; Fri, 16 Oct 2015 07:01:51 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr8266823lbb.112.1445004110836; Fri, 16 Oct 2015 07:01:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1309389lbq; Fri, 16 Oct 2015 07:01:49 -0700 (PDT) X-Received: by 10.13.221.196 with SMTP id g187mr11390575ywe.225.1445004109190; Fri, 16 Oct 2015 07:01:49 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a1si13676409qgf.107.2015.10.16.07.01.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Oct 2015 07:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:53849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn5Zp-0006j4-QN for patch@linaro.org; Fri, 16 Oct 2015 10:01:45 -0400 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 To: qemu-devel@nongnu.org Date: Fri, 16 Oct 2015 14:58:05 +0100 Message-Id: <1445003887-14475-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> References: <1445003887-14475-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 11/13] target-arm: implement arm_debug_target_el() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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)