From owner-svn-src-head@freebsd.org Wed Oct 7 09:12:51 2015 Return-Path: Delivered-To: svn-src-head@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 973A69D0D9F; Wed, 7 Oct 2015 09:12:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 52978ACD; Wed, 7 Oct 2015 09:12:51 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t979CoC5054141; Wed, 7 Oct 2015 09:12:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t979Co21054138; Wed, 7 Oct 2015 09:12:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201510070912.t979Co21054138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 7 Oct 2015 09:12:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288983 - 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-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, 07 Oct 2015 09:12:51 -0000 Author: kib Date: Wed Oct 7 09:12:49 2015 New Revision: 288983 URL: https://svnweb.freebsd.org/changeset/base/288983 Log: A follow-up to r288492. In fact, revert the mentioned commit for pre-VFPv3 processors, since they do require software support code to handle denormals. For VFPv3 and later, enable flush-to-zero if hardware does not claim full denormals arithmetic support by VMVFR1_FZ field in mvfr1 register. The end result is that we do use correct fpu environment on Cortexes with VFPv3, while ARM11 (e.g. rpi) is in non-compliant flush-to-zero mode. At least CPUs without complete hardware implementation of IEEE 754 do not cause unhandled floating point exception on underflow, as it was before r288492. Noted by: ian Tested by: gjb Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/arm/arm/vfp.c head/sys/arm/arm/vm_machdep.c head/sys/arm/include/md_var.h Modified: head/sys/arm/arm/vfp.c ============================================================================== --- head/sys/arm/arm/vfp.c Wed Oct 7 08:56:38 2015 (r288982) +++ head/sys/arm/arm/vfp.c Wed Oct 7 09:12:49 2015 (r288983) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -128,6 +129,15 @@ vfp_init(void) tmp = fmrx(mvfr1); PCPU_SET(vfpmvfr1, tmp); + + if (PCPU_GET(cpuid) == 0) { + if ((tmp & VMVFR1_FZ_MASK) == 0x1) { + /* Denormals arithmetic support */ + initial_fpscr &= ~VFPSCR_FZ; + thread0.td_pcb->pcb_vfpstate.fpscr = + initial_fpscr; + } + } } /* initialize the coprocess 10 and 11 calls Modified: head/sys/arm/arm/vm_machdep.c ============================================================================== --- head/sys/arm/arm/vm_machdep.c Wed Oct 7 08:56:38 2015 (r288982) +++ head/sys/arm/arm/vm_machdep.c Wed Oct 7 09:12:49 2015 (r288983) @@ -85,6 +85,8 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct switchframe) == 48); CTASSERT(sizeof(struct trapframe) == 80); +uint32_t initial_fpscr = VFPSCR_DN | VFPSCR_FZ; + /* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child @@ -134,7 +136,7 @@ cpu_fork(register struct thread *td1, re pcb2->pcb_regs.sf_sp = STACKALIGN(td2->td_frame); pcb2->pcb_vfpcpu = -1; - pcb2->pcb_vfpstate.fpscr = VFPSCR_DN; + pcb2->pcb_vfpstate.fpscr = initial_fpscr; tf = td2->td_frame; tf->tf_spsr &= ~PSR_C; Modified: head/sys/arm/include/md_var.h ============================================================================== --- head/sys/arm/include/md_var.h Wed Oct 7 08:56:38 2015 (r288982) +++ head/sys/arm/include/md_var.h Wed Oct 7 09:12:49 2015 (r288983) @@ -71,4 +71,6 @@ void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); int minidumpsys(struct dumperinfo *); +extern uint32_t initial_fpscr; + #endif /* !_MACHINE_MD_VAR_H_ */