Skip to contentSkip to conversation

xen/arm: vgic-v2: Map the GIC virtual CPU interface with the correct size

PATCH In review Julien Grall 2 participants 5 messages Sep 17, 2015 – Sep 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: vgic-v2: Map the GIC virtual CPU interface with the correct size

On GICv2, the GIC virtual CPU interface is at minimum 8KB. Due some to some necessary quirk for GIC using 64KB stride, we are mapping the region in 2 time.
The first mapping is 4KB and the second one is 8KB, i.e 12KB in total. Although the minimum supported size (and widely used) is 8KB. This means that we are mapping 4KB more to any guest using GICv2.

While this looks scary at first glance, the GIC virtual CPU interface is most frequently at the end the GIC I/O region. So we will most likely map an an unused I/O region or a mirrored version of GICV for platform using 64KB stride.

Nonetheless, fix the second mapping to only map 4KB.

---

This is a candidate for Xen 4.6 and backport to Xen 4.5. Without this patch we are mapping 4KB more than we should to any guest. While this looks scary at first glance, in pratice there is always space after the GIC I/O region. So we would just expose unused I/O range.

Boot tested on midway (ARM32) and x-gene (ARM64).

---
 xen/arch/arm/vgic-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/vgic-v2.c +2 -2
index 524787b..fa71598 100644
@@ -576,10 +576,10 @@ static int vgic_v2_domain_init(struct domain *d)
 
     if ( !platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) )
         ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + PAGE_SIZE),
-                               2, paddr_to_pfn(vgic_v2_hw.vbase + PAGE_SIZE));
+                               1, paddr_to_pfn(vgic_v2_hw.vbase + PAGE_SIZE));
     else
         ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase + PAGE_SIZE),
-                               2, paddr_to_pfn(vgic_v2_hw.vbase + SZ_64K));
+                               1, paddr_to_pfn(vgic_v2_hw.vbase + SZ_64K));
 
     if ( ret )
         return ret;
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Julien Grall

On GICv2, the GIC virtual CPU interface is at minimum 8KB. Due some to some necessary quirk for GIC using 64KB stride, we are mapping the region in 2 time.
The first mapping is 4KB and the second one is 8KB, i.e 12KB in total. Although the minimum supported size (and widely used) is 8KB. This means that we are mapping 4KB more to any guest using GICv2.

Quoted 8 lines

While this looks scary at first glance, the GIC virtual CPU interface is most frequently at the end the GIC I/O region. So we will most likely map an an unused I/O region or a mirrored version of GICV for platform using 64KB stride.

Nonetheless, fix the second mapping to only map 4KB.

Quoted 3 lines

---

This is a candidate for Xen 4.6 and backport to Xen 4.5.

I concur and with Wei not being around I shall plan to apply later today unless there are objections.

#2 lore raw
Quoted 19 lines · Ian Campbell
Quoted 14 lines · Julien Grall

On GICv2, the GIC virtual CPU interface is at minimum 8KB. Due some to some necessary quirk for GIC using 64KB stride, we are mapping the region in 2 time.
The first mapping is 4KB and the second one is 8KB, i.e 12KB in total. Although the minimum supported size (and widely used) is 8KB. This means
that we are mapping 4KB more to any guest using GICv2.

While this looks scary at first glance, the GIC virtual CPU interface is
most frequently at the end the GIC I/O region. So we will most likely map an an unused I/O region or a mirrored version of GICV for platform using 64KB stride.

Quoted 3 lines

Nonetheless, fix the second mapping to only map 4KB.

Quoted 8 lines
Quoted 3 lines

---

This is a candidate for Xen 4.6 and backport to Xen 4.5.

I concur and with Wei not being around I shall plan to apply later today unless there are objections.

I got distracted. Now applied to staging and staging-4.6 now and noted for later application to 4.5

#3 lore raw

Hi Ian,

Quoted 24 lines · Ian Campbell
Quoted 23 lines · Ian Campbell
Quoted 14 lines · Julien Grall

On GICv2, the GIC virtual CPU interface is at minimum 8KB. Due some to some necessary quirk for GIC using 64KB stride, we are mapping the region in 2 time.
The first mapping is 4KB and the second one is 8KB, i.e 12KB in total. Although the minimum supported size (and widely used) is 8KB. This means
that we are mapping 4KB more to any guest using GICv2.

While this looks scary at first glance, the GIC virtual CPU interface is
most frequently at the end the GIC I/O region. So we will most likely map an an unused I/O region or a mirrored version of GICV for platform using 64KB stride.

Quoted 3 lines

Nonetheless, fix the second mapping to only map 4KB.

Quoted 2 lines

---

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This is a candidate for Xen 4.6 and backport to Xen 4.5.

I concur and with Wei not being around I shall plan to apply later today unless there are objections.

I got distracted. Now applied to staging and staging-4.6 now and noted for later application to 4.5

It won't apply cleanly for Xen 4.5, this code was living in the gic driver. I will send a backport patch for it.

Regards,

Signature · 1 line
Julien Grall
#4 lore raw
Quoted 38 lines · Julien Grall

Hi Ian,

Quoted 35 lines · Ian Campbell
Quoted 33 lines · Ian Campbell
Quoted 19 lines · Julien Grall

On GICv2, the GIC virtual CPU interface is at minimum 8KB. Due some to
some necessary quirk for GIC using 64KB stride, we are mapping the region in 2 time.
The first mapping is 4KB and the second one is 8KB, i.e 12KB in total.
Although the minimum supported size (and widely used) is 8KB. This means
that we are mapping 4KB more to any guest using GICv2.

While this looks scary at first glance, the GIC virtual CPU interface
is
most frequently at the end the GIC I/O region. So we will most likely
map an an unused I/O region or a mirrored version of GICV for platform
using 64KB stride.

Quoted 3 lines

Nonetheless, fix the second mapping to only map 4KB.

Quoted 3 lines

---

This is a candidate for Xen 4.6 and backport to Xen 4.5.

I concur and with Wei not being around I shall plan to apply later today
unless there are objections.

Quoted 6 lines
Quoted 3 lines

I got distracted. Now applied to staging and staging-4.6 now and noted for
later application to 4.5

It won't apply cleanly for Xen 4.5, this code was living in the gic driver. I will send a backport patch for it.

Thanks.