Skip to content

Commit 4fc20d0

Browse files
CharlesWu465Rick Chen
authored andcommitted
riscv: fpu: refine FPU save flow (torvalds#207)
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> Co-authored-by: Rick Chen <rick@andestech.com> Reviewed-on: https://gitea.andestech.com/RD-SW/linux/pulls/207 Reviewed-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
1 parent 1bfdc14 commit 4fc20d0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/kernel/process.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ void arch_release_task_struct(struct task_struct *tsk)
199199

200200
int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
201201
{
202-
fstate_save(src, task_pt_regs(src));
202+
if (has_fpu())
203+
fstate_save(src, task_pt_regs(src));
203204
*dst = *src;
204205
/* clear entire V context, including datap for a new task */
205206
memset(&dst->thread.vstate, 0, sizeof(struct __riscv_v_ext_state));

0 commit comments

Comments
 (0)