Skip to contentSkip to conversation

xen: arm: add a quirk to handle platforms with unusual GIC layout

PATCH Superseded Ian Campbell 3 participants 6 messages Nov 22, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/15 xen: arm: add a quirk to handle platforms with unusual GIC layout

Use this quirk on the xgene platform.

This should ideally be fixed by an extension to the device tree bindings as described in http://www.spinics.net/lists/devicetree/msg10473.html especially
http://www.spinics.net/lists/devicetree/msg10478.html. However for the time being a platform specific quirk will do.

---
v2: This replaces "xen: arm: GICC_DIR register at offset 0x10000 instead of 0x1000"

---
 xen/arch/arm/gic.c                   |    6 +++++-
 xen/arch/arm/platforms/xgene-storm.c |    2 +-
 xen/include/asm-arm/platform.h       |    5 +++++
 3 files changed, 11 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +5 -1
index ab49106..9711f5d 100644
@@ -30,6 +30,7 @@
 #include <xen/device_tree.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
+#include <asm/platform.h>
 
 #include <asm/gic.h>
 
@@ -444,7 +445,10 @@ void __init gic_init(void)
     BUILD_BUG_ON(FIXMAP_ADDR(FIXMAP_GICC1) !=
                  FIXMAP_ADDR(FIXMAP_GICC2)-PAGE_SIZE);
     set_fixmap(FIXMAP_GICC1, gic.cbase >> PAGE_SHIFT, DEV_SHARED);
-    set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 1, DEV_SHARED);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) )
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x10, DEV_SHARED);
+    else
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x1, DEV_SHARED);
     set_fixmap(FIXMAP_GICH, gic.hbase >> PAGE_SHIFT, DEV_SHARED);
 
     /* Global settings: interrupt distributor */
xen/arch/arm/platforms/xgene-storm.c +1 -1
index 727ac2b..d185a4a 100644
@@ -27,7 +27,7 @@
 
 static uint32_t xgene_storm_quirks(void)
 {
-    return PLATFORM_QUIRK_DOM0_MAPPING_11;
+    return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE;
 }
 
 
xen/include/asm-arm/platform.h +5 -0
index c282b30..c9314e5 100644
@@ -44,6 +44,11 @@ struct platform_desc {
  * Useful on platform where System MMU is not yet implemented
  */
 #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0)
+/*
+ * Quirk for platforms where the 4K GIC register ranges are placed at
+ * 64K stride.
+ */
+#define PLATFORM_QUIRK_GIC_64K_STRIDE (1 << 1)
 
 void __init platform_init(void);
 int __init platform_init_time(void);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 1 line · Ian Campbell

Use this quirk on the xgene platform.

With this quirk you only fix xen GIC. What about dom0/guest GIC ? I know that Linux is not using the secondary page, but we expose 2 pages contiguous page. With this quirk the first page is valid ... but the second page could belong to another device.

Can we remove the second page when the quirk is enabled?

Quoted 67 lines

This should ideally be fixed by an extension to the device tree bindings as described in http://www.spinics.net/lists/devicetree/msg10473.html especially
http://www.spinics.net/lists/devicetree/msg10478.html. However for the time being a platform specific quirk will do.

---
v2: This replaces "xen: arm: GICC_DIR register at offset 0x10000 instead of 0x1000"

---
  xen/arch/arm/gic.c                   |    6 +++++-
  xen/arch/arm/platforms/xgene-storm.c |    2 +-
  xen/include/asm-arm/platform.h       |    5 +++++
  3 files changed, 11 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +5 -1
index ab49106..9711f5d 100644
@@ -30,6 +30,7 @@
  #include <xen/device_tree.h>
  #include <asm/p2m.h>
  #include <asm/domain.h>
+#include <asm/platform.h>
 
  #include <asm/gic.h>
 
@@ -444,7 +445,10 @@ void __init gic_init(void)
      BUILD_BUG_ON(FIXMAP_ADDR(FIXMAP_GICC1) !=
                   FIXMAP_ADDR(FIXMAP_GICC2)-PAGE_SIZE);
      set_fixmap(FIXMAP_GICC1, gic.cbase >> PAGE_SHIFT, DEV_SHARED);
-    set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 1, DEV_SHARED);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) )
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x10, DEV_SHARED);
+    else
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x1, DEV_SHARED);
      set_fixmap(FIXMAP_GICH, gic.hbase >> PAGE_SHIFT, DEV_SHARED);
 
      /* Global settings: interrupt distributor */
