From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org
Subject: Re: [PATCH] xen: arm: correct use of find_next_bit
Date: Fri, 24 Jan 2014 14:36:19 +0000 [thread overview]
Message-ID: <52E27A63.6030903@linaro.org> (raw)
In-Reply-To: <1390573387-15386-1-git-send-email-ian.campbell@citrix.com>
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 <fu.wei@linaro.org>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Good catch! Do you plan to apply this patch for Xen 4.4?
Acked-by: Julien Grall <julien.grall@linaro.org>
> ---
> xen/arch/arm/vgic.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 90e9707..553411d 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -362,11 +362,12 @@ read_as_zero:
>
> static void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
> {
> + const unsigned long mask = r;
> struct pending_irq *p;
> unsigned int irq;
> int i = 0;
>
> - while ( (i = find_next_bit((const long unsigned int *) &r, 32, i)) < 32 ) {
> + while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> irq = i + (32 * n);
> p = irq_to_pending(v, irq);
> clear_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> @@ -379,11 +380,12 @@ static void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
>
> static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> {
> + const unsigned long mask = r;
> struct pending_irq *p;
> unsigned int irq;
> int i = 0;
>
> - while ( (i = find_next_bit((const long unsigned int *) &r, 32, i)) < 32 ) {
> + while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> irq = i + (32 * n);
> p = irq_to_pending(v, irq);
> set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
>
--
Julien Grall
next prev parent reply other threads:[~2014-01-24 14:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 14:23 [PATCH] xen: arm: correct use of find_next_bit Ian Campbell
2014-01-24 14:36 ` Julien Grall [this message]
2014-01-24 14:48 ` Ian Campbell
2014-02-04 15:50 ` Ian Campbell
2014-01-24 14:40 ` Jan Beulich
2014-01-24 14:50 ` Ian Campbell
2014-01-27 12:33 ` Stefano Stabellini
2014-01-27 12:53 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52E27A63.6030903@linaro.org \
--to=julien.grall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.