From nobody Mon Feb 9 16:35:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657614514960110.31338935665292; Tue, 12 Jul 2022 01:28:34 -0700 (PDT) Received: from localhost ([::1]:56066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBBFx-0006gr-Se for importer@patchew.org; Tue, 12 Jul 2022 04:28:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBAqC-0003Og-0s for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:59 -0400 Received: from mail.loongson.cn ([114.242.206.163]:57088 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBAq4-0001Qi-9v for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:55 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_9JdKs1i3NgYAA--.15429S3; Tue, 12 Jul 2022 16:01:34 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH 1/5] target/loongarch/cpu: Fix cpu_class_by_name function Date: Tue, 12 Jul 2022 16:01:29 +0800 Message-Id: <20220712080133.4176971-2-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> References: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dx_9JdKs1i3NgYAA--.15429S3 X-Coremail-Antispam: 1UD129KBjvdXoWrZFy3WrW7Wr4DtFy3tFW5Wrg_yoWfZFc_Wa 4fZ3ykWF4DW3WDtw4jv34rJw15JF4rCFnIkF9rA39agwn8XF45ArsFqwn7Z34Ygr45KFnY krW7CryYyr4akjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657614515831100001 Content-Type: text/plain; charset="utf-8" In loongarch_cpu_class_by_name(char *cpu_model) function, the argument cpu_model already has the suffix '-loongarch-cpu', so we should remove the LOONGARCH_CPU_TYPE_NAME(cpu_model) macro. Signed-off-by: Xiaojuan Yang --- target/loongarch/cpu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index e21715592a..8294b05ee8 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -571,11 +571,8 @@ static void loongarch_cpu_init(Object *obj) static ObjectClass *loongarch_cpu_class_by_name(const char *cpu_model) { ObjectClass *oc; - char *typename; =20 - typename =3D g_strdup_printf(LOONGARCH_CPU_TYPE_NAME("%s"), cpu_model); - oc =3D object_class_by_name(typename); - g_free(typename); + oc =3D object_class_by_name(cpu_model); return oc; } =20 --=20 2.31.1 From nobody Mon Feb 9 16:35:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657614260628916.2923407335896; Tue, 12 Jul 2022 01:24:20 -0700 (PDT) Received: from localhost ([::1]:48728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBBBq-0001LM-Kh for importer@patchew.org; Tue, 12 Jul 2022 04:24:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBAq8-0003Nx-I0 for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:59 -0400 Received: from mail.loongson.cn ([114.242.206.163]:57090 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBAq5-0001Qj-Np for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:52 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_9JdKs1i3NgYAA--.15429S4; Tue, 12 Jul 2022 16:01:35 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH 2/5] hw/intc/loongarch_pch_pic: Fix coverity errors in update irq Date: Tue, 12 Jul 2022 16:01:30 +0800 Message-Id: <20220712080133.4176971-3-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> References: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dx_9JdKs1i3NgYAA--.15429S4 X-Coremail-Antispam: 1UD129KBjvJXoWxJr1xtrW7JF15Kr1DCryrCrg_yoW8XFWxpF WDAF13Kr4rJFsxX3s5Cay5WFyfuFnrZr17WFZIya4xCr45ArnYk3yvqrW3ZFy8WrWrJFyj qFZ3Wa15u3WDCaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657614262273100001 Content-Type: text/plain; charset="utf-8" Fix coverity errors: 1. In find_first_bit function, the 'size' argument need 'unsigned long' type, so we add the suffix 'UL' on 'size' argument when use the function. 2. In expression 1ULL << irq, left shifting by more than 63 bits has undefined behavior. And out-of-bounds access error occured when 'irq' >=3D 64. So we add a condition to avoid this. Fix coverity CID: 1489761 1489764 1489765 Signed-off-by: Xiaojuan Yang --- hw/intc/loongarch_pch_pic.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index 3c9814a3b4..779a087a03 100644 --- a/hw/intc/loongarch_pch_pic.c +++ b/hw/intc/loongarch_pch_pic.c @@ -21,16 +21,20 @@ static void pch_pic_update_irq(LoongArchPCHPIC *s, uint= 64_t mask, int level) if (level) { val =3D mask & s->intirr & ~s->int_mask; if (val) { - irq =3D find_first_bit(&val, 64); - s->intisr |=3D 0x1ULL << irq; - qemu_set_irq(s->parent_irq[s->htmsi_vector[irq]], 1); + irq =3D find_first_bit(&val, 64UL); + if (irq < 64) { + s->intisr |=3D 0x1ULL << irq; + qemu_set_irq(s->parent_irq[s->htmsi_vector[irq]], 1); + } } } else { val =3D mask & s->intisr; if (val) { - irq =3D find_first_bit(&val, 64); - s->intisr &=3D ~(0x1ULL << irq); - qemu_set_irq(s->parent_irq[s->htmsi_vector[irq]], 0); + irq =3D find_first_bit(&val, 64UL); + if (irq < 64) { + s->intisr &=3D ~(0x1ULL << irq); + qemu_set_irq(s->parent_irq[s->htmsi_vector[irq]], 0); + } } } } --=20 2.31.1 From nobody Mon Feb 9 16:35:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657614678249871.436030842214; Tue, 12 Jul 2022 01:31:18 -0700 (PDT) Received: from localhost ([::1]:60216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBBIb-0001Jl-71 for importer@patchew.org; Tue, 12 Jul 2022 04:31:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBAq9-0003Ob-0m for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:59 -0400 Received: from mail.loongson.cn ([114.242.206.163]:57094 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBAq6-0001RL-NT for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:52 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_9JdKs1i3NgYAA--.15429S5; Tue, 12 Jul 2022 16:01:35 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH 3/5] target/loongarch/cpu: Fix coverity errors about excp_names Date: Tue, 12 Jul 2022 16:01:31 +0800 Message-Id: <20220712080133.4176971-4-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> References: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dx_9JdKs1i3NgYAA--.15429S5 X-Coremail-Antispam: 1UD129KBjvJXoWruFyrury7uFW7ZryxWw17KFg_yoW8JF1xpF sFvr9FgryfJrWDZw1kJayYqrn8Xw43GFn2ga1SkFyrtr1Sqr92vF1vqa9YvF15J397XrWU uF4fAryFq3W5XaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657614678976100001 Content-Type: text/plain; charset="utf-8" Fix out-of-bounds errors when access excp_names[] array. the valid boundary size of excp_names should be 0 to ARRAY_SIZE(excp_names)-1. However, the general code do not consider the max boundary. Fix coverity CID: 1489758 Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson --- target/loongarch/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 8294b05ee8..8e17b61a85 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -140,7 +140,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) =20 if (cs->exception_index !=3D EXCCODE_INT) { if (cs->exception_index < 0 || - cs->exception_index > ARRAY_SIZE(excp_names)) { + cs->exception_index >=3D ARRAY_SIZE(excp_names)) { name =3D "unknown"; } else { name =3D excp_names[cs->exception_index]; @@ -190,8 +190,8 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) cause =3D cs->exception_index; break; default: - qemu_log("Error: exception(%d) '%s' has not been supported\n", - cs->exception_index, excp_names[cs->exception_index]); + qemu_log("Error: exception(%d) has not been supported\n", + cs->exception_index); abort(); } =20 --=20 2.31.1 From nobody Mon Feb 9 16:35:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657614114241362.8638636975296; Tue, 12 Jul 2022 01:21:54 -0700 (PDT) Received: from localhost ([::1]:45958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBB9V-0007TE-5a for importer@patchew.org; Tue, 12 Jul 2022 04:21:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBAq8-0003Ny-N6 for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:59 -0400 Received: from mail.loongson.cn ([114.242.206.163]:57092 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBAq5-0001Qk-Lt for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:52 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_9JdKs1i3NgYAA--.15429S6; Tue, 12 Jul 2022 16:01:35 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH 4/5] target/loongarch/tlb_helper: Fix coverity integer overflow error Date: Tue, 12 Jul 2022 16:01:32 +0800 Message-Id: <20220712080133.4176971-5-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> References: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dx_9JdKs1i3NgYAA--.15429S6 X-Coremail-Antispam: 1UD129KBjvdXoWrZw47GF17Gry7tFW7Ww4rZrb_yoWDZrg_CF 1Iqwn7uryUWw12ywsYv34qyF17Kw1IgF43Cay2gFW7K345XF43Kw4qq3Z3Ar4YkrWrCrna kwnrZry3CF4YgjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657614115572100001 Content-Type: text/plain; charset="utf-8" Replace '1' with '1UL' to fix unintentional integer overflow errors in tlb_helper file. Fix coverity CID: 1489759 1489762 Signed-off-by: Xiaojuan Yang --- target/loongarch/tlb_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c index bab19c7e05..b300230588 100644 --- a/target/loongarch/tlb_helper.c +++ b/target/loongarch/tlb_helper.c @@ -298,7 +298,7 @@ static void invalidate_tlb_entry(CPULoongArchState *env= , int index) } else { tlb_ps =3D FIELD_EX64(env->CSR_STLBPS, CSR_STLBPS, PS); } - pagesize =3D 1 << tlb_ps; + pagesize =3D 1UL << tlb_ps; mask =3D MAKE_64BIT_MASK(0, tlb_ps + 1); =20 if (tlb_v0) { @@ -736,7 +736,7 @@ void helper_ldpte(CPULoongArchState *env, target_ulong = base, target_ulong odd, (tmp0 & (~(1 << R_TLBENTRY_G_SHIFT))); ps =3D ptbase + ptwidth - 1; if (odd) { - tmp0 +=3D (1 << ps); + tmp0 +=3D (1UL << ps); } } else { /* 0:64bit, 1:128bit, 2:192bit, 3:256bit */ --=20 2.31.1 From nobody Mon Feb 9 16:35:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657614402335107.95853506606329; Tue, 12 Jul 2022 01:26:42 -0700 (PDT) Received: from localhost ([::1]:51160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBBE9-00034h-3E for importer@patchew.org; Tue, 12 Jul 2022 04:26:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBAqG-0003Os-0z for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:02:01 -0400 Received: from mail.loongson.cn ([114.242.206.163]:57098 helo=loongson.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBAq8-0001R7-Sn for qemu-devel@nongnu.org; Tue, 12 Jul 2022 04:01:59 -0400 Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx_9JdKs1i3NgYAA--.15429S7; Tue, 12 Jul 2022 16:01:35 +0800 (CST) From: Xiaojuan Yang To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, gaosong@loongson.cn, maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk, mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca, f4bug@amsat.org, peter.maydell@linaro.org Subject: [PATCH 5/5] target/loongarch/op_helper: Fix coverity cond_at_most error Date: Tue, 12 Jul 2022 16:01:33 +0800 Message-Id: <20220712080133.4176971-6-yangxiaojuan@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> References: <20220712080133.4176971-1-yangxiaojuan@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf9Dx_9JdKs1i3NgYAA--.15429S7 X-Coremail-Antispam: 1UD129KBjvdXoWrtFW7CFWrZw4UKr4rury5twb_yoW3uFX_uF W7Xr1Dur4DWw1jkw4Yv3s5tr17KF18GFnIkF4UXr42kFyYga13Jw1DW3s3Cr1UCFyrJrs0 vwnFyry7C3WYkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUUUUUUU X-CM-SenderInfo: p1dqw5xldry3tdq6z05rqj20fqof0/ 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=114.242.206.163; envelope-from=yangxiaojuan@loongson.cn; helo=loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1657614403532100001 Content-Type: text/plain; charset="utf-8" The boundary size of cpucfg array should be 0 to 20. So, using index bigger than 20 to access cpucfg[] must be forbidden. Fix coverity CID: 1489760 Signed-off-by: Xiaojuan Yang --- target/loongarch/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c index 4b429b6699..b05a0b7648 100644 --- a/target/loongarch/op_helper.c +++ b/target/loongarch/op_helper.c @@ -81,7 +81,7 @@ target_ulong helper_crc32c(target_ulong val, target_ulong= m, uint64_t sz) =20 target_ulong helper_cpucfg(CPULoongArchState *env, target_ulong rj) { - return rj > 21 ? 0 : env->cpucfg[rj]; + return rj > 20 ? 0 : env->cpucfg[rj]; } =20 uint64_t helper_rdtime_d(CPULoongArchState *env) --=20 2.31.1