From patchwork Mon Oct 7 14:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13824787 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 DFB99CFB441 for ; Mon, 7 Oct 2024 14:29:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.812105.1224820 (Exim 4.92) (envelope-from ) id 1sxojj-0004OG-Hj; Mon, 07 Oct 2024 14:29:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 812105.1224820; Mon, 07 Oct 2024 14:29:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxojj-0004O9-Ej; Mon, 07 Oct 2024 14:29:23 +0000 Received: by outflank-mailman (input) for mailman id 812105; Mon, 07 Oct 2024 14:29:22 +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 1sxoXM-0002dC-8D for xen-devel@lists.xenproject.org; Mon, 07 Oct 2024 14:16:36 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c16f7f91-84b6-11ef-99a2-01e77a169b0f; Mon, 07 Oct 2024 16:16:33 +0200 (CEST) Received: from truciolo.bugseng.com (unknown [37.162.58.49]) by support.bugseng.com (Postfix) with ESMTPSA id ACA1E4EE0743; Mon, 7 Oct 2024 16:16:32 +0200 (CEST) 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: c16f7f91-84b6-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1728310593; bh=pkehAqIigHugA14oiN/kSXZIjXGX6ygiIRmSA9aEPl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNsLZMClLCIOP+iP8GcTHaCg58dgwWfkO4r+WhG5ZXUvUN0XFBIc1ScaaIwfzRhfL /odxlPhj6dvIpEFtVIF20a88aIPFblEWcM9g0rkadhHOmkTB3USqkpTDp7NgUBeY98 MTLbB+0j3XluWB88FxHjz3xVp9fqLMQ6qyJPvbUu7PfiJqqityPafRMrZwu69ubTxE lIKwmy0JRR7Zzllp5I0yEmMUAevmpLiiC+TE4zq4Eu2Dx2CAwQheVCtNXeVZxWiLG0 152/2bXWyuG0avdiQDhlCSmOm7vhz6e0TVYB7cN0QiwA2KjZmGXLJRqaomAEafzt7V iRuv3ufAY364Q== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH v2 1/4] x86/emul: add defensive code Date: Mon, 7 Oct 2024 16:16:16 +0200 Message-ID: <063bd71b535825715bd54ee9238bec2fc87f0bba.1728308312.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Add defensive code after unreachable program points. This also meets the requirements to deviate violations of MISRA C:2012 Rule 16.3: "An unconditional `break' statement shall terminate every switch-clause". Signed-off-by: Federico Serafini --- Changes in v2: - use goto unhandleable. --- xen/arch/x86/x86_emulate/x86_emulate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 0ea0d5e67e..6b6b8c8fe4 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -6840,6 +6840,7 @@ x86_emulate( break; default: ASSERT_UNREACHABLE(); + goto unhandleable; } break; #ifdef HAVE_AS_SSE4_2 @@ -6868,6 +6869,7 @@ x86_emulate( # endif default: ASSERT_UNREACHABLE(); + goto unhandleable; } break; #endif From patchwork Mon Oct 7 14:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13824786 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 EB841CFB441 for ; Mon, 7 Oct 2024 14:28:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.812092.1224812 (Exim 4.92) (envelope-from ) id 1sxoiy-0002YQ-Be; Mon, 07 Oct 2024 14:28:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 812092.1224812; Mon, 07 Oct 2024 14:28:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxoiy-0002YB-5T; Mon, 07 Oct 2024 14:28:36 +0000 Received: by outflank-mailman (input) for mailman id 812092; Mon, 07 Oct 2024 14:28: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 1sxoXL-0002yM-TY for xen-devel@lists.xenproject.org; Mon, 07 Oct 2024 14:16:35 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c25ca249-84b6-11ef-a0bb-8be0dac302b0; Mon, 07 Oct 2024 16:16:35 +0200 (CEST) Received: from truciolo.bugseng.com (unknown [37.162.58.49]) by support.bugseng.com (Postfix) with ESMTPSA id D37314EE0745; Mon, 7 Oct 2024 16:16:33 +0200 (CEST) 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: c25ca249-84b6-11ef-a0bb-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1728310595; bh=bPGNGs/7gKws9KC4a8OFYQw2+N/QcDxZjIxN7dUNgMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNh/5lISmIQ1gmhVCXsh3Ez15sbICvQAm7ysmvf676GQzNBIlv2V2aSe2xHDGo4sP wpMcgMFqQnALlSIk2QY9IIUG/O/+o7g8lL1lQjw4EdlaTtR+h1pEWtZFmMlpOiitUe ihO3ihs9V3gfIXk4jPbloTuP45zJ+Nz+bmCPE6keWYqjmGBlQHMzu9jX7WKKj1hw9W 7Jxnt4WVAeh0EG3Az1cmMGCqfGi5DGFoD1sygqxPloAbZtZZzTVEE8DaHBCeOzn5WT lNeJNlRFbF8UuGpFzvDqgt3pOWIXySZzTCl9/+3IsSxKovXJMrJabk0nXwUwK2PVZL ivq6qW/m4a2Yg== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH v2 2/4] x86/emul: address violations of MISRA C Rule 16.3 Date: Mon, 7 Oct 2024 16:16:17 +0200 Message-ID: <662440bc082fcb91ad9489999add02fc71416d45.1728308312.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Add missing break statements to address violations of MISRA C:2012 Rule 16.3 (An unconditional `break' statement shall terminate every switch-clause). Make explicit unreachability of a program points with ASSERT_UNREACHABLE(). No functional change. Signed-off-by: Federico Serafini --- Changes in v2: - unreachability made explicit. --- xen/arch/x86/x86_emulate/fpu.c | 5 +++++ xen/arch/x86/x86_emulate/x86_emulate.c | 1 + 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/x86_emulate/fpu.c b/xen/arch/x86/x86_emulate/fpu.c index 480d879657..f0dab346e0 100644 --- a/xen/arch/x86/x86_emulate/fpu.c +++ b/xen/arch/x86/x86_emulate/fpu.c @@ -218,6 +218,7 @@ int x86emul_fpu(struct x86_emulate_state *s, */ if ( dst->type == OP_MEM && !s->fpu_ctrl && !fpu_check_write() ) dst->type = OP_NONE; + break; } break; @@ -296,6 +297,7 @@ int x86emul_fpu(struct x86_emulate_state *s, default: generate_exception(X86_EXC_UD); } + break; } break; @@ -386,6 +388,7 @@ int x86emul_fpu(struct x86_emulate_state *s, */ if ( dst->type == OP_MEM && !s->fpu_ctrl && !fpu_check_write() ) dst->type = OP_NONE; + break; } break; @@ -457,6 +460,8 @@ int x86emul_fpu(struct x86_emulate_state *s, case 7: /* fistp m64i */ goto fpu_memdst64; } + ASSERT_UNREACHABLE(); + break; } break; diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 6b6b8c8fe4..30674ec301 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -8310,6 +8310,7 @@ x86_emulate( } if ( rc != 0 ) goto done; + break; default: break; } From patchwork Mon Oct 7 14:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13824788 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 449D7CFB43F for ; Mon, 7 Oct 2024 14:29:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.812107.1224831 (Exim 4.92) (envelope-from ) id 1sxojy-00056T-Tf; Mon, 07 Oct 2024 14:29:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 812107.1224831; Mon, 07 Oct 2024 14:29: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 1sxojy-00055m-Qj; Mon, 07 Oct 2024 14:29:38 +0000 Received: by outflank-mailman (input) for mailman id 812107; Mon, 07 Oct 2024 14:29:37 +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 1sxoXO-0002dC-IW for xen-devel@lists.xenproject.org; Mon, 07 Oct 2024 14:16:38 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c2f69c14-84b6-11ef-99a2-01e77a169b0f; Mon, 07 Oct 2024 16:16:36 +0200 (CEST) Received: from truciolo.bugseng.com (unknown [37.162.58.49]) by support.bugseng.com (Postfix) with ESMTPSA id 67D704EE0746; Mon, 7 Oct 2024 16:16:35 +0200 (CEST) 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: c2f69c14-84b6-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1728310596; bh=E7dB2FCofs9MFp7zihxh1wxnARDyNN7WgWI2FwQOK0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xVPGjM9WjmZpi8GG7K9MaKDBHZwteFI3oEC0yibwshSbIA5MxmazJ2nlmAPH8z8XV ydBaf+FQ3AAfT6hfAwEp+ksKFO0j3UVtrKrGnAda5JHB1CZ95YQ3HUS/3Q1OZ2nTxQ H8syHKDPHxjy1fQyO5r4zkGDoCtrIXjXLuLv8lw5Kczd1hIT4IKijqL9g9v9qI11gI +qEtVlpB+dKouWU80A4wXuR4lR6tr4lT2lzuSLkIu6ghEwCTary4FKkxx9+cdLJx3x CXMSp0RmQwR08y0eiH6H9A5HEKEw+OjqeWqpyEo39l4OUfYP5eQLpvAWdO2oIA/i1I 0gH2S1Owz3nLA== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH v2 3/4] xen/vpci: address violations of MISRA C Rule 16.3 Date: Mon, 7 Oct 2024 16:16:18 +0200 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Address violations of MISRA C:2012 Rule 16.3: "An unconditional `break' statement shall terminate every switch-clause". No functional change. Signed-off-by: Federico Serafini Acked-by: Roger Pau Monné --- Changes from v2: - simply break without returning X86EMUL_UNHANDLEABLE. As pointed out by Jan, these functions only return X86EMUL_OKAY but: https://lists.xenproject.org/archives/html/xen-devel/2024-09/msg00727.html Do you have any comments? --- xen/drivers/vpci/msix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c index fbe710ab92..5bb4444ce2 100644 --- a/xen/drivers/vpci/msix.c +++ b/xen/drivers/vpci/msix.c @@ -364,6 +364,7 @@ static int adjacent_read(const struct domain *d, const struct vpci_msix *msix, default: ASSERT_UNREACHABLE(); + break; } spin_unlock(&vpci->lock); @@ -512,6 +513,7 @@ static int adjacent_write(const struct domain *d, const struct vpci_msix *msix, default: ASSERT_UNREACHABLE(); + break; } spin_unlock(&vpci->lock); From patchwork Mon Oct 7 14:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13824784 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 B052CCFB43F for ; Mon, 7 Oct 2024 14:26:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.812062.1224770 (Exim 4.92) (envelope-from ) id 1sxogs-0005Z4-8C; Mon, 07 Oct 2024 14:26:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 812062.1224770; Mon, 07 Oct 2024 14:26:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxogs-0005Yx-5i; Mon, 07 Oct 2024 14:26:26 +0000 Received: by outflank-mailman (input) for mailman id 812062; Mon, 07 Oct 2024 14:26:25 +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 1sxoXO-0002yM-3E for xen-devel@lists.xenproject.org; Mon, 07 Oct 2024 14:16:38 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c3bc471c-84b6-11ef-a0bb-8be0dac302b0; Mon, 07 Oct 2024 16:16:37 +0200 (CEST) Received: from truciolo.bugseng.com (unknown [37.162.58.49]) by support.bugseng.com (Postfix) with ESMTPSA id 4C67E4EE074C; Mon, 7 Oct 2024 16:16:36 +0200 (CEST) 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: c3bc471c-84b6-11ef-a0bb-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bugseng.com; s=mail; t=1728310597; bh=Cj7N+K8vyoIngmTvtRYCAMfqpWWddHIl9pmTFZ7wneY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HlM9scJN3uJ3HDUAg+2dJHb1oLxWkXIjhV32iHKtNcMKHzFdTtGNxjUfVtugP5QZf pinxogS46o5Y5Vq9wmzsTzfT5LtLERkht6uXnM+jIQGHCJbAQ45yG1ckvoTa5PBIH8 hCLAgvPD74v/aZa42Ji+wDxzrJXWnrZstmeFw1bJMszg1MWt2GxMaEaibWDnRBaMwj LugF/OPtHc8rdwS/+F2oAsmwO/Wq935GBF+GPJyj7Ku3Ihp+rgZ481hUrV1EfT1cAh walqsVhR3YBwGY7C0LUc6C4CrKeQOizm7nVh8LJa7sfcezrrbU5S4tz8y4bOTrdrrC XUHLbd6hHFOxA== From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [XEN PATCH v2 4/4] xen/pci: address a violation of MISRA C Rule 16.3 Date: Mon, 7 Oct 2024 16:16:19 +0200 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Refactor the code to avoid an implicit fallthrough and address a violation of MISRA C:2012 Rule 16.3: "An unconditional `break' statement shall terminate every switch-clause". No functional change. Signed-off-by: Federico Serafini Reviewed-by: Stefano Stabellini Acked-by: Roger Pau Monné --- Changes in v2: - improved description. --- xen/drivers/passthrough/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 5a446d3dce..a5705def3f 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -170,8 +170,10 @@ static int __init cf_check parse_phantom_dev(const char *str) { case 1: case 2: case 4: if ( *s ) - default: return -EINVAL; + break; + default: + return -EINVAL; } phantom_devs[nr_phantom_devs++] = phantom;