From patchwork Sat Aug 21 19:59:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501026 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp827302jab; Sat, 21 Aug 2021 13:07:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwgUvEorxfxQ2AdimgQrm/pPnBu7CtdTxEVRjPSCFPDugmymbPWFcV9jUDXsB/Hsn3bVFx X-Received: by 2002:a5d:9355:: with SMTP id i21mr1231784ioo.12.1629576426368; Sat, 21 Aug 2021 13:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629576426; cv=none; d=google.com; s=arc-20160816; b=n/PU1Zepq67o+Sbq/uwMwLlSnrBrQ6+onn+j/ZSpuL3Dk9bSNU5XOZtbdLXXUUWTte T4zIgN6iL21fXqYk06mxcsFsG0CGQoLZlpJFcrUw4PLuPx8qSGcDB9BAgjspHMQZ3rNF SVaGC3KnBULq7kn8PI7f6lwhNdbSPz6/2ykXDamz+8yewKb5f8X2EbnmClZ48jViVFaI LTDd8bcinkClMgtjE3WOdHSUP8wSxiecbWyy7Q6gPN4oI7c1Hgfo04OgH+TCCVkLJqOd 1UAQFYh7gZ74hhtZy19WaY3V3NSJXgBDGDfzZqdfcdupn4EUM3HPBgQndl2AAA65K4iW rI7Q== 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=jyjmx6dJlAZkeakh8uDBhf4OBANtwL2mG6Iow2I7JHtQjLRBMozJ4s0r88b6ijkCHW wJ+3JsO61b8rt7G8YOmLAQZI9Jejdfd5P7TSQ3XbA/G2ITFnbNmYIvML3Hns7QIBM56g L2n7umRQkOGQbCL3MkimtCknWkjB2iXV35otjijTCcljuRDc2LScblwDAf6srfi0BKwJ hrofQwSLMgebvzf/ZvHaybBGwo/6gdQ+9p/P0MQYBFpmZ3KOVboTFJhm+1yAEOcMPslL 2fOamFs+L5di34zYPAqve4oc+SbOL1gTy8Q5z28B3+1VCBHbzpeHGfy/jNi+CoPTFp9Z WswA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CWy0u4It; 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 q7si11387952ilu.111.2021.08.21.13.07.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Aug 2021 13:07:06 -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=CWy0u4It; 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]:55418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHXGj-0003bD-TA for patch@linaro.org; Sat, 21 Aug 2021 16:07:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHXA2-0002HD-2G for qemu-devel@nongnu.org; Sat, 21 Aug 2021 16:00:10 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:40512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHX9y-0004X7-6l for qemu-devel@nongnu.org; Sat, 21 Aug 2021 16:00:09 -0400 Received: by mail-pf1-x434.google.com with SMTP id y190so11739311pfg.7 for ; Sat, 21 Aug 2021 13:00:05 -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=CWy0u4ItQ1fMEI83X7OMtn0drKtEV8/2zb7hqU3BgWpKtZovNZU80UGL0Sne0i54uf BxT1K8kfL4Zlo9fcSACd1py78BetXDy/ZKjh5G+JK9hSQ3sR3/g8Pe2+WQtGANFOSWxf XsXlchc15t9nMOjw2HlFFpPPs7ZWUUVsYhJfoAQiIjFjVqVsO/vParXY6gbg/opafsch a5rQOnWUmIMUXE5kE2OC8N1pyWNsTnKUjiGbUC+pU1UcUGQfjqWD30D0h2whwtq8KALc ffMiaoXPvAhPbosmv292M1cfjxFBMuL4BNMLxRjnzfTeHFcucXS9+Z9mA6fobJ4iED2R R09A== 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=1GwQXaikJPOnXJQIMQ/JzNg2jCKDE196b7cKL2erVtk=; b=i3uIK1XomERr1hCInq68PAhbZxQ4v+TBt0m+JaK3yWdvocRb5tsszY/mmT9psnkCNZ zXHF6Shn+kNY4a1Kr9cW5enAlLCZtXc8Aez6hGN0XOtkjaHNIqZXpDJ77jgU/vld7/mX oDpnd25Z7+49d/G7sYQy+Jou/zR8lf5JjRwEuxlfWp56BW4dVDd0te2Hc76OzSXLWQjw 03YiY/qDeFa9oVhBRBJ+rRAsx4ZBa3bwT4K73of0Yjvt7IbBnMxho9gq7gyawzsWSRik Facxy9Z9vSPnP0GCODYnVOWLafVOtif80sBG0B9etrpkxb9mw1n4FjGpi48XHVdPFJWE Zx7A== X-Gm-Message-State: AOAM532aCa5EHsGQcJfyKCi/zP6kXJNY/12hs34tUepSQYSnSxcIuR4z yzof78mw9ogU/G/JEZiGmILh/uECi94hnA== X-Received: by 2002:a65:670f:: with SMTP id u15mr24513059pgf.205.1629576004541; Sat, 21 Aug 2021 13:00:04 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id h13sm12562257pgh.93.2021.08.21.13.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 13:00:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] target/arm: Suppress bp for exceptions with more priority Date: Sat, 21 Aug 2021 12:59:57 -0700 Message-Id: <20210821195958.41312-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210821195958.41312-1-richard.henderson@linaro.org> References: <20210821195958.41312-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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;