net/ifc: do not notify before HW ready
authorXiao Wang <xiao.w.wang@intel.com>
Fri, 14 Sep 2018 01:25:17 +0000 (09:25 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 27 Sep 2018 23:41:01 +0000 (01:41 +0200)
If the device is not clearly reset by the previous driver and holds
some invalid ring addr, and the relay thread kicks it before HW is
properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in
the vdpa_ifcvf_start function, if a kick relay happens before
vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
Cc: stable@dpdk.org
Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/ifc/ifcvf_vdpa.c

index 88d8140..b9d0068 100644 (file)
@@ -469,11 +469,11 @@ update_datapath(struct ifcvf_internal *internal)
                if (ret)
                        goto err;
 
-               ret = setup_notify_relay(internal);
+               ret = vdpa_ifcvf_start(internal);
                if (ret)
                        goto err;
 
-               ret = vdpa_ifcvf_start(internal);
+               ret = setup_notify_relay(internal);
                if (ret)
                        goto err;
 
@@ -481,12 +481,12 @@ update_datapath(struct ifcvf_internal *internal)
        } else if (rte_atomic32_read(&internal->running) &&
                   (!rte_atomic32_read(&internal->started) ||
                    !rte_atomic32_read(&internal->dev_attached))) {
-               vdpa_ifcvf_stop(internal);
-
                ret = unset_notify_relay(internal);
                if (ret)
                        goto err;
 
+               vdpa_ifcvf_stop(internal);
+
                ret = vdpa_disable_vfio_intr(internal);
                if (ret)
                        goto err;