From patchwork Mon Dec 11 10:30:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486984 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5416EC46CC5 for ; Mon, 11 Dec 2023 10:30:54 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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) } } -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 */ case SHUTDOWN_crash: debugger_trap_immediate(); printk("Hardware Dom%u crashed: ", hardware_domain->domain_id); kexec_crash(CRASHREASON_HWDOM); maybe_reboot(); - break; /* not reached */ case SHUTDOWN_reboot: printk("Hardware Dom%u shutdown: rebooting machine\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ 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 */ case SHUTDOWN_soft_reset: printk("Hardware domain %d did unsupported soft reset, rebooting.\n", hardware_domain->domain_id); machine_restart(0); - break; /* not reached */ default: printk("Hardware Dom%u shutdown (unknown reason %u): ", hardware_domain->domain_id, reason); maybe_reboot(); - break; /* not reached */ } -} - +} 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; -void noreturn hwdom_shutdown(u8 reason); +void noreturn hwdom_shutdown(uint8_t reason); void noreturn machine_restart(unsigned int delay_millisecs); void noreturn machine_halt(void); From patchwork Mon Dec 11 10:30:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486985 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CE20C4167B for ; Mon, 11 Dec 2023 10:30:55 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 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_HANDLE_PARAM(void) arg) } spin_unlock(&d->arch.e820_lock); - return 0; + break; } case XENMEM_machine_memory_map: @@ -4818,7 +4818,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( __copy_to_guest(arg, &ctxt.map, 1) ) return -EFAULT; - return 0; + break; } case XENMEM_machphys_mapping: @@ -4834,7 +4834,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( copy_to_guest(arg, &mapping, 1) ) return -EFAULT; - return 0; + break; } #ifdef CONFIG_HVM From patchwork Mon Dec 11 10:30:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486989 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A7B9C4167B for ; Mon, 11 Dec 2023 10:30:57 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; 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, mmio_info_t *info, reg32 & GITS_CTLR_ENABLE); spin_unlock(&its->its_lock); spin_unlock(&its->vcmd_lock); - return 1; + break; } case VREG32(GITS_IIDR): @@ -1292,7 +1292,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, its->creadr = 0; spin_unlock(&its->its_lock); - return 1; + break; 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, mmio_info_t *info, spin_unlock(&its->vcmd_lock); - return 1; + break; case VREG64(GITS_CREADR): goto write_ignore_64; @@ -1353,7 +1353,7 @@ static int vgic_v3_its_mmio_write(struct vcpu *v, mmio_info_t *info, its->baser_dev = reg; spin_unlock(&its->its_lock); - return 1; + break; 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, mmio_info_t *info, its->max_collections = 0; its->baser_coll = reg; spin_unlock(&its->its_lock); - return 1; + break; case VRANGE64(GITS_BASER2, GITS_BASER7): goto write_ignore_64; From patchwork Mon Dec 11 10:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486987 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C82D9C10F07 for ; Mon, 11 Dec 2023 10:30:55 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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 */ From patchwork Mon Dec 11 10:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486983 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36954C10DC3 for ; Mon, 11 Dec 2023 10:30:54 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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)); do_unexpected_trap(fault, regs); - - break; + ASSERT_UNREACHABLE(); } default: printk("Hypervisor Trap. HSR=%#"PRIregister" EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n", hsr.bits, hsr.ec, hsr.len, hsr.iss); do_unexpected_trap("Hypervisor", regs); + ASSERT_UNREACHABLE(); } } From patchwork Mon Dec 11 10:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486986 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14300C46CC6 for ; Mon, 11 Dec 2023 10:30:56 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 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_hypercall.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( ret = continue_hypercall_on_cpu( 0, cpu_down_helper, (void *)(unsigned long)cpu); - break; } break; From patchwork Mon Dec 11 10:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13486982 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC53DC4167B for ; Mon, 11 Dec 2023 10:30:52 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 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 deviated 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 = faults = 0; ; prev_faults = faults ) { + BUILD_BUG_ON(sizeof(faults) != 4); /* Clang doesn't support %z in asm. */ + switch ( __builtin_expect(ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET], 8) ) { - BUILD_BUG_ON(sizeof(faults) != 4); /* Clang doesn't support %z in asm. */ #define _xrstor(insn) \ asm volatile ( "1: .byte " insn "\n" \ "3:\n" \