diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -270,9 +270,7 @@ /* Store the VFP registers */ #ifdef VFP mov x28, lr - mov x1, x0 /* move pcb to the correct register */ - mov x0, xzr /* td = NULL */ - bl vfp_save_state + bl vfp_save_state_savectx mov lr, x28 #endif diff --git a/sys/arm64/arm64/vfp.c b/sys/arm64/arm64/vfp.c --- a/sys/arm64/arm64/vfp.c +++ b/sys/arm64/arm64/vfp.c @@ -166,25 +166,11 @@ : : "r"(fpcr), "r"(fpsr), "r"(vfp_state)); } -void -vfp_save_state(struct thread *td, struct pcb *pcb) +static void +vfp_save_state_common(struct thread *td, struct pcb *pcb) { uint32_t cpacr; - KASSERT(pcb != NULL, ("NULL vfp pcb")); - KASSERT(td == NULL || td->td_pcb == pcb, ("Invalid vfp pcb")); - - /* - * savectx() will be called on panic with dumppcb as an argument, - * dumppcb doesn't have pcb_fpusaved set, so set it to save - * the VFP registers. - */ - if (pcb->pcb_fpusaved == NULL) - pcb->pcb_fpusaved = &pcb->pcb_fpustate; - - if (td == NULL) - td = curthread; - critical_enter(); /* * Only store the registers if the VFP is enabled, @@ -202,6 +188,30 @@ critical_exit(); } +void +vfp_save_state(struct thread *td, struct pcb *pcb) +{ + KASSERT(td != NULL, ("NULL vfp thread")); + KASSERT(pcb != NULL, ("NULL vfp pcb")); + KASSERT(td->td_pcb == pcb, ("Invalid vfp pcb")); + + vfp_save_state_common(td, pcb); +} + +void +vfp_save_state_savectx(struct pcb *pcb) +{ + /* + * savectx() will be called on panic with dumppcb as an argument, + * dumppcb doesn't have pcb_fpusaved set, so set it to save + * the VFP registers. + */ + MPASS(pcb->pcb_fpusaved == NULL); + pcb->pcb_fpusaved = &pcb->pcb_fpustate; + + vfp_save_state_common(curthread, pcb); +} + /* * Update the VFP state for a forked process or new thread. The PCB will * have been copied from the old thread. diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h --- a/sys/arm64/include/vfp.h +++ b/sys/arm64/include/vfp.h @@ -78,6 +78,7 @@ void vfp_reset_state(struct thread *, struct pcb *); void vfp_restore_state(void); void vfp_save_state(struct thread *, struct pcb *); +void vfp_save_state_savectx(struct pcb *); struct fpu_kern_ctx;