From owner-freebsd-ppc@FreeBSD.ORG Thu Aug 3 18:59:31 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 1278516A540; Thu, 3 Aug 2006 18:59:31 +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 631EA43D46; Thu, 3 Aug 2006 18:59:30 +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 k73IxRee046401 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Aug 2006 11:59:28 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Message-ID: <44D24772.7080109@FreeBSD.org> Date: Thu, 03 Aug 2006 11:58:58 -0700 From: Maxim Sobolev Organization: Sippy Software, Inc. User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: Peter Grehan References: <44D23F02.9020709@FreeBSD.org> <200608031826.k73IQX835138@makai.watson.ibm.com> <44D2419F.1050100@FreeBSD.org> <44D245E5.4070102@freebsd.org> In-Reply-To: <44D245E5.4070102@freebsd.org> Content-Type: text/plain; charset=KOI8-U; format=flowed Content-Transfer-Encoding: 7bit Cc: 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 18:59:31 -0000 Peter Grehan wrote: >> Well, actually *nix has a long history of just killing the program >> with SIGBUS in such case. >> >> I am just wondering if it's really expected behavior on >> FreeBSD/powerpc or not. > > No :( > > What system are you running on ? I was pretty sure that G3/G4 CPUs > allowed unaligned accesses unless you explicitly disabled it (except for > cases such as vector ops). A 64 bit op on these CPUs should decompose > into separate 32-bit accesses ala i386 so the same case should occurr > for unaligned 32-bit ops. > > In any event, the default should be that unaligned accesses are > handled, and then have switches to optionally uprintf the address, or > SIGBUS. It's G4 (Mac Mini). Dmesg reports processor as: cpu0: Motorola PowerPC 7447A revision 1.2, 1250.00 MHz cpu0: HID0 8450c0bc According to the following link, unaligned floating-point 64-bits access isn't supported in the PowerPC: http://www-128.ibm.com/developerworks/library/pa-dalign/ I use the following program to reproduce the problem. It dies with "failure doing 64-bit access at address 0x7fffd8e1". #include #include #include static char *atype; static uint8_t *apoint; static void sigbus(int signum) { printf("failure doing %s-bit access at address %p\n", atype, apoint); exit(1); } int main() { uint8_t buf[1024]; uint16_t v16; uint32_t v32; uint64_t v64; static int i; signal(SIGBUS, sigbus); atype = "16"; for (i = 0; i < 256; i++) { apoint = (uint8_t *)&(buf[i]); v16 = *(uint16_t *)apoint; } atype = "32"; for (i = 0; i < 256; i++) { apoint = (uint8_t *)&(buf[i]); v32 = *(uint32_t *)apoint; } atype = "64"; for (i = 0; i < 256; i++) { apoint = (uint8_t *)&(buf[i]); v64 = *(uint64_t *)apoint; } exit(0); } -Maxim