All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-16  0:32 ` Ivy Lopez
  0 siblings, 0 replies; 10+ messages in thread
From: Ivy Lopez @ 2026-08-16  0:32 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: Alexandre Ghiti, Andrew Jones, linux-riscv, linux-kernel,
	Ivy Lopez

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-16  0:32 ` Ivy Lopez
  0 siblings, 0 replies; 10+ messages in thread
From: Ivy Lopez @ 2026-08-16  0:32 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: Alexandre Ghiti, Andrew Jones, linux-riscv, linux-kernel,
	Ivy Lopez

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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
  2026-08-16  0:32 ` Ivy Lopez
@ 2026-08-17 14:14   ` Conor Dooley
  -1 siblings, 0 replies; 10+ messages in thread
From: Conor Dooley @ 2026-08-17 14:14 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Jones, linux-riscv, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]

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 <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
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-17 14:14   ` Conor Dooley
  0 siblings, 0 replies; 10+ messages in thread
From: Conor Dooley @ 2026-08-17 14:14 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Jones, linux-riscv, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1781 bytes --]

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 <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
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
  2026-08-17 14:14   ` Conor Dooley
@ 2026-08-17 21:15     ` Ivy Lopez
  -1 siblings, 0 replies; 10+ messages in thread
From: Ivy Lopez @ 2026-08-17 21:15 UTC (permalink / raw)
  To: conor.dooley
  Cc: alex, andrew.jones, aou, linux-kernel, linux-riscv, palmer, pjw

On Mon, Aug 17, 2026 at 03:14:36PM +0100, Conor Dooley wrote:
> 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.

Ah ok, thanks for the clarification.. I hadn't realized F-without-D is
already structurally impossible here, so this patch doesn't change
actual behavior.

Would you prefer a v2 that fixes has_fpu() instead (checking D only,
or F && D, whichever matches the intended semantics elsewhere), or
would you rather I just drop this patch since RISCV_HWPROBE_IMA_FD already
behaves correctly in practice?

Happy to send whichever you'd find useful!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-17 21:15     ` Ivy Lopez
  0 siblings, 0 replies; 10+ messages in thread
From: Ivy Lopez @ 2026-08-17 21:15 UTC (permalink / raw)
  To: conor.dooley
  Cc: alex, andrew.jones, aou, linux-kernel, linux-riscv, palmer, pjw

On Mon, Aug 17, 2026 at 03:14:36PM +0100, Conor Dooley wrote:
> 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.

Ah ok, thanks for the clarification.. I hadn't realized F-without-D is
already structurally impossible here, so this patch doesn't change
actual behavior.

Would you prefer a v2 that fixes has_fpu() instead (checking D only,
or F && D, whichever matches the intended semantics elsewhere), or
would you rather I just drop this patch since RISCV_HWPROBE_IMA_FD already
behaves correctly in practice?

Happy to send whichever you'd find useful!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
  2026-08-17 21:15     ` Ivy Lopez
@ 2026-08-18  9:45       ` Conor Dooley
  -1 siblings, 0 replies; 10+ messages in thread
From: Conor Dooley @ 2026-08-18  9:45 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: conor.dooley, alex, andrew.jones, aou, linux-kernel, linux-riscv,
	palmer, pjw

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

On Mon, Aug 17, 2026 at 03:15:07PM -0600, Ivy Lopez wrote:
> On Mon, Aug 17, 2026 at 03:14:36PM +0100, Conor Dooley wrote:
> > 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.
> 
> Ah ok, thanks for the clarification.. I hadn't realized F-without-D is
> already structurally impossible here, so this patch doesn't change
> actual behavior.
> 
> Would you prefer a v2 that fixes has_fpu() instead (checking D only,
> or F && D, whichever matches the intended semantics elsewhere), or
> would you rather I just drop this patch since RISCV_HWPROBE_IMA_FD already
> behaves correctly in practice?
> 
> Happy to send whichever you'd find useful!

