From nobody Sat May 18 13:36:50 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 1702555755114673.7177219332771; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654520.1021487 (Exim 4.92) (envelope-from ) id 1rDkWH-0001Be-Ic; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (output) from mailman id 654520.1021487; Thu, 14 Dec 2023 12:08:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWH-0001AS-Bl; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (input) for mailman id 654520; Thu, 14 Dec 2023 12:08:48 +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 1rDkWF-0000tI-VF for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:47 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 87e99b2e-9a79-11ee-9b0f-b553b5be7939; Thu, 14 Dec 2023 13:08:45 +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 39B574EE0744; Thu, 14 Dec 2023 13:08:45 +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: 87e99b2e-9a79-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Simone Ballarin Subject: [PATCH 1/9] xen/arm64: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:43 +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: 1702555755461100002 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Add volatile qualifiers missing in casts. Arguments p and ptr are originally volatile-qualified. There's no reason to drop the qualifiers. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/lib/bitops.c | 6 ++++-- xen/arch/arm/include/asm/arm64/cmpxchg.h | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitop= s.c index 20e3f3d6ce..275a780329 100644 --- a/xen/arch/arm/arm64/lib/bitops.c +++ b/xen/arch/arm/arm64/lib/bitops.c @@ -32,7 +32,8 @@ static always_inline bool int_##name(int nr, volatile void *p, bool timeou= t,\ unsigned int max_try) = \ { = \ - volatile uint32_t *ptr =3D (uint32_t *)p + BITOP_WORD((unsigned int)nr= ); \ + volatile uint32_t *ptr =3D (volatile uint32_t *)p + = \ + BITOP_WORD((unsigned int)nr); = \ const uint32_t mask =3D BITOP_MASK((unsigned int)nr); = \ unsigned long res, tmp; = \ = \ @@ -67,7 +68,8 @@ bool name##_timeout(int nr, volatile void *p, unsigned in= t max_try) \ static always_inline bool int_##name(int nr, volatile void *p, int *oldbit= , \ bool timeout, unsigned int max_try) = \ { = \ - volatile uint32_t *ptr =3D (uint32_t *)p + BITOP_WORD((unsigned int)nr= ); \ + volatile uint32_t *ptr =3D (volatile uint32_t *)p + = \ + BITOP_WORD((unsigned int)nr); = \ unsigned int bit =3D (unsigned int)nr % BITOP_BITS_PER_WORD; = \ const uint32_t mask =3D BITOP_MASK(bit); = \ unsigned long res, tmp; = \ diff --git a/xen/arch/arm/include/asm/arm64/cmpxchg.h b/xen/arch/arm/includ= e/asm/arm64/cmpxchg.h index dbfaf91567..031fa6d92a 100644 --- a/xen/arch/arm/include/asm/arm64/cmpxchg.h +++ b/xen/arch/arm/include/asm/arm64/cmpxchg.h @@ -13,7 +13,7 @@ static inline unsigned long __xchg(unsigned long x, volat= ile void *ptr, int size "1: ldxrb %w0, %2\n" " stlxrb %w1, %w3, %2\n" " cbnz %w1, 1b\n" - : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(u8 *)ptr) + : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(volatile u8 *)ptr) : "r" (x) : "memory"); break; @@ -22,7 +22,7 @@ static inline unsigned long __xchg(unsigned long x, volat= ile void *ptr, int size "1: ldxrh %w0, %2\n" " stlxrh %w1, %w3, %2\n" " cbnz %w1, 1b\n" - : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(u16 *)ptr) + : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(volatile u16 *)ptr) : "r" (x) : "memory"); break; @@ -31,7 +31,7 @@ static inline unsigned long __xchg(unsigned long x, volat= ile void *ptr, int size "1: ldxr %w0, %2\n" " stlxr %w1, %w3, %2\n" " cbnz %w1, 1b\n" - : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(u32 *)ptr) + : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(volatile u32 *)ptr) : "r" (x) : "memory"); break; @@ -40,7 +40,7 @@ static inline unsigned long __xchg(unsigned long x, volat= ile void *ptr, int size "1: ldxr %0, %2\n" " stlxr %w1, %3, %2\n" " cbnz %w1, 1b\n" - : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(u64 *)ptr) + : "=3D&r" (ret), "=3D&r" (tmp), "+Q" (*(volatile u64 *)ptr) : "r" (x) : "memory"); break; @@ -82,7 +82,7 @@ static inline bool __cmpxchg_case_##name(volatile void *p= tr, \ " stxr" #sz " %w0, %" #w "4, %2\n" \ "1:\n" \ : "=3D&r" (res), "=3D&r" (oldval), \ - "+Q" (*(unsigned long *)ptr) \ + "+Q" (*(volatile unsigned long *)ptr) \ : "Ir" (*old), "r" (new) \ : "cc"); \ \ --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755538343.0708768034042; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654522.1021499 (Exim 4.92) (envelope-from ) id 1rDkWI-0001ST-A7; Thu, 14 Dec 2023 12:08:50 +0000 Received: by outflank-mailman (output) from mailman id 654522.1021499; Thu, 14 Dec 2023 12:08:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWI-0001Od-3X; Thu, 14 Dec 2023 12:08:50 +0000 Received: by outflank-mailman (input) for mailman id 654522; Thu, 14 Dec 2023 12:08:48 +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 1rDkWG-0000tI-KV for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:48 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 88302c32-9a79-11ee-9b0f-b553b5be7939; Thu, 14 Dec 2023 13:08:46 +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 B01994EE0742; Thu, 14 Dec 2023 13:08:45 +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: 88302c32-9a79-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Simone Ballarin Subject: [PATCH 2/9] xen/arm: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:44 +0100 Message-Id: <1ad7937f9aa2086e76a87c8edf8105bd4476bf39.1702555387.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: 1702555757656100006 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Add missing const qualifiers in casts. The variables are originally const-qualified. There's no reason to drop the qualifiers. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- xen/arch/arm/bootfdt.c | 6 +++--- xen/arch/arm/include/asm/alternative.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index f496a8cf94..e7948ea3e8 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -377,7 +377,7 @@ static int __init process_chosen_node(const void *fdt, = int node, printk("linux,initrd-start property has invalid length %d\n", len); return -EINVAL; } - start =3D dt_read_paddr((void *)&prop->data, dt_size_to_cells(len)); + start =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(le= n)); =20 prop =3D fdt_get_property(fdt, node, "linux,initrd-end", &len); if ( !prop ) @@ -390,7 +390,7 @@ static int __init process_chosen_node(const void *fdt, = int node, printk("linux,initrd-end property has invalid length %d\n", len); return -EINVAL; } - end =3D dt_read_paddr((void *)&prop->data, dt_size_to_cells(len)); + end =3D dt_read_paddr((const void *)&prop->data, dt_size_to_cells(len)= ); =20 if ( start >=3D end ) { @@ -541,7 +541,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t pa= ddr) =20 add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); =20 - ret =3D device_tree_for_each_node((void *)fdt, 0, early_scan_node, NUL= L); + ret =3D device_tree_for_each_node((const void *)fdt, 0, early_scan_nod= e, NULL); if ( ret ) panic("Early FDT parsing failed (%d)\n", ret); =20 diff --git a/xen/arch/arm/include/asm/alternative.h b/xen/arch/arm/include/= asm/alternative.h index d3210e82f9..c7632668b6 100644 --- a/xen/arch/arm/include/asm/alternative.h +++ b/xen/arch/arm/include/asm/alternative.h @@ -20,7 +20,7 @@ struct alt_instr { }; =20 /* Xen: helpers used by common code. */ -#define __ALT_PTR(a,f) ((void *)&(a)->f + (a)->f) +#define __ALT_PTR(a,f) ((const void *)&(a)->f + (a)->f) #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) #define ALT_REPL_PTR(a) __ALT_PTR(a, repl_offset) =20 --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755697522.0157609053921; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654524.1021515 (Exim 4.92) (envelope-from ) id 1rDkWJ-0001sB-Fj; Thu, 14 Dec 2023 12:08:51 +0000 Received: by outflank-mailman (output) from mailman id 654524.1021515; Thu, 14 Dec 2023 12:08:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWJ-0001pJ-BU; Thu, 14 Dec 2023 12:08:51 +0000 Received: by outflank-mailman (input) for mailman id 654524; Thu, 14 Dec 2023 12:08:49 +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 1rDkWH-0000tI-KV for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8880a984-9a79-11ee-9b0f-b553b5be7939; Thu, 14 Dec 2023 13:08:46 +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 3360D4EE0747; Thu, 14 Dec 2023 13:08:46 +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: 8880a984-9a79-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Jan Beulich , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , Simone Ballarin Subject: [PATCH 3/9] xen/efi: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:45 +0100 Message-Id: <4540a3850dae951dd6bc4f9b001c9816bde2e49e.1702555387.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: 1702555757644100004 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Add missing const qualifiers in casts. The variables are originally const-qualified. There's no reason to drop the qualifiers. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Jan Beulich Reviewed-by: Stefano Stabellini --- xen/common/efi/boot.c | 6 +++--- xen/common/version.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 6110819918..efbec00af9 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1248,10 +1248,10 @@ static void __init efi_exit_boot(EFI_HANDLE ImageHa= ndle, EFI_SYSTEM_TABLE *Syste #endif =20 /* Adjust pointers into EFI. */ - efi_ct =3D (void *)efi_ct + DIRECTMAP_VIRT_START; - efi_rs =3D (void *)efi_rs + DIRECTMAP_VIRT_START; + efi_ct =3D (const void *)efi_ct + DIRECTMAP_VIRT_START; + efi_rs =3D (const void *)efi_rs + DIRECTMAP_VIRT_START; efi_memmap =3D (void *)efi_memmap + DIRECTMAP_VIRT_START; - efi_fw_vendor =3D (void *)efi_fw_vendor + DIRECTMAP_VIRT_START; + efi_fw_vendor =3D (const void *)efi_fw_vendor + DIRECTMAP_VIRT_START; } =20 /* SAF-1-safe */ diff --git a/xen/common/version.c b/xen/common/version.c index d320135208..6ac5a52700 100644 --- a/xen/common/version.c +++ b/xen/common/version.c @@ -178,7 +178,7 @@ void __init xen_build_init(void) if ( &n[1] >=3D __note_gnu_build_id_end ) return; =20 - sz =3D (void *)__note_gnu_build_id_end - (void *)n; + sz =3D (const void *)__note_gnu_build_id_end - (const void *)n; =20 rc =3D xen_build_id_check(n, sz, &build_id_p, &build_id_len); =20 --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755792346.0042316852158; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654519.1021481 (Exim 4.92) (envelope-from ) id 1rDkWH-00018Q-80; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (output) from mailman id 654519.1021481; Thu, 14 Dec 2023 12:08:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWH-00018J-4l; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (input) for mailman id 654519; Thu, 14 Dec 2023 12:08:47 +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 1rDkWF-0000tC-Lc for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:47 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 88b622c6-9a79-11ee-98e9-6d05b1d4d9a1; Thu, 14 Dec 2023 13:08:47 +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 B2FEA4EE0C8A; Thu, 14 Dec 2023 13:08:46 +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: 88b622c6-9a79-11ee-98e9-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Jan Beulich , Simone Ballarin Subject: [PATCH 4/9] ACPI: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:46 +0100 Message-Id: <44c8f94bcfe4f0e33e53a7eb8aef826e7d906196.1702555387.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: 1702555757638100002 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Add missing const qualifiers missing in casting. There's no reason to drop the const qualifier in ACPI_COMPARE_NAME since the macro arguments are not modified in its body. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- xen/include/acpi/acmacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/acpi/acmacros.h b/xen/include/acpi/acmacros.h index 86c503c20f..d7c74c5769 100644 --- a/xen/include/acpi/acmacros.h +++ b/xen/include/acpi/acmacros.h @@ -116,7 +116,7 @@ #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) =20 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED -#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (u32,(a)) =3D=3D *= ACPI_CAST_PTR (u32,(b))) +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (const u32,(a)) = =3D=3D *ACPI_CAST_PTR (const u32,(b))) #else #define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (cha= r,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE)) #endif --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755602826.6585514662244; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654521.1021493 (Exim 4.92) (envelope-from ) id 1rDkWH-0001Ef-UZ; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (output) from mailman id 654521.1021493; Thu, 14 Dec 2023 12:08:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWH-0001D0-Jv; Thu, 14 Dec 2023 12:08:49 +0000 Received: by outflank-mailman (input) for mailman id 654521; Thu, 14 Dec 2023 12:08:48 +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 1rDkWG-0000tC-BR for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:48 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 88f990b8-9a79-11ee-98e9-6d05b1d4d9a1; Thu, 14 Dec 2023 13:08:47 +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 118C74EE0743; Thu, 14 Dec 2023 13:08:47 +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: 88f990b8-9a79-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 5/9] xen/x86: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:47 +0100 Message-Id: <68e28c7631f1233df1527674cfc27cf3f44797a7.1702555387.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: 1702555757650100005 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Add missing const qualifiers in casts. Macro get_mb2_data returns values that are const-qualified. The results are stored in const struct pointers, hence there's no need to cast away the const qualifiers. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- xen/arch/x86/boot/reloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index df0bc710a7..77fdb2be05 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -300,8 +300,8 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, ui= nt32_t video_out) const struct vesa_mode_info *mi; =20 video =3D _p(video_out); - ci =3D (void *)get_mb2_data(tag, vbe, vbe_control_info); - mi =3D (void *)get_mb2_data(tag, vbe, vbe_mode_info); + ci =3D (const void *)get_mb2_data(tag, vbe, vbe_control_in= fo); + mi =3D (const void *)get_mb2_data(tag, vbe, vbe_mode_info); =20 if ( ci->version >=3D 0x0200 && (mi->attrib & 0x9b) =3D=3D= 0x9b ) { --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555756242780.7557255657329; Thu, 14 Dec 2023 04:09:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654526.1021534 (Exim 4.92) (envelope-from ) id 1rDkWK-0002DQ-U5; Thu, 14 Dec 2023 12:08:52 +0000 Received: by outflank-mailman (output) from mailman id 654526.1021534; Thu, 14 Dec 2023 12:08: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 1rDkWK-0002Bh-FA; Thu, 14 Dec 2023 12:08:52 +0000 Received: by outflank-mailman (input) for mailman id 654526; Thu, 14 Dec 2023 12:08:50 +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 1rDkWI-0000tI-KY for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:50 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 892a5a09-9a79-11ee-9b0f-b553b5be7939; Thu, 14 Dec 2023 13:08:48 +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 7D10A4EE0C8F; Thu, 14 Dec 2023 13:08:47 +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: 892a5a09-9a79-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Shawn Anastasio , Simone Ballarin Subject: [PATCH 6/9] xen/ppc: address violations of MISRA C:2012 Rule 11.8. Date: Thu, 14 Dec 2023 13:07:48 +0100 Message-Id: <0dcaf3a85f3293168b993c42303dfd55684a7bb7.1702555387.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: 1702555757643100003 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Fix violation by adding missing const qualifier in cast. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Adaptation requested by the community to make the code more consistent. --- xen/arch/ppc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/ppc/include/asm/atomic.h b/xen/arch/ppc/include/asm/a= tomic.h index 64168aa3f1..fe778579fb 100644 --- a/xen/arch/ppc/include/asm/atomic.h +++ b/xen/arch/ppc/include/asm/atomic.h @@ -16,7 +16,7 @@ =20 static inline int atomic_read(const atomic_t *v) { - return *(volatile int *)&v->counter; + return *(const volatile int *)&v->counter; } =20 static inline int _atomic_read(atomic_t v) --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555757146463.94120870898007; Thu, 14 Dec 2023 04:09:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654523.1021507 (Exim 4.92) (envelope-from ) id 1rDkWI-0001Yl-QR; Thu, 14 Dec 2023 12:08:50 +0000 Received: by outflank-mailman (output) from mailman id 654523.1021507; Thu, 14 Dec 2023 12:08:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWI-0001Wq-GK; Thu, 14 Dec 2023 12:08:50 +0000 Received: by outflank-mailman (input) for mailman id 654523; Thu, 14 Dec 2023 12:08:49 +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 1rDkWH-0000tC-BT for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 896fae79-9a79-11ee-98e9-6d05b1d4d9a1; Thu, 14 Dec 2023 13:08:48 +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 CEBE34EE0C8D; Thu, 14 Dec 2023 13:08:47 +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: 896fae79-9a79-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 7/9] x86/hvm: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:49 +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: 1702555757635100001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Remove unnecessary cast. from is a const-qualified pointer to void and the function hvm_copy_to_gues= t_linear requires a const void* type argument, therefore the cast to void* is not ne= cessary. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Jan Beulich Reviewed-by: Stefano Stabellini --- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 35a30df3b1..523e0df57c 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3462,7 +3462,7 @@ unsigned int copy_to_user_hvm(void *to, const void *f= rom, unsigned int len) return 0; } =20 - rc =3D hvm_copy_to_guest_linear((unsigned long)to, (void *)from, len, = 0, NULL); + rc =3D hvm_copy_to_guest_linear((unsigned long)to, from, len, 0, NULL); return rc ? len : 0; /* fake a copy_to_user() return code */ } =20 --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755833186.0394751619483; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654525.1021524 (Exim 4.92) (envelope-from ) id 1rDkWK-00021z-72; Thu, 14 Dec 2023 12:08:52 +0000 Received: by outflank-mailman (output) from mailman id 654525.1021524; Thu, 14 Dec 2023 12:08: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 1rDkWJ-00020q-Uo; Thu, 14 Dec 2023 12:08:51 +0000 Received: by outflank-mailman (input) for mailman id 654525; Thu, 14 Dec 2023 12:08:50 +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 1rDkWI-0000tC-BU for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:50 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 89c53d18-9a79-11ee-98e9-6d05b1d4d9a1; Thu, 14 Dec 2023 13:08:49 +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 46A274EE0C81; Thu, 14 Dec 2023 13:08:48 +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: 89c53d18-9a79-11ee-98e9-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Simone Ballarin , Doug Goldstein , Stefano Stabellini , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [PATCH 8/9] xen: add deviations for Rule 11.8 Date: Thu, 14 Dec 2023 13:07:50 +0100 Message-Id: <854747a97c4c7a70bfe1a30a038f2cc6aebfb566.1702555387.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: 1702555757665100007 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". Deviate use of macro container_of. Deviate use of function ERR_CAST. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- container_of: Fixing this violation would require the declaration of a new macro taking advantage of the return value of the ternary operator ?: : its return value preserves qualifiers present on both expression, hence returning void* or qualified void* depending on pointer type, like in this= macro: '#define same_constness_void_ptr(ptr) ((typeof((false ? (void*) 1 : (ptr))= )) (ptr))' The result could then be used with a Generic to avoid the cast. --- automation/eclair_analysis/ECLAIR/deviations.ecl | 12 ++++++++++++ docs/misra/deviations.rst | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index 683f2bbfe8..d3e32a6ac8 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -292,6 +292,18 @@ constant expressions are required.\"" # Series 11 # =20 +-doc_begin=3D"Violations caused by container_of are due to pointer arithme= tic operations +with the provided offset. The resulting pointer is then immediately cast b= ack to its +original type, which preserves the qualifier. This use can be deemed as sa= fe. +Fixing this violation would require to increase code complexity and lower = readability." +-config=3DMC3R1.R11.8,reports+=3D{safe,"any_area(any_loc(any_exp(macro(^co= ntainer_of$))))"} +-doc_end + +-doc_begin=3D"This function is made to explicitly cast an error-valued poi= nter to a void +pointer type to make it clear that's what's going on, so the violation is = deliberate." +-config=3DMC3R1.R11.8,reports+=3D{deliberate,"all_area(context(^ERR_CAST\\= (.*$))"} +-doc_end + -doc_begin=3D"This construct is used to check if the type is scalar, and f= or this purpose the use of 0 as a null pointer constant is deliberate." -config=3DMC3R1.R11.9,reports+=3D{deliberate, "any_area(any_loc(any_exp(ma= cro(^__ACCESS_ONCE$))))" } diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index eda3c8100c..98733d636d 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -248,6 +248,19 @@ Deviations related to MISRA C:2012 Rules: If no bits are set, 0 is returned. - Tagged as `safe` for ECLAIR. =20 + * - R11.8 + - Violations caused by container_of are due to pointer arithmetic ope= rations + with the provided offset. The resulting pointer is then immediately= cast back to its + original type, which preserves the qualifier. This use can be deeme= d as safe. + Fixing this violation would require to increase code complexity and= lower readability. + - Tagged as `safe` for ECLAIR. + =20 + * - R11.8 + - This function is made to explicitly cast an error-valued pointer to= a + void pointer type to make it clear that's what's going on, so the + violation is deliberate. + - Tagged ad `deliberate` for ECLAIR. + * - R11.9 - __ACCESS_ONCE uses an integer, which happens to be zero, as a compile time check. The typecheck uses a cast. The usage of zero or= other --=20 2.40.0 From nobody Sat May 18 13:36:50 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 1702555755253661.2620124653231; Thu, 14 Dec 2023 04:09:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654527.1021550 (Exim 4.92) (envelope-from ) id 1rDkWM-0002ll-E9; Thu, 14 Dec 2023 12:08:54 +0000 Received: by outflank-mailman (output) from mailman id 654527.1021550; Thu, 14 Dec 2023 12:08:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWL-0002hP-V2; Thu, 14 Dec 2023 12:08:53 +0000 Received: by outflank-mailman (input) for mailman id 654527; Thu, 14 Dec 2023 12:08:51 +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 1rDkWJ-0000tI-Kj for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:51 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8a19fd92-9a79-11ee-9b0f-b553b5be7939; Thu, 14 Dec 2023 13:08:49 +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 D060B4EE0C91; Thu, 14 Dec 2023 13:08:48 +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: 8a19fd92-9a79-11ee-9b0f-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Simone Ballarin Subject: [PATCH 9/9] xen: add SAF deviation for safe cast removal. Date: Thu, 14 Dec 2023 13:07:51 +0100 Message-Id: <36e996b864853dba26a9c9fb9c9c674e92cc935e.1702555387.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: 1702555755452100001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states: "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer". In function __hvm_copy, the const qualifier is cast away to comply with its function signature. There's no modification of the pointee during its execution, therefore its use can be deemed as safe. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- docs/misra/safe.json | 8 ++++++++ xen/arch/x86/hvm/hvm.c | 1 + 2 files changed, 9 insertions(+) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 952324f85c..e748bc6cf5 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -28,6 +28,14 @@ }, { "id": "SAF-3-safe", + "analyser": { + "eclair": "MC3R1.R11.8" + }, + "name": "MC3R1.R11.8: removal of const qualifier to comply wit= h function signature", + "text": "It is safe to cast away const qualifiers to comply wi= th function signature if the function does not modify the pointee." + }, + { + "id": "SAF-4-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 523e0df57c..414853254f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3413,6 +3413,7 @@ static enum hvm_translation_result __hvm_copy( enum hvm_translation_result hvm_copy_to_guest_phys( paddr_t paddr, const void *buf, unsigned int size, struct vcpu *v) { + /* SAF-3-safe */ return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */, paddr, size, v, HVMCOPY_to_guest | HVMCOPY_phys, 0, NULL); --=20 2.40.0