Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A155C4332F for ; Thu, 14 Dec 2023 12:09:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.654518.1021471 (Exim 4.92) (envelope-from ) id 1rDkWG-0000tV-0f; Thu, 14 Dec 2023 12:08:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 654518.1021471; Thu, 14 Dec 2023 12:08:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDkWF-0000tO-Tx; Thu, 14 Dec 2023 12:08:47 +0000 Received: by outflank-mailman (input) for mailman id 654518; Thu, 14 Dec 2023 12:08:46 +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 1rDkWE-0000tC-MS for xen-devel@lists.xenproject.org; Thu, 14 Dec 2023 12:08:46 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 87b94610-9a79-11ee-98e9-6d05b1d4d9a1; 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 436BB4EE073A; Thu, 14 Dec 2023 13:08:44 +0100 (CET) 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: 87b94610-9a79-11ee-98e9-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 , Jan Beulich , Andrew Cooper , George Dunlap , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Shawn Anastasio , Simone Ballarin , Doug Goldstein Subject: [PATCH 0/9] xen: address violations of MISRA C:2012 Rule 11.8 Date: Thu, 14 Dec 2023 13:07:42 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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". This patch amends or removes casts that unnecessarily drop const and volatile qualifiers. Example: static always_inline bool int_##name(volatile void *p) { volatile uint32_t *ptr = (uint32_t *)p; /* Non-compliant */ volatile uint32_t *ptr = (volatile uint32_t *)p; /* Compliant, proposed change */ } In this example, the volatile qualifier is unnecessarily removed from the original object, therefore making it non-compliant. Deviate the following violations: - removal of const qualifier to comply with function signature It is safe to cast away const qualifiers to comply with function signature if the function does not modify the pointee. A SAF-3-safe comment was added to deviate this violation. - violations in macro container_of Violations caused by this macro are due to pointer arithmetic operations with the provided offset. The resulting pointer is then immediately cast back to its original type, which preserves the qualifier. This use can be deemed as safe. - violations in function ERR_CAST 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. Maria Celeste Cesario (9): xen/arm64: address violations of MISRA C:2012 Rule 11.8 xen/arm: address violations of MISRA C:2012 Rule 11.8 xen/efi: address violations of MISRA C:2012 Rule 11.8 ACPI: address violations of MISRA C:2012 Rule 11.8 xen/x86: address violations of MISRA C:2012 Rule 11.8 xen/ppc: address violations of MISRA C:2012 Rule 11.8. x86/hvm: address violations of MISRA C:2012 Rule 11.8 xen: add deviations for Rule 11.8 xen: add SAF deviation for safe cast removal. automation/eclair_analysis/ECLAIR/deviations.ecl | 12 ++++++++++++ docs/misra/deviations.rst | 13 +++++++++++++ docs/misra/safe.json | 8 ++++++++ xen/arch/arm/arm64/lib/bitops.c | 6 ++++-- xen/arch/arm/bootfdt.c | 6 +++--- xen/arch/arm/include/asm/alternative.h | 2 +- xen/arch/arm/include/asm/arm64/cmpxchg.h | 10 +++++----- xen/arch/ppc/include/asm/atomic.h | 2 +- xen/arch/x86/boot/reloc.c | 4 ++-- xen/arch/x86/hvm/hvm.c | 3 ++- xen/common/efi/boot.c | 6 +++--- xen/common/version.c | 2 +- xen/include/acpi/acmacros.h | 2 +- 13 files changed, 56 insertions(+), 20 deletions(-) -- 2.40.0