From owner-freebsd-arm@FreeBSD.ORG Thu Jan 24 23:23:59 2008 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EB2916A418 for ; Thu, 24 Jan 2008 23:23:59 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mail.digiware.nl (www.tegenbosch28.nl [217.21.251.97]) by mx1.freebsd.org (Postfix) with ESMTP id EA91D13C4E5 for ; Thu, 24 Jan 2008 23:23:58 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from localhost (localhost.digiware.nl [127.0.0.1]) by mail.digiware.nl (Postfix) with ESMTP id 390DC1735A; Fri, 25 Jan 2008 00:23:54 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.nl Received: from mail.digiware.nl ([127.0.0.1]) by localhost (rack1.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tBBiE0FocZ0Y; Fri, 25 Jan 2008 00:23:51 +0100 (CET) Received: from [192.168.2.10] (unknown [192.168.2.10]) by mail.digiware.nl (Postfix) with ESMTP id CA42C17331; Fri, 25 Jan 2008 00:23:51 +0100 (CET) Message-ID: <47991E08.6070609@digiware.nl> Date: Fri, 25 Jan 2008 00:23:52 +0100 From: Willem Jan Withagen Organization: Digiware User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: "M. Warner Losh" References: <479880A7.1030107@digiware.nl> <20080124.084828.1608359032.imp@bsdimp.com> <864pd386mj.fsf@ds4.des.no> <20080124.110954.179240992.imp@bsdimp.com> In-Reply-To: <20080124.110954.179240992.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: des@des.no, freebsd-arm@freebsd.org Subject: Re: sshd broken on arm? X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 23:23:59 -0000 M. Warner Losh wrote: > In message: <864pd386mj.fsf@ds4.des.no> > Dag-Erling_Smørgrav writes: > : "M. Warner Losh" writes: > : > Actually, the above fix *IS* the correct fix for arm given the ABI > : > that we're using... > : > : No. The correct fix is one that will be acceptable to the upstream > : vendor, who has a different perspective on things than we do. > > The problem is that the char array isn't guaranteed to be aligned in > any way. The fix posted is correct. > > There may be other fixes too, such as using a union to force > alignment. Well I'm sort of puzzled right now since after preprocessing the variable allocation part boils down to: ===== struct msghdr msg; struct iovec vec; char ch = '\0'; ssize_t n; char tmp[((((unsigned)(sizeof(struct cmsghdr)) + (sizeof(int) - 1)) & ~(sizeof(int) - 1)) + (((unsigned)(sizeof(int)) + (sizeof(int ) - 1)) & ~(sizeof(int) - 1)))]; struct cmsghdr *cmsg; ===== So as far as I can see is char tmp[] included between 2 4-byte items and allocation should be "automagically" 4-byte aligned. Now adding simple code like tmp[0] = 50, the first part of the assembly is: (Comments are mine for as far as I can grasp them) ==== mm_send_fd: @ args = 0, pretend = 0, frame = 72 @ frame_needed = 1, current_function_anonymous_args = 0 // entry code mov ip, sp stmfd sp!, {fp, ip, lr, pc} sub fp, ip, #4 // allocate stack space sub sp, sp, #72 str r0, [fp, #-16] str r1, [fp, #-20] // ch = '\0' mov r3, #0 mov r2, r3 strb r2, [fp, #-57] // tmp[0] = 50 mov r3, #50 mov r2, r3 strb r2, [fp, #-80] // msg = &tmp sub r3, fp, #80 str r3, [fp, #-32] // ==== So it seems that with this compiler tmp is correctly aligned. What I used for this is the arm-elf-gcc-295 from ports, not doing any optimisation. Optimisation eliminates just about everything in my simple test. Trying it on the full code, I still don't see an unaligned reference to &tmp But then that might vary with the compiler. But I cannot follow the suggestions at the freebsd/arm pages. I do not have a -CURRENT system, and trying it on 7.0 starts to complain right away on the first file to compile. Su suggestions there are welcome. --WjW