diff options
| author | Jari Sihvola <jsihv@gmx.com> | 2026-03-05 08:57:22 +0000 |
|---|---|---|
| committer | Ruslan Bukin <br@FreeBSD.org> | 2026-03-05 09:00:23 +0000 |
| commit | d3eaa40282c7734385d028b6a4fb9574d17255e3 (patch) | |
| tree | 51909b5e95583cc9870c8147909b97ef3a7fd387 | |
| parent | dff2758b5fa7d4987b03f3a04e1b02b367fe9b73 (diff) | |
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
| -rw-r--r-- | sys/riscv/riscv/vm_machdep.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |
