diff mbox series

[XEN,v2,11/25] arm: new VGIC: Add alternative redist region storage

Message ID c34ecad9ad13f97d0d4680a2f0c51fa2a7b4871a.1699618395.git.mykyta_poturai@epam.com (mailing list archive)
State New, archived
Headers show
Series arm: Add GICv3 support to the New VGIC | expand

Commit Message

Mykyta Poturai Nov. 10, 2023, 12:56 p.m. UTC
Guests DT creation requires redist regions to be stored in the specific
variables in struct vgic_dist. But in new VGIC a linked list is used for
that. To not clutter the DT creation code with ifdefs, add alternative
storage for redist regions in struct vgic_dist.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 xen/arch/arm/include/asm/new_vgic.h | 5 +++++
 xen/arch/arm/vgic/vgic-v3.c         | 8 ++++++++
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/new_vgic.h b/xen/arch/arm/include/asm/new_vgic.h
index 11d8f71851..9eafab45ff 100644
--- a/xen/arch/arm/include/asm/new_vgic.h
+++ b/xen/arch/arm/include/asm/new_vgic.h
@@ -21,6 +21,7 @@ 
 #include <xen/list.h>
 #include <xen/mm.h>
 #include <xen/spinlock.h>
+#include <asm/gic_v3_defs.h>
 
 #define VGIC_V3_MAX_CPUS        255
 #define VGIC_V2_MAX_CPUS        8
@@ -136,6 +137,10 @@  struct vgic_dist {
     paddr_t             csize; /* CPU interface size */
     paddr_t             vbase; /* virtual CPU interface base address */
 
+    /* for compatibility with guests DT creation*/
+    uint32_t nr_regions;
+    struct rdist_region *rdist_regions;
+
     /* distributor enabled */
     bool                enabled;
 
diff --git a/xen/arch/arm/vgic/vgic-v3.c b/xen/arch/arm/vgic/vgic-v3.c
index 682d57b476..8b700609f0 100644
--- a/xen/arch/arm/vgic/vgic-v3.c
+++ b/xen/arch/arm/vgic/vgic-v3.c
@@ -257,6 +257,10 @@  int vgic_v3_map_resources(struct domain *d)
     /* Allocate memory for Re-distributor regions */
     rdist_count = vgic_v3_max_rdist_count(d);
 
+    /*For compatibility with hwdom dt node creation*/
+    d->arch.vgic.nr_regions = rdist_count;
+    d->arch.vgic.rdist_regions = xzalloc_array(struct rdist_region, rdist_count);
+
     /*
      * For domain using the host memory layout, it gets the hardware
      * address.
@@ -268,6 +272,8 @@  int vgic_v3_map_resources(struct domain *d)
 
         for ( i = 0; i < vgic_v3_hw_data.nr_rdist_regions; i++ )
         {
+            d->arch.vgic.rdist_regions[i].base = vgic_v3_hw_data.regions[i].base;
+            d->arch.vgic.rdist_regions[i].size = vgic_v3_hw_data.regions[i].size;
             vgic_v3_set_redist_base(d, i, vgic_v3_hw_data.regions[i].base,
                                     vgic_v3_hw_data.regions[i].size /
                                         GICV3_GICR_SIZE);
@@ -276,6 +282,8 @@  int vgic_v3_map_resources(struct domain *d)
     else
     {
         d->arch.vgic.dbase = GUEST_GICV3_GICD_BASE;
+        d->arch.vgic.rdist_regions[0].base = GUEST_GICV3_GICR0_BASE;
+        d->arch.vgic.rdist_regions[0].size = GUEST_GICV3_GICR0_SIZE;
 
         /* A single Re-distributor region is mapped for the guest. */
         BUILD_BUG_ON(GUEST_GICV3_RDIST_REGIONS != 1);