From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1436EC433F5 for ; Sat, 16 Oct 2021 17:22:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B558560E74 for ; Sat, 16 Oct 2021 17:22:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B558560E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbnOA-0001mn-Rw for qemu-devel@archiver.kernel.org; Sat, 16 Oct 2021 13:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbnGL-00012S-TJ for qemu-devel@nongnu.org; Sat, 16 Oct 2021 13:14:27 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:33751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbnGJ-0006Cg-AO for qemu-devel@nongnu.org; Sat, 16 Oct 2021 13:14:25 -0400 Received: by mail-pg1-x532.google.com with SMTP id j190so4947443pgd.0 for ; Sat, 16 Oct 2021 10:14:22 -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=sefFRWXuAIwA9Hn9aMW9zKhBMiydf7kE/zMEjZquoTs=; b=FinqihW5F838ZFLUFQXSASvcn4kgsAE233XQSszP7T8g07v7J2OuLhq70Wn+G3rr0G FZerP1aDK4OYppbSaX4mp3Rgc3IWJ0fz+XwcKC6a07PMqc0D3mKUIYhMudGKma0BHIIw e3poNEMilyJxRwYxgtvV9DZnUvgMENiJA3A8IygfcIVPrbdueRWxn5u5DHAqs2OnD/j/ sVv1SFWoZm+EEpYnsPCW+ia2z/BL3cekWXXW0EJG8w4mAfv93vdVvjCLoVFceyjbX8xw bJnpPcJqxD+sb9TpH4ktYl/RZVHwzVpv+BWXdMAuPtvCjDuwepvbZa9ybHK7vN9WI5s6 f8BA== 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=sefFRWXuAIwA9Hn9aMW9zKhBMiydf7kE/zMEjZquoTs=; b=zB+3xzIaGN9+Bi7liQysYTDR/XrbxoT8aZM6buJlFhfiMrZSS0TYjKL1wkDx+lcPdf 2t0XTH7ZQIqfZD8RvR7zHdjjJsbTNy+ZvQ0CcpzVotu0C5eMyebLaM0BF67qyMOCkvmf l3ZfUSvIZIMkSh1OZQUcD7zx7Sat7JAOKuej0JEZl8+8q8JDHs4uVcIOV3DpLJ0GzvtP mHYq8F3wC1xUgIxLDJeCI0PCDGtFXsboZCMKJratHh4e2vbxzDQqtq+INHzQr242/AxO Si0IwIijB824000I+4bMOqclv9JD/Kgqnt2x4IDSG+D40AgMsvXPr+knvkKKo5Wf19vJ z9iw== X-Gm-Message-State: AOAM531ItrNGV+6g0q8MLQ2WKyVjHrE0OWONHN7nb01z0kIbVTIdSd5C UNSyFAgtmBBaIVrCLweSvZEfhPuemJi1IQ== X-Google-Smtp-Source: ABdhPJytipreVyb9xVymZdp06ulsQoSugUFsDDvJIR5XEIPoKDkdyqq45v+aLQtYD2PutXL9kphxbg== X-Received: by 2002:a63:b006:: with SMTP id h6mr6913792pgf.366.1634404461409; Sat, 16 Oct 2021 10:14:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id l4sm2330281pfc.121.2021.10.16.10.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 10:14:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/14] target/riscv: Properly check SEW in amo_op Date: Sat, 16 Oct 2021 10:14:05 -0700 Message-Id: <20211016171412.3163784-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211016171412.3163784-1-richard.henderson@linaro.org> References: <20211016171412.3163784-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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: qemu-riscv@nongnu.org, frank.chang@sifive.com, alistair.francis@wdc.com, fabien.portas@grenoble-inp.org, frederic.petrot@univ-grenoble-alpes.fr, zhiwei_liu@c-sky.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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(-) 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); -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mbnGe-0001OY-G1 for mharc-qemu-riscv@gnu.org; Sat, 16 Oct 2021 13:14:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbnGM-00012T-07 for qemu-riscv@nongnu.org; Sat, 16 Oct 2021 13:14:27 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:39901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbnGJ-0006Cf-FD for qemu-riscv@nongnu.org; Sat, 16 Oct 2021 13:14:25 -0400 Received: by mail-pg1-x535.google.com with SMTP id g184so11679066pgc.6 for ; Sat, 16 Oct 2021 10:14:22 -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=sefFRWXuAIwA9Hn9aMW9zKhBMiydf7kE/zMEjZquoTs=; b=FinqihW5F838ZFLUFQXSASvcn4kgsAE233XQSszP7T8g07v7J2OuLhq70Wn+G3rr0G FZerP1aDK4OYppbSaX4mp3Rgc3IWJ0fz+XwcKC6a07PMqc0D3mKUIYhMudGKma0BHIIw e3poNEMilyJxRwYxgtvV9DZnUvgMENiJA3A8IygfcIVPrbdueRWxn5u5DHAqs2OnD/j/ sVv1SFWoZm+EEpYnsPCW+ia2z/BL3cekWXXW0EJG8w4mAfv93vdVvjCLoVFceyjbX8xw bJnpPcJqxD+sb9TpH4ktYl/RZVHwzVpv+BWXdMAuPtvCjDuwepvbZa9ybHK7vN9WI5s6 f8BA== 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=sefFRWXuAIwA9Hn9aMW9zKhBMiydf7kE/zMEjZquoTs=; b=hZ7UbbEMKbkwt5jEyDI+2ZdOai2z3yXWzEaSU/1vvbwiaG4vOtFfnj6vFhdRkYd9/0 flAsoTbvToM2IhzpyvNnUiSHMjQf2iT4FmkIXJU6qOCMrGeu1MF0Mb23Xqx6HgkjD3W0 crCj8jqr9KeNmAX5SD4M5XLNeUtsTerCXoJRjfwSvxgZKLzoq40sT7LvKNGWJ84H8yS4 GcRD+q3CTUZpknQ669Pf9bJLEjI3FKrhH5t8+5He0nh0UQlKMmgAO79/3uYqhHzRIS/Z 7VtCk3iHNojAnqTzLwluqRhIFiOFczt/0SzWQRkqT+ClR9w0QwoAZGO5r68En0nQ9b0k yGmw== X-Gm-Message-State: AOAM530qnyZTkoMAl1XaVntPGY8PZVsDsCuLpdKVshqwhejsvtVSakav 8ubims4scCJHoH6ryRdjgbWo/w== X-Google-Smtp-Source: ABdhPJytipreVyb9xVymZdp06ulsQoSugUFsDDvJIR5XEIPoKDkdyqq45v+aLQtYD2PutXL9kphxbg== X-Received: by 2002:a63:b006:: with SMTP id h6mr6913792pgf.366.1634404461409; Sat, 16 Oct 2021 10:14:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id l4sm2330281pfc.121.2021.10.16.10.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 10:14:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, frederic.petrot@univ-grenoble-alpes.fr, fabien.portas@grenoble-inp.org, zhiwei_liu@c-sky.com, frank.chang@sifive.com Subject: [PATCH v3 07/14] target/riscv: Properly check SEW in amo_op Date: Sat, 16 Oct 2021 10:14:05 -0700 Message-Id: <20211016171412.3163784-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211016171412.3163784-1-richard.henderson@linaro.org> References: <20211016171412.3163784-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Oct 2021 17:14:27 -0000 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(-) 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); -- 2.25.1