From nobody Sat May 18 09:22:52 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 1702483958275133.46823579689988; Wed, 13 Dec 2023 08:12:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654093.1020760 (Exim 4.92) (envelope-from ) id 1rDRqD-0008DU-BO; Wed, 13 Dec 2023 16:12:09 +0000 Received: by outflank-mailman (output) from mailman id 654093.1020760; Wed, 13 Dec 2023 16:12:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDRqD-0008DN-8n; Wed, 13 Dec 2023 16:12:09 +0000 Received: by outflank-mailman (input) for mailman id 654093; Wed, 13 Dec 2023 16:12: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 1rDRqC-0007yZ-9u for xen-devel@lists.xenproject.org; Wed, 13 Dec 2023 16:12:08 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5c40281e-99d2-11ee-9b0f-b553b5be7939; Wed, 13 Dec 2023 17:12:06 +0100 (CET) Received: from beta.station (net-37-182-35-120.cust.vodafonedsl.it [37.182.35.120]) by support.bugseng.com (Postfix) with ESMTPSA id E527E4EE0738; Wed, 13 Dec 2023 17:12:05 +0100 (CET) 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: 5c40281e-99d2-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Kevin Tian , Simone Ballarin Subject: [PATCH v2 1/2] x86/IOMMU: address violations of MISRA C:2012 Rule 14.4 Date: Wed, 13 Dec 2023 17:10:50 +0100 Message-Id: <746a33fff1386b2e76657b5f7cfb31f3b117a1fe.1702310368.git.maria.celeste.cesario@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: 1702483958901100001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 14.4 whose headline states: "The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type". Add comparisons to avoid using enum constants as controlling expressions to comply with Rule 14.4. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2 - rename prefix from AMD/IOMMU to x86/IOMMU - move changes on msi.c and hpet.c in this patch. --- xen/arch/x86/hpet.c | 6 +++--- xen/arch/x86/msi.c | 4 ++-- xen/drivers/passthrough/amd/iommu_init.c | 4 ++-- xen/drivers/passthrough/vtd/iommu.c | 4 ++-- xen/drivers/passthrough/vtd/quirks.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c index 7be26c6a9b..d1ddc8ddf6 100644 --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -279,7 +279,7 @@ static int hpet_msi_write(struct hpet_event_channel *ch= , struct msi_msg *msg) { ch->msi.msg =3D *msg; =20 - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) { int rc =3D iommu_update_ire_from_msi(&ch->msi, msg); =20 @@ -353,7 +353,7 @@ static int __init hpet_setup_msi_irq(struct hpet_event_= channel *ch) u32 cfg =3D hpet_read32(HPET_Tn_CFG(ch->idx)); irq_desc_t *desc =3D irq_to_desc(ch->msi.irq); =20 - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) { ch->msi.hpet_id =3D hpet_blockid; ret =3D iommu_setup_hpet_msi(&ch->msi); @@ -372,7 +372,7 @@ static int __init hpet_setup_msi_irq(struct hpet_event_= channel *ch) ret =3D __hpet_setup_msi_irq(desc); if ( ret < 0 ) { - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) iommu_update_ire_from_msi(&ch->msi, NULL); return ret; } diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index 7f8e794254..72dce2e4ab 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -189,7 +189,7 @@ static int write_msi_msg(struct msi_desc *entry, struct= msi_msg *msg) { entry->msg =3D *msg; =20 - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) { int rc; =20 @@ -555,7 +555,7 @@ int msi_free_irq(struct msi_desc *entry) destroy_irq(entry[nr].irq); =20 /* Free the unused IRTE if intr remap enabled */ - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) iommu_update_ire_from_msi(entry + nr, NULL); } =20 diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthr= ough/amd/iommu_init.c index 5515cb70fd..e02a09a9a7 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -1480,7 +1480,7 @@ int __init amd_iommu_init(bool xt) goto error_out; } =20 - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) register_keyhandler('V', &amd_iommu_dump_intremap_tables, "dump IOMMU intremap tables", 0); =20 @@ -1498,7 +1498,7 @@ int __init amd_iommu_init_late(void) =20 /* Further initialize the device table(s). */ pci_init =3D true; - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) rc =3D iterate_ivrs_mappings(amd_iommu_setup_device_table); =20 for_each_amd_iommu ( iommu ) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index e13b7d99db..bd6d69a6f5 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2543,7 +2543,7 @@ static int __must_check init_vtd_hw(bool resume) /* * Enable interrupt remapping */ =20 - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) { int apic; for ( apic =3D 0; apic < nr_ioapics; apic++ ) @@ -2559,7 +2559,7 @@ static int __must_check init_vtd_hw(bool resume) } } } - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) { for_each_drhd_unit ( drhd ) { diff --git a/xen/drivers/passthrough/vtd/quirks.c b/xen/drivers/passthrough= /vtd/quirks.c index 5a56565ea8..950dcd56ef 100644 --- a/xen/drivers/passthrough/vtd/quirks.c +++ b/xen/drivers/passthrough/vtd/quirks.c @@ -392,7 +392,7 @@ void __init platform_quirks_init(void) map_igd_reg(); =20 /* Tylersburg interrupt remap quirk */ - if ( iommu_intremap ) + if ( iommu_intremap !=3D iommu_intremap_off ) tylersburg_intremap_quirk(); } =20 --=20 2.40.0 From nobody Sat May 18 09:22:52 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 1702483964025327.9866157443033; Wed, 13 Dec 2023 08:12:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654094.1020771 (Exim 4.92) (envelope-from ) id 1rDRqV-0000DJ-PM; Wed, 13 Dec 2023 16:12:27 +0000 Received: by outflank-mailman (output) from mailman id 654094.1020771; Wed, 13 Dec 2023 16:12: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 1rDRqV-0000DA-MR; Wed, 13 Dec 2023 16:12:27 +0000 Received: by outflank-mailman (input) for mailman id 654094; Wed, 13 Dec 2023 16:12: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 1rDRqU-00009X-1O for xen-devel@lists.xenproject.org; Wed, 13 Dec 2023 16:12:26 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6738794a-99d2-11ee-98e9-6d05b1d4d9a1; Wed, 13 Dec 2023 17:12:25 +0100 (CET) Received: from beta.station (net-37-182-35-120.cust.vodafonedsl.it [37.182.35.120]) by support.bugseng.com (Postfix) with ESMTPSA id 63DCC4EE0737; Wed, 13 Dec 2023 17:12:24 +0100 (CET) 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: 6738794a-99d2-11ee-98e9-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Simone Ballarin Subject: [PATCH v2 2/2] xen/x86_emulate: address violations of MISRA C:2012 Rule 14.4 Date: Wed, 13 Dec 2023 17:10:51 +0100 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: 1702483964803100001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 14.4 whose headline states: "The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type". Add comparisons to avoid using enum constants as controlling expressions to comply with Rule 14.4. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Acked-by: Jan Beulich --- Changes in v2: - move changes on hpet.c and msi.c to x86/IOMMU patch. - rename prefix from xen/x86 to xen/x86_emulate. --- xen/arch/x86/x86_emulate/x86_emulate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emul= ate/x86_emulate.c index cf780da501..00b7365ed3 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1320,7 +1320,7 @@ x86_emulate( ea.bytes =3D 2; goto srcmem_common; case SrcMem: - if ( state->simd_size ) + if ( state->simd_size !=3D simd_none ) break; ea.bytes =3D (d & ByteOp) ? 1 : op_bytes; srcmem_common: @@ -1460,7 +1460,7 @@ x86_emulate( /* Becomes a normal DstMem operation from here on. */ case DstMem: generate_exception_if(ea.type =3D=3D OP_MEM && evex.z, X86_EXC_UD); - if ( state->simd_size ) + if ( state->simd_size !=3D simd_none ) { generate_exception_if(lock_prefix, X86_EXC_UD); break; @@ -8176,7 +8176,7 @@ x86_emulate( goto done; } =20 - if ( state->rmw ) + if ( state->rmw !=3D rmw_NONE ) { ea.val =3D src.val; op_bytes =3D dst.bytes; @@ -8205,7 +8205,7 @@ x86_emulate( =20 dst.type =3D OP_NONE; } - else if ( state->simd_size ) + else if ( state->simd_size !=3D simd_none ) { generate_exception_if(!op_bytes, X86_EXC_UD); generate_exception_if((vex.opcx && (d & TwoOp) && --=20 2.40.0