From patchwork Wed Aug 18 01:00:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 498873 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp156708jab; Tue, 17 Aug 2021 18:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCFxaJCPZSUbuMwZiwv5hM53L2tmRtdIFtFVBm/qPj96drCzAU9J5gwjrpw7DgyAMv3bE2 X-Received: by 2002:a05:6122:da3:: with SMTP id bc35mr5464907vkb.18.1629248761103; Tue, 17 Aug 2021 18:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629248761; cv=none; d=google.com; s=arc-20160816; b=pvDEnnpJQ+ieJguzdnhGsuO7x133OOyu9hgXkYfofZZ2qK7rWNahht1IWb/EIywpBb Pb/pgk0onR9F+WStDMfs1StN1FNmY2qnxPBH+1rqAU1LUweRJUQNRDMOa71cpKnY7vt1 ISK+AQXrVkCZSJB1WFWNBmH0AHCgCiYuWRaTgR+p2v6AlkX9r/GQ1aCAMfZftGLiexRa uI5nkOG8XQs1YZPpUpMprtVpIPluNKkwKyg4C8KGDzhUMtZ6s3NM2EbM0KHO/K+hudeP 2rfhLdACSIJs6lHozEnMK4ePd3F/xSfXzmCil4Mp7fbeVCfnQxEWK5X5kXvW2nlGaAlE 4tmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=3++UiM9Nvpex33sDYBqi5LO8w14qjh3qiR4geB26iKQ=; b=sNCOOQX/scafT+Gez9kS5A3i3vWKM3w5a052P1z80aXWZ/SliekJ8WyRxNnbq0i5gM S0NcxgSwo3BnM43JP6hniOt6dfzQuHPv88VETf6j3p2PWQr3+DYlke8AJC6bCVeETHIX hbdAhiPn4/k2DbXtfJVN906YG21XqvXzo4PjfknKt2oKWVw/m/vlucpHM0zV6NLqxg99 xr1yzq8//1Jf7nd8IsQcFtkohLClCNFWfaZrWgNQCtvHXMNaxgkAfouWXQwuruqc+FIz I/2hUzUICgwXOEbUHN3yX2lq7o2yaC1rPf1Ah5azieSjh/f4JmlGbUEilTWe4Te1x/z5 szeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hvtvifip; 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 o10si1784033vsl.104.2021.08.17.18.06.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Aug 2021 18:06:01 -0700 (PDT) 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=Hvtvifip; 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]:56012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGA1o-00034f-Gu for patch@linaro.org; Tue, 17 Aug 2021 21:06:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mG9wu-000491-72 for qemu-devel@nongnu.org; Tue, 17 Aug 2021 21:00:57 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:45807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mG9wp-0001OD-Ib for qemu-devel@nongnu.org; Tue, 17 Aug 2021 21:00:55 -0400 Received: by mail-pj1-x102a.google.com with SMTP id m24-20020a17090a7f98b0290178b1a81700so1218537pjl.4 for ; Tue, 17 Aug 2021 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3++UiM9Nvpex33sDYBqi5LO8w14qjh3qiR4geB26iKQ=; b=HvtvifipWcMTSCAtENYbf4UhBK5dI7dfEyiX/nAFe88Q+DvjPLBFxu8vhUMWCCrYRr g+vIjImlTxeKvD9E5NHuxHXhuIf+zKyABupvCBLGLnpw75+TkXkTw2RCMgzIqLGkWvb7 cLu2s0AtS+1gSW+Rm2eJQEEfv0zHt8qHHgxexBJ1jlpUk2kmEkzMpq8E4dgwgFJhgUE0 aGVJWdMxd7y1isERpqRRfLxQ5I8/djLnRA1TtVZaseQvWqfXQOgTDqd/obGEo69UVzXc +26OzUUBKc3ClFhwRTtE3gPa8ZGLy5dHTqhJ2wDJZ93Z5S2N4TtlUF4KHDcV7NKq+3Bp Y4cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3++UiM9Nvpex33sDYBqi5LO8w14qjh3qiR4geB26iKQ=; b=Du+R9OmAAw/J3gxzPZ+juN9S7GlGN2o1podOR/kjvsiVCjkvEDDM0BEkdgNYkB3U60 DmhD56XRZ1q8fQxw+QBtwnBfgVQgZUkslJ66yFEUwrlngDRVCJtSSkAXZuKaZ3Q8Uc3z p7eSfzJfgBtIlJN1EU0lNqW4eGxYpx/aa9G9IvO9tT+vIs9IWoViIqiFKI63D6VN7wNP KLJOV2AY9SKZ1LdbOrJSjoE2+chDTMjTSQGCF9Wf5SIZzkiGu19+63s9+SE7kBVLd/Q7 jX4XmZNGHoMWVmGy71cOuY67EY5F28mrD6zp+BhJ29rNvduBmKyfT5dghN2SSOX5PENw /FIA== X-Gm-Message-State: AOAM533PRxkPXjh7ZrqGqCAkDnUVeC+nNu0/IHyoZySaWV2VmCckWDeg X0SGKvTEQZfFQ5HsEzBGfdbYxJP45T61qg== X-Received: by 2002:a17:90b:507:: with SMTP id r7mr6408192pjz.47.1629248450220; Tue, 17 Aug 2021 18:00:50 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id r13sm4567422pgl.90.2021.08.17.18.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 18:00:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/4] target/arm: Suppress bp for exceptions with more priority Date: Tue, 17 Aug 2021 15:00:41 -1000 Message-Id: <20210818010041.337010-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818010041.337010-1-richard.henderson@linaro.org> References: <20210818010041.337010-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Both single-step and pc alignment faults have priority over breakpoint exceptions. Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index 2983e36dd3..32f3caec23 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;