diff mbox

[Xen-devel,v3,8/8] xen/arm: Handle translated addresses for hardware domains

Message ID B944B469BF5302468AC6EB05E56CC70D17B3E4@lhreml509-mbb
State New
Headers show

Commit Message

Frediano Ziglio Nov. 5, 2014, 4:02 p.m. UTC
> On 11/05/2014 03:51 PM, Julien Grall wrote:
> >> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index
> >> 2f6bbd5..9b9e696 100644
> >> --- a/xen/arch/arm/gic-v2.c
> >> +++ b/xen/arch/arm/gic-v2.c
> >> @@ -629,9 +629,8 @@ static int gicv2_make_dt_node(const struct
> domain *d,
> >>                                const struct dt_device_node *node,
> >> void *fdt)  {
> >>      const struct dt_device_node *gic = dt_interrupt_controller;
> >> -    const void *compatible = NULL;
> >> +    const void *compatible = NULL, *tmp;
> >>      u32 len;
> >> -    __be32 *new_cells, *tmp;
> >
> > I would prefer if you keep tmp as __be32 *. It documents the real
> type
> > of the data. Also, for clarity, I would rename it to cells.
> 
> s/cells/regs/.  Sorry
> 
> --
> Julien Grall

This version should be perfect then.


Subject: [PATCH 7/7] xen/arm: Handle translated addresses for hardware domains in GICv2

Translated address could have an offset applied to them.
Replicate same value for device node to avoid improper address
computation in the OS.

Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>
---
 xen/arch/arm/gic-v2.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 2f6bbd5..c2666df 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -631,7 +631,7 @@  static int gicv2_make_dt_node(const struct domain *d,
     const struct dt_device_node *gic = dt_interrupt_controller;
     const void *compatible = NULL;
     u32 len;
-    __be32 *new_cells, *tmp;
+    const __be32 *regs;
     int res = 0;
 
     compatible = dt_get_property(gic, "compatible", &len);
@@ -664,18 +664,18 @@  static int gicv2_make_dt_node(const struct domain *d,
     if ( res )
         return res;
 
+    /* copy GICC and GICD regions */
+    regs = dt_get_property(gic, "reg", &len);
+    if ( !regs )
+    {
+        dprintk(XENLOG_ERR, "Can't find reg property for the gic node\n");
+        return -FDT_ERR_XEN(ENOENT);
+    }
+
     len = dt_cells_to_size(dt_n_addr_cells(node) + dt_n_size_cells(node));
     len *= 2; /* GIC has two memory regions: Distributor + CPU interface */
-    new_cells = xzalloc_bytes(len);
-    if ( new_cells == NULL )
-        return -FDT_ERR_XEN(ENOMEM);
-
-    tmp = new_cells;
-    dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
-    dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
 
-    res = fdt_property(fdt, "reg", new_cells, len);
-    xfree(new_cells);
+    res = fdt_property(fdt, "reg", regs, len);
 
     return res;
 }