Skip to content

Commit

Permalink
Fix the logic for when to restore the VFP registers. It should restore
Browse files Browse the repository at this point in the history
them when a different thread last used them, or when the thread was last
run on a different cpu.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
  • Loading branch information
zxombie committed Jul 1, 2015
1 parent 35189d4 commit c950fb6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sys/arm64/arm64/vfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ vfp_save_state(struct thread *td)
*/
cpacr = READ_SPECIALREG(cpacr_el1);
if ((cpacr & CPACR_FPEN_MASK) == CPACR_FPEN_TRAP_NONE) {
KASSERT(PCPU_GET(fpcurthread) == td,
("Storing an invalid VFP state"));

vfp_state = td->td_pcb->pcb_vfp;
__asm __volatile(
"mrs %0, fpcr \n"
Expand Down Expand Up @@ -142,7 +145,12 @@ vfp_restore_state(void)

vfp_enable();

if (PCPU_GET(fpcurthread) != curthread && cpu != curpcb->pcb_vfpcpu) {
/*
* If the previous thread on this cpu to use the VFP was not the
* current threas, or the current thread last used it on a different
* cpu we need to restore the old state.
*/
if (PCPU_GET(fpcurthread) != curthread || cpu != curpcb->pcb_vfpcpu) {

vfp_state = curthread->td_pcb->pcb_vfp;
fpcr = curthread->td_pcb->pcb_fpcr;
Expand Down

0 comments on commit c950fb6

Please sign in to comment.