diff mbox series

[Xen-devel,v2] xen/arm: vgic: Make sure the number of SPIs is a multiple of 32

Message ID 20180216145956.3271-1-julien.grall@arm.com
State Accepted
Commit 23b40df6f098e3bcb2f105a4909860240976e40f
Headers show
Series [Xen-devel,v2] xen/arm: vgic: Make sure the number of SPIs is a multiple of 32 | expand

Commit Message

Julien Grall Feb. 16, 2018, 2:59 p.m. UTC
The vGIC relies on having a pending_irq available for every IRQs
described in the ranks. As each rank describes 32 interrupts, we need to
make sure the number of SPIs is a multiple of 32.

Reported-by: Jeff Kubascik <Jeff.Kubascik@dornerworks.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Cc: Jarvis Roach <Jarvis.Roach@dornerworks.com>

---
    This should be backported up to Xen 4.8.

    Changes in v2:
        - Update the Reported-by address
---
 xen/arch/arm/vgic.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stefano Stabellini Feb. 21, 2018, 1:05 a.m. UTC | #1
On Fri, 16 Feb 2018, Julien Grall wrote:
> The vGIC relies on having a pending_irq available for every IRQs
> described in the ranks. As each rank describes 32 interrupts, we need to
> make sure the number of SPIs is a multiple of 32.
> 
> Reported-by: Jeff Kubascik <Jeff.Kubascik@dornerworks.com>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Cc: Jarvis Roach <Jarvis.Roach@dornerworks.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> ---
>     This should be backported up to Xen 4.8.
> 
>     Changes in v2:
>         - Update the Reported-by address
> ---
>  xen/arch/arm/vgic.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 9921769b15..34269bcf27 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -123,6 +123,13 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)
>  
>      d->arch.vgic.ctlr = 0;
>  
> +    /*
> +     * The vGIC relies on having a pending_irq available for every IRQ
> +     * described in the ranks. As each rank describes 32 interrupts, we
> +     * need to make sure the number of SPIs is a multiple of 32.
> +     */
> +    nr_spis = ROUNDUP(nr_spis, 32);
> +
>      /* Limit the number of virtual SPIs supported to (1020 - 32) = 988  */
>      if ( nr_spis > (1020 - NR_LOCAL_IRQS) )
>          return -EINVAL;
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 9921769b15..34269bcf27 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -123,6 +123,13 @@  int domain_vgic_init(struct domain *d, unsigned int nr_spis)
 
     d->arch.vgic.ctlr = 0;
 
+    /*
+     * The vGIC relies on having a pending_irq available for every IRQ
+     * described in the ranks. As each rank describes 32 interrupts, we
+     * need to make sure the number of SPIs is a multiple of 32.
+     */
+    nr_spis = ROUNDUP(nr_spis, 32);
+
     /* Limit the number of virtual SPIs supported to (1020 - 32) = 988  */
     if ( nr_spis > (1020 - NR_LOCAL_IRQS) )
         return -EINVAL;