Split out vfp_new_thread
To keep the vfp thread creation code in one place move into vfp.c. This will also help with adding SVE support as it depends on VFP. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35615
This commit is contained in:
parent
cf337fcd74
commit
baf8f20a4a
@ -199,6 +199,32 @@ vfp_save_state(struct thread *td, struct pcb *pcb)
|
||||
critical_exit();
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the VFP state for a forked process or new thread. The PCB will
|
||||
* have been copied from the old thread.
|
||||
*/
|
||||
void
|
||||
vfp_new_thread(struct thread *newtd, struct thread *oldtd, bool fork)
|
||||
{
|
||||
struct pcb *newpcb;
|
||||
|
||||
newpcb = newtd->td_pcb;
|
||||
|
||||
/* Kernel threads start with clean VFP */
|
||||
if ((oldtd->td_pflags & TDP_KTHREAD) != 0) {
|
||||
newpcb->pcb_fpflags &=
|
||||
~(PCB_FP_STARTED | PCB_FP_KERN | PCB_FP_NOSAVE);
|
||||
} else {
|
||||
MPASS((newpcb->pcb_fpflags & (PCB_FP_KERN|PCB_FP_NOSAVE)) == 0);
|
||||
if (!fork) {
|
||||
newpcb->pcb_fpflags &= ~PCB_FP_STARTED;
|
||||
}
|
||||
}
|
||||
|
||||
newpcb->pcb_fpusaved = &newpcb->pcb_fpustate;
|
||||
newpcb->pcb_vfpcpu = UINT_MAX;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the FP state to avoid leaking state from the parent process across
|
||||
* execve() (and to ensure that we get a consistent floating point environment
|
||||
|
@ -109,8 +109,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
|
||||
td2->td_pcb->pcb_x[20] = (uintptr_t)td2;
|
||||
td2->td_pcb->pcb_lr = (uintptr_t)fork_trampoline;
|
||||
td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame;
|
||||
td2->td_pcb->pcb_fpusaved = &td2->td_pcb->pcb_fpustate;
|
||||
td2->td_pcb->pcb_vfpcpu = UINT_MAX;
|
||||
|
||||
vfp_new_thread(td2, td1, true);
|
||||
|
||||
/* Setup to release spin count in fork_exit(). */
|
||||
td2->td_md.md_spinlock_count = 1;
|
||||
@ -187,9 +187,9 @@ cpu_copy_thread(struct thread *td, struct thread *td0)
|
||||
td->td_pcb->pcb_x[20] = (uintptr_t)td;
|
||||
td->td_pcb->pcb_lr = (uintptr_t)fork_trampoline;
|
||||
td->td_pcb->pcb_sp = (uintptr_t)td->td_frame;
|
||||
td->td_pcb->pcb_fpflags &= ~(PCB_FP_STARTED | PCB_FP_KERN | PCB_FP_NOSAVE);
|
||||
td->td_pcb->pcb_fpusaved = &td->td_pcb->pcb_fpustate;
|
||||
td->td_pcb->pcb_vfpcpu = UINT_MAX;
|
||||
|
||||
/* Update VFP state for the new thread */
|
||||
vfp_new_thread(td, td0, false);
|
||||
|
||||
/* Setup to release spin count in fork_exit(). */
|
||||
td->td_md.md_spinlock_count = 1;
|
||||
|
@ -68,6 +68,7 @@ struct thread;
|
||||
|
||||
void vfp_init(void);
|
||||
void vfp_discard(struct thread *);
|
||||
void vfp_new_thread(struct thread *, struct thread *, bool);
|
||||
void vfp_reset_state(struct thread *, struct pcb *);
|
||||
void vfp_restore_state(void);
|
||||
void vfp_save_state(struct thread *, struct pcb *);
|
||||
|
Loading…
Reference in New Issue
Block a user