xen/arm: Add GICv3 support
v11 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 of v6a are merged.
The v8 version of GICv3 patches are posted here.
Tested with ARM64 simulator with multicore core
and booted Dom0 kernel.
Major changes in v11:
- use vgic_rank_irq
- rename vgicv3_..() to vgic_v3_..()
Major changes in v10:
- Made irq rank calculation generic
- Fixed issue of rank calculation for 64 bit reg size
- Implemented callback for reading irq priority and getting vcpu target for vgic-v3
Major changes in v9:
- Rebased on top of Stephano's patches in staging branch
- Added 2 more fixes for generic GICv2 code to make it generic for GICV3
- Fixed alignment
- Removed unsed PIDR2 macros
Major changes in v8:
- Introduced assembler aliases for GIC system registers to be able to compile with Linaro toolchain
- Few PIDRn macros definitions are moved to vgic-v3.c
- Introduced 2 more patches. Patch 1 for introducing sizes.h file and Patch 2 for {READ,WRITE}_SYSREG macro changes
Major changes in v7:
- Introduced vgic callback to handle sysreg emulation
- Coding style fixes
- undef64_exception instead of undef_exception for sysreg error
Vijaya Kumar K (7):
xen/arm: Calculate irq rank from irq number xen/arm: Add vgic callback to read irq priority 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 | 1285 +++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 6 + xen/arch/arm/setup.c | 5 +- xen/arch/arm/traps.c | 15 + xen/arch/arm/vgic-v2.c | 35 +- xen/arch/arm/vgic-v3.c | 1007 +++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 38 +- 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 | 161 +++++ xen/include/asm-arm/processor.h | 17 +- xen/include/asm-arm/sysregs.h | 56 ++ xen/include/asm-arm/vgic.h | 23 +- 17 files changed, 2711 insertions(+), 70 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
PATCH v11 1/7 xen/arm: Calculate irq rank from irq number
From: Vijaya Kumar K <[email protected]>
irq rank calculated is not generic and assumes
hardware register size value which does not work
for future GIC versions like V3.
--- xen/arch/arm/vgic.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
xen/arch/arm/vgic.c +14 -7
@@ -31,6 +31,16 @@#include <asm/gic.h> #include <asm/vgic.h> +static inline struct vgic_irq_rank *vgic_get_rank (struct vcpu *v,int rank) +{ +if ( rank ==0 ) +return v->arch.vgic.private_irqs; +else if ( rank <=DOMAIN_NR_RANKS (v->domain) ) +return &v->domain->arch.vgic.shared_irqs[rank -1 ]; +else +return NULL ; +} +/* * Returns rank corresponding to a GICD_<FOO><n> register for * GICD_<FOO> with <b>-bits-per-interrupt.
@@ -40,17 +50,14 @@ struct vgic_irq_rank *vgic_rank_offset(struct vcpu *v, int b, int n, {int rank =REG_RANK_NR (b, (n >> s)); -if ( rank ==0 ) -return v->arch.vgic.private_irqs; -else if ( rank <=DOMAIN_NR_RANKS (v->domain) ) -return &v->domain->arch.vgic.shared_irqs[rank -1 ]; -else -return NULL ; +return vgic_get_rank (v, rank); }struct vgic_irq_rank *vgic_rank_irq (struct vcpu *v,unsigned int irq) { -return vgic_rank_offset (v,8 , irq,DABT_WORD ); +int rank = irq/32 ; + +return vgic_get_rank (v, rank); }int domain_vgic_init (struct domain *d)
Signature · 1 line
1.7.9.5
PATCH v11 2/7 xen/arm: Add vgic callback to read irq priority
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irq
---
v11: use vgic_irq_rank
--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)
xen/arch/arm/vgic-v2.c +12 -0
@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq); + +ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 ); + +return priority; +} +static int vgic_v2_vcpu_init (struct vcpu *v) {int i;
@@ -555,6 +566,7 @@ static int vgic_v2_domain_init(struct domain *d)static const struct vgic_ops vgic_v2_ops = { .vcpu_init = vgic_v2_vcpu_init, .domain_init = vgic_v2_domain_init, + .get_irq_priority = vgic_v2_get_irq_priority, .get_target_vcpu = vgic_v2_get_target_vcpu, };
xen/arch/arm/vgic.c +1 -1
@@ -368,7 +368,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)bool_t running;vgic_lock_rank (v, rank, flags); - priority =vgic_byte_read (rank->ipriority[REG_RANK_INDEX (8 , irq,DABT_WORD )],0 , irq &0x3 ); + priority = v->domain->arch.vgic.handler->get_irq_priority (v, irq);vgic_unlock_rank (v, rank, flags);spin_lock_irqsave (&v->arch.vgic.lock, flags);
xen/include/asm-arm/vgic.h +2 -0
@@ -96,6 +96,8 @@ struct vgic_ops {int (*vcpu_init)(struct vcpu *v);/* Domain specific initialization of vGIC */ int (*domain_init)(struct domain *d); +/* Get priority for a given irq stored in vgic structure */ +int (*get_irq_priority)(struct vcpu *v,unsigned int irq);/* Get the target vcpu for a given virq. The rank lock is already taken * when calling this. */ struct vcpu *(*get_target_vcpu)(struct vcpu *v,unsigned int irq);
Signature · 1 line
1.7.9.5
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 19 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irqSigned-off-by Vijaya Kumar K <[email protected]>---
v11: usevgic_irq_rank--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)xen/arch/arm/vgic-v2.c +0
-0
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 527
Quoted 7 lines
xen/arch/arm/vgic-v2.c +4
-0@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);
this is good
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 530
Quoted 2 lines
xen/arch/arm/vgic-v2.c +2
-0+ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );
this has been changed without mention in the change log for the patch, it was
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);
It is best to use the previous version, as it uses the common conversion functions.
Quoted 43 lines
xen/arch/arm/vgic-v2.c +4
-0+return priority; +} +static int vgic_v2_vcpu_init (struct vcpu *v) {int i;@@ -555,6 +566,7 @@ static int vgic_v2_domain_init(struct domain *d)static const struct vgic_ops vgic_v2_ops = { .vcpu_init = vgic_v2_vcpu_init, .domain_init = vgic_v2_domain_init, + .get_irq_priority = vgic_v2_get_irq_priority, .get_target_vcpu = vgic_v2_get_target_vcpu, };xen/arch/arm/vgic.c +1
-1@@ -368,7 +368,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)bool_t running;vgic_lock_rank (v, rank, flags); - priority =vgic_byte_read (rank->ipriority[REG_RANK_INDEX (8 , irq,DABT_WORD )],0 , irq &0x3 ); + priority = v->domain->arch.vgic.handler->get_irq_priority (v, irq);vgic_unlock_rank (v, rank, flags);spin_lock_irqsave (&v->arch.vgic.lock, flags);xen/include/asm-arm/vgic.h +2
-0@@ -96,6 +96,8 @@ struct vgic_ops {int (*vcpu_init)(struct vcpu *v);/* Domain specific initialization of vGIC */ int (*domain_init)(struct domain *d); +/* Get priority for a given irq stored in vgic structure */ +int (*get_irq_priority)(struct vcpu *v,unsigned int irq);/* Get the target vcpu for a given virq. The rank lock is already taken * when calling this. */ struct vcpu *(*get_target_vcpu)(struct vcpu *v,unsigned int irq);Signature · 1 line
1.7.9.5
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 34 lines · Stefano Stabellini
Quoted 19 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irqSigned-off-by Vijaya Kumar K <[email protected]>---
v11: usevgic_irq_rank--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)xen/arch/arm/vgic-v2.c +0
-0xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 527
Quoted 7 lines
xen/arch/arm/vgic-v2.c +4
-0@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);this is good
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 530
Quoted 2 lines
xen/arch/arm/vgic-v2.c +2
-0+ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );
Quoted 7 lines
this has been changed without mention in the change log for the patch, it was
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);It is best to use the previous version, as it uses the common conversion functions.
I changed it because we don't need do clumsy things
to get ipriority index with irq number in hand. If you don't have any further comments, I will send final version with this change for your ack.
Quoted 47 lines
Quoted 47 lines
xen/arch/arm/vgic-v2.c +4
-0+return priority; +} +static int vgic_v2_vcpu_init (struct vcpu *v) {int i;@@ -555,6 +566,7 @@ static int vgic_v2_domain_init(struct domain *d)static const struct vgic_ops vgic_v2_ops = { .vcpu_init = vgic_v2_vcpu_init, .domain_init = vgic_v2_domain_init, + .get_irq_priority = vgic_v2_get_irq_priority, .get_target_vcpu = vgic_v2_get_target_vcpu, };xen/arch/arm/vgic.c +1
-1@@ -368,7 +368,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)bool_t running;vgic_lock_rank (v, rank, flags); - priority =vgic_byte_read (rank->ipriority[REG_RANK_INDEX (8 , irq,DABT_WORD )],0 , irq &0x3 ); + priority = v->domain->arch.vgic.handler->get_irq_priority (v, irq);vgic_unlock_rank (v, rank, flags);spin_lock_irqsave (&v->arch.vgic.lock, flags);xen/include/asm-arm/vgic.h +2
-1@@ -96,6 +96,8 @@ struct vgic_ops {int (*vcpu_init)(struct vcpu *v);/* Domain specific initialization of vGIC */ int (*domain_init)(struct domain *d); +/* Get priority for a given irq stored in vgic structure */ +int (*get_irq_priority)(struct vcpu *v,unsigned int irq);/* Get the target vcpu for a given virq. The rank lock is already taken * when calling this. */ struct vcpu *(*get_target_vcpu)(struct vcpu *v,unsigned int irq); --1.7.9.5
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 41 lines · Vijay Kilari
Quoted 39 lines · Stefano Stabellini
Quoted 19 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irqSigned-off-by Vijaya Kumar K <[email protected]>---
v11: usevgic_irq_rank--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)xen/arch/arm/vgic-v2.c +0
-0xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 527
Quoted 7 lines
xen/arch/arm/vgic-v2.c +4
-0@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);this is good
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 530
Quoted 2 lines
xen/arch/arm/vgic-v2.c +2
-0+ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );this has been changed without mention in the change log for the patch, it was
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);
Quoted 7 lines
Quoted 2 lines
It is best to use the previous version, as it uses the common conversion functions.
I changed it because we don't need do clumsy things
to get ipriority index with irq number in hand. If you don't have any further comments, I will send final version with this change for your ack.
TBH I think that the open coded version is more readable than the macro, but we need to be consistent (so that we can easily change the macro and fix all the call sites in one change for example).
In any case I don't think that you need to resend just for this small change. We can fix in a follow up patch.
Quoted 48 lines
Quoted 47 lines
Quoted 47 lines
xen/arch/arm/vgic-v2.c +4
-0+return priority; +} +static int vgic_v2_vcpu_init (struct vcpu *v) {int i;@@ -555,6 +566,7 @@ static int vgic_v2_domain_init(struct domain *d)static const struct vgic_ops vgic_v2_ops = { .vcpu_init = vgic_v2_vcpu_init, .domain_init = vgic_v2_domain_init, + .get_irq_priority = vgic_v2_get_irq_priority, .get_target_vcpu = vgic_v2_get_target_vcpu, };xen/arch/arm/vgic.c +1
-1@@ -368,7 +368,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)bool_t running;vgic_lock_rank (v, rank, flags); - priority =vgic_byte_read (rank->ipriority[REG_RANK_INDEX (8 , irq,DABT_WORD )],0 , irq &0x3 ); + priority = v->domain->arch.vgic.handler->get_irq_priority (v, irq);vgic_unlock_rank (v, rank, flags);spin_lock_irqsave (&v->arch.vgic.lock, flags);xen/include/asm-arm/vgic.h +2
-1@@ -96,6 +96,8 @@ struct vgic_ops {int (*vcpu_init)(struct vcpu *v);/* Domain specific initialization of vGIC */ int (*domain_init)(struct domain *d); +/* Get priority for a given irq stored in vgic structure */ +int (*get_irq_priority)(struct vcpu *v,unsigned int irq);/* Get the target vcpu for a given virq. The rank lock is already taken * when calling this. */ struct vcpu *(*get_target_vcpu)(struct vcpu *v,unsigned int irq); --1.7.9.5
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 2 lines · Stefano Stabellini
In any case I don't think that you need to resend just for this small change. We can fix in a follow up patch.
Yeah, lets not respin the whole lot again just for this.
I've applied this series with Stefano's acks, Vijay, please can you follow up with the minor changes discussed here (I think #4 had a similar comment?)
Thanks!
Ian.
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
In reply to Stefano StabelliniQuoted 50 lines · Stefano Stabellini
Quoted 41 lines · Vijay Kilari
Quoted 39 lines · Stefano Stabellini
Quoted 19 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irqSigned-off-by Vijaya Kumar K <[email protected]>---
v11: usevgic_irq_rank--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)xen/arch/arm/vgic-v2.c +0
-0xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 527
Quoted 7 lines
xen/arch/arm/vgic-v2.c +4
-0@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);this is good
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 530
Quoted 2 lines
xen/arch/arm/vgic-v2.c +2
-0+ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );this has been changed without mention in the change log for the patch, it was
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);Quoted 7 lines
Quoted 2 lines
It is best to use the previous version, as it uses the common conversion functions.
I changed it because we don't need do clumsy things
to get ipriority index with irq number in hand. If you don't have any further comments, I will send final version with this change for your ack.
Quoted 6 lines
TBH I think that the open coded version is more readable than the macro, but we need to be consistent (so that we can easily change the macro and fix all the call sites in one change for example).
In any case I don't think that you need to resend just for this small change. We can fix in a follow up patch.
I see that you have made similar changes using in vgic-v2.c in
static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) {
....
target = vgic_byte_read(rank->itargets[(irq%32)/4], 0, irq % 4);
shall I revert back to use REG_RANK_INDEX here as well in my next commit?
Regards
Vijay
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 59 lines · Vijay Kilari
Quoted 50 lines · Stefano Stabellini
Quoted 41 lines · Vijay Kilari
Quoted 39 lines · Stefano Stabellini
Quoted 19 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Use callback in vgic driver to read priority for
a given irqSigned-off-by Vijaya Kumar K <[email protected]>---
v11: usevgic_irq_rank--- xen/arch/arm/vgic-v2.c | 12 ++++++++++++ xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-)xen/arch/arm/vgic-v2.c +0
-0xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 527
Quoted 7 lines
xen/arch/arm/vgic-v2.c +4
-0@@ -521,6 +521,17 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)return v_target; } +static int vgic_v2_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);this is good
xen/arch/arm/vgic-v2.c static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) · line 530
Quoted 2 lines
xen/arch/arm/vgic-v2.c +2
-0+ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );this has been changed without mention in the change log for the patch, it was
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);Quoted 7 lines
Quoted 2 lines
It is best to use the previous version, as it uses the common conversion functions.
I changed it because we don't need do clumsy things
to get ipriority index with irq number in hand. If you don't have any further comments, I will send final version with this change for your ack.Quoted 6 lines
TBH I think that the open coded version is more readable than the macro, but we need to be consistent (so that we can easily change the macro and fix all the call sites in one change for example).
In any case I don't think that you need to resend just for this small change. We can fix in a follow up patch.
Quoted 6 lines
I see that you have made similar changes using in
vgic-v2.cinstatic struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) {
....target = vgic_byte_read(rank->itargets[(irq%32)/4], 0, irq % 4);
Ops, I see that I talk the talk but I don't walk the walk
Quoted 2 lines
shall I revert back to use
REG_RANK_INDEXhere as well in my next commit?
Yes, please
Re: [PATCH for-4.5 v11 2/7] xen/arm: Add vgic callback to read irq priority
Quoted 25 lines · Stefano Stabellini
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8, irq,
DABT_WORD)], 0, irq & 0x3);It is best to use the previous version, as it uses the common conversion functions.
I changed it because we don't need do clumsy things
to get ipriority index with irq number in hand. If you don't have any further comments, I will send final version with this change for your ack.Quoted 6 lines
TBH I think that the open coded version is more readable than the macro, but we need to be consistent (so that we can easily change the macro and fix all the call sites in one change for example).
In any case I don't think that you need to resend just for this small change. We can fix in a follow up patch.
Quoted 6 lines
I see that you have made similar changes using in
vgic-v2.cinstatic struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq) {
....target = vgic_byte_read(rank->itargets[(irq%32)/4], 0, irq % 4);
Quoted 7 lines
Ops, I see that I talk the talk but I don't walk the walk
Quoted 2 lines
shall I revert back to use
REG_RANK_INDEXhere as well in my next commit?Yes, please
I have already sent patch by name "xen/arm: Use REG_RANK_INDEX macro" Please review
Regards
Vijay
PATCH v11 3/7 xen/arm: Add support for GIC v3
In reply to [email protected]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)
---
v9: - ICC_IAR1_EL1 holds only IRQ number. Do not mask the value
- Remove unused PIDR2 JEP register definitions
- Change {GICR,GICD}_PIDR2_ARCH_REV_SHIFT to {GICR,GICD}_PIDR2_ARCH_REV_OFFSET
- Remove duplicate MPIDR_LEVEL_BITS define
- Implemented gicv3_set_irq_affinity similar to gic v2
- make access to desc->status flags atomic
v8: - Introduced assembler aliases for GIC system registers
- Removed usage of lib.h for adding size macro, instead used sizes.h
- Renamed PIDR macros
- Removed check for number of cpus in cluster in gicv3_send_sgi() and instead check is added in gicv3_populate_rdist()
- Added comments and fixed coding style
- Removed nr_lrs parameter in gicv3_{restore,save}_lrs()
- Rename GICV3 compat strings.
v7: - Fixed wrong check for irq number in gicv3_set_irq_properties.
- Introduced panic during cpu_init on wrong priority bits.
v6: - Added read_apr() to read ICH_APRn in GICv3
- Added asserts
- PIDR2 check for architecture valu
- Remove update_cpu_lr_mask call
- Changed parameter ordering for gicv3_send_sgi()
- Save and restore ICC_SRE_EL1 registers
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/gic-v3.c | 1200 +++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/domain.h | 8 + xen/include/asm-arm/gic.h | 20 + xen/include/asm-arm/gic_v3_defs.h | 154 +++++ xen/include/asm-arm/processor.h | 13 + xen/include/asm-arm/sysregs.h | 53 ++ 7 files changed, 1449 insertions(+)
xen/arch/arm/Makefile +1 -0
@@ -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 +1200 -0
1,200 lines not on this page · raw message
xen/include/asm-arm/domain.h +8 -0
@@ -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
@@ -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_COMPAT_GIC_V3 "arm,gic-v3" + +#define DT_MATCH_GIC_V3 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_V3) + +/* +* 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 +154 -0
154 lines not on this page · raw message
xen/include/asm-arm/processor.h +13 -0
@@ -20,6 +20,19 @@#define AFFINITY_MASK (level) ~((_AC(0x1,U) << ((level) * MPIDR_LEVEL_BITS)) - 1) +/* +* Macros to extract affinity level. picked from kernel +*/ + +#define MPIDR_LEVEL_BITS_SHIFT 3 +#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/asm-arm/sysregs.h +53 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v11 4/7 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)
---
v11:- remove wrong comment and fix wrong coding style
- use vgic_rank_irq
v10:- Implement callbacks get_target_vcpu and get_irq_priority
for vgic-v3
- REG_RANK_NR is updated for 64 bit
v9: - Use 128K mask to compute GICR register offset if stride
is not set
- Fix alignment errors in vgic-v.c
- Updated vgic_{lock,unlock}_rank
v8: - Fixed printk coding styles
- Moved GICD_PIDRn and GICR_PIDRn macros to vgic-v3.c from header file
- Check is made on return value of vgic_v3_init()
v7: Fixed coding style.
v6: Removed byte read access for IROUTERN register.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/vgic-v2.c | 23 +- xen/arch/arm/vgic-v3.c | 953 ++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 6 + xen/include/asm-arm/vgic.h | 18 +- 5 files changed, 988 insertions(+), 13 deletions(-)
xen/arch/arm/Makefile +1 -0
@@ -29,6 +29,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 +11 -12
@@ -132,10 +132,9 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info)if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width; rank =vgic_rank_offset (v,8 , gicd_reg -GICD_ITARGETSR ,DABT_WORD );if ( rank ==NULL ) goto read_as_zero; -vgic_lock_rank (v, rank, flags); - *r = rank->itargets[REG_RANK_INDEX (8 , gicd_reg -GICD_ITARGETSR , -DABT_WORD )]; + *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);vgic_unlock_rank (v, rank, flags);
@@ -390,7 +389,7 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info)struct vcpu *v_target, *v_old; new_target = i %8 ; - old_target_mask =vgic_byte_read (rank->itargets[REG_RANK_INDEX (8 , + old_target_mask =vgic_byte_read (rank->v2.itargets[REG_RANK_INDEX (8 , gicd_reg -GICD_ITARGETSR ,DABT_WORD )],0 , i/8 ); old_target =find_first_bit (&old_target_mask,8 );
@@ -404,11 +403,11 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info) i +=8 - new_target; }if ( dabt.size ==DABT_WORD ) - rank->itargets[REG_RANK_INDEX (8 , gicd_reg -GICD_ITARGETSR , -DABT_WORD )] = target; + rank->v2.itargets[REG_RANK_INDEX (8 , gicd_reg -GICD_ITARGETSR , +DABT_WORD )] = target;else -vgic_byte_write (&rank->itargets[REG_RANK_INDEX (8 , - gicd_reg -GICD_ITARGETSR ,DABT_WORD )], target, gicd_reg); +vgic_byte_write (&rank->v2.itargets[REG_RANK_INDEX (8 , + gicd_reg -GICD_ITARGETSR ,DABT_WORD )], target, gicd_reg);vgic_unlock_rank (v, rank, flags);return 1 ; }
@@ -511,7 +510,7 @@ static struct vcpu *vgic_v2_get_target_vcpu(struct vcpu *v, unsigned int irq)struct vgic_irq_rank *rank =vgic_rank_irq (v, irq);ASSERT (spin_is_locked (&rank->lock)); - target =vgic_byte_read (rank->itargets[(irq%32 )/4 ],0 , irq %4 ); + target =vgic_byte_read (rank->v2.itargets[(irq%32 )/4 ],0 , irq %4 );/* 1-N SPI should be delivered as pending to all the vcpus in the * mask, but here we just return the first vcpu for simplicity and * because it would be too slow to do otherwise. */
@@ -538,7 +537,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 ))
@@ -553,8 +552,8 @@ static int vgic_v2_domain_init(struct domain *d)/* By default deliver to CPU0 */ for ( i =0 ; i <DOMAIN_NR_RANKS (d); i++ ) -memset (d->arch.vgic.shared_irqs[i].itargets,0x1 , -sizeof (d->arch.vgic.shared_irqs[i].itargets)); +memset (d->arch.vgic.shared_irqs[i].v2.itargets,0x1 , +sizeof (d->arch.vgic.shared_irqs[i].v2.itargets));/* We rely on gicv_setup() to initialize dbase(vGIC distributor base) */ register_mmio_handler(d, &vgic_v2_distr_mmio_handler, d->arch.vgic.dbase,
xen/arch/arm/vgic-v3.c new file +953 -0
953 lines not on this page · raw message
xen/arch/arm/vgic.c +6 -0
@@ -76,6 +76,12 @@ int domain_vgic_init(struct domain *d)switch (gic_hw_version () ) { +#ifdef CONFIG_ARM_64 +case GIC_V3 : +if (vgic_v3_init (d) ) +return -ENODEV ; +break ; +#endif case GIC_V2 :if (vgic_v2_init (d) )return -ENODEV ;
xen/include/asm-arm/vgic.h +17 -1
@@ -88,7 +88,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 {
@@ -120,6 +127,14 @@ static inline int REG_RANK_NR(int b, uint32_t n) {switch ( b ) { +/* +* IRQ ranks are of size 32. So n cannot be shifted beyond 5 for 32 +* and above. For 64-bit n is already shifted DBAT_DOUBLE_WORD +* by the caller +*/ +case 64 : +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 ;
@@ -172,6 +187,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
Re: [PATCH for-4.5 v11 4/7] xen/arm: Add virtual GICv3 support
Quoted 35 lines · On Fri, 12 Sep 2014, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add virtual GICv3 driver support.
Also, with this patchvgic_irq_rankstructure is modified to hold GICv2GICD_TARGETand GICv3GICD_ROUTERregisters under union.This patch adds only basic GICv3 support. Does not support Interrupt Translation support (ITS)
Signed-off-by Vijaya Kumar K <[email protected]>---
v11:- remove wrong comment and fix wrong coding style
- usevgic_rank_irq
v10:- Implement callbacksget_target_vcpuandget_irq_priority
for vgic-v3
-REG_RANK_NRis updated for 64 bit
v9: - Use 128K mask to compute GICR register offset if stride
is not set
- Fix alignment errors invgic-v.c
- Updated vgic_{lock,unlock}_rank
v8: - Fixed printk coding styles
- MovedGICD_PIDRnandGICR_PIDRnmacros tovgic-v3.cfrom header file
- Check is made on return value ofvgic_v3_init()
v7: Fixed coding style.
v6: Removed byte read access for IROUTERN register.--- xen/arch/arm/Makefile | 1 + xen/arch/arm/vgic-v2.c | 23 +- xen/arch/arm/vgic-v3.c | 953 ++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 6 + xen/include/asm-arm/vgic.h | 18 +- 5 files changed, 988 insertions(+), 13 deletions(-)
xen/arch/arm/vgic-v3.c line 890
Quoted 7 lines
xen/arch/arm/vgic-v3.c new file +7
-0+static int vgic_v3_get_irq_priority (struct vcpu *v,unsigned int irq) +{ +int priority; +struct vgic_irq_rank *rank =vgic_rank_irq (v, irq); + +ASSERT (spin_is_locked (&rank->lock)); + priority =vgic_byte_read (rank->ipriority[(irq%32 )/4 ],0 , irq %4 );
It's best to do
priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8,
irq, DABT_WORD)], 0, irq & 0x3);like you did previously.
In any case
PATCH v11 5/7 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 | 78 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 6 ++++ xen/include/asm-arm/gic.h | 4 +++ 5 files changed, 141 insertions(+), 45 deletions(-)
xen/arch/arm/domain_build.c +2 -45
@@ -777,9 +777,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 ;/*
@@ -794,48 +791,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;
@@ -1058,6 +1014,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 +78 -0
96 lines not on this page · raw message
xen/arch/arm/gic.c +6 -0
@@ -625,6 +625,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 +4 -0
@@ -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
PATCH v11 6/7 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 | 15 +++++++++++ xen/arch/arm/vgic-v3.c | 54 +++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 9 +++++++ xen/include/asm-arm/gic_v3_defs.h | 7 +++++ xen/include/asm-arm/sysregs.h | 3 +++ xen/include/asm-arm/vgic.h | 3 +++ 6 files changed, 91 insertions(+)
xen/arch/arm/traps.c +15 -0
@@ -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
@@ -1743,6 +1744,20 @@ static void do_sysreg(struct cpu_user_regs *regs,domain_crash_synchronous (); }break ; +case HSR_SYSREG_ICC_SGI1R_EL1 : +if ( !vgic_emulate (regs, hsr) ) + { +dprintk (XENLOG_WARNING , +"failed emulation of sysreg ICC_SGI1R_EL1 access\n" ); +inject_undef64_exception (regs, 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" ); +inject_undef64_exception (regs, hsr.len);default : bad_sysreg: {
xen/arch/arm/vgic-v3.c +54 -0
66 lines not on this page · raw message
xen/arch/arm/vgic.c +9 -0
@@ -435,6 +435,15 @@ void arch_evtchn_inject(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq); } +int vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) +{ +struct vcpu *v = current; + +ASSERT (v->domain->arch.vgic.handler->emulate_sysreg !=NULL ); + +return v->domain->arch.vgic.handler->emulate_sysreg (regs, hsr); +} +/* * Local variables: * mode: C
xen/include/asm-arm/gic_v3_defs.h +7 -0
@@ -142,6 +142,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
@@ -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 +3 -0
@@ -108,6 +108,8 @@ struct vgic_ops {/* Get the target vcpu for a given virq. The rank lock is already taken * when calling this. */ struct vcpu *(*get_target_vcpu)(struct vcpu *v,unsigned int irq); +/* vGIC sysreg emulation */ +int (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr); };/* Number of ranks of interrupt registers for a domain */
@@ -183,6 +185,7 @@ 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 struct vgic_irq_rank *vgic_rank_irq (struct vcpu *v,unsigned int irq); +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
PATCH v11 7/7 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
---
v10: - Correct error message
v9: - Correct error message
v8: - Rearranged prf64 structure member variables
v7: - return -ENODEV on lack GICv3 platform support instead of
panic
--- xen/arch/arm/gic-v3.c | 7 +++++++ xen/arch/arm/setup.c | 5 +++-- xen/include/asm-arm/cpufeature.h | 1 + xen/include/asm-arm/processor.h | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-)
xen/arch/arm/gic-v3.c +7 -0
@@ -39,6 +39,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;
@@ -1158,6 +1159,12 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data)int res, i;uint32_t reg; +if ( !cpu_has_gicv3 ) + { +dprintk (XENLOG_ERR ,"GICv3: driver requires system register support\n" ); +return -ENODEV ; + } +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
@@ -103,9 +103,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-SysReg" :"" );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
@@ -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(gic) == 1)#endif #define cpu_feature32 (c, feat) ((c)->pfr32.feat)
xen/include/asm-arm/processor.h +2 -2
@@ -250,8 +250,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 gic:4; /* GIC support */ + unsigned long __res0:4;unsigned long __res1; }; } pfr64;
Signature · 1 line
1.7.9.5