From owner-svn-src-all@FreeBSD.ORG Sun Mar 9 14:24:06 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C2106614; Sun, 9 Mar 2014 14:24:06 +0000 (UTC) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A4976DAE; Sun, 9 Mar 2014 14:24:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s29EO6W8083908; Sun, 9 Mar 2014 14:24:06 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s29EO6UQ083903; Sun, 9 Mar 2014 14:24:06 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201403091424.s29EO6UQ083903@svn.freebsd.org> From: Ian Lepore Date: Sun, 9 Mar 2014 14:24:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262948 - in head/sys/arm: arm include 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.17 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: Sun, 09 Mar 2014 14:24:06 -0000 Author: ian Date: Sun Mar 9 14:24:05 2014 New Revision: 262948 URL: http://svnweb.freebsd.org/changeset/base/262948 Log: Always call vfp_discard() on thread death, not just when the VFP is enabled. In vfp_discard(), if the state in the VFP hardware belongs to the thread which is dying, NULL out pcpu fpcurthread to indicate the state currently in the hardware belongs to nobody. Submitted by: Juergen Weiss Pointy hat to: me Modified: head/sys/arm/arm/swtch.S head/sys/arm/arm/vfp.c head/sys/arm/include/vfp.h Modified: head/sys/arm/arm/swtch.S ============================================================================== --- head/sys/arm/arm/swtch.S Sun Mar 9 13:23:49 2014 (r262947) +++ head/sys/arm/arm/swtch.S Sun Mar 9 14:24:05 2014 (r262948) @@ -124,14 +124,11 @@ ENTRY(cpu_throw) * r5 = newtd */ - GET_PCPU(r7, r9) - -#ifdef VFP - fmrx r0, fpexc /* This thread is dying, if the VFP */ - tst r0, #(VFPEXC_EN) /* is enabled, go shut it down */ - blne _C_LABEL(vfp_discard) /* without preserving its state. */ +#ifdef VFP /* This thread is dying, disable */ + bl _C_LABEL(vfp_discard) /* VFP without preserving state. */ #endif + GET_PCPU(r7, r9) ldr r7, [r5, #(TD_PCB)] /* r7 = new thread's PCB */ /* Switch to lwp0 context */ Modified: head/sys/arm/arm/vfp.c ============================================================================== --- head/sys/arm/arm/vfp.c Sun Mar 9 13:23:49 2014 (r262947) +++ head/sys/arm/arm/vfp.c Sun Mar 9 14:24:05 2014 (r262948) @@ -229,21 +229,23 @@ vfp_store(struct vfp_state *vfpsave, boo } /* - * If the VFP hardware is on, the current thread was using it but now that - * thread is dying. Turn off the VFP and set pcpu fpcurthread to 0, to indicate - * that the VFP hardware state does not belong to any thread. Called only from - * cpu_throw(), so we don't have to worry about a context switch here. + * The current thread is dying. If the state currently in the hardware belongs + * to the current thread, set fpcurthread to NULL to indicate that the VFP + * hardware state does not belong to any thread. If the VFP is on, turn it off. + * Called only from cpu_throw(), so we don't have to worry about a context + * switch here. */ void -vfp_discard() +vfp_discard(struct thread *td) { u_int tmp; + if (PCPU_GET(fpcurthread) == td) + PCPU_SET(fpcurthread, NULL); + tmp = fmrx(VFPEXC); - if (tmp & VFPEXC_EN) { + if (tmp & VFPEXC_EN) fmxr(VFPEXC, tmp & ~VFPEXC_EN); - PCPU_SET(fpcurthread, 0); - } } #endif Modified: head/sys/arm/include/vfp.h ============================================================================== --- head/sys/arm/include/vfp.h Sun Mar 9 13:23:49 2014 (r262947) +++ head/sys/arm/include/vfp.h Sun Mar 9 14:24:05 2014 (r262948) @@ -129,7 +129,7 @@ #ifndef LOCORE void vfp_init(void); void vfp_store(struct vfp_state *, boolean_t); -void vfp_discard(void); +void vfp_discard(struct thread *); #endif #endif