mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] riscv: fpu: refine FPU save flow
@ 2026-02-05  5:53 Hui Min Mina Chou
  2026-02-09  8:34 ` Vivian Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Hui Min Mina Chou @ 2026-02-05  5:53 UTC (permalink / raw)
  To: pjw, palmer, aou, alex, linux-riscv, linux-kernel
  Cc: tim609, ben717, minachou, az70021, Charles Ci-Jyun Wu

From: Charles Ci-Jyun Wu <dminus@andestech.com>

When Kernel first time run to arch_dup_task_struct(),
it will check if sstatus.FS is dirty. If it is dirty,
then it will do FPU save flow. But this field is
floating currently. Meanwhile if the combination between
platform(HW) and Kernel(SW) about FPU configuration
is mismatch. eq: The platform is without FPU and Kernel
is with FPU. Then Kernel may trigger illegal instruction
here.

Hence it shall check by has_fpu before do FPU save flow
in arch_dup_task_struct().

Signed-off-by: Rick Chen <rick@andestech.com>
Signed-off-by: Charles Ci-Jyun Wu <dminus@andestech.com>
---
 arch/riscv/kernel/process.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 31a392993cb4..a27c21c7d9c6 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -199,7 +199,8 @@ void arch_release_task_struct(struct task_struct *tsk)
 
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
-	fstate_save(src, task_pt_regs(src));
+	if (has_fpu())
+		fstate_save(src, task_pt_regs(src));
 	*dst = *src;
 	/* clear entire V context, including datap for a new task */
 	memset(&dst->thread.vstate, 0, sizeof(struct __riscv_v_ext_state));
-- 
2.34.1


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

end of thread, other threads:[~2026-02-24  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05  5:53 [PATCH] riscv: fpu: refine FPU save flow Hui Min Mina Chou
2026-02-09  8:34 ` Vivian Wang
2026-02-09  8:39   ` Vivian Wang
2026-02-24  7:11     ` Mina Chou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®