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
This commit is contained in:
Jari Sihvola
2026-03-05 08:57:22 +00:00
committed by Ruslan Bukin
parent dff2758b5f
commit d3eaa40282
+8 -1
View File
@@ -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);