The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ivy Lopez <skunkolee@gmail.com>
To: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>,
	Andrew Jones <andrew.jones@oss.qualcomm.com>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	Ivy Lopez <skunkolee@gmail.com>
Subject: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
Date: Sat, 15 Aug 2026 18:32:16 -0600	[thread overview]
Message-ID: <20260816003216.22534-1-skunkolee@gmail.com> (raw)

Documentation/arch/riscv/hwprobe.rst states that RISCV_HWPROBE_IMA_FD
means both the F and D extensions are supported. However, the
implementation uses has_fpu(), which returns true if either extension
is present, since that's sufficient to determine whether FPU state
needs to be saved/restored. Reusing it here silently weakens the
hwprobe semantics from "F and D" to "F or D", giving userspace no way
to know which extension is actually present when only one is.

Check both extensions explicitly with riscv_isa_extension_available(),
matching the pattern already used for the neighboring C and V checks.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221874
Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
 arch/riscv/kernel/sys_hwprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index 1659d31fd288..7f91beb82a1c 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 (has_fpu())
+	if (riscv_isa_extension_available(NULL, f) && riscv_isa_extension_available(NULL, d))
 		pair->value |= RISCV_HWPROBE_IMA_FD;
 
 	if (riscv_isa_extension_available(NULL, c))
-- 
2.55.0


                 reply	other threads:[~2026-08-16  0:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260816003216.22534-1-skunkolee@gmail.com \
    --to=skunkolee@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=andrew.jones@oss.qualcomm.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox