From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796033481; b=fFyas9hlq7eo3vjZcxCsCldSgZiQvVzVGZ7PvWDTuZOZp4LEcG5qpxbMaO5jOl1QSWI3 jrVxvI7imd23CL16FG4r/qvHjdK6EPWpStPkP66Jew1rZ4yc/+UygldcLMryNpxKfUSrm doC2U8NxGB+VYKG4vTP1yCCQ1bA73vcwUUJQEWGgPVADTQfhOIDt6Xj9U166+E1BXXo/Y salE7e1LpApctxPmLxEIveceEOr/YBmAGg+RW64jtwOxjhGu2DpXCQogQxB02C5qmpWBe KUMAKde2u35n7R2DorCPL3yT36egMPplwhHBd0LA7NvsqeBer52zjFT0r45JPez0DcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796033481; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=NqUMiKer1SzzCPgeGuTrDrX0ecMC8hw9CRFsou8LB+g=; b=JcOm4t20mfWO8BBfGDFDSEjryEKh0WJWBb3/9iuhPL9DmBWaJZRw4n37pc1lrFOKG8Y5 lLRpB8I4x1C94B/twsvU1tuwmV09z9RXYsBJWPpwFET/QhbmqbKhOzP7g85n8u/FDHMtW 45gaXkfnvKNCiZKC6JNkT+QTY0TXX11z6vKJcbKTDytZtNlEG6+02Kpp4we5i2gH8/P+y xLu4PUfn5Gp0nmE1uLrRj7mj1iZCrOiUW5WCbeClvumZvXgfEdNddjjIVv/GBE9DsJOOR /mu9isV69helQZmDAbMP3HHWXKp50iOkKSAacZnTJfsRvsCFdn/sVSs41CSr8349hHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KT1S2381; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 269F6606A31C for ; Mon, 30 Nov 2026 10:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KT1S2381 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5C051F00899; Mon, 30 Nov 2026 10:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796033480; bh=NqUMiKer1SzzCPgeGuTrDrX0ecMC8hw9CRFsou8LB+g=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=KT1S2381ACjxGGNY7vJ5c35LNF7h04zRPx5oWRD5H01+dVxJwlDsiBT9Y2fPsCcYT KRGcvaws4xBxQlHfV2raZqsb/aef7te7nP6udic750geSuVfsuRFFkDrzDWnWTyU3h A+pFN3V8Oo4QuRZ+rJOyYHH0oBkNm44RH87f4ZG92LeZun0ZX/374Rhzk5O4+9b/2n elI9a8jJjt64tOQUDH8HTgu/da0D/o9XY8QOzo/dVaWsu8UBmdc1j3CiqIxc4fiF26 pyjc0svpx+hqsATFuctpXvpcM4NIVfb/iyKHmEwbE4XgKj9ZNkqhPlPHRzIBsA/t56 UWCr5Mak4pCBA== From: Thomas Gleixner To: Nickolai Zeldovich Cc: Radu Rendec , Anup Patel , linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] genirq/msi: Fix the mapping race of wire to MSI interrupts In-Reply-To: References: <20261017025420.792976-1-nickolai@csail.mit.edu> <87jymmuj2l.ffs@fw13> Date: Mon, 30 Nov 2026 11:11:16 +0100 Message-ID: <87jylur5mj.ffs@fw13> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Nov 16 2026 at 08:49, Nickolai Zeldovich wrote: > On Mon, Nov 9, 2026 at 10:21=E2=80=AFAM Thomas Gleixner = 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 =20 +static int irq_validate_trigger(int virq. unsigned int type) +{ + if (type =3D=3D IRQ_TYPE_NONE) + return virq; + + /* Protect against concurrent modifications */ + scoped_irqdesc_get_and_lock(irq, 0) { + struct irq_data *d =3D 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 =3D IRQ_TYPE_NONE; struct irq_domain *domain; - struct irq_data *irq_data; irq_hw_number_t hwirq; int virq; =20 @@ -944,32 +957,7 @@ unsigned int irq_create_fwspec_mapping(s */ virq =3D 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 =3D=3D IRQ_TYPE_NONE || type =3D=3D 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) =3D=3D IRQ_TYPE_NONE) { - irq_data =3D irq_get_irq_data(virq); - if (!irq_data) { - virq =3D 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 =3D 0; + virq =3D irq_validate_trigger(virq, type); goto out; } =20