From nobody Tue Feb 10 02:54:55 2026 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=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1568388274; cv=none; d=zoho.com; s=zohoarc; b=ClfzBA55xCvpwfTdBs8oUMCdjg3HplZB89qsImZ6+F8Cv0Q2lRf8dBObuEDZrf+qTqP4NBEwN7IiErJXFXY9avV3jeweTRuzLDi7+N24J5TxSrXjkAKIv6Eg2MaVr5Y4/b5TjCO2076Y3PBXZ3Txo5ze0Of5Vb/OLEEWpvW1Zm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568388274; h=Content-Type: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:ARC-Authentication-Results; bh=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=EP+BYFo/Hlngopc0h4alc/oHSSRB4wYqeYUGrU0WcA2+kyPCikgu9gZEiOp5fjNcQIyaw/krAwutnWyBDrzJcEED1fd5vQLX1E9dUDoPHc5BGVSoe/epwETDtrPUZW6QiLk60nJ9o29CzEzoICZKMWk3bzdTFeWyJwQG3Wy0yT4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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=fail 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 15683882749477.928613929210087; Fri, 13 Sep 2019 08:24:34 -0700 (PDT) Received: from localhost ([::1]:45162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nR3-0004ju-P9 for importer@patchew.org; Fri, 13 Sep 2019 11:24:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52073) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8nLW-0007d1-Lk for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8nLV-0000JY-DN for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:50 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8nLV-0000Im-6n for qemu-devel@nongnu.org; Fri, 13 Sep 2019 11:18:49 -0400 Received: by mail-wr1-x429.google.com with SMTP id l16so32398942wrv.12 for ; Fri, 13 Sep 2019 08:18:49 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a16sm2769685wmm.36.2019.09.13.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 08:18:46 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9D63F1FF8F; Fri, 13 Sep 2019 16:18:45 +0100 (BST) 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=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=qUzwKAeU+Jx1kEUMYqjScAm/evx7NJWNTK0yla7o58SjttUOAqZmHCtcZJbc71eSVv aQjQi+A/5IJygAQZ09Kj7xJWCLliRmUFKshf5hmnFnbTbAnPQdP8jeodrZ6YiJ55QVS+ peVPVqyVJMSTsbHQy5fY+OW8j+TiBmnD3nwbjVyHfI42BdbqLHMW422fd5c5ADbJCGqj EAVezv6QeWxoWHKAqttKKRd0tTb0/q/89wXI3HJI8rDnZBKClCzImZKxqvYY+J6MpK4l Q/DQABGLUSd/ZUCtksFMSd/+nu39mTgh6X1LOgvlM3zrKlbZKVPsGbL2AQI9Co6cOB1F AdZQ== 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=Rhh9od3jglb/e8p3pboZpBtMsu6c6uuGIYDm01cfBo0=; b=g/qEqwmOEWcl2TNjFJ9J0epD6MbckOLmvUeeBv+36gdye7xvQc9e0VjpapRO/tFDRn Q58/ILMZRT8PsKRSOnLK3J7pFzMtRlF8IsY3TVj0ASqFygXU8/wOQfubL+qZaq5fdbSY SCRmweGcUH6OReGv9FWRkoBGV9vqJWlRajJ5msfhYsp5xq8XxlU2zde16n781IljCzxa fSszX4N121KbOEvlkqEAtGfZ+SQph2Ns64jHoksCnrGrmM71S6mq/GSUuUU0iWYbZV1Q pRlGpnldsGWTR2oyz7NlyxA+K7QLH9B2mpWTcyzCiRiroJpqvFRYKS85yU0lQYY/Pmb0 2vsg== X-Gm-Message-State: APjAAAUaLKk/DNOOdv4KoKSEmnGztstDbw/gM5LuE5GcNmKcFVe6xkpz PeP92hJ6l8ODRMCzusJgffm8Vg== X-Google-Smtp-Source: APXvYqyWhhlLW4A4C1CCoIVflvc0topuiUn6ARO5jOSFKddC3qCwWqurSO6o7V7F03owxRQ8R8b1Vw== X-Received: by 2002:a5d:548d:: with SMTP id h13mr2242639wrv.215.1568387928086; Fri, 13 Sep 2019 08:18:48 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Sep 2019 16:18:41 +0100 Message-Id: <20190913151845.12582-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190913151845.12582-1-alex.bennee@linaro.org> References: <20190913151845.12582-1-alex.bennee@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::429 Subject: [Qemu-devel] [PATCH v6 2/6] target/arm: handle M-profile semihosting at translate time 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: Richard Henderson , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 --- v2 - update for change to gen_exception_internal_insn API v3 - update for decode tree v4 - use !IS_USER v5 - return #ifndef CONFIG_USER --- 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