Skip to contentSkip to conversation

Misc MISRA fixes for default Xen build configurations

PATCH In review Nicola Vetrini 4 participants 9 messages Nov 20, 2025 – Nov 25, 2025

lore
Share & tools
lore
#0 lore raw

cover Misc MISRA fixes for default Xen build configurations

This series addresses some of the violations found by widening the scope of application of MISRA checking to default builds of Xen for both ARM64 and x86_64.

While it has been tested on top of a patch yet to be applied (but with the necessary R-by [1]) these fixes can go in independently of that.

As evidenced by the CI pipeline below, there are a number of regressions on guidelines that were clean on the restricted scope but are not in the wider one; the patches in this series address a subset of those.

CI pipeline: https://gitlab.com/xen-project/people/bugseng/xen/-/pipelines/2156782159

[1] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2511031448530.495094@ubuntu-linux-20-04-desktop/

Nicola Vetrini (4):
xen/xsm: address violations of MISRA C rules 8.3 and 7.2 xen/sched: address violation of MISRA C Rule 16.3 xen/param: address violation of MISRA C Rule 20.7 xen/param: address violation of MISRA C Rule 8.2

 xen/common/sched/credit.c | 2 +-
 xen/include/xen/param.h   | 6 +++---
 xen/include/xsm/xsm.h     | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.51.2
#1 lore raw

PATCH 1/4 xen/xsm: address violations of MISRA C rules 8.3 and 7.2

Rule 8.3 states: Function types shall be in prototype form with named parameters.

add parameter to 'has_xsm_magic' to make it consistent with the definition.

Rule 7.2 states: A u' or U' suffix shall be applied to all integer constants that are represented in an unsigned type.

add missing U' to both #define for XSM_MAGIC` for consistency.

No functional change.

---
 xen/include/xsm/xsm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/xsm/xsm.h +3 -3
index 9a23d2827c..074d61cd45 100644
@@ -22,9 +22,9 @@
 typedef uint32_t xsm_magic_t;
 
 #ifdef CONFIG_XSM_FLASK
-#define XSM_MAGIC 0xf97cff8c
+#define XSM_MAGIC 0xf97cff8cU
 #else
-#define XSM_MAGIC 0x0
+#define XSM_MAGIC 0x0U
 #endif
 
 /*
@@ -815,7 +815,7 @@ int xsm_multiboot_policy_init(
  */
 int xsm_dt_init(void);
 int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);
-bool has_xsm_magic(paddr_t);
+bool has_xsm_magic(paddr_t start);
 #endif
 
 void xsm_fixup_ops(struct xsm_ops *ops);
Signature · 1 line
2.51.2
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] xen/xsm: address violations of MISRA C rules 8.3 and 7.2

Quoted 35 lines · Nicola Vetrini

Rule 8.3 states: Function types shall be in prototype form with named parameters.

add parameter to 'has_xsm_magic' to make it consistent with the definition.

Rule 7.2 states: A u' or U' suffix shall be applied to all integer constants that are represented in an unsigned type.

add missing U' to both #define for XSM_MAGIC` for consistency.

No functional change.

---
  xen/include/xsm/xsm.h | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/xsm/xsm.h +2 -2
index 9a23d2827c..074d61cd45 100644
@@ -22,9 +22,9 @@
  typedef uint32_t xsm_magic_t;
 
  #ifdef CONFIG_XSM_FLASK
-#define XSM_MAGIC 0xf97cff8c
+#define XSM_MAGIC 0xf97cff8cU
  #else
-#define XSM_MAGIC 0x0
+#define XSM_MAGIC 0x0U
  #endif
 
  /*

xen/include/xsm/xsm.h int xsm_multiboot_policy_init( · line 821

Quoted 8 lines
xen/include/xsm/xsm.h +1 -1
@@ -815,7 +815,7 @@ int xsm_multiboot_policy_init(
   */
  int xsm_dt_init(void);
  int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);
-bool has_xsm_magic(paddr_t);
+bool has_xsm_magic(paddr_t start);
  #endif
 
  void xsm_fixup_ops(struct xsm_ops *ops);
#3 lore raw

PATCH 2/4 xen/sched: address violation of MISRA C Rule 16.3

In reply to Nicola Vetrini

The rule states: An unconditional `break' statement shall terminate every switch-clause.

Use the `fallthrough' pseudo-keyword for which an ECLAIR deviation is already in place.

No functional change.

---
 xen/common/sched/credit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/sched/credit.c +1 -1
index 6dcf6b2c8b..e9a91d11c3 100644
@@ -1288,7 +1288,7 @@ csched_sys_cntl(const struct scheduler *ops,
         prv->unit_migr_delay = MICROSECS(params->vcpu_migr_delay_us);
         spin_unlock_irqrestore(&prv->lock, flags);
 
-        /* FALLTHRU */
+        fallthrough;
     case XEN_SYSCTL_SCHEDOP_getinfo:
         params->tslice_ms = prv->tslice / MILLISECS(1);
         params->ratelimit_us = prv->ratelimit / MICROSECS(1);
Signature · 1 line
2.51.2
Acked-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] xen/sched: address violation of MISRA C Rule 16.3

Quoted 9 lines · Nicola Vetrini

The rule states: An unconditional `break' statement shall terminate every switch-clause.

Use the `fallthrough' pseudo-keyword for which an ECLAIR deviation is already in place.

No functional change.

Juergen

#5 lore raw

PATCH 3/4 xen/param: address violation of MISRA C Rule 20.7

In reply to Nicola Vetrini

The rule states: Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses.

Add parentheses in the defition of `custom_runtime_var_sz' to address the violations.

No functional change.

---
 xen/include/xen/param.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/xen/param.h +2 -2
index 1bdbab34ab..f5a2189400 100644
@@ -102,8 +102,8 @@ extern struct param_hypfs __paramhypfs_start[], __paramhypfs_end[];
 
 #define custom_runtime_set_var_sz(parfs, var, sz) \
     { \
-        (parfs)->hypfs.u.content = var; \
-        (parfs)->hypfs.e.max_size = sz; \
+        (parfs)->hypfs.u.content = (var); \
+        (parfs)->hypfs.e.max_size = (sz); \
         (parfs)->hypfs.e.size = strlen(var) + 1; \
     }
 #define custom_runtime_set_var(parfs, var) \
Signature · 1 line
2.51.2
Acked-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] xen/param: address violation of MISRA C Rule 20.7

Quoted 9 lines · Nicola Vetrini

The rule states: Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses.

Add parentheses in the defition of `custom_runtime_var_sz' to address the violations.

No functional change.

#7 lore raw

PATCH 4/4 xen/param: address violation of MISRA C Rule 8.2

In reply to Nicola Vetrini

add missing parameter name in function pointer member declaration.

No functional change.

---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/xen/param.h +1 -1
index f5a2189400..3b6f134b07 100644
@@ -90,7 +90,7 @@ extern const struct kernel_param __setup_start[], __setup_end[];
 struct param_hypfs {
     struct hypfs_entry_leaf hypfs;
     void (*init_leaf)(struct param_hypfs *par);
-    int (*func)(const char *);
+    int (*func)(const char *s);
 };
 
 extern struct param_hypfs __paramhypfs_start[], __paramhypfs_end[];
Signature · 1 line
2.51.2