From patchwork Fri Jun 10 16:07:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 580605 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp1890349max; Fri, 10 Jun 2022 09:15:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjdxUTSPfd5Et1rBmMuPQRNTzYp3z69NYdy6Ji4986fhBM9bGaBPxxCFqytYal9sy6ZtDn X-Received: by 2002:ac8:5b50:0:b0:305:1a53:48f2 with SMTP id n16-20020ac85b50000000b003051a5348f2mr4217864qtw.100.1654877752851; Fri, 10 Jun 2022 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654877752; cv=none; d=google.com; s=arc-20160816; b=QCFlQdI2a0QToeDxvQV/MNP/tA3xTlqRvQBsa5VH3MWgXAKAQRecNGKzfDj/S6rIor Mb51DeGhIB0XrMwsRhX2nXKyfbt0vdvjQ++rW4SaJXPiFCwcgwRBQLe/9eOjUAYBUWhK EuS9+nxv2vTHvG9X6Hk2If0hhkYQO2Cpt/DhNY9V7QMoKXGZJYyVN9TcuMqo71ziaSra 8aGw8n+Fr7I6AirWK7RtorXKU7mCLOm806nmzLmJc0hjsQO7xxw3htr6ILHHj15VntJn 0LJA/Csh+akUwmHxpO3fr1A3smZ8eLlQVscNwB2eU6WmWwhHs2njvWKy3YiPiMLB1oYD x+eQ== 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=7rZ7+K14fAta0tvCAh13EOYsic/ydHpR4N0fIgccYaA=; b=UfmekJe/gj5YmsPH+4OIsmMVElVA6FhPlAkUGfoNEPpRWurat+1dpxkANDRs5jMt6p jar6jAD4UZOmPYWZRBibmToslrSYrgmJIkRJQt4Egp6KuKohDYihSp0bOWn9X5Md/vl4 0l5MKrYTWdmn+oCpbK+n8UgYm3cS63Z5SeM3CQe4Tm6j3VpGuJmHCk9cyKm129rGHYPt TnWZ6keFe3LYsO9awqZRowJJlyc4yWEHfUmuFnvpE/WJobzxTMrrGYI3Y7teHDJFuDSR 8Y1kGxZ5wi0jL82fG3Q5KL9BeG2NlwRoglqQi+ml2rTlkjGFIv1R3KHZbLWQ5AauuVwN fW1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GDcOLIgd; 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 bk39-20020a05620a1a2700b006a740f9b5a8si1901592qkb.531.2022.06.10.09.15.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jun 2022 09:15: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=pass header.i=@linaro.org header.s=google header.b=GDcOLIgd; 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]:42274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzhIe-00039y-BZ for patch@linaro.org; Fri, 10 Jun 2022 12:15:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzhBA-0007sl-O4 for qemu-devel@nongnu.org; Fri, 10 Jun 2022 12:08:08 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:37771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzhB5-0007Hi-Ld for qemu-devel@nongnu.org; Fri, 10 Jun 2022 12:08:06 -0400 Received: by mail-wm1-x336.google.com with SMTP id o37-20020a05600c512500b0039c4ba4c64dso1368072wms.2 for ; Fri, 10 Jun 2022 09:08:00 -0700 (PDT) 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=7rZ7+K14fAta0tvCAh13EOYsic/ydHpR4N0fIgccYaA=; b=GDcOLIgd5dFSqsSSbegchX5LpY6b9rY7KtaspYbvLPpGRXtMl8zf5qMCD9xOTthxVK CtN2aLwiNILNWm2V0PkA9+S6Ser9BsFM1NBq1oy0wVfM1dWhLrFNM3G/BHfYPfHCHHPf Upoe2hjz//wCQec+lSlR4GHe3H0GFYZJufbaru+PGQwkRqULE2j8w54Pl5tEqOw5cxn6 fGvsw6+Oj/hSe962U5Pghy8he1JeJ00s+PXfY1uxG9gt19DavXCHZGiaMgIeCg42p3Uk WPUjcT5EPqbumY/TkZEKUdyoGbZpVXX4BK6cixJRRQ88SJ5BStQW3AjaErMfgRe2+bEQ XVnQ== 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=7rZ7+K14fAta0tvCAh13EOYsic/ydHpR4N0fIgccYaA=; b=ZeGluuFYaLoj48YhzzjjWdU8qDoAAGrWLKCfqW9RbM9YKFRZbUQnbW6Ud3InJ9lE9q gDanXJxGWUsljUSxTl+GE/GTUyVF8mRVK+TkrBwpRAkBrawUiRd9qfShyfcdl6MF+owo pwR6j6qifNtx/fOx4gAV+qmlEnkmk29Tcm3Fh7899Oh4bXUz0D9yB2UpyFhVcBPdP5RH brldKorz7NWL0+F5W6iFp35VBUAGAqVU+jJtjJxdKl0yaTczJElzt37sDu6G2k5AuYqf 2DOaM01OzljhNK3322z+4/sPG6Ls4XDK6xnxcUsJDPlphpHh5U9zcOOWoedD/ppdhRhy Z0Uw== X-Gm-Message-State: AOAM531IG8Z9ThUh+X2lLBjfOoNOyVYsDGtE1hz2hlTu2Nr4Fy/aY3Sa 2yXI8tQi/suWTzC1KLw80g0jOcg1w1L0Fw== X-Received: by 2002:a05:600c:3555:b0:39c:7c36:573b with SMTP id i21-20020a05600c355500b0039c7c36573bmr448605wmq.107.1654877279074; Fri, 10 Jun 2022 09:07:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bp11-20020a5d5a8b000000b0020c5253d926sm14276053wrb.114.2022.06.10.09.07.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 09:07:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/28] target/arm: Create raise_exception_debug Date: Fri, 10 Jun 2022 17:07:31 +0100 Message-Id: <20220610160738.2230762-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610160738.2230762-1-peter.maydell@linaro.org> References: <20220610160738.2230762-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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 Handle the debug vs current el exception test in one place. Leave EXCP_BKPT alone, since that treats debug < current differently. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220609202901.1177572-22-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/debug_helper.c | 44 +++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index a3a1b98de28..26004df99ba 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -12,6 +12,26 @@ #include "exec/helper-proto.h" +/* + * Raise an exception to the debug target el. + * Modify syndrome to indicate when origin and target EL are the same. + */ +G_NORETURN static void +raise_exception_debug(CPUARMState *env, uint32_t excp, uint32_t syndrome) +{ + int debug_el = arm_debug_target_el(env); + int cur_el = arm_current_el(env); + + /* + * If singlestep is targeting a lower EL than the current one, then + * DisasContext.ss_active must be false and we can never get here. + * Similarly for watchpoint and breakpoint matches. + */ + assert(debug_el >= cur_el); + syndrome |= (debug_el == cur_el) << ARM_EL_EC_SHIFT; + raise_exception(env, excp, syndrome, debug_el); +} + /* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ static bool aa64_generate_debug_exceptions(CPUARMState *env) { @@ -418,19 +438,16 @@ void arm_debug_excp_handler(CPUState *cs) if (wp_hit) { if (wp_hit->flags & BP_CPU) { bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0; - bool same_el = arm_debug_target_el(env) == arm_current_el(env); cs->watchpoint_hit = NULL; env->exception.fsr = arm_debug_exception_fsr(env); env->exception.vaddress = wp_hit->hitaddr; - raise_exception(env, EXCP_DATA_ABORT, - syn_watchpoint(same_el, 0, wnr), - arm_debug_target_el(env)); + raise_exception_debug(env, EXCP_DATA_ABORT, + syn_watchpoint(0, 0, wnr)); } } else { uint64_t pc = is_a64(env) ? env->pc : env->regs[15]; - bool same_el = (arm_debug_target_el(env) == arm_current_el(env)); /* * (1) GDB breakpoints should be handled first. @@ -450,9 +467,7 @@ void arm_debug_excp_handler(CPUState *cs) * exception/security level. */ env->exception.vaddress = 0; - raise_exception(env, EXCP_PREFETCH_ABORT, - syn_breakpoint(same_el), - arm_debug_target_el(env)); + raise_exception_debug(env, EXCP_PREFETCH_ABORT, syn_breakpoint(0)); } } @@ -489,18 +504,7 @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome) { - int debug_el = arm_debug_target_el(env); - int cur_el = arm_current_el(env); - - /* - * If singlestep is targeting a lower EL than the current one, then - * DisasContext.ss_active must be false and we can never get here. - */ - assert(debug_el >= cur_el); - if (debug_el == cur_el) { - syndrome |= 1 << ARM_EL_EC_SHIFT; - } - raise_exception(env, EXCP_UDEF, syndrome, debug_el); + raise_exception_debug(env, EXCP_UDEF, syndrome); } #if !defined(CONFIG_USER_ONLY)