From nobody Thu Dec 18 22:22:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.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=1569603354; cv=none; d=zoho.com; s=zohoarc; b=M/yTra3SDQsu6fw5kVjGmbtaC1+LvnhkEXD0sV0a2yiCHU93Kgl4O/6t/k9hofnHdhQmCmiSbZoONB0NPcvC7upDnCfcGTDgqxpogIh0YEIKHnRYPzcm0TKw12Coz62d1mOcDMZTxp2g2sSuGQHgm04jGyea9HcYf5E9k42myZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569603354; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=lMzpaWj77iIcNxSlT3zcE/i8ZeOFrgVR+n/jrGwxbAY=; b=F+wCBxTMNWUsMKuiJQnljd7CYCeu+yUazu2XV8wlkPenRKGsXeNbPXmmSRTSYfp4ARSAKPezExkjN1sTd+9jRgBX12h930To1kRhmvEDDweZLrQ3Lubjjn0y08AHKFHZowWPruwswV42rub7sl0l4FJUwes8Y7vYr0BJdx6pOjw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156960335454891.17282192749929; Fri, 27 Sep 2019 09:55:54 -0700 (PDT) Received: from localhost ([::1]:53654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDtX6-0002C6-E1 for importer@patchew.org; Fri, 27 Sep 2019 12:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51177) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDrSY-0002Rb-Lu for qemu-devel@nongnu.org; Fri, 27 Sep 2019 10:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDrSW-00087o-42 for qemu-devel@nongnu.org; Fri, 27 Sep 2019 10:43:01 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:37221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDrST-00086e-V1 for qemu-devel@nongnu.org; Fri, 27 Sep 2019 10:42:59 -0400 Received: by mail-wr1-x430.google.com with SMTP id i1so3141963wro.4 for ; Fri, 27 Sep 2019 07:42:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id y12sm2874539wrn.74.2019.09.27.07.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 07:42:54 -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=lMzpaWj77iIcNxSlT3zcE/i8ZeOFrgVR+n/jrGwxbAY=; b=urSb5JvZE57DJPDUJFtehYkhAeRWzsC5ugRfpWdJbCpXKUiC45onVBfx228WsbHhDO bvBSFGmy9hSvhewBlvl/zRNbtMT3NcQ5lJLdzBx4kgRhRLiLutoJnHVtPibIzPoPdwHH oSRqWRdALo9w1LnQ6RY1Q2UaMmKnap81mE3BYjpKNnhAM+Wkt0CMog2x0VwKVIAGtQWu 6tDME4zoaCZF+6BMTNaufJ17ELll4fTXXfiC1dyHAALmw4MAh08WI/Qct5B5+9RYr9nb tcYah8/nYFhsqhZ79BneFVjUMT10t8Qn7ifQz377oRPJ9XLygH/L6vvrNB2ABjP1goCG Q9Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lMzpaWj77iIcNxSlT3zcE/i8ZeOFrgVR+n/jrGwxbAY=; b=lorHfcC0AmTZ4PScgXMTMNTV4WAP+J0yeXc6R2NTN0TPbpzzO2ZaRAmwx0ai0YCSjT AmAvUzcqCuLn1POccP4PDnqWPeDCunuEB6nlUfrVvGZkQt+XoD4OSFYVNJpgTJ9Rc9kn /PqDgRWWuGl8EfushhK/x+xHboFOR6d6NLwrZqkxtFUR6K0ugKiNqikeJWQtiesFIeJm iJJROwMe5ovFtg/uE5HBRAGYa8/tbAsMH/kSOtBXOIpFcMXN8EG01o1++wYL8DoOxlmb JFgIgA5na1YJulf4yGUGu6JLa6DKkV2LlAbUfnXJ3/dpB9pXxEfiMxvDYBwcxYDpHy0c oXvA== X-Gm-Message-State: APjAAAWZDHDksSDXjiaqF6JFh3/zPGIsePrXJtBbkcMMEBquN5lX/Rij QzV+rUE1fxOAdazwX5PoP9+YvOs093swOA== X-Google-Smtp-Source: APXvYqzWj9GInlnHDa5/cnRfNjePLHBKOUGa+f0sh5AGNzGlzROKAwW7311zTCVlv2ThFvOtyEQySA== X-Received: by 2002:a1c:cbcc:: with SMTP id b195mr8033109wmg.80.1569595374584; Fri, 27 Sep 2019 07:42:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/9] target/arm: handle M-profile semihosting at translate time Date: Fri, 27 Sep 2019 15:42:43 +0100 Message-Id: <20190927144249.29999-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190927144249.29999-1-peter.maydell@linaro.org> References: <20190927144249.29999-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Alex Benn=C3=A9e We do this for other semihosting calls so we might as well do it for M-profile as well. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-id: 20190913151845.12582-3-alex.bennee@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/m_helper.c | 18 ++++++------------ target/arm/translate.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 884d35d2b02..27cd2f3f964 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -2114,19 +2114,13 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) break; } break; + case EXCP_SEMIHOST: + qemu_log_mask(CPU_LOG_INT, + "...handling as semihosting call 0x%x\n", + env->regs[0]); + env->regs[0] =3D do_arm_semihosting(env); + return; case EXCP_BKPT: - if (semihosting_enabled()) { - int nr; - nr =3D arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0= xff; - if (nr =3D=3D 0xab) { - env->regs[15] +=3D 2; - qemu_log_mask(CPU_LOG_INT, - "...handling as semihosting call 0x%x\n", - env->regs[0]); - env->regs[0] =3D do_arm_semihosting(env); - return; - } - } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); break; case EXCP_IRQ: diff --git a/target/arm/translate.c b/target/arm/translate.c index 34bb280e3da..b5272119330 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8424,7 +8424,16 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) if (!ENABLE_ARCH_5) { return false; } - gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); + if (arm_dc_feature(s, ARM_FEATURE_M) && + semihosting_enabled() && +#ifndef CONFIG_USER_ONLY + !IS_USER(s) && +#endif + (a->imm =3D=3D 0xab)) { + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + } else { + gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); + } return true; } =20 --=20 2.20.1