From nobody Tue Feb 10 12:13:34 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=1567020296; cv=none; d=zoho.com; s=zohoarc; b=L8FlBQOrdE/Z2kgJoAVgJ6/QMFRevYsGG/XcVmUF0+WfzTJZZSWV2ZZhacVlGZ480Na4vyZ633uRSvoX6o5Osr8GIpclAef3hjpU2ZiI+dcsw8nZu8mYubTcCHhq9bDO+MmOwGA+vUDM5NFf377VvJgkCt9cAzfY+0Shv9+YUag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567020296; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QCVrNyP4aQ0jX7CvYJg0KqtkiSJELZNM0Q5/bhu0tlI=; b=KP5Ny6xs1oXlxSoco0cpl526kkolI/y49vkj8kD+Opt+zk79zaiU27sIS08yUQcwcg/IWgWHwuUa5GxEPMY4dbkcayxXnyMq0tbLvK+9dewSDhYGedPFA3zX4HL0vWZGIyz1JXXPt6bCA72YPVvKOI0gk3hd2RnVkDjLC613xWc= 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 1567020296873254.6100166251823; Wed, 28 Aug 2019 12:24:56 -0700 (PDT) Received: from localhost ([::1]:41208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i33Ym-0005Fw-Ni for importer@patchew.org; Wed, 28 Aug 2019 15:24:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37770) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i33G3-0003NY-9H for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i33G0-0008UP-Cf for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:26 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:38451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i33G0-0008TA-5u for qemu-devel@nongnu.org; Wed, 28 Aug 2019 15:05:24 -0400 Received: by mail-pf1-x444.google.com with SMTP id o70so392086pfg.5 for ; Wed, 28 Aug 2019 12:05:23 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id f27sm2967944pgm.60.2019.08.28.12.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 12:05:20 -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; bh=QCVrNyP4aQ0jX7CvYJg0KqtkiSJELZNM0Q5/bhu0tlI=; b=L9ub4gFlnNTqqoViMGHLAPW95jwbeBVCJHQKC9zmbl44JbKBUXlk+U//kLRnbD7ueb MKFRR9CgFUJkuzs9ndYooe9WfLqDKc51fPjs0R3ilQ8W4cdGCRpsrv/7XB8SlAouY11T htYvPnUyfPdrj5g/IuBSu9s9Y4MtpvfDH9ghirN5LqjEbpSFyTj5X6AL71QeYO6VDBUY 1uTrGJWgsY+2TidYV6c19vgxUBdclHrQY2glQZaTYdS6gmggWl2a10i5tbNmHQc+Q7y+ YNOc9WIZPjtHUbTbt9OelhWuIOsa6E1JcGs78sZu6RAFwXeDCZoLbb8Glijh750CMWfD yRiQ== 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; bh=QCVrNyP4aQ0jX7CvYJg0KqtkiSJELZNM0Q5/bhu0tlI=; b=t0vY/HC7u6kOZutaW1Y+qE4KTC36wLNP4Cj27FERKG+jXZ6LASpMPbzYQM+FOxor2q xjdCHfCle6HFZrcgBAC7w7/vanyvPicIJD+rsCDOQamNVFXsExsf5gOMz5RaBiQYVSIJ /txM4OSZTeI7nq9xu5ycODTI9OPU//LukppxCrtAtmS6EocIc4blRn9PsueNIrVP0fKS QxbQyriPkNvI9gfApUU5Pl7Ey5CamFJwBrYF6AL0B3GMpCCbhm9F3J2VakVOu8zasFjI GRJO24fcdpFFh/p41JIxS99z5k/j3njn0SUliXoQTwXV43isZOLj1544jG2PVOfTvfns +HhA== X-Gm-Message-State: APjAAAX+I1uTvmLJtE2VnDLYDoE67eYnCZg3m3jaiZE1lUXojysScKNr +1X9s8tdp+sMEcUtvJ139CwxhGPPfgA= X-Google-Smtp-Source: APXvYqwiZ+NvHZReUAqRyp3P3GxdXs6Xq2kT29kecjwWXeJIOUuozlMU8CvVjm6OY4XLPyjALmFgnA== X-Received: by 2002:a17:90a:342d:: with SMTP id o42mr5916292pjb.27.1567019121835; Wed, 28 Aug 2019 12:05:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 28 Aug 2019 12:04:04 -0700 Message-Id: <20190828190456.30315-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190828190456.30315-1-richard.henderson@linaro.org> References: <20190828190456.30315-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH v3 17/69] target/arm: Convert ERET 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: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass the T5 encoding of SUBS PC, LR, #IMM through the normal SUBS path to make it clear exactly what's happening -- we hit ALUExceptionReturn along that path. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Use unallocated_encoding for IS_USER check. --- target/arm/translate.c | 62 ++++++++++++++++-------------------------- target/arm/a32.decode | 2 ++ target/arm/t32.decode | 8 ++++++ 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index c285d4f882..203b6160da 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8477,6 +8477,27 @@ static bool trans_CLZ(DisasContext *s, arg_CLZ *a) return true; } =20 +static bool trans_ERET(DisasContext *s, arg_ERET *a) +{ + TCGv_i32 tmp; + + if (!arm_dc_feature(s, ARM_FEATURE_V7VE)) { + return false; + } + if (IS_USER(s)) { + unallocated_encoding(s); + return true; + } + if (s->current_el =3D=3D 2) { + /* ERET from Hyp uses ELR_Hyp, not LR */ + tmp =3D load_cpu_field(elr_el[2]); + } else { + tmp =3D load_reg(s, 14); + } + gen_exception_return(s, tmp); + return true; +} + /* * Legacy decoder. */ @@ -8771,29 +8792,10 @@ static void disas_arm_insn(DisasContext *s, unsigne= d int insn) case 0x4: /* crc32 */ /* All done in decodetree. Illegal ops reach here. */ goto illegal_op; - case 0x5: - /* Saturating addition and subtraction. */ + case 0x5: /* Saturating addition and subtraction. */ + case 0x6: /* ERET */ /* All done in decodetree. Reach here for illegal ops. */ goto illegal_op; - case 0x6: /* ERET */ - if (op1 !=3D 3) { - goto illegal_op; - } - if (!arm_dc_feature(s, ARM_FEATURE_V7VE)) { - goto illegal_op; - } - if ((insn & 0x000fff0f) !=3D 0x0000000e) { - /* UNPREDICTABLE; we choose to UNDEF */ - goto illegal_op; - } - - if (s->current_el =3D=3D 2) { - tmp =3D load_cpu_field(elr_el[2]); - } else { - tmp =3D load_reg(s, 14); - } - gen_exception_return(s, tmp); - break; case 7: { int imm16 =3D extract32(insn, 0, 4) | (extract32(insn, 8, 12) = << 4); @@ -10586,24 +10588,6 @@ static void disas_thumb2_insn(DisasContext *s, uin= t32_t insn) case 4: /* bxj, in decodetree */ goto illegal_op; case 5: /* Exception return. */ - if (IS_USER(s)) { - goto illegal_op; - } - if (rn !=3D 14 || rd !=3D 15) { - goto illegal_op; - } - if (s->current_el =3D=3D 2) { - /* ERET from Hyp uses ELR_Hyp, not LR */ - if (insn & 0xff) { - goto illegal_op; - } - tmp =3D load_cpu_field(elr_el[2]); - } else { - tmp =3D load_reg(s, rn); - tcg_gen_subi_i32(tmp, tmp, insn & 0xff); - } - gen_exception_return(s, tmp); - break; case 6: /* MRS, in decodetree */ case 7: /* MSR, in decodetree */ goto illegal_op; diff --git a/target/arm/a32.decode b/target/arm/a32.decode index 182f2b6725..52a66dd1d5 100644 --- a/target/arm/a32.decode +++ b/target/arm/a32.decode @@ -211,3 +211,5 @@ BXJ .... 0001 0010 1111 1111 1111 0010 ...= . @rm BLX_r .... 0001 0010 1111 1111 1111 0011 .... @rm =20 CLZ .... 0001 0110 1111 .... 1111 0001 .... @rdm + +ERET ---- 0001 0110 0000 0000 0000 0110 1110 diff --git a/target/arm/t32.decode b/target/arm/t32.decode index 67724efe4b..6236d28b99 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -218,4 +218,12 @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 ..= .. @rdm MSR_v7m 1111 0011 100 0 rn:4 1000 mask:2 00 sysm:8 } BXJ 1111 0011 1100 rm:4 1000 1111 0000 0000 &r + { + # At v6T2, this is the T5 encoding of SUBS PC, LR, #IMM, and works as = for + # every other encoding of SUBS. With v7VE, IMM=3D0 is redefined as ER= ET. + # The distinction between the two only matters for Hyp mode. + ERET 1111 0011 1101 1110 1000 1111 0000 0000 + SUB_rri 1111 0011 1101 1110 1000 1111 imm:8 \ + &s_rri_rot rot=3D0 s=3D1 rd=3D15 rn=3D14 + } } --=20 2.17.1