From patchwork Thu Oct 7 17:47:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515465 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp1414675ime; Thu, 7 Oct 2021 10:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvZFg4enPD/xto+5BGNLsvf9dX/Iur+06zOlBkQ9D+s4ekb+pQvZY7tZs2YU0MPiiY/0SM X-Received: by 2002:a37:6d6:: with SMTP id 205mr4377747qkg.417.1633629474638; Thu, 07 Oct 2021 10:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633629474; cv=none; d=google.com; s=arc-20160816; b=dDp11cg8bX65Y3b/7x3Afu6Ics3+4weFeT4iP9AEm5OdYUcVKSzJUkdO0+4DcnWdE8 Jd3p/HzHvtfjyNUOrCnS12292czenuVI8Ukq7d/dG/ToHVOTE6yq9KOCtGD/Iq6Uk/OK r7KfAerd3eMK8e/K8ZeuK2xlbzdJ+0/3IevVoxkFF0bRfY4ID9xwvbbDLJvuBj5ppuIw 7893QsjyjsXVQifqSoRvZKfSSbQYRPodHTnCwtrO8WFvLborWGqwqHIEBNhsZBQ+exLN fiR2HyQLbc5y9reob+I24msOHvwaMiKg8Ogyh1dafoxxMP4ryqrS7V2Hu201ldSZu1AM iQ1w== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=D7b+ydnd4zMrVyDCywxRov6Sf650NgZr4E9SJVFsXBA=; b=vfrbuSnB7OaEcf9l+d862658NYFPYs5TmeXXdZfpbSRVIXeQe+t9/+pSUfh3pNZmSg KoK4y3LTQEnbNW7SWdDEaFpth5WPH/FX1A4eFdkbNOWhfNA7Qs+hQeD4NWSJLgiN/6vZ 66q/vrKF6bAj5Yc5GppBYcnopzd9be/dKeWYssDouW9ZhuN+vzNjbi7ssJv+w5SwXxyi Et2ySR0VJLqcZ1rN+vvcWk0hHj4Ke+b9rDs/AfhP5BNDQcDP7DbW2Cxmxa8+OT77TMaR MWJRtQa3qUU5DNomweZOWnjRcOwi2aenrkmREgRqKBMl7wI0fqiMtQPH3/GOASVGs6Vc bR/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FHV9yYFJ; 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 cv8si19904qvb.9.2021.10.07.10.57.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Oct 2021 10:57:54 -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=FHV9yYFJ; 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]:49290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYXeU-000579-5W for patch@linaro.org; Thu, 07 Oct 2021 13:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYXUV-00043e-71 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 13:47:39 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:40899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mYXUR-0006tT-NT for qemu-devel@nongnu.org; Thu, 07 Oct 2021 13:47:34 -0400 Received: by mail-pl1-x62f.google.com with SMTP id j15so4424579plh.7 for ; Thu, 07 Oct 2021 10:47:30 -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=D7b+ydnd4zMrVyDCywxRov6Sf650NgZr4E9SJVFsXBA=; b=FHV9yYFJPv4guJVXkntYu4zWE5YrpuTZUSgZ9nJEVFHqqVzW0MTA57t0yv4XAF7VJ1 iUML6/Jo37U961AYGE+wl9CabLdUOGiolI17jD1cnQ5ABACrnXoakg1V78J++4m1V0tP NI4k2uexqwjFgLhnoVGqgZFLFzhiGVpo4fVXtJacv4rBAvNYMIVcf+RuzPXpDkXNIuF/ WT3gE9gkmI13SKPRnIzmEUmACWDkRQZntH4+nerOylWYAM0Sw61+niS0VBBN9b1qnEhu wZPmetJdlV82I2FP15kD7MYwvooSVdnYGsqeThsa8pViDd0MrnkI5uWC22b9KpKA8aRW TlHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D7b+ydnd4zMrVyDCywxRov6Sf650NgZr4E9SJVFsXBA=; b=PZt2/Jd4rB23JGdKl4MVpcRE+WHXumbaXGMcMNPDI2qaXKieZidxGwTZFbsS1Zm2IN 5pcLiVxO+NZoD8ptSecCpidHsBCUqahIupiQDZUi+y8r4BXLHnvcCl594LUhgn+c8gCh Z0an8lTc2o5oCpohytmL3wxbThiPy+6wkwgxpRZu4jVFEMFRe7fjLe7V/cMKKtCtUi8j O+74uT2jMW/w3wIzHur7JsvhU47b+dl18Bw3KolAFFpmvH6r5ZPy1ANeCxkPuaWnUceH L3fwTKiLQLK6fcNp99y5qC9KEoKKJvwLbOXfDB0ToPjgEvLaxC7gbYWCSZ+BudUmh3ak 5wJg== X-Gm-Message-State: AOAM532kh6kJg4tbwzS6sUlqJ8pX6tfg7tTJlYsvzsIo1OnA+3vvmKFO xAEADeUKe87xDsCKQ0oiwXGF06x5/U03Pg== X-Received: by 2002:a17:903:2403:b0:13d:cef7:61f1 with SMTP id e3-20020a170903240300b0013dcef761f1mr5209951plo.48.1633628849388; Thu, 07 Oct 2021 10:47:29 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id 197sm83318pfv.6.2021.10.07.10.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 10:47:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/13] target/riscv: Properly check SEW in amo_op Date: Thu, 7 Oct 2021 10:47:16 -0700 Message-Id: <20211007174722.929993-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211007174722.929993-1-richard.henderson@linaro.org> References: <20211007174722.929993-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 autolearn=ham autolearn_force=no X-Spam_action: no action 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: alistair.francis@wdc.com, frederic.petrot@univ-grenoble-alpes.fr, qemu-riscv@nongnu.org, fabien.portas@grenoble-inp.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We're currently assuming SEW <= 3, and the "else" from the SEW == 3 must be less. Use a switch and explicitly bound both SEW and SEQ for all cases. Signed-off-by: Richard Henderson --- target/riscv/insn_trans/trans_rvv.c.inc | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) -- 2.25.1 diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index bbc5c93ef1..91fca4a2d1 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -704,18 +704,20 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) gen_helper_exit_atomic(cpu_env); s->base.is_jmp = DISAS_NORETURN; return true; - } else { - if (s->sew == 3) { - if (!is_32bit(s)) { - fn = fnsd[seq]; - } else { - /* Check done in amo_check(). */ - g_assert_not_reached(); - } - } else { - assert(seq < ARRAY_SIZE(fnsw)); - fn = fnsw[seq]; - } + } + + switch (s->sew) { + case 0 ... 2: + assert(seq < ARRAY_SIZE(fnsw)); + fn = fnsw[seq]; + break; + case 3: + /* XLEN check done in amo_check(). */ + assert(seq < ARRAY_SIZE(fnsd)); + fn = fnsd[seq]; + break; + default: + g_assert_not_reached(); } data = FIELD_DP32(data, VDATA, MLEN, s->mlen);