From: sashiko-bot@kernel.org
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v2] irqchip/riscv-aplic: fix asynchronous probing
Date: Mon, 12 Oct 2026 08:41:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-167856@kernel.org> (raw)
In-Reply-To: <20261012-aplic-async-probe-v2-1-868d7684c9d6@mobileye.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] irqchip/riscv-aplic: panic on writing __ro_after_init atomic variable during late probe
--
commit 85f19d2af252a4bd94c9b2ae22ff4a1c3d7ce27f
Author: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
irqchip/riscv-aplic: fix asynchronous probing
This commit replaces the boolean flag with an atomic counter to prevent a
double-add race condition when probing multiple APLIC instances
asynchronously.
Link: https://lore.kernel.org/r/20261012-aplic-async-probe-v1-1-4c2c4f5b0916@mobileye.com
> diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
> --- a/drivers/irqchip/irq-riscv-aplic-main.c
> +++ b/drivers/irqchip/irq-riscv-aplic-main.c
> @@ -116,14 +116,12 @@ static struct syscore aplic_syscore = {
> .ops = &aplic_syscore_ops,
> };
>
> -static bool aplic_syscore_registered __ro_after_init;
> +static atomic_t aplic_syscore_registered __ro_after_init = ATOMIC_INIT(0);
>
> static void aplic_syscore_init(void)
> {
> - if (!aplic_syscore_registered) {
> + if (!atomic_cmpxchg(&aplic_syscore_registered, 0, 1))
[Severity: High]
Will this trigger a fatal page fault if the probe is deferred?
The aplic_syscore_registered variable retains the __ro_after_init attribute,
which places it in a memory section that becomes strictly read-only after
the kernel initialization phase completes.
Platform driver probes can be deferred (for instance, waiting for an MSI
domain) and run in a workqueue after the init phase is done.
If a late probe calls aplic_syscore_init(), atomic_cmpxchg() will attempt
to write 1 to this read-only memory page, which causes a store fault (or
AMO fault on RISC-V).
Does the __ro_after_init attribute need to be removed here to safely
support late and deferred probing?
> register_syscore(&aplic_syscore);
> - aplic_syscore_registered = true;
> - }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-aplic-async-probe-v2-1-868d7684c9d6@mobileye.com?part=1
next prev parent reply other threads:[~2026-10-12 8:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 8:33 Vladimir Kondratiev
2026-10-12 8:41 ` sashiko-bot [this message]
2026-10-12 9:05 ` Vladimir Kondratiev
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=sashiko-outbox-167856@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vladimir.kondratiev@mobileye.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®