]> git.karo-electronics.de Git - karo-tx-linux.git/commit
virtio-pci: make reset operation safer
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 17 Nov 2011 15:41:15 +0000 (17:41 +0200)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 22 Nov 2011 00:08:57 +0000 (11:08 +1100)
commitb64aded83a1bbbccce68a1f17782719c23b8fd94
tree2a67489ea4218a2f88103b233c33505f927afff9
parent0cd418ef40acd10114c4e1a40658224c336daddd
virtio-pci: make reset operation safer

virtio pci device reset actually just does an I/O
write, which in PCI is really posted, that is it
can complete on CPU before the device has received it.

Further, interrupts might have been pending on
another CPU, so device callback might get invoked after reset.

This conflicts with how drivers use reset, which is typically:
reset
unregister
a callback running after reset completed can race with
unregister, potentially leading to use after free bugs.

Fix by flushing out the write, and flushing pending interrupts.

This assumes that device is never reset from
its vq/config callbacks, or in parallel with being
added/removed, document this assumption.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/virtio/virtio_pci.c
include/linux/virtio_config.h