From nobody Fri May 17 15:47:07 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 1702983988543644.7417778928408; Tue, 19 Dec 2023 03:06:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656668.1025023 (Exim 4.92) (envelope-from ) id 1rFXvP-0003pf-Sj; Tue, 19 Dec 2023 11:06:11 +0000 Received: by outflank-mailman (output) from mailman id 656668.1025023; Tue, 19 Dec 2023 11:06:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvP-0003ou-KG; Tue, 19 Dec 2023 11:06:11 +0000 Received: by outflank-mailman (input) for mailman id 656668; Tue, 19 Dec 2023 11:06:10 +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 1rFXvO-0003Hq-LH for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:10 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9b79e041-9e5e-11ee-98eb-6d05b1d4d9a1; Tue, 19 Dec 2023 12:06: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 8DD474EE0C8D; Tue, 19 Dec 2023 12:06:06 +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: 9b79e041-9e5e-11ee-98eb-6d05b1d4d9a1 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 v2 1/6] xen/arm: address violations of MISRA C:2012 Rule 11.8 Date: Tue, 19 Dec 2023 12:05:09 +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: 1702983989784100001 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. Drop redundant cast to preserve const qualifier. No functional change. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2: - drop redundant cast on fdt --- 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..1cbac3cb2a 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(fdt, 0, early_scan_node, 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 Fri May 17 15:47:07 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 170298399045815.975886117493133; Tue, 19 Dec 2023 03:06:30 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656670.1025044 (Exim 4.92) (envelope-from ) id 1rFXvR-0004RP-Cy; Tue, 19 Dec 2023 11:06:13 +0000 Received: by outflank-mailman (output) from mailman id 656670.1025044; Tue, 19 Dec 2023 11:06:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvR-0004OG-7T; Tue, 19 Dec 2023 11:06:13 +0000 Received: by outflank-mailman (input) for mailman id 656670; Tue, 19 Dec 2023 11:06:11 +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 1rFXvP-0003Hq-Lb for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:11 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9bb7bc45-9e5e-11ee-98eb-6d05b1d4d9a1; Tue, 19 Dec 2023 12:06:07 +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 1B7B04EE0C92; Tue, 19 Dec 2023 12:06:07 +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: 9bb7bc45-9e5e-11ee-98eb-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Maria Celeste Cesario , Shawn Anastasio , Simone Ballarin , Stefano Stabellini Subject: [PATCH v2 2/6] xen/ppc: address violations of MISRA C:2012 Rule 11.8. Date: Tue, 19 Dec 2023 12:05:10 +0100 Message-Id: <9270a4fe1712cff6a99e60c7862de1c1b2dde3d6.1702982442.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: 1702983991724100003 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 Acked-by: Shawn Anastasio --- 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 Fri May 17 15:47:07 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 1702983985430926.6875656357194; Tue, 19 Dec 2023 03:06:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656667.1025016 (Exim 4.92) (envelope-from ) id 1rFXvP-0003in-Er; Tue, 19 Dec 2023 11:06:11 +0000 Received: by outflank-mailman (output) from mailman id 656667.1025016; Tue, 19 Dec 2023 11:06:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvP-0003hs-A9; Tue, 19 Dec 2023 11:06:11 +0000 Received: by outflank-mailman (input) for mailman id 656667; Tue, 19 Dec 2023 11:06:10 +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 1rFXvO-0003cc-CD for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:10 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9c46a156-9e5e-11ee-9b0f-b553b5be7939; Tue, 19 Dec 2023 12:06:08 +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 806C34EE0C98; Tue, 19 Dec 2023 12:06:07 +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: 9c46a156-9e5e-11ee-9b0f-b553b5be7939 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 v2 3/6] xen: add deviations for Rule 11.8 Date: Tue, 19 Dec 2023 12:05:11 +0100 Message-Id: <04cdbf21db915634acd49108edab7d6331df35eb.1702982442.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: 1702983986005100001 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". The macro 'container_of' violates the Rule because it casts away any qualifier to do pointer arithmetic, but making the macro definition complia= nt would add additional complexity, therefore a deviation is introduced. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Changes in v2: - remove deviation for function ERR_CAST; 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 | 7 +++++++ docs/misra/deviations.rst | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/= eclair_analysis/ECLAIR/deviations.ecl index 683f2bbfe8..1515378ff1 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -292,6 +292,13 @@ 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 is deemed safe. +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 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..ccf6e90e87 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -248,6 +248,13 @@ 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 is deemed sa= fe. + Fixing this violation would require to increase code complexity and= lower readability. + - Tagged as `safe` for ECLAIR. + =20 * - 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 Fri May 17 15:47:07 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 1702983992452811.1543819723071; Tue, 19 Dec 2023 03:06:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656672.1025059 (Exim 4.92) (envelope-from ) id 1rFXvS-0004kk-K8; Tue, 19 Dec 2023 11:06:14 +0000 Received: by outflank-mailman (output) from mailman id 656672.1025059; Tue, 19 Dec 2023 11:06:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvS-0004jU-Cn; Tue, 19 Dec 2023 11:06:14 +0000 Received: by outflank-mailman (input) for mailman id 656672; Tue, 19 Dec 2023 11:06:12 +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 1rFXvQ-0003Hq-Lu for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:12 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9c871784-9e5e-11ee-98eb-6d05b1d4d9a1; Tue, 19 Dec 2023 12:06:08 +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 26ABC4EE0C9A; Tue, 19 Dec 2023 12:06:08 +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: 9c871784-9e5e-11ee-98eb-6d05b1d4d9a1 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 , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Simone Ballarin Subject: [PATCH v2 4/6] xen: add SAF deviation for safe cast removal Date: Tue, 19 Dec 2023 12:05:12 +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: 1702983994646100002 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 SAF-3-safe deviation: removal of const qualifier to comply with functio= n signature. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin --- Changes in v2: - reword SAF-3-safe text; - merge comments on __hvm_copy; - add SAF-3-safe comment in x86/hvm.c:3433; - add SAF-3-safe comment on arm/guestcopy.c raw_copy_to_guest and raw_copy_to_guest_flush_dcache. --- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/guestcopy.c | 2 ++ xen/arch/x86/hvm/hvm.c | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 952324f85c..96b964293a 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": "A single function could either read or write through = a passed in pointer, depending on how it is called. It is deemed safe to ca= st away a const qualifier when passing a pointer to such a function, when t= he other parameters guarantee read-only operation." + }, + { + "id": "SAF-4-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 6716b03561..cf80ac46b1 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -109,6 +109,7 @@ static unsigned long copy_guest(void *buf, uint64_t add= r, unsigned int len, =20 unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int l= en) { + /* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current), COPY_to_guest | COPY_linear); } @@ -116,6 +117,7 @@ unsigned long raw_copy_to_guest(void *to, const void *f= rom, unsigned int len) unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned int len) { + /* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current), COPY_to_guest | COPY_flush_dcache | COPY_linear); } diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 523e0df57c..324893fbcc 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3413,7 +3413,8 @@ 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) { - return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */, + /* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ + return __hvm_copy((void *)buf, paddr, size, v, HVMCOPY_to_guest | HVMCOPY_phys, 0, NULL); } @@ -3429,7 +3430,8 @@ enum hvm_translation_result hvm_copy_to_guest_linear( unsigned long addr, const void *buf, unsigned int size, uint32_t pfec, pagefault_info_t *pfinfo) { - return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */, + /* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ + return __hvm_copy((void *)buf, addr, size, current, HVMCOPY_to_guest | HVMCOPY_line= ar, PFEC_page_present | PFEC_write_access | pfec, pfinfo= ); } --=20 2.40.0 From nobody Fri May 17 15:47:07 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 170298399161110.65120207157213; Tue, 19 Dec 2023 03:06:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656669.1025039 (Exim 4.92) (envelope-from ) id 1rFXvR-0004Ln-2B; Tue, 19 Dec 2023 11:06:13 +0000 Received: by outflank-mailman (output) from mailman id 656669.1025039; Tue, 19 Dec 2023 11:06:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvQ-0004KT-Tc; Tue, 19 Dec 2023 11:06:12 +0000 Received: by outflank-mailman (input) for mailman id 656669; Tue, 19 Dec 2023 11:06:11 +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 1rFXvP-0003cc-4X for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:11 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9d234269-9e5e-11ee-9b0f-b553b5be7939; Tue, 19 Dec 2023 12:06:09 +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 DBB564EE0C96; Tue, 19 Dec 2023 12:06:08 +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: 9d234269-9e5e-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 , Simone Ballarin Subject: [PATCH v2 5/6] xen: remove unused function ERR_CAST Date: Tue, 19 Dec 2023 12:05:13 +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: 1702983994562100001 Content-Type: text/plain; charset="utf-8" From: Maria Celeste Cesario Function ERR_CAST contains a violation 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". Since the function has no users, it is appropriate to remove it. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Acked-by: Jan Beulich Reviewed-by: Stefano Stabellini --- Commit introduced in v2. --- xen/include/xen/err.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h index 2f29b57d28..cbdd1bf7f8 100644 --- a/xen/include/xen/err.h +++ b/xen/include/xen/err.h @@ -36,19 +36,6 @@ static inline long __must_check IS_ERR_OR_NULL(const voi= d *ptr) return !ptr || IS_ERR_VALUE((unsigned long)ptr); } =20 -/** - * ERR_CAST - Explicitly cast an error-valued pointer to another pointer t= ype - * @ptr: The pointer to cast. - * - * Explicitly cast an error-valued pointer to another pointer type in such= a - * way as to make it clear that's what's going on. - */ -static inline void * __must_check ERR_CAST(const void *ptr) -{ - /* cast away the const */ - return (void *)ptr; -} - static inline int __must_check PTR_RET(const void *ptr) { return IS_ERR(ptr) ? PTR_ERR(ptr) : 0; --=20 2.40.0 From nobody Fri May 17 15:47:07 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 1702984001797125.98903623139017; Tue, 19 Dec 2023 03:06:41 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.656671.1025053 (Exim 4.92) (envelope-from ) id 1rFXvS-0004bW-4m; Tue, 19 Dec 2023 11:06:14 +0000 Received: by outflank-mailman (output) from mailman id 656671.1025053; Tue, 19 Dec 2023 11:06:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFXvR-0004a0-RM; Tue, 19 Dec 2023 11:06:13 +0000 Received: by outflank-mailman (input) for mailman id 656671; Tue, 19 Dec 2023 11:06:12 +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 1rFXvQ-0003cc-2G for xen-devel@lists.xenproject.org; Tue, 19 Dec 2023 11:06:12 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9d6cbe10-9e5e-11ee-9b0f-b553b5be7939; Tue, 19 Dec 2023 12:06:10 +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 7A4024EE0C9B; Tue, 19 Dec 2023 12:06:09 +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: 9d6cbe10-9e5e-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 , Simone Ballarin Subject: [PATCH v2 6/6] xen/common: address violations of MISRA C:2012 Rule 11.8 Date: Tue, 19 Dec 2023 12:05:14 +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: 1702984003754100001 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". Change cast type from void* to uintptr_t. void* type cast resulted in violation of the Rule, a cast to type uintptr_t is more appropriate type-wise. Signed-off-by: Maria Celeste Cesario Signed-off-by: Simone Ballarin Acked-by: Jan Beulich --- Commit introduced in v2 --- xen/common/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/version.c b/xen/common/version.c index d320135208..e807ef4de0 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 (uintptr_t)__note_gnu_build_id_end - (uintptr_t)n; =20 rc =3D xen_build_id_check(n, sz, &build_id_p, &build_id_len); =20 --=20 2.40.0