vhost/crypto: fix write back source
authorFan Zhang <roy.fan.zhang@intel.com>
Mon, 28 Sep 2020 10:59:16 +0000 (11:59 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 28 Sep 2020 11:19:02 +0000 (13:19 +0200)
This patch fixes vhost crypto library for the incorrect source and
destination buffer calculation in the copy mode.

Fixes: cd1e8f03abf0 ("vhost/crypto: fix packet copy in chaining mode")
Cc: stable@dpdk.org
Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Chenbo Xia <chenbo.xia@intel.com>
lib/librte_vhost/vhost_crypto.c

index 494f490..f1cc32a 100644 (file)
@@ -749,14 +749,14 @@ prepare_write_back_data(struct vhost_crypto_data_req *vc_req,
                wb_data->src = src + offset;
                dlen = desc->len;
                dst = IOVA_TO_VVA(uint8_t *, vc_req, desc->addr,
-                       &dlen, VHOST_ACCESS_RW) + offset;
+                       &dlen, VHOST_ACCESS_RW);
                if (unlikely(!dst || dlen != desc->len)) {
                        VC_LOG_ERR("Failed to map descriptor");
                        goto error_exit;
                }
 
-               wb_data->dst = dst;
-               wb_data->len = RTE_MIN(desc->len - offset, write_back_len);
+               wb_data->dst = dst + offset;
+               wb_data->len = RTE_MIN(dlen - offset, write_back_len);
                write_back_len -= wb_data->len;
                src += offset + wb_data->len;
                offset = 0;
@@ -801,7 +801,7 @@ prepare_write_back_data(struct vhost_crypto_data_req *vc_req,
                        goto error_exit;
                }
 
-               wb_data->src = src;
+               wb_data->src = src + offset;
                wb_data->dst = dst;
                wb_data->len = RTE_MIN(desc->len - offset, write_back_len);
                write_back_len -= wb_data->len;