The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=d3eaa40282c7734385d028b6a4fb9574d17255e3
commit d3eaa40282c7734385d028b6a4fb9574d17255e3 Author: Jari Sihvola <[email protected]> AuthorDate: 2026-03-05 08:57:22 +0000 Commit: Ruslan Bukin <[email protected]> CommitDate: 2026-03-05 09:00:23 +0000 riscv: save FPE state in cpu_fork(). Save the Floating Point Extension (FPE) state before copying struct pcb. Reviewed by: br Differential Revision: https://reviews.freebsd.org/D53804 --- sys/riscv/riscv/vm_machdep.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/riscv/riscv/vm_machdep.c b/sys/riscv/riscv/vm_machdep.c index e5a5cf31af15..e0254f80e62f 100644 --- a/sys/riscv/riscv/vm_machdep.c +++ b/sys/riscv/riscv/vm_machdep.c @@ -48,6 +48,7 @@ #include <machine/riscvreg.h> #include <machine/cpu.h> +#include <machine/fpe.h> #include <machine/cpufunc.h> #include <machine/pcb.h> #include <machine/frame.h> @@ -91,7 +92,13 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) if ((flags & RFPROC) == 0) return; - /* RISCVTODO: save the FPU state here */ + /* Ensure the floating-point state is saved before copying the pcb. */ + if ((td1->td_pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + MPASS(td1 == curthread); + critical_enter(); + fpe_state_save(td1); + critical_exit(); + } cpu_set_pcb_frame(td2);
