On 2017年03月13日 18:18, Paolo Bonzini wrote:

On 13/03/2017 10:55, Cornelia Huck wrote:
On Mon, 13 Mar 2017 14:29:41 +0800
Jason Wang <jasow...@redhat.com> wrote:

To avoid access stale memory region cache after reset, this patch
check the existence of virtqueue pfn for all exported virtqueue access
helpers before trying to use them.

Cc: Cornelia Huck <cornelia.h...@de.ibm.com>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Signed-off-by: Jason Wang <jasow...@redhat.com>
---
  hw/virtio/virtio.c | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index efce4b3..76cc81b 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -322,6 +322,10 @@ static int virtio_queue_empty_rcu(VirtQueue *vq)
          return 0;
      }

+    if (unlikely(!vq->vring.avail)) {
+        return 0;
Shouldn't that rather return !0 (denoting a non-existing queue as
empty)?
Yes, and the check should also go first (before the function can return 0).

Paolo

Yes, will fix in V3.

Thanks

Reply via email to