xen/evtchn: enable build optimization for evtchn_move_pirqs()/send_guest_pirq()
PATCH v2 1/2 xen/evtchn: enable build optimization for evtchn_move_pirqs()/send_guest_pirq()
From: Grygorii Strashko <[email protected]>
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).
---
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(-)
xen/arch/x86/include/asm/irq.h +1 -1
@@ -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);
xen/common/event_channel.c +4 -1
@@ -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) {
xen/common/sched/core.c +0 -1
@@ -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)
Signature · 1 line
2.34.1
PATCH 2/2 xen/arm: irq: drop unreachable pirq callbacks
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under CONFIG_HAS_PIRQ idefs corresponding Arm arch callbacks become unreachable, so drop them.
--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)
xen/arch/arm/irq.c +0 -29
@@ -595,35 +595,6 @@ unlock:return ret; } -/* -* pirq event channels. We don't use these on ARM, instead we use the -* features of the GIC to inject virtualised normal interrupts. -*/ -struct pirq *alloc_pirq_struct (struct domain *d) -{ -return NULL ; -} - -/* -* These are all unreachable given an alloc_pirq_struct -* which returns NULL, all callers try to lookup struct pirq first -* which will fail. -*/ -int pirq_guest_bind (struct vcpu *v,struct pirq *pirq,int will_share) -{ -BUG (); -} - -void pirq_guest_unbind (struct domain *d,struct pirq *pirq) -{ -BUG (); -} - -void pirq_set_affinity (struct domain *d,int pirq,const cpumask_t *mask) -{ -BUG (); -} -static bool irq_validate_new_type (unsigned int curr,unsigned int new) {return (curr ==IRQ_TYPE_INVALID || curr == new );
Signature · 1 line
2.34.1
Re: [XEN][PATCH 2/2] xen/arm: irq: drop unreachable pirq callbacks
Quoted 9 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under
CONFIG_HAS_PIRQidefs corresponding Arm arch callbacks become unreachable, so drop them.Signed-off-by Grygorii Strashko <[email protected]>--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)
Can this really be a separate change? That is, aren't we going to have transient Misra violations (for Arm only) between the two changes?
Jan
Quoted 38 lines
xen/arch/arm/irq.c +0
-29@@ -595,35 +595,6 @@ unlock:return ret; } -/* -* pirq event channels. We don't use these on ARM, instead we use the -* features of the GIC to inject virtualised normal interrupts. -*/ -struct pirq *alloc_pirq_struct (struct domain *d) -{ -return NULL ; -} - -/* -* These are all unreachable given an alloc_pirq_struct -* which returns NULL, all callers try to lookup struct pirq first -* which will fail. -*/ -int pirq_guest_bind (struct vcpu *v,struct pirq *pirq,int will_share) -{ -BUG (); -} - -void pirq_guest_unbind (struct domain *d,struct pirq *pirq) -{ -BUG (); -} - -void pirq_set_affinity (struct domain *d,int pirq,const cpumask_t *mask) -{ -BUG (); -} -static bool irq_validate_new_type (unsigned int curr,unsigned int new) {return (curr ==IRQ_TYPE_INVALID || curr == new );
Re: [XEN][PATCH 2/2] xen/arm: irq: drop unreachable pirq callbacks
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under
CONFIG_HAS_PIRQidefs corresponding Arm arch callbacks become unreachable, so drop them.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Grygorii Strashko <[email protected]>--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)Can this really be a separate change? That is, aren't we going to have transient Misra violations (for Arm only) between the two changes?
The violation exist even before this series, and applies to arm/ppc/riscv actually
alloc_pirq_struct - unreachablepirq_guest_bind - unreachablepirq_guest_unbind - unreachablepirq_set_affinity - "reachable" at least from compiler point of view.
Would you like to have cumulative, cross-arch change to drop above arch callbacks and squash it in previous patch?
Quoted 39 lines
Quoted 38 lines
xen/arch/arm/irq.c +0
-29@@ -595,35 +595,6 @@ unlock:return ret; } -/* -* pirq event channels. We don't use these on ARM, instead we use the -* features of the GIC to inject virtualised normal interrupts. -*/ -struct pirq *alloc_pirq_struct (struct domain *d) -{ -return NULL ; -} - -/* -* These are all unreachable given an alloc_pirq_struct -* which returns NULL, all callers try to lookup struct pirq first -* which will fail. -*/ -int pirq_guest_bind (struct vcpu *v,struct pirq *pirq,int will_share) -{ -BUG (); -} - -void pirq_guest_unbind (struct domain *d,struct pirq *pirq) -{ -BUG (); -} - -void pirq_set_affinity (struct domain *d,int pirq,const cpumask_t *mask) -{ -BUG (); -} -static bool irq_validate_new_type (unsigned int curr,unsigned int new) {return (curr ==IRQ_TYPE_INVALID || curr == new );
Signature · 2 lines
Best regards, -grygorii
Re: [XEN][PATCH 2/2] xen/arm: irq: drop unreachable pirq callbacks
Quoted 19 lines · Grygorii Strashko
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under
CONFIG_HAS_PIRQidefs corresponding Arm arch callbacks become unreachable, so drop them.Quoted 7 lines
Quoted 4 lines
Signed-off-by Grygorii Strashko <[email protected]>--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)Can this really be a separate change? That is, aren't we going to have transient Misra violations (for Arm only) between the two changes?
The violation exist even before this series, and applies to arm/ppc/riscv actually
Quoted 7 lines
alloc_pirq_struct- unreachablepirq_guest_bind- unreachablepirq_guest_unbind- unreachablepirq_set_affinity- "reachable" at least from compiler point of view.Would you like to have cumulative, cross-arch change to drop above arch callbacks and squash it in previous patch?
If the issue is pre-existing, then it doesn't need squashing and the order isn't important. But it would indeed be desirable to have the cleanup done across the board.
Jan
Re: [XEN][PATCH 2/2] xen/arm: irq: drop unreachable pirq callbacks
Quoted 25 lines · Jan Beulich
Quoted 24 lines · Grygorii Strashko
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under
CONFIG_HAS_PIRQidefs corresponding Arm arch callbacks become unreachable, so drop them.Quoted 7 lines
Quoted 4 lines
Signed-off-by Grygorii Strashko <[email protected]>--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)Can this really be a separate change? That is, aren't we going to have transient Misra violations (for Arm only) between the two changes?
The violation exist even before this series, and applies to arm/ppc/riscv actually
alloc_pirq_struct- unreachablepirq_guest_bind- unreachablepirq_guest_unbind- unreachablepirq_set_affinity- "reachable" at least from compiler point of view.
Quoted 6 lines
Quoted 2 lines
Would you like to have cumulative, cross-arch change to drop above arch callbacks and squash it in previous patch?
If the issue is pre-existing, then it doesn't need squashing and the order isn't important. But it would indeed be desirable to have the cleanup done across the board.
I can create clean-up patches for all affected arches.
What's you opinion on how to proceed:
- re-send this series with additional patches
- wait for patch 1 and then send arch specific clean-up series ?
Thank you.
Signature · 2 lines
Best regards, -grygorii
Re: [XEN][PATCH 2/2] xen/arm: irq: drop unreachable pirq callbacks
Quoted 31 lines · Grygorii Strashko
Quoted 23 lines · Jan Beulich
Quoted 22 lines · Grygorii Strashko
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
Hence all common PIRQ code is under
CONFIG_HAS_PIRQidefs corresponding Arm arch callbacks become unreachable, so drop them.Quoted 7 lines
Quoted 4 lines
Signed-off-by Grygorii Strashko <[email protected]>--- xen/arch/arm/irq.c | 29 ----------------------------- 1 file changed, 29 deletions(-)Can this really be a separate change? That is, aren't we going to have transient Misra violations (for Arm only) between the two changes?
The violation exist even before this series, and applies to arm/ppc/riscv actually
alloc_pirq_struct- unreachablepirq_guest_bind- unreachablepirq_guest_unbind- unreachablepirq_set_affinity- "reachable" at least from compiler point of view.Quoted 6 lines
Quoted 2 lines
Would you like to have cumulative, cross-arch change to drop above arch callbacks and squash it in previous patch?
If the issue is pre-existing, then it doesn't need squashing and the order isn't important. But it would indeed be desirable to have the cleanup done across the board.
Quoted 6 lines
I can create clean-up patches for all affected arches.
What's you opinion on how to proceed:
- re-send this series with additional patches
- wait for patch 1 and then send arch specific clean-up series ?
Largely up to you, I would say. I was actually about to commit patch 1, when I noticed that it's still lacking a scheduler maintainer ack.
Jan
Quoted 9 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).
The patch title isn't quite appropriate anymore with this description, I think.
Quoted 1 line
Signed-off-by Grygorii Strashko <[email protected]>
preferably with ...
xen/common/event_channel.c void evtchn_destroy_final(struct domain *d) · line 1715
Quoted 8 lines
xen/common/event_channel.c +1
-0@@ -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;
... one of the two blank lines also dropped here, just like you do ...
xen/common/event_channel.c void evtchn_move_pirqs(struct vcpu *v) · line 1728
Quoted 6 lines
xen/common/event_channel.c +1
-1@@ -1722,7 +1725,7 @@ void evtchn_move_pirqs(struct vcpu *v) }read_unlock (&d->event_lock); } - +#endif /* CONFIG_HAS_PIRQ */
... here. Happy to adjust while committing, but please consider suggesting a replacement patch title.
Jan
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).The patch title isn't quite appropriate anymore with this description, I think.
Quoted 1 line
Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Jan Beulich <[email protected]>preferably with ...
xen/common/event_channel.c void evtchn_destroy_final(struct domain *d) · line 1715
Quoted 8 lines
xen/common/event_channel.c +1
-0@@ -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;... one of the two blank lines also dropped here, just like you do ...
Quoted 8 lines
xen/common/event_channel.c void evtchn_move_pirqs(struct vcpu *v) · line 1728
Quoted 6 lines
xen/common/event_channel.c +1
-1@@ -1722,7 +1725,7 @@ void evtchn_move_pirqs(struct vcpu *v) }read_unlock (&d->event_lock); } - +#endif /* CONFIG_HAS_PIRQ */ ... here. Happy to adjust while committing,
Thank you.
Quoted 1 line
but please consider suggesting a replacement patch title.
Honestly, I, by myself, not sure about proper patch title :( My options would be:
"xen/evtchn: evtchn_move_pirqs()/send_guest_pirq() fix MISRA Rule 2.1 violation"
"xen/evtchn: opt out of common pIRQ code for arches without pIRQ support"
"xen/evtchn: fully restrict concept of pIRQ for arches with pIRQ support only"
Signature · 2 lines
Best regards, -grygorii
Quoted 46 lines · Grygorii Strashko
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).The patch title isn't quite appropriate anymore with this description, I think.
Quoted 1 line
Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Jan Beulich <[email protected]>preferably with ...
xen/common/event_channel.c void evtchn_destroy_final(struct domain *d) · line 1715
Quoted 8 lines
xen/common/event_channel.c +1
-0@@ -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;... one of the two blank lines also dropped here, just like you do ...
Quoted 8 lines
xen/common/event_channel.c void evtchn_move_pirqs(struct vcpu *v) · line 1728
Quoted 6 lines
xen/common/event_channel.c +1
-1@@ -1722,7 +1725,7 @@ void evtchn_move_pirqs(struct vcpu *v) }read_unlock (&d->event_lock); } - +#endif /* CONFIG_HAS_PIRQ */ ... here. Happy to adjust while committing,
Thank you.
Quoted 1 line
but please consider suggesting a replacement patch title.
Quoted 8 lines
Honestly, I, by myself, not sure about proper patch title :( My options would be:
"xen/evtchn: evtchn_move_pirqs()/send_guest_pirq() fix MISRA Rule 2.1 violation"
"xen/evtchn: opt out of common pIRQ code for arches without pIRQ support"
"xen/evtchn: fully restrict concept of pIRQ for arches with pIRQ support only"
I would probably pick one of the latter two, but as said - an ack is still missing here. FTAOD: It is on you to chase it.
Jan
Quoted 50 lines · Jan Beulich
Quoted 49 lines · Grygorii Strashko
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).The patch title isn't quite appropriate anymore with this description, I think.
Quoted 1 line
Signed-off-by Grygorii Strashko <[email protected]>Reviewed-by Jan Beulich <[email protected]>preferably with ...
xen/common/event_channel.c void evtchn_destroy_final(struct domain *d) · line 1715
Quoted 8 lines
xen/common/event_channel.c +1
-0@@ -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;... one of the two blank lines also dropped here, just like you do ...
Quoted 8 lines
xen/common/event_channel.c void evtchn_move_pirqs(struct vcpu *v) · line 1728
Quoted 6 lines
xen/common/event_channel.c +1
-1@@ -1722,7 +1725,7 @@ void evtchn_move_pirqs(struct vcpu *v) }read_unlock (&d->event_lock); } - +#endif /* CONFIG_HAS_PIRQ */ ... here. Happy to adjust while committing,
Thank you.
Quoted 1 line
but please consider suggesting a replacement patch title.
Honestly, I, by myself, not sure about proper patch title :( My options would be:
Quoted 9 lines
Quoted 5 lines
"xen/evtchn: evtchn_move_pirqs()/send_guest_pirq() fix MISRA Rule 2.1 violation"
"xen/evtchn: opt out of common pIRQ code for arches without pIRQ support"
"xen/evtchn: fully restrict concept of pIRQ for arches with pIRQ support only"
I would probably pick one of the latter two, but as said - an ack is still missing here. FTAOD: It is on you to chase it.
Could you merge first patch and I'll send cumulative arch clean-up patches?
Signature · 2 lines
Best regards, -grygorii
Hi Juergen, Dario, George,
Sorry that disturbing you.
Would it be possible to take a look at this patch as it has change in common/sched/core.c?
Quoted 84 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).Signed-off-by Grygorii Strashko <[email protected]>---
changes in v2:
- functions fully moved under idefs
-evtchn_move_pirqs()call moved in x86 arch codev1: 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(-)xen/arch/x86/include/asm/irq.h +1
-1@@ -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);xen/common/event_channel.c +4
-1@@ -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) {xen/common/sched/core.c +0
-1@@ -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)
Signature · 2 lines
Best regards, -grygorii
Jürgen Groß
Acked-byQuoted 18 lines · Grygorii Strashko
Hi Juergen, Dario, George,
Sorry that disturbing you.
Would it be possible to take a look at this patch as it has change incommon/sched/core.c?Quoted 11 lines · Grygorii Strashko
From: Grygorii Strashko <[email protected]>
On platforms without PIRQ support evtchn_move_pirqs()/send_guest_pirq() functions are unreachable (Misra rule 2.1).
Move these function under
CONFIG_HAS_PIRQifdefs to fix Misra rule 2.1 violation and resolve call ofevtchn_move_pirqs()from common /sched/core.cvcpu_move_irqs()code by movingevtchn_move_pirqs()into x86arch_move_irqs()callback (which is converted to define).Signed-off-by Grygorii Strashko <[email protected]>
Juergen