Skip to contentSkip to conversation

xen/arm: Add GICv3 support

PATCH Superseded [email protected] 4 participants 18 messages Jul 3, 2014 – Jul 16, 2014

v6 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v6 cover xen/arm: Add GICv3 support

From: Vijaya Kumar K <[email protected]>

Add GICv3 support for arm64 platform.

Quoted 1 line

From v6 version, this patch series is split into v6a and v6.

All the GICv2 and VGIC code refactoring patches (first 17 patches) are set as v6a and GICv3 patches as v6 series.

Here GICv3 v6 patches are posted

Tested with ARM64 simulator with multicore core
and booted Dom0 kernel.

Major changes in v6:
- Added read_apr() to read ICH_APRn in GICv3
- Added asserts
- PIDR2 check for architecture value
- Remove update_cpu_lr_mask call
- Changed parameter ordering for gicv3_send_sgi()
- Save and restore ICC_SRE_EL1 register
- Computed cpumask in gicv3_send_sgi() function

Major changes in v5:
- Introduced new patch for checking platform capability for gicv3
- Introduced more patches for vgic clean up and code movement
- Added synchronization barriers and clean up in GICv3 driver
- Rebase on top of master branch + remotes/origin/no_maintenance_interrupts-v8 patch set
- Code base available in github
git clone https://github.com/vijaykilari/Xen-GICv3.git
- Fixed comments and coding style

Major changes in v4:
- Changed io handlers to take mmio address and size as parameters
- ioremap is used instead of fixmap to map GICv2 address space. Removed /4 in GICv2 register definitions
- vGIC driver now uses register size to calculate IRQ rank
- GICv2 LR register definitions are declared locally in GICv2 driver
- GICR & GICD common register handling in vgic-v3 driver are segregated in one common function
- irq_hw_controller definition is managed in GICv2 and GICv3 drivers
- Made irq_ops const
- GIC DT node is updated in respective drivers
- Comments and coding style fixes
- Rebased on remotes/origin/no_maintenance_interrupts-v8 + Julien's patch set

Major changes in v3:
- Moved io.h from xen/arch/arm to xen/include/asm-arm and renamed as mmio.h
- Made all the io handlers as domain specific and removed check handlers. Instead address and size are passed
- Cleaned up sgi handling functions in V2 gic driver and made generic
- Removed unused parameters in do_sgi call
- VGIC driver is chosen based on GIC driver initialized
- Implemented SGI handling for GICv3 to boot multicore
- Missing coding style fixes
- Rebased to remotes/origin/no_maintenance_interrupts-v6 branch of Stephano's unstable tree

Major Changes in v2:
- Added per domain io handler
- Use device api to initialize gic driver
- Avoid use of void pointer to access common data
- Moved vgic address information data from domain.h
- Coding style

Vijaya Kumar K (5):
xen/arm: Add support for GIC v3
xen/arm: Add virtual GICv3 support
xen/arm: Update Dom0 GIC dt node with GICv3 information xen/arm: add SGI handling for GICv3
xen/arm: check for GICv3 platform support

 xen/arch/arm/Makefile             |    2 +
 xen/arch/arm/domain_build.c       |   47 +-
 xen/arch/arm/gic-v2.c             |   51 ++
 xen/arch/arm/gic-v3.c             | 1277 +++++++++++++++++++++++++++++++++++++
 xen/arch/arm/gic.c                |    6 +
 xen/arch/arm/setup.c              |    5 +-
 xen/arch/arm/traps.c              |   30 +
 xen/arch/arm/vgic-v2.c            |    8 +-
 xen/arch/arm/vgic-v3.c            |  955 +++++++++++++++++++++++++++
 xen/arch/arm/vgic.c               |    5 +
 xen/include/asm-arm/cpufeature.h  |    1 +
 xen/include/asm-arm/domain.h      |    8 +
 xen/include/asm-arm/gic.h         |   24 +
 xen/include/asm-arm/gic_v3_defs.h |  166 +++++
 xen/include/asm-arm/processor.h   |   19 +-
 xen/include/asm-arm/sysregs.h     |    3 +
 xen/include/asm-arm/vgic.h        |   14 +-
 xen/include/xen/lib.h             |    2 +
 18 files changed, 2568 insertions(+), 55 deletions(-)
 create mode 100644 xen/arch/arm/gic-v3.c
 create mode 100644 xen/arch/arm/vgic-v3.c
 create mode 100644 xen/include/asm-arm/gic_v3_defs.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v6 1/5 xen/arm: Add support for GIC v3

From: Vijaya Kumar K <[email protected]>

Add support for GIC v3 specification System register access(SRE) is enabled to access cpu and virtual interface registers based on kernel GICv3 driver.

This patch adds only basic v3 support.
Does not support Interrupt Translation support (ITS)

---
Changes in v6:
- Added read_apr() to read ICH_APRn in GICv3
- Added asserts
- PIDR2 check for architecture value
- Remove update_cpu_lr_mask call
- Changed parameter ordering for gicv3_send_sgi()
- Save and restore ICC_SRE_EL1 register
- Computed cpumask in gicv3_send_sgi() function

---
 xen/arch/arm/Makefile             |    1 +
 xen/arch/arm/gic-v3.c             | 1195 +++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/domain.h      |    8 +
 xen/include/asm-arm/gic.h         |   20 +
 xen/include/asm-arm/gic_v3_defs.h |  159 +++++
 xen/include/asm-arm/processor.h   |   14 +
 xen/include/xen/lib.h             |    2 +
 7 files changed, 1399 insertions(+)
xen/arch/arm/Makefile +1 -0
index 20f59f4..1684c09 100644
@@ -11,6 +11,7 @@ obj-y += domctl.o
 obj-y += sysctl.o
 obj-y += domain_build.o
 obj-y += gic.o gic-v2.o
+obj-$(CONFIG_ARM_64) += gic-v3.o
 obj-y += io.o
 obj-y += irq.o
 obj-y += kernel.o
xen/arch/arm/gic-v3.c new file +1195 -0

1,195 lines not on this page · raw message

xen/include/asm-arm/domain.h +8 -0
index 32d0554..787e93c 100644
@@ -99,6 +99,14 @@ struct arch_domain
         /* Base address for guest GIC */
         paddr_t dbase; /* Distributor base address */
         paddr_t cbase; /* CPU base address */
