diff --git a/sys/riscv/riscv/vm_machdep.c b/sys/riscv/riscv/vm_machdep.c --- a/sys/riscv/riscv/vm_machdep.c +++ b/sys/riscv/riscv/vm_machdep.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -91,7 +92,12 @@ 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) { + critical_enter(); + fpe_state_save(td1); + critical_exit(); + } cpu_set_pcb_frame(td2);