[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v8 6/7] xen/arm: clear pending irq queues on do_psci_cpu_on
Don't inject irqs to vcpus that are down. Also when (re)activating a vcpu, clear the vgic and gic irq queues: we don't want to inject any irqs that couldn't be handled by the vcpu right before going offline. Changes in v7: - call gic_clear_pending_irqs before clearing VPF_down on do_psci_cpu_on. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- xen/arch/arm/gic.c | 12 ++++++++++++ xen/arch/arm/psci.c | 3 +++ xen/arch/arm/vgic.c | 16 ++++++++++++++-- xen/include/asm-arm/gic.h | 2 ++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 2a44cf8..8d35e0e 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -576,6 +576,18 @@ static void gic_restore_pending_irqs(struct vcpu *v) } +void gic_clear_pending_irqs(struct vcpu *v) +{ + struct pending_irq *p, *t; + unsigned long flags; + + spin_lock_irqsave(&gic.lock, flags); + v->arch.lr_mask = 0; + list_for_each_entry_safe ( p, t, &v->arch.vgic.lr_pending, lr_queue ) + list_del_init(&p->lr_queue); + spin_unlock_irqrestore(&gic.lock, flags); +} + static void gic_inject_irq_start(void) { register_t hcr = READ_SYSREG(HCR_EL2); diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c index 1761791..18feead 100644 --- a/xen/arch/arm/psci.c +++ b/xen/arch/arm/psci.c @@ -15,6 +15,7 @@ #include <xen/types.h> #include <asm/current.h> +#include <asm/gic.h> #include <asm/psci.h> int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point) @@ -33,6 +34,8 @@ int do_psci_cpu_on(uint32_t vcpuid, register_t entry_point) if ( (ctxt = alloc_vcpu_guest_context()) == NULL ) return PSCI_DENIED; + vgic_clear_pending_irqs(v); + memset(ctxt, 0, sizeof(*ctxt)); ctxt->user_regs.pc64 = (u64) entry_point; ctxt->sctlr = SCTLR_BASE; diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 0e9cc4a..f9c1a6b 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -641,6 +641,18 @@ struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq) return n; } +void vgic_clear_pending_irqs(struct vcpu *v) +{ + struct pending_irq *p, *t; + unsigned long flags; + + spin_lock_irqsave(&v->arch.vgic.lock, flags); + list_for_each_entry_safe ( p, t, &v->arch.vgic.inflight_irqs, inflight ) + list_del_init(&p->inflight); + gic_clear_pending_irqs(v); + spin_unlock_irqrestore(&v->arch.vgic.lock, flags); +} + void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual) { int idx = irq >> 2, byte = irq & 0x3; @@ -652,8 +664,8 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual) spin_lock_irqsave(&v->arch.vgic.lock, flags); - /* irq already pending */ - if (!list_empty(&n->inflight)) + /* vcpu offline or irq already pending */ + if (test_bit(_VPF_down, &v->pause_flags) || !list_empty(&n->inflight)) { spin_unlock_irqrestore(&v->arch.vgic.lock, flags); return; diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 0f9f74b..84ebc83 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -140,12 +140,14 @@ extern void domain_vgic_free(struct domain *d); extern int vcpu_vgic_init(struct vcpu *v); extern void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq,int virtual); +extern void vgic_clear_pending_irqs(struct vcpu *v); extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq); extern void gic_route_ppis(void); extern void gic_route_spis(void); extern void gic_inject(void); +extern void gic_clear_pending_irqs(struct vcpu *v); extern int gic_events_need_delivery(void); extern void __cpuinit init_maintenance_interrupt(void); -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |