From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 30 19:37:33 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 849E116A481 for ; Sun, 30 Dec 2007 19:37:33 +0000 (UTC) (envelope-from ticso@cicely12.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.freebsd.org (Postfix) with ESMTP id 2D09D13C474 for ; Sun, 30 Dec 2007 19:37:32 +0000 (UTC) (envelope-from ticso@cicely12.cicely.de) Received: from cicely5.cicely.de ([10.1.1.7]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id lBUJbUXC025869; Sun, 30 Dec 2007 20:37:31 +0100 (CET) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (cicely12.cicely.de [10.1.1.14]) by cicely5.cicely.de (8.13.4/8.13.4) with ESMTP id lBUJbK5k091030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 30 Dec 2007 20:37:21 +0100 (CET) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (localhost [127.0.0.1]) by cicely12.cicely.de (8.13.4/8.13.3) with ESMTP id lBUJbKnP047185; Sun, 30 Dec 2007 20:37:20 +0100 (CET) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.13.4/8.13.3/Submit) id lBUJbIZ0047184; Sun, 30 Dec 2007 20:37:18 +0100 (CET) (envelope-from ticso) Date: Sun, 30 Dec 2007 20:37:18 +0100 From: Bernd Walter To: Mike Meyer Message-ID: <20071230193718.GH31522@cicely12.cicely.de> References: <20071229.122221.-432830441.imp@bsdimp.com> <20071229193034.GA73845@freebie.xs4all.nl> <86prwp161k.fsf@ds4.des.no> <20071230093432.GF31522@cicely12.cicely.de> <20071230135506.47beac58@bhuda.mired.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20071230135506.47beac58@bhuda.mired.org> X-Operating-System: FreeBSD cicely12.cicely.de 5.4-STABLE alpha User-Agent: Mutt/1.5.9i X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED=-1.8, BAYES_00=-2.599 autolearn=ham version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on cicely12.cicely.de Cc: freebsd-hackers@freebsd.org, ticso@cicely.de Subject: Re: Architectures with strict alignment? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Dec 2007 19:37:33 -0000 On Sun, Dec 30, 2007 at 01:55:06PM -0500, Mike Meyer wrote: > On Sun, 30 Dec 2007 10:34:33 +0100 Bernd Walter wrote: > > On Sat, Dec 29, 2007 at 11:37:27PM +0100, Dag-Erling Smørgrav wrote: > > > Wilko Bulte writes: > > > > In the past the alpha port had it too. > > > > > > No, it was optional and defaulted to off. > > > > It was never optional, since no alpha CPU can do missaligned access > > Alphas can fix missaligned access by software trap handlers in the same > > way as most other strong alignment architectures can and we did this > > for userland, but not in kernel. > > > Nevertheless it is horribly slow to do this, but was required since > > there was so many crappy software that days - fortunately this has > > changed over time, although I still see aligment traps on new software > > as well. > > Sadly said we never implemented missaligment traps for x86 so > [...] > > Ok, I'm a bit confused. Since you're talking about moving code from > the x86 to the alpha, I'm assuming you're talking about C code. Isn't > it the *compilers* job to enforce alignment issues, unless the > programmer specifically asks for byte-specific control of the layout > of a set of variables? Not in every case. It is not unusual to read raw bytes from e.g. network and use a struct pointer to it. But in case of network data it may be missaligned and if the struct contains anything else then bytes you may be doing missaligned accesses. > Or are these the issue, and the problem is that people do that and > then don't use the appropriate APIs to pull data from them, thus > causing you headaches? No - they just don't think about alignment when parsing data from random source. A very tricky case are IP headers in ethernet bytes - the ethernet header is not divideable by 4, but the IPs inside are 32 bit. Not to speak about the payload, which might contain 32 bit values. We have seen lots of missalignment bugs every now and then in ipfw, but now ipfw is aligment save since years now. I'm still not 100% sure if TCP NFS clients are save. At least in FreeBSD 5.x it is not. -- B.Walter http://www.bwct.de http://www.fizon.de bernd@bwct.de info@bwct.de support@fizon.de