From patchwork Tue Oct 19 15:24:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515971 Delivered-To: patch@linaro.org Received: by 2002:ac0:cd8c:0:0:0:0:0 with SMTP id d12csp838961imp; Tue, 19 Oct 2021 09:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO2myaYRsZTmuffk92E9vYArx7oTXYgebPVZHbgdJVAI5Gjwv4GSEY1O179woF+nZsAizS X-Received: by 2002:a05:6102:358e:: with SMTP id h14mr24929292vsu.0.1634661572631; Tue, 19 Oct 2021 09:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634661572; cv=none; d=google.com; s=arc-20160816; b=IqYJjAtevaOUlKH6gi9kw5C48DmNZ8e7UkME9iijMlqylsBgmVLY2ThBycVNeK7t98 Jsz5/XunmdbDGdfiny8WkZl0SHqsguCLx3PaXEgvEzSZXrCzcLDJZ3OW030497ZgKK+d Mh9fL1rIx2+IyB9FwD1HqPV8UlZlOUsLXjxCITuHVGXZw1+7bWeOb4Vm9OdBzn2LxErE azx71oQpeeRMz2rg8i6ml9CmlIproze3MV3zv8iS5qrbObhYWMOQDIJiOsJInvfr4qKV PekdJKZe/R5v1+n8PTBUrsqqujj46cmYHtKKEDPM997/b1OTfPhNJrzHMxVesfjw2q0I tC+w== 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=mfu2QZ3gpRQ8C8fsN7554x8wxijvHESDqJdXEHq27p8=; b=IJmB55FhqDhePUGvpSLuQLT7NPd0P5onYfJNIh5Wg++PHvjADNWmovvG7ok+dSJtXd ka663RF18RA82hY0L/PbRDoGjoHP+1Lcxb8ivzP+oqbOngSBBbHjC3s8LZNPu+IQ/XO3 BcIWY7dqMXlZ+6u647VRccp+giAa3XHZ/R7i0Rmx8tZnlA+L65tcbeV/YCalZhryOImC z+wEE6+Fl0HKDwe/VurDPY4BzOe7OhajtBG7jzyBI5gRS7W3ZZHWIGZhMkfd3V/0+5v0 VHNW9vQg+g2ZmM7jdbuHhobwa3tvSx/9jc/H8RNgYTo0XFahrQ0XmgmVuS4l85EZHwwa KWFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a1YR+2BJ; 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 c17si13288526uam.103.2021.10.19.09.39.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Oct 2021 09:39:32 -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=a1YR+2BJ; 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]:39054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcs9E-0004qj-2Q for patch@linaro.org; Tue, 19 Oct 2021 12:39:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcqz0-00055V-KX for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:54 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:45746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcqyr-0007XG-SL for qemu-devel@nongnu.org; Tue, 19 Oct 2021 11:24:54 -0400 Received: by mail-pl1-x631.google.com with SMTP id s1so12086210plg.12 for ; Tue, 19 Oct 2021 08:24:45 -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=mfu2QZ3gpRQ8C8fsN7554x8wxijvHESDqJdXEHq27p8=; b=a1YR+2BJtRX9o6BMOYcBV+wrw+PCXiamdbTRbPfuwMVFaTTxWYGRUp1aYeXqPs2IjY 4lKPGb+2/jDEU84sSnPK/a4Dls38eD8gECwRsVKeYMwYD4e686/NUtn4dGVLm1dApfIM p4jqWHtXP+kbj43Dwf2xc6aOgi7vAt7h+DJ+Sour9uCsmGJmKH2hyDdwAD699XRFH6XI IAMGIAIpDruqbHMVtMNt8zd0624C4FMq5WPnhSc0jDA4sNRNVzfWJDRv8as1S/eA19Ta XRlXsFwVyMG0VSxCRgtz8NBwRHJwaycMxjPKetQxZtgDhpAoV1nzMZ4z0FqBWAEg9ek8 9Kjg== 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=mfu2QZ3gpRQ8C8fsN7554x8wxijvHESDqJdXEHq27p8=; b=rSXL2Q4hEL3LH7Mc2X4hohV+tpAkyPstHxheJP88C7UyWqcSqaDgKuIUCTwGvPfBRY gBNCDbtolf8a7yXUPdMVtxk5S8ceTmRxFpBvYZ7B00loOMizc3V1i5lyMpdJVsM4OXAD eR0PMSQ6EQYn/cuWmzwNT4jSyeQR6wvmMvO2ysVxKTVCg5Pv9hSB92iTB0ZdGTnmdo1o kp1ROhqqYORApTzho3Voc7QIhnjVcXsOfaKtzIwBsmZ6cqAxNP38CIfsZtN1kyr4uFCq 9C2xIuWdqWho6u8QjzSIglk9W/VqIOa1DmiKM4CwHkY6H6y77KH2iHNH/xT7EtZMIxjP jG+g== X-Gm-Message-State: AOAM532pdS578aBE4OzqiQMUBf7ysZ1LKtBQK6E5e0gRX8AJw+sFBWi+ XZRgClKA9IT1ItGZ+zSoNtkjLVG+PL335g== X-Received: by 2002:a17:90b:1283:: with SMTP id fw3mr589113pjb.99.1634657084471; Tue, 19 Oct 2021 08:24:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id i2sm3293814pjt.19.2021.10.19.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 08:24:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 07/16] target/riscv: Properly check SEW in amo_op Date: Tue, 19 Oct 2021 08:24:29 -0700 Message-Id: <20211019152438.269077-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019152438.269077-1-richard.henderson@linaro.org> References: <20211019152438.269077-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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=unavailable 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 d60279b295..d16446d3bb 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);