From patchwork Wed Sep 4 11:21:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 172919 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1093650ily; Wed, 4 Sep 2019 04:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsbd2tXCxn8LZhAHZHwWlrhO1xeXKnyCSoK2ZxGsgpmdKnNorZ2t8wso5wugHhWx21Il1Y X-Received: by 2002:ac8:4757:: with SMTP id k23mr10775259qtp.40.1567596240813; Wed, 04 Sep 2019 04:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567596240; cv=none; d=google.com; s=arc-20160816; b=h/8vMH4lQgO2bfYm8Ncc9HwGnWTD2t91FxkA1O9wV2b0/yaLPhLABKQN/TaPGkINwD fKidCXlvy1Q7Gqwu7PTWA+nuOTxAodaR+e8897UKF5bckk578YHR4VY5a3weusXB0Mmh 8uBDxEMIJfYQ2mlRKt30j7X672fi2JlAYFnUPOm/UbdtqUhyRP1ZaWRk69MMEtchyafs L+2wD2KrwMuAcTscM4mjCIiADko2FhLU9qiNelO1hKiOeBigIxuygpWlO2Aye5SKOza5 /IF0DW5PX8mVcOa18rJM4/8b3dqFVtRrAyDAy86KFEoVl+KtN1pdUyljzUOZBy26iZuC X7ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=9Ge+XWvDG5sVV+m6AqlxOZT4JsJcjtpuvEGkiH2jJk8=; b=kQBX5g6TQGt7sawQWfM1j9sh7gJHQm2AP4Hb9f2KfmavcFzkk9NxpRzE+FIRuyRjdr hopwJRuAIln9RqQ5Lmu42YGjUlpBjdHKSNvCvKO1gix6KVPLJP1B24t/2H7fpdkso8X/ OVuzjHJ4wGmnaJRnin49yO/NeEod20WgURHCGp84csrGsXnjGX2Rx231AH32rhnkNHez 6lrzI9VHytMlGnMHdgkXixKDOKHIuQZQlDqjqsrfaVqfYabjTez3mISAS28NfxjBZ4du DjVp1Bu8P+HA59McceK2SOr6bSLjH2mgF3ix98ycHDRaythdpmC/Q40omwR6lRTuDsbd zaaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O6FI0Ztt; 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=fail (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 j3si3813928qtq.103.2019.09.04.04.24.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 04:24:00 -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=fail header.i=@linaro.org header.s=google header.b=O6FI0Ztt; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5TOK-0001BD-B0 for patch@linaro.org; Wed, 04 Sep 2019 07:24:00 -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) 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-Received: by 2002:adf:a382:: with SMTP id l2mr46472685wrb.194.1567596070494; Wed, 04 Sep 2019 04:21:10 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As for the other semihosting calls we can resolve this at translate time. Signed-off-by: Alex Bennée 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(-) -- 2.20.1 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)); } +/* + * 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 != 0 && +#endif + (imm8 == 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 = imm8; + s->base.is_jmp = 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, uint32_t insn) goto undef; if (cond == 0xf) { - /* swi */ - gen_set_pc_im(s, s->base.pc_next); - s->svc_imm = extract32(insn, 0, 8); - s->base.is_jmp = DISAS_SWI; + /* swi/svc */ + gen_thumb_swi(s, extract32(insn, 0, 8)); break; } /* generate a conditional jump to next instruction */