From nobody Thu Sep 19 01:13:19 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 1721722555105229.59743177968278; Tue, 23 Jul 2024 01:15:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.762675.1172900 (Exim 4.92) (envelope-from ) id 1sWAgO-0008P3-Kp; Tue, 23 Jul 2024 08:15:40 +0000 Received: by outflank-mailman (output) from mailman id 762675.1172900; Tue, 23 Jul 2024 08:15: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 1sWAgO-0008Ow-Hg; Tue, 23 Jul 2024 08:15:40 +0000 Received: by outflank-mailman (input) for mailman id 762675; Tue, 23 Jul 2024 08:15:39 +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 1sWAgN-0008AN-JK for xen-devel@lists.xenproject.org; Tue, 23 Jul 2024 08:15:39 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id be7d88b8-48cb-11ef-bbfe-fd08da9f4363; Tue, 23 Jul 2024 10:15:38 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-79-35-51-193.retail.telecomitalia.it [79.35.51.193]) by support.bugseng.com (Postfix) with ESMTPSA id DF8D44EE0743; Tue, 23 Jul 2024 10:15:35 +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: be7d88b8-48cb-11ef-bbfe-fd08da9f4363 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Simone Ballarin , Doug Goldstein , Stefano Stabellini , Andrew Cooper , Jan Beulich , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Alessandro Zucchelli Subject: [XEN PATCH v5 02/17] misra: modify deviations for empty and generated headers Date: Tue, 23 Jul 2024 10:14:54 +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: 1721722557260116600 Content-Type: text/plain; charset="utf-8" From: Simone Ballarin 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 Reviewed-by: Stefano Stabellini Signed-off-by: Alessandro Zucchelli Signed-off-by: Nicola Vetrini --- Changes in v4: - rebased against current staging tree 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 The reason of moving the comment-based deviation in "runtime.h" is that it should appear immediatly before the violation and, for files with no tokens, the location is the the last line of the file. --- 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 0af1cb93d1..1c39a9a16d 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -72,13 +72,6 @@ they are not instances of commented-out code." -config=3DMC3R1.D4.3,reports+=3D{deliberate, "any_area(any_loc(file(arm64_= bitops))&&context(name(int_clear_mask16)))"} -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 44d1c4890e..ffa8bfdc4a 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -76,6 +76,14 @@ }, { "id": "SAF-9-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-10-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..4d2d40bf3c 100644 --- a/xen/arch/arm/efi/runtime.h +++ b/xen/arch/arm/efi/runtime.h @@ -1 +1,2 @@ /* Placeholder for ARM-specific runtime include/declarations */ +/* SAF-9-safe empty header */ diff --git a/xen/include/Makefile b/xen/include/Makefile index 2e61b50139..058b0a566b 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-9-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