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

[PATCH v2] automation/eclair: generalize the noreturn function-pointer deviation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 13 Oct 2026 07:56:25 +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=xMYMA/KwPHjEVJ8bC31LLOq6cVzWd+H96Cfq1RBleIs=; b=yALR5k4lExwFvA46Hyc7VELWGMeYp5JOejcoJCXItM40bYh3reM3Tdnni3NBLFrvMRIHVzEorHc631oOvZutvj0gVnW3yyjIHN+diqZHcrAMKg4i/7QoVsgSXTXlPzxdSO5e/WIHwY4FpsbQ6zo/3JrWqJSaViYcrB3/s5C2BTicdXPpDlFfetl12CDvZqohC5utTMMNXJQPlW6GbSsJerLgjpCSdddWegconi6mbIhcty6Xtxxgli2zqN6JOBSwYq4SFIIAsT9mfmtRBR2tG0IZ1EnaW+pUm8ZlyHchcFydqdX4Zg0hK+P0TkgJrjUQLQgFWx6sXm+fyRseieO6wQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oLzn74/6tgj+8Txg9SD0IPrdo8+LalZnsV3JSVun+PyEAjdhQSlgL2MVXnNAzJbzQl0GXwGXlcyBxQjZI1QujQZj4BBhAwebhY7oJkndb/hqLTHf+Wmuqv2iMz+F6vmLbYRb7XG248eIDVNKtFwDVKSYGvPkHWu7kC7/MJo1GiRWBAsj1gXAL074fdEP4kd+iHIN04Lx3zZnAXs5aX2rHV5vABtOwTRkfJgcbMIT9zQsdXPTZ2NJRQgs/08Q+Etvj9gdvmji7wQB/NCnj7NxXpI95VwtTgzylK3fWHBXSKToGSkxrrFNvSuysQ12dJfaTWYg4HUUwqS2ZKzKKclUCw==
  • 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>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, 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>
  • Delivery-date: Tue, 13 Oct 2026 07:56:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdWuhYpZfkS0sLoEKj8O8bb8Y05w==
  • Thread-topic: [PATCH v2] automation/eclair: generalize the noreturn function-pointer deviation

The R11.1 safe cast only matched void noreturn (*)(void *). Accept any
noreturn function pointer converted to a compatible function pointer.
canonical() covers typeof destinations, and compatible_deep_unqualified
keeps the parameter and return types aligned.

Discarding noreturn does not change the calling convention. The full
rationale is in docs/misra/deviations.rst.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
CI test pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2941365256

Changes in v2:
- do not claim that discarding noreturn leaves compiler behavior unchanged
- write that code after the call is unreachable, and that Xen's behavior
  is the same (whether the compiler deletes that code or leaves it)

Link to v1:
https://patchew.org/Xen/d68c56607781bfa829766aed36eeb31f06080fbc.1791224638.git.dmytro._5Fprokopchuk1@xxxxxxxx/
---
 automation/eclair_analysis/ECLAIR/deviations.ecl |  7 +++----
 docs/misra/deviations.rst                        | 10 ++++++----
 docs/misra/rules.rst                             |  7 ++++---
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 6cdb10a129..226793f52e 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -394,11 +394,10 @@ constant expressions are required.\""
 }
 -doc_end
 
--doc_begin="The conversion from 'void noreturn (*)(void *)' to 'void (*)(void 
*)' is safe
-because the semantics of the 'noreturn' attribute do not alter the calling 
convention or behavior of the resulting code."
+-doc_begin="The conversion from a noreturn function pointer to a function 
pointer with a compatible signature does not alter the calling convention."
 -config=MC3A2.R11.1,casts+={safe,
-  "kind(bitcast)&&to(type(pointer(inner(return(builtin(void))&&all_param(1, 
pointer(builtin(void)))))))&&from(expr(skip(!syntactic(),
-   ref(property(noreturn)))))"} 
+  
"kind(bitcast)&&to(type(canonical(__function_pointer_types)))&&from(expr(skip(!syntactic(),
+   ref(property(noreturn)))))&&relation(compatible_deep_unqualified)"}
 -doc_end
 
 -doc_begin="The conversion from a pointer to an incomplete type to unsigned 
long does not lose any information, provided that the target type has enough 
bits to store it."
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 6bcc2adf95..430811b39d 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -392,10 +392,12 @@ Deviations related to MISRA C:2012 Rules:
      - Tagged as `safe` for ECLAIR.
 
    * - R11.1
-     - The conversion from 'void noreturn (*)(...)' to 'void (*)(...)' is safe
-       because the semantics of the 'noreturn' attribute do not alter the 
calling
-       convention or behavior of the resulting code, parameters handling remain
-       consistent.
+     - The conversion from a noreturn function pointer to a function pointer
+       with a compatible signature does not alter the calling convention.
+       The callee does not return, so code following a call through the
+       resulting pointer is unreachable. The compiler may delete that
+       unreachable code when it can see the noreturn callee, or it may
+       leave the code in place. Xen's behavior is the same in either case.
      - Tagged as `safe` for ECLAIR.
 
    * - R11.2
diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index a59cf1782e..bd288bba29 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -435,9 +435,10 @@ maintainers if you want to suggest a change.
        and any other type
      - All conversions to integer types are permitted if the destination
        type has enough bits to hold the entire value. Conversions to bool
-       and void* are permitted. Conversions from 'void noreturn (*)(...)'
-       to 'void (*)(...)' are permitted. Conversions from [unsigned] long
-       or '(void *)' to a function pointer are permitted.
+       and void* are permitted. Conversions from a noreturn function pointer
+       to a function pointer with a compatible signature are permitted.
+       Conversions from [unsigned] long or '(void *)' to a function pointer
+       are permitted.
        Example::
 
            unsigned long func_addr = (unsigned long)&some_function;
-- 
2.43.0

 


Rackspace

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