[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] xen/arm: deviate MISRA R11.8 for capability enable callbacks


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Thu, 19 Nov 2026 11:49:26 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K5FTm/tEl0dsiLJ0HktNmziadQe8K7eE7Ap4wcMwm8U=; b=hSS6rc5hJcDnVL17w6FJLKo5QrxrE1mFeoDBaQ0MpppEVm7DDdXvw6ZnHf7LOxqNX7uDrBB7t3VREww+EOr8pAT/ZLjMizsDegIq4gcCcjPHeccVxR4G0zgxewpgLOglrGxv0sdl9/D1dv/YL8cP7Y0LlU43DJwIIOCij2R0nZ9aiwKcGwW64KaSssC6rztCCuWUsVQ4zAcf+yrePIIkQ+8SoaFBV0LR+BYb22i7g1/M3el2pmNNb5q7O3vGs/4INVKR8ILNDYbzSPLCyu0rOb3H2URt/KKj47ERF+Mw3f04AQ6G5P2WUbG0BwwmZ5hLAtIki92b66XoTVCJj/Q3JQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mMN0MNMG9vbgUEnSpTw64nttUp4yPLRknjJe5tDaGdpzHBCtFepiVFmh5IYmL1rYwBieg+f3mwx+7PYfhEB/96eCBsPuefkhYFZpLpE7TtUoGjn9E0I9RwB3ww99tAzgJhwgbFPs6AhywThDRTYrE/TOkWa1MFjjevyh7QUToKmIu0IhkuwJV1CHrTMK09PIuGZKDOqq/BqZT3vIkbK5GTQmZZZGY72Yglp7wmZenzHw1GJabps5c+7/s7/YUfpo1R2SR31qSPcoFASMfgDXdSBHjCC5DHu+WCBNlI1T/IgtjByBv4voRVsvh1Oc7fbgqkdHeL77cvZNlAkCgAgOLw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 19 Nov 2026 11:49:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdeBwHGnVyHQGpAEaDepxzc/WbYw==
  • Thread-topic: [PATCH v2] xen/arm: deviate MISRA R11.8 for capability enable callbacks

MISRA C Rule 11.8 forbids casts that remove the const qualifier from
the pointed-to type. enable_cpu_capabilities() and
enable_nonboot_cpu_caps() cast a const struct arm_cpu_capabilities
pointer to void * so that it can be passed to the capability enable
callback, either directly or through stop_machine_run().

The callback type takes void * by convention. Existing callback
implementations treat the pointer as const and do not modify the
object. Document both casts with SAF-15-safe comment.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Changes in v2:
- make SAF-15 generic for casting a const pointer to void * for a
  callback, not Arm caps only
---
 docs/misra/safe.json      | 8 ++++++++
 xen/arch/arm/cpufeature.c | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index 3584cb90c6..85a2f31692 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -124,6 +124,14 @@
         },
         {
             "id": "SAF-15-safe",
+            "analyser": {
+                "eclair": "MC3A2.R11.8"
+            },
+            "name": "Rule 11.8: cast const pointer to void * for a callback",
+            "text": "Callbacks often have void * parameters, to be 
type-generic. Casting a const-qualified pointer to void * only to pass it into 
such a signature is safe when the callback implementation treat the pointer as 
const and do not modify the object."
+        },
+        {
+            "id": "SAF-16-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
index 8d8cd19a96..7db0f8dcdb 100644
--- a/xen/arch/arm/cpufeature.c
+++ b/xen/arch/arm/cpufeature.c
@@ -72,6 +72,7 @@ void __init enable_cpu_capabilities(const struct 
arm_cpu_capabilities *caps)
              * an IPI, giving us a PSTATE that disappears when we
              * return.
              */
+            /* SAF-15-safe R11.8 cast const pointer to void * for a callback */
             ret = stop_machine_run(caps->enable, (void *)caps, NR_CPUS);
             /* stop_machine_run should never fail at this stage of the boot. */
             BUG_ON(ret);
@@ -108,6 +109,7 @@ int enable_nonboot_cpu_caps(const struct 
arm_cpu_capabilities *caps)
 
         if ( caps->enable )
         {
+            /* SAF-15-safe R11.8 cast const pointer to void * for a callback */
             int ret = caps->enable((void *)caps);
 
             if ( ret )
-- 
2.43.0

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.