xen/irq: Delete the pirq_cleanup_check() macro

MISRA Rule 5.5 objects to a macro aliasing a function, which is what
pirq_cleanup_check() does. The macro was originally intended to ensure the
condition 'if (!pirq->evtchn)' is always checked before invoking the function,
avoiding errors across call sites.

There are only a handful of users, so expand it inline to be plain regular
C. Doing this shows one path now needing braces, and one path in
'evtchn_bind_pirq()' where the expanded form simplifies back to no delta, as
it follows an unconditional clear of 'info->evtchn'.

While this complies with MISRA, it shifts the responsibility to developers to
check 'if (!pirq->evtchn)' at call sites.

No functional changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Andrew Cooper committed 2025-12-12 03:04:48 +00:00
1 parent 3161cfa40b
commit 4aa218acd4
4 files changed
+17 -11

No files matched your search

+7 -4
View File
@@ -1351,7 +1351,8 @@ static void clear_domain_irq_pirq(struct domain *d, int irq, struct pirq *pirq)
static void cleanup_domain_irq_pirq(struct domain *d, int irq,
struct pirq *pirq)
{
pirq_cleanup_check(pirq, d);
if ( !pirq->evtchn )
pirq_cleanup_check(pirq, d);
radix_tree_delete(&d->arch.irq_pirq, irq);
}
@@ -1409,7 +1410,7 @@ struct pirq *alloc_pirq_struct(struct domain *d)
return pirq;
}
void (pirq_cleanup_check)(struct pirq *pirq, struct domain *d)
void pirq_cleanup_check(struct pirq *pirq, struct domain *d)
{
/*
* Check whether all fields have their default values, and delete
@@ -2849,7 +2850,8 @@ int map_domain_emuirq_pirq(struct domain *d, int pirq, int emuirq)
radix_tree_int_to_ptr(pirq));
break;
default:
pirq_cleanup_check(info, d);
if ( !info->evtchn )
pirq_cleanup_check(info, d);
return err;
}
}
@@ -2884,7 +2886,8 @@ int unmap_domain_pirq_emuirq(struct domain *d, int pirq)
if ( info )
{
info->arch.hvm.emuirq = IRQ_UNBOUND;
pirq_cleanup_check(info, d);
if ( !info->evtchn )
pirq_cleanup_check(info, d);
}
if ( emuirq != IRQ_PT )
radix_tree_delete(&d->arch.hvm.emuirq_pirq, emuirq);
+4 -1
View File
@@ -741,11 +741,14 @@ int evtchn_close(struct domain *d1, int port1, bool guest)
if ( !is_hvm_domain(d1) ||
domain_pirq_to_irq(d1, pirq->pirq) <= 0 ||
unmap_domain_pirq_emuirq(d1, pirq->pirq) < 0 )
{
/*
* The successful path of unmap_domain_pirq_emuirq() will have
* called pirq_cleanup_check() already.
*/
pirq_cleanup_check(pirq, d1);
if ( !pirq->evtchn )
pirq_cleanup_check(pirq, d1);
}
}
unlink_pirq_port(chn1, d1->vcpu[chn1->notify_vcpu_id]);
break;
+6 -3
View File
@@ -329,7 +329,8 @@ int pt_irq_create_bind(
pirq_dpci->gmsi.gvec = 0;
pirq_dpci->dom = NULL;
pirq_dpci->flags = 0;
pirq_cleanup_check(info, d);
if ( !info->evtchn )
pirq_cleanup_check(info, d);
write_unlock(&d->event_lock);
return rc;
}
@@ -536,7 +537,8 @@ int pt_irq_create_bind(
hvm_irq_dpci->link_cnt[link]--;
}
pirq_dpci->flags = 0;
pirq_cleanup_check(info, d);
if ( !info->evtchn )
pirq_cleanup_check(info, d);
write_unlock(&d->event_lock);
xfree(girq);
xfree(digl);
@@ -693,7 +695,8 @@ int pt_irq_destroy_bind(
*/
pt_pirq_softirq_reset(pirq_dpci);
pirq_cleanup_check(pirq, d);
if ( !pirq->evtchn )
pirq_cleanup_check(pirq, d);
}
write_unlock(&d->event_lock);
-3
View File
@@ -185,9 +185,6 @@ extern struct pirq *pirq_get_info(struct domain *d, int pirq);
void pirq_cleanup_check(struct pirq *pirq, struct domain *d);
#define pirq_cleanup_check(pirq, d) \
(!(pirq)->evtchn ? pirq_cleanup_check(pirq, d) : (void)0)
extern void pirq_guest_eoi(struct pirq *pirq);
extern void desc_guest_eoi(struct irq_desc *desc, struct pirq *pirq);
extern int pirq_guest_unmask(struct domain *d);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.