Re: [PATCH v1] genirq/msi: Fix the mapping race of wire to MSI interrupts
From: Thomas Gleixner
Date: Mon Nov 30 2026 - 05:11:24 EST
On Mon, Nov 16 2026 at 08:49, Nickolai Zeldovich wrote:
> On Mon, Nov 9, 2026 at 10:21 AM Thomas Gleixner <tglx@xxxxxxxxxx> wrote:
>> Something like the uncompiled below is less intrusive and avoids the
>> subtle breakage.
>
> Thank you, your version looks better than what I was proposing. I'm
> happy for you to take over this fix (your patch works and passes my
> testing against v7.4-rc3), if that's easier for you.
Nah. Just make it a proper patch and add "Suggested-by: tglx...".
> Also, in the same function, there are two other potential races. Let
> me know if these seem important enough to fix, and if it's useful for
> me to send a patch for them or if you want to take them over as well.
...
> One fix would be to do these checks and stores under desc->lock.
Correct. Below is a skeleton to start with.
Thanks,
tglx
---
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -911,11 +911,24 @@ int irq_populate_fwspec_info(struct irq_
}
#endif
+static int irq_validate_trigger(int virq. unsigned int type)
+{
+ if (type == IRQ_TYPE_NONE)
+ return virq;
+
+ /* Protect against concurrent modifications */
+ scoped_irqdesc_get_and_lock(irq, 0) {
+ struct irq_data *d = irq_desc_get_irq_data(scoped_irqdesc);
+
+ // Do the checks based on @d. Return virq on success
+ // 0 on fail.
+ }
+}
+
unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)
{
unsigned int type = IRQ_TYPE_NONE;
struct irq_domain *domain;
- struct irq_data *irq_data;
irq_hw_number_t hwirq;
int virq;
@@ -944,32 +957,7 @@ unsigned int irq_create_fwspec_mapping(s
*/
virq = irq_find_mapping(domain, hwirq);
if (virq) {
- /*
- * If the trigger type is not specified or matches the
- * current trigger type then we are done so return the
- * interrupt number.
- */
- if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq))
- goto out;
-
- /*
- * If the trigger type has not been set yet, then set
- * it now and return the interrupt number.
- */
- if (irq_get_trigger_type(virq) == IRQ_TYPE_NONE) {
- irq_data = irq_get_irq_data(virq);
- if (!irq_data) {
- virq = 0;
- goto out;
- }
-
- irqd_set_trigger_type(irq_data, type);
- goto out;
- }
-
- pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n",
- hwirq, of_node_full_name(to_of_node(fwspec->fwnode)));
- virq = 0;
+ virq = irq_validate_trigger(virq, type);
goto out;
}