From nobody Mon Sep 16 18:54:59 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1662455451; cv=none; d=zohomail.com; s=zohoarc; b=LfK+SQMFGVw/uy5k2JNrZdQyiJvQlWF8CuFTJmYEQxbGvPNn1gu1i6ZGzYBkE74p2g8rSeTTmB24LvEZgbGLm8JsMSQy+89vuqLo3OBsFR6Zt5u+GnRTFqTivEvN46IO9wGVGe4NwPKZ8f18Q5j5DZQW1U4Y9wJXkHaI4/hVoUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662455451; h=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; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=O/96kxwI1lOLvzn89oeD+jki4FMyPvVEOGHJPzWg2SF3+0QiW+El9vwtjdwq7MbP35dKyshuVZj8mzVY885s/8n2EkKaclwxor8O1UXfBfyVDJ9fe7Bofsd1Poln+hlrA4zfO3xKjhzl7cu6xgUPx23kjSzwW1ScqCftM2pbQE0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166245545115510.50838368738323; Tue, 6 Sep 2022 02:10:51 -0700 (PDT) Received: from localhost ([::1]:44184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVUbZ-0004zW-Si for importer2@patchew.org; Tue, 06 Sep 2022 05:10:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVU6W-0002y5-4u for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:44 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVU6U-0005bS-8c for qemu-devel@nongnu.org; Tue, 06 Sep 2022 04:38:43 -0400 Received: by mail-wr1-x42c.google.com with SMTP id az27so14306880wrb.6 for ; Tue, 06 Sep 2022 01:38:41 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:a5c0:5a80:ba98:3a71:8524:e0b1]) by smtp.gmail.com with ESMTPSA id g26-20020a7bc4da000000b003a54f49c1c8sm13421859wmk.12.2022.09.06.01.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 01:38:40 -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:subject:date; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=wr+8fA7woVjc8qRZQe0R9g0J//X91kP+CdFAt1ZDwvon9u3M7J8QktEwNNIqFkDdkt GDFsZ9/FWCRGasf5FbhFD1NO46Cbbo2O99sIwBgm8KsSSKq9EzVniLiCCSf4RGcuS1Dt C+/JGg3sH71uMDcHgsPVTaE0/B04Kc0zFr713BzK4bVDsBEjOKg5vTR8sxTsbR48egYt HU9XQDjzDWlGHW1QSg3qx+npajtMBVYUbcLII5rDeP6bhk3JQTRvOafzT1sXa7TMIqct 09Nx34Ud+7uEG/8hPt9IYUZ084iDuCq6n+jbtjdlErq5uGlahqlCcb9sDzrXe9/I6O6y SX0w== 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 :subject:date; bh=Ar6YL5FF/K2Div4uruzg03ZvW0xj9yBOSm1jZPy9tok=; b=HFwuCMr7ry0FCSFHGzbLVv1labNbPC6tWPgN3vxuIYUPbRgR6AdrWteHRKcMIVhyiT aKYeW+fPywqIQ9xZ1W1mv+QylBmay5aHIhGeJ9PHKgC9aIedVYsCWM6yCseSYrCgiRTR Xtp5WaJai5a5Ku9SselR6oOxb4U7k3DRRmFWne/zkGKFpj5DAIsNJN67+mduBB+dkUe8 N9TukMEAqBLdgbEq0ZgrFr4Z062wYKsPAv9JRxl/QGoxF18bRF31vBtVsspJOXOfviaT gNmhY75Ub3N3zHLttYUyDfRQoaVhue+ou0dIYvYVcHfRJov3okmuZ0zsUVZpFCCpdDhO GHcA== X-Gm-Message-State: ACgBeo0kvqm/aNgERygsy2knUvDRIDh4uGVfdBReYx6FAgUYtUQN0S/Z zU5UAvWuTc2Trulyly43Y/4iYc854lx3Ee84 X-Google-Smtp-Source: AA6agR7FJ4utPx0r00YBXO/0QOuz6dUCEI5d13yx0iZ2uwB2bruUmK0i32443PubhkrxogDHsNWfrA== X-Received: by 2002:a05:6000:168d:b0:226:da6a:6d78 with SMTP id y13-20020a056000168d00b00226da6a6d78mr22379665wrd.180.1662453520644; Tue, 06 Sep 2022 01:38:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Alistair Francis , Ilya Leoshkevich Subject: [PULL v3 19/20] target/riscv: Add MAX_INSN_LEN and insn_len Date: Tue, 6 Sep 2022 09:38:14 +0100 Message-Id: <20220906083815.252478-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906083815.252478-1-richard.henderson@linaro.org> References: <20220906083815.252478-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42c.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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1662455451500100001 Content-Type: text/plain; charset="utf-8" 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" =20 +/* 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) =3D=3D 3 ? 4 : 2; +} + static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opc= ode) { /* @@ -1037,7 +1045,7 @@ static void decode_opc(CPURISCVState *env, DisasConte= xt *ctx, uint16_t opcode) }; =20 /* Check for compressed insn */ - if (extract16(opcode, 0, 2) !=3D 3) { + if (insn_len(opcode) =3D=3D 2) { if (!has_ext(ctx, RVC)) { gen_exception_illegal(ctx); } else { --=20 2.34.1