All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/shim: adjust for Misra C:2012 rule 20.12
@ 2026-05-13 15:52 Jan Beulich
  2026-05-13 16:30 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2026-05-13 15:52 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Roger Pau Monné, Teddy Astie

... ("A macro parameter used as an operand to the `#' or `##' operators,
which is itself subject to further macro replacement, shall only be used
as an operand to these operators"). Move the HVM_PARAM_ prefixes into the
macro body, to use ## on the 2nd use (each) of the macro parameter.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I understand that this "absorbing" of prefixes isn't liked by some people,
so I'm all ears towards alternative suggestions.

https://gitlab.com/xen-project/hardware/xen-staging/-/jobs/14354119193
(also covering the 17.5 patch)

--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -116,17 +116,17 @@ void __init pv_shim_fixup_e820(void)
 
     ASSERT(xen_guest);
 
-#define MARK_PARAM_RAM(p) ({                    \
-    rc = xen_hypercall_hvm_get_param(p, &pfn);  \
-    if ( rc )                                   \
-        panic("Unable to get " #p "\n");        \
-    mark_pfn_as_ram(pfn);                       \
-    ASSERT(i < ARRAY_SIZE(reserved_pages));     \
-    reserved_pages[i++].mfn = pfn;              \
+#define MARK_PARAM_RAM(p) ({                                 \
+    rc = xen_hypercall_hvm_get_param(HVM_PARAM_ ## p, &pfn); \
+    if ( rc )                                                \
+        panic("Unable to get HVM_PARAM_" #p "\n");           \
+    mark_pfn_as_ram(pfn);                                    \
+    ASSERT(i < ARRAY_SIZE(reserved_pages));                  \
+    reserved_pages[i++].mfn = pfn;                           \
 })
-    MARK_PARAM_RAM(HVM_PARAM_STORE_PFN);
+    MARK_PARAM_RAM(STORE_PFN);
     if ( !pv_console )
-        MARK_PARAM_RAM(HVM_PARAM_CONSOLE_PFN);
+        MARK_PARAM_RAM(CONSOLE_PFN);
 #undef MARK_PARAM_RAM
 }
 
@@ -190,9 +190,9 @@ void __init pv_shim_setup_dom(struct dom
     long rc;
 
 #define SET_AND_MAP_PARAM(p, si, va) ({                                        \
-    rc = xen_hypercall_hvm_get_param(p, &param);                               \
+    rc = xen_hypercall_hvm_get_param(HVM_PARAM_ ## p, &param);                 \
     if ( rc )                                                                  \
-        panic("Unable to get " #p "\n");                                       \
+        panic("Unable to get HVM_PARAM_" #p "\n");                             \
     (si) = param;                                                              \
     if ( va )                                                                  \
     {                                                                          \
@@ -207,12 +207,11 @@ void __init pv_shim_setup_dom(struct dom
         evtchn_reserve(d, param);                                              \
     }                                                                          \
 })
-    SET_AND_MAP_PARAM(HVM_PARAM_STORE_PFN, si->store_mfn, store_va);
-    SET_AND_MAP_PARAM(HVM_PARAM_STORE_EVTCHN, si->store_evtchn, 0);
-    SET_AND_MAP_PARAM(HVM_PARAM_CONSOLE_EVTCHN, si->console.domU.evtchn, 0);
+    SET_AND_MAP_PARAM(STORE_PFN, si->store_mfn, store_va);
+    SET_AND_MAP_PARAM(STORE_EVTCHN, si->store_evtchn, 0);
+    SET_AND_MAP_PARAM(CONSOLE_EVTCHN, si->console.domU.evtchn, 0);
     if ( !pv_console )
-        SET_AND_MAP_PARAM(HVM_PARAM_CONSOLE_PFN, si->console.domU.mfn,
-                          console_va);
+        SET_AND_MAP_PARAM(CONSOLE_PFN, si->console.domU.mfn, console_va);
 #undef SET_AND_MAP_PARAM
     else
     {


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-13 21:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 15:52 [PATCH] x86/shim: adjust for Misra C:2012 rule 20.12 Jan Beulich
2026-05-13 16:30 ` Andrew Cooper
2026-05-13 21:07   ` Nicola Vetrini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.