New VGIC(-v2) implementation
Re: [PATCH 44/57] ARM: new VGIC: Add SGIPENDR register handlers
In reply to Andre PrzywaraHi Andre,
Quoted 7 lines · Andre Przywara
As this register is v2 specific, its implementation lives entirely in
vgic-mmio-v2.c.
This register allows setting the source mask of an IPI.This is based on Linux commit
ed40213ef9b0, written by Andre Przywara.Signed-off-by Andre Przywara <[email protected]>
Cheers,
Quoted 109 lines
---
Changelog RFC ... v1:
- use C99 and unsigned data typesxen/arch/arm/vgic/vgic-mmio-v2.c | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-)xen/arch/arm/vgic/vgic-mmio-v2.c +79
-2@@ -177,6 +177,83 @@ static void vgic_mmio_write_target(struct vcpu *vcpu, } } +static unsigned long vgic_mmio_read_sgipend (struct vcpu *vcpu, +paddr_t addr,unsigned int len) +{ +uint32_t intid =VGIC_ADDR_TO_INTID (addr,8 ); +uint32_t val =0 ; +unsigned int i; + +ASSERT (intid <VGIC_NR_SGIS ); + +for ( i =0 ; i < len; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (vcpu->domain, vcpu, intid + i); + + val |= (uint32_t )irq->source << (i *8 ); + +vgic_put_irq (vcpu->domain, irq); + } + +return val; +} + +static void vgic_mmio_write_sgipendc (struct vcpu *vcpu, +paddr_t addr,unsigned int len, +unsigned long val) +{ +uint32_t intid =VGIC_ADDR_TO_INTID (addr,8 ); +unsigned int i; +unsigned long flags; + +ASSERT (intid <VGIC_NR_SGIS ); + +for ( i =0 ; i < len; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (vcpu->domain, vcpu, intid + i); + +spin_lock_irqsave (&irq->irq_lock, flags); + + irq->source &= ~((val >> (i *8 )) &0xff ); +if ( !irq->source ) + irq->pending_latch = false; + +spin_unlock_irqrestore (&irq->irq_lock, flags); +vgic_put_irq (vcpu->domain, irq); + } +} + +static void vgic_mmio_write_sgipends (struct vcpu *vcpu, +paddr_t addr,unsigned int len, +unsigned long val) +{ +uint32_t intid =VGIC_ADDR_TO_INTID (addr,8 ); +unsigned int i; +unsigned long flags; + +ASSERT (intid <VGIC_NR_SGIS ); + +for ( i =0 ; i < len; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (vcpu->domain, vcpu, intid + i); + +spin_lock_irqsave (&irq->irq_lock, flags); + + irq->source |= (val >> (i *8 )) &0xff ; + +if ( irq->source ) + { + irq->pending_latch = true; +vgic_queue_irq_unlock (vcpu->domain, irq, flags); + } +else + { +spin_unlock_irqrestore (&irq->irq_lock, flags); + } +vgic_put_irq (vcpu->domain, irq); + } +} +static const struct vgic_register_region vgic_v2_dist_registers[] = { REGISTER_DESC_WITH_LENGTH(GICD_CTLR, vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12,@@ -215,10 +292,10 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_raz, vgic_mmio_write_sgir, 4, VGIC_ACCESS_32bit),REGISTER_DESC_WITH_LENGTH (GICD_CPENDSGIR , - vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + vgic_mmio_read_sgipend, vgic_mmio_write_sgipendc, 16, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit),REGISTER_DESC_WITH_LENGTH (GICD_SPENDSGIR , - vgic_mmio_read_raz, vgic_mmio_write_wi, 16, + vgic_mmio_read_sgipend, vgic_mmio_write_sgipends, 16, VGIC_ACCESS_32bit | VGIC_ACCESS_8bit), };
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 45/57 ARM: new VGIC: Handle hardware mapped IRQs
In reply to Andre PrzywaraThe VGIC supports virtual IRQs to be connected to a hardware IRQ, so when a guest EOIs the virtual interrupt, it affects the state of that corresponding interrupt on the hardware side at the same time. Implement the interface that the Xen arch/core code expects to connect the virtual and the physical world.
---
Changelog RFC ... v1:
- add ASSERT for hardware mapped IRQs being SPI only
- check h/w IRQ matches before disconnecting
xen/arch/arm/vgic/vgic.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)
xen/arch/arm/vgic/vgic.c +71 -0
@@ -698,6 +698,77 @@ void vgic_kick_vcpus(struct domain *d) } } +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v, +unsigned int virq) +{ +struct irq_desc *desc =NULL ; +struct vgic_irq *irq =vgic_get_irq (d, v, virq); +unsigned long flags; + +if ( !irq ) +return NULL ; + +spin_lock_irqsave (&irq->irq_lock, flags); +if ( irq->hw ) + { +ASSERT (irq->hwintid >=VGIC_NR_PRIVATE_IRQS ); + desc =irq_to_desc (irq->hwintid); + } +spin_unlock_irqrestore (&irq->irq_lock, flags); + +vgic_put_irq (d, irq); + +return desc; +} + +/* +* was: +* int kvm_vgic_map_phys_irq(struct vcpu *vcpu, u32 virt_irq, u32 phys_irq) +* int kvm_vgic_unmap_phys_irq(struct vcpu *vcpu, unsigned int virt_irq) +*/ +int vgic_connect_hw_irq (struct domain *d,struct vcpu *vcpu, +unsigned int virt_irq,struct irq_desc *desc, +bool connect) +{ +struct vgic_irq *irq =vgic_get_irq (d, vcpu, virt_irq); +unsigned long flags; +int ret =0 ; + +if ( !irq ) +return -EINVAL ; + +spin_lock_irqsave (&irq->irq_lock, flags); + +if ( connect )/* assign a mapped IRQ */ + { +/* The VIRQ should not be already enabled by the guest */ +if ( !irq->hw && !irq->enabled ) + { + irq->hw = true; + irq->hwintid = desc->irq; + } +else + ret = -EBUSY ; + } +else /* remove a mapped IRQ */ + { +if ( desc && irq->hwintid != desc->irq ) + { + ret = -EINVAL ; + } +else + { + irq->hw = false; + irq->hwintid =0 ; + } + } + +spin_unlock_irqrestore (&irq->irq_lock, flags); +vgic_put_irq (d, irq); + +return ret; +} +static unsigned int translate_irq_type (bool is_level) {return is_level ?IRQ_TYPE_LEVEL_HIGH :IRQ_TYPE_EDGE_RISING ;
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 45/57] ARM: new VGIC: Handle hardware mapped IRQs
Hi Andre,
Quoted 7 lines · Andre Przywara
The VGIC supports virtual IRQs to be connected to a hardware IRQ, so when a guest EOIs the virtual interrupt, it affects the state of that corresponding interrupt on the hardware side at the same time. Implement the interface that the Xen
arch/corecode expects to connect the virtual and the physical world.Signed-off-by Andre Przywara <[email protected]>
Cheers,
Quoted 91 lines
---
Changelog RFC ... v1:
- add ASSERT for hardware mapped IRQs being SPI only
- check h/w IRQ matches before disconnectingxen/arch/arm/vgic/vgic.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)xen/arch/arm/vgic/vgic.c +71
-0@@ -698,6 +698,77 @@ void vgic_kick_vcpus(struct domain *d) } } +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v, +unsigned int virq) +{ +struct irq_desc *desc =NULL ; +struct vgic_irq *irq =vgic_get_irq (d, v, virq); +unsigned long flags; + +if ( !irq ) +return NULL ; + +spin_lock_irqsave (&irq->irq_lock, flags); +if ( irq->hw ) + { +ASSERT (irq->hwintid >=VGIC_NR_PRIVATE_IRQS ); + desc =irq_to_desc (irq->hwintid); + } +spin_unlock_irqrestore (&irq->irq_lock, flags); + +vgic_put_irq (d, irq); + +return desc; +} + +/* +* was: +* int kvm_vgic_map_phys_irq(struct vcpu *vcpu, u32 virt_irq, u32 phys_irq) +* int kvm_vgic_unmap_phys_irq(struct vcpu *vcpu, unsigned int virt_irq) +*/ +int vgic_connect_hw_irq (struct domain *d,struct vcpu *vcpu, +unsigned int virt_irq,struct irq_desc *desc, +bool connect) +{ +struct vgic_irq *irq =vgic_get_irq (d, vcpu, virt_irq); +unsigned long flags; +int ret =0 ; + +if ( !irq ) +return -EINVAL ; + +spin_lock_irqsave (&irq->irq_lock, flags); + +if ( connect )/* assign a mapped IRQ */ + { +/* The VIRQ should not be already enabled by the guest */ +if ( !irq->hw && !irq->enabled ) + { + irq->hw = true; + irq->hwintid = desc->irq; + } +else + ret = -EBUSY ; + } +else /* remove a mapped IRQ */ + { +if ( desc && irq->hwintid != desc->irq ) + { + ret = -EINVAL ; + } +else + { + irq->hw = false; + irq->hwintid =0 ; + } + } + +spin_unlock_irqrestore (&irq->irq_lock, flags); +vgic_put_irq (d, irq); + +return ret; +} +static unsigned int translate_irq_type (bool is_level) {return is_level ?IRQ_TYPE_LEVEL_HIGH :IRQ_TYPE_EDGE_RISING ;
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 46/57 ARM: new VGIC: Add event channel IRQ handling
In reply to Andre PrzywaraThe Xen core/arch code relies on two abstracted functions to inject an event channel IRQ and to query its pending state.
Implement those to query the state of the new VGIC implementation.
---
Changelog RFC ... v1:
- add locking
xen/arch/arm/vgic/vgic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
xen/arch/arm/vgic/vgic.c +23 -0
@@ -698,6 +698,29 @@ void vgic_kick_vcpus(struct domain *d) } } +void arch_evtchn_inject (struct vcpu *v) +{ +vgic_inject_irq (v->domain, v, v->domain->arch.evtchn_irq, true); +} + +bool vgic_evtchn_irq_pending (struct vcpu *v) +{ +struct vgic_irq *irq; +unsigned long flags; +bool pending; + +/* Does not work for LPIs. */ +ASSERT (!is_lpi (v->domain->arch.evtchn_irq)); + + irq =vgic_get_irq (v->domain, v, v->domain->arch.evtchn_irq); +spin_lock_irqsave (&irq->irq_lock, flags); + pending =irq_is_pending (irq); +spin_unlock_irqrestore (&irq->irq_lock, flags); +vgic_put_irq (v->domain, irq); + +return pending; +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 46/57] ARM: new VGIC: Add event channel IRQ handling
Hi Andre,
Quoted 3 lines · Andre Przywara
The Xen core/arch code relies on two abstracted functions to inject an event channel IRQ and to query its pending state.
Implement those to query the state of the new VGIC implementation.
The code looks good, but I am wondering why we ever need to call vgic_evtchn_irq_pending in local_event_needs_delivery_nomask.
After all, the event channel is an interrupt. So it should already get caught by vgic_pending_irq(). If not, then there are no point to wake up the vCPU for nothing (it will not get handled). Stefano, do you have insight why the current implementation?
Anyway, the code as it is fine so:
Cheers,
Quoted 44 lines
Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- add lockingxen/arch/arm/vgic/vgic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)xen/arch/arm/vgic/vgic.c +23
-0@@ -698,6 +698,29 @@ void vgic_kick_vcpus(struct domain *d) } } +void arch_evtchn_inject (struct vcpu *v) +{ +vgic_inject_irq (v->domain, v, v->domain->arch.evtchn_irq, true); +} + +bool vgic_evtchn_irq_pending (struct vcpu *v) +{ +struct vgic_irq *irq; +unsigned long flags; +bool pending; + +/* Does not work for LPIs. */ +ASSERT (!is_lpi (v->domain->arch.evtchn_irq)); + + irq =vgic_get_irq (v->domain, v, v->domain->arch.evtchn_irq); +spin_lock_irqsave (&irq->irq_lock, flags); + pending =irq_is_pending (irq); +spin_unlock_irqrestore (&irq->irq_lock, flags); +vgic_put_irq (v->domain, irq); + +return pending; +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 47/57 ARM: new VGIC: Handle virtual IRQ allocation/reservation
In reply to Andre PrzywaraTo find an unused virtual IRQ number Xen uses a scheme to track used virtual IRQs.
Implement this interface in the new VGIC to make the Xen core/arch code happy.
This is actually somewhat VGIC agnostic, so is mostly a copy of the code from the old VGIC. But it has to live in the VGIC files, so we can't easily reuse the existing implementation.
---
Changelog RFC ... v1:
- no changes
xen/arch/arm/vgic/vgic.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
xen/arch/arm/vgic/vgic.c +44 -0
@@ -721,6 +721,50 @@ bool vgic_evtchn_irq_pending(struct vcpu *v)return pending; } +bool vgic_reserve_virq (struct domain *d,unsigned int virq) +{ +if ( virq >=vgic_num_irqs (d) ) +return false; + +return !test_and_set_bit (virq, d->arch.vgic.allocated_irqs); +} + +int vgic_allocate_virq (struct domain *d,bool spi) +{ +int first, end; +unsigned int virq; + +if ( !spi ) + { +/* We only allocate PPIs. SGIs are all reserved */ + first =16 ; + end =32 ; + } +else + { + first =32 ; + end =vgic_num_irqs (d); + } + +/* +* There is no spinlock to protect allocated_irqs, therefore +* test_and_set_bit may fail. If so retry it. +*/ +do + { + virq =find_next_zero_bit (d->arch.vgic.allocated_irqs, end, first); +if ( virq >= end ) +return -1 ; + }while (test_and_set_bit (virq, d->arch.vgic.allocated_irqs) ); + +return virq; +} + +void vgic_free_virq (struct domain *d,unsigned int virq) +{ +clear_bit (virq, d->arch.vgic.allocated_irqs); +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 47/57] ARM: new VGIC: Handle virtual IRQ allocation/reservation
Hi Andre,
Quoted 9 lines · Andre Przywara
To find an unused virtual IRQ number Xen uses a scheme to track used virtual IRQs.
Implement this interface in the new VGIC to make the Xen core/arch code happy.
This is actually somewhat VGIC agnostic, so is mostly a copy of the code from the old VGIC. But it has to live in the VGIC files, so we can't easily reuse the existing implementation.Signed-off-by Andre Przywara <[email protected]>
Cheers,
Quoted 63 lines
---
Changelog RFC ... v1:
- no changesxen/arch/arm/vgic/vgic.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)xen/arch/arm/vgic/vgic.c +44
-0@@ -721,6 +721,50 @@ bool vgic_evtchn_irq_pending(struct vcpu *v)return pending; } +bool vgic_reserve_virq (struct domain *d,unsigned int virq) +{ +if ( virq >=vgic_num_irqs (d) ) +return false; + +return !test_and_set_bit (virq, d->arch.vgic.allocated_irqs); +} + +int vgic_allocate_virq (struct domain *d,bool spi) +{ +int first, end; +unsigned int virq; + +if ( !spi ) + { +/* We only allocate PPIs. SGIs are all reserved */ + first =16 ; + end =32 ; + } +else + { + first =32 ; + end =vgic_num_irqs (d); + } + +/* +* There is no spinlock to protect allocated_irqs, therefore +* test_and_set_bit may fail. If so retry it. +*/ +do + { + virq =find_next_zero_bit (d->arch.vgic.allocated_irqs, end, first); +if ( virq >= end ) +return -1 ; + }while (test_and_set_bit (virq, d->arch.vgic.allocated_irqs) ); + +return virq; +} + +void vgic_free_virq (struct domain *d,unsigned int virq) +{ +clear_bit (virq, d->arch.vgic.allocated_irqs); +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 48/57 ARM: new VGIC: Dump virtual IRQ info
In reply to Andre PrzywaraWhen we dump guest state on the Xen console, we also print the state of IRQs that are on a VCPU.
Add the code to dump the state of an IRQ handled by the new VGIC.
---
Changelog RFC ... v1:
- use proper locking
- use one header line to announce active or pending IRQs
xen/arch/arm/vgic/vgic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
xen/arch/arm/vgic/vgic.c +25 -0
@@ -765,6 +765,31 @@ void vgic_free_virq(struct domain *d, unsigned int virq)clear_bit (virq, d->arch.vgic.allocated_irqs); } +void gic_dump_vgic_info (struct vcpu *v) +{ +struct vgic_cpu *vgic_cpu = &v->arch.vgic; +struct vgic_irq *irq; +unsigned long flags; + +spin_lock_irqsave (&v->arch.vgic.ap_list_lock, flags); + +if ( !list_empty (&vgic_cpu->ap_list_head) ) +printk (" active or pending interrupts queued:\n" ); + + list_for_each_entry ( irq, &vgic_cpu->ap_list_head, ap_list ) + { +spin_lock (&irq->irq_lock); +printk (" %s %s irq %u: %spending, %sactive, %senabled\n" , + irq->hw ?"hardware" :"virtual" , + irq->config ==VGIC_CONFIG_LEVEL ?"level" :"edge" , + irq->intid,irq_is_pending (irq) ?"" :"not " , + irq->active ?"" :"not " , irq->enabled ?"" :"not " ); +spin_unlock (&irq->irq_lock); + } + +spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 48/57] ARM: new VGIC: Dump virtual IRQ info
Hi Andre,
Quoted 5 lines · Andre Przywara
When we dump guest state on the Xen console, we also print the state of IRQs that are on a VCPU.
Add the code to dump the state of an IRQ handled by the new VGIC.Signed-off-by Andre Przywara <[email protected]>
Cheers,
Quoted 45 lines
---
Changelog RFC ... v1:
- use proper locking
- use one header line to announce active or pending IRQsxen/arch/arm/vgic/vgic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)xen/arch/arm/vgic/vgic.c +25
-0@@ -765,6 +765,31 @@ void vgic_free_virq(struct domain *d, unsigned int virq)clear_bit (virq, d->arch.vgic.allocated_irqs); } +void gic_dump_vgic_info (struct vcpu *v) +{ +struct vgic_cpu *vgic_cpu = &v->arch.vgic; +struct vgic_irq *irq; +unsigned long flags; + +spin_lock_irqsave (&v->arch.vgic.ap_list_lock, flags); + +if ( !list_empty (&vgic_cpu->ap_list_head) ) +printk (" active or pending interrupts queued:\n" ); + + list_for_each_entry ( irq, &vgic_cpu->ap_list_head, ap_list ) + { +spin_lock (&irq->irq_lock); +printk (" %s %s irq %u: %spending, %sactive, %senabled\n" , + irq->hw ?"hardware" :"virtual" , + irq->config ==VGIC_CONFIG_LEVEL ?"level" :"edge" , + irq->intid,irq_is_pending (irq) ?"" :"not " , + irq->active ?"" :"not " , irq->enabled ?"" :"not " ); +spin_unlock (&irq->irq_lock); + } + +spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 49/57 ARM: new VGIC: provide system register emulation stub
In reply to Andre PrzywaraThe Xen arch code traps system registers writes from the guest and will relay anything GIC related to the VGIC.
Since this affects only GICv3 (which we don't yet emulate), provide a stub implementation of vgic_emulate() for now.
---
Changelog RFC ... v1:
- no changes
xen/arch/arm/vgic/vgic.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/arch/arm/vgic/vgic.c +7 -0
@@ -813,6 +813,13 @@ struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v,return desc; } +bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) +{ +ASSERT (current->domain->arch.vgic.version ==GIC_V3 ); + +return false; +} +/* * was: * int kvm_vgic_map_phys_irq(struct vcpu *vcpu, u32 virt_irq, u32 phys_irq)
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 49/57] ARM: new VGIC: provide system register emulation stub
Quoted 6 lines · Andre Przywara
The Xen arch code traps system registers writes from the guest and will relay anything GIC related to the VGIC.
Since this affects only GICv3 (which we don't yet emulate), provide a stub implementation ofvgic_emulate()for now.Signed-off-by Andre Przywara <[email protected]>
Cheers,
Quoted 26 lines
---
Changelog RFC ... v1:
- no changesxen/arch/arm/vgic/vgic.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/arch/arm/vgic/vgic.c +7
-0@@ -813,6 +813,13 @@ struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v,return desc; } +bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) +{ +ASSERT (current->domain->arch.vgic.version ==GIC_V3 ); + +return false; +} +/* * was: * int kvm_vgic_map_phys_irq(struct vcpu *vcpu, u32 virt_irq, u32 phys_irq)
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 50/57 ARM: new VGIC: Implement arch_move_irqs()
In reply to Andre PrzywaraWhen a VCPU moves to another CPU, we need to adjust the target affinity of any hardware mapped vIRQs, to observe our "physical-follows-virtual" policy.
Implement arch_move_irqs() to adjust the physical affinity of all hardware mapped vIRQs targetting this VCPU.
---
Changelog RFC ... v1:
- actually implement arch_move_irqs() (instead of just stubbing it)
xen/arch/arm/vgic/vgic.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
xen/arch/arm/vgic/vgic.c +42 -0
@@ -790,6 +790,48 @@ void gic_dump_vgic_info(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); } +/** +* arch_move_irqs() - migrate the physical affinity of hardware mapped vIRQs +* @v: the vCPU, already assigned to the new pCPU +* +* arch_move_irqs() updates the physical affinity of all virtual IRQs +* targetting this given vCPU. This only affects hardware mapped IRQs. The +* new pCPU to target is already set in v->processor. +* This is called by the core code after a vCPU has been migrated to a new +* physical CPU. +*/ +void arch_move_irqs (struct vcpu *v) +{ +struct domain *d = v->domain; +unsigned int i; + +/* We only target SPIs with this function */ +for ( i =0 ; i < d->arch.vgic.nr_spis; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (d,NULL , i +VGIC_NR_PRIVATE_IRQS ); +unsigned long flags; +irq_desc_t *desc; + +if ( !irq ) +continue ; + +spin_lock_irqsave (&irq->irq_lock, flags); + +/* only vIRQs that are not on a vCPU yet , but targetting this vCPU */ +if ( irq->hw && !irq->vcpu && irq->target_vcpu == v) + desc =irq_to_desc (irq->hwintid); +else + desc =NULL ; + +spin_unlock_irqrestore (&irq->irq_lock, flags); + +if ( desc ) +vgic_sync_hardware_irq (d, desc, irq); + +vgic_put_irq (d, irq); + } +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 50/57] ARM: new VGIC: Implement arch_move_irqs()
Hi Andre,
Quoted 49 lines · Andre Przywara
When a VCPU moves to another CPU, we need to adjust the target affinity of any hardware mapped vIRQs, to observe our "physical-follows-virtual" policy.
Implementarch_move_irqs()to adjust the physical affinity of all hardware mapped vIRQs targetting this VCPU.Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- actually implementarch_move_irqs()(instead of just stubbing it)xen/arch/arm/vgic/vgic.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)xen/arch/arm/vgic/vgic.c +27
-0@@ -790,6 +790,48 @@ void gic_dump_vgic_info(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); } +/** +* arch_move_irqs() - migrate the physical affinity of hardware mapped vIRQs +* @v: the vCPU, already assigned to the new pCPU +* +* arch_move_irqs() updates the physical affinity of all virtual IRQs +* targetting this given vCPU. This only affects hardware mapped IRQs. The +* new pCPU to target is already set in v->processor. +* This is called by the core code after a vCPU has been migrated to a new +* physical CPU. +*/ +void arch_move_irqs (struct vcpu *v) +{ +struct domain *d = v->domain; +unsigned int i; + +/* We only target SPIs with this function */ +for ( i =0 ; i < d->arch.vgic.nr_spis; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (d,NULL , i +VGIC_NR_PRIVATE_IRQS ); +unsigned long flags; +irq_desc_t *desc; + +if ( !irq ) +continue ; + +spin_lock_irqsave (&irq->irq_lock, flags); +
xen/arch/arm/vgic/vgic.c void gic_dump_vgic_info(struct vcpu *v) · line 829
Quoted 10 lines
xen/arch/arm/vgic/vgic.c +10
-0+/* only vIRQs that are not on a vCPU yet , but targetting this vCPU */ +if ( irq->hw && !irq->vcpu && irq->target_vcpu == v) + desc =irq_to_desc (irq->hwintid); +else + desc =NULL ; + +spin_unlock_irqrestore (&irq->irq_lock, flags); + +if ( desc ) +vgic_sync_hardware_irq (d, desc, irq);
You want to look at my comment about using vgic_sync_hardware_irq for routing on patch #43.
xen/arch/arm/vgic/vgic.c void gic_dump_vgic_info(struct vcpu *v) · line 837
Quoted 9 lines
xen/arch/arm/vgic/vgic.c +5
-0+ +vgic_put_irq (d, irq); + } +} +struct irq_desc *vgic_get_hw_irq_desc (struct domain *d,struct vcpu *v,unsigned int virq) {
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 51/57 ARM: new VGIC: Add preliminary stub implementation
In reply to Andre PrzywaraThe ARM arch code requires an interrupt controller emulation to implement vgic_clear_pending_irqs(), although it is suspected that it is actually not necessary. Go with a stub for now to make the linker happy.
---
Changelog RFC ... v1:
- split off from former patch, otherwise unchanged
xen/arch/arm/vgic/vgic.c | 8 ++++++++ 1 file changed, 8 insertions(+)
xen/arch/arm/vgic/vgic.c +8 -0
@@ -790,6 +790,14 @@ void gic_dump_vgic_info(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); } +void vgic_clear_pending_irqs (struct vcpu *v) +{ +/* +* TODO: It is unclear whether we really need this, so we might instead +* remove it on the caller site. +*/ +} +/** * arch_move_irqs() - migrate the physical affinity of hardware mapped vIRQs * @v: the vCPU, already assigned to the new pCPU
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 51/57] ARM: new VGIC: Add preliminary stub implementation
Hi Andre,
Quoted 3 lines · Andre Przywara
The ARM arch code requires an interrupt controller emulation to implement
vgic_clear_pending_irqs(), although it is suspected that it is actually not necessary. Go with a stub for now to make the linker happy.
The implementation of that function is fundamentally wrong on the current vGIC for a few reasons:
- lr_mask is reset but the LRs are not. This means when we context
switch back, the LR might still be written and injecting unexpected interrupt (whoops).
- both lists (inflight and pending) are cleared which means that a
physical interrupt pending on that vCPU is lost forever (stay active in the physical so never going to fire again).
Furthermore, I don't think that Xen business to reset the GIC on cpu_on. If anything should be done, then is it on CPU_off to migrate the current interrupts to another vCPU. But IIRC the OS is responsible for that.
So I would kill that function. Any opinions?
Quoted 19 lines
Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- split off from former patch, otherwise unchangedxen/arch/arm/vgic/vgic.c | 8 ++++++++ 1 file changed, 8 insertions(+)xen/arch/arm/vgic/vgic.c +1
-0@@ -790,6 +790,14 @@ void gic_dump_vgic_info(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.ap_list_lock, flags); } +void vgic_clear_pending_irqs (struct vcpu *v)
xen/arch/arm/vgic/vgic.c void gic_dump_vgic_info(struct vcpu *v) · line 803
Quoted 10 lines
xen/arch/arm/vgic/vgic.c +7
-0+{ +/* +* TODO: It is unclear whether we really need this, so we might instead +* remove it on the caller site. +*/ +} +/** * arch_move_irqs() - migrate the physical affinity of hardware mapped vIRQs * @v: the vCPU, already assigned to the new pCPU
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 51/57] ARM: new VGIC: Add preliminary stub implementation
Hi,
Quoted 16 lines · Julien Grall
Hi Andre,
Quoted 3 lines · Andre Przywara
The ARM arch code requires an interrupt controller emulation to implement
vgic_clear_pending_irqs(), although it is suspected that it is actually not necessary. Go with a stub for now to make the linker happy.The implementation of that function is fundamentally wrong on the current vGIC for a few reasons:
-lr_maskis reset but the LRs are not. This means when we context switch back, the LR might still be written and injecting unexpected interrupt (whoops).
- both lists (inflight and pending) are cleared which means that a physical interrupt pending on that vCPU is lost forever (stay active in the physical so never going to fire again).
Quoted 5 lines
Furthermore, I don't think that Xen business to reset the GIC on
cpu_on. If anything should be done, then is it onCPU_offto migrate the current interrupts to another vCPU. But IIRC the OS is responsible for that.So I would kill that function. Any opinions?
So I guess given that the patch is pretty small, we are good with keeping that for now, and solve this together with the old VGIC later.
Cheers,
Andre.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- split off from former patch, otherwise unchanged
xen/arch/arm/vgic/vgic.c| 8 ++++++++1 file changed, 8 insertions(+)xen/arch/arm/vgic/vgic.c +3
-0@@ -790,6 +790,14 @@ void gic_dump_vgic_info(struct vcpu *v) spin_unlock_irqrestore(&v->arch.vgic.ap_list_lock, flags); } +void vgic_clear_pending_irqs(struct vcpu *v) +{ + /* +* TODO: It is unclear whether we really need this, so we might instead
+ * remove it on the caller site.
+ */
+}
Quoted 9 lines
Quoted 6 lines
+
/**
*arch_move_irqs()- migrate the physical affinity of hardware mapped vIRQs
* @v: the vCPU, already assigned to the new pCPUCheers,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 51/57] ARM: new VGIC: Add preliminary stub implementation
Hi,
Quoted 19 lines · Andre Przywara
Hi,
Quoted 16 lines · Julien Grall
Hi Andre,
Quoted 3 lines · Andre Przywara
The ARM arch code requires an interrupt controller emulation to implement
vgic_clear_pending_irqs(), although it is suspected that it is actually not necessary. Go with a stub for now to make the linker happy.The implementation of that function is fundamentally wrong on the current vGIC for a few reasons:
-lr_maskis reset but the LRs are not. This means when we context
switch back, the LR might still be written and injecting unexpected interrupt (whoops).
- both lists (inflight and pending) are cleared which means that a
physical interrupt pending on that vCPU is lost forever (stay active in the physical so never going to fire again).
Quoted 8 lines
Quoted 5 lines
Furthermore, I don't think that Xen business to reset the GIC on
cpu_on. If anything should be done, then is it onCPU_offto migrate the current interrupts to another vCPU. But IIRC the OS is responsible for that.So I would kill that function. Any opinions?
So I guess given that the patch is pretty small, we are good with keeping that for now, and solve this together with the old VGIC later.
I am ok with that.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 52/57 ARM: new VGIC: vgic-init: register VGIC
In reply to Andre PrzywaraThis patch implements the function which is called by Xen when it wants to register the virtual GIC.
This also implements domain_max_vcpus() for the new VGIC, which reports back the maximum number of VCPUs a certain GIC model supports.
---
Changelog RFC ... v1:
- split off definition of domain_max_vcpus()
xen/arch/arm/vgic/vgic-init.c | 60 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic.c | 22 ++++++++++++++++ xen/arch/arm/vgic/vgic.h | 3 +++ 3 files changed, 85 insertions(+) create mode 100644 xen/arch/arm/vgic/vgic-init.c
xen/arch/arm/vgic/vgic-init.c new file +60 -0
@@ -0,0 +1,60 @@ +/* +* Copyright (C) 2015, 2016 ARM Ltd. +* Imported from Linux ("new" KVM VGIC) and heavily adapted to Xen. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/sched.h> +#include <asm/new_vgic.h> + +#include "vgic.h" + +/* CREATION */ + +/** +* domain_vgic_register: create a virtual GIC +* @d: domain pointer +* @mmio_count: pointer to add number of required MMIO regions +* +* was: kvm_vgic_create +*/ +int domain_vgic_register (struct domain *d,int *mmio_count) +{ +switch ( d->arch.vgic.version ) + { +case GIC_V2 : + *mmio_count =1 ; +break ; +default : +BUG (); + } + +if ( d->max_vcpus >domain_max_vcpus (d) ) +return -E2BIG ; + + d->arch.vgic.vgic_dist_base =VGIC_ADDR_UNDEF ; + d->arch.vgic.vgic_cpu_base =VGIC_ADDR_UNDEF ; + d->arch.vgic.vgic_redist_base =VGIC_ADDR_UNDEF ; + +return 0 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/arm/vgic/vgic.c +22 -0
@@ -956,6 +956,28 @@ void vgic_sync_hardware_irq(struct domain *d,spin_unlock_irqrestore (&desc->lock, flags); } +unsigned int domain_max_vcpus (const struct domain *d) +{ +unsigned int vgic_vcpu_limit; + +switch ( d->arch.vgic.version ) + { +#ifdef CONFIG_HAS_GICV3 +case GIC_V3 : + vgic_vcpu_limit =VGIC_V3_MAX_CPUS ; +break ; +#endif +case GIC_V2 : + vgic_vcpu_limit =VGIC_V2_MAX_CPUS ; +break ; +default : + vgic_vcpu_limit =MAX_VIRT_CPUS ; +break ; + } + + return min_t(unsigned int, MAX_VIRT_CPUS, vgic_vcpu_limit); +} +/* * Local variables: * mode: C
xen/arch/arm/vgic/vgic.h +3 -0
@@ -20,6 +20,9 @@#define PRODUCT_ID_XEN 0x58/* ASCII code X */ #define IMPLEMENTER_ARM 0x43b +#define VGIC_ADDR_UNDEF INVALID_PADDR +#define IS_VGIC_ADDR_UNDEF (_x) ((_x) == VGIC_ADDR_UNDEF) +#define VGIC_PRI_BITS 5#define vgic_irq_is_sgi (intid) ((intid) < VGIC_NR_SGIS)
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 53/57 ARM: new VGIC: vgic-init: implement vgic_init
In reply to Andre PrzywaraThis patch allocates and initializes the data structures used to model the vgic distributor and virtual cpu interfaces. At that stage the number of IRQs and number of virtual CPUs is frozen. Implement the various functions that the Xen arch code is expecting to call during domain and VCPU setup to initialize the VGIC. Their prototypes are already in existing header files.
This is based on Linux commit ad275b8bb1e6, written by Eric Auger.
---
Changelog RFC ... v1:
- adapt to former changes
- add missing comment line
- extend commit message
xen/arch/arm/vgic/vgic-init.c | 196 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+)
xen/arch/arm/vgic/vgic-init.c +196 -0
@@ -20,6 +20,77 @@#include "vgic.h" +/* +* Initialization rules: there are multiple stages to the vgic +* initialization, both for the distributor and the CPU interfaces. The basic +* idea is that even though the VGIC is not functional or not requested from +* user space, the critical path of the run loop can still call VGIC functions +* that just won't do anything, without them having to check additional +* initialization flags to ensure they don't look at uninitialized data +* structures. +* +* Distributor: +* +* - vgic_early_init(): initialization of static data that doesn't +* depend on any sizing information or emulation type. No allocation +* is allowed there. +* +* - vgic_init(): allocation and initialization of the generic data +* structures that depend on sizing information (number of CPUs, +* number of interrupts). Also initializes the vcpu specific data +* structures. Can be executed lazily for GICv2. +* +* CPU Interface: +* +* - kvm_vgic_vcpu_early_init(): initialization of static data that +* doesn't depend on any sizing information or emulation type. No +* allocation is allowed there. +*/ + +/** +* vgic_vcpu_early_init() - Initialize static VGIC VCPU data structures +* @vcpu: The VCPU whose VGIC data structures whould be initialized +* +* Only do initialization, but do not actually enable the VGIC CPU interface +* yet. +*/ +static void vgic_vcpu_early_init (struct vcpu *vcpu) +{ +struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic; +int i; + +INIT_LIST_HEAD (&vgic_cpu->ap_list_head); +spin_lock_init (&vgic_cpu->ap_list_lock); + +/* +* Enable and configure all SGIs to be edge-triggered and +* configure all PPIs as level-triggered. +*/ +for ( i =0 ; i <VGIC_NR_PRIVATE_IRQS ; i++ ) + { +struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; + +INIT_LIST_HEAD (&irq->ap_list); +spin_lock_init (&irq->irq_lock); + irq->intid = i; + irq->vcpu =NULL ; + irq->target_vcpu = vcpu; + irq->targets =1U << vcpu->vcpu_id; +atomic_set (&irq->refcount,0 ); +if (vgic_irq_is_sgi (i) ) + { +/* SGIs */ + irq->enabled =1 ; + irq->config =VGIC_CONFIG_EDGE ; + } +else + { +/* PPIs */ + irq->config =VGIC_CONFIG_LEVEL ; + } + } +} +/* CREATION */ /**
@@ -50,6 +121,131 @@ int domain_vgic_register(struct domain *d, int *mmio_count)return 0 ; } +/* INIT/DESTROY */ + +/** +* domain_vgic_init: initialize the dist data structures +* @d: domain pointer +* @nr_spis: number of SPIs +*/ +int domain_vgic_init (struct domain *d,unsigned int nr_spis) +{ +struct vgic_dist *dist = &d->arch.vgic; +int i, ret; + +/* Limit the number of virtual SPIs supported to (1020 - 32) = 988 */ +if ( nr_spis > (1020 -NR_LOCAL_IRQS ) ) +return -EINVAL ; + + dist->nr_spis = nr_spis; + dist->spis = xzalloc_array(struct vgic_irq, nr_spis); +if ( !dist->spis ) +return -ENOMEM ; + +/* +* In the following code we do not take the irq struct lock since +* no other action on irq structs can happen while the VGIC is +* not initialized yet: +* If someone wants to inject an interrupt or does a MMIO access, we +* require prior initialization in case of a virtual GICv3 or trigger +* initialization when using a virtual GICv2. +*/ +for ( i =0 ; i < nr_spis; i++ ) + { +struct vgic_irq *irq = &dist->spis[i]; + + irq->intid = i +VGIC_NR_PRIVATE_IRQS ; +INIT_LIST_HEAD (&irq->ap_list); +spin_lock_init (&irq->irq_lock); + irq->vcpu =NULL ; + irq->target_vcpu =NULL ; +atomic_set (&irq->refcount,0 ); +if ( dist->version ==GIC_V2 ) + irq->targets =0 ; +else + irq->mpidr =0 ; + } + +INIT_LIST_HEAD (&dist->lpi_list_head); +spin_lock_init (&dist->lpi_list_lock); + +if ( dist->version ==GIC_V2 ) + ret =vgic_v2_map_resources (d); +else + ret = -ENXIO ; + +if ( ret ) +return ret; + +/* allocated_irqs() is used by Xen to find available vIRQs */ + d->arch.vgic.allocated_irqs = + xzalloc_array(unsigned long, BITS_TO_LONGS(vgic_num_irqs(d))); +if ( !d->arch.vgic.allocated_irqs ) +return -ENOMEM ; + +/* vIRQ0-15 (SGIs) are reserved */ +for ( i =0 ; i <NR_GIC_SGI ; i++ ) +set_bit (i, d->arch.vgic.allocated_irqs); + +return 0 ; +} + +/** +* vcpu_vgic_init() - Register VCPU-specific KVM iodevs +* was: kvm_vgic_vcpu_init() +* Xen: adding vgic_vx_enable() call +* @vcpu: pointer to the VCPU being created and initialized +*/ +int vcpu_vgic_init (struct vcpu *vcpu) +{ +int ret =0 ; + +vgic_vcpu_early_init (vcpu); + +if (gic_hw_version () ==GIC_V2 ) +vgic_v2_enable (vcpu); +else + ret = -ENXIO ; + +return ret; +} + +void domain_vgic_free (struct domain *d) +{ +struct vgic_dist *dist = &d->arch.vgic; +int i, ret; + +for ( i =0 ; i < dist->nr_spis; i++ ) + { +struct vgic_irq *irq =vgic_get_irq (d,NULL ,32 + i); + +if ( !irq->hw ) +continue ; + + ret =release_guest_irq (d, irq->hwintid); +if ( ret ) +dprintk (XENLOG_G_WARNING , +"d%u: Failed to release virq %u ret = %d\n" , + d->domain_id,32 + i, ret); + } + + dist->ready = false; + dist->initialized = false; + +xfree (dist->spis); +xfree (dist->allocated_irqs); + dist->nr_spis =0 ; +} + +int vcpu_vgic_free (struct vcpu *vcpu) +{ +struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic; + +INIT_LIST_HEAD (&vgic_cpu->ap_list_head); + +return 0 ; +} +/* * Local variables: * mode: C
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 53/57] ARM: new VGIC: vgic-init: implement vgic_init
Hi Andre,
Quoted 55 lines · Andre Przywara
This patch allocates and initializes the data structures used to model the vgic distributor and virtual cpu interfaces. At that stage the number of IRQs and number of virtual CPUs is frozen. Implement the various functions that the Xen arch code is expecting to call during domain and VCPU setup to initialize the VGIC. Their prototypes are already in existing header files.
This is based on Linux commit
ad275b8bb1e6, written by Eric Auger.Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- adapt to former changes
- add missing comment line
- extend commit messagexen/arch/arm/vgic/vgic-init.c | 196 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+)xen/arch/arm/vgic/vgic-init.c +28
-0@@ -20,6 +20,77 @@#include "vgic.h" +/* +* Initialization rules: there are multiple stages to the vgic +* initialization, both for the distributor and the CPU interfaces. The basic +* idea is that even though the VGIC is not functional or not requested from +* user space, the critical path of the run loop can still call VGIC functions +* that just won't do anything, without them having to check additional +* initialization flags to ensure they don't look at uninitialized data +* structures. +* +* Distributor: +* +* - vgic_early_init(): initialization of static data that doesn't +* depend on any sizing information or emulation type. No allocation +* is allowed there. +* +* - vgic_init(): allocation and initialization of the generic data +* structures that depend on sizing information (number of CPUs, +* number of interrupts). Also initializes the vcpu specific data +* structures. Can be executed lazily for GICv2. +* +* CPU Interface: +* +* - kvm_vgic_vcpu_early_init(): initialization of static data that +* doesn't depend on any sizing information or emulation type. No +* allocation is allowed there. +*/ + +/**
xen/arch/arm/vgic/vgic-init.c line 60
Quoted 10 lines
xen/arch/arm/vgic/vgic-init.c +10
-0+* vgic_vcpu_early_init() - Initialize static VGIC VCPU data structures +* @vcpu: The VCPU whose VGIC data structures whould be initialized +* +* Only do initialization, but do not actually enable the VGIC CPU interface +* yet. +*/ +static void vgic_vcpu_early_init (struct vcpu *vcpu) +{ +struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic; +int i;
unsigned please.
xen/arch/arm/vgic/vgic-init.c line 63
Quoted 3 lines
xen/arch/arm/vgic/vgic-init.c +3
-0+ +INIT_LIST_HEAD (&vgic_cpu->ap_list_head); +spin_lock_init (&vgic_cpu->ap_list_lock);
Do we need something similar to 23b40df6f098e3bcb2f105a4909860240976e40f "xen/arm: vgic: Make sure the number of SPIs is a multiple of 32"?
Quoted 38 lines
xen/arch/arm/vgic/vgic-init.c +31
-0+ +/* +* Enable and configure all SGIs to be edge-triggered and +* configure all PPIs as level-triggered. +*/ +for ( i =0 ; i <VGIC_NR_PRIVATE_IRQS ; i++ ) + { +struct vgic_irq *irq = &vgic_cpu->private_irqs[i]; + +INIT_LIST_HEAD (&irq->ap_list); +spin_lock_init (&irq->irq_lock); + irq->intid = i; + irq->vcpu =NULL ; + irq->target_vcpu = vcpu; + irq->targets =1U << vcpu->vcpu_id; +atomic_set (&irq->refcount,0 ); +if (vgic_irq_is_sgi (i) ) + { +/* SGIs */ + irq->enabled =1 ; + irq->config =VGIC_CONFIG_EDGE ; + } +else + { +/* PPIs */ + irq->config =VGIC_CONFIG_LEVEL ; + } + } +} +/* CREATION */ /** @@ -50,6 +121,131 @@ int domain_vgic_register(struct domain *d, int *mmio_count)return 0 ; } +/* INIT/DESTROY */
xen/arch/arm/vgic/vgic-init.c int domain_vgic_register(struct domain *d, int *mmio_count) · line 134
Quoted 10 lines
xen/arch/arm/vgic/vgic-init.c +10
-0+ +/** +* domain_vgic_init: initialize the dist data structures +* @d: domain pointer +* @nr_spis: number of SPIs +*/ +int domain_vgic_init (struct domain *d,unsigned int nr_spis) +{ +struct vgic_dist *dist = &d->arch.vgic; +int i, ret;
Ditto for i.
Quoted 85 lines
xen/arch/arm/vgic/vgic-init.c +85
-0+ +/* Limit the number of virtual SPIs supported to (1020 - 32) = 988 */ +if ( nr_spis > (1020 -NR_LOCAL_IRQS ) ) +return -EINVAL ; + + dist->nr_spis = nr_spis; + dist->spis = xzalloc_array(struct vgic_irq, nr_spis); +if ( !dist->spis ) +return -ENOMEM ; + +/* +* In the following code we do not take the irq struct lock since +* no other action on irq structs can happen while the VGIC is +* not initialized yet: +* If someone wants to inject an interrupt or does a MMIO access, we +* require prior initialization in case of a virtual GICv3 or trigger +* initialization when using a virtual GICv2. +*/ +for ( i =0 ; i < nr_spis; i++ ) + { +struct vgic_irq *irq = &dist->spis[i]; + + irq->intid = i +VGIC_NR_PRIVATE_IRQS ; +INIT_LIST_HEAD (&irq->ap_list); +spin_lock_init (&irq->irq_lock); + irq->vcpu =NULL ; + irq->target_vcpu =NULL ; +atomic_set (&irq->refcount,0 ); +if ( dist->version ==GIC_V2 ) + irq->targets =0 ; +else + irq->mpidr =0 ; + } + +INIT_LIST_HEAD (&dist->lpi_list_head); +spin_lock_init (&dist->lpi_list_lock); + +if ( dist->version ==GIC_V2 ) + ret =vgic_v2_map_resources (d); +else + ret = -ENXIO ; + +if ( ret ) +return ret; + +/* allocated_irqs() is used by Xen to find available vIRQs */ + d->arch.vgic.allocated_irqs = + xzalloc_array(unsigned long, BITS_TO_LONGS(vgic_num_irqs(d))); +if ( !d->arch.vgic.allocated_irqs ) +return -ENOMEM ; + +/* vIRQ0-15 (SGIs) are reserved */ +for ( i =0 ; i <NR_GIC_SGI ; i++ ) +set_bit (i, d->arch.vgic.allocated_irqs); + +return 0 ; +} + +/** +* vcpu_vgic_init() - Register VCPU-specific KVM iodevs +* was: kvm_vgic_vcpu_init() +* Xen: adding vgic_vx_enable() call +* @vcpu: pointer to the VCPU being created and initialized +*/ +int vcpu_vgic_init (struct vcpu *vcpu) +{ +int ret =0 ; + +vgic_vcpu_early_init (vcpu); + +if (gic_hw_version () ==GIC_V2 ) +vgic_v2_enable (vcpu); +else + ret = -ENXIO ; + +return ret; +} + +void domain_vgic_free (struct domain *d) +{ +struct vgic_dist *dist = &d->arch.vgic; +int i, ret; + +for ( i =0 ; i < dist->nr_spis; i++ ) + {
xen/arch/arm/vgic/vgic-init.c int domain_vgic_register(struct domain *d, int *mmio_count) · line 229
Quoted 10 lines
xen/arch/arm/vgic/vgic-init.c +10
-0+struct vgic_irq *irq =vgic_get_irq (d,NULL ,32 + i); + +if ( !irq->hw ) +continue ; + + ret =release_guest_irq (d, irq->hwintid); +if ( ret ) +dprintk (XENLOG_G_WARNING , +"d%u: Failed to release virq %u ret = %d\n" , + d->domain_id,32 + i, ret);
Indentation looks wrong.
Quoted 13 lines
xen/arch/arm/vgic/vgic-init.c +12
-0+ } + + dist->ready = false; + dist->initialized = false; + +xfree (dist->spis); +xfree (dist->allocated_irqs); + dist->nr_spis =0 ; +} + +int vcpu_vgic_free (struct vcpu *vcpu) +{
xen/arch/arm/vgic/vgic-init.c int domain_vgic_register(struct domain *d, int *mmio_count) · line 251
Quoted 10 lines
xen/arch/arm/vgic/vgic-init.c +7
-0+struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic; + +INIT_LIST_HEAD (&vgic_cpu->ap_list_head); + +return 0 ; +} +/* * Local variables: * mode: C
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 54/57 ARM: new VGIC: vgic-init: implement map_resources
In reply to Andre Przywaramap_resources is the last initialization step needed before the first VCPU is run. At that stage the code stores the MMIO base addresses used. Also it registers the respective register frames with the MMIO framework.
This is based on Linux commit cbae53e663ea, written by Eric Auger.
---
Changelog RFC ... v1:
- adapting to previous changes
xen/arch/arm/vgic/vgic-v2.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic.h | 1 + 2 files changed, 67 insertions(+)
xen/arch/arm/vgic/vgic-v2.c +66 -0
@@ -221,6 +221,72 @@ void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) gic_hw_ops->write_lr (lr, &lr_val); } +int vgic_v2_map_resources (struct domain *d) +{ +struct vgic_dist *dist = &d->arch.vgic; +paddr_t cbase, csize; +paddr_t vbase; +int ret; + +/* +* The hardware domain gets the hardware address. +* Guests get the virtual platform layout. +*/ +if (is_hardware_domain (d) ) + { + d->arch.vgic.vgic_dist_base = gic_v2_hw_data.dbase; +/* +* For the hardware domain, we always map the whole HW CPU +* interface region in order to match the device tree (the "reg" +* properties is copied as it is). +* Note that we assume the size of the CPU interface is always +* aligned to PAGE_SIZE. +*/ + cbase = gic_v2_hw_data.cbase;/* was: dist->vgic_cpu_base */ + csize = gic_v2_hw_data.csize; + vbase = gic_v2_hw_data.vbase;/* was: kvm_vgic_global_state.vcpu_base */ + } +else + { + d->arch.vgic.vgic_dist_base =GUEST_GICD_BASE ; +/* +* The CPU interface exposed to the guest is always 8kB. We may +* need to add an offset to the virtual CPU interface base +* address when in the GIC is aliased to get a 8kB contiguous +* region. +*/ +BUILD_BUG_ON (GUEST_GICC_SIZE !=SZ_8K ); + cbase =GUEST_GICC_BASE ; + csize =GUEST_GICC_SIZE ; + vbase = gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; + } + + + ret =vgic_register_dist_iodev (d,gaddr_to_gfn (dist->vgic_dist_base), +VGIC_V2 ); +if ( ret ) + { +gdprintk (XENLOG_ERR ,"Unable to register VGIC MMIO regions\n" ); +return ret; + } + +/* +* Map the gic virtual cpu interface in the gic cpu interface +* region of the guest. +*/ + ret =map_mmio_regions (d,gaddr_to_gfn (cbase), csize /PAGE_SIZE , +maddr_to_mfn (vbase)); +if ( ret ) + { +gdprintk (XENLOG_ERR ,"Unable to remap VGIC CPU to VCPU\n" ); +return ret; + } + + dist->ready = true; + +return 0 ; +} +/* * Local variables: * mode: C
xen/arch/arm/vgic/vgic.h +1 -0
@@ -61,6 +61,7 @@ void vgic_sync_hardware_irq(struct domain *d,void vgic_v2_fold_lr_state (struct vcpu *vcpu);void vgic_v2_populate_lr (struct vcpu *vcpu,struct vgic_irq *irq,int lr);void vgic_v2_set_underflow (struct vcpu *vcpu); +int vgic_v2_map_resources (struct domain *d);int vgic_register_dist_iodev (struct domain *d,gfn_t dist_base_fn,enum vgic_type );
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 54/57] ARM: new VGIC: vgic-init: implement map_resources
Hi Andre,
Quoted 37 lines · Andre Przywara
map_resourcesis the last initialization step needed before the first VCPU is run. At that stage the code stores the MMIO base addresses used. Also it registers the respective register frames with the MMIO framework.This is based on Linux commit
cbae53e663ea, written by Eric Auger.Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- adapting to previous changesxen/arch/arm/vgic/vgic-v2.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic.h | 1 + 2 files changed, 67 insertions(+)xen/arch/arm/vgic/vgic-v2.c +14
-0@@ -221,6 +221,72 @@ void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) gic_hw_ops->write_lr (lr, &lr_val); } +int vgic_v2_map_resources (struct domain *d) +{ +struct vgic_dist *dist = &d->arch.vgic; +paddr_t cbase, csize; +paddr_t vbase; +int ret; + +/* +* The hardware domain gets the hardware address. +* Guests get the virtual platform layout. +*/ +if (is_hardware_domain (d) ) + { + d->arch.vgic.vgic_dist_base = gic_v2_hw_data.dbase;
xen/arch/arm/vgic/vgic-v2.c void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) · line 247
Quoted 10 lines
xen/arch/arm/vgic/vgic-v2.c +10
-0+/* +* For the hardware domain, we always map the whole HW CPU +* interface region in order to match the device tree (the "reg" +* properties is copied as it is). +* Note that we assume the size of the CPU interface is always +* aligned to PAGE_SIZE. +*/ + cbase = gic_v2_hw_data.cbase;/* was: dist->vgic_cpu_base */ + csize = gic_v2_hw_data.csize; + vbase = gic_v2_hw_data.vbase;/* was: kvm_vgic_global_state.vcpu_base */
NIT: Please keep the comment indented the same way.
Quoted 21 lines
xen/arch/arm/vgic/vgic-v2.c +21
-0+ } +else + { + d->arch.vgic.vgic_dist_base =GUEST_GICD_BASE ; +/* +* The CPU interface exposed to the guest is always 8kB. We may +* need to add an offset to the virtual CPU interface base +* address when in the GIC is aliased to get a 8kB contiguous +* region. +*/ +BUILD_BUG_ON (GUEST_GICC_SIZE !=SZ_8K ); + cbase =GUEST_GICC_BASE ; + csize =GUEST_GICC_SIZE ; + vbase = gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; + } + + + ret =vgic_register_dist_iodev (d,gaddr_to_gfn (dist->vgic_dist_base), +VGIC_V2 ); +if ( ret ) + {
xen/arch/arm/vgic/vgic-v2.c void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) · line 278
Quoted 10 lines
xen/arch/arm/vgic/vgic-v2.c +10
-0+gdprintk (XENLOG_ERR ,"Unable to register VGIC MMIO regions\n" ); +return ret; + } + +/* +* Map the gic virtual cpu interface in the gic cpu interface +* region of the guest. +*/ + ret =map_mmio_regions (d,gaddr_to_gfn (cbase), csize /PAGE_SIZE , +maddr_to_mfn (vbase));
Indentation.
Quoted 20 lines
xen/arch/arm/vgic/vgic-v2.c +11
-0+if ( ret ) + { +gdprintk (XENLOG_ERR ,"Unable to remap VGIC CPU to VCPU\n" ); +return ret; + } + + dist->ready = true; + +return 0 ; +} +/* * Local variables: * mode: C xen/arch/arm/vgic/vgic.h +0
-0
xen/arch/arm/vgic/vgic.h void vgic_sync_hardware_irq(struct domain *d, · line 67
Quoted 7 lines
xen/arch/arm/vgic/vgic.h +1
-0@@ -61,6 +61,7 @@ void vgic_sync_hardware_irq(struct domain *d,void vgic_v2_fold_lr_state (struct vcpu *vcpu);void vgic_v2_populate_lr (struct vcpu *vcpu,struct vgic_irq *irq,int lr);void vgic_v2_set_underflow (struct vcpu *vcpu); +int vgic_v2_map_resources (struct domain *d);int vgic_register_dist_iodev (struct domain *d,gfn_t dist_base_fn,enum vgic_type );
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 55/57 ARM: new VGIC: Add vgic_v2_enable
In reply to Andre PrzywaraEnable the VGIC operation by properly initialising the registers in the hypervisor GIC interface.
This is based on Linux commit f7b6985cc3d0, written by Eric Auger.
---
Changelog RFC ... v1:
- drop unneeded vgic_vmcr initialization
- use update_hcr_status wrapper
xen/arch/arm/vgic/vgic-v2.c | 6 ++++++ xen/arch/arm/vgic/vgic.h | 1 + 2 files changed, 7 insertions(+)
xen/arch/arm/vgic/vgic-v2.c +6 -0
@@ -221,6 +221,12 @@ void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) gic_hw_ops->write_lr (lr, &lr_val); } +void vgic_v2_enable (struct vcpu *vcpu) +{ +/* Get the show on the road... */ + gic_hw_ops->update_hcr_status (GICH_HCR_EN ,1 ); +} +int vgic_v2_map_resources (struct domain *d) {struct vgic_dist *dist = &d->arch.vgic;
xen/arch/arm/vgic/vgic.h +1 -0
@@ -61,6 +61,7 @@ void vgic_sync_hardware_irq(struct domain *d,void vgic_v2_fold_lr_state (struct vcpu *vcpu);void vgic_v2_populate_lr (struct vcpu *vcpu,struct vgic_irq *irq,int lr);void vgic_v2_set_underflow (struct vcpu *vcpu); +void vgic_v2_enable (struct vcpu *vcpu);int vgic_v2_map_resources (struct domain *d);int vgic_register_dist_iodev (struct domain *d,gfn_t dist_base_fn,enum vgic_type );
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 55/57] ARM: new VGIC: Add vgic_v2_enable
Hi Andre,
Quoted 6 lines · Andre Przywara
Enable the VGIC operation by properly initialising the registers in the hypervisor GIC interface.
This is based on Linux commit
f7b6985cc3d0, written by Eric Auger.Signed-off-by Andre Przywara <[email protected]>
Would you mind to move that patch before #53? This feels more logical as the first user in there.
Quoted 32 lines
---
Changelog RFC ... v1:
- drop unneededvgic_vmcrinitialization
- useupdate_hcr_statuswrapperxen/arch/arm/vgic/vgic-v2.c | 6 ++++++ xen/arch/arm/vgic/vgic.h | 1 + 2 files changed, 7 insertions(+)xen/arch/arm/vgic/vgic-v2.c +6
-0@@ -221,6 +221,12 @@ void vgic_v2_populate_lr(struct vcpu *vcpu, struct vgic_irq *irq, int lr) gic_hw_ops->write_lr (lr, &lr_val); } +void vgic_v2_enable (struct vcpu *vcpu) +{ +/* Get the show on the road... */ + gic_hw_ops->update_hcr_status (GICH_HCR_EN ,1 ); +} +int vgic_v2_map_resources (struct domain *d) {struct vgic_dist *dist = &d->arch.vgic;xen/arch/arm/vgic/vgic.h +0
-0
xen/arch/arm/vgic/vgic.h void vgic_sync_hardware_irq(struct domain *d, · line 67
Quoted 7 lines
xen/arch/arm/vgic/vgic.h +1
-0@@ -61,6 +61,7 @@ void vgic_sync_hardware_irq(struct domain *d,void vgic_v2_fold_lr_state (struct vcpu *vcpu);void vgic_v2_populate_lr (struct vcpu *vcpu,struct vgic_irq *irq,int lr);void vgic_v2_set_underflow (struct vcpu *vcpu); +void vgic_v2_enable (struct vcpu *vcpu);int vgic_v2_map_resources (struct domain *d);int vgic_register_dist_iodev (struct domain *d,gfn_t dist_base_fn,enum vgic_type );
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 56/57 ARM: allocate two pages for struct vcpu
In reply to Andre PrzywaraAt the moment we allocate exactly one page for struct vcpu on ARM, also have a check in place to prevent it growing beyond 4KB.
As the struct includes the state of all 32 private (per-VCPU) interrupts, we are at 3840 bytes on arm64 at the moment already. Growing the per-IRQ VGIC structure even slightly makes the VCPU quickly exceed the 4K limit. The new VGIC will need more space per virtual IRQ. I spent a few hours trying to trim this down, but couldn't get it below 4KB, even with the nasty hacks piling up to save some bytes here and there.
It turns out that beyond efficiency, maybe, there is no real technical reason this struct has to fit in one page, so lifting the limit to two pages seems like the most pragmatic solution.
---
Changelog RFC ... v1:
- no changes
xen/arch/arm/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
xen/arch/arm/domain.c +6 -3
@@ -502,10 +502,13 @@ void dump_pageframe_info(struct domain *d)struct vcpu *alloc_vcpu_struct (void ) {struct vcpu *v; -BUILD_BUG_ON (sizeof (*v) >PAGE_SIZE ); - v =alloc_xenheap_pages (0 ,0 ); -if ( v !=NULL ) + +BUILD_BUG_ON (sizeof (*v) >2 *PAGE_SIZE ); + v =alloc_xenheap_pages (1 ,0 ); +if ( v !=NULL ) {clear_page (v); +clear_page ((void *)v +PAGE_SIZE ); + }return v; }
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 56/57] ARM: allocate two pages for struct vcpu
Hi,
Quoted 25 lines · Andre Przywara
At the moment we allocate exactly one page for struct vcpu on ARM, also have a check in place to prevent it growing beyond 4KB.
As the struct includes the state of all 32 private (per-VCPU) interrupts, we are at 3840 bytes on arm64 at the moment already. Growing the per-IRQ VGIC structure even slightly makes the VCPU quickly exceed the 4K limit. The new VGIC will need more space per virtual IRQ. I spent a few hours trying to trim this down, but couldn't get it below 4KB, even with the nasty hacks piling up to save some bytes here and there.
It turns out that beyond efficiency, maybe, there is no real technical reason this struct has to fit in one page, so lifting the limit to two pages seems like the most pragmatic solution.Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- no changesxen/arch/arm/domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)xen/arch/arm/domain.c +0
-0
xen/arch/arm/domain.c void dump_pageframe_info(struct domain *d) · line 507
Quoted 9 lines
xen/arch/arm/domain.c +3
-3@@ -502,10 +502,13 @@ void dump_pageframe_info(struct domain *d)struct vcpu *alloc_vcpu_struct (void ) {struct vcpu *v; -BUILD_BUG_ON (sizeof (*v) >PAGE_SIZE ); - v =alloc_xenheap_pages (0 ,0 ); -if ( v !=NULL ) + +BUILD_BUG_ON (sizeof (*v) >2 *PAGE_SIZE ); + v =alloc_xenheap_pages (1 ,0 );
While I am still not a big fan of increasing struct vcpu. We should at least not blindly increase it for anyone. There are indeed some setup where the 8KB solution is not necessary. This is the case of Arm32, and Arm64 (with the old vGIC).
I would also like to hear Stefano's opinion on that one.
xen/arch/arm/domain.c void dump_pageframe_info(struct domain *d) · line 514
Quoted 8 lines
xen/arch/arm/domain.c +3
-0+if ( v !=NULL ) {clear_page (v); +clear_page ((void *)v +PAGE_SIZE ); + }return v; }
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 57/57 ARM: VGIC: wire new VGIC(-v2) files into Xen build system
In reply to Andre PrzywaraNow that we have both the old VGIC prepared to cope with a sibling and the code for the new VGIC in place, lets add a Kconfig option to enable the new code and wire it into the Xen build system.
This will add a compile time option to use either the "old" or the "new" VGIC.
In the moment this is restricted to a vGIC-v2. To make the build system happy, we provide a temporary dummy implementation of vgic_v3_setup_hw() to allow building for now.
---
Changelog RFC ... v1:
- no changes
xen/arch/arm/Kconfig | 6 +++++- xen/arch/arm/Makefile | 10 +++++++++- xen/arch/arm/vgic/vgic.c | 8 ++++++++ xen/common/Makefile | 1 + 4 files changed, 23 insertions(+), 2 deletions(-)
xen/arch/arm/Kconfig +5 -1
@@ -48,7 +48,11 @@ config HAS_GICV3 config HAS_ITS bool prompt "GICv3 ITS MSI controller support" if EXPERT = "y" - depends on HAS_GICV3 + depends on HAS_GICV3 && !NEW_VGIC + +config NEW_VGIC + bool + prompt "Use new VGIC implementation" config SBSA_VUART_CONSOLE bool "Emulated SBSA UART console support"
xen/arch/arm/Makefile +9 -1
@@ -16,7 +16,6 @@ obj-y += domain_build.o obj-y += domctl.o obj-$(EARLY_PRINTK) += early_printk.o obj-y += gic.o -obj-y += gic-vgic.o obj-y += gic-v2.o obj-$(CONFIG_HAS_GICV3) += gic-v3.o obj-$(CONFIG_HAS_ITS) += gic-v3-its.o
@@ -47,10 +46,19 @@ obj-y += sysctl.o obj-y += time.o obj-y += traps.o obj-y += vcpreg.o +ifeq ($(CONFIG_NEW_VGIC),y) +obj-y += vgic/vgic.o +obj-y += vgic/vgic-v2.o +obj-y += vgic/vgic-mmio.o +obj-y += vgic/vgic-mmio-v2.o +obj-y += vgic/vgic-init.o +else +obj-y += gic-vgic.o obj-y += vgic.o obj-y += vgic-v2.o obj-$(CONFIG_HAS_GICV3) += vgic-v3.o obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o +endif obj-y += vm_event.o obj-y += vtimer.o obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
xen/arch/arm/vgic/vgic.c +8 -0
@@ -978,6 +978,14 @@ unsigned int domain_max_vcpus(const struct domain *d) return min_t(unsigned int, MAX_VIRT_CPUS, vgic_vcpu_limit); } +void vgic_v3_setup_hw (paddr_t dbase, +unsigned int nr_rdist_regions, +const struct rdist_region *regions, +unsigned int intid_bits) +{ +/* Dummy implementation to allow building without actual vGICv3 support. */ +} +/* * Local variables: * mode: C
xen/common/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-y += keyhandler.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC) += kimage.o obj-y += lib.o +obj-$(CONFIG_NEW_VGIC) += list_sort.o obj-$(CONFIG_LIVEPATCH) += livepatch.o livepatch_elf.o obj-y += lzo.o obj-$(CONFIG_HAS_MEM_ACCESS) += mem_access.o
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 57/57] ARM: VGIC: wire new VGIC(-v2) files into Xen build system
Hi,
Quoted 25 lines · Andre Przywara
Now that we have both the old VGIC prepared to cope with a sibling and the code for the new VGIC in place, lets add a
Kconfigoption to enable the new code and wire it into the Xen build system.
This will add a compile time option to use either the "old" or the "new" VGIC.
In the moment this is restricted to a vGIC-v2. To make the build system happy, we provide a temporary dummy implementation ofvgic_v3_setup_hw()to allow building for now.Signed-off-by Andre Przywara <[email protected]>---
Changelog RFC ... v1:
- no changesxen/arch/arm/Kconfig | 6 +++++- xen/arch/arm/Makefile | 10 +++++++++- xen/arch/arm/vgic/vgic.c | 8 ++++++++ xen/common/Makefile | 1 + 4 files changed, 23 insertions(+), 2 deletions(-)xen/arch/arm/Kconfig +0
-0
xen/arch/arm/Kconfig config HAS_GICV3 · line 55
Quoted 9 lines
xen/arch/arm/Kconfig +5
-1@@ -48,7 +48,11 @@ config HAS_GICV3 config HAS_ITS bool prompt "GICv3 ITS MSI controller support" if EXPERT = "y" - depends on HAS_GICV3 + depends on HAS_GICV3 && !NEW_VGIC + +config NEW_VGIC + bool + prompt "Use new VGIC implementation"
You potentially want to add a description encouraging people to test and making aware of this is new (not security supported). Or maybe we need to do that in SUPPORT.MD?
Quoted 16 lines
xen/arch/arm/Kconfig +0
-0config SBSA_VUART_CONSOLE bool "Emulated SBSA UART console support"xen/arch/arm/Makefile +0
-1@@ -16,7 +16,6 @@ obj-y += domain_build.o obj-y += domctl.o obj-$(EARLY_PRINTK) += early_printk.o obj-y += gic.o -obj-y += gic-vgic.o obj-y += gic-v2.o obj-$(CONFIG_HAS_GICV3) += gic-v3.o obj-$(CONFIG_HAS_ITS) += gic-v3-its.o
xen/arch/arm/Makefile obj-y += sysctl.o · line 54
Quoted 9 lines
xen/arch/arm/Makefile +6
-0@@ -47,10 +46,19 @@ obj-y += sysctl.o obj-y += time.o obj-y += traps.o obj-y += vcpreg.o +ifeq ($(CONFIG_NEW_VGIC),y) +obj-y += vgic/vgic.o +obj-y += vgic/vgic-v2.o +obj-y += vgic/vgic-mmio.o +obj-y += vgic/vgic-mmio-v2.o +obj-y += vgic/vgic-init.o
Hmmm, I would much prefer to see a Makefile introduced in vgic.
xen/common/Makefile
Quoted 33 lines
xen/arch/arm/Makefile +3
-0+else +obj-y += gic-vgic.o obj-y += vgic.o obj-y += vgic-v2.o obj-$(CONFIG_HAS_GICV3) += vgic-v3.o obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o +endif obj-y += vm_event.o obj-y += vtimer.o obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.oxen/arch/arm/vgic/vgic.c +8
-0@@ -978,6 +978,14 @@ unsigned int domain_max_vcpus(const struct domain *d) return min_t(unsigned int, MAX_VIRT_CPUS, vgic_vcpu_limit); } +void vgic_v3_setup_hw (paddr_t dbase, +unsigned int nr_rdist_regions, +const struct rdist_region *regions, +unsigned int intid_bits) +{ +/* Dummy implementation to allow building without actual vGICv3 support. */ +} +/* * Local variables: * mode: C xen/common/Makefile +0
-0
This would require to CC the "REST".
xen/common/Makefile obj-y += keyhandler.o · line 22
Quoted 5 lines
xen/common/Makefile +1
-0@@ -19,6 +19,7 @@ obj-y += keyhandler.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_KEXEC) += kimage.o obj-y += lib.o +obj-$(CONFIG_NEW_VGIC) += list_sort.
This does not look right to me. I would much prefer a new config or building by default. I would like to hear the opinion of others here.
xen/common/Makefile obj-y += keyhandler.o · line 25
Quoted 4 lines
xen/common/Makefile +0
-0obj-$(CONFIG_LIVEPATCH) += livepatch.o livepatch_elf.o obj-y += lzo.o obj-$(CONFIG_HAS_MEM_ACCESS) += mem_access.o
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 4 lines · Andre Przywara
tl;dr: Coarse changelog below, individual patches have changelogs as well.
This is an updated version of the new VGIC-v2 implementation.
For the brave amongst you who actually want to try it, there is a git repo with these patches on top of current origin/staging:
http://www.linux-arm.org/git?p=xen-ap.git;a=shortlog;h=refs/heads/vgic-new/v1git://linux-arm.org/xen-ap.git branch vgic-new/v1
Cheers,
Andre.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel