From: sashiko-bot@kernel.org
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v6 3/6] riscv: accept the atomic extensions this kernel was built with
Date: Tue, 10 Nov 2026 13:51:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-207157@kernel.org> (raw)
In-Reply-To: <20261110-lrsc-only-v6-3-bafc3cc0fcae@mobileye.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] riscv: hwprobe_one_pair() falsely reports IMA base on
zalrsc-only harts
--
commit 28e749f3a8a1535f66a4515b72ef2377c9c49282
Author: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
riscv: accept the atomic extensions this kernel was built with
This commit updates riscv_early_of_processor_hartid() to accept harts
whose riscv,isa-extensions property lists "zalrsc" (and "zaamo" when
CONFIG_RISCV_ISA_ZAAMO is enabled) instead of "a".
> diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
> index 3dbc8cc557dd1..9ba0d49c87bc3 100644
> --- a/arch/riscv/kernel/cpu.c
> +++ b/arch/riscv/kernel/cpu.c
> @@ -82,12 +82,29 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo
> return -ENODEV;
>
> if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
> - of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
> - of_property_match_string(node, "riscv,isa-extensions", "a") < 0) {
> - pr_warn("CPU with hartid=%lu does not support ima", *hart);
> + of_property_match_string(node, "riscv,isa-extensions", "m") < 0) {
> + pr_warn("CPU with hartid=%lu does not support im", *hart);
> return -ENODEV;
> }
>
> + /*
> + * Require the atomic extensions this kernel was built with. "a"
> + * covers both; otherwise LR/SC is always needed and AMO is needed
> + * when the kernel uses it.
> + */
> + if (of_property_match_string(node, "riscv,isa-extensions", "a") < 0) {
> + if (of_property_match_string(node, "riscv,isa-extensions", "zalrsc") < 0) {
> + pr_warn("CPU with hartid=%lu does not support zalrsc", *hart);
> + return -ENODEV;
> + }
> +
> + if (IS_ENABLED(CONFIG_RISCV_ISA_ZAAMO) &&
> + of_property_match_string(node, "riscv,isa-extensions", "zaamo") < 0) {
> + pr_warn("CPU with hartid=%lu does not support zaamo", *hart);
> + return -ENODEV;
> + }
> + }
[Severity: Medium]
As reported by Conor Dooley on v4 [1], when CONFIG_RISCV_ISA_ZAAMO is
disabled and a hart boots with only "zalrsc" (without "a" or "zaamo"),
does hwprobe_one_pair() still report RISCV_HWPROBE_BASE_BEHAVIOR_IMA for
RISCV_HWPROBE_KEY_BASE_BEHAVIOR?
arch/riscv/kernel/sys_hwprobe.c:hwprobe_one_pair() {
...
case RISCV_HWPROBE_KEY_BASE_BEHAVIOR:
pair->value = RISCV_HWPROBE_BASE_BEHAVIOR_IMA;
break;
...
}
RISCV_HWPROBE_BASE_BEHAVIOR_IMA advertises full rv32ima or rv64ima
support, including Zaamo AMO instructions, so userspace querying hwprobe
on a zalrsc-only hart will be told that AMO instructions are supported and
can fault with SIGILL when executing them.
[1] https://lore.kernel.org/r/20261103-pushcart-very-04a34d0ffb0e@spud
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110-lrsc-only-v6-0-bafc3cc0fcae@mobileye.com?part=3
next prev parent reply other threads:[~2026-11-10 13:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:20 [PATCH v6 0/6] riscv: restrict the ISA used for atomics to avoid unsupported or slow AMO Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 13:20 ` [PATCH v6 1/6] riscv: probes: reject probes inside an LR/SC sequence Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 13:20 ` [PATCH v6 2/6] riscv: build kernel atomics from LR/SC when Zaamo is disabled Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 19:02 ` Conor Dooley
2026-11-10 19:02 ` Conor Dooley
2026-11-11 4:18 ` Jisheng Zhang
2026-11-11 4:18 ` Jisheng Zhang
2026-11-11 6:37 ` Vladimir Kondratiev
2026-11-11 6:37 ` Vladimir Kondratiev
2026-11-10 13:21 ` [PATCH v6 3/6] riscv: accept the atomic extensions this kernel was built with Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 13:51 ` sashiko-bot [this message]
2026-11-10 13:21 ` [PATCH v6 4/6] riscv: report the A extension when Zaamo and Zalrsc are both present Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 13:21 ` [PATCH v6 5/6] riscv, bpf: emit LR/SC loops when Zaamo is disabled Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 14:00 ` sashiko-bot
2026-11-10 13:21 ` [PATCH v6 6/6] riscv: hwprobe: report whether AMO is faster than LR/SC Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 14:04 ` sashiko-bot
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-207157@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=gary@garyguo.net \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--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 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.