From patchwork Wed Dec 15 10:40:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 524270 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp246624imb; Wed, 15 Dec 2021 03:33:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi+zPUhptUIqnOw4MDID7wSEW9fk0i2jbIe9dsGb1hBBJCEPl3N81gMdM26jHi9OasrT4r X-Received: by 2002:a25:8609:: with SMTP id y9mr5438564ybk.50.1639568033342; Wed, 15 Dec 2021 03:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639568033; cv=none; d=google.com; s=arc-20160816; b=HR776WzSV6R1rcNfBUXiUhViTGeEIZ7DU24Z4ro++0uNGQuuUdJYrR/QmPNWOvYEw2 PKCCivuYp9U4q6DbEoxf3MaprcFN4EwxfBc55+QU3Fl/AeM6Zvp7PA+SoZCOb/wTujzx mmvG0IbOw7ImIQJzf5blEZ3HQbvs3gpiwHa7FDS2j+TkYHCjEmA9gxwp5PHI8XyCR6Fy 1nzc4yap1S08v5AqgbjCalTk8phht3bWbUcPp29n/gjAemiiDXXMTldak8a1cktys53t 5ck57mObxg0TvxziwqQJeiB6TOSXG86ohEx1Qt7qkvC1NolApQLtDzhOnnLhMNvcbEOC AmUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tLNa3rIPfRwl8m/eEZTAjhUMYzfnAvACuXtMQvvgIj0=; b=Zv6JLbP/vTuMyaDURM2nC6/0I0RiCNlv1nurRF7pr8Smg/22eQTipNhZF2E3+kOxqM eGDlJNcS+kiAE680hRsDegNzzYuBhh6bt4qnLCqCKP451i6WvG9glZMts1Di08LNSDK4 8U92IAIUIWP+qBkcwMNjpqVSgpFItpWuexHMWk7pNVi2oUYzRcac/6Uxbyw4I3fjWfHL PvoyIH4edVSYM6ld/srd+w3QPqO6XWKP160A4tXzsDlpJUo/oMKpplHK/x4GQE7w5XxI kzc1vAXHDG6UBF6cnefWdfIM2F12mBFqoOtlQDRQ9ZuVuEYsa9dNbJwo6T/TJZZ9Sajl xkmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ey2eAYmO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j76si1792550ybj.679.2021.12.15.03.33.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Dec 2021 03:33:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ey2eAYmO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxSXg-0004Fe-PD for patch@linaro.org; Wed, 15 Dec 2021 06:33:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxRid-00073S-FA for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:07 -0500 Received: from [2a00:1450:4864:20::435] (port=42992 helo=mail-wr1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxRiY-0008Rr-RY for qemu-devel@nongnu.org; Wed, 15 Dec 2021 05:41:07 -0500 Received: by mail-wr1-x435.google.com with SMTP id c4so37353338wrd.9 for ; Wed, 15 Dec 2021 02:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=tLNa3rIPfRwl8m/eEZTAjhUMYzfnAvACuXtMQvvgIj0=; b=Ey2eAYmO/iAHeBAImw1yeZiEGIhxnCdS8gxid9CBpQ4npDvhXhuwcjbEzgixXVktrX k8dnJ47X7gxR7gxMgIapaj9ioNIKdrUSdYnaDF0gUaN9VlB3iLBO+Of0k/3cpnwJixJg 7frqLEOSpnHpkeeD7NXaNLbUaLxNnSeo8ql1w4bU7lpPp+wdFmY4Rbi2veXnOju3yiGB 9e4wuQmVOnTN+tdw3CK+YloWhihhjl3hmQgxb05MXxrz9A1DKA463NVQxaYizL6G0xHt +kHHTzw8JeGuVrSSR83FBZ34CPZnITxuJlzit2VE+ae2VeWF4JK3f2cr1dbzMnc2CQwz riFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tLNa3rIPfRwl8m/eEZTAjhUMYzfnAvACuXtMQvvgIj0=; b=kh15rubNlHxiBveVSTz6iENkMTrgxWALa/zUadqk/TKO/TLr2Kv4dN/YsyHk/8sOJX 63YFC8SphZdyirNDS+JB1UBr6H8rH03Pnrm5bXxaydsMcH7c5MJtLyesjmIp6gjE7fwv FifUfkDThxSv4guSPHYIIZDjKN9ia6T2kUIHmvJ2TzPv5ngXAhG3updeWvXCLArxdxoG vjzqRWDnpwnGXldQJd3c7lsnejt1q/yvcB9QmEqw2eVJZKnlpx9VJ+LveaF04cY/lxbd tkYN3dFBVDbYp5XqwWsvJmahK/8NMbZY1TRVXbe1z2nm6AcVGEWc/jvlk44+I2NttogL JCig== X-Gm-Message-State: AOAM5326hx0AQnt/J6bJ5rj4/pfD0kd7dfRvBvaoK8OymcgNS/9Grmqi zmLlHrKbw9C5wMUnJ+VKIef6jGxgIx/Dmg== X-Received: by 2002:a5d:52c3:: with SMTP id r3mr3898533wrv.115.1639564860547; Wed, 15 Dec 2021 02:41:00 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e18sm1600815wrs.48.2021.12.15.02.41.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 02:41:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/33] target/arm: Suppress bp for exceptions with more priority Date: Wed, 15 Dec 2021 10:40:33 +0000 Message-Id: <20211215104049.2030475-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215104049.2030475-1-peter.maydell@linaro.org> References: <20211215104049.2030475-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::435 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" From: Richard Henderson Both single-step and pc alignment faults have priority over breakpoint exceptions. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell --- target/arm/debug_helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index 2983e36dd33..32f3caec238 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -220,6 +220,7 @@ bool arm_debug_check_breakpoint(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + target_ulong pc; int n; /* @@ -231,6 +232,28 @@ bool arm_debug_check_breakpoint(CPUState *cs) return false; } + /* + * Single-step exceptions have priority over breakpoint exceptions. + * If single-step state is active-pending, suppress the bp. + */ + if (arm_singlestep_active(env) && !(env->pstate & PSTATE_SS)) { + return false; + } + + /* + * PC alignment faults have priority over breakpoint exceptions. + */ + pc = is_a64(env) ? env->pc : env->regs[15]; + if ((is_a64(env) || !env->thumb) && (pc & 3) != 0) { + return false; + } + + /* + * Instruction aborts have priority over breakpoint exceptions. + * TODO: We would need to look up the page for PC and verify that + * it is present and executable. + */ + for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) { if (bp_wp_matches(cpu, n, false)) { return true;