xen/arch/arm/platforms/xgene-storm.c +1 -1
index 727ac2b..d185a4a 100644
@@ -27,7 +27,7 @@
 
  static uint32_t xgene_storm_quirks(void)
  {
-    return PLATFORM_QUIRK_DOM0_MAPPING_11;
+    return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE;
  }
 
 
xen/include/asm-arm/platform.h +5 -0
index c282b30..c9314e5 100644
@@ -44,6 +44,11 @@ struct platform_desc {
   * Useful on platform where System MMU is not yet implemented
   */
  #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0)
+/*
+ * Quirk for platforms where the 4K GIC register ranges are placed at
+ * 64K stride.
+ */
+#define PLATFORM_QUIRK_GIC_64K_STRIDE (1 << 1)
 
  void __init platform_init(void);
  int __init platform_init_time(void);
Signature · 1 line
Julien Grall
#5 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell

Use this quirk on the xgene platform.

This should ideally be fixed by an extension to the device tree bindings as described in http://www.spinics.net/lists/devicetree/msg10473.html especially
http://www.spinics.net/lists/devicetree/msg10478.html. However for the time being a platform specific quirk will do.

Quoted 69 lines

---
v2: This replaces "xen: arm: GICC_DIR register at offset 0x10000 instead of 0x1000"

---
 xen/arch/arm/gic.c                   |    6 +++++-
 xen/arch/arm/platforms/xgene-storm.c |    2 +-
 xen/include/asm-arm/platform.h       |    5 +++++
 3 files changed, 11 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +5 -1
index ab49106..9711f5d 100644
@@ -30,6 +30,7 @@
 #include <xen/device_tree.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
+#include <asm/platform.h>
 
 #include <asm/gic.h>
 
@@ -444,7 +445,10 @@ void __init gic_init(void)
     BUILD_BUG_ON(FIXMAP_ADDR(FIXMAP_GICC1) !=
                  FIXMAP_ADDR(FIXMAP_GICC2)-PAGE_SIZE);
     set_fixmap(FIXMAP_GICC1, gic.cbase >> PAGE_SHIFT, DEV_SHARED);
-    set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 1, DEV_SHARED);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) )
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x10, DEV_SHARED);
+    else
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x1, DEV_SHARED);
     set_fixmap(FIXMAP_GICH, gic.hbase >> PAGE_SHIFT, DEV_SHARED);
 
     /* Global settings: interrupt distributor */
xen/arch/arm/platforms/xgene-storm.c +1 -1
index 727ac2b..d185a4a 100644
@@ -27,7 +27,7 @@
 
 static uint32_t xgene_storm_quirks(void)
 {
-    return PLATFORM_QUIRK_DOM0_MAPPING_11;
+    return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE;
 }
 
 
xen/include/asm-arm/platform.h +5 -1
index c282b30..c9314e5 100644
@@ -44,6 +44,11 @@ struct platform_desc {
  * Useful on platform where System MMU is not yet implemented
  */
 #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0)
+/*
+ * Quirk for platforms where the 4K GIC register ranges are placed at
+ * 64K stride.
+ */
+#define PLATFORM_QUIRK_GIC_64K_STRIDE (1 << 1)
 
 void __init platform_init(void);
 int __init platform_init_time(void);
--

1.7.10.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Julien Grall
Quoted 8 lines · Julien Grall
Quoted 1 line · Ian Campbell

Use this quirk on the xgene platform.

With this quirk you only fix xen GIC. What about dom0/guest GIC ? I know that Linux is not using the secondary page, but we expose 2 pages contiguous page. With this quirk the first page is valid ... but the second page could belong to another device.

Damn, good point.

Quoted 1 line

Can we remove the second page when the quirk is enabled?

I think what I will do is make gicv_setup map the two discontiguous 4K regions contiguously into the guest space. This is consistent with the DTB we expose to the guest.

The reason for the discontinuity at the h/w level is (AFAICT) to support OSes using 64K pages and/or granules. I think we can live without these for the time being.

Ian.

Quoted 69 lines
Quoted 68 lines

This should ideally be fixed by an extension to the device tree bindings as described in http://www.spinics.net/lists/devicetree/msg10473.html especially
http://www.spinics.net/lists/devicetree/msg10478.html. However for the time being a platform specific quirk will do.

---
v2: This replaces "xen: arm: GICC_DIR register at offset 0x10000 instead of 0x1000"

---
  xen/arch/arm/gic.c                   |    6 +++++-
  xen/arch/arm/platforms/xgene-storm.c |    2 +-
  xen/include/asm-arm/platform.h       |    5 +++++
  3 files changed, 11 insertions(+), 2 deletions(-)
xen/arch/arm/gic.c +5 -1
index ab49106..9711f5d 100644
@@ -30,6 +30,7 @@
  #include <xen/device_tree.h>
  #include <asm/p2m.h>
  #include <asm/domain.h>
+#include <asm/platform.h>
 
  #include <asm/gic.h>
 
@@ -444,7 +445,10 @@ void __init gic_init(void)
      BUILD_BUG_ON(FIXMAP_ADDR(FIXMAP_GICC1) !=
                   FIXMAP_ADDR(FIXMAP_GICC2)-PAGE_SIZE);
      set_fixmap(FIXMAP_GICC1, gic.cbase >> PAGE_SHIFT, DEV_SHARED);
-    set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 1, DEV_SHARED);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GIC_64K_STRIDE) )
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x10, DEV_SHARED);
+    else
+        set_fixmap(FIXMAP_GICC2, (gic.cbase >> PAGE_SHIFT) + 0x1, DEV_SHARED);
      set_fixmap(FIXMAP_GICH, gic.hbase >> PAGE_SHIFT, DEV_SHARED);
 
      /* Global settings: interrupt distributor */
