From: Ian Campbell Subject: Re: [PATCH] xen: arm: correct use of find_next_bit Date: Tue, 4 Feb 2014 15:50:18 +0000 Message-ID: <1391529018.6497.39.camel@kazak.uk.xensource.com> References: <1390573387-15386-1-git-send-email-ian.campbell@citrix.com> <52E27A63.6030903@linaro.org> <1390574921.2124.87.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1390574921.2124.87.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: xen-devel@lists.xen.org, tim@xen.org, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Fri, 2014-01-24 at 14:48 +0000, Ian Campbell wrote: > On Fri, 2014-01-24 at 14:36 +0000, Julien Grall wrote: > > On 01/24/2014 02:23 PM, Ian Campbell wrote: > > > find_next_bit takes a "const unsigned long *" but forcing a cast of an > > > "uint32_t *" throws away the alignment constraints and ends up causing an > > > alignment fault on arm64 if the input happened to be 4 but not 8 byte aligned. > > > > > > Instead of casting use a temporary variable of the right type. > > > > > > I've had a look around for similar constructs and the only thing I found was > > > maintenance_interrupt which cases a uint64_t down to an unsigned long, which > > > although perhaps not best advised is safe I think. > > > > > > This was observed with the AArch64 Linaro toolchain 2013.12 but I think that > > > is just coincidental due to subtle changes to the stack layout etc. > > > > > > Reported-by: Fu Wei > > > Signed-off-by: Ian Campbell > > > > Good catch! Do you plan to apply this patch for Xen 4.4? > > Yes, I think it is a suitable bug fix. Applied, thanks.