From nobody Mon Feb 9 19:08:56 2026 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 1697815763566133.01388613192375; Fri, 20 Oct 2023 08:29:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.619839.965616 (Exim 4.92) (envelope-from ) id 1qtrQn-0007SY-Nm; Fri, 20 Oct 2023 15:28:57 +0000 Received: by outflank-mailman (output) from mailman id 619839.965616; Fri, 20 Oct 2023 15:28:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qtrQn-0007S9-FF; Fri, 20 Oct 2023 15:28:57 +0000 Received: by outflank-mailman (input) for mailman id 619839; Fri, 20 Oct 2023 15:28:56 +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 1qtrQm-0005jz-O7 for xen-devel@lists.xenproject.org; Fri, 20 Oct 2023 15:28:56 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 61f0e886-6f5d-11ee-98d5-6d05b1d4d9a1; Fri, 20 Oct 2023 17:28:56 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 462E94EE0744; Fri, 20 Oct 2023 17:28:54 +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: 61f0e886-6f5d-11ee-98d5-6d05b1d4d9a1 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, Nicola Vetrini , George Dunlap , Julien Grall , Wei Liu , Paul Durrant Subject: [XEN PATCH][for-4.19 v3 7/8] xen/types: address Rule 10.1 for DECLARE_BITMAP use Date: Fri, 20 Oct 2023 17:28:36 +0200 Message-Id: <9fd2cc7aa1a8640630910f873f6ddb65ed7adb6e.1697815135.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: 1697815764550100001 Content-Type: text/plain; charset="utf-8" Given its use in the declaration 'DECLARE_BITMAP(features, IOMMU_FEAT_count)' the argument 'bits' has essential type 'enum iommu_feature', which is not allowed by the Rule as an operand to the addition operator in macro 'BITS_TO_LONGS'. This construct is deviated with a deviation comment. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- Changes in v3: - edited comment --- docs/misra/safe.json | 8 ++++++++ xen/include/xen/iommu.h | 1 + xen/include/xen/types.h | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 39c5c056c7d4..952324f85cf9 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -20,6 +20,14 @@ }, { "id": "SAF-2-safe", + "analyser": { + "eclair": "MC3R1.R10.1" + }, + "name": "MC3R1.R10.1: use of an enumeration constant in an ari= thmetic operation", + "text": "This violation can be fixed with a cast to (int) of t= he enumeration constant, but a deviation was chosen due to code readability= (see also the comment in BITS_TO_LONGS)." + }, + { + "id": "SAF-3-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 0e747b0bbc1c..d5c25770915b 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -360,6 +360,7 @@ struct domain_iommu { #endif =20 /* Features supported by the IOMMU */ + /* SAF-2-safe enum constant in arithmetic operation */ DECLARE_BITMAP(features, IOMMU_FEAT_count); =20 /* Does the guest share HAP mapping with the IOMMU? */ diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index 23cad71c8a47..9603ab70b54d 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -22,6 +22,11 @@ typedef signed long ssize_t; =20 typedef __PTRDIFF_TYPE__ ptrdiff_t; =20 +/* + * Users of this macro are expected to pass a positive value. + * + * XXX: should become an unsigned quantity + */ #define BITS_TO_LONGS(bits) \ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ --=20 2.34.1