+#ifdef CONFIG_ARM_64
+        /* GIC V3 addressing */
+        paddr_t dbase_size; /* Distributor base size */
+        paddr_t rbase[MAX_RDIST_COUNT];      /* Re-Distributor base address */
+        paddr_t rbase_size[MAX_RDIST_COUNT]; /* Re-Distributor size */
+        uint32_t rdist_stride;               /* Re-Distributor stride */
+        int rdist_count;                     /* No. of Re-Distributors */
+#endif
     } vgic;
 
     struct vuart {
xen/include/asm-arm/gic.h +20 -0
index a0c07bf..d5a2fcf 100644
@@ -18,6 +18,10 @@
 #ifndef __ASM_ARM_GIC_H__
 #define __ASM_ARM_GIC_H__
 
+#define NR_GIC_LOCAL_IRQS  NR_LOCAL_IRQS
+#define NR_GIC_SGI         16
+#define MAX_RDIST_COUNT    4
+
 #define GICD_CTLR       (0x000)
 #define GICD_TYPER      (0x004)
 #define GICD_IIDR       (0x008)
@@ -154,6 +158,20 @@
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7)
 
+#define DT_MATCH_GIC_V3_STRING1      "arm,gic-v3"
+
+#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V3_STRING1);
+
+/*
+ * GICv3 registers that needs to be saved/restored
+ */
+struct gic_v3 {
+    uint32_t hcr, vmcr, sre_el1;
+    uint32_t apr0[4];
+    uint32_t apr1[4];
+    uint64_t lr[16];
+};
+
 /*
  * GICv2 register that needs to be saved/restored
  * on VCPU context switch
@@ -170,6 +188,7 @@ struct gic_v2 {
  */
 union gic_state_data {
     struct gic_v2 v2;
+    struct gic_v3 v3;
 };
 
 /*
@@ -189,6 +208,7 @@ struct gic_lr {
 
 enum gic_version {
     GIC_V2,
+    GIC_V3,
 };
 
 extern enum gic_version gic_hw_version(void);
xen/include/asm-arm/gic_v3_defs.h new file +159 -0

159 lines not on this page · raw message

xen/include/asm-arm/processor.h +14 -0
index bdfff4e..ccaa9da 100644
@@ -17,6 +17,20 @@
 #define MPIDR_HWID_MASK     _AC(0xffffff,U)
 #define MPIDR_INVALID       (~MPIDR_HWID_MASK)
 
+/*
+ * Macros to extract affinity level. picked from kernel
+ */
+
+#define MPIDR_LEVEL_BITS_SHIFT  3
+#define MPIDR_LEVEL_BITS        (1 << MPIDR_LEVEL_BITS_SHIFT)
+#define MPIDR_LEVEL_MASK        ((1 << MPIDR_LEVEL_BITS) - 1)
+
+#define MPIDR_LEVEL_SHIFT(level) \
+         (((1 << level) >> 1) << MPIDR_LEVEL_BITS_SHIFT)
+
+#define MPIDR_AFFINITY_LEVEL(mpidr, level) \
+         ((mpidr >> MPIDR_LEVEL_SHIFT(level)) & MPIDR_LEVEL_MASK)
+
 /* TTBCR Translation Table Base Control Register */
 #define TTBCR_EAE    _AC(0x80000000,U)
 #define TTBCR_N_MASK _AC(0x07,U)
