xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/2] xen/arm: remove race conditions in irq migration
@ 2017-04-04  1:08 Stefano Stabellini
  2017-04-04  1:09 ` [PATCH v6 1/2] arm: remove irq from inflight, then change physical affinity Stefano Stabellini
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Stabellini @ 2017-04-04  1:08 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 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 second patch addressed the last two issues by refusing any irq
migration requests while one request is already in-progress and not yet
completed.


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.


Changes in v6:
- smp_mb/smb_wmb
- refuse nested irq migration requests instead of trying to handle them


Stefano Stabellini (2):
      arm: remove irq from inflight, then change physical affinity
      vgic: refuse irq migration when one is already in progress

 xen/arch/arm/gic.c         |  8 +++++++-
 xen/arch/arm/vgic-v2.c     |  7 +++----
 xen/arch/arm/vgic-v3.c     |  7 ++++---
 xen/arch/arm/vgic.c        | 14 +++++++++-----
 xen/include/asm-arm/vgic.h |  2 +-
 5 files changed, 24 insertions(+), 14 deletions(-)

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

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

end of thread, other threads:[~2017-04-05 12:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-04  1:08 [PATCH v6 0/2] xen/arm: remove race conditions in irq migration Stefano Stabellini
2017-04-04  1:09 ` [PATCH v6 1/2] arm: remove irq from inflight, then change physical affinity Stefano Stabellini
2017-04-04  1:09   ` [PATCH v6 2/2] vgic: refuse irq migration when one is already in progress Stefano Stabellini
2017-04-05 12:35     ` Julien Grall
2017-04-05 12:30   ` [PATCH v6 1/2] arm: remove irq from inflight, then change physical affinity Julien Grall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).