All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] xen/arm: remove race conditions in irq migration
@ 2017-03-01 22:15 Stefano Stabellini
  2017-03-01 22:15 ` [PATCH v5 1/3] arm: remove irq from inflight, then change physical affinity Stefano Stabellini
  0 siblings, 1 reply; 18+ messages in thread
From: Stefano Stabellini @ 2017-03-01 22:15 UTC (permalink / raw)
  To: julien.grall; +Cc: xen-devel, sstabellini

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@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-04-03 21:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01 22:15 [PATCH v5 0/3] xen/arm: remove race conditions in irq migration Stefano Stabellini
2017-03-01 22:15 ` [PATCH v5 1/3] arm: remove irq from inflight, then change physical affinity Stefano Stabellini
2017-03-01 22:15   ` [PATCH v5 2/3] xen/arm: move setting of new target vcpu to vgic_migrate_irq Stefano Stabellini
2017-03-03 17:38     ` Julien Grall
2017-03-29 23:48       ` Stefano Stabellini
2017-03-31 15:29         ` Julien Grall
2017-03-01 22:15   ` [PATCH v5 3/3] xen/arm: vgic_migrate_irq: do not race against GIC_IRQ_GUEST_MIGRATING Stefano Stabellini
2017-03-03 17:47     ` Julien Grall
2017-03-29 23:47       ` Stefano Stabellini
2017-03-31 16:02         ` Julien Grall
2017-03-31 20:24           ` Stefano Stabellini
2017-04-03 11:03             ` Julien Grall
2017-04-03 21:24               ` Stefano Stabellini
2017-03-01 23:24   ` [PATCH v5 1/3] arm: remove irq from inflight, then change physical affinity Julien Grall
2017-03-03 17:04     ` Julien Grall
2017-03-03 19:34       ` Stefano Stabellini
2017-03-03 19:38         ` Julien Grall
2017-03-22 23:59           ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.