From patchwork Wed Oct 20 03:17:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515989 Delivered-To: patch@linaro.org Received: by 2002:adf:a11e:0:0:0:0:0 with SMTP id o30csp1324117wro; Tue, 19 Oct 2021 20:29:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvVocmXd6UkUFUYh9DHZs/IYIV6/y8CDU8kTkcR2si6Q6BaAcJqenLwDjNo421OnAPRT++ X-Received: by 2002:a54:4f8f:: with SMTP id g15mr7112345oiy.169.1634700570333; Tue, 19 Oct 2021 20:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634700570; cv=none; d=google.com; s=arc-20160816; b=tUGtKbwhnagIRwYvYlXkMZ8dl0slIQLzXPxA3s7tlzTX41Al2q4PLJphDPWVVUhFux ImJibeJkP0GU7vd+fBKXdU864aRBYtEtkr1gmIo/YYiB97mT3dGzIbJv4GWtOaHAMtTc A+WHKlg72rYnUXL6nDimLy+JyouDTCISM0u4CMMDsRdbxhmiQgF4WZnB0fSepa3ZQqHc 9EKw+HZswVbGTN/wLfb4d+kRfVJimPvSCEoOWhsR/JrBH4/0sTej6RxvPNW2VyXVLf75 oevcd0/PSEecn0LT4UZTexj87TicWl5D32bjg8rV/CH9D4klDuErXLKEeo/6aE0pmfUY x2GA== 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=UakmtpX/ULO2Fxh/+VRPEmYBUzLO6qfGKR5m4Cqlo1Y=; b=HWBpOGwDsaIPKyGgodi3jwZw7vSXmt9hkK2Kb6Anrdurxexkr7gvsKnIxzX2AE1aDD PxmFeXA8S7ACxAqMiG1Mz2qssOpBsffsWGPsy7q9vDzd5y2QiMFZ4YUnCqFiQRh36TFY smstaVfbQYb9AhqbLma1XA2TWqYC43jQL1vgtbZjLjmUdq4Xw01w1OqhuZfjyWkFciHH 3CHqVZc8ykzkBpH1RbF5imDGdV2qvbvNHiZHSFWm6kin+22JSx/S6Sn+9f0G5AVZOaxB EVWXf48xAY4s5w9sNq1V1yVjqxQHj3Xw1k3euIuXp4z6CaqU2ER93tmegSFJtqjdLZms t7kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DmA2mxyA; 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 s20si1693600oiw.134.2021.10.19.20.29.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Oct 2021 20:29:30 -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=DmA2mxyA; 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]:53002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1md2ID-0001Nt-Gb for patch@linaro.org; Tue, 19 Oct 2021 23:29:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md26U-0006tD-UP for qemu-devel@nongnu.org; Tue, 19 Oct 2021 23:17:22 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:42562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1md26Q-00012B-Fo for qemu-devel@nongnu.org; Tue, 19 Oct 2021 23:17:22 -0400 Received: by mail-pl1-x62d.google.com with SMTP id w17so3283396plg.9 for ; Tue, 19 Oct 2021 20:17:17 -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=UakmtpX/ULO2Fxh/+VRPEmYBUzLO6qfGKR5m4Cqlo1Y=; b=DmA2mxyA655Ycr+H014vUT4DEXePkf0xbHXfa/VlZTFOfcmzHAUZKwgdy1116FBQOX KF+Fd8SlEElIb88rAyI0l2AHv9hapnfZUNx9Gn2zcXHMY5VLgWrDDD1ODfpR+Z7JLgv/ orVav7pQoaDcZmc2pgpmxzy3WdaVA94NBJ5ykGC6bzTZWu47rlvQJkrQ2belmHApM8IZ JhktCnzl1cSfQCte0RO+FvgXuDXHhNusd/9/VBXnd1k9EnArjJZgTq7kU2AKMi54ZJXN EZmZmDucNf3NUtbLfSBrpnTa4f5SwuqLDQe/HKbpMjq8QfjEVjVnDILyiMK7EIKpIRs3 sXUw== 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=UakmtpX/ULO2Fxh/+VRPEmYBUzLO6qfGKR5m4Cqlo1Y=; b=N5jQ5/ACXBGjpeULVGj9wsmN/7QQrL3eg5VDh8hpzmQ4nUU3FPpxHm0vAYa6IOEiS0 k3lnIcyn1Wge7P6922Dri72zOUXNA/ESHQbzCYp9LZti+HHQnSB/4kFsqKhfct9XgcAo Z0OTpbym3y6Hc2MfXB5SnTAekVtcPSrJC7eUS380kuLbuMHg4iCXLQtnxm56peGn3baW zEFOyLBnIzpjH2HU54gFdaM9b6BWMwJdMkWcZFGcJeiI9+CehIej5J0t4OFGAP6SN0hP 7xgo9ybpVGBPfhlGBG+/sVLIIfWqUTdgxaZzAs3fS0Ks9mqrGs9UzxoMVRWWx2BDJ7bg YgcA== X-Gm-Message-State: AOAM530dCivBgpPRAixEdc0VNOeaZyCnXzrGvvRsm+FdSXxtTz/q5h2D Ewf04+YNOwMQXz5ogJuosCpZN6qWE4fV+g== X-Received: by 2002:a17:90b:1e49:: with SMTP id pi9mr4413311pjb.144.1634699836020; Tue, 19 Oct 2021 20:17:16 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id c8sm505364pjr.38.2021.10.19.20.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 20:17:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 07/15] target/riscv: Properly check SEW in amo_op Date: Tue, 19 Oct 2021 20:17:01 -0700 Message-Id: <20211020031709.359469-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211020031709.359469-1-richard.henderson@linaro.org> References: <20211020031709.359469-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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, qemu-riscv@nongnu.org, zhiwei_liu@c-sky.com 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. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis 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 61fd82d41a..a102c3687e 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);