From: Grygorii Strashko <grygorii_stras...@epam.com>

On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq()
functions are unreachable (Misra rule 2.1).

Move these function under CONFIG_HAS_PIRQ ifdefs to fix Misra rule 2.1
violation and resolve call of evtchn_move_pirqs() from common /sched/core.c
vcpu_move_irqs() code by moving evtchn_move_pirqs() into x86
arch_move_irqs() callback (which is converted to define).

Signed-off-by: Grygorii Strashko <grygorii_stras...@epam.com>
---
changes in v2:
- functions fully moved under idefs
- evtchn_move_pirqs() call moved in x86 arch code

v1: https://lists.xenproject.org/archives/html/xen-devel/2025-07/msg01207.html
 xen/arch/x86/include/asm/irq.h | 2 +-
 xen/common/event_channel.c     | 5 ++++-
 xen/common/sched/core.c        | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/include/asm/irq.h b/xen/arch/x86/include/asm/irq.h
index 3c73073b71b3..8c81f66434a8 100644
--- a/xen/arch/x86/include/asm/irq.h
+++ b/xen/arch/x86/include/asm/irq.h
@@ -224,7 +224,7 @@ void cleanup_domain_irq_mapping(struct domain *d);
 
 bool cpu_has_pending_apic_eoi(void);
 
-static inline void arch_move_irqs(struct vcpu *v) { }
+#define arch_move_irqs(v) evtchn_move_pirqs(v)
 
 struct msi_info;
 int allocate_and_map_gsi_pirq(struct domain *d, int index, int *pirq_p);
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index c8c1bfa615df..aa5cf41a8d6d 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -970,6 +970,7 @@ void send_guest_domain_virq(struct domain *d, uint32_t virq)
     read_unlock_irqrestore(&v->virq_lock, flags);
 }
 
+#ifdef CONFIG_HAS_PIRQ
 void send_guest_pirq(struct domain *d, const struct pirq *pirq)
 {
     int port;
@@ -994,6 +995,7 @@ void send_guest_pirq(struct domain *d, const struct pirq 
*pirq)
         evtchn_read_unlock(chn);
     }
 }
+#endif /* CONFIG_HAS_PIRQ */
 
 static DEFINE_SPINLOCK(global_virq_handlers_lock);
 
@@ -1707,6 +1709,7 @@ void evtchn_destroy_final(struct domain *d)
 }
 
 
+#ifdef CONFIG_HAS_PIRQ
 void evtchn_move_pirqs(struct vcpu *v)
 {
     struct domain *d = v->domain;
@@ -1722,7 +1725,7 @@ void evtchn_move_pirqs(struct vcpu *v)
     }
     read_unlock(&d->event_lock);
 }
-
+#endif /* CONFIG_HAS_PIRQ */
 
 static void domain_dump_evtchn_info(struct domain *d)
 {
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 13fdf57e57b9..ad6032fb2865 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -642,7 +642,6 @@ int sched_init_vcpu(struct vcpu *v)
 static void vcpu_move_irqs(struct vcpu *v)
 {
     arch_move_irqs(v);
-    evtchn_move_pirqs(v);
 }
 
 static void sched_move_irqs(const struct sched_unit *unit)
-- 
2.34.1

Reply via email to