From owner-svn-src-head@FreeBSD.ORG Wed Apr 15 14:18:26 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EABF029E; Wed, 15 Apr 2015 14:18:26 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D51E76EB; Wed, 15 Apr 2015 14:18:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3FEIQic095984; Wed, 15 Apr 2015 14:18:26 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3FEIQrs095983; Wed, 15 Apr 2015 14:18:26 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201504151418.t3FEIQrs095983@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 15 Apr 2015 14:18:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281554 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Apr 2015 14:18:27 -0000 Author: andrew Date: Wed Apr 15 14:18:25 2015 New Revision: 281554 URL: https://svnweb.freebsd.org/changeset/base/281554 Log: Ensure the userland thread and floating-point state has been saved before copying the pcb. These values may have been changed just before the call to fork and without a call to cpu_switch, where they would have been saved. Sponsored by: The FreeBSD Foundation Modified: head/sys/arm64/arm64/vm_machdep.c Modified: head/sys/arm64/arm64/vm_machdep.c ============================================================================== --- head/sys/arm64/arm64/vm_machdep.c Wed Apr 15 11:48:41 2015 (r281553) +++ head/sys/arm64/arm64/vm_machdep.c Wed Apr 15 14:18:25 2015 (r281554) @@ -47,6 +47,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef VFP +#include +#endif + /* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child @@ -61,6 +65,19 @@ cpu_fork(struct thread *td1, struct proc if ((flags & RFPROC) == 0) return; + if (td1 == curthread) { + /* + * Save the tpidr_el0 and the vfp state, these normally happen + * in cpu_switch, but if userland changes these then forks + * this may not have happened. + */ + td1->td_pcb->pcb_tpidr_el0 = READ_SPECIALREG(tpidr_el0); +#ifdef VFP + if ((td1->td_pcb->pcb_fpflags & PCB_FP_STARTED) != 0) + vfp_save_state(td1); +#endif + } + pcb2 = (struct pcb *)(td2->td_kstack + td2->td_kstack_pages * PAGE_SIZE) - 1;