From: Hui Min Mina Chou <minachou@andestech.com>
To: <pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<alex@ghiti.fr>, <linux-riscv@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: <tim609@andestech.com>, <ben717@andestech.com>,
<minachou@andestech.com>, <az70021@gmail.com>,
Charles Ci-Jyun Wu <dminus@andestech.com>
Subject: [PATCH] riscv: fpu: refine FPU save flow
Date: Thu, 5 Feb 2026 13:53:42 +0800 [thread overview]
Message-ID: <20260205055342.572379-1-minachou@andestech.com> (raw)
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
next reply other threads:[~2026-02-05 5:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 5:53 Hui Min Mina Chou [this message]
2026-02-09 8:34 ` Vivian Wang
2026-02-09 8:39 ` Vivian Wang
2026-02-24 7:11 ` Mina Chou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260205055342.572379-1-minachou@andestech.com \
--to=minachou@andestech.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=az70021@gmail.com \
--cc=ben717@andestech.com \
--cc=dminus@andestech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=tim609@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®