From nobody Tue Feb 10 12:59:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1654809334; cv=none; d=zohomail.com; s=zohoarc; b=hXDu+2P644igJ7LXgI1sQNuXmAbtT3ntxJfSsW4i4e9BOWhTHULLPEkuhoVfkcRBpkycJzHR1W1+fpCWiRahbjTLfvRUI7VkISRFkP1a62zY7D5z3m/7KmkSdoS3rb468E+ykea/l8YeA+iiPrPFLQ56RAbYQnSLpfrdfnGV83w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654809334; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZvVhJ9luWKkwdZYjhq+lmyv/sw3Hp1aeF2mDU3UCb9I=; b=JShQq/AXJPkw2TRujrMCpHnn4k+hyk8rfOWcwvvAEkNrAY6oivmEQYvsps0ys2882gHGbxCbyEL+yWuYfwJW99sPk6U4pxdZz6GkpGnHt6Gc4eu2jEGm1G2jkpL4JftFbs9+wgx/Bnfz+mWzscC4l4zgJZiDa9xzOUaYdsTSilk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654809334530356.96511819513887; Thu, 9 Jun 2022 14:15:34 -0700 (PDT) Received: from localhost ([::1]:45974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzPV7-0003Ah-8i for importer@patchew.org; Thu, 09 Jun 2022 17:15:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzOmX-0004G3-0Z for qemu-devel@nongnu.org; Thu, 09 Jun 2022 16:29:29 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:36519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzOmR-0008Qi-Li for qemu-devel@nongnu.org; Thu, 09 Jun 2022 16:29:26 -0400 Received: by mail-pj1-x1030.google.com with SMTP id u12-20020a17090a1d4c00b001df78c7c209so379259pju.1 for ; Thu, 09 Jun 2022 13:29:22 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:839f:476f:678:38a]) by smtp.gmail.com with ESMTPSA id r20-20020a635d14000000b003fded88238esm7528139pgb.36.2022.06.09.13.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 13:29:21 -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=ZvVhJ9luWKkwdZYjhq+lmyv/sw3Hp1aeF2mDU3UCb9I=; b=DPulRIgojQCZy6t5X9+M99Rqkf7yq/DJOkd1kZalEiFRDXJog77c/qCzgTuJ08CDhh UNGE6JeqZudQ6EfcoWeEBglJCaVjq4f5yrZ9R4WWCNIWc5fcuevs+DiI8w+zzpeCopP3 OWDdxvIAwUqSjFVtFjfdyflfZdAbcXOIX60mx07rf5lQdSujthQfjCddAK3SYnykzLii EFdPnJOAw2FhPYCze5CEwFhWrZBGAqfr+xGU2eGgXl8JocGWVgEeWM/BVH6KlOZdCTNG kG2igrLOgkXxoa29sTMpBbjNqeVCZwWASDFq+VYjg6daRt5fKaMYR3TW/HGO2VpSs6AP L60A== 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=ZvVhJ9luWKkwdZYjhq+lmyv/sw3Hp1aeF2mDU3UCb9I=; b=5QYevd1rpA+q03jgN95vxSCfeRiMa9A9fjlaFd2q3dZ9hyCviWq1/oJZW2xJQ5pb3v AT7ekJsW27DuK3gW/RsbkQ/TOsvs7xX0YU9RKdJG51Qcd+xVyCQAiHUDTudCoOps/aZS wV/7arxcoMkx7CGz4Ds3g22ScztR/DGO3EkEQ5lmvbmVUkvmfVvslg86z8usDrek2NJA TBghcXzyGgZuaUpKqrRQL/A7w4Xy1EA6pXuXnGFjf49PGR8+xxwZHx8L3ptUxlca0m9r uUs0wxGa9ejjwdeRNXHNmNOIwgEDQvkqj6sXvnxY9AKbtGShFhf6LUlqnLGeR0IdTiO3 L06w== X-Gm-Message-State: AOAM533+6J2fENwmT8gvTg5whuY9OHMsFlpVQLsHVszz5KGiXKcHmEcI BmxVKgQC2Vl8CNb47KhWMr7wHQYryzdUvw== X-Google-Smtp-Source: ABdhPJye3YztWSG6SnWKnZKXgTw4NoZz/leGXGiMdA/IJzHaqRUKxVO/v+fxYEsk1UWNJ1/P8DD0+g== X-Received: by 2002:a17:903:32c1:b0:166:3f58:c1b3 with SMTP id i1-20020a17090332c100b001663f58c1b3mr39938291plr.108.1654806561573; Thu, 09 Jun 2022 13:29:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 21/23] target/arm: Create raise_exception_debug Date: Thu, 9 Jun 2022 13:28:59 -0700 Message-Id: <20220609202901.1177572-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220609202901.1177572-1-richard.henderson@linaro.org> References: <20220609202901.1177572-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1654809335396100001 Content-Type: text/plain; charset="utf-8" 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 --- 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 a3a1b98de2..26004df99b 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -12,6 +12,26 @@ #include "exec/helper-proto.h" =20 =20 +/* + * 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 =3D arm_debug_target_el(env); + int cur_el =3D 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 >=3D cur_el); + syndrome |=3D (debug_el =3D=3D 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 =3D (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) !=3D 0; - bool same_el =3D arm_debug_target_el(env) =3D=3D arm_current_e= l(env); =20 cs->watchpoint_hit =3D NULL; =20 env->exception.fsr =3D arm_debug_exception_fsr(env); env->exception.vaddress =3D 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 =3D is_a64(env) ? env->pc : env->regs[15]; - bool same_el =3D (arm_debug_target_el(env) =3D=3D arm_current_el(e= nv)); =20 /* * (1) GDB breakpoints should be handled first. @@ -450,9 +467,7 @@ void arm_debug_excp_handler(CPUState *cs) * exception/security level. */ env->exception.vaddress =3D 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)); } } =20 @@ -489,18 +504,7 @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uin= t32_t syndrome) =20 void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome) { - int debug_el =3D arm_debug_target_el(env); - int cur_el =3D 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 >=3D cur_el); - if (debug_el =3D=3D cur_el) { - syndrome |=3D 1 << ARM_EL_EC_SHIFT; - } - raise_exception(env, EXCP_UDEF, syndrome, debug_el); + raise_exception_debug(env, EXCP_UDEF, syndrome); } =20 #if !defined(CONFIG_USER_ONLY) --=20 2.34.1