From: Marc Zyngier <maz@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Johan Hovold <johan+linaro@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, platform-driver-x86@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org, Hsin-Yi Wang <hsinyi@chromium.org>,
Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Subject: Re: [PATCH v5 19/19] irqdomain: Switch to per-domain locking
Date: Sat, 11 Feb 2023 12:52:23 +0000 [thread overview]
Message-ID: <867cwoz7nc.wl-maz@kernel.org> (raw)
In-Reply-To: <Y+d9hM2yaBV1Tr2o@hovoldconsulting.com>
AOn Sat, 11 Feb 2023 11:35:32 +0000,
Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Feb 10, 2023 at 03:06:37PM +0000, Marc Zyngier wrote:
> > On Fri, 10 Feb 2023 12:57:40 +0000,
> > Johan Hovold <johan@kernel.org> wrote:
> > >
> > > On Fri, Feb 10, 2023 at 11:38:58AM +0000, Marc Zyngier wrote:
> > > > On Fri, 10 Feb 2023 09:56:03 +0000,
> > > > Johan Hovold <johan@kernel.org> wrote:
>
> > > > > > > @@ -1132,6 +1147,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
> > > > > > > else
> > > > > > > domain = irq_domain_create_tree(fwnode, ops, host_data);
> > > > > > > if (domain) {
> > > > > > > + domain->root = parent->root;
> > > > > > > domain->parent = parent;
> > > > > > > domain->flags |= flags;
> > > > > >
> > > > > > So we still have a bug here, as we have published a domain that we
> > > > > > keep updating. A parallel probing could find it in the interval and do
> > > > > > something completely wrong.
> > > > >
> > > > > Indeed we do, even if device links should make this harder to hit these
> > > > > days.
> > > > >
> > > > > > Splitting the work would help, as per the following patch.
> > > > >
> > > > > Looks good to me. Do you want to submit that as a patch that I'll rebase
> > > > > on or should I submit it as part of a v6?
> > > >
> > > > Just take it directly.
> > >
> > > Ok, thanks.
>
> I've added a commit message and turned it into a patch to include in v6
> now:
>
> commit 3af395aa894c7df94ef2337e572e5e1710b4bbda (HEAD -> work)
> Author: Marc Zyngier <maz@kernel.org>
> Date: Thu Feb 9 16:00:55 2023 +0000
>
> irqdomain: Fix domain registration race
>
> Hierarchical domains created using irq_domain_create_hierarchy() are
> currently added to the domain list before having been fully initialised.
>
> This specifically means that a racing allocation request might fail to
> allocate irq data for the inner domains of a hierarchy in case the
> parent domain pointer has not yet been set up.
>
> Note that this is not really any issue for irqchip drivers that are
> registered early via IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE(), but
> could potentially cause trouble with drivers that are registered later
> (e.g. when using IRQCHIP_PLATFORM_DRIVER_BEGIN(), gpiochip drivers,
> etc.).
>
> Fixes: afb7da83b9f4 ("irqdomain: Introduce helper function irq_domain_add_hierarchy()")
> Cc: stable@vger.kernel.org # 3.19
> ...
> [ johan: add a commit message ]
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
>
> Could you just give your SoB for the diff here so I can credit you as
> author?
Thanks for that. Feel free to add:
Signed-off-by: Marc Zyngier <maz@kernel.org>
>
> > > I guess this turns the "Use irq_domain_create_hierarchy()" patches into
> > > fixes that should be backported as well.
> >
> > Maybe. Backports are not my immediate concern.
>
> Turns out all of those drivers are registered early via
> IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE() so there shouldn't really be
> any risk of hitting this race for those.
>
> > > But note that your proposed diff may not be sufficient to prevent
> > > lookups from racing with domain registration generally. Many drivers
> > > still update the bus token after the domain has been added (and
> > > apparently some still set flags also after creating hierarchies I just
> > > noticed, e.g. amd_iommu_create_irq_domain).
> >
> > The bus token should only rarely be a problem, as it is often set on
> > an intermediate level which isn't directly looked-up by anything else.
> > And if it did happen, it would probably result in a the domain not
> > being found.
> >
> > Flags, on the other hand, are more problematic. But I consider this a
> > driver bug which should be fixed independently.
>
> I agree.
>
> > > It seems we'd need to expose a separate allocation and registration
> > > interface, or at least pass in the bus token to a new combined
> > > interface.
> >
> > Potentially, yes. But this could come later down the line. I'm more
> > concerned in getting this series into -next, as the merge window is
> > fast approaching.
>
> I'll post a v6 first thing Monday if you can give me that SoB before
> then.
You should be all set. Please post the series at your earliest
convenience, and I'll let i simmer in -next for a bit.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Johan Hovold <johan+linaro@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, platform-driver-x86@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org, Hsin-Yi Wang <hsinyi@chromium.org>,
Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Subject: Re: [PATCH v5 19/19] irqdomain: Switch to per-domain locking
Date: Sat, 11 Feb 2023 12:52:23 +0000 [thread overview]
Message-ID: <867cwoz7nc.wl-maz@kernel.org> (raw)
In-Reply-To: <Y+d9hM2yaBV1Tr2o@hovoldconsulting.com>
AOn Sat, 11 Feb 2023 11:35:32 +0000,
Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Feb 10, 2023 at 03:06:37PM +0000, Marc Zyngier wrote:
> > On Fri, 10 Feb 2023 12:57:40 +0000,
> > Johan Hovold <johan@kernel.org> wrote:
> > >
> > > On Fri, Feb 10, 2023 at 11:38:58AM +0000, Marc Zyngier wrote:
> > > > On Fri, 10 Feb 2023 09:56:03 +0000,
> > > > Johan Hovold <johan@kernel.org> wrote:
>
> > > > > > > @@ -1132,6 +1147,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent,
> > > > > > > else
> > > > > > > domain = irq_domain_create_tree(fwnode, ops, host_data);
> > > > > > > if (domain) {
> > > > > > > + domain->root = parent->root;
> > > > > > > domain->parent = parent;
> > > > > > > domain->flags |= flags;
> > > > > >
> > > > > > So we still have a bug here, as we have published a domain that we
> > > > > > keep updating. A parallel probing could find it in the interval and do
> > > > > > something completely wrong.
> > > > >
> > > > > Indeed we do, even if device links should make this harder to hit these
> > > > > days.
> > > > >
> > > > > > Splitting the work would help, as per the following patch.
> > > > >
> > > > > Looks good to me. Do you want to submit that as a patch that I'll rebase
> > > > > on or should I submit it as part of a v6?
> > > >
> > > > Just take it directly.
> > >
> > > Ok, thanks.
>
> I've added a commit message and turned it into a patch to include in v6
> now:
>
> commit 3af395aa894c7df94ef2337e572e5e1710b4bbda (HEAD -> work)
> Author: Marc Zyngier <maz@kernel.org>
> Date: Thu Feb 9 16:00:55 2023 +0000
>
> irqdomain: Fix domain registration race
>
> Hierarchical domains created using irq_domain_create_hierarchy() are
> currently added to the domain list before having been fully initialised.
>
> This specifically means that a racing allocation request might fail to
> allocate irq data for the inner domains of a hierarchy in case the
> parent domain pointer has not yet been set up.
>
> Note that this is not really any issue for irqchip drivers that are
> registered early via IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE(), but
> could potentially cause trouble with drivers that are registered later
> (e.g. when using IRQCHIP_PLATFORM_DRIVER_BEGIN(), gpiochip drivers,
> etc.).
>
> Fixes: afb7da83b9f4 ("irqdomain: Introduce helper function irq_domain_add_hierarchy()")
> Cc: stable@vger.kernel.org # 3.19
> ...
> [ johan: add a commit message ]
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
>
> Could you just give your SoB for the diff here so I can credit you as
> author?
Thanks for that. Feel free to add:
Signed-off-by: Marc Zyngier <maz@kernel.org>
>
> > > I guess this turns the "Use irq_domain_create_hierarchy()" patches into
> > > fixes that should be backported as well.
> >
> > Maybe. Backports are not my immediate concern.
>
> Turns out all of those drivers are registered early via
> IRQCHIP_DECLARE() or IRQCHIP_ACPI_DECLARE() so there shouldn't really be
> any risk of hitting this race for those.
>
> > > But note that your proposed diff may not be sufficient to prevent
> > > lookups from racing with domain registration generally. Many drivers
> > > still update the bus token after the domain has been added (and
> > > apparently some still set flags also after creating hierarchies I just
> > > noticed, e.g. amd_iommu_create_irq_domain).
> >
> > The bus token should only rarely be a problem, as it is often set on
> > an intermediate level which isn't directly looked-up by anything else.
> > And if it did happen, it would probably result in a the domain not
> > being found.
> >
> > Flags, on the other hand, are more problematic. But I consider this a
> > driver bug which should be fixed independently.
>
> I agree.
>
> > > It seems we'd need to expose a separate allocation and registration
> > > interface, or at least pass in the bus token to a new combined
> > > interface.
> >
> > Potentially, yes. But this could come later down the line. I'm more
> > concerned in getting this series into -next, as the merge window is
> > fast approaching.
>
> I'll post a v6 first thing Monday if you can give me that SoB before
> then.
You should be all set. Please post the series at your earliest
convenience, and I'll let i simmer in -next for a bit.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-11 12:52 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 13:23 [PATCH v5 00/19] irqdomain: fix mapping race and clean up locking Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 01/19] irqdomain: Fix association race Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 02/19] irqdomain: Fix disassociation race Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 03/19] irqdomain: Drop bogus fwspec-mapping error handling Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 04/19] irqdomain: Look for existing mapping only once Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 05/19] irqdomain: Refactor __irq_domain_alloc_irqs() Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 06/19] irqdomain: Fix mapping-creation race Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 14:03 ` Marc Zyngier
2023-02-09 14:03 ` Marc Zyngier
2023-02-10 9:10 ` Johan Hovold
2023-02-10 9:10 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 07/19] irqdomain: Drop revmap mutex Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 08/19] irqdomain: Drop dead domain-name assignment Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 09/19] irqdomain: Drop leftover brackets Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 11/19] x86/ioapic: Use irq_domain_create_hierarchy() Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 12/19] x86/apic: " Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 13/19] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 14/19] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 15/19] irqchip/gic-v3-its: " Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 16/19] irqchip/gic-v3-mbi: " Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 17/19] irqchip/loongson-pch-msi: " Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 18/19] irqchip/mvebu-odmi: " Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 13:23 ` [PATCH v5 19/19] irqdomain: Switch to per-domain locking Johan Hovold
2023-02-09 13:23 ` Johan Hovold
2023-02-09 16:00 ` Marc Zyngier
2023-02-09 16:00 ` Marc Zyngier
2023-02-10 9:56 ` Johan Hovold
2023-02-10 9:56 ` Johan Hovold
2023-02-10 11:38 ` Marc Zyngier
2023-02-10 11:38 ` Marc Zyngier
2023-02-10 12:57 ` Johan Hovold
2023-02-10 12:57 ` Johan Hovold
2023-02-10 15:06 ` Marc Zyngier
2023-02-10 15:06 ` Marc Zyngier
2023-02-11 11:35 ` Johan Hovold
2023-02-11 11:35 ` Johan Hovold
2023-02-11 12:52 ` Marc Zyngier [this message]
2023-02-11 12:52 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=867cwoz7nc.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=hsinyi@chromium.org \
--cc=johan+linaro@kernel.org \
--cc=johan@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=mark-pk.tsai@mediatek.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.