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

Re: [PATCH 3/3] misra: deviate MISRA C Rule 5.5 for ARM SMMU fault handlers


  • To: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Thu, 04 Jun 2026 08:23:50 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1780554231; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=wpRW8U+4ZquNMOfcE/qcP8H4Q49TTxFxWiEPQcHVf4I=; b=Isf5qnWmR4D9sBE8kHCuGr3HFFGf33y6mgIn3gpWgQFeO4Z4+dGIR09+y+1zcIAmrj7r y1ujjVQxPV/CDkO6zwA3JW881VxKzLyvAnVfahmHx9OjPSdKt7pzFzzTEv/BR17i2mXdW FWqQmNRflqYC4kiPPlv1dVyYBidZ5M6JuwKbhv55a9vnQq4h9CEw+9Fqa/hu0eFdRgL3F 1dv3yom8Rl0gemg3j1ZdAIplUr5vks7jqMkxgAm7OCwnQQJe+bMW2N0TD5zmXmytFjdVJ F/Wwk2CKiBAVH/qwQ8dCOSinrtWLXYDkEZ9nPhD5qSqOCvyZ9IwxtXGW5+zr6P9nrxNVq gmiUvD/IwhbcDS+q3TZhoOPjXzyiEBjY4pNty0N7E0lCo+W8I6XBdmOIaA5wP/GlkIiGr tRAqrWvw98BamRxWnBxc1AFUPIxC6ZU07iWrQR0xXSzYmeWjz5f5iBT7mlxJE37D78sEn OV5e/sBkf95x/jQoInwCwuzuvtcoEurqD2wvpsqAdJOID8Q2v94SjtQnH0tZXq1F/nZdb 0PqFAgS89qsvTKj5h7CkiTnXLJrc14Pw4PIftm+lmIs9TQ/MeaR46Amk5q32vpKFXsKHJ 8PaI13RLaBH18gH7W66Cg7NOW2OBwHl8cWEmp8sFFqgaOJkn37VLYXONiv1w4Zk=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1780554231; b=QBZADWzZfxFlRVOJgKJZfL3xmGDipvoilkebsOjT+9LFDHx/uJQgvZTEvVzmSxd/3NMk UqOUkdLdvkpVs/y2z3QIbworoq59cLkw1oib1UXiUj18McQqCvNoP+gOAxFbH2bDYLTB6 lnUrzKwvqFKsiQ+SfcADiGWMuKhQnZwHhx0WpSe8GKFPXDbbtu5FJceZIYAtr6/r3Bygs iM5Ffk/MUIrth/lmm2LF/ZntqnOYM4IUZVDyVdCSwbxy3+g8K54qmjmY80bBh7pYidtNx 8jFftXpdZh6SHJh1VjIIxxPWHer6VJx7Vdpigdt3OIPcxZLmgw0udwbGE9EdYYQGZrDPf NhBVZ1qWSEWrN42LkhAGJquzRIRtWk7+fGutYZhF6Ogp92ALg4YHgnNMqFHYkEuHGzxO/ zfXDXxk0pK3ysMsxDRoJ0XQWILNPZVNjHlKrLo69P7mgStO5f57CWK0BHaGKM8NJELYVr hiLEMgAPmvKNsaNwUFKS36aiwyWQukMUeAT+bUPxqx+vyHGuRB6nRseUha1XSpfyCoM+1 PLGBKywQNDXWb3u81duiCLvZWeOOWNtutwTGYO6t64wTmJrH/MvD/akHh9k1JtH/QUbxI XbjBtiu8nb0f96nrYnXixOyn+4TEFKRiAWqM0QnrrRUyb2L3xdZDzNSmJr3MRPk=
  • Authentication-results: eu.smtp.expurgate.cloud; none
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, 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.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 04 Jun 2026 06:23:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-05-25 14:05, Dmytro Prokopchuk1 wrote:
MISRA C Rule 5.5 states: "Identifiers shall be distinct from macro
names".

Update ECLAIR configuration to deviate intentional identifier and
macro name clashes by specifying the macros that should be ignored.
This includes 'arm_smmu_global_fault' and 'arm_smmu_context_fault',
where the original ARM SMMU handler returns irqreturn_t, while the
same-named macro redirects later uses to a Xen wrapper with the
void interrupt-handler signature expected by Xen 'request_irq()'.

Update deviations.rst and rules.rst accordingly.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ++++++
 docs/misra/deviations.rst                        | 7 +++++++
 docs/misra/rules.rst                             | 4 ++++
 3 files changed, 17 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 7aa64796ba..419a23ce8e 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -144,6 +144,12 @@ ARM SMMU driver calls by reordering the handler and flags arguments." -config=MC3A2.R5.5,ignored_macros+="name(request_irq)&&loc(file(^xen/drivers/passthrough/arm/smmu\\.c$))"
 -doc_end

+-doc_begin="Clashes between ARM SMMU fault handler functions and macro names in 'xen/drivers/passthrough/arm/smmu.c' are deliberate. +The original ARM SMMU handler returns irqreturn_t, while the macro redirects later uses to a Xen wrapper with the
+void interrupt-handler signature expected by Xen 'request_irq()'."
+-config=MC3A2.R5.5,ignored_macros+="name(arm_smmu_global_fault||arm_smmu_context_fault)&&loc(file(^xen/drivers/passthrough/arm/smmu\\.c$))"
+-doc_end
+
 -doc_begin="The type \"ret_t\" is deliberately defined multiple times,
 depending on the guest."
-config=MC3A2.R5.6,reports+={deliberate,"any_area(any_loc(text(^.*ret_t.*$)))"}
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 01f141b73f..15c88b82f4 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -192,6 +192,13 @@ Deviations related to MISRA C:2012 Rules:
        reordering the handler and flags arguments.
      - ECLAIR has been configured to ignore this macro.

+   * - R5.5
+ - Clashes between the ARM SMMU fault handler functions and macro names are + intentional. The original ARM SMMU handler returns irqreturn_t, while
+       the macro redirects later uses to a Xen wrapper with the void
+       interrupt-handler signature expected by Xen 'request_irq()'.
+     - ECLAIR has been configured to ignore these macros.
+
    * - R5.6
- The type ret_t is deliberately defined multiple times depending on the
        type of guest to service.
diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index 097c20432e..88d2c5fa7c 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -230,6 +230,10 @@ maintainers if you want to suggest a change.
the macro is a local compatibility wrapper that adapts ARM SMMU driver
        call to Xen's request_irq() argument order.

+ Clashes between ARM SMMU fault handler functions and macro names are + allowed because the macros redirect ARM SMMU driver uses to a Xen interrupt
+       wrapper with the handler signature expected by request_irq().
+
* - `Rule 5.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_
      - Required
      - A typedef name shall be a unique identifier

Seeing the growing number of exceptions for R5.5 and 5.6 for one reason or another in deviations.ecl, I wonder whether a more structured approach to the configuration would be better (e.g., a JSON file that is then processed just before the build to produce an ECL file fragment evaluated in the the right place). The change itself is fine, but I think this would tidy up a bit the file from these targeted exceptions.

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

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