From: Conor Dooley <conor@kernel.org>
To: Ivy Lopez <skunkolee@gmail.com>
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, andrew.jones@oss.qualcomm.com,
conor.dooley@microchip.com, schwab@suse.de,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] riscv: hwprobe: fix has_fpu() to require D extension only
Date: Tue, 25 Aug 2026 18:11:49 +0100 [thread overview]
Message-ID: <20260825-essay-flashily-8df1f3d9a615@spud> (raw)
In-Reply-To: <20260825142034.31230-1-skunkolee@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2888 bytes --]
On Tue, Aug 25, 2026 at 08:20:34AM -0600, Ivy Lopez wrote:
> The kernel never supports F without D, since D depends on F. As such,
> has_fpu() checking either extension with '||' is incorrect: it
> reports FPU support when only F is present, which is not sufficient
> for D-dependent state save/restore, and weakens
> RISCV_HWPROBE_IMA_FD semantics to "F or D" instead of "F and D".
>
> Fix has_fpu() to check D only, which is equivalent to requiring both
> extensions given the dependency. Revert the explicit F && D check in
> sys_hwprobe.c back to calling has_fpu(), which is now correct.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=221874
> Suggested-by: Conor Dooley <conor.dooley@microchip.com>
> Suggested-by: Andreas Schwab <schwab@suse.de>
> Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
> ---
> Changes in v2:
> - Original v1 approach (explicit F && D check in sys_hwprobe.c) was a
> no-op since F-without-D is structurally impossible. Per Conor and
> Andreas, fix has_fpu() itself instead, checking D only. Revert the
> sys_hwprobe.c change back to calling has_fpu().
> - Link to v1: https://lore.kernel.org/r/20260816003216.22534-1-skunkolee@gmail.com
This v2 looks like a diff on top of your v1, but your v1 didn't get
applied (AFAIK) so this patch doesn't make sense.
> arch/riscv/include/asm/switch_to.h | 4 ++--
> arch/riscv/kernel/sys_hwprobe.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h
> index 0e71eb82f920..8186cda88e17 100644
> --- a/arch/riscv/include/asm/switch_to.h
> +++ b/arch/riscv/include/asm/switch_to.h
> @@ -60,8 +60,8 @@ static inline void __switch_to_fpu(struct task_struct *prev,
>
> static __always_inline bool has_fpu(void)
> {
> - return riscv_has_extension_likely(RISCV_ISA_EXT_f) ||
> - riscv_has_extension_likely(RISCV_ISA_EXT_d);
> + /* D extension depends on F, so checking D alone is sufficient. */
> + return riscv_has_extension_likely(RISCV_ISA_EXT_d);
> }
> #else
> static __always_inline bool has_fpu(void) { return false; }
> diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
> index 7f91beb82a1c..1659d31fd288 100644
> --- a/arch/riscv/kernel/sys_hwprobe.c
> +++ b/arch/riscv/kernel/sys_hwprobe.c
> @@ -85,7 +85,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
> u64 missing = 0;
>
> pair->value = 0;
> - if (riscv_isa_extension_available(NULL, f) && riscv_isa_extension_available(NULL, d))
> + if (has_fpu())
> pair->value |= RISCV_HWPROBE_IMA_FD;
>
> if (riscv_isa_extension_available(NULL, c))
This second portion should be dropped, since it is a reversion to how
things were before.
Additionally, please don't submit new versions as a reply to old ones.
Thanks,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-08-25 17:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 0:32 [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD Ivy Lopez
2026-08-17 14:14 ` Conor Dooley
2026-08-17 21:15 ` Ivy Lopez
2026-08-18 9:45 ` Conor Dooley
2026-08-18 10:19 ` Andreas Schwab
2026-08-25 14:20 ` [PATCH v2] riscv: hwprobe: fix has_fpu() to require D extension only Ivy Lopez
2026-08-25 17:11 ` Conor Dooley [this message]
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=20260825-essay-flashily-8df1f3d9a615@spud \
--to=conor@kernel.org \
--cc=alex@ghiti.fr \
--cc=andrew.jones@oss.qualcomm.com \
--cc=aou@eecs.berkeley.edu \
--cc=conor.dooley@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=schwab@suse.de \
--cc=skunkolee@gmail.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