I think I would rather see has_fpu() get changed. I think checking
either D only (ideally with a comment explaining why that's correct to
do) or checking both are equally valid, which to do is up to you.

I don't think there's really any other equivalents to this has_fpu()
code because anything that would do it just calls has_fpu() instead!
The closest thing to it that I found is code in cpufeature.c that only
checks D (with comments), but that code is part of the wider extension
parsing logic that where the block on F without D happens in the first
place, so it may not be the best example.

In the future, when replying, please try to keep more than just one mail
of context, to make it easier for people to follow the conversation if
this is the only mail they read or if they forgot exactly what was going
on in the previous ones.

Cheers,
Conor.



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-18  9:45       ` Conor Dooley
  0 siblings, 0 replies; 10+ messages in thread
From: Conor Dooley @ 2026-08-18  9:45 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: conor.dooley, alex, andrew.jones, aou, linux-kernel, linux-riscv,
	palmer, pjw


[-- Attachment #1.1: Type: text/plain, Size: 1803 bytes --]

On Mon, Aug 17, 2026 at 03:15:07PM -0600, Ivy Lopez wrote:
> On Mon, Aug 17, 2026 at 03:14:36PM +0100, Conor Dooley wrote:
> > 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.
> 
> Ah ok, thanks for the clarification.. I hadn't realized F-without-D is
> already structurally impossible here, so this patch doesn't change
> actual behavior.
> 
> Would you prefer a v2 that fixes has_fpu() instead (checking D only,
> or F && D, whichever matches the intended semantics elsewhere), or
> would you rather I just drop this patch since RISCV_HWPROBE_IMA_FD already
> behaves correctly in practice?
> 
> Happy to send whichever you'd find useful!

I think I would rather see has_fpu() get changed. I think checking
either D only (ideally with a comment explaining why that's correct to
do) or checking both are equally valid, which to do is up to you.

I don't think there's really any other equivalents to this has_fpu()
code because anything that would do it just calls has_fpu() instead!
The closest thing to it that I found is code in cpufeature.c that only
checks D (with comments), but that code is part of the wider extension
parsing logic that where the block on F without D happens in the first
place, so it may not be the best example.

In the future, when replying, please try to keep more than just one mail
of context, to make it easier for people to follow the conversation if
this is the only mail they read or if they forgot exactly what was going
on in the previous ones.

Cheers,
Conor.



[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
  2026-08-17 21:15     ` Ivy Lopez
@ 2026-08-18 10:19       ` Andreas Schwab
  -1 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2026-08-18 10:19 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: conor.dooley, alex, andrew.jones, aou, linux-kernel, linux-riscv,
	palmer, pjw

On Aug 17 2026, Ivy Lopez wrote:

> Would you prefer a v2 that fixes has_fpu() instead (checking D only,
> or F && D, whichever matches the intended semantics elsewhere), or

The D extension depends on F.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD
@ 2026-08-18 10:19       ` Andreas Schwab
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2026-08-18 10:19 UTC (permalink / raw)
  To: Ivy Lopez
  Cc: conor.dooley, alex, andrew.jones, aou, linux-kernel, linux-riscv,
	palmer, pjw

On Aug 17 2026, Ivy Lopez wrote:

> Would you prefer a v2 that fixes has_fpu() instead (checking D only,
> or F && D, whichever matches the intended semantics elsewhere), or

The D extension depends on F.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-08-18 10:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16  0:32 [PATCH] riscv: hwprobe: require both F and D extensions for RISCV_HWPROBE_IMA_FD Ivy Lopez
2026-08-16  0:32 ` Ivy Lopez
2026-08-17 14:14 ` Conor Dooley
2026-08-17 14:14   ` Conor Dooley
2026-08-17 21:15   ` Ivy Lopez
2026-08-17 21:15     ` Ivy Lopez
2026-08-18  9:45     ` Conor Dooley
2026-08-18  9:45       ` Conor Dooley
2026-08-18 10:19     ` Andreas Schwab
2026-08-18 10:19       ` Andreas Schwab

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.