From patchwork Mon Sep 20 02:45:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 514297 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1669888jao; Sun, 19 Sep 2021 19:50:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSFfCJcW4pIdIKNhb1Ti/FvC0bh/PQQvYt1BBcI/jKqJw0HBoM64T+1x3h7ac+cDxL4t+y X-Received: by 2002:a05:6214:146d:: with SMTP id c13mr23108683qvy.46.1632106252712; Sun, 19 Sep 2021 19:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632106252; cv=none; d=google.com; s=arc-20160816; b=WYKrlGn7PoldtzM7lqAu334SVH21l1/BASfj6+i/wdTQjDDJA+qrlzDj15Rz2U/MbE +vJeSGj6oYi5FuVR9xs5q+Z4afcwIE8XV2eNelwK10zM/DRi/EjTPSyWs36aJWVbWWw7 f4qpu0fUJztf84Npqni1ai+1rg2CfvLaWYBaxKfOhCLMTWEuXA2b/5Zwo1QSaMNusZDi XmgZcCAvLJpdYhj8Su6jqN6olBzbuVOO6F36D9gmGiCYLRUD9LAoWWnCa26hrfakfb4y 4/X8X83qLcT9dBKGsSwRTLF/6jHoW+uoWHZU6IH5lXve1+Ya9PNNQlv0keB2xnOIzVMm Owjw== 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=1GwQXaikJPOnXJQIMQ/JzNg2jCKDE196b7cKL2erVtk=; b=htp8VhUV+atwFpZMDcfkSrq1QoXe/feC3axKhUQx9fVxC25/V+PmEa2Wd7Xxzc2z0f 67rB617RqcvCZb6rK2X8JTbXY9hhYbF6Gmjl2CGjiyesyOPd3GIaXFPTt0Jd5CQpgCSW 2xq/mYjwfI26ilzlq6+lOb1mDIrzxgGVSLytYdpdmVW1+Y2L7K42nLdVtpUmpCwQd2tI 9RKkUk0x497g9JbClOx9UGOrzvvLPJxXMDzOZhuK1p3oKW0AN7xXFeO1qDLggoeoTZTk KuYN2MCeibyJPGgMQZcbp8C1F9fVvg10AtfC1auIexidu7p22buSKXtVf/HXB4GTpBrC ou8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=b59t+xSI; 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=fail (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 bm40si3690166qkb.51.2021.09.19.19.50.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Sep 2021 19:50:52 -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=fail header.i=@linaro.org header.s=google header.b=b59t+xSI; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mS9OO-0003OK-7G for patch@linaro.org; Sun, 19 Sep 2021 22:50:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mS9Iw-0005DK-Gs for qemu-devel@nongnu.org; Sun, 19 Sep 2021 22:45:14 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:33738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mS9Iu-0008Fr-L1 for qemu-devel@nongnu.org; Sun, 19 Sep 2021 22:45:14 -0400 Received: by mail-pl1-x62b.google.com with SMTP id t4so10114338plo.0 for ; Sun, 19 Sep 2021 19:45:11 -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=1GwQXaikJPOnXJQIMQ/JzNg2jCKDE196b7cKL2erVtk=; b=b59t+xSIgNEcDZu1q+PD3N4Lxi2N0VDrWDmYJ6T3JxH+8+sSykxh7as3gGkZ5tSXo/ /hona2CR2Ecl8Pg3dh6TY2YfjGwPUv3NDWUDXX3/3baPw9hIlRwb59imAtzXyxO6W0ch 0AMMdPzJ5u/WhVnLK/lMi6ip1PkaAM9fhAk3z6TefBbeiRMEh31vKHKRPaXcgIkANHJf +b9Clk6ncLvPicZo5LxJS3kKdv4HPnNyKcfuXnE2Z/Mf1am0VPVf9bIxytG7qP3mft80 vvLCQgguUq5tv49qHxJMitnESN+bfNvCTfNHMf/VeFOEa0j0sQODWNY53vVIM9ta5KHj FZJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1GwQXaikJPOnXJQIMQ/JzNg2jCKDE196b7cKL2erVtk=; b=xAXIicPyu2UmOvdLiVEuzFh91+MJ+kmgrMWMIoMTuto3BZSMi/zObUvOwls27tLuKG XIHRXVUFR9Pxvi9jjmsHcCA5WsIM3kfFG16xmu8X0WzGUibGy4mughKtM5Eu5y8uZqn8 y0nqeyI8b6cVk60IrCWer/tnjl2tr5NPL29Hl/7oApHHI109HeXOu3hy9J3Ct6fHi0Uy RCCcJ8a3NHC492Dd8OUAgNkTQEyyColwGk/qFemLjCiKO6n17weYTmtBQ8S2FkdHnb45 ZFOoFd4D2MLtGylgdeC60ymhJWADxtbcajixe8bgaU9zqMjq7f27KtVc8OBkc2jmxJ4t jI9A== X-Gm-Message-State: AOAM532kRLcwz3sAP0cbO5T4kZZij/x58YhC50qH7ro+/+Jyij+NXAr3 GwVXP/hOVXgWhgemsu5HUZDOIf7qrCAkaQ== X-Received: by 2002:a17:90a:19d8:: with SMTP id 24mr26935696pjj.57.1632105909850; Sun, 19 Sep 2021 19:45:09 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id fh3sm16164767pjb.8.2021.09.19.19.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 19:45:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 5/6] target/arm: Suppress bp for exceptions with more priority Date: Sun, 19 Sep 2021 19:45:03 -0700 Message-Id: <20210920024504.625965-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210920024504.625965-1-richard.henderson@linaro.org> References: <20210920024504.625965-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: Peter Maydell , 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/debug_helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) -- 2.25.1 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;