From owner-freebsd-arm@FreeBSD.ORG Fri May 10 08:51:57 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1AE549D0; Fri, 10 May 2013 08:51:57 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from nibbler.fubar.geek.nz (nibbler.fubar.geek.nz [199.48.134.198]) by mx1.freebsd.org (Postfix) with ESMTP id F1142AF4; Fri, 10 May 2013 08:51:56 +0000 (UTC) Received: from bender.lan (46-37-44-135.dsl.cnl.uk.net [46.37.44.135]) by nibbler.fubar.geek.nz (Postfix) with ESMTPSA id CC5155E1F1; Fri, 10 May 2013 08:51:49 +0000 (UTC) Date: Fri, 10 May 2013 09:51:50 +0100 From: Andrew Turner To: Tim Kientzle Subject: Re: Is this related to the general panic discussed in freebsd-current? Message-ID: <20130510095150.481feca7@bender.lan> In-Reply-To: References: <51835891.4050409@thieprojects.ch> <03971BD1-4ADE-4435-BDD0-B94B62634F1D@bsdimp.com> <5183BF8C.4040406@thieprojects.ch> <6D0E82C9-79D1-4804-9B39-3440F99AA8FE@kientzle.com> <20130505140006.0d671ba5@bender> <20130505233729.63ac23bc@bender.lan> <724191A9-57F4-4D66-9E4A-EBBC13BDC0D1@freebsd.org> <20130506124711.23978ec8@bender.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-arm@freebsd.org X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 May 2013 08:51:57 -0000 On Thu, 9 May 2013 22:17:09 -0700 Tim Kientzle wrote: > > On May 6, 2013, at 4:47 AM, Andrew Turner wrote: > > > On Sun, 5 May 2013 22:39:56 -0700 > > Tim Kientzle wrote: > >> Here's a version of stack_capture that allows a Clang-built > >> OABI kernel with WITNESS enabled to boot: > >> > >> /* In sys/arm/arm/stack_machdep.c */ > >> static void > >> stack_capture(struct stack *st, u_int32_t *frame) > >> { > >> vm_offset_t callpc; > >> > >> stack_zero(st); > >> while (INKERNEL(frame)) { > >> callpc = frame[1]; > >> if (stack_put(st, callpc) == -1) > >> break; > >> frame = (u_int32_t *)(frame[0]); > >> } > >> } > > It looks like this should work in most cases where fp and lr are > > next to each other (ip and sp are between them but doesn't need to > > be saved). > > Disassembling an EABI kernel, there are 7930 'push' instructions with > fp and lr next to each other and only 220 without, so it looks like > the EABI kernel uses this frame convention as well. It looks like this is a product of cang/llvm. There is no mention of the frame pointer that I can find in the EABI documentation and gcc doesn't appear to generate the 'push' instruction with fp. We can't rely on fp being stored or valid on EABI. > So what do you think of the following? I suspect we need to call stack_zero in all cases. I would thing the following would work: static void stack_capture(struct stack *st, u_int32_t *frame) { #if !defined(__ARM_EABI__) && !defined(__clang__) vm_offset_t callpc; #endif stack_zero(st); #if !defined(__ARM_EABI__) && !defined(__clang__) while (1) { if (!INKERNEL(frame)) break; callpc = frame[FR_SCP]; if (stack_put(st, callpc) == -1) break; frame = (u_int32_t *)(frame[FR_RFP]); } #endif } Alternatively the call to stack_zero could be pushed up into the two functions that call stack_capture. Looking at the code it appears stack_save_td also uses the frame pointer to get the stack location, however as this would be unused this is less of an issue. Andrew