Author: andrew
Date: Wed Jul  1 17:27:44 2015
New Revision: 285014
URL: https://svnweb.freebsd.org/changeset/base/285014

Log:
  Fix the logic for when to restore the VFP registers. It should restore
  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

Modified:
  head/sys/arm64/arm64/vfp.c

Modified: head/sys/arm64/arm64/vfp.c
==============================================================================
--- head/sys/arm64/arm64/vfp.c  Wed Jul  1 17:19:51 2015        (r285013)
+++ head/sys/arm64/arm64/vfp.c  Wed Jul  1 17:27:44 2015        (r285014)
@@ -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"
@@ -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;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to