From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290664927188.18224962292607; Mon, 11 Dec 2023 02:31:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651595.1017317 (Exim 4.92) (envelope-from ) id 1rCdYb-0005Dx-F0; Mon, 11 Dec 2023 10:30:37 +0000 Received: by outflank-mailman (output) from mailman id 651595.1017317; Mon, 11 Dec 2023 10:30:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYb-0005D4-9p; Mon, 11 Dec 2023 10:30:37 +0000 Received: by outflank-mailman (input) for mailman id 651595; Mon, 11 Dec 2023 10:30:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYZ-00059V-Ts for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:35 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 514714a9-9810-11ee-98e8-6d05b1d4d9a1; Mon, 11 Dec 2023 11:30:34 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 4478F4EE0741; Mon, 11 Dec 2023 11:30:33 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 514714a9-9810-11ee-98e8-6d05b1d4d9a1 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [XEN PATCH 1/7] xen/shutdown: address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:22 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290667067100008 Content-Type: text/plain; charset="utf-8" Given that 'hwdom_shutdown' is a noreturn function, unreachable breaks can be eliminated to resolve violations of Rule 2.1. On the occasion, the type of its parameter is changed to uint8_t. No functional change. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- xen/common/shutdown.c | 11 ++--------- xen/include/xen/shutdown.h | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index 37901a4f3391..290f90d70fe1 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -30,7 +30,7 @@ static void noreturn maybe_reboot(void) } } =20 -void hwdom_shutdown(u8 reason) +void hwdom_shutdown(uint8_t reason) { switch ( reason ) { @@ -38,39 +38,32 @@ void hwdom_shutdown(u8 reason) printk("Hardware Dom%u halted: halting machine\n", hardware_domain->domain_id); machine_halt(); - break; /* not reached */ =20 case SHUTDOWN_crash: debugger_trap_immediate(); printk("Hardware Dom%u crashed: ", hardware_domain->domain_id); kexec_crash(CRASHREASON_HWDOM); maybe_reboot(); - break; /* not reached */ =20 case SHUTDOWN_reboot: printk("Hardware Dom%u shutdown: rebooting machine\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ =20 case SHUTDOWN_watchdog: printk("Hardware Dom%u shutdown: watchdog rebooting machine\n", hardware_domain->domain_id); kexec_crash(CRASHREASON_WATCHDOG); machine_restart(0); - break; /* not reached */ =20 case SHUTDOWN_soft_reset: printk("Hardware domain %d did unsupported soft reset, rebooting.\= n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ =20 default: printk("Hardware Dom%u shutdown (unknown reason %u): ", hardware_domain->domain_id, reason); maybe_reboot(); - break; /* not reached */ } -} =20 - +} diff --git a/xen/include/xen/shutdown.h b/xen/include/xen/shutdown.h index 668aed0be580..3537c30e0a1b 100644 --- a/xen/include/xen/shutdown.h +++ b/xen/include/xen/shutdown.h @@ -6,7 +6,7 @@ /* opt_noreboot: If true, machine will need manual reset on error. */ extern bool opt_noreboot; =20 -void noreturn hwdom_shutdown(u8 reason); +void noreturn hwdom_shutdown(uint8_t reason); =20 void noreturn machine_restart(unsigned int delay_millisecs); void noreturn machine_halt(void); --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290664851916.056106078791; Mon, 11 Dec 2023 02:31:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651597.1017342 (Exim 4.92) (envelope-from ) id 1rCdYe-0005vB-V1; Mon, 11 Dec 2023 10:30:40 +0000 Received: by outflank-mailman (output) from mailman id 651597.1017342; Mon, 11 Dec 2023 10:30:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYe-0005v4-Rr; Mon, 11 Dec 2023 10:30:40 +0000 Received: by outflank-mailman (input) for mailman id 651597; Mon, 11 Dec 2023 10:30:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYd-0005Em-M6 for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:39 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 51d2ff79-9810-11ee-9b0f-b553b5be7939; Mon, 11 Dec 2023 11:30:35 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id AD6D34EE0742; Mon, 11 Dec 2023 11:30:34 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 51d2ff79-9810-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 2/7] x86/mm: address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:23 +0100 Message-Id: <5913d8871ff6c4f320c521e50e550a64e58d4351.1702283415.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290665267100005 Content-Type: text/plain; charset="utf-8" The "return 0" after the swich statement in 'xen/arch/x86/mm.c' is unreachable because all switch clauses end with returns. However, some of them can be substituted with "break"s to allow the "return 0" outside the switch to be reachable. No functional changes. Signed-off-by: Nicola Vetrini --- xen/arch/x86/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 0a66db10b959..8b31426a5348 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4753,7 +4753,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HAND= LE_PARAM(void) arg) } =20 spin_unlock(&d->arch.e820_lock); - return 0; + break; } =20 case XENMEM_machine_memory_map: @@ -4818,7 +4818,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HAND= LE_PARAM(void) arg) if ( __copy_to_guest(arg, &ctxt.map, 1) ) return -EFAULT; =20 - return 0; + break; } =20 case XENMEM_machphys_mapping: @@ -4834,7 +4834,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HAND= LE_PARAM(void) arg) if ( copy_to_guest(arg, &mapping, 1) ) return -EFAULT; =20 - return 0; + break; } =20 #ifdef CONFIG_HVM --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290667094744.5401722730707; Mon, 11 Dec 2023 02:31:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651598.1017347 (Exim 4.92) (envelope-from ) id 1rCdYf-0005xz-BG; Mon, 11 Dec 2023 10:30:41 +0000 Received: by outflank-mailman (output) from mailman id 651598.1017347; Mon, 11 Dec 2023 10:30:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYf-0005x1-3J; Mon, 11 Dec 2023 10:30:41 +0000 Received: by outflank-mailman (input) for mailman id 651598; Mon, 11 Dec 2023 10:30:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYd-0005Em-T4 for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:39 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5238be18-9810-11ee-9b0f-b553b5be7939; Mon, 11 Dec 2023 11:30:36 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 801C84EE0743; Mon, 11 Dec 2023 11:30:35 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5238be18-9810-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [XEN PATCH 3/7] xen/arm: address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:24 +0100 Message-Id: <4c0d38f2b707afa9aed1853a99d286fa2424fb9d.1702283415.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290669140100001 Content-Type: text/plain; charset="utf-8" The "return 1;" statements at the end of some cases in the switch of function 'vgic_v3_its_mmio_write' in 'vcig-v3-its.c' cause the unreachability of the "return 1;" statement after the switch, thus violating MISRA C:2012 Rule 2.1: "A project shall not contain unreachable code". The same is true for the switch in 'arch_memory_op' from 'xen/arch/arm/mm.c'. Signed-off-by: Nicola Vetrini --- xen/arch/arm/mm.c | 2 +- xen/arch/arm/vgic-v3-its.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index eeb65ca6bb79..9be8e711f61e 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -277,7 +277,7 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void= ) arg) /* XXX: memsharing not working yet */ case XENMEM_get_sharing_shared_pages: case XENMEM_get_sharing_freed_pages: - return 0; + break; =20 default: return -ENOSYS; diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 05429030b539..b9195bbd0538 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -1255,7 +1255,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmi= o_info_t *info, reg32 & GITS_CTLR_ENA= BLE); spin_unlock(&its->its_lock); spin_unlock(&its->vcmd_lock); - return 1; + break; } =20 case VREG32(GITS_IIDR): @@ -1292,7 +1292,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmi= o_info_t *info, its->creadr =3D 0; spin_unlock(&its->its_lock); =20 - return 1; + break; =20 case VREG64(GITS_CWRITER): if ( !vgic_reg64_check_access(info->dabt) ) goto bad_width; @@ -1308,7 +1308,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmi= o_info_t *info, =20 spin_unlock(&its->vcmd_lock); =20 - return 1; + break; =20 case VREG64(GITS_CREADR): goto write_ignore_64; @@ -1353,7 +1353,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmi= o_info_t *info, =20 its->baser_dev =3D reg; spin_unlock(&its->its_lock); - return 1; + break; =20 case VREG64(GITS_BASER1): /* collection table */ if ( !vgic_reg64_check_access(info->dabt) ) goto bad_width; @@ -1384,7 +1384,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmi= o_info_t *info, its->max_collections =3D 0; its->baser_coll =3D reg; spin_unlock(&its->its_lock); - return 1; + break; =20 case VRANGE64(GITS_BASER2, GITS_BASER7): goto write_ignore_64; --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290665137386.0250797859486; Mon, 11 Dec 2023 02:31:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651596.1017332 (Exim 4.92) (envelope-from ) id 1rCdYc-0005eq-K4; Mon, 11 Dec 2023 10:30:38 +0000 Received: by outflank-mailman (output) from mailman id 651596.1017332; Mon, 11 Dec 2023 10:30:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYc-0005ej-GQ; Mon, 11 Dec 2023 10:30:38 +0000 Received: by outflank-mailman (input) for mailman id 651596; Mon, 11 Dec 2023 10:30:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYb-00059V-5z for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:37 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 52789d88-9810-11ee-98e8-6d05b1d4d9a1; Mon, 11 Dec 2023 11:30:36 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 216EA4EE0744; Mon, 11 Dec 2023 11:30:36 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 52789d88-9810-11ee-98e8-6d05b1d4d9a1 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , George Dunlap , Dario Faggioli Subject: [XEN PATCH 4/7] xen/sched: address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:25 +0100 Message-Id: <4006f1eb1977a89a57c5c02f003a2fefc06dfc42.1702283415.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290667059100007 Content-Type: text/plain; charset="utf-8" The break statement after the return statement is definitely unreachable and can be removed with no functional change. Signed-off-by: Nicola Vetrini Acked-by: George Dunlap Reviewed-by: Stefano Stabellini --- xen/common/sched/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index f6ac1e5af8bd..d177c675c81b 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2239,7 +2239,6 @@ static bool sched_tasklet_check_cpu(unsigned int cpu) /* fallthrough */ case TASKLET_enqueued|TASKLET_scheduled: return true; - break; case TASKLET_scheduled: clear_bit(_TASKLET_scheduled, tasklet_work); /* fallthrough */ --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290661446560.3405719888538; Mon, 11 Dec 2023 02:31:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651599.1017354 (Exim 4.92) (envelope-from ) id 1rCdYf-00065l-MC; Mon, 11 Dec 2023 10:30:41 +0000 Received: by outflank-mailman (output) from mailman id 651599.1017354; Mon, 11 Dec 2023 10:30:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYf-00064Z-Gg; Mon, 11 Dec 2023 10:30:41 +0000 Received: by outflank-mailman (input) for mailman id 651599; Mon, 11 Dec 2023 10:30:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYe-0005Em-3t for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:40 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 52e3650c-9810-11ee-9b0f-b553b5be7939; Mon, 11 Dec 2023 11:30:37 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 959214EE0740; Mon, 11 Dec 2023 11:30:36 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 52e3650c-9810-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [XEN PATCH 5/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed Date: Mon, 11 Dec 2023 11:30:26 +0100 Message-Id: <394b69b769f2dc2461d2ddb0c7e037f4794eb244.1702283415.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290663108100001 Content-Type: text/plain; charset="utf-8" The branches of the switch after a call to 'do_unexpected_trap' cannot return, but there is one path that may return, hence only some clauses are marked with ASSERT_UNREACHABLE(). Signed-off-by: Nicola Vetrini --- xen/arch/arm/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 3784e8276ef6..e7c920b043d2 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -2152,7 +2152,7 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs) case HSR_EC_SVE: /* An SVE exception is a bug somewhere in hypervisor code */ do_unexpected_trap("SVE trap at EL2", regs); - break; + ASSERT_UNREACHABLE(); #endif case HSR_EC_DATA_ABORT_CURR_EL: case HSR_EC_INSTR_ABORT_CURR_EL: @@ -2171,13 +2171,13 @@ void do_trap_hyp_sync(struct cpu_user_regs *regs) dump_hyp_walk(get_hfar(is_data)); =20 do_unexpected_trap(fault, regs); - - break; + ASSERT_UNREACHABLE(); } default: printk("Hypervisor Trap. HSR=3D%#"PRIregister" EC=3D0x%x IL=3D%x S= yndrome=3D0x%"PRIx32"\n", hsr.bits, hsr.ec, hsr.len, hsr.iss); do_unexpected_trap("Hypervisor", regs); + ASSERT_UNREACHABLE(); } } =20 --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290668944207.14981108477218; Mon, 11 Dec 2023 02:31:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651600.1017363 (Exim 4.92) (envelope-from ) id 1rCdYg-0006Et-Fq; Mon, 11 Dec 2023 10:30:42 +0000 Received: by outflank-mailman (output) from mailman id 651600.1017363; Mon, 11 Dec 2023 10:30:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYg-0006Ci-0K; Mon, 11 Dec 2023 10:30:42 +0000 Received: by outflank-mailman (input) for mailman id 651600; Mon, 11 Dec 2023 10:30:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYe-0005Em-TA for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:40 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 533cb554-9810-11ee-9b0f-b553b5be7939; Mon, 11 Dec 2023 11:30:38 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 46FDA4EE0742; Mon, 11 Dec 2023 11:30:37 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 533cb554-9810-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 6/7] x86/platform: removed break to address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:27 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290671177100002 Content-Type: text/plain; charset="utf-8" The break statement is redundant, hence it can be removed. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- xen/arch/x86/platform_hypercall.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hype= rcall.c index 4dde71db275c..7556c6e6cd0c 100644 --- a/xen/arch/x86/platform_hypercall.c +++ b/xen/arch/x86/platform_hypercall.c @@ -723,7 +723,6 @@ ret_t do_platform_op( =20 ret =3D continue_hypercall_on_cpu( 0, cpu_down_helper, (void *)(unsigned long)cpu); - break; } break; =20 --=20 2.34.1 From nobody Sun May 19 10:14:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1702290661464362.4080873164427; Mon, 11 Dec 2023 02:31:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.651601.1017381 (Exim 4.92) (envelope-from ) id 1rCdYh-0006qO-Nr; Mon, 11 Dec 2023 10:30:43 +0000 Received: by outflank-mailman (output) from mailman id 651601.1017381; Mon, 11 Dec 2023 10:30:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYh-0006pj-JF; Mon, 11 Dec 2023 10:30:43 +0000 Received: by outflank-mailman (input) for mailman id 651601; Mon, 11 Dec 2023 10:30:42 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCdYf-0005Em-TF for xen-devel@lists.xenproject.org; Mon, 11 Dec 2023 10:30:41 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 53a27fd5-9810-11ee-9b0f-b553b5be7939; Mon, 11 Dec 2023 11:30:38 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id CF4CE4EE0744; Mon, 11 Dec 2023 11:30:37 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 53a27fd5-9810-11ee-9b0f-b553b5be7939 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Nicola Vetrini , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH 7/7] x86/xstate: move BUILD_BUG_ON to address MISRA C:2012 Rule 2.1 Date: Mon, 11 Dec 2023 11:30:28 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702290663254100003 Content-Type: text/plain; charset="utf-8" The string literal inside the expansion of BUILD_BUG_ON is considered unreachable code; however, such statement can be moved earlier with no functional change. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- The motivation for this code movement is that keeping it inside the switch statement matches MISRA's definition of unreachable code, but does not fall= into the category of declarations without initialization, which is already a dev= iated aspect. An alternative approach would be to deviate BUILD_BUG_ON as well. --- xen/arch/x86/xstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index cf94761d0542..99f0526c8988 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -396,9 +396,10 @@ void xrstor(struct vcpu *v, uint64_t mask) */ for ( prev_faults =3D faults =3D 0; ; prev_faults =3D faults ) { + BUILD_BUG_ON(sizeof(faults) !=3D 4); /* Clang doesn't support %z i= n asm. */ + switch ( __builtin_expect(ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET], 8)= ) { - BUILD_BUG_ON(sizeof(faults) !=3D 4); /* Clang doesn't support = %z in asm. */ #define _xrstor(insn) \ asm volatile ( "1: .byte " insn "\n" \ "3:\n" \ --=20 2.34.1