From owner-freebsd-ppc@FreeBSD.ORG Thu Aug 3 22:17:23 2006 Return-Path: X-Original-To: freebsd-ppc@FreeBSD.org Delivered-To: freebsd-ppc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BBF6016A501; Thu, 3 Aug 2006 22:17:23 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from sippysoft.com (gk.360sip.com [72.236.70.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D22543DA1; Thu, 3 Aug 2006 22:17:15 +0000 (GMT) (envelope-from sobomax@FreeBSD.org) Received: from [192.168.1.56] ([204.244.149.125]) (authenticated bits=0) by sippysoft.com (8.13.6/8.13.6) with ESMTP id k73MHBeX048783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Aug 2006 15:17:13 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Message-ID: <44D275C4.5020407@FreeBSD.org> Date: Thu, 03 Aug 2006 15:16:36 -0700 From: Maxim Sobolev Organization: Sippy Software, Inc. User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: David Edelsohn References: <44D23F02.9020709@FreeBSD.org> <200608031826.k73IQX835138@makai.watson.ibm.com> <44D2419F.1050100@FreeBSD.org> <44D245E5.4070102@freebsd.org> <44D24772.7080109@FreeBSD.org> <44D24A3F.5080407@freebsd.org> <200608031929.k73JTq834496@makai.watson.ibm.com> In-Reply-To: <200608031929.k73JTq834496@makai.watson.ibm.com> Content-Type: text/plain; charset=KOI8-U; format=flowed Content-Transfer-Encoding: 7bit Cc: Peter Grehan , freebsd-ppc@FreeBSD.org Subject: Re: Unaligned 64-bits access on FreeBSD/powerpc X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Aug 2006 22:17:23 -0000 David Edelsohn wrote: >>>>>> Peter Grehan writes: > >>> atype = "64"; >>> for (i = 0; i < 256; i++) { >>> apoint = (uint8_t *)&(buf[i]); >>> v64 = *(uint64_t *)apoint; >>> } > > Peter> Would you be able to do a disassembly on this ? I suspect gcc is using > Peter> floating-point regs to do the 64-bit loads. > > That does not matter. The OS is suppose to catch the misaligned > load and emulate the instruction in a handler. If FreeBSD cannot handle > that, then it needs to configure GCC for PowerPC in strict-alignment > embedded mode, which is ABI incompatible. If FreeBSD wants to use the > standard PPC SVR4 ABI or PPC32 Linux variant, it must support any > misaligned load. That is the OS's responsibility, period. David, Thank you for your input. I am trying to debug this problem right now. It appears that the FreeBSD kernel already handles this condition based on the DSISR/DAR contents(trap.c, function fix_unaligned()). However, for some reason when the trap happens the DSISR is set to 0x40000000 (all bits but bit 30 are set to 0). IBM's Programming Environments Manual says the following regarding Alignment Exception in the big endian mode: Setting the DSISR and DAR as described below is optional for implementations on which alignment exceptions occur rarely, if ever, for cases that the alignment exception handler emulates. For such implementations, if the DSISR and DAR are not set as described below they are set to undefined values. Therefore, I am wondering if it's the case here. -Maxim