From nobody Sat May 18 12:47:51 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 1696580803636722.126948747942; Fri, 6 Oct 2023 01:26:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613302.953759 (Exim 4.92) (envelope-from ) id 1qogA8-0006V9-To; Fri, 06 Oct 2023 08:26:20 +0000 Received: by outflank-mailman (output) from mailman id 613302.953759; Fri, 06 Oct 2023 08:26: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 1qogA8-0006V1-RF; Fri, 06 Oct 2023 08:26:20 +0000 Received: by outflank-mailman (input) for mailman id 613302; Fri, 06 Oct 2023 08:26:19 +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 1qogA7-0006Fc-M6 for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:19 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 05292aa9-6422-11ee-9b0d-b553b5be7939; Fri, 06 Oct 2023 10:26:17 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 6AD184EE073A; Fri, 6 Oct 2023 10:26:16 +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: 05292aa9-6422-11ee-9b0d-b553b5be7939 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 , Simone Ballarin , Doug Goldstein , George Dunlap , Julien Grall , Wei Liu Subject: [XEN PATCH][for-4.19 1/9] xen/include: add macro LOWEST_POW2 Date: Fri, 6 Oct 2023 10:26:04 +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: 1696580805866100001 Content-Type: text/plain; charset="utf-8" The purpose of this macro is to encapsulate the well-known expression 'x & -x', that in 2's complement architectures on unsigned integers will give 2^ffs(x), where ffs(x) is the position of the lowest set bit in x. A deviation for ECLAIR is also introduced. Signed-off-by: Nicola Vetrini --- automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++ xen/include/xen/macros.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index d8170106b449..016164643105 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -274,6 +274,12 @@ still non-negative." -config=3DMC3R1.R10.1,etypes+=3D{safe, "stmt(operator(logical)||node(condi= tional_operator||binary_conditional_operator))", "dst_type(ebool||boolean)"} -doc_end =20 +-doc_begin=3D"The macro LOWEST_POW2 encapsulates a well-known pattern to o= btain the value +2^ffs(x) for unsigned integers on two's complement architectures +(all the architectures supported by Xen satisfy this requirement)." +-config=3DMC3R1.R10.1,reports+=3D{safe, "any_area(any_loc(any_exp(macro(^L= OWEST_POW2$))))"} +-doc_end + ### Set 3 ### =20 # diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h index d0caae7db298..bb9a1c9a53d0 100644 --- a/xen/include/xen/macros.h +++ b/xen/include/xen/macros.h @@ -8,8 +8,10 @@ #define DIV_ROUND(n, d) (((n) + (d) / 2) / (d)) #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) =20 -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) +#define LOWEST_POW2(x) ((x) & -(x)) + +#define MASK_EXTR(v, m) (((v) & (m)) / LOWEST_POW2(m)) +#define MASK_INSR(v, m) (((v) * LOWEST_POW2(m)) & (m)) =20 #define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x #define count_args(args...) \ --=20 2.34.1 From nobody Sat May 18 12:47:51 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 1696580806042212.8066817218837; Fri, 6 Oct 2023 01:26:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613305.953783 (Exim 4.92) (envelope-from ) id 1qogAA-00074x-Qb; Fri, 06 Oct 2023 08:26:22 +0000 Received: by outflank-mailman (output) from mailman id 613305.953783; Fri, 06 Oct 2023 08:26:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qogAA-00073K-KM; Fri, 06 Oct 2023 08:26:22 +0000 Received: by outflank-mailman (input) for mailman id 613305; Fri, 06 Oct 2023 08:26:20 +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 1qogA8-0006Fc-MH for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:20 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 05a511e9-6422-11ee-9b0d-b553b5be7939; Fri, 06 Oct 2023 10:26:18 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 56B8C4EE073C; Fri, 6 Oct 2023 10:26: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: 05a511e9-6422-11ee-9b0d-b553b5be7939 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 , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN PATCH][for-4.19 2/9] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1 Date: Fri, 6 Oct 2023 10:26:05 +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: 1696580807899100003 Content-Type: text/plain; charset="utf-8" The definitions of ffs{l}? violate Rule 10.1, by using the well-known pattern (x & -x); its usage is wrapped by the LOWEST_POW2 macro. No functional change. --- xen/arch/arm/include/asm/bitops.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/b= itops.h index 71ae14cab355..d119e1ccc952 100644 --- a/xen/arch/arm/include/asm/bitops.h +++ b/xen/arch/arm/include/asm/bitops.h @@ -9,6 +9,8 @@ #ifndef _ARM_BITOPS_H #define _ARM_BITOPS_H =20 +#include + #include =20 /* @@ -155,8 +157,8 @@ static inline int fls(unsigned int x) } =20 =20 -#define ffs(x) ({ unsigned int __t =3D (x); fls(__t & -__t); }) -#define ffsl(x) ({ unsigned long __t =3D (x); flsl(__t & -__t); }) +#define ffs(x) ({ unsigned int __t =3D (x); fls(LOWEST_POW2(__t)); }) +#define ffsl(x) ({ unsigned long __t =3D (x); flsl(LOWEST_POW2(__t)); }) =20 /** * find_first_set_bit - find the first set bit in @word --=20 2.34.1 From nobody Sat May 18 12:47:51 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 1696580800253516.7622906779714; Fri, 6 Oct 2023 01:26:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613303.953762 (Exim 4.92) (envelope-from ) id 1qogA9-0006Xf-61; Fri, 06 Oct 2023 08:26:21 +0000 Received: by outflank-mailman (output) from mailman id 613303.953762; Fri, 06 Oct 2023 08:26:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qogA9-0006X1-2p; Fri, 06 Oct 2023 08:26:21 +0000 Received: by outflank-mailman (input) for mailman id 613303; Fri, 06 Oct 2023 08:26:19 +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 1qogA7-0006Fk-U6 for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:19 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 062776ce-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:19 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 2DC6D4EE073D; Fri, 6 Oct 2023 10:26:18 +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: 062776ce-6422-11ee-98d3-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 Subject: [XEN PATCH][for-4.19 3/9] xen/pdx: amend definition of PDX_GROUP_COUNT Date: Fri, 6 Oct 2023 10:26:06 +0200 Message-Id: <370da41f72fa55c95a97268c250efc76a33d93d3.1696514677.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: 1696580801750100003 Content-Type: text/plain; charset="utf-8" The definition of PDX_GROUP_COUNT causes violations of MISRA C:2012 Rule 10.1, therefore the problematic part now uses the LOWEST_POW2 macro, which encapsulates the pattern. Signed-off-by: Nicola Vetrini --- xen/include/xen/pdx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h index f3fbc4273aa4..5b88a4a2cd86 100644 --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -72,7 +72,7 @@ extern unsigned long max_pdx; =20 #define PDX_GROUP_COUNT ((1 << PDX_GROUP_SHIFT) / \ - (sizeof(*frame_table) & -sizeof(*frame_table))) + (LOWEST_POW2(sizeof(*frame_table)))) extern unsigned long pdx_group_valid[]; =20 /** --=20 2.34.1 From nobody Sat May 18 12:47:51 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 1696580807726706.3001700312598; Fri, 6 Oct 2023 01:26:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613304.953779 (Exim 4.92) (envelope-from ) id 1qogAA-00071H-Fr; Fri, 06 Oct 2023 08:26:22 +0000 Received: by outflank-mailman (output) from mailman id 613304.953779; Fri, 06 Oct 2023 08:26:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qogAA-0006zP-CQ; Fri, 06 Oct 2023 08:26:22 +0000 Received: by outflank-mailman (input) for mailman id 613304; Fri, 06 Oct 2023 08:26: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 1qogA8-0006Fk-Jt for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:20 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 06973160-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:19 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 0C6664EE073E; Fri, 6 Oct 2023 10:26:18 +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: 06973160-6422-11ee-98d3-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 , Wei Liu Subject: [XEN PATCH 4/9] x86_64/mm: express macro CNT using LOWEST_POW2 Date: Fri, 6 Oct 2023 10:26:07 +0200 Message-Id: <1a44e7559ce4c7588a7b76c19d3154e471417cfa.1696514677.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: 1696580809942100006 Content-Type: text/plain; charset="utf-8" The various definitions of macro CNT (and the related BUILD_BUG_ON) can be rewritten using LOWEST_POW2, encapsulating a violation of MISRA C:2012 Rule 10.1. Signed-off-by: Nicola Vetrini --- I do find somewhat odd the multiple identical #define-s and #undef-s of CNT= in this file, as well as the last BUILD_BUG_ON((sizeof(*frame_table) & ~sizeof(*frame_table)) [...] Perhaps here a cleanup is needed, to have a single definition of CNT and identical BUILD_BUG_ON-s (wrapped in a macro, even)? --- xen/arch/x86/x86_64/mm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index c3ebb777144a..8ae704f920a1 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -351,9 +351,9 @@ static int setup_compat_m2p_table(struct mem_hotadd_inf= o *info) ~((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1) ); #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (LOWEST_POW2(sizeof(*frame_table)) / \ sizeof(*compat_machine_to_phys_mapping)) - BUILD_BUG_ON((sizeof(*frame_table) & -sizeof(*frame_table)) % \ + BUILD_BUG_ON(LOWEST_POW2(sizeof(*frame_table)) % \ sizeof(*compat_machine_to_phys_mapping)); for ( i =3D smap; i < emap; i +=3D (1UL << (L2_PAGETABLE_SHIFT - 2)) ) @@ -410,10 +410,10 @@ static int setup_m2p_table(struct mem_hotadd_info *in= fo) va =3D RO_MPT_VIRT_START + smap * sizeof(*machine_to_phys_mapping); #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned long)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (LOWEST_POW2(sizeof(*frame_table)) / \ sizeof(*machine_to_phys_mapping)) - BUILD_BUG_ON((sizeof(*frame_table) & -sizeof(*frame_table)) % \ + BUILD_BUG_ON(LOWEST_POW2(sizeof(*frame_table)) % \ sizeof(*machine_to_phys_mapping)); i =3D smap; @@ -539,7 +539,7 @@ void __init paging_init(void) mpt_size =3D (max_page * BYTES_PER_LONG) + (1UL << L2_PAGETABLE_SHIFT= ) - 1; mpt_size &=3D ~((1UL << L2_PAGETABLE_SHIFT) - 1UL); #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned long)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (LOWEST_POW2(sizeof(*frame_table)) / \ sizeof(*machine_to_phys_mapping)) BUILD_BUG_ON((sizeof(*frame_table) & ~sizeof(*frame_table)) % \ sizeof(*machine_to_phys_mapping)); @@ -666,7 +666,7 @@ void __init paging_init(void) mpt_size =3D 0; #define MFN(x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (LOWEST_POW2(sizeof(*frame_table)) / \ sizeof(*compat_machine_to_phys_mapping)) BUILD_BUG_ON((sizeof(*frame_table) & ~sizeof(*frame_table)) % \ sizeof(*compat_machine_to_phys_mapping)); -- 2.34.1 From nobody Sat May 18 12:47:51 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 1696580808631721.3919061891336; Fri, 6 Oct 2023 01:26:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613306.953791 (Exim 4.92) (envelope-from ) id 1qogAB-0007AS-9F; Fri, 06 Oct 2023 08:26:23 +0000 Received: by outflank-mailman (output) from mailman id 613306.953791; Fri, 06 Oct 2023 08:26: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 1qogAB-00077t-1k; Fri, 06 Oct 2023 08:26:23 +0000 Received: by outflank-mailman (input) for mailman id 613306; Fri, 06 Oct 2023 08:26:21 +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 1qogA9-0006Fk-KG for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:21 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0704009e-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:20 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id C12D34EE074E; Fri, 6 Oct 2023 10:26:19 +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: 0704009e-6422-11ee-98d3-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 , Wei Liu Subject: [XEN PATCH 5/9] x86/cpu-policy: address violations of MISRA C Rule 10.1 Date: Fri, 6 Oct 2023 10:26:08 +0200 Message-Id: <463572d126a7700e5e90ef3a49104bd4b8c1c389.1696514677.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: 1696580809935100005 Content-Type: text/plain; charset="utf-8" The COUNT_LEAVES macro is introduced to avoid using an essentially boolean value in a subtraction. No functional change. Signed-off-by: Nicola Vetrini --- xen/include/xen/lib/x86/cpu-policy.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86= /cpu-policy.h index bab3eecda6c1..700993cc67e8 100644 --- a/xen/include/xen/lib/x86/cpu-policy.h +++ b/xen/include/xen/lib/x86/cpu-policy.h @@ -95,17 +95,18 @@ const char *x86_cpuid_vendor_to_str(unsigned int vendor= ); #define CPUID_GUEST_NR_EXTD MAX(CPUID_GUEST_NR_EXTD_INTEL, \ CPUID_GUEST_NR_EXTD_AMD) =20 +#define COUNT_LEAVES(X) ((X) - ((X) ? 1 : 0)) /* * Maximum number of leaves a struct cpu_policy turns into when serialised= for * interaction with the toolstack. (Sum of all leaves in each union, less= the * entries in basic which sub-unions hang off of.) */ -#define CPUID_MAX_SERIALISED_LEAVES \ - (CPUID_GUEST_NR_BASIC + \ - CPUID_GUEST_NR_FEAT - !!CPUID_GUEST_NR_FEAT + \ - CPUID_GUEST_NR_CACHE - !!CPUID_GUEST_NR_CACHE + \ - CPUID_GUEST_NR_TOPO - !!CPUID_GUEST_NR_TOPO + \ - CPUID_GUEST_NR_XSTATE - !!CPUID_GUEST_NR_XSTATE + \ +#define CPUID_MAX_SERIALISED_LEAVES \ + (CPUID_GUEST_NR_BASIC + \ + COUNT_LEAVES(CPUID_GUEST_NR_FEAT) + \ + COUNT_LEAVES(CPUID_GUEST_NR_CACHE) + \ + COUNT_LEAVES(CPUID_GUEST_NR_TOPO) + \ + COUNT_LEAVES(CPUID_GUEST_NR_XSTATE) + \ CPUID_GUEST_NR_EXTD + 2 /* hv_limit and hv2_limit */ ) =20 /* Maximum number of MSRs written when serialising a cpu_policy. */ --=20 2.34.1 From nobody Sat May 18 12:47:51 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 1696580812417958.9483535864797; Fri, 6 Oct 2023 01:26:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613307.953807 (Exim 4.92) (envelope-from ) id 1qogAC-0007gs-LG; Fri, 06 Oct 2023 08:26:24 +0000 Received: by outflank-mailman (output) from mailman id 613307.953807; Fri, 06 Oct 2023 08:26:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qogAC-0007fb-EE; Fri, 06 Oct 2023 08:26:24 +0000 Received: by outflank-mailman (input) for mailman id 613307; Fri, 06 Oct 2023 08:26:22 +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 1qogAA-0006Fk-KV for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:22 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 076ff614-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:21 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 7C7D14EE0C87; Fri, 6 Oct 2023 10:26: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: 076ff614-6422-11ee-98d3-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 , Wei Liu Subject: [XEN PATCH 6/9] x86/io_apic: address violation of MISRA C:2012 Rule 10.1 Date: Fri, 6 Oct 2023 10:26:09 +0200 Message-Id: <7def4be3f63306569a2ac1776c2d6ed24ff24ee2.1696514677.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: 1696580814207100002 Content-Type: text/plain; charset="utf-8" The definition of IO_APIC_BASE contains a sum of an essentially enum value (FIX_IO_APIC_BASE_0) that is positive with an index that, in all instances, is unsigned, therefore the former is cast to unsigned, so that the operands are of the same essential type. No functional change. Reviewed-by: Stefano Stabellini --- xen/arch/x86/include/asm/io_apic.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/io_apic.h b/xen/arch/x86/include/asm/= io_apic.h index a7e4c9e146de..a0fc50d601fe 100644 --- a/xen/arch/x86/include/asm/io_apic.h +++ b/xen/arch/x86/include/asm/io_apic.h @@ -14,9 +14,10 @@ * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar */ =20 -#define IO_APIC_BASE(idx) \ - ((volatile uint32_t *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + (idx)) \ - + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK))) +#define IO_APIC_BASE(idx) \ + ((volatile uint32_t *) \ + (__fix_to_virt((unsigned int)FIX_IO_APIC_BASE_0 + (idx)) \ + + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK))) =20 #define IO_APIC_ID(idx) (mp_ioapics[idx].mpc_apicid) =20 --=20 2.34.1 From nobody Sat May 18 12:47:51 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 169658081437991.6960577127436; Fri, 6 Oct 2023 01:26:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613308.953813 (Exim 4.92) (envelope-from ) id 1qogAD-0007o0-7I; Fri, 06 Oct 2023 08:26:25 +0000 Received: by outflank-mailman (output) from mailman id 613308.953813; Fri, 06 Oct 2023 08:26: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 1qogAC-0007mB-S9; Fri, 06 Oct 2023 08:26:24 +0000 Received: by outflank-mailman (input) for mailman id 613308; Fri, 06 Oct 2023 08:26:23 +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 1qogAB-0006Fk-Kn for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:23 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 07db203e-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:22 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 333864EE0C81; Fri, 6 Oct 2023 10:26:21 +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: 07db203e-6422-11ee-98d3-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 , Wei Liu Subject: [XEN PATCH 7/9] x86/mce: Move MC_NCLASSES into the enum mctelem_class Date: Fri, 6 Oct 2023 10:26:10 +0200 Message-Id: <08293d72e236a7a6aec0305bc3f901a6636747ab.1696514677.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: 1696580816028100005 Content-Type: text/plain; charset="utf-8" The definition of MC_NCLASSES contained a violation of MISRA C:2012 Rule 10.1, therefore by moving it as an enumeration constant resolves the violation and makes it more resilient to possible additions to that enum. Signed-off-by: Nicola Vetrini Acked-by: Andrew Cooper --- Note that the use of an enum constant as operand to [ ] and !=3D is allowed by the Rule. --- xen/arch/x86/cpu/mcheck/mctelem.c | 2 -- xen/arch/x86/cpu/mcheck/mctelem.h | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mctelem.c b/xen/arch/x86/cpu/mcheck/mc= telem.c index 329ac20faf96..77a4d1d5ff48 100644 --- a/xen/arch/x86/cpu/mcheck/mctelem.c +++ b/xen/arch/x86/cpu/mcheck/mctelem.c @@ -64,8 +64,6 @@ struct mctelem_ent { =20 #define MC_NENT (MC_URGENT_NENT + MC_NONURGENT_NENT) =20 -#define MC_NCLASSES (MC_NONURGENT + 1) - #define COOKIE2MCTE(c) ((struct mctelem_ent *)(c)) #define MCTE2COOKIE(tep) ((mctelem_cookie_t)(tep)) =20 diff --git a/xen/arch/x86/cpu/mcheck/mctelem.h b/xen/arch/x86/cpu/mcheck/mc= telem.h index d4eba53ae0e5..21b251847bc0 100644 --- a/xen/arch/x86/cpu/mcheck/mctelem.h +++ b/xen/arch/x86/cpu/mcheck/mctelem.h @@ -55,8 +55,9 @@ typedef struct mctelem_cookie *mctelem_cookie_t; =20 typedef enum mctelem_class { - MC_URGENT, - MC_NONURGENT + MC_URGENT, + MC_NONURGENT, + MC_NCLASSES } mctelem_class_t; =20 extern void mctelem_init(unsigned int); --=20 2.34.1 From nobody Sat May 18 12:47:51 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 1696580815164778.6045721714636; Fri, 6 Oct 2023 01:26:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613309.953828 (Exim 4.92) (envelope-from ) id 1qogAE-0008Ma-VB; Fri, 06 Oct 2023 08:26:26 +0000 Received: by outflank-mailman (output) from mailman id 613309.953828; Fri, 06 Oct 2023 08: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 1qogAE-0008L1-Pl; Fri, 06 Oct 2023 08:26:26 +0000 Received: by outflank-mailman (input) for mailman id 613309; Fri, 06 Oct 2023 08:26:24 +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 1qogAC-0006Fk-LE for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:24 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 085ea74b-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:22 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id DEEA04EE0C88; Fri, 6 Oct 2023 10:26:21 +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: 085ea74b-6422-11ee-98d3-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 , Paul Durrant , George Dunlap , Julien Grall , Wei Liu Subject: [XEN PATCH][for-4.19 8/9] xen/types: address Rule 10.1 for DECLARE_BITMAP use Date: Fri, 6 Oct 2023 10:26:11 +0200 Message-Id: <9642dcb4ab51ec9eaeedf16056fbcd946a3efbea.1696514677.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: 1696580816030100006 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'. A comment in BITS_TO_LONGS is added to make it clear that values passed are meant to be positive. Signed-off-by: Nicola Vetrini --- xen/include/xen/iommu.h | 2 +- xen/include/xen/types.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 0e747b0bbc1c..34aa0b9b5b81 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -360,7 +360,7 @@ struct domain_iommu { #endif =20 /* Features supported by the IOMMU */ - DECLARE_BITMAP(features, IOMMU_FEAT_count); + DECLARE_BITMAP(features, (int)IOMMU_FEAT_count); =20 /* Does the guest share HAP mapping with the IOMMU? */ bool hap_pt_share; diff --git a/xen/include/xen/types.h b/xen/include/xen/types.h index aea259db1ef2..936e83d333a0 100644 --- a/xen/include/xen/types.h +++ b/xen/include/xen/types.h @@ -22,6 +22,7 @@ typedef signed long ssize_t; =20 typedef __PTRDIFF_TYPE__ ptrdiff_t; =20 +/* Users of this macro are expected to pass a positive value */ #define BITS_TO_LONGS(bits) \ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ --=20 2.34.1 From nobody Sat May 18 12:47:51 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 169658081268390.34655899449422; Fri, 6 Oct 2023 01:26:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.613310.953834 (Exim 4.92) (envelope-from ) id 1qogAF-0008Rm-Jx; Fri, 06 Oct 2023 08:26:27 +0000 Received: by outflank-mailman (output) from mailman id 613310.953834; Fri, 06 Oct 2023 08:26: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 1qogAF-0008QV-8Q; Fri, 06 Oct 2023 08:26:27 +0000 Received: by outflank-mailman (input) for mailman id 613310; Fri, 06 Oct 2023 08: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 1qogAD-0006Fk-LQ for xen-devel@lists.xenproject.org; Fri, 06 Oct 2023 08:26:25 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 08da8f32-6422-11ee-98d3-6d05b1d4d9a1; Fri, 06 Oct 2023 10:26:23 +0200 (CEST) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id BEC954EE0C89; Fri, 6 Oct 2023 10:26: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: 08da8f32-6422-11ee-98d3-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 Subject: [XEN PATCH 9/9] xen/compat: address Rule 10.1 for macros CHECK_SIZE Date: Fri, 6 Oct 2023 10:26:12 +0200 Message-Id: <7edf60c0e7bd0680d8b8f8d3aec1264ee5a43878.1696514677.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: 1696580814201100001 Content-Type: text/plain; charset="utf-8" The essential type of the result of an inequality operator is essentially boolean, therefore it shouldn't be used as an argument of the multiplication operator, which expects an integer. Signed-off-by: Nicola Vetrini --- xen/include/xen/compat.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/include/xen/compat.h b/xen/include/xen/compat.h index f2ce5bb3580a..5ffee6a9fed1 100644 --- a/xen/include/xen/compat.h +++ b/xen/include/xen/compat.h @@ -151,12 +151,14 @@ CHECK_NAME_(k, n, T)(k xen_ ## n *x, \ return x =3D=3D c; \ } =20 +#define SIZE_NEQUAL(a, b) \ + (sizeof(a) !=3D sizeof(b) ? 1 : 0) #define CHECK_SIZE(name) \ - typedef int CHECK_NAME(name, S)[1 - (sizeof(xen_ ## name ## _t) !=3D \ - sizeof(compat_ ## name ## _t)) * = 2] + typedef int CHECK_NAME(name, S)[1 - (SIZE_NEQUAL(xen_ ## name ## _t, \ + compat_ ## name ## _t= )) * 2] #define CHECK_SIZE_(k, n) \ - typedef int CHECK_NAME_(k, n, S)[1 - (sizeof(k xen_ ## n) !=3D \ - sizeof(k compat_ ## n)) * 2] + typedef int CHECK_NAME_(k, n, S)[1 - (SIZE_NEQUAL(k xen_ ## n, \ + k compat_ ## n)) * 2] =20 #define CHECK_FIELD_COMMON(name, t, f) \ static inline int __maybe_unused name(xen_ ## t ## _t *x, compat_ ## t ## = _t *c) \ --=20 2.34.1