From nobody Wed Nov 12 03:39:52 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=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=1567596298; cv=none; d=zoho.com; s=zohoarc; b=SueiZKhZ6L2CtJNViPxksk5cZZ/IUFIbS0AvCgKELKMdMSWHbPd18eK04NtRraxZfI+W5xI6ZJpdRC+3WeF8jzURPAJZEOJUC8FRN9hbjkqm5tHzSZgAHUdPVxDXThv3vI1uJWY8V89m+fPRlp2+7aqWX9oGBWBudRpTP7lo8TU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567596298; 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=9Ge+XWvDG5sVV+m6AqlxOZT4JsJcjtpuvEGkiH2jJk8=; b=T7ZvWY9GMGi4xg4v6Z31AnLy/xlKnrJKxWfuDA2dHviM5bMmygulL7Xknx8LmBi4psymkVbLitQdrBRPdFIYFUyi9kpJ96wSB26rZkbGqClobxeE0i4OQCGXQLmBrxb4Brt2CJdQdQEZaVBEIRv7XwTwCVSZ6rrZsvjrTKXh7Lk= 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 1567596298137482.77383407435127; Wed, 4 Sep 2019 04:24:58 -0700 (PDT) Received: from localhost ([::1]:56270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5TPF-0001xu-5n for importer@patchew.org; Wed, 04 Sep 2019 07:24:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36451) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5TLe-00075u-0V for qemu-devel@nongnu.org; Wed, 04 Sep 2019 07:21:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5TLc-0007CP-E4 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 07:21:13 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:35645) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5TLc-0007Ap-5Q for qemu-devel@nongnu.org; Wed, 04 Sep 2019 07:21:12 -0400 Received: by mail-wr1-x442.google.com with SMTP id g7so20864871wrx.2 for ; Wed, 04 Sep 2019 04:21:11 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g3sm27729634wrh.28.2019.09.04.04.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 04:21:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 388951FF8F; Wed, 4 Sep 2019 12:21:09 +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=9Ge+XWvDG5sVV+m6AqlxOZT4JsJcjtpuvEGkiH2jJk8=; b=O6FI0ZttUEpi5a4oug0HoQfV6DRGdNK+GZszcdX5dQF7NiZt0pYxYhxgVbqMM7szEh frWqJBi/TEbAPrEojO2s3c2R1Xly5GoLYZMl8KpSkwPBxWnPH9V5DCzPc5067bijH+7k 3pqZnv1W3FkdEVv9Nl3fshQRD/btVt+4ODDYxm5uxoY4SfGFzp3GNEweO5rZPOWyamXJ /pcBveE8CUAS4k8IhfBL+5Z77kfRE4WXsXK622CTPiOrHxuOt9dr1WX5qcyiR9NB7kq6 jDNpOdas04QvODYmb/QNgcsawpvCA/hl2B8DL1swVHIbhPO9f5yXIoXd+dqMqHrfAUYc Xz3Q== 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=9Ge+XWvDG5sVV+m6AqlxOZT4JsJcjtpuvEGkiH2jJk8=; b=I9/X7Aj7VFV+g6sp4eH2hNUBxe0sXIkFMqL85WhN9053SfAIhl5jett1Ez6/NrvFhW UOuPkvbfqxwVcMH/GVfQLzUM20jg++7j407dsMnPvzzS+JL6djWhM2QyEkIe7FGSKLXV dxzPYDJnxPHsouKWkzpAJtzhmEbIU83lROkBTK6Mxs+hnogWrURkgDl/c+umQ+s58U3C FDV6nqTZ2dSA72eDhSjAcAQUdBWSSY0zXbpdomISPuCCLzAO7TSRYZYm4Zvl9b8ckHOL UHrMydPWJmXT/BGPKIbXkQwXdiXFscvMLbD00qx9sb6mgjqs8MnPDolh39k3Yy3op3uZ qULw== X-Gm-Message-State: APjAAAVjrCP5Z0Z9lKAFtKyrO/oEzrtREXjZtiXRDaXKu/JhIRdhIhEx mjvTtoDxAWsXt1jabcMy8lJ6JQ== X-Google-Smtp-Source: APXvYqwlKadfVsjIOAoPStal5zo8aeWOPbDSSAco0c4AsV8rkYUNhaYEksSW8u9OyBsklS1yC6nylw== X-Received: by 2002:adf:a382:: with SMTP id l2mr46472685wrb.194.1567596070494; Wed, 04 Sep 2019 04:21:10 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 12:21:05 +0100 Message-Id: <20190904112108.2341-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190904112108.2341-1-alex.bennee@linaro.org> References: <20190904112108.2341-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::442 Subject: [Qemu-devel] [PATCH v2 2/5] target/arm: handle A-profile T32 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?= , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As for the other semihosting calls we can resolve this at translate time. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v2 - update for change to gen_exception_internal_insn API --- target/arm/translate.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 816d46b2205..673994ed1a1 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10949,6 +10949,24 @@ static inline void gen_thumb_bkpt(DisasContext *s,= int imm8) gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true)); } =20 +/* + * Thumb SWI. On A-profile CPUs this may be a semihosting call. + */ +static inline void gen_thumb_swi(DisasContext *s, int imm8) +{ + if (semihosting_enabled() && +#ifndef CONFIG_USER_ONLY + s->current_el !=3D 0 && +#endif + (imm8 =3D=3D 0xab)) { + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + return; + } + gen_set_pc_im(s, s->base.pc_next); + s->svc_imm =3D imm8; + s->base.is_jmp =3D DISAS_SWI; +} + static void disas_thumb_insn(DisasContext *s, uint32_t insn) { uint32_t val, op, rm, rn, rd, shift, cond; @@ -11700,10 +11718,8 @@ static void disas_thumb_insn(DisasContext *s, uint= 32_t insn) goto undef; =20 if (cond =3D=3D 0xf) { - /* swi */ - gen_set_pc_im(s, s->base.pc_next); - s->svc_imm =3D extract32(insn, 0, 8); - s->base.is_jmp =3D DISAS_SWI; + /* swi/svc */ + gen_thumb_swi(s, extract32(insn, 0, 8)); break; } /* generate a conditional jump to next instruction */ --=20 2.20.1