From nobody Tue May 14 09:31:36 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 169451152405538.65189426536028; Tue, 12 Sep 2023 02:38:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600135.935752 (Exim 4.92) (envelope-from ) id 1qfzql-0000mQ-0F; Tue, 12 Sep 2023 09:38:27 +0000 Received: by outflank-mailman (output) from mailman id 600135.935752; Tue, 12 Sep 2023 09:38: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 1qfzqk-0000mJ-TS; Tue, 12 Sep 2023 09:38:26 +0000 Received: by outflank-mailman (input) for mailman id 600135; Tue, 12 Sep 2023 09:38:26 +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 1qfzqk-0000lh-4f for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:26 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1e561451-5150-11ee-8786-cb3800f73035; Tue, 12 Sep 2023 11:38:24 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id CB11A4EE0745; Tue, 12 Sep 2023 11:38:23 +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: 1e561451-5150-11ee-8786-cb3800f73035 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN PATCH v2 01/10] misra: add deviation for headers that explicitly avoid guards Date: Tue, 12 Sep 2023 11:36:47 +0200 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: 1694511525889100001 Content-Type: text/plain; charset="utf-8" Some headers, under specific circumstances (documented in a comment at the beginning of the file), explicitly avoid inclusion guards: the caller is responsible for including them correctly. These files are not supposed to comply with Directive 4.10: "Precautions shall be taken in order to prevent the contents of a header file being included more than once" This patch adds deviation cooments for headers that avoid guards. Signed-off-by: Simone Ballarin --- Changes in v2: - use the format introduced with doc/misra/safe.json instead of a generic text-based deviation --- docs/misra/safe.json | 8 ++++++++ xen/include/public/arch-x86/cpufeatureset.h | 1 + xen/include/public/errno.h | 1 + 3 files changed, 10 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 39c5c056c7..db438c9770 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -20,6 +20,14 @@ }, { "id": "SAF-2-safe", + "analyser": { + "eclair": "MC3R1.D4.10" + }, + "name": "Dir 4.10: headers that leave it up to the caller to i= nclude them correctly", + "text": "Headers that deliberatively avoid inclusion guards ex= plicitly leaving responsibility to the caller are allowed." + }, + { + "id": "SAF-3-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/publ= ic/arch-x86/cpufeatureset.h index 6b6ce2745c..eac1ae4b2a 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -23,6 +23,7 @@ * their XEN_CPUFEATURE() being appropriate in the included context. */ =20 +/* SAF-1-safe header that leaves it up to the caller to include them corre= ctly */ #ifndef XEN_CPUFEATURE =20 /* diff --git a/xen/include/public/errno.h b/xen/include/public/errno.h index 5a78a7607c..8b60ac74ae 100644 --- a/xen/include/public/errno.h +++ b/xen/include/public/errno.h @@ -17,6 +17,7 @@ * will unilaterally #undef XEN_ERRNO(). */ =20 +/* SAF-1-safe header that leaves it up to the caller to include them corre= ctly */ #ifndef XEN_ERRNO =20 /* --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694511535538885.9057451853383; Tue, 12 Sep 2023 02:38:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600143.935762 (Exim 4.92) (envelope-from ) id 1qfzqx-0001J8-Cu; Tue, 12 Sep 2023 09:38:39 +0000 Received: by outflank-mailman (output) from mailman id 600143.935762; Tue, 12 Sep 2023 09:38:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzqx-0001J1-8w; Tue, 12 Sep 2023 09:38:39 +0000 Received: by outflank-mailman (input) for mailman id 600143; Tue, 12 Sep 2023 09:38:38 +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 1qfzqw-0008Jk-3J for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:38 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 24d5358b-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:38:35 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id A41494EE0743; Tue, 12 Sep 2023 11:38:34 +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: 24d5358b-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Doug Goldstein , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN PATCH v2 02/10] misra: modify deviations for empty and generated headers Date: Tue, 12 Sep 2023 11:36:48 +0200 Message-Id: <6da900e1692ac1c1fff554da53dfbbeb1e42ad07.1694510856.git.simone.ballarin@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: 1694511538034100001 Content-Type: text/plain; charset="utf-8" This patch modifies deviations for Directive 4.10: "Precautions shall be taken in order to prevent the contents of a header file being included more than once" This patch avoids the file-based deviation for empty headers, and replaces it with a comment-based one using the format specified in docs/misra/safe.json. Generated headers are not generally safe against multi-inclusions, whether a header is safe depends on the nature of the generated code in the header. For that reason, this patch drops the deviation for generated headers. Signed-off-by: Simone Ballarin --- Changes in v2: - use the format introduced with doc/misra/safe.json instead of a file-based deviation for empty headers - remove deviation for generated headers --- automation/eclair_analysis/ECLAIR/deviations.ecl | 7 ------- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/efi/runtime.h | 1 + xen/include/Makefile | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index d8170106b4..9313027af1 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -78,13 +78,6 @@ inline functions." -config=3DMC3R1.D4.9,macros+=3D{deliberate, "loc(file(api:public))"} -doc_end =20 --doc_begin=3D"This header file is autogenerated or empty, therefore it pos= es no -risk if included more than once." --file_tag+=3D{empty_header, "^xen/arch/arm/efi/runtime\\.h$"} --file_tag+=3D{autogen_headers, "^xen/include/xen/compile\\.h$||^xen/includ= e/generated/autoconf.h$||^xen/include/xen/hypercall-defs.h$"} --config=3DMC3R1.D4.10,reports+=3D{safe, "all_area(all_loc(file(empty_heade= r||autogen_headers)))"} --doc_end - -doc_begin=3D"Files that are intended to be included more than once do not= need to conform to the directive." -config=3DMC3R1.D4.10,reports+=3D{safe, "first_area(text(^/\\* This file i= s legitimately included multiple times\\. \\*/$, begin-4))"} diff --git a/docs/misra/safe.json b/docs/misra/safe.json index db438c9770..e8e200cb0a 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -28,6 +28,14 @@ }, { "id": "SAF-3-safe", + "analyser": { + "eclair": "MC3R1.D4.10" + }, + "name": "Dir 4.10: empty headers", + "text": "Empty headers pose no risk if included more than once= ." + }, + { + "id": "SAF-4-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/arm/efi/runtime.h b/xen/arch/arm/efi/runtime.h index 25afcebed1..5e35184ff4 100644 --- a/xen/arch/arm/efi/runtime.h +++ b/xen/arch/arm/efi/runtime.h @@ -1 +1,2 @@ +/* SAF-2-safe empty header */ /* Placeholder for ARM-specific runtime include/declarations */ diff --git a/xen/include/Makefile b/xen/include/Makefile index 2e61b50139..31782fb177 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -53,7 +53,7 @@ cmd_compat_h =3D \ mv -f $@.new $@ =20 quiet_cmd_stub_h =3D GEN $@ -cmd_stub_h =3D echo '/* empty */' >$@ +cmd_stub_h =3D echo '/* SAF-2-safe empty header */' >$@ =20 quiet_cmd_compat_i =3D CPP $@ cmd_compat_i =3D $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/c= onfig.h,$(XEN_CFLAGS)) $(cppflags-y) -o $@ $< --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694512030597923.9829706705995; Tue, 12 Sep 2023 02:47:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600192.935842 (Exim 4.92) (envelope-from ) id 1qfzyx-0006rE-2M; Tue, 12 Sep 2023 09:46:55 +0000 Received: by outflank-mailman (output) from mailman id 600192.935842; Tue, 12 Sep 2023 09:46:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzyw-0006r5-VL; Tue, 12 Sep 2023 09:46:54 +0000 Received: by outflank-mailman (input) for mailman id 600192; Tue, 12 Sep 2023 09:46:53 +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 1qfzr0-0008Jk-Av for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:42 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 280b60d6-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:38:40 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id 0EDA54EE0743; Tue, 12 Sep 2023 11:38:40 +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: 280b60d6-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN PATCH v2 03/10] misra: add deviations for direct inclusion guards Date: Tue, 12 Sep 2023 11:36:49 +0200 Message-Id: <0c1fb82b539d939e7c6655a9a8f3d7fe8b213cef.1694510856.git.simone.ballarin@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: 1694512031945100001 Content-Type: text/plain; charset="utf-8" Add deviation comments to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Inclusion guards must appear at the beginning of the headers (comments are permitted anywhere). This patch adds deviation comments using the format specified in docs/misra/safe.json for headers with just the direct inclusion guard before the inclusion guard since they are safe and not supposed to comply with the directive. Signed-off-by: Simone Ballarin --- The patch has been introduced in v2. --- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/include/asm/hypercall.h | 1 + xen/arch/x86/include/asm/hypercall.h | 1 + xen/include/xen/unaligned.h | 1 + 4 files changed, 11 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index e8e200cb0a..0ec594f6bf 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -36,6 +36,14 @@ }, { "id": "SAF-4-safe", + "analyser": { + "eclair": "MC3R1.D4.10" + }, + "name": "Dir 4.10: direct inclusion guard before", + "text": "Headers with just the direct inclusion guard before t= he inclusion guard are safe." + }, + { + "id": "SAF-5-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/arm/include/asm/hypercall.h b/xen/arch/arm/include/as= m/hypercall.h index ccd26c5184..24f8c61a73 100644 --- a/xen/arch/arm/include/asm/hypercall.h +++ b/xen/arch/arm/include/asm/hypercall.h @@ -1,3 +1,4 @@ +/* SAF-3-safe direct inclusion guard before */ #ifndef __XEN_HYPERCALL_H__ #error "asm/hypercall.h should not be included directly - include xen/hype= rcall.h instead" #endif diff --git a/xen/arch/x86/include/asm/hypercall.h b/xen/arch/x86/include/as= m/hypercall.h index ec2edc771e..dfdfe80021 100644 --- a/xen/arch/x86/include/asm/hypercall.h +++ b/xen/arch/x86/include/asm/hypercall.h @@ -2,6 +2,7 @@ * asm-x86/hypercall.h */ =20 +/* SAF-3-safe direct inclusion guard before */ #ifndef __XEN_HYPERCALL_H__ #error "asm/hypercall.h should not be included directly - include xen/hype= rcall.h instead" #endif diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h index 0a2b16d05d..190ada7800 100644 --- a/xen/include/xen/unaligned.h +++ b/xen/include/xen/unaligned.h @@ -3,6 +3,7 @@ * without faulting, and at least reasonably efficiently. Other architect= ures * will need to have a custom asm/unaligned.h. */ +/* SAF-3-safe direct inclusion guard before */ #ifndef __ASM_UNALIGNED_H__ #error "xen/unaligned.h should not be included directly - include asm/unal= igned.h instead" #endif --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694512007782338.92478137966657; Tue, 12 Sep 2023 02:46:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600169.935801 (Exim 4.92) (envelope-from ) id 1qfzyK-0004w0-Qb; Tue, 12 Sep 2023 09:46:16 +0000 Received: by outflank-mailman (output) from mailman id 600169.935801; Tue, 12 Sep 2023 09:46:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzyK-0004vt-O5; Tue, 12 Sep 2023 09:46:16 +0000 Received: by outflank-mailman (input) for mailman id 600169; Tue, 12 Sep 2023 09:46:15 +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 1qfzr9-0008Jk-An for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:51 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2bf45b43-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:38:47 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id C44A24EE0743; Tue, 12 Sep 2023 11:38:46 +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: 2bf45b43-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN PATCH v2 04/10] xen/arm: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:50 +0200 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: 1694512009826100001 Content-Type: text/plain; charset="utf-8" Add inclusion guard to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Mechanical change. Signed-off-by: Simone Ballarin Acked-by: Stefano Stabellini --- Changes in v2: - drop changes in xen/arch/arm/include/asm/hypercall.h - drop changes in xen/arch/arm/include/asm/iocap.h since they are not related with the directive --- xen/arch/arm/efi/efi-boot.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index 1c3640bb65..aaa468f186 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -3,6 +3,10 @@ * is intended to be included by common/efi/boot.c _only_, and * therefore can define arch specific global variables. */ + +#ifndef __ARM_EFI_EFI_BOOT_H__ +#define __ARM_EFI_EFI_BOOT_H__ + #include #include #include @@ -1003,6 +1007,8 @@ static void __init efi_arch_flush_dcache_area(const v= oid *vaddr, UINTN size) __flush_dcache_area(vaddr, size); } =20 +#endif /* __ARM_EFI_EFI_BOOT_H__ */ + /* * Local variables: * mode: C --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694512024783370.72214849197087; Tue, 12 Sep 2023 02:47:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600184.935832 (Exim 4.92) (envelope-from ) id 1qfzyq-0006Oj-P6; Tue, 12 Sep 2023 09:46:48 +0000 Received: by outflank-mailman (output) from mailman id 600184.935832; Tue, 12 Sep 2023 09:46:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzyq-0006OZ-MP; Tue, 12 Sep 2023 09:46:48 +0000 Received: by outflank-mailman (input) for mailman id 600184; Tue, 12 Sep 2023 09:46:47 +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 1qfzrA-0008Jk-Aw for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:52 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2d2f9255-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:38:49 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id CA0A24EE0745; Tue, 12 Sep 2023 11:38:48 +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: 2d2f9255-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH v2 05/10] xen/x86: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:51 +0200 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: 1694512025379100001 Content-Type: text/plain; charset="utf-8" Add or move inclusion guards to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Inclusion guards must appear at the beginning of the headers (comments are permitted anywhere). Mechanical change. Signed-off-by: Simone Ballarin --- Changes in v2: - remove extra blanks - drop changes in C files Note: Changes in Makefile were not strictly necessary in v1 and a maintainer asked to removing them since there was a deviation for generated headers. Now, in v2, they are required since the deviation has been removed by another patch of this series. --- xen/arch/x86/Makefile | 8 ++++---- xen/arch/x86/cpu/cpu.h | 5 +++++ xen/arch/x86/x86_64/mmconfig.h | 5 +++++ xen/arch/x86/x86_emulate/private.h | 5 +++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index f3abdf9cd1..40d0cb76af 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -260,17 +260,17 @@ $(objtree)/arch/x86/include/asm/asm-macros.h: $(obj)/= asm-macros.i $(src)/Makefil $(call filechk,asm-macros.h) =20 define filechk_asm-macros.h + echo '#ifndef __ASM_MACROS_H__'; \ + echo '#define __ASM_MACROS_H__'; \ echo '#if 0'; \ echo '.if 0'; \ echo '#endif'; \ - echo '#ifndef __ASM_MACROS_H__'; \ - echo '#define __ASM_MACROS_H__'; \ echo 'asm ( ".include \"$@\"" );'; \ - echo '#endif /* __ASM_MACROS_H__ */'; \ echo '#if 0'; \ echo '.endif'; \ cat $<; \ - echo '#endif' + echo '#endif'; \ + echo '#endif /* __ASM_MACROS_H__ */' endef =20 $(obj)/efi.lds: AFLAGS-y +=3D -DEFI diff --git a/xen/arch/x86/cpu/cpu.h b/xen/arch/x86/cpu/cpu.h index e3d06278b3..95939c7fb6 100644 --- a/xen/arch/x86/cpu/cpu.h +++ b/xen/arch/x86/cpu/cpu.h @@ -1,3 +1,6 @@ +#ifndef __X86_CPU_CPU_H__ +#define __X86_CPU_CPU_H__ + /* attempt to consolidate cpu attributes */ struct cpu_dev { void (*c_early_init)(struct cpuinfo_x86 *c); @@ -24,3 +27,5 @@ void amd_init_lfence(struct cpuinfo_x86 *c); void amd_init_ssbd(const struct cpuinfo_x86 *c); void amd_init_spectral_chicken(void); void detect_zen2_null_seg_behaviour(void); + +#endif /* __X86_CPU_CPU_H__ */ diff --git a/xen/arch/x86/x86_64/mmconfig.h b/xen/arch/x86/x86_64/mmconfig.h index 2d49fc79a0..c562879c76 100644 --- a/xen/arch/x86/x86_64/mmconfig.h +++ b/xen/arch/x86/x86_64/mmconfig.h @@ -5,6 +5,9 @@ * Author: Allen Kay - adapted from linux */ =20 +#ifndef __X86_X86_64_MMCONFIG_H__ +#define __X86_X86_64_MMCONFIG_H__ + #define PCI_DEVICE_ID_INTEL_E7520_MCH 0x3590 #define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 =20 @@ -72,3 +75,5 @@ int pci_mmcfg_reserved(uint64_t address, unsigned int seg= ment, int pci_mmcfg_arch_init(void); int pci_mmcfg_arch_enable(unsigned int); void pci_mmcfg_arch_disable(unsigned int); + +#endif /* __X86_X86_64_MMCONFIG_H__ */ diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/= private.h index 719dad59cd..ffa134f297 100644 --- a/xen/arch/x86/x86_emulate/private.h +++ b/xen/arch/x86/x86_emulate/private.h @@ -6,6 +6,9 @@ * Copyright (c) 2005-2007 XenSource Inc. */ =20 +#ifndef __X86_X86_EMULATE_PRIVATE_H__ +#define __X86_X86_EMULATE_PRIVATE_H__ + #ifdef __XEN__ =20 # include @@ -831,3 +834,5 @@ static inline int read_ulong(enum x86_segment seg, *val =3D 0; return ops->read(seg, offset, val, bytes, ctxt); } + +#endif /* __X86_X86_EMULATE_PRIVATE_H__ */ --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694511548987424.05002000285083; Tue, 12 Sep 2023 02:39:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600148.935772 (Exim 4.92) (envelope-from ) id 1qfzrA-0001vj-Ke; Tue, 12 Sep 2023 09:38:52 +0000 Received: by outflank-mailman (output) from mailman id 600148.935772; Tue, 12 Sep 2023 09:38:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzrA-0001vY-H7; Tue, 12 Sep 2023 09:38:52 +0000 Received: by outflank-mailman (input) for mailman id 600148; Tue, 12 Sep 2023 09:38:51 +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 1qfzr9-0000lh-TL for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:51 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2e69508d-5150-11ee-8786-cb3800f73035; Tue, 12 Sep 2023 11:38:51 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id D4F9B4EE0746; Tue, 12 Sep 2023 11:38:50 +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: 2e69508d-5150-11ee-8786-cb3800f73035 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH v2 06/10] x86/EFI: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:52 +0200 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: 1694511551363100001 Content-Type: text/plain; charset="utf-8" Add inclusion guard to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Mechanical change. Signed-off-by: Simone Ballarin --- Changes in v2: - remove changes in "xen/arch/x86/efi/efi-boot.h" Note: Changes in efi-boot.h have been removed since the file is intenteded to be included by common/efi/boot.c only. This motivation is not enough to raise a deviation record, so the violation is still present. --- xen/arch/x86/efi/runtime.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/arch/x86/efi/runtime.h b/xen/arch/x86/efi/runtime.h index 77866c5f21..10b36bcb89 100644 --- a/xen/arch/x86/efi/runtime.h +++ b/xen/arch/x86/efi/runtime.h @@ -1,3 +1,6 @@ +#ifndef __X86_EFI_RUNTIME_H__ +#define __X86_EFI_RUNTIME_H__ + #include #include #include @@ -17,3 +20,5 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry= _t l4e) } } #endif + +#endif /* __X86_EFI_RUNTIME_H__ */ --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694511551324205.34639419241762; Tue, 12 Sep 2023 02:39:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600151.935782 (Exim 4.92) (envelope-from ) id 1qfzrD-0002IJ-Sh; Tue, 12 Sep 2023 09:38:55 +0000 Received: by outflank-mailman (output) from mailman id 600151.935782; Tue, 12 Sep 2023 09:38:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzrD-0002IC-Ou; Tue, 12 Sep 2023 09:38:55 +0000 Received: by outflank-mailman (input) for mailman id 600151; Tue, 12 Sep 2023 09:38:54 +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 1qfzrC-0000lh-Nm for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:38:54 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3017714e-5150-11ee-8786-cb3800f73035; Tue, 12 Sep 2023 11:38:54 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id A13AF4EE0743; Tue, 12 Sep 2023 11:38:53 +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: 3017714e-5150-11ee-8786-cb3800f73035 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH v2 07/10] xen/common: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:53 +0200 Message-Id: <580f202ce2b07a91b496f34dc4b300d8fb23dbc8.1694510856.git.simone.ballarin@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: 1694511552134100003 Content-Type: text/plain; charset="utf-8" Add inclusion guards to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Mechanical change. Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2: - drop changes in C files --- xen/common/decompress.h | 5 +++++ xen/common/event_channel.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/xen/common/decompress.h b/xen/common/decompress.h index e8195b353a..da3c3abb6a 100644 --- a/xen/common/decompress.h +++ b/xen/common/decompress.h @@ -1,3 +1,6 @@ +#ifndef __COMMON_DECOMPRESS_H__ +#define __COMMON_DECOMPRESS_H__ + #ifdef __XEN__ =20 #include @@ -23,3 +26,5 @@ #define large_free free =20 #endif + +#endif /* __COMMON_DECOMPRESS_H__ */ diff --git a/xen/common/event_channel.h b/xen/common/event_channel.h index 45219ca67c..040bad77f9 100644 --- a/xen/common/event_channel.h +++ b/xen/common/event_channel.h @@ -1,5 +1,8 @@ /* Event channel handling private header. */ =20 +#ifndef __COMMON_EVENT_CHANNEL_H__ +#define __COMMON_EVENT_CHANNEL_H__ + #include =20 static inline unsigned int max_evtchns(const struct domain *d) @@ -52,6 +55,8 @@ int evtchn_fifo_init_control(struct evtchn_init_control *= init_control); int evtchn_fifo_expand_array(const struct evtchn_expand_array *expand_arra= y); void evtchn_fifo_destroy(struct domain *d); =20 +#endif /* __COMMON_EVENT_CHANNEL_H__ */ + /* * Local variables: * mode: C --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694511570171703.8642358820442; Tue, 12 Sep 2023 02:39:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600161.935791 (Exim 4.92) (envelope-from ) id 1qfzrX-000383-3D; Tue, 12 Sep 2023 09:39:15 +0000 Received: by outflank-mailman (output) from mailman id 600161.935791; Tue, 12 Sep 2023 09:39:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzrX-00037w-0Y; Tue, 12 Sep 2023 09:39:15 +0000 Received: by outflank-mailman (input) for mailman id 600161; Tue, 12 Sep 2023 09:39:14 +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 1qfzrW-0000lh-56 for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:39:14 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3413f20a-5150-11ee-8786-cb3800f73035; Tue, 12 Sep 2023 11:39:01 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id 786624EE0743; Tue, 12 Sep 2023 11:39:00 +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: 3413f20a-5150-11ee-8786-cb3800f73035 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Jan Beulich Subject: [XEN PATCH v2 08/10] xen/efi: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:54 +0200 Message-Id: <5585708f62883ada3e7900c45a2c97dbcf927294.1694510856.git.simone.ballarin@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: 1694511570527100001 Content-Type: text/plain; charset="utf-8" Add inclusion guards to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Mechanical change. Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2: - drop changes in C files --- xen/common/efi/efi.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h index c02fbb7b69..cef9381d30 100644 --- a/xen/common/efi/efi.h +++ b/xen/common/efi/efi.h @@ -1,3 +1,6 @@ +#ifndef __COMMON_EFI_EFI_H__ +#define __COMMON_EFI_EFI_H__ + #include #include #include @@ -51,3 +54,5 @@ void free_ebmalloc_unused_mem(void); =20 const void *pe_find_section(const void *image, const UINTN image_size, const CHAR16 *section_name, UINTN *size_out); + +#endif /* __COMMON_EFI_EFI_H__ */ --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694512109083492.7227543281389; Tue, 12 Sep 2023 02:48:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600214.935852 (Exim 4.92) (envelope-from ) id 1qg00A-0008GW-CJ; Tue, 12 Sep 2023 09:48:10 +0000 Received: by outflank-mailman (output) from mailman id 600214.935852; Tue, 12 Sep 2023 09:48:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qg00A-0008GP-99; Tue, 12 Sep 2023 09:48:10 +0000 Received: by outflank-mailman (input) for mailman id 600214; Tue, 12 Sep 2023 09:48:08 +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 1qfzri-0008Jk-3S for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:39:26 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4124ea73-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:39:22 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id 458EA4EE0743; Tue, 12 Sep 2023 11:39:22 +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: 4124ea73-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH v2 09/10] xen: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:55 +0200 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: 1694512110089100001 Content-Type: text/plain; charset="utf-8" Amended inclusion guards to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). Inclusion guards must appear at the beginning of the headers (comments are permitted anywhere) and the #if directive cannot be used for other checks. Mechanical change. Reviewed-by: Stefano Stabellini --- Changes in v2: - drop changes in xen/include/xen/unaligned.h since this second series adds a comment-based deviation in a separate patch - use #ifndef instead of #if !defined() --- xen/include/xen/err.h | 4 +++- xen/include/xen/pci_ids.h | 5 +++++ xen/include/xen/softirq.h | 4 +++- xen/include/xen/vmap.h | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h index 2f29b57d28..646c20ab4a 100644 --- a/xen/include/xen/err.h +++ b/xen/include/xen/err.h @@ -1,5 +1,6 @@ -#if !defined(__XEN_ERR_H__) && !defined(__ASSEMBLY__) +#ifndef __XEN_ERR_H__ #define __XEN_ERR_H__ +#ifndef __ASSEMBLY__ =20 #include #include @@ -54,4 +55,5 @@ static inline int __must_check PTR_RET(const void *ptr) return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; } =20 +#endif /* __ASSEMBLY__ */ #endif /* __XEN_ERR_H__ */ diff --git a/xen/include/xen/pci_ids.h b/xen/include/xen/pci_ids.h index e798477a7e..1a739d4c92 100644 --- a/xen/include/xen/pci_ids.h +++ b/xen/include/xen/pci_ids.h @@ -1,3 +1,6 @@ +#ifndef __XEN_PCI_IDS_H__ +#define __XEN_PCI_IDS_H__ + #define PCI_VENDOR_ID_AMD 0x1022 =20 #define PCI_VENDOR_ID_NVIDIA 0x10de @@ -11,3 +14,5 @@ #define PCI_VENDOR_ID_BROADCOM 0x14e4 =20 #define PCI_VENDOR_ID_INTEL 0x8086 + +#endif /* __XEN_PCI_IDS_H__ */ diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index 33d6f2ecd2..4c7655188a 100644 --- a/xen/include/xen/softirq.h +++ b/xen/include/xen/softirq.h @@ -1,5 +1,6 @@ -#if !defined(__XEN_SOFTIRQ_H__) && !defined(__ASSEMBLY__) +#ifndef __XEN_SOFTIRQ_H__ #define __XEN_SOFTIRQ_H__ +#ifndef __ASSEMBLY__ =20 /* Low-latency softirqs come first in the following list. */ enum { @@ -40,4 +41,5 @@ void cpu_raise_softirq_batch_finish(void); */ void process_pending_softirqs(void); =20 +#endif /* __ASSEMBLY__ */ #endif /* __XEN_SOFTIRQ_H__ */ diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index b0f7632e89..03868b0b1a 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -1,5 +1,6 @@ -#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START) +#ifndef __XEN_VMAP_H__ #define __XEN_VMAP_H__ +#ifdef VMAP_VIRT_START =20 #include #include @@ -38,4 +39,5 @@ static inline void vm_init(void) vm_init_type(VMAP_DEFAULT, (void *)VMAP_VIRT_START, arch_vmap_virt_end= ()); } =20 +#endif /* VMAP_VIRT_START */ #endif /* __XEN_VMAP_H__ */ --=20 2.34.1 From nobody Tue May 14 09:31:36 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 1694512006419746.0821949989194; Tue, 12 Sep 2023 02:46:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.600171.935811 (Exim 4.92) (envelope-from ) id 1qfzyT-0005Gn-3D; Tue, 12 Sep 2023 09:46:25 +0000 Received: by outflank-mailman (output) from mailman id 600171.935811; Tue, 12 Sep 2023 09:46:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qfzyT-0005Ge-0S; Tue, 12 Sep 2023 09:46:25 +0000 Received: by outflank-mailman (input) for mailman id 600171; Tue, 12 Sep 2023 09:46:23 +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 1qfzrm-0008Jk-3v for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 09:39:30 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 42c29484-5150-11ee-9b0d-b553b5be7939; Tue, 12 Sep 2023 11:39:25 +0200 (CEST) Received: from beta.station (net-93-66-137-131.cust.vodafonedsl.it [93.66.137.131]) by support.bugseng.com (Postfix) with ESMTPSA id EA7B24EE0745; Tue, 12 Sep 2023 11:39:24 +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: 42c29484-5150-11ee-9b0d-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [XEN PATCH v2 10/10] x86/asm: address violations of MISRA C:2012 Directive 4.10 Date: Tue, 12 Sep 2023 11:36:56 +0200 Message-Id: <1bab3ee9632be879244a405ee248f03392c58731.1694510856.git.simone.ballarin@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: 1694512007703100001 Content-Type: text/plain; charset="utf-8" Amend generation script, add inclusion guards to address violations of MISRA C:2012 Directive 4.10 ("Precautions shall be taken in order to prevent the contents of a header file being included more than once"). This patch amends the Makefile adding the required inclusion guards for xlat.h. Add deviation comment for files intended for multiple inclusion. Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2: - merge patches 7/13 and 13/13 of v1 as they had the same commit message - amend the Makefile to produce the required inclusion guard - use the format introduced with doc/misra/safe.json instead of a generic text-based deviation --- docs/misra/safe.json | 8 ++++++++ xen/arch/x86/include/asm/compat.h | 5 +++++ xen/arch/x86/include/asm/cpufeatures.h | 5 +---- xen/arch/x86/include/asm/efibind.h | 5 +++++ xen/include/Makefile | 8 ++++++-- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 0ec594f6bf..82c636ee94 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -44,6 +44,14 @@ }, { "id": "SAF-5-safe", + "analyser": { + "eclair": "MC3R1.D4.10" + }, + "name": "Dir 4.10: file intended for multiple inclusion", + "text": "Files intended for multiple inclusion are not suppose= d to comply with D4.10." + }, + { + "id": "SAF-6-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/x86/include/asm/compat.h b/xen/arch/x86/include/asm/c= ompat.h index 818cad87db..3d3891d061 100644 --- a/xen/arch/x86/include/asm/compat.h +++ b/xen/arch/x86/include/asm/compat.h @@ -2,6 +2,9 @@ * compat.h */ =20 +#ifndef __ASM_X86_COMPAT_H__ +#define __ASM_X86_COMPAT_H__ + #ifdef CONFIG_COMPAT =20 #define COMPAT_BITS_PER_LONG 32 @@ -18,3 +21,5 @@ int switch_compat(struct domain *); #include static inline int switch_compat(struct domain *d) { return -EOPNOTSUPP; } #endif + +#endif /* __ASM_X86_COMPAT_H__ */ diff --git a/xen/arch/x86/include/asm/cpufeatures.h b/xen/arch/x86/include/= asm/cpufeatures.h index da0593de85..39b15e463a 100644 --- a/xen/arch/x86/include/asm/cpufeatures.h +++ b/xen/arch/x86/include/asm/cpufeatures.h @@ -1,7 +1,4 @@ -/* - * Explicitly intended for multiple inclusion. - */ - +/* SAF-4-safe file intended for multiple inclusion */ #include =20 /* Number of capability words covered by the featureset words. */ diff --git a/xen/arch/x86/include/asm/efibind.h b/xen/arch/x86/include/asm/= efibind.h index bce02f3707..f2eb8b5496 100644 --- a/xen/arch/x86/include/asm/efibind.h +++ b/xen/arch/x86/include/asm/efibind.h @@ -1,2 +1,7 @@ +#ifndef __ASM_X86_EFIBIND_H__ +#define __ASM_X86_EFIBIND_H__ + #include #include + +#endif /* __ASM_X86_EFIBIND_H__ */ diff --git a/xen/include/Makefile b/xen/include/Makefile index 31782fb177..b2f9576362 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -105,9 +105,13 @@ xlat-y :=3D $(shell sed -ne 's,@arch@,$(compat-arch-y)= ,g' -re 's,^[?!][[:blank:]]+ xlat-y :=3D $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) =20 quiet_cmd_xlat_h =3D GEN $@ -cmd_xlat_h =3D \ - cat $(filter %.h,$^) >$@.new; \ +define cmd_xlat_h + echo "#ifndef _COMPAT_XLAT_H" > $@.new; \ + echo "#define _COMPAT_XLAT_H" >> $@.new; \ + cat $(filter %.h,$^) >> $@.new; \ + echo "#endif /* _COMPAT_XLAT_H */" >> $@.new; \ mv -f $@.new $@ +endef =20 $(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) FORCE $(call if_changed,xlat_h) --=20 2.34.1