xen/include/xen/lib.h +2 -0
index e81b80e..7aef378 100644
@@ -67,6 +67,8 @@ do {                                                            \
 
 #define reserve_bootmem(_p,_l) ((void)0)
 
+#define SZ_64K  0x00010000
+
 struct domain;
 
 void cmdline_parse(const char *cmdline);
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

xen/include/xen/lib.h do { · line 72

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 10:37, <[email protected]> wrote:
xen/include/xen/lib.h +2 -0
@@ -67,6 +67,8 @@ do {                                                        
    \
 
 #define reserve_bootmem(_p,_l) ((void)0)
 
+#define SZ_64K  0x00010000
+

What a strange definition? What's wrong with using the literal number if indeed all you mean is "64k"?

Jan

#3 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 10:37, <[email protected]> wrote:
xen/include/xen/lib.h +0 -0
@@ -67,6 +67,8 @@ do {
    \
 
Quoted 7 lines

xen/include/xen/lib.h do { \ · line 71

Quoted 4 lines
xen/include/xen/lib.h +2 -0
 #define reserve_bootmem(_p,_l) ((void)0)
 
+#define SZ_64K  0x00010000
+

What a strange definition? What's wrong with using the literal number if indeed all you mean is "64k"?

Yes, these definitions are similar to include/linux/sizes.h in kernel

#4 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 04.07.14 at 08:19, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 10:37, <[email protected]> wrote:
xen/include/xen/lib.h +0 -0
@@ -67,6 +67,8 @@ do {
    \
 
 #define reserve_bootmem(_p,_l) ((void)0)
 
Quoted 7 lines
Quoted 5 lines

xen/include/xen/lib.h do { \ · line 71

Quoted 2 lines
xen/include/xen/lib.h +2 -0
+#define SZ_64K  0x00010000
+

What a strange definition? What's wrong with using the literal number if indeed all you mean is "64k"?

Yes, these definitions are similar to include/linux/sizes.h in kernel

With no rationale at all given in the original commit's description. _If_ you really need this, explain why in a patch adding a sizes.h similar to Linux'es instead of a random single item in a random place.

Jan

#5 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 04.07.14 at 08:19, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich

xen/include/xen/lib.h do { · line 72

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 10:37, <[email protected]> wrote:
xen/include/xen/lib.h +2 -0
@@ -67,6 +67,8 @@ do {
    \
 
 #define reserve_bootmem(_p,_l) ((void)0)
 
+#define SZ_64K  0x00010000
+

What a strange definition? What's wrong with using the literal number if indeed all you mean is "64k"?

Quoted 5 lines
Quoted 1 line

Yes, these definitions are similar to include/linux/sizes.h in kernel

With no rationale at all given in the original commit's description. _If_ you really need this, explain why in a patch adding a sizes.h similar to Linux'es instead of a random single item in a random place.

Vijay, I see this remains unaddressed in v7 of the series. Judging from the number of mails from Julien I've seen repeating comments from past iterations this is a common problem with your resubmissions.

If you don't agree with some review feedback or don't want to do it for some reason then please reply and explain why not. Either you can convince the maintainers or not. Just resending without the requested change made just means that we have to go around the review loop again and wastes the reviewers' and your time.

On the other hand if you are simply missing out on half the comments by mistake then please take more care.

For this specific patch Jan is a maintainer of this bit of Xen, so if he is unhappy with it then it can't go in.

Ian.

#6 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

Quoted 33 lines · Ian Campbell
Quoted 16 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 04.07.14 at 08:19, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich

xen/include/xen/lib.h do { · line 72

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.07.14 at 10:37, <[email protected]> wrote:
xen/include/xen/lib.h +2 -0
@@ -67,6 +67,8 @@ do {
    \
 
 #define reserve_bootmem(_p,_l) ((void)0)
 
+#define SZ_64K  0x00010000
+

What a strange definition? What's wrong with using the literal number if indeed all you mean is "64k"?

Quoted 5 lines
Quoted 1 line

Yes, these definitions are similar to include/linux/sizes.h in kernel

With no rationale at all given in the original commit's description. _If_ you really need this, explain why in a patch adding a sizes.h similar to Linux'es instead of a random single item in a random place.

Vijay, I see this remains unaddressed in v7 of the series. Judging from the number of mails from Julien I've seen repeating comments from past iterations this is a common problem with your resubmissions.

If you don't agree with some review feedback or don't want to do it for some reason then please reply and explain why not. Either you can convince the maintainers or not. Just resending without the requested change made just means that we have to go around the review loop again and wastes the reviewers' and your time.

Quoted 5 lines

On the other hand if you are simply missing out on half the comments by mistake then please take more care.

For this specific patch Jan is a maintainer of this bit of Xen, so if he is unhappy with it then it can't go in.

OK. I have updated commit message mentioning macro added in lib.h.
Anyway, I will add new file size.h as I see further GIC features drivers ported from kernel uses sizes.h file.

#7 lore raw

Re: [PATCH v6 1/5] xen/arm: Add support for GIC v3

In reply to [email protected]

Hi Vijay,

xen/arch/arm/gic-v3.c line 712

Quoted 11 lines · On 07/03/2014 09:37 AM, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +11 -0
+static void __cpuinit gicv3_hyp_init(void)
+{
+    uint32_t vtr;
+
+    vtr = READ_SYSREG32(ICH_VTR_EL2);
+    gicv3_info.nr_lrs  = (vtr & GICH_VTR_NRLRGS) + 1;
+    gicv3.nr_priorities = ((vtr >> GICH_VTR_PRIBITS_SHIFT) &
+                          GICH_VTR_PRIBITS_MASK) + 1;
+
+    if ( !((gicv3.nr_priorities > 4) && (gicv3.nr_priorities < 8)) )
+        dprintk(XENLOG_ERR, "GICv3: Invalid number of priority bits\n");

You already know that something is wrong, shouldn't you panic here? Otherwise you will hit the BUG in {save,restore}_aprn_regs later.

xen/arch/arm/gic-v3.c line 716

Quoted 4 lines
xen/arch/arm/gic-v3.c new file +4 -0
+
+    WRITE_SYSREG32(GICH_VMCR_EOI | GICH_VMCR_VENG1, ICH_VMCR_EL2);
+    WRITE_SYSREG32(GICH_HCR_EN, ICH_HCR_EL2);
+}

Regards,

Signature · 1 line
Julien Grall
#8 lore raw

PATCH v6 2/5 xen/arm: Add virtual GICv3 support

In reply to [email protected]

From: Vijaya Kumar K <[email protected]>

Add virtual GICv3 driver support.
Also, with this patch vgic_irq_rank structure is modified to hold GICv2 GICD_TARGET and GICv3 GICD_ROUTER registers under union.

This patch adds only basic GICv3 support. Does not support Interrupt Translation support (ITS)

---
 xen/arch/arm/Makefile      |    1 +
 xen/arch/arm/vgic-v2.c     |    8 +-
 xen/arch/arm/vgic-v3.c     |  902 ++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/vgic.c        |    5 +
 xen/include/asm-arm/vgic.h |   13 +-
 5 files changed, 924 insertions(+), 5 deletions(-)
xen/arch/arm/Makefile +1 -0
index 1684c09..ba61e58 100644
@@ -28,6 +28,7 @@ obj-y += smp.o
 obj-y += shutdown.o
 obj-y += traps.o
 obj-y += vgic.o vgic-v2.o
+obj-$(CONFIG_ARM_64) += vgic-v3.o
 obj-y += vtimer.o
 obj-y += vuart.o
 obj-y += hvm.o
xen/arch/arm/vgic-v2.c +4 -4
index 5959ca7..9dbe5b3 100644
@@ -133,7 +133,7 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info)
         if ( rank == NULL) goto read_as_zero;
 
         vgic_lock_rank(v, rank);
-        *r = rank->itargets[REG_RANK_INDEX(8, gicd_reg - GICD_ITARGETSR,
+        *r = rank->v2.itargets[REG_RANK_INDEX(8, gicd_reg - GICD_ITARGETSR,
                                            DABT_WORD)];
         if ( dabt.size == DABT_BYTE )
             *r = vgic_byte_read(*r, dabt.sign, gicd_reg);
@@ -361,10 +361,10 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
         if ( rank == NULL) goto write_ignore;
         vgic_lock_rank(v, rank);
         if ( dabt.size == DABT_WORD )
-            rank->itargets[REG_RANK_INDEX(8, gicd_reg - GICD_ITARGETSR,
+            rank->v2.itargets[REG_RANK_INDEX(8, gicd_reg - GICD_ITARGETSR,
                                           DABT_WORD)] = *r;
         else
-            vgic_byte_write(&rank->itargets[REG_RANK_INDEX(8,
+            vgic_byte_write(&rank->v2.itargets[REG_RANK_INDEX(8,
                        gicd_reg - GICD_ITARGETSR, DABT_WORD)], *r, gicd_reg);
         vgic_unlock_rank(v, rank);
         return 1;
@@ -466,7 +466,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
 
     /* For SGI and PPI the target is always this CPU */
     for ( i = 0 ; i < 8 ; i++ )
-        v->arch.vgic.private_irqs->itargets[i] =
+        v->arch.vgic.private_irqs->v2.itargets[i] =
               (1<<(v->vcpu_id+0))
             | (1<<(v->vcpu_id+8))
             | (1<<(v->vcpu_id+16))
xen/arch/arm/vgic-v3.c new file +902 -0

902 lines not on this page · raw message

xen/arch/arm/vgic.c +5 -0
index 3ccabf4..87e30ba 100644
@@ -69,6 +69,11 @@ int domain_vgic_init(struct domain *d)
 
     switch ( gic_hw_version() )
     {
+#ifdef CONFIG_ARM_64
+    case GIC_V3:
+        vgic_v3_init(d);
+        break;
+#endif
     case GIC_V2:
         vgic_v2_init(d);
         break;
xen/include/asm-arm/vgic.h +12 -1
index d310ca1..2fc6b72 100644
@@ -83,7 +83,14 @@ struct vgic_irq_rank {
     uint32_t ienable, iactive, ipend, pendsgi;
     uint32_t icfg[2];
     uint32_t ipriority[8];
-    uint32_t itargets[8];
+    union {
+        struct {
+            uint32_t itargets[8];
+        }v2;
+        struct {
+            uint64_t irouter[32];
+        }v3;
+    };
 };
 
 struct vgic_ops {
@@ -112,6 +119,9 @@ static inline int REG_RANK_NR(int b, uint32_t n)
 {
     switch ( b )
     {
+    case 64: return n >> 6;
+    case 32: return n >> 5;
+    case 16: return n >> 4;
     case 8: return n >> 3;
     case 4: return n >> 2;
     case 2: return n >> 1;
@@ -161,6 +171,7 @@ 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);
 extern void register_vgic_ops(struct domain *d, const struct vgic_ops *ops);
 int vgic_v2_init(struct domain *d);
+int vgic_v3_init(struct domain *d);
 
 extern int vcpu_vgic_free(struct vcpu *v);
 extern int vgic_to_sgi(struct vcpu *v, register_t sgir,
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v6 3/5 xen/arm: Update Dom0 GIC dt node with GICv3 information

In reply to [email protected]

From: Vijaya Kumar K <[email protected]>

Update GIC device tree node for DOM0 with GICv3 information. GIC hw specfic device tree information is moved to respective GIC driver.

---
 xen/arch/arm/domain_build.c |   47 ++-----------------------
 xen/arch/arm/gic-v2.c       |   51 +++++++++++++++++++++++++++
 xen/arch/arm/gic-v3.c       |   80 ++++++++++++++++++++++++++++++++++++++++++-
 xen/arch/arm/gic.c          |    6 ++++
 xen/include/asm-arm/gic.h   |    8 +++--
 5 files changed, 144 insertions(+), 48 deletions(-)
xen/arch/arm/domain_build.c +2 -45
index 8c850ca..40e83f3 100644
@@ -526,9 +526,6 @@ static int make_gic_node(const struct domain *d, void *fdt,
                          const struct dt_device_node *node)
 {
     const struct dt_device_node *gic = dt_interrupt_controller;
-    const void *compatible = NULL;
-    u32 len;
-    __be32 *new_cells, *tmp;
     int res = 0;
 
     /*
@@ -543,48 +540,7 @@ static int make_gic_node(const struct domain *d, void *fdt,
 
     DPRINT("Create gic node\n");
 
-    compatible = dt_get_property(gic, "compatible", &len);
-    if ( !compatible )
-    {
-        dprintk(XENLOG_ERR, "Can't find compatible property for the gic node\n");
-        return -FDT_ERR_XEN(ENOENT);
-    }
-
-    res = fdt_begin_node(fdt, "interrupt-controller");
-    if ( res )
-        return res;
-
-    res = fdt_property(fdt, "compatible", compatible, len);
-    if ( res )
-        return res;
-
-    res = fdt_property_cell(fdt, "#interrupt-cells", 3);
-    if ( res )
-        return res;
-
-    res = fdt_property(fdt, "interrupt-controller", NULL, 0);
-
-    if ( res )
-        return res;
-
-    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;
-    DPRINT("  Set Distributor Base 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           d->arch.vgic.dbase, d->arch.vgic.dbase + PAGE_SIZE - 1);
-    dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
-
-    DPRINT("  Set Cpu Base 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           d->arch.vgic.cbase, d->arch.vgic.cbase + (PAGE_SIZE * 2) - 1);
-    dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
-
-    res = fdt_property(fdt, "reg", new_cells, len);
-    xfree(new_cells);
-
+    res = gic_make_node(d, node, fdt);
     if ( res )
         return res;
 
@@ -805,6 +761,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
     static const struct dt_device_match gic_matches[] __initconst =
     {
         DT_MATCH_GIC_V2,
+        DT_MATCH_GIC_V3,
         { /* sentinel */ },
     };
     static const struct dt_device_match timer_matches[] __initconst =
xen/arch/arm/gic-v2.c +51 -0

69 lines not on this page · raw message

xen/arch/arm/gic-v3.c +79 -1

104 lines not on this page · raw message

xen/arch/arm/gic.c +6 -0
index c0d70b8..38aa7b5 100644
@@ -616,6 +616,12 @@ void __cpuinit init_maintenance_interrupt(void)
                 "irq-maintenance", NULL);
 }
 
+int gic_make_node(const struct domain *d,const struct dt_device_node *node,
+                   void *fdt)
+{
+    return gic_hw_ops->make_dt_node(d, node, fdt);
+}
+
 /*
  * Local variables:
  * mode: C
xen/include/asm-arm/gic.h +6 -2
index d5a2fcf..51a0a26 100644
@@ -158,9 +158,9 @@
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7)
 
-#define DT_MATCH_GIC_V3_STRING1      "arm,gic-v3"
+#define DT_COMPAT_GIC_V3             "arm,gic-v3"
 
-#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_MATCH_GIC_V3_STRING1);
+#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_V3)
 
 /*
  * GICv3 registers that needs to be saved/restored
@@ -336,9 +336,13 @@ struct gic_hw_operations {
     unsigned int (*read_apr)(int apr_reg);
     /* Secondary CPU init */
     int (*secondary_init)(void);
+    int (*make_dt_node)(const struct domain *d,
+                        const struct dt_device_node *node, void *fdt);
 };
 
 void register_gic_ops(const struct gic_hw_operations *ops);
+int gic_make_node(const struct domain *d,const struct dt_device_node *node,
+                  void *fdt);
 
 #endif /* __ASSEMBLY__ */
 #endif
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v6 4/5 xen/arm: add SGI handling for GICv3

In reply to [email protected]

From: Vijaya Kumar K <[email protected]>

In ARMv8, write to ICC_SGI1R_EL1 register raises trap to EL2. Handle the trap and inject SGI to vcpu.

---
 xen/arch/arm/traps.c              |   30 +++++++++++++++++
 xen/arch/arm/vgic-v3.c            |   65 +++++++++++++++++++++++++++++++++----
 xen/include/asm-arm/gic_v3_defs.h |    7 ++++
 xen/include/asm-arm/sysregs.h     |    3 ++
 xen/include/asm-arm/vgic.h        |    1 +
 5 files changed, 100 insertions(+), 6 deletions(-)
xen/arch/arm/traps.c +30 -0
index 686d8b7..adc316b 100644
@@ -41,6 +41,7 @@
 #include "decode.h"
 #include "vtimer.h"
 #include <asm/gic.h>
+#include <asm/vgic.h>
 
 /* The base of the stack must always be double-word aligned, which means
  * that both the kernel half of struct cpu_user_regs (which is pushed in
@@ -496,6 +497,18 @@ static void inject_dabt_exception(struct cpu_user_regs *regs,
 #endif
 }
 
+static void inject_undef_exception(struct cpu_user_regs *regs,
+                                   register_t addr,
+                                   int instr_len)
+{
+    if ( is_32bit_domain(current->domain) )
+        inject_undef32_exception(regs);
+#ifdef CONFIG_ARM_64
+    else
+        inject_undef64_exception(regs, instr_len);
+#endif
+}
+
 struct reg_ctxt {
     /* Guest-side state */
     uint32_t sctlr_el1;
@@ -1591,6 +1604,7 @@ static void do_sysreg(struct cpu_user_regs *regs,
                       union hsr hsr)
 {
     register_t *x = select_user_reg(regs, hsr.sysreg.reg);
+    register_t addr;
 
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {
@@ -1641,6 +1655,22 @@ static void do_sysreg(struct cpu_user_regs *regs,
             domain_crash_synchronous();
         }
         break;
+    case HSR_SYSREG_ICC_SGI1R_EL1:
+        if ( !vgic_emulate(regs, hsr) )
+        {
+            addr = READ_SYSREG64(FAR_EL2);
+            dprintk(XENLOG_WARNING,
+                    "failed emulation of sysreg ICC_SGI1R_EL1 access\n");
+            inject_undef_exception(regs, addr, hsr.len);
+        }
+        break;
+    case HSR_SYSREG_ICC_SGI0R_EL1:
+    case HSR_SYSREG_ICC_ASGI1R_EL1:
+        /* TBD: Implement to support secure grp0/1 SGI forwarding */
+        dprintk(XENLOG_WARNING,
+                "Emulation of sysreg ICC_SGI0R_EL1/ASGI1R_EL1 not supported\n");
+        addr = READ_SYSREG64(FAR_EL2);
+        inject_undef_exception(regs, addr, hsr.len);
     default:
  bad_sysreg:
         {
xen/arch/arm/vgic-v3.c +59 -6

119 lines not on this page · raw message

xen/include/asm-arm/gic_v3_defs.h +7 -0
index 1c32e0c..b94ba20 100644
@@ -147,6 +147,13 @@
 #define GICH_VMCR_PRIORITY_MASK      0xff
 #define GICH_VMCR_PRIORITY_SHIFT     24
 
+#define ICH_SGI_IRQMODE_SHIFT        40
+#define ICH_SGI_IRQMODE_MASK         0x1
+#define ICH_SGI_TARGET_OTHERS        1
+#define ICH_SGI_TARGET_LIST          0
+#define ICH_SGI_IRQ_SHIFT            24
+#define ICH_SGI_IRQ_MASK             0xf
+#define ICH_SGI_TARGETLIST_MASK      0xffff
 #endif /* __ASM_ARM_GIC_V3_DEFS_H__ */
 
 /*
xen/include/asm-arm/sysregs.h +3 -0
index b00871c..48ea498 100644
@@ -78,6 +78,9 @@
 #define HSR_SYSREG_PMINTENCLR_EL1 HSR_SYSREG(3,0,c9,c14,2)
 #define HSR_SYSREG_MAIR_EL1       HSR_SYSREG(3,0,c10,c2,0)
 #define HSR_SYSREG_AMAIR_EL1      HSR_SYSREG(3,0,c10,c3,0)
+#define HSR_SYSREG_ICC_SGI1R_EL1  HSR_SYSREG(3,0,c12,c11,5)
+#define HSR_SYSREG_ICC_ASGI1R_EL1 HSR_SYSREG(3,1,c12,c11,6)
+#define HSR_SYSREG_ICC_SGI0R_EL1  HSR_SYSREG(3,2,c12,c11,7)
 #define HSR_SYSREG_CONTEXTIDR_EL1 HSR_SYSREG(3,0,c13,c0,1)
 
 #define HSR_SYSREG_PMCR_EL0       HSR_SYSREG(3,3,c9,c12,0)
xen/include/asm-arm/vgic.h +1 -0
index 2fc6b72..fa30616 100644
@@ -167,6 +167,7 @@ extern void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq);
 extern void vgic_clear_pending_irqs(struct vcpu *v);
 extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq);
 extern struct vgic_irq_rank *vgic_rank_offset(struct vcpu *v, int b, int n, int s);
+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);
 extern void register_vgic_ops(struct domain *d, const struct vgic_ops *ops);
Signature · 1 line
1.7.9.5
#11 lore raw

Re: [PATCH v6 4/5] xen/arm: add SGI handling for GICv3

Hi Vijay,

Quoted 27 lines · On 07/03/2014 09:37 AM, [email protected] wrote:

From: Vijaya Kumar K <[email protected]>

In ARMv8, write to ICC_SGI1R_EL1 register raises trap to EL2. Handle the trap and inject SGI to vcpu.

---
 xen/arch/arm/traps.c              |   30 +++++++++++++++++
 xen/arch/arm/vgic-v3.c            |   65 +++++++++++++++++++++++++++++++++----
 xen/include/asm-arm/gic_v3_defs.h |    7 ++++
 xen/include/asm-arm/sysregs.h     |    3 ++
 xen/include/asm-arm/vgic.h        |    1 +
 5 files changed, 100 insertions(+), 6 deletions(-)
xen/arch/arm/traps.c +1 -0
index 686d8b7..adc316b 100644
@@ -41,6 +41,7 @@
 #include "decode.h"
 #include "vtimer.h"
 #include <asm/gic.h>
+#include <asm/vgic.h>
 
 /* The base of the stack must always be double-word aligned, which means
  * that both the kernel half of struct cpu_user_regs (which is pushed in

xen/arch/arm/traps.c static void inject_dabt_exception(struct cpu_user_regs *regs, · line 502

Quoted 6 lines
xen/arch/arm/traps.c +3 -0
@@ -496,6 +497,18 @@ static void inject_dabt_exception(struct cpu_user_regs *regs,
 #endif
 }
 
+static void inject_undef_exception(struct cpu_user_regs *regs,
+                                   register_t addr,
+                                   int instr_len)

Odd, you give in parameter addr, but never use it...

Quoted 21 lines
xen/arch/arm/traps.c +10 -0
+{
+    if ( is_32bit_domain(current->domain) )
+        inject_undef32_exception(regs);
+#ifdef CONFIG_ARM_64
+    else
+        inject_undef64_exception(regs, instr_len);
+#endif
+}
+
 struct reg_ctxt {
     /* Guest-side state */
     uint32_t sctlr_el1;
@@ -1591,6 +1604,7 @@ static void do_sysreg(struct cpu_user_regs *regs,
                       union hsr hsr)
 {
     register_t *x = select_user_reg(regs, hsr.sysreg.reg);
+    register_t addr;
 
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {

xen/arch/arm/traps.c static void do_sysreg(struct cpu_user_regs *regs, · line 1664

Quoted 10 lines
xen/arch/arm/traps.c +7 -0
@@ -1641,6 +1655,22 @@ static void do_sysreg(struct cpu_user_regs *regs,
             domain_crash_synchronous();
         }
         break;
+    case HSR_SYSREG_ICC_SGI1R_EL1:
+        if ( !vgic_emulate(regs, hsr) )
+        {
+            addr = READ_SYSREG64(FAR_EL2);
+            dprintk(XENLOG_WARNING,
+                    "failed emulation of sysreg ICC_SGI1R_EL1 access\n");
+            inject_undef_exception(regs, addr, hsr.len);

AFAIK, sysreg only exist for 64 bits guest. At least the precondition to call this function is the guest is 64 bits (see the caller). So you can use directly inject_undef64_exception.

xen/arch/arm/traps.c static void do_sysreg(struct cpu_user_regs *regs, · line 1673

Quoted 9 lines
xen/arch/arm/traps.c +9 -0
+        }
+        break;
+    case HSR_SYSREG_ICC_SGI0R_EL1:
+    case HSR_SYSREG_ICC_ASGI1R_EL1:
+        /* TBD: Implement to support secure grp0/1 SGI forwarding */
+        dprintk(XENLOG_WARNING,
+                "Emulation of sysreg ICC_SGI0R_EL1/ASGI1R_EL1 not supported\n");
+        addr = READ_SYSREG64(FAR_EL2);
+        inject_undef_exception(regs, addr, hsr.len);

Same remark here.

xen/arch/arm/vgic-v3.c line 38

Quoted 13 lines
xen/arch/arm/traps.c +0 -0
     default:
  bad_sysreg:
         {
xen/arch/arm/vgic-v3.c +1 -1
index 63948ed..7beed17 100644
@@ -35,7 +35,7 @@
 #include <asm/vgic.h>
 
 static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info,
-                                        uint32_t gicr_reg)
+                                         uint32_t gicr_reg)

Spurious change.

xen/arch/arm/vgic-v3.c read_as_zero: · line 144

Quoted 9 lines
xen/arch/arm/vgic-v3.c +1 -1
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -141,7 +141,7 @@ read_as_zero:
 }
 
 static int __vgic_v3_rdistr_rd_mmio_write(struct vcpu *v, mmio_info_t *info,
-                                    uint32_t gicr_reg)
+                                          uint32_t gicr_reg)

Spurious change.

Quoted 13 lines
xen/arch/arm/vgic-v3.c +1 -1
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -214,7 +214,7 @@ write_ignore:
 }
 
 static int __vgic_v3_distr_common_mmio_read(struct vcpu *v, mmio_info_t *info,
-                                           uint32_t reg)
+                                            uint32_t reg)
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();

xen/arch/arm/vgic-v3.c read_as_zero: · line 316

Quoted 5 lines
xen/arch/arm/vgic-v3.c +1 -1
@@ -313,7 +313,7 @@ read_as_zero:
 }
 
 static int __vgic_v3_distr_common_mmio_write(struct vcpu *v, mmio_info_t *info,
-                                            uint32_t reg)
+                                             uint32_t reg)

Spurious change.

xen/arch/arm/vgic-v3.c write_ignore: · line 426

Quoted 9 lines
xen/arch/arm/vgic-v3.c +1 -1
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -423,7 +423,7 @@ write_ignore:
 }
 
 static int vgic_v3_rdistr_sgi_mmio_read(struct vcpu *v, mmio_info_t *info,
-                                     uint32_t gicr_reg)
+                                        uint32_t gicr_reg)

Spurious change.

xen/arch/arm/vgic-v3.c read_as_zero: · line 487

Quoted 9 lines
xen/arch/arm/vgic-v3.c +1 -1
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -484,7 +484,7 @@ read_as_zero:
 }
 
 static int vgic_v3_rdistr_sgi_mmio_write(struct vcpu *v, mmio_info_t *info,
-                                      uint32_t gicr_reg)
+                                         uint32_t gicr_reg)

Spurious change.

Quoted 25 lines
xen/arch/arm/vgic-v3.c +18 -0
 {
     struct hsr_dabt dabt = info->dabt;
     struct cpu_user_regs *regs = guest_cpu_user_regs();
@@ -835,6 +835,57 @@ write_ignore_64:
     return 1;
 }
 
+static int vgicv3_to_sgi(struct vcpu *v, register_t sgir)
+{
+    int virq;
+    int irqmode;
+    enum gic_sgi_mode sgi_mode;
+    unsigned long vcpu_mask = 0;
+
+    irqmode = (sgir >> ICH_SGI_IRQMODE_SHIFT) & ICH_SGI_IRQMODE_MASK;
+    virq = (sgir >> ICH_SGI_IRQ_SHIFT ) & ICH_SGI_IRQ_MASK;
+    vcpu_mask = sgir & ICH_SGI_TARGETLIST_MASK;
+
+    /* Map GIC sgi value to enum value */
+    switch ( irqmode )
+    {
+    case ICH_SGI_TARGET_LIST:
+        sgi_mode = SGI_TARGET_LIST;
+        break;
+    case ICH_SGI_TARGET_OTHERS:

xen/arch/arm/vgic-v3.c write_ignore_64: · line 865

Quoted 10 lines
xen/arch/arm/vgic-v3.c +10 -0
+        sgi_mode = SGI_TARGET_OTHERS;
+        break;
+    default:
+        BUG();
+    }
+
+    return vgic_to_sgi(v, sgir, sgi_mode, virq, vcpu_mask);
+}
+
+int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr)

Please see my comment on "[PATCH v8a 5/6] xen/arm: split vgic driver into generic and vgic-v2 driver".

Quoted 27 lines
xen/arch/arm/vgic-v3.c +23 -0
+{
+    struct vcpu *v = current;
+    struct hsr_sysreg sysreg = hsr.sysreg;
+    register_t *r = select_user_reg(regs, sysreg.reg);
+
+    ASSERT (hsr.ec == HSR_EC_SYSREG);
+
+    switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
+    {
+    case HSR_SYSREG_ICC_SGI1R_EL1:
+        /* WO */
+        if ( !sysreg.read )
+            return vgic_send_sgi(v, *r);
+        else
+        {
+            gdprintk(XENLOG_WARNING, "Reading SGI1R_EL1 - WO register\n");
+            return 0;
+        }
+    default:
+        return 0;
+    }
+}
+
 static const struct mmio_handler_ops vgic_rdistr_mmio_handler = {
     .read_handler  = vgic_v3_rdistr_mmio_read,
     .write_handler = vgic_v3_rdistr_mmio_write,

xen/arch/arm/vgic-v3.c static int vgicv3_domain_init(struct domain *d) · line 920

Quoted 4 lines
xen/arch/arm/vgic-v3.c +1 -0
@@ -866,6 +917,7 @@ static int vgicv3_domain_init(struct domain *d)
 {
     int i;
 
+     /* We rely on gicv init to get dbase and size */

Why do you add the comment in this patch. Shouldn't be part of the vgic v3 emulation?

Regards,

Signature · 1 line
Julien Grall
#12 lore raw

Re: [PATCH v6 4/5] xen/arm: add SGI handling for GICv3

Quoted 35 lines · Julien Grall

Hi Vijay,

Quoted 32 lines · On 07/03/2014 09:37 AM, [email protected] wrote:

From: Vijaya Kumar K <[email protected]>

In ARMv8, write to ICC_SGI1R_EL1 register raises trap to EL2. Handle the trap and inject SGI to vcpu.

---
 xen/arch/arm/traps.c              |   30 +++++++++++++++++
 xen/arch/arm/vgic-v3.c            |   65 +++++++++++++++++++++++++++++++++----
 xen/include/asm-arm/gic_v3_defs.h |    7 ++++
 xen/include/asm-arm/sysregs.h     |    3 ++
 xen/include/asm-arm/vgic.h        |    1 +
 5 files changed, 100 insertions(+), 6 deletions(-)
 struct reg_ctxt {
     /* Guest-side state */
     uint32_t sctlr_el1;
xen/arch/arm/traps.c +4 -0
@@ -1591,6 +1604,7 @@ static void do_sysreg(struct cpu_user_regs *regs,
                       union hsr hsr)
 {
     register_t *x = select_user_reg(regs, hsr.sysreg.reg);
+    register_t addr;
 
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {
@@ -1641,6 +1655,22 @@ static void do_sysreg(struct cpu_user_regs *regs,
             domain_crash_synchronous();
         }
         break;
+    case HSR_SYSREG_ICC_SGI1R_EL1:
+        if ( !vgic_emulate(regs, hsr) )
+        {
Quoted 8 lines

xen/arch/arm/traps.c static void do_sysreg(struct cpu_user_regs *regs, · line 1664

Quoted 4 lines
xen/arch/arm/traps.c +4 -0
+            addr = READ_SYSREG64(FAR_EL2);
+            dprintk(XENLOG_WARNING,
+                    "failed emulation of sysreg ICC_SGI1R_EL1 access\n");
+            inject_undef_exception(regs, addr, hsr.len);

AFAIK, sysreg only exist for 64 bits guest. At least the precondition to call this function is the guest is 64 bits (see the caller). So you can use directly inject_undef64_exception.

What if the Guest is running int Aarch32 bit mode and make sysreg access?

Regards
Vijay

#13 lore raw

Re: [PATCH v6 4/5] xen/arm: add SGI handling for GICv3

Quoted 45 lines · Vijay Kilari
Quoted 35 lines · Julien Grall

Hi Vijay,

Quoted 32 lines · On 07/03/2014 09:37 AM, [email protected] wrote:

From: Vijaya Kumar K <[email protected]>

In ARMv8, write to ICC_SGI1R_EL1 register raises trap to EL2. Handle the trap and inject SGI to vcpu.

---
 xen/arch/arm/traps.c              |   30 +++++++++++++++++
 xen/arch/arm/vgic-v3.c            |   65 +++++++++++++++++++++++++++++++++----
 xen/include/asm-arm/gic_v3_defs.h |    7 ++++
 xen/include/asm-arm/sysregs.h     |    3 ++
 xen/include/asm-arm/vgic.h        |    1 +
 5 files changed, 100 insertions(+), 6 deletions(-)
 struct reg_ctxt {
     /* Guest-side state */
     uint32_t sctlr_el1;
xen/arch/arm/traps.c +4 -0
@@ -1591,6 +1604,7 @@ static void do_sysreg(struct cpu_user_regs *regs,
                       union hsr hsr)
 {
     register_t *x = select_user_reg(regs, hsr.sysreg.reg);
+    register_t addr;
 
     switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
     {
@@ -1641,6 +1655,22 @@ static void do_sysreg(struct cpu_user_regs *regs,
             domain_crash_synchronous();
         }
         break;
+    case HSR_SYSREG_ICC_SGI1R_EL1:
+        if ( !vgic_emulate(regs, hsr) )
+        {
Quoted 8 lines

xen/arch/arm/traps.c static void do_sysreg(struct cpu_user_regs *regs, · line 1664

Quoted 4 lines
xen/arch/arm/traps.c +4 -0
+            addr = READ_SYSREG64(FAR_EL2);
+            dprintk(XENLOG_WARNING,
+                    "failed emulation of sysreg ICC_SGI1R_EL1 access\n");
+            inject_undef_exception(regs, addr, hsr.len);

AFAIK, sysreg only exist for 64 bits guest. At least the precondition to call this function is the guest is 64 bits (see the caller). So you can use directly inject_undef64_exception.

Quoted 2 lines

What if the Guest is running int Aarch32 bit mode and make sysreg access?

Won't that trap as a MCRR/MRRC access rather than a sysreg access? Those would come via a different HSR.EC code and would need plumbing in there not here.

Ian.

#14 lore raw

PATCH v6 5/5 xen/arm: check for GICv3 platform support

In reply to [email protected]

From: Vijaya Kumar K <[email protected]>

ID_AA64PFR0_EL1 register provides information about GIC support. Check for this register in GICv3 driver.

Also print GICv3 support information in boot log

---
 xen/arch/arm/gic-v3.c            |    4 ++++
 xen/arch/arm/setup.c             |    5 +++--
 xen/include/asm-arm/cpufeature.h |    1 +
 xen/include/asm-arm/processor.h  |    5 ++---
 4 files changed, 10 insertions(+), 5 deletions(-)
xen/arch/arm/gic-v3.c +4 -0
index 8fd10c4..fde032d 100644
@@ -38,6 +38,7 @@
 #include <asm/device.h>
 #include <asm/gic.h>
 #include <asm/gic_v3_defs.h>
+#include <asm/cpufeature.h>
 
 struct rdist_region {
     paddr_t base;
@@ -1153,6 +1154,9 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data)
     int res, i;
     uint32_t reg;
 
+    if ( !cpu_has_gicv3 )
+        panic("Platform does not support GICv3\n");
+
     dt_device_set_used_by(node, DOMID_XEN);
 
     res = dt_device_get_address(node, 0, &gicv3.dbase, &gicv3.dbase_size);
xen/arch/arm/setup.c +3 -2
index 78dc7f5..6a90c81 100644
@@ -100,9 +100,10 @@ static void __init processor_id(void)
            cpu_has_el2_32 ? "64+32" : cpu_has_el2_64 ? "64" : "No",
            cpu_has_el1_32 ? "64+32" : cpu_has_el1_64 ? "64" : "No",
            cpu_has_el0_32 ? "64+32" : cpu_has_el0_64 ? "64" : "No");
-    printk("    Extensions:%s%s\n",
+    printk("    Extensions:%s%s%s\n",
            cpu_has_fp ? " FloatingPoint" : "",
-           cpu_has_simd ? " AdvancedSIMD" : "");
+           cpu_has_simd ? " AdvancedSIMD" : "",
+           cpu_has_gicv3 ? " GICv3" : "");
 
     printk("  Debug Features: %016"PRIx64" %016"PRIx64"\n",
            boot_cpu_data.dbg64.bits[0], boot_cpu_data.dbg64.bits[1]);
xen/include/asm-arm/cpufeature.h +1 -0
index 1d2c9c7..bd84c57 100644
@@ -15,6 +15,7 @@
 #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
 #define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
 #define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
+#define cpu_has_gicv3     (boot_cpu_feature64(gicv3) == 1)
 #endif
 
 #define cpu_feature32(c, feat)         ((c)->pfr32.feat)
xen/include/asm-arm/processor.h +2 -3
index ccaa9da..0188800 100644
@@ -188,9 +188,8 @@ struct cpuinfo_arm {
             unsigned long el3:4;
             unsigned long fp:4;   /* Floating Point */
             unsigned long simd:4; /* Advanced SIMD */
-            unsigned long __res0:8;
-
-            unsigned long __res1;
+            unsigned long gicv3:4; /* GIC support */
+            unsigned long __res0:36;
         };
     } pfr64;
 
Signature · 1 line
1.7.9.5
#15 lore raw

Re: [PATCH v6 5/5] xen/arm: check for GICv3 platform support

Hi Vijay,

Quoted 20 lines · On 07/03/2014 09:37 AM, [email protected] wrote:
---
 xen/arch/arm/gic-v3.c            |    4 ++++
 xen/arch/arm/setup.c             |    5 +++--
 xen/include/asm-arm/cpufeature.h |    1 +
 xen/include/asm-arm/processor.h  |    5 ++---
 4 files changed, 10 insertions(+), 5 deletions(-)
xen/arch/arm/gic-v3.c +1 -0
index 8fd10c4..fde032d 100644
@@ -38,6 +38,7 @@
 #include <asm/device.h>
 #include <asm/gic.h>
 #include <asm/gic_v3_defs.h>
+#include <asm/cpufeature.h>
 
 struct rdist_region {
     paddr_t base;

xen/arch/arm/gic-v3.c static int __init gicv3_init(struct dt_device_node *node, const void *data) · line 1158

Quoted 5 lines
xen/arch/arm/gic-v3.c +2 -0
@@ -1153,6 +1154,9 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data)
     int res, i;
     uint32_t reg;
 
+    if ( !cpu_has_gicv3 )
+        panic("Platform does not support GICv3\n");

printk(XENLOG_ERR, "Platform does not support GICv3\n"); return -ENODEV;

?

Signature · 1 line
Julien Grall
#16 lore raw
In reply to [email protected]

Hi Vijay,

Quoted 11 lines · On 07/03/2014 09:37 AM, [email protected] wrote:

From: Vijaya Kumar K <[email protected]>

Add GICv3 support for arm64 platform.
From v6 version, this patch series is split into v6a and v6. All the GICv2 and VGIC code refactoring patches (first 17 patches) are set as v6a and GICv3 patches as v6 series.

Here GICv3 v6 patches are posted

Tested with ARM64 simulator with multicore core
and booted Dom0 kernel.

AFAIU the series, it's possible to boot DOM0 with GICv3, but guest boot will be broken. Any plan to add support for guest?

Regards,

Signature · 1 line
Julien Grall
#17 lore raw
Quoted 10 lines · Julien Grall

Hi Vijay,

Quoted 7 lines · On 07/03/2014 09:37 AM, [email protected] wrote:

From: Vijaya Kumar K <[email protected]>

Add GICv3 support for arm64 platform.
From v6 version, this patch series is split into v6a and v6. All the GICv2 and VGIC code refactoring patches (first 17 patches) are set as v6a and GICv3 patches as v6 series.

Quoted 7 lines
Quoted 4 lines

Here GICv3 v6 patches are posted

Tested with ARM64 simulator with multicore core
and booted Dom0 kernel.

AFAIU the series, it's possible to boot DOM0 with GICv3, but guest boot will be broken. Any plan to add support for guest?

Yes, I plan to do it. I see changes are required to tools/libxl/libxl_arm.c and to keep compatibility with GICv2,
Ian has suggested to query GIC version and based on this generate DT for guest.

Regards
Vijay