[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 1/4] xen/arm64: Map the redistributor region by max_vcpus of domU danamically



From: Chen Baozi <baozich@xxxxxxxxx>

The number of redistributor is determined by the number of CPU
interface. So we postpone redistributor mmio size initialization to
the point when the max_vcpus is set.

Signed-off-by: Chen Baozi <baozich@xxxxxxxxx>
---
 xen/arch/arm/vgic-v3.c     | 24 +++++++++++++++++++-----
 xen/common/domctl.c        | 10 ++++++++++
 xen/include/asm-arm/vgic.h |  3 +++
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index 45d54a2..a0c1de9 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -1143,6 +1143,18 @@ static int vgic_v3_vcpu_init(struct vcpu *v)
     return 0;
 }
 
+void vgic_v3_rdist_map(struct domain *d)
+{
+    /* The first redistributor should contain enough space for all CPUs */
+    d->arch.vgic.rdist_regions[0].size = d->arch.vgic.rdist_stride * 
(d->max_vcpus);
+
+    register_mmio_handler(d, &vgic_rdistr_mmio_handler,
+        d->arch.vgic.rdist_regions[0].base,
+        d->arch.vgic.rdist_regions[0].size);
+
+    return;
+}
+
 static int vgic_v3_domain_init(struct domain *d)
 {
     int i, idx;
@@ -1194,7 +1206,6 @@ static int vgic_v3_domain_init(struct domain *d)
         /* The first redistributor should contain enough space for all CPUs */
         BUILD_BUG_ON((GUEST_GICV3_GICR0_SIZE / GUEST_GICV3_RDIST_STRIDE) < 
MAX_VIRT_CPUS);
         d->arch.vgic.rdist_regions[0].base = GUEST_GICV3_GICR0_BASE;
-        d->arch.vgic.rdist_regions[0].size = GUEST_GICV3_GICR0_SIZE;
         d->arch.vgic.rdist_regions[0].first_cpu = 0;
     }
 
@@ -1214,10 +1225,13 @@ static int vgic_v3_domain_init(struct domain *d)
      * redistributors. The handler will take care to choose which
      * redistributor is targeted.
      */
-    for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
-        register_mmio_handler(d, &vgic_rdistr_mmio_handler,
-            d->arch.vgic.rdist_regions[i].base,
-            d->arch.vgic.rdist_regions[i].size);
+    if ( is_hardware_domain(d) )
+    {
+        for ( i = 0; i < d->arch.vgic.nr_regions; i++ )
+            register_mmio_handler(d, &vgic_rdistr_mmio_handler,
+                d->arch.vgic.rdist_regions[i].base,
+                d->arch.vgic.rdist_regions[i].size);
+    }
 
     d->arch.vgic.ctlr = VGICD_CTLR_DEFAULT;
 
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index e571e76..43b9f79 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -33,6 +33,11 @@
 #include <public/domctl.h>
 #include <xsm/xsm.h>
 
+#ifdef CONFIG_ARM_64
+#include <asm/gic.h>
+#include <asm/vgic.h>
+#endif
+
 static DEFINE_SPINLOCK(domctl_lock);
 DEFINE_SPINLOCK(vcpu_alloc_lock);
 
@@ -680,6 +685,11 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
             d->max_vcpus = max;
         }
 
+#ifdef CONFIG_ARM_64
+        if (!is_hardware_domain(d) && d->arch.vgic.version == GIC_V3)
+            vgic_v3_rdist_map(d);
+#endif
+
         for ( i = 0; i < max; i++ )
         {
             if ( d->vcpu[i] != NULL )
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index 6dcdf9f..4d7edc6 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -191,6 +191,9 @@ extern struct vgic_irq_rank *vgic_rank_irq(struct vcpu *v, 
unsigned int irq);
 extern int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr);
 extern void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n);
 extern void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n);
+#ifdef CONFIG_ARM_64
+extern void vgic_v3_rdist_map(struct domain *d);
+#endif
 
 #define DEFINE_VGIC_OPS(version)                        \
     extern const struct vgic_ops vgic_v##version##_ops;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.