vhost: Fix VPP crash when reloading VM with mixed-type ports [VPP-1406] 45/14545/6
authorYichen Wang <yicwang@cisco.com>
Wed, 29 Aug 2018 06:05:27 +0000 (23:05 -0700)
committerDamjan Marion <dmarion@me.com>
Wed, 12 Sep 2018 13:17:32 +0000 (13:17 +0000)
When VM is having mixed type of vhost-user and SRIOV ports, QEMU (RedHat
v2.10) will not send disconnect signal to VPP, and just gives the new
memory region directly. VPP is not able to handle new memory region
mapping without disconnect signal first, which will result in a SEGV.
The fix will handle the VM reboot scenario without explict disconnect
signal from QEMU.

The fix is to invalidate the avail, desc, and used pointers in the txvq
when the new memory regions are received. This is because these pointers
are not valid anymore with the new memory regions. In the input node, check
to make sure the avail pointer is valid and punt if not.

Change-Id: Ieb8b427b202f4442a58907dab1661d63a03650de
Signed-off-by: Yichen Wang <yicwang@cisco.com>
src/vnet/devices/virtio/vhost_user.c
src/vnet/devices/virtio/vhost_user_input.c

index a8a7ae8..796be4b 100644 (file)
@@ -73,7 +73,9 @@ get_huge_page_size (int fd)
 static void
 unmap_all_mem_regions (vhost_user_intf_t * vui)
 {
-  int i, r;
+  int i, r, q;
+  vhost_user_vring_t *vq;
+
   for (i = 0; i < vui->nregions; i++)
     {
       if (vui->region_mmap_addr[i] != MAP_FAILED)
@@ -104,6 +106,14 @@ unmap_all_mem_regions (vhost_user_intf_t * vui)
        }
     }
   vui->nregions = 0;
+
+  for (q = 0; q < VHOST_VRING_MAX_N; q++)
+    {
+      vq = &vui->vrings[q];
+      vq->avail = 0;
+      vq->used = 0;
+      vq->desc = 0;
+    }
 }
 
 static void
index 1a7a0c4..2614048 100644 (file)
@@ -259,6 +259,10 @@ vhost_user_if_input (vlib_main_t * vm,
   u16 thread_index = vm->thread_index;
   u16 copy_len = 0;
 
+  /* The descriptor table is not ready yet */
+  if (PREDICT_FALSE (txvq->avail == 0))
+    return 0;
+
   {
     /* do we have pending interrupts ? */
     vhost_user_vring_t *rxvq = &vui->vrings[VHOST_VRING_IDX_RX (qid)];