From owner-freebsd-arm@freebsd.org Mon Dec 28 14:08:09 2015 Return-Path: Delivered-To: freebsd-arm@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 695CFA54C51; Mon, 28 Dec 2015 14:08:09 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from kif.fubar.geek.nz (kif.fubar.geek.nz [178.62.119.249]) by mx1.freebsd.org (Postfix) with ESMTP id 310EC1EEF; Mon, 28 Dec 2015 14:08:08 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from zapp.Home (unknown [90.200.119.55]) by kif.fubar.geek.nz (Postfix) with ESMTPSA id 927D3D7A17; Mon, 28 Dec 2015 14:07:32 +0000 (UTC) Date: Mon, 28 Dec 2015 14:07:29 +0000 From: Andrew Turner To: Mark Millard Cc: Warner Losh , mat@FreeBSD.org, freebsd-arm , FreeBSD Toolchain , Ian Lepore Subject: Re: 11.0-CURRENT (r292413) on a rpi2b: arm-gnueabi-freebsd/bin/ar, _fseeko, and memset vs memory alignment (SCTRL bit[1]=1?): Explains the Bus error? Message-ID: <20151228140729.565c9dc6@zapp.Home> In-Reply-To: <9DA7895D-B3DE-41FD-900C-EC95BDE19728@dsl-only.net> References: <4CC6220D-72FB-45AD-AE70-5EB4EF0BCF5C@dsl-only.net> <0D81C2CA-BF1C-4C14-B816-A8C5F68715B5@bsdimp.com> <51EB4AAB-BC81-4282-BA4D-D329C41D660B@dsl-only.net> <8B52074F-FDEF-4119-BB04-630F9BE9E6DB@bsdimp.com> <118D2970-4799-46B1-81A1-0101B907C1BE@dsl-only.net> <9DA7895D-B3DE-41FD-900C-EC95BDE19728@dsl-only.net> X-Mailer: Claws Mail 3.13.0 (GTK+ 2.24.29; amd64-portbld-freebsd11.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2015 14:08:09 -0000 On Mon, 28 Dec 2015 03:33:09 -0800 Mark Millard wrote: ... > The failing code is for the "placement new" in the loop: > > A) &getArgBuffer()[I] is not always an address for which the vst1.64 > instruction gets an aligned address. > > but. . . > > B) TemplateArgument(Args[I])'s copy construction activity has code > (such as the vst1.64) requiring a specific alignment when SCTLR > bit[1]==1. > > C) Nothing here has any explicitly packed data structures. The bug is we enable the alignment checks in the kernel. Compilers assume there are no alignment checks on ARMv7. We have taught gcc to generate worse code on FreeBSD because of this. There was some concern about reading non-naturally aligned data in the kernel not being atomic, this could be checked by, in debug configurations, enabling alignment checks on entry to the kernel and disabling them on exit. We could also have a flag for clang to tell it we are in the kernel, there is already something similar for iOS. Andrew