Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD

Conor Dooley <[email protected]>
Newsgroups org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel
Message-ID <20260817-unmade-dyslexic-4bb4acf535af@wendy>
On Sat, Aug 15, 2026 at 06:32:16PM -0600, Ivy Lopez wrote:
> 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.

The kernel never supports F without D, so this cannot occur.
riscv_isa_extension_available(NULL, f) always returns false if D is not
also present.

If anything, the code in has_fpu() should be changed to only check D and
not F to match expectations elsewhere, or F and D for the same reason.

> 
> 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 <[email protected]>
> ---
>  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
>

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCaoMXSAAKCRB4tDGHoIJi
0r33AP9xvTpVhoNyjAY90W4COwASd1mqNfOe9G3m5dpok0xXnAEAvta/WYrgdiJS
ph9ufnFx3dNQEarmIui3TUPaJMjtEgs=
=JOkw
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.