]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
arm: remove irq from inflight, then change physical affinity
authorStefano Stabellini <sstabellini@kernel.org>
Wed, 5 Apr 2017 20:28:42 +0000 (13:28 -0700)
committerStefano Stabellini <sstabellini@kernel.org>
Thu, 6 Apr 2017 23:15:49 +0000 (16:15 -0700)
This patch fixes a potential race that could happen when
gic_update_one_lr and vgic_vcpu_inject_irq run simultaneously.

When GIC_IRQ_GUEST_MIGRATING is set, we must make sure that the irq has
been removed from inflight before changing physical affinity, to avoid
concurrent accesses to p->inflight, as vgic_vcpu_inject_irq will take a
different vcpu lock.

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/gic.c

index 9522c6c25cded1e5a7df86fab63b633b591f0cf0..f5dc88530b83647cb4289e0a242c5bb7ef3aca1d 100644 (file)
@@ -503,6 +503,13 @@ static void gic_update_one_lr(struct vcpu *v, int i)
             gic_raise_guest_irq(v, irq, p->priority);
         else {
             list_del_init(&p->inflight);
+            /*
+             * Remove from inflight, then change physical affinity. It
+             * makes sure that when a new interrupt is received on the
+             * next pcpu, inflight is already cleared. No concurrent
+             * accesses to inflight.
+             */
+            smp_wmb();
             if ( test_and_clear_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) )
             {
                 struct vcpu *v_target = vgic_get_target_vcpu(v, irq);