From patchwork Thu Sep 1 06:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 601804 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp261043mae; Thu, 1 Sep 2022 00:22:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jXGmdTI/x5bZtq8nLE62HwhUDYsxtVU9CV87D2N18kbRSklkxW5MBTpfXobFSr20yjs4W X-Received: by 2002:a37:8744:0:b0:6bc:1d10:5369 with SMTP id j65-20020a378744000000b006bc1d105369mr18265848qkd.14.1662016972528; Thu, 01 Sep 2022 00:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662016972; cv=none; d=google.com; s=arc-20160816; b=I99YWO3yhQhTonABh/OdRKhooWn9SHKrgq3Rk5RthU1KGMp6FNJ0mxzQh1CBlqRLO1 vPeUSJeTNL03GIlsJ0z06abcj7krXFZYF4EGSBs3LVm5n3Sf1OS6a9XPxBkqn2rS4Pn0 8S/dnVgv8bOPuqJH3byMh4XwbueCIB4jgtNeqc5rsmMBjD4PrVwdysBnY11OQpK+C0Br AmGzH0DuhyopmfNOFPv5chsnYms8G4TIndoDvC3rfo74FT8Qo6zhMHAS5a189J74kXil SqOv8sGR0V11thfylCP1bPnutiHn6iH2GX7oGat9kQ/a5jkl7efDNcHOxeTBLXVCX4d3 rCZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=V0bzNCJTxoGXtF4EbJMGshWo4Ox/Qmi/HEZplubmrUkDTBiuVRbDF6CddmXBfls0Gu c4yb+mwbPSb0/5M4ZSbE4VZ0enP8y5+Nz+2tMGTUQQ9yeyug9PacLsjy4zc4jDhc26uj Fso1poDOAy67Hg+GsyN9W7qRVS3a+XRDG8zkymkh3TPM6+XS31dE/iJUVNkJUTzHB5JC zXR5TbPfLg8o4trslyC+FXMd9CS0JFMnvKC/k8evvU+eeZ3eSGqMOWqTzLb4BpB4dFEc ig0fZsoxPRc0PENhR64Er74bg5x42nf9I0UgG71vqhRo0mC93kvH2UOe3fige5hahhFy vbkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NwKKSebe; 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=pass (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 bq20-20020a05620a469400b006b94073b03dsi8398948qkb.584.2022.09.01.00.22.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Sep 2022 00:22:52 -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=pass header.i=@linaro.org header.s=google header.b=NwKKSebe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTeXM-0007ks-3N for patch@linaro.org; Thu, 01 Sep 2022 03:22:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTe4o-0006ce-93 for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:22 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:42908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTe4m-0003RX-GO for qemu-devel@nongnu.org; Thu, 01 Sep 2022 02:53:21 -0400 Received: by mail-wr1-x42a.google.com with SMTP id m16so20984080wru.9 for ; Wed, 31 Aug 2022 23:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=NwKKSebeesF/qrC/3apRByzSl4cuI8eDtiSNMOXzrKoSv3dy0CXFHET8VdnVPYIPda 7ITqsu32515oRWrXp70wFwv/BrgpGXywQf9jp2KWbV4ZqF1muSdvQKWd9LVZqrppzbzw uRJsXI1oaKqUZ+Q/yaUtd8KF8W5nAjVjPHlno6mMEXioEBvLzkxiUsoFACF+uuM3SDGv gGHFK7GIybLXTNzB8Bx2QuAhujKxBlxKvgYUIH++5z6YMiOgOhWIhNPmMi6FDG8LLsz6 XtY048ySBramFDHVza8ejowrokb376+hbKu48mFjyEZM1udyVqXGPdm7jQPQuC7BlYjw lbZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=gWgQo634QZuragEiyeVInwCwdstldq2cVy0URJXztZPeiCAJClecR5wp07uFSGUoAj 6DVqgLQKFNZJ/qXqIbBcxc/XXmV+YD4KRrvUOckcG+dQBszNUKNcMp5525KjbmeMoerQ 6xeK9i8rZ0ehzanLPvAe57oik+fxBTx6riYpGWoe1uzoEGFFmHK4tiqQsAlOYKAk/pd1 2s9xVkvaB7jeqU3pLbgI6KCfxY1g7lTEjYNpKhHekuUTFhKlzNgmMJ+zef8Zzagl1vkZ E1TipOB4nho6voY3uRbkx44W+Wli4FQtGOWqkuCaNt4QniobXcsQPCpJOvmKYGqnkmD3 dlng== X-Gm-Message-State: ACgBeo1+S5PXIiRDP1BFgSWz39tdknl86Y7yEZ6CLIz3Gw1XkDQtlF1v WBx/c6QNAqOnRjsfmRzw8YBoZLB1p7yn+nDs X-Received: by 2002:a5d:59a2:0:b0:226:e6c3:a6c2 with SMTP id p2-20020a5d59a2000000b00226e6c3a6c2mr5665319wrr.236.1662015198913; Wed, 31 Aug 2022 23:53:18 -0700 (PDT) Received: from stoup.. ([87.192.221.83]) by smtp.gmail.com with ESMTPSA id a6-20020a5d4d46000000b00226dedf1ab7sm8308153wru.76.2022.08.31.23.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 23:53:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Ilya Leoshkevich Subject: [PULL 19/20] target/riscv: Add MAX_INSN_LEN and insn_len Date: Thu, 1 Sep 2022 07:52:09 +0100 Message-Id: <20220901065210.117081-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220901065210.117081-1-richard.henderson@linaro.org> References: <20220901065210.117081-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These will be useful in properly ending the TB. Reviewed-by: Alistair Francis Acked-by: Ilya Leoshkevich Tested-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- target/riscv/translate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 38666ddc91..a719aa6e63 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1022,6 +1022,14 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc) /* Include decoders for factored-out extensions */ #include "decode-XVentanaCondOps.c.inc" +/* The specification allows for longer insns, but not supported by qemu. */ +#define MAX_INSN_LEN 4 + +static inline int insn_len(uint16_t first_word) +{ + return (first_word & 3) == 3 ? 4 : 2; +} + static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) { /* @@ -1037,7 +1045,7 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) }; /* Check for compressed insn */ - if (extract16(opcode, 0, 2) != 3) { + if (insn_len(opcode) == 2) { if (!has_ext(ctx, RVC)) { gen_exception_illegal(ctx); } else {