xen: arm: remove hardcoded gnttab location from dom0
authorIan Campbell <ian.campbell@citrix.com>
Wed, 4 Dec 2013 17:03:02 +0000 (17:03 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 6 Dec 2013 11:45:21 +0000 (11:45 +0000)
The DT provided to guests (including dom0) includes a Xen node which, among
other things, describes an MMIO region which can be safely used for grant
table mappings (i.e. it is a hole in the physical address space). For domU we
provide a hardcoded values based on our hardcoded guest virtual machine
layout. However for dom0 we need to fit in with the underlying platform.
Leaving this hardcoded was an oversight which on some platforms could result
in the grant table overlaying RAM or MMIO regions which are in use by domain
0.

For the 4.4 release do as we did with the dom0 evtchn PPI and provide a hook
for the platform code to supply a suitable hardcoded address for the platform
(derived from reading the data sheet). Platforms which do not provide the hook
get the existing address as a default.

After 4.4 we should switch to selecting a region of host RAM which is not RAM
in the guest address map. This should be more flexible and safer but the patch
was looking too complex for 4.4.

Platform        Gnttab Address
========        ==============
exynos5.c       0xb0000000, confirmed and tested by Julien.
sunxi.c         0x01d00000, confirmed in data sheet.
midway.c        0xff800000, confirmed by Andre, boot tested by Ian.
vexpress.c      0xb0000000, existing hardcoded value was selected for vexpress.
omap5.c         0x4b000000, confirmed by Baozi
xgene-storm.c   0x1f800000, confirmed by Pranavkumar

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Julien.Grall@linaro.org
Cc: Stefano.Stabellini@eu.citrix.com
Cc: Andre Przywara <andre.przywara@linaro.org>
Acked-by: Chen Baozi <baozich@gmail.com>
Acked-by: Pranavkumar Sawargaonkar <psawargaonkar@apm.com>
Cc: Anup Patel <apatel@apm.com>
xen/arch/arm/domain_build.c
xen/arch/arm/platform.c
xen/arch/arm/platforms/midway.c
xen/arch/arm/platforms/omap5.c
xen/arch/arm/platforms/sunxi.c
xen/arch/arm/platforms/xgene-storm.c
xen/include/asm-arm/platform.h

index 532e8110a04a516c2f9f494d3a77ab72a172df1c..d50658bfea5c6b1600e9c17d3125b22dccad0bcd 100644 (file)
@@ -331,6 +331,7 @@ static int make_hypervisor_node(struct domain *d,
     int res;
     int addrcells = dt_n_addr_cells(parent);
     int sizecells = dt_n_size_cells(parent);
+    paddr_t gnttab_start, gnttab_size;
 
     DPRINT("Create hypervisor node\n");
 
@@ -352,10 +353,12 @@ static int make_hypervisor_node(struct domain *d,
     if ( res )
         return res;
 
-    DPRINT("  Grant table range: 0xb0000000-0x20000\n");
+    platform_dom0_gnttab(&gnttab_start, &gnttab_size);
+    DPRINT("  Grant table range: %#"PRIpaddr"-%#"PRIpaddr"\n",
+           gnttab_start, gnttab_start + gnttab_size);
     /* reg 0 is grant table space */
     cells = &reg[0];
-    dt_set_range(&cells, parent, 0xb0000000, 0x20000);
+    dt_set_range(&cells, parent, gnttab_start, gnttab_size);
     res = fdt_property(fdt, "reg", reg,
                        dt_cells_to_size(addrcells + sizecells));
     if ( res )
index 1122bbd976b75b2cc716bb15d18b2474513864b0..74c33282002fb9087a93533b4d783ad0e4ca7fff 100644 (file)
@@ -167,6 +167,20 @@ unsigned int platform_dom0_evtchn_ppi(void)
     return GUEST_EVTCHN_PPI;
 }
 
+void platform_dom0_gnttab(paddr_t *start, paddr_t *size)
+{
+    if ( platform && platform->dom0_gnttab_size )
+    {
+        *start = platform->dom0_gnttab_start;
+        *size = platform->dom0_gnttab_size;
+    }
+    else
+    {
+        *start = 0xb0000000;
+        *size = 0x20000;
+    }
+}
+
 /*
  * Local variables:
  * mode: C
index b221279ec7ad5327d6536de942585540568da0c4..42f76975fb38697a8e271dc5cedef803abf5d645 100644 (file)
@@ -51,6 +51,9 @@ static const char * const midway_dt_compat[] __initconst =
 PLATFORM_START(midway, "CALXEDA MIDWAY")
     .compatible = midway_dt_compat,
     .reset = midway_reset,
+
+    .dom0_gnttab_start = 0xff800000,
+    .dom0_gnttab_size = 0x20000,
 PLATFORM_END
 
 /*
index 423d11b144e4136e58034c2c9ce9b1803fec34d9..76d4d9b125aab478c9ef563ed6ea6c01e8c64785 100644 (file)
@@ -156,6 +156,9 @@ PLATFORM_START(omap5, "TI OMAP5")
     .specific_mapping = omap5_specific_mapping,
     .smp_init = omap5_smp_init,
     .cpu_up = cpu_up_send_sgi,
+
+    .dom0_gnttab_start = 0x4b000000,
+    .dom0_gnttab_size = 0x20000,
 PLATFORM_END
 
 /*
index b466518757e71ed56d8ae69c15796793385b70f0..fb1280185e3f84bb1439cb6952ff92a353c7f344 100644 (file)
@@ -37,6 +37,9 @@ static const struct dt_device_match sunxi_blacklist_dev[] __initconst =
 PLATFORM_START(sunxi, "Allwinner A20")
     .compatible = sunxi_dt_compat,
     .blacklist_dev = sunxi_blacklist_dev,
+
+    .dom0_gnttab_start = 0x01d00000,
+    .dom0_gnttab_size = 0x20000,
 PLATFORM_END
 
 /*
index f760fcd2eb699dd0219845b579c74549b64d9059..5b0bd5f118fea21a469bfde67dce25685073e31b 100644 (file)
@@ -118,7 +118,10 @@ PLATFORM_START(xgene_storm, "APM X-GENE STORM")
     .compatible = xgene_storm_dt_compat,
     .quirks = xgene_storm_quirks,
     .specific_mapping = xgene_storm_specific_mapping,
+
     .dom0_evtchn_ppi = 24,
+    .dom0_gnttab_start = 0x1f800000,
+    .dom0_gnttab_size = 0x20000,
 PLATFORM_END
 
 /*
index edb399b9bbbfa39966b44ee74a696465542dd438..bcd209703922da45a9f612ce5fc1d9a7ab8466ee 100644 (file)
@@ -41,6 +41,12 @@ struct platform_desc {
      * The IRQ (PPI) to use to inject event channels to dom0.
      */
     unsigned int dom0_evtchn_ppi;
+    /*
+     * The location of a region of physical address space which dom0
+     * can use for grant table mappings. If size is zero defaults to
+     * 0xb0000000-0xb0020000.
+     */
+    paddr_t dom0_gnttab_start, dom0_gnttab_size;
 };
 
 /*
@@ -61,6 +67,7 @@ void platform_poweroff(void);
 bool_t platform_has_quirk(uint32_t quirk);
 bool_t platform_device_is_blacklisted(const struct dt_device_node *node);
 unsigned int platform_dom0_evtchn_ppi(void);
+void platform_dom0_gnttab(paddr_t *start, paddr_t *size);
 
 #define PLATFORM_START(_name, _namestr)                         \
 static const struct platform_desc  __plat_desc_##_name __used   \