From: Ian Campbell Subject: Re: [PATCH] xen: arm: correct use of find_next_bit Date: Mon, 27 Jan 2014 12:53:35 +0000 Message-ID: <1390827215.12230.29.camel@kazak.uk.xensource.com> References: <1390573387-15386-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: julien.grall@linaro.org, tim@xen.org, fu.wei@linaro.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2014-01-27 at 12:33 +0000, Stefano Stabellini wrote: > On Fri, 24 Jan 2014, 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. > > I am not opposed to this patch, but for the sake of clarity, isn't the > alignment of (uint32_t*) and (const unsigned long*) the same? It should > be 8 bytes in both cases on ARM64. The target of a uint32_t * only needs to be 4 byte aligned on arm64, since that is the natural alignment of a 32-bit type. > It seems to me that the problem is not the cast to (const unsigned > long*), but the usage of &r: maybe the tools aren't able to covert &r to > a properly aligned pointer? No, &r behaves exactly as expected and returns the address of r, whatever the alignment of r is. > Am I getting this wrong? I think so, yes. Ian.