Skip to contentSkip to conversation

Fix MISRA regressions for new ARM64 configurations

PATCH In review Michal Orzel 3 participants 7 messages Dec 5, 2025

lore
Share & tools
lore
#0 lore raw

cover Fix MISRA regressions for new ARM64 configurations

After addition of new eclair scans for other configurations like defconfig, some regressions for clean rules were reported. This series focuses on report generated for ARM64 and gets rid of all the regressions.

Diff:
eclair-ARM64{-testing}: was 22 regressions, now 0 eclair-x86_64{-testing}: was 359 regressions, now 337

https://gitlab.com/xen-project/people/morzel/xen/-/pipelines/2197932219

Michal Orzel (3):
public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK common/kernel: Rename hypfs "params" variable xen/hypfs: Enclose HYPFS_DIR_INIT var parameter in parentheses

 xen/common/kernel.c        | 6 +++---
 xen/include/public/trace.h | 2 +-
 xen/include/xen/hypfs.h    | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK

TRC_PV_HYPERCALL_V2_ARG_MASK represents unsigned type, so according to MISRA C R7.2. U suffix should be applied. Fix the violation.

---
 xen/include/public/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/trace.h +1 -1
index 141efa0ea7b9..a7d7fb8c507f 100644
@@ -157,7 +157,7 @@
  */
 #define TRC_PV_HYPERCALL_V2_ARG_32(i) (0x1 << (20 + 2*(i)))
 #define TRC_PV_HYPERCALL_V2_ARG_64(i) (0x2 << (20 + 2*(i)))
-#define TRC_PV_HYPERCALL_V2_ARG_MASK  (0xfff00000)
+#define TRC_PV_HYPERCALL_V2_ARG_MASK  (0xfff00000U)
 
 #define TRC_SHADOW_NOT_SHADOW                 (TRC_SHADOW +  1)
 #define TRC_SHADOW_FAST_PROPAGATE             (TRC_SHADOW +  2)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] public/trace: Add U suffix to TRC_PV_HYPERCALL_V2_ARG_MASK

Quoted 13 lines · Michal Orzel

TRC_PV_HYPERCALL_V2_ARG_MASK represents unsigned type, so according to MISRA C R7.2. U suffix should be applied. Fix the violation.

---
 xen/include/public/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/public/trace.h +0 -0
index 141efa0ea7b9..a7d7fb8c507f 100644

xen/include/public/trace.h line 163

Quoted 8 lines
xen/include/public/trace.h +1 -1
@@ -157,7 +157,7 @@
  */
 #define TRC_PV_HYPERCALL_V2_ARG_32(i) (0x1 << (20 + 2*(i)))
 #define TRC_PV_HYPERCALL_V2_ARG_64(i) (0x2 << (20 + 2*(i)))
-#define TRC_PV_HYPERCALL_V2_ARG_MASK  (0xfff00000)
+#define TRC_PV_HYPERCALL_V2_ARG_MASK  (0xfff00000U)
 
 #define TRC_SHADOW_NOT_SHADOW                 (TRC_SHADOW +  1)
 #define TRC_SHADOW_FAST_PROPAGATE             (TRC_SHADOW +  2)

Hmm.  Ideally we should use _AC() (or whatever monstrosity we call it in the public headers), but this header contains C structs unguarded by __ASSEMBL{ER,Y}__ so we don't need to be so careful.

changing it, you can drop the brackets too.

#3 lore raw

PATCH 2/3 common/kernel: Rename hypfs "params" variable

In reply to Michal Orzel

Inside do_xen_version, there are two other places using local variables named "params". Rename hypfs dir "params" to "params_dir". This resolves MISRA C R5.3 violation.

---
 xen/common/kernel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/common/kernel.c +3 -3
index e6979352e100..fb45f8139995 100644
@@ -483,13 +483,13 @@ static int __init cf_check buildinfo_init(void)
 }
 __initcall(buildinfo_init);
 
-static HYPFS_DIR_INIT(params, "params");
+static HYPFS_DIR_INIT(params_dir, "params");
 
 static int __init cf_check param_init(void)
 {
     struct param_hypfs *param;
 
-    hypfs_add_dir(&hypfs_root, &params, true);
+    hypfs_add_dir(&hypfs_root, &params_dir, true);
 
     for ( param = __paramhypfs_start; param < __paramhypfs_end; param++ )
     {
@@ -497,7 +497,7 @@ static int __init cf_check param_init(void)
             param->init_leaf(param);
         else if ( param->hypfs.e.type == XEN_HYPFS_TYPE_STRING )
             param->hypfs.e.size = strlen(param->hypfs.u.content) + 1;
-        hypfs_add_leaf(&params, &param->hypfs, true);
+        hypfs_add_leaf(&params_dir, &param->hypfs, true);
     }
 
     return 0;
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] common/kernel: Rename hypfs "params" variable

Quoted 5 lines · Michal Orzel

Inside do_xen_version, there are two other places using local variables named "params". Rename hypfs dir "params" to "params_dir". This resolves MISRA C R5.3 violation.

Equally, the two things called params could be shorted to p, but "params" is a common general name so this approach is probably better.

#5 lore raw

PATCH 3/3 xen/hypfs: Enclose HYPFS_DIR_INIT var parameter in parentheses

In reply to Michal Orzel

The var parameter is later on expanded and referenced by LIST_HEAD_INIT and shall be enclosed in parentheses. This resolves MISRA C R20.7 violation.

---
 xen/include/xen/hypfs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/include/xen/hypfs.h +2 -2
index d8fcac23b46b..fef667298b21 100644
@@ -95,9 +95,9 @@ struct hypfs_dyndir_id {
         .e.name = (nam),                          \
         .e.size = 0,                              \
         .e.max_size = 0,                          \
-        .e.list = LIST_HEAD_INIT(var.e.list),     \
+        .e.list = LIST_HEAD_INIT((var).e.list),   \
         .e.funcs = (fn),                          \
-        .dirlist = LIST_HEAD_INIT(var.dirlist),   \
+        .dirlist = LIST_HEAD_INIT((var).dirlist), \
     }
 
 #define HYPFS_DIR_INIT(var, nam)                  \
Signature · 1 line
2.43.0