From owner-svn-src-all@freebsd.org Wed Jul 1 17:27:45 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0171A992D83; Wed, 1 Jul 2015 17:27:45 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E703F2144; Wed, 1 Jul 2015 17:27:44 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t61HRikT047199; Wed, 1 Jul 2015 17:27:44 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t61HRiKB047198; Wed, 1 Jul 2015 17:27:44 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201507011727.t61HRiKB047198@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 1 Jul 2015 17:27:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285014 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jul 2015 17:27:45 -0000 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;