xen/arm: vgic: Correctly calculate GICD_TYPER.ITLinesNumber
authorJulien Grall <julien.grall@linaro.org>
Wed, 1 Apr 2015 16:21:46 +0000 (17:21 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 2 Apr 2015 09:42:35 +0000 (10:42 +0100)
The formula of GICD_TYPER.ITLinesNumber is 32(N + 1).

As the number of SPIs suppported by the domain may not be a multiple of
32, we have to round up the number before using it.

At the same time remove the mask GICD_TYPE_LINES which is pointless.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/vgic-v2.c
xen/arch/arm/vgic-v3.c

index 40619b25d4736cfecfb72cc825ba4fab8751b60b..b5a8f29568305a8677d9f7c79b590c21dd684157 100644 (file)
@@ -55,7 +55,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
         /* No secure world support for guests. */
         vgic_lock(v);
         *r = ( ((v->domain->max_vcpus - 1) << GICD_TYPE_CPUS_SHIFT) )
-            |( ((v->domain->arch.vgic.nr_spis / 32)) & GICD_TYPE_LINES );
+            | DIV_ROUND_UP(v->domain->arch.vgic.nr_spis, 32);
         vgic_unlock(v);
         return 1;
     case GICD_IIDR:
index 81fbb26adb3ca453ad5a5096aa9bbad8f604e8a2..45a46c3b13b6e646b558ee3dc4712f0e6ab3c333 100644 (file)
@@ -700,7 +700,7 @@ static int vgic_v3_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
         if ( dabt.size != DABT_WORD ) goto bad_width;
         /* No secure world support for guests. */
         *r = ((ncpus - 1) << GICD_TYPE_CPUS_SHIFT |
-              ((v->domain->arch.vgic.nr_spis / 32) & GICD_TYPE_LINES));
+              DIV_ROUND_UP(v->domain->arch.vgic.nr_spis, 32));
 
         *r |= (irq_bits - 1) << GICD_TYPE_ID_BITS_SHIFT;