xen/arch/arm/platforms/xgene-storm.c +1 -1
index 727ac2b..d185a4a 100644
@@ -27,7 +27,7 @@
 
  static uint32_t xgene_storm_quirks(void)
  {
-    return PLATFORM_QUIRK_DOM0_MAPPING_11;
+    return PLATFORM_QUIRK_DOM0_MAPPING_11|PLATFORM_QUIRK_GIC_64K_STRIDE;
  }
 
 
xen/include/asm-arm/platform.h +5 -0
index c282b30..c9314e5 100644
@@ -44,6 +44,11 @@ struct platform_desc {
   * Useful on platform where System MMU is not yet implemented
   */
  #define PLATFORM_QUIRK_DOM0_MAPPING_11 (1 << 0)
+/*
+ * Quirk for platforms where the 4K GIC register ranges are placed at
+ * 64K stride.
+ */
+#define PLATFORM_QUIRK_GIC_64K_STRIDE (1 << 1)
 
  void __init platform_init(void);
  int __init platform_init_time(void);
#3 lore raw
Quoted 14 lines · Ian Campbell
Quoted 8 lines · Julien Grall
Quoted 1 line · Ian Campbell

Use this quirk on the xgene platform.

With this quirk you only fix xen GIC. What about dom0/guest GIC ? I know that Linux is not using the secondary page, but we expose 2 pages contiguous page. With this quirk the first page is valid ... but the second page could belong to another device.

Damn, good point.

Quoted 1 line

Can we remove the second page when the quirk is enabled?

Quoted 7 lines

I think what I will do is make gicv_setup map the two discontiguous 4K regions contiguously into the guest space. This is consistent with the DTB we expose to the guest.

The reason for the discontinuity at the h/w level is (AFAICT) to support OSes using 64K pages and/or granules. I think we can live without these for the time being.

I'm fine with this solution as long as we are sure there is no device memory just after the first page.

Signature · 1 line
Julien Grall
#4 lore raw
Quoted 20 lines · Julien Grall
Quoted 18 lines · Ian Campbell
Quoted 8 lines · Julien Grall
Quoted 1 line · Ian Campbell

Use this quirk on the xgene platform.

With this quirk you only fix xen GIC. What about dom0/guest GIC ? I know that Linux is not using the secondary page, but we expose 2 pages contiguous page. With this quirk the first page is valid ... but the second page could belong to another device.

Damn, good point.

Quoted 1 line

Can we remove the second page when the quirk is enabled?

I think what I will do is make gicv_setup map the two discontiguous 4K regions contiguously into the guest space. This is consistent with the DTB we expose to the guest.

Quoted 6 lines
Quoted 3 lines

The reason for the discontinuity at the h/w level is (AFAICT) to support OSes using 64K pages and/or granules. I think we can live without these for the time being.

I'm fine with this solution as long as we are sure there is no device memory just after the first page.

The way the GIC memory map is defined that isn't possible and it's not the case on this platform.

Ian.