From patchwork Fri Sep 6 20:26:33 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: 173297 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1211104ilq; Fri, 6 Sep 2019 13:27:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz64xG/mq8Pa9yFMfuZjzwoIkD1CDyLACyNpN641Nq2Auc3LlaVCuQRbUYouvMvaaatTFXq X-Received: by 2002:a50:da02:: with SMTP id z2mr11744828edj.254.1567801647326; Fri, 06 Sep 2019 13:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567801647; cv=none; d=google.com; s=arc-20160816; b=z97wcMKMRiPrMCfjALjs0dNJWVuA3apBV43Lqs4OnGbqg1H7sNJkokLxlqdDEJIotU HdzkFryJFELm4uGe9YiDTbyZhIzxVatL35DIicxsZzCgta4A2zrNBnU2E7Yw1KwPGdCT 1EzS7tbeNAkARhNdlfmIp/uyj6ZSUQ/QT9w7r0mAPh2FAk+6LbzF4gUItgcrsNvUXbKZ 76iHIA5PLWKiJXetk+ntBFsZYMyB445svsZk9D13x5qVWUtqEU1Pl08/whZg/+cbUNgs ryD4WZAlahi+Zd6xh9twBrbGPY73MkIxXDAuK9fzLXMhC6WQENJ88bMXk/ko1Qo8q4Mu figA== 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=ZOU2dawRnEbn8gBP7FThkgEA/iC2qfVj+g99luazd38=; b=ksvCpIqekTUswAt6//bpQfDo88myHUfLE7mIdmo4oPiStGhNNVWbEyicDV49kMhowG ERY1A/7b5tSUp6VMHGGe61xq70PB6noyuUTy53nt9J5AdGw109C8iEaj2JAO4ZlvuZIl IS0ppg/Nc46lbJKiJooJN+20NZi/G8gfhojQpHAxOLss0PjVD/lxhR1qUV/Vq6h/VgX4 jv2Tz4cKOBGd64bY23aOgcrEAtqF6O9vK0DAxuxcaTqG6siynT1uvRtWmOYsN/cpzQdh qTIA0jrp9ilNBjDChC1U4LQCnHvh+BVsvMrUNqYL/mnm8VrWq8lO5TKn00KWFf6v7Fcu ek5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eBASGjen; 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 qh24si3571429ejb.19.2019.09.06.13.27.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2019 13:27:27 -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=eBASGjen; 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]:60074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6KpK-0003XS-19 for patch@linaro.org; Fri, 06 Sep 2019 16:27:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58079) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Kob-00036d-Iu for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Koa-0002RO-Ce for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:41 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44093) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i6Koa-0002Qa-6G for qemu-devel@nongnu.org; Fri, 06 Sep 2019 16:26:40 -0400 Received: by mail-wr1-x444.google.com with SMTP id 30so7798107wrk.11 for ; Fri, 06 Sep 2019 13:26:40 -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=ZOU2dawRnEbn8gBP7FThkgEA/iC2qfVj+g99luazd38=; b=eBASGjen2ZL2L4llBMfB43XePTKBBldIO3FhxmCpbQvf3xIyLMRS4WtGA4alGa+1VY kDhGv4vp95je7khBoW/IJDzfrMqxKIW2Bwfw9vheq21wM+tI638mdXs4x1oPubw0GLk0 jlb8/w3Unh6BKMn35MeTxTuEfkPchcuLN/EALq2g4J6mHksqIT8ZygBb4va6ElwKlqIc GMzE5jUeUQ3WIFaBHz3GfLJC6vimStaJxUEiN/emmK214PDWHr75FL3fHJsNzmd16Ko8 qCbUv/Kw1SD5in9G+PMwWHHOn2zCCamLPfJ6TSFJIBrlq/pQ5hsqLQ9OcIPxPNw/C3vt Aiqg== 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=ZOU2dawRnEbn8gBP7FThkgEA/iC2qfVj+g99luazd38=; b=GyAbLKYguuSBWL0C/eCVh54IcuG+n+H8ZizDzwzutiAXKItWLt44jAp+1Dl4TrGHwq A4HOxiEy0uzNtibwoUwhmIXVwXnQEa3fFKF6k3anzSg297cEYQ4Gn1th4v/VWJMD5ibs 2nTZ/TSlRHKUhyLkjzPjyMVUWaGAKtei8u1i+QYlo4x3b39TN8n50PJb8Yg2jyxaARZb fSzE9rrPqxPSwzd0jyvkfIyqAV0o1sZOoIRrZwwsYbvitlbE0gqu3fQbP9P7wwkeCJZz DUOndMVcWf+emJG2AlFRaLyBhN56XwFAjKnpimu3SImJo4GY4dyAsifZp+ejRYakWrmo BTng== X-Gm-Message-State: APjAAAUwfsAJugUx2DdNKoAOcfDUTjrckxtE3Chg8k94zdkNbCkZglVH pAPVy2vSiC0SqHu7CGokAVgW6MDr7jM= X-Received: by 2002:a5d:49c3:: with SMTP id t3mr9007638wrs.151.1567801599051; Fri, 06 Sep 2019 13:26:39 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e3sm9315586wrh.12.2019.09.06.13.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 13:26:38 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8CC581FF8F; Fri, 6 Sep 2019 21:26:36 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 6 Sep 2019 21:26:33 +0100 Message-Id: <20190906202636.28642-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190906202636.28642-1-alex.bennee@linaro.org> References: <20190906202636.28642-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::444 Subject: [Qemu-devel] [PATCH v4 2/4] target/arm: handle A-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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org 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 --- v2 - update for change to gen_exception_internal_insn API v3 - update for decode tree, merge T32 & A32 commits - dropped r-b due to changes v4 - !IS_USER and !arm_dc_feature(s, ARM_FEATURE_M) --- target/arm/translate.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 6689acc911e..d7ee4f88ace 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10219,14 +10219,22 @@ static bool trans_CBZ(DisasContext *s, arg_CBZ *a) } /* - * Supervisor call + * Supervisor call - both T32 & A32 come here so we need to check + * which mode we are in when checking for semihosting. */ static bool trans_SVC(DisasContext *s, arg_SVC *a) { - gen_set_pc_im(s, s->base.pc_next); - s->svc_imm = a->imm; - s->base.is_jmp = DISAS_SWI; + const uint32_t semihost_imm = s->thumb ? 0xab : 0x123456; + + if (!arm_dc_feature(s, ARM_FEATURE_M) && semihosting_enabled() + && !IS_USER(s) && (a->imm == semihost_imm)) { + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); + } else { + gen_set_pc_im(s, s->base.pc_next); + s->svc_imm = a->imm; + s->base.is_jmp = DISAS_SWI; + } return true; }