From nobody Fri May 17 06:07:32 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 1713382662589264.94457292315155; Wed, 17 Apr 2024 12:37:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.707737.1105957 (Exim 4.92) (envelope-from ) id 1rxB5s-0004an-Ur; Wed, 17 Apr 2024 19:37:20 +0000 Received: by outflank-mailman (output) from mailman id 707737.1105957; Wed, 17 Apr 2024 19:37:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rxB5s-0004aa-RY; Wed, 17 Apr 2024 19:37:20 +0000 Received: by outflank-mailman (input) for mailman id 707737; Wed, 17 Apr 2024 19:37:20 +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 1rxB5s-0004XH-9A for xen-devel@lists.xenproject.org; Wed, 17 Apr 2024 19:37:20 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e77ba27b-fcf1-11ee-b909-491648fe20b8; Wed, 17 Apr 2024 21:37:19 +0200 (CEST) Received: from nico.bugseng.com (unknown [46.228.253.202]) by support.bugseng.com (Postfix) with ESMTPSA id F405A4EE074D; Wed, 17 Apr 2024 21:37:17 +0200 (CEST) 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: e77ba27b-fcf1-11ee-b909-491648fe20b8 From: Nicola Vetrini To: xen-devel@lists.xenproject.org, nicola.vetrini@bugseng.com Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, bertrand.marquis@arm.com, julien@xen.org, Andrew Cooper , George Dunlap , Jan Beulich Subject: [XEN PATCH v3 1/2] xen/domctl: address violations of MISRA C Rule 16.2 Date: Wed, 17 Apr 2024 21:37:11 +0200 Message-Id: <6ebb49a8ae92dc036d7bed0c708a8830bb93c788.1713382466.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: 1713382663260100003 Content-Type: text/plain; charset="utf-8" Refactor the first clauses so that a violation of MISRA C Rule 16.2 is resolved (a switch label should be immediately enclosed in the compound statement of the switch). Note that the switch clause ending with the pseudo keyword "fallthrough" is an allowed exception to Rule 16.3. Convert fallthrough comments in other clauses to the pseudo-keyword while at it. No functional change. Signed-off-by: Nicola Vetrini Acked-by: Jan Beulich --- docs/misra/safe.json | 8 ++++++++ xen/common/domain.c | 1 + 2 files changed, 9 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index fe2bc185097d..9b13bcf71706 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -44,6 +44,14 @@ }, { "id": "SAF-5-safe", + "analyser": { + "eclair": "MC3R1.R16.2" + }, + "name": "MC3R1.R16.2: using a case label when the most closely= -enclosing compound statement is not a switch statement", + "text": "A switch label enclosed by some compound statement th= at is not the body of a switch is permitted within local helper macros that= are unlikely to be misused or misunderstood." + }, + { + "id": "SAF-6-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/common/domain.c b/xen/common/domain.c index 282c3ab62308..1e555d658c97 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -457,6 +457,7 @@ static int domain_teardown(struct domain *d) =20 for_each_vcpu ( d, v ) { + /* SAF-5-safe MISRA C Rule 16.2: switch label enclosed by for = loop*/ PROGRESS_VCPU(teardown); =20 rc =3D vcpu_teardown(v); --=20 2.34.1 From nobody Fri May 17 06:07:32 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 1713382663655115.27955653471224; Wed, 17 Apr 2024 12:37:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.707738.1105973 (Exim 4.92) (envelope-from ) id 1rxB5z-000537-6D; Wed, 17 Apr 2024 19:37:27 +0000 Received: by outflank-mailman (output) from mailman id 707738.1105973; Wed, 17 Apr 2024 19:37:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rxB5z-000530-3H; Wed, 17 Apr 2024 19:37:27 +0000 Received: by outflank-mailman (input) for mailman id 707738; Wed, 17 Apr 2024 19:37:26 +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 1rxB5y-00050p-Fa for xen-devel@lists.xenproject.org; Wed, 17 Apr 2024 19:37:26 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e930535f-fcf1-11ee-94a3-07e782e9044d; Wed, 17 Apr 2024 21:37:22 +0200 (CEST) Received: from nico.bugseng.com (unknown [46.228.253.202]) by support.bugseng.com (Postfix) with ESMTPSA id D31534EE074E; Wed, 17 Apr 2024 21:37:20 +0200 (CEST) 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: e930535f-fcf1-11ee-94a3-07e782e9044d From: Nicola Vetrini To: xen-devel@lists.xenproject.org, nicola.vetrini@bugseng.com Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, bertrand.marquis@arm.com, julien@xen.org, Simone Ballarin , Doug Goldstein , Andrew Cooper , George Dunlap , Jan Beulich Subject: [XEN PATCH v3 2/2] eclair_analysis: deviate x86 emulator for Rule 16.2 Date: Wed, 17 Apr 2024 21:37:12 +0200 Message-Id: <4ab08d63b264da38d8d91b37ae18a5fb7999d47f.1713382466.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: 1713382665335100001 Content-Type: text/plain; charset="utf-8" MISRA C Rule 16.2 states: "A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement". Since complying with this rule of the x86 emulator would lead to a lot of code duplication, it is deemed better to exempt those files for this guideline. No functional change. Signed-off-by: Nicola Vetrini Acked-by: Stefano Stabellini --- automation/eclair_analysis/ECLAIR/deviations.ecl | 7 +++++++ docs/misra/deviations.rst | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index 0230b41c6d1c..190f6a2fd4e0 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -358,6 +358,13 @@ therefore have the same behavior of a boolean" # Series 16. # =20 +-doc_begin=3D"Complying with the Rule would entail a lot of code duplicati= on in the implementation of the x86 emulator, +therefore it is deemed better to leave such files as is." +-file_tag+=3D{x86_emulate,"^xen/arch/x86/x86_emulate/.*$"} +-file_tag+=3D{x86_svm_emulate,"^xen/arch/x86/hvm/svm/emulate\\.c$"} +-config=3DMC3R1.R16.2,reports+=3D{deliberate, "any_area(any_loc(file(x86_e= mulate||x86_svm_emulate)))"} +-doc_end + -doc_begin=3D"Switch clauses ending with continue, goto, return statements= are safe." -config=3DMC3R1.R16.3,terminals+=3D{safe, "node(continue_stmt||goto_stmt||= return_stmt)"} diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index 32b02905d19a..ed0c1e8ed0bf 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -296,6 +296,12 @@ Deviations related to MISRA C:2012 Rules: therefore have the same behavior of a boolean. - Project-wide deviation; tagged as `deliberate` for ECLAIR. =20 + * - R16.2 + - Complying with the Rule would entail a lot of code duplication in t= he + implementation of the x86 emulator, therefore it is deemed better to + leave such files as is. + - Tagged as `deliberate` for ECLAIR. + * - R16.3 - Switch clauses ending with continue, goto, return statements are sa= fe. - Tagged as `safe` for ECLAIR. --=20 2.34.1