On 2017年03月29日 16:41, Paolo Bonzini wrote:
On 29/03/2017 10:37, Jason Wang wrote:
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 03592c5..73e69ac 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -176,6 +176,10 @@ err_used:
address_space_cache_destroy(&new->desc);
err_desc:
g_free(new);
+ atomic_rcu_set(&vq->vring.caches, NULL);
+ if (old) {
+ call_rcu(old, virtio_free_region_cache, rcu);
+ }
}
/* virt queue functions */
Paolo
This looks a good fix but may not solve this issue completely. Depends
on the iova that guest uses, address_space_cache_init() may succeed even
in this case since vtd does a passthrough translation in this case.
Can you explain this more?
Paolo
Yes. In this case, virtio-net-pci is not reset, but vtd has been reset.
So virtio-net-pci will still try to use the iova of ring to setup the
cache but now vtd treat iova as gpa since dmar has been disabled during
reset. (E.g In my test with Linux driver, desc map succeed but used fail.)
Thanks