[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v5 0/3] xen/arm: remove race conditions in irq migration



Hi all,

this patch series removes three race conditions affecting the current
code base.

The first race condition is between gic_update_one_lr and
vgic_vcpu_inject_irq: as soon as gic_update_one_lr calls
irq_set_affinity a new interrupt could be injected in the new pcpu,
eventually vgic_vcpu_inject_irq is called which manipulates the inflight
list. The first patch solves this race by adding a barrier in
gic_update_one_lr. This patch was suggested by Julien.

The second race condition happens when gic_update_one_lr runs
simultaneously with vgic_store_itargetsr and vgic_migrate_irq. Setting
the new target is done after calling vgic_migrate_irq, which means that
gic_update_one_lr could end up setting the physical affinity to the one
of the old pcpu. The second patch solves the problem by moving the code
to set the new vcpu target from vgic_store_itargetsr to
vgic_migrate_irq. The code is still not entirely safe due to the last
race condition.

The third race condition happens again between gic_update_one_lr and
vgic_migrate_irq: when GIC_IRQ_GUEST_MIGRATING is already set and
vgic_migrate_irq is called again, it will take a different vgic lock
from the one that gic_update_one_lr is taking. The third patch addresses
this problem by adding barriers and busy waits to make sure that
vgic_migrate_irq and gic_update_one_lr can run safely at the same time,
even without taking the same lock.

For your reference, it is not possible to take the p->desc lock from
gic_update_one_lr, because the correct lock ordering is p->desc lock,
then vgic lock.


Stefano Stabellini (3):
      arm: remove irq from inflight, then change physical affinity
      xen/arm: move setting of new target vcpu to vgic_migrate_irq
      xen/arm: vgic_migrate_irq: do not race against GIC_IRQ_GUEST_MIGRATING

 xen/arch/arm/gic.c         | 10 +++++++++-
 xen/arch/arm/vgic-v2.c     |  5 ++---
 xen/arch/arm/vgic-v3.c     |  4 +---
 xen/arch/arm/vgic.c        | 27 ++++++++++++++++++++++-----
 xen/include/asm-arm/vgic.h |  3 ++-
 5 files changed, 36 insertions(+), 13 deletions(-)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.