[PATCH v3] riscv: hwprobe: fix has_fpu() to require D extension only
Ivy Lopez <[email protected]>
| Newsgroups | org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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. sys_hwprobe.c already calls has_fpu() and needs no changes. Link: https://bugzilla.kernel.org/show_bug.cgi?id=221874 Suggested-by: Conor Dooley <[email protected]> Suggested-by: Andreas Schwab <[email protected]> Signed-off-by: Ivy Lopez <[email protected]> --- Changes in v3: - Drop the sys_hwprobe.c hunk entirely: it already calls has_fpu(), no change needed there since v1 was never merged. - This is a new thread per maintainer request, not a reply to v1/v2. arch/riscv/include/asm/switch_to.h | 4 ++-- 1 file changed, 2 insertions(+), 2 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; } -- 2.55.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv