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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 17 Nov 2026 21:31:44 +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=uS4FOq+gx0XLaq6e+JhIdA2zgGATpIC0hJ5eH48iM3k=; b=pSgSotWWLBUv6gJfclMH/cD4nNdIvFEUEG/H61jwBTzsWCl3fHN/Ou62gnQY911Id0/L756hqeVvXTa+BWrQ03xWLVNyI6zywc/xKleZxTLUemJ32fMdP8dHGGMXdl05QrCWpw9zYDyq/hYW8Y22ReWkSR8ePfNrNMJbAhjDbN05CIusHyw6LYsajvjuBPgzqje0CVe1oIu8NLaqpKuruFWUj91TXDmjWT4bmSESdSetDJt5kmmM5MBH4yP7OkNlDb7QNpI3B68AZf5CDGbU83IKVhj8jDGSrj8s592LYwj2vJRyBFOsEb+oav1lFFzPPyl32tSgffmP94mJOBcmww==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nwUfdEKGYKNCZaDZvQjWfvfaSuCfrJOsq3EonqQBx5VTr5KVEXc+tsrtzwMUoCXva/of+Mim9ZeizDeFX/K23PufsK9+mT+Efjn9ISoNBsa3FQ+EPbGH3rihmK8WGdSNSCn/7+KspdXNOfF2HCEjHYgu0kIjhw6aHTKXL0RTg4tFfE4SPMUoh6T+KcL00j6iP3n3GTXLpRkfmCT+VKCCDmJ4B/X+ig/+wlnm50+E4l5MnMIwuCWpwRTpKpSnYzm38BNNMsJL99VvoMk/246F8t68YdB7idmULXLTA2LcGghkSQV5sKzxHtLuW94vWmfEgryCR1S7nZh7X9d9OFIxvA==
  • 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: Tue, 17 Nov 2026 21:31:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHddtsL6F0/2Q3MIESmeIeKPz/reQ==
  • Thread-topic: [PATCH] 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 enable
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>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/3081209229
---
 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..67f8ed9869 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 capabilities to void * for enable 
callback",
+            "text": "The Arm CPU capability enable callback takes void * to 
match the generic callback convention. The cast removes const only to pass a 
const struct arm_cpu_capabilities * into that signature. Existing enable 
implementations 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..4d2b183a62 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 caps to void * for enable 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 caps to void * for enable 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®.