From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by dpdk.org (Postfix) with ESMTP id 2C6221B3A9 for ; Wed, 3 Oct 2018 18:52:55 +0200 (CEST) Received: by mail-wr1-f53.google.com with SMTP id z4-v6so6931187wrb.1 for ; Wed, 03 Oct 2018 09:52:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=th88qzZRZt8G6V4YIcIeUaTt0DIF9pbbsbsKw2cazgI=; b=fyJjMyzakFWGtx697MiTKFFh6wrDK3T9hAUGHmfXEkzpokoToiCQPyj7cgmxqe9kL0 z1d3k3IXdjw2IQcyOhmcgQCdp41uBCknK0Xtof/Rcihdn8+I8VJTQGp+di8sZ3ViwR85 dcwWEYc+oiIlvhWIuKDSC9rOlRUZyPvZy6Rasc5E+4M4+AVZ4eHVsclEG1hhqsd1s3en +NDX4yw9bxizwINKVkxqYGnWT4bkz8muaxaEGzsr7POQYkyW++wvgmQ4T3Ri91CLfRz7 hTt0ZKDgNcq6MEOk0xhFjkviwkcEPu8YomCT+xsEYs+1vY/50kgpIW0ZRtLK3T7YCxb0 T0sw== X-Gm-Message-State: ABuFfohlsAFoZwYw5emZEVrHJK8FYTEHKUg6loNGMvT995CClwzxNII/ 3VYfCbQpiz2qB7vH0zAuBANr7pkP X-Google-Smtp-Source: ACcGV63AbJiyEJlGM4Z8jm64S/aX1wLoZvMhqiF4BI1o5PQpGg+vakfe4ApgADdHOoTczWDnwIjGDQ== X-Received: by 2002:adf:e94b:: with SMTP id m11-v6mr2022784wrn.126.1538585574691; Wed, 03 Oct 2018 09:52:54 -0700 (PDT) Received: from localhost ([2a01:4b00:f419:6f00:8361:8946:ba2b:d556]) by smtp.gmail.com with ESMTPSA id x15-v6sm1360303wrt.90.2018.10.03.09.52.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Oct 2018 09:52:53 -0700 (PDT) From: Luca Boccassi To: Jiayu Hu Cc: Maxime Coquelin , dpdk stable Date: Wed, 3 Oct 2018 17:52:37 +0100 Message-Id: <20181003165239.8531-4-bluca@debian.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003165239.8531-1-bluca@debian.org> References: <20181003162121.16364-1-bluca@debian.org> <20181003165239.8531-1-bluca@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'vhost: fix corner case for enqueue operation' has been queued to LTS release 16.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Oct 2018 16:52:55 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/05/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Luca Boccassi --- >>From 05cdc11afb96e78f2d2f31e129a7e6ac59e4bc99 Mon Sep 17 00:00:00 2001 From: Jiayu Hu Date: Mon, 17 Sep 2018 11:54:42 +0800 Subject: [PATCH] vhost: fix corner case for enqueue operation [ upstream commit 729199397f9fc4ba265e94d492c792244e8c364b ] When performing enqueue operations on the split and packed rings, if the reserved buffer length from the descriptor table exceeds 65535, the returned length by fill_vec_buf_split/_packed() overflows. This patch is to avoid this corner case. Fixes: f689586bc060 ("vhost: shadow used ring update") Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path") Fixes: 2f3225a7d69b ("vhost: add vector filling support for packed ring") Fixes: 37f5e79a271d ("vhost: add shadow used ring support for packed rings") Fixes: a922401f35cc ("vhost: add Rx support for packed ring") Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring") Signed-off-by: Jiayu Hu Reviewed-by: Maxime Coquelin --- lib/librte_vhost/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index cfd69ceac1..eaee1c78f1 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -272,7 +272,7 @@ flush_shadow_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq) static inline void __attribute__((always_inline)) update_shadow_used_ring(struct vhost_virtqueue *vq, - uint16_t desc_idx, uint16_t len) + uint16_t desc_idx, uint32_t len) { uint16_t i = vq->shadow_used_idx++; @@ -610,7 +610,7 @@ static inline int __attribute__((always_inline)) fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq, uint32_t avail_idx, uint32_t *vec_idx, struct buf_vector *buf_vec, uint16_t *desc_chain_head, - uint16_t *desc_chain_len) + uint32_t *desc_chain_len) { uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)]; uint32_t vec_id = *vec_idx; @@ -684,7 +684,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq, uint16_t tries = 0; uint16_t head_idx = 0; - uint16_t len = 0; + uint32_t len = 0; *num_buffers = 0; cur_idx = vq->last_avail_idx; -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-10-03 17:44:54.657796019 +0100 +++ 0004-vhost-fix-corner-case-for-enqueue-operation.patch 2018-10-03 17:44:54.570534601 +0100 @@ -1,8 +1,10 @@ -From 729199397f9fc4ba265e94d492c792244e8c364b Mon Sep 17 00:00:00 2001 +From 05cdc11afb96e78f2d2f31e129a7e6ac59e4bc99 Mon Sep 17 00:00:00 2001 From: Jiayu Hu Date: Mon, 17 Sep 2018 11:54:42 +0800 Subject: [PATCH] vhost: fix corner case for enqueue operation +[ upstream commit 729199397f9fc4ba265e94d492c792244e8c364b ] + When performing enqueue operations on the split and packed rings, if the reserved buffer length from the descriptor table exceeds 65535, the returned length by fill_vec_buf_split/_packed() @@ -14,47 +16,37 @@ Fixes: 37f5e79a271d ("vhost: add shadow used ring support for packed rings") Fixes: a922401f35cc ("vhost: add Rx support for packed ring") Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring") -Cc: stable@dpdk.org Signed-off-by: Jiayu Hu Reviewed-by: Maxime Coquelin --- - lib/librte_vhost/virtio_net.c | 20 +++++++++++--------- - 1 file changed, 11 insertions(+), 9 deletions(-) + lib/librte_vhost/virtio_net.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c -index 4bfae76a6e..f8794ee198 100644 +index cfd69ceac1..eaee1c78f1 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c -@@ -122,7 +122,7 @@ flush_shadow_used_ring_split(struct virtio_net *dev, struct vhost_virtqueue *vq) +@@ -272,7 +272,7 @@ flush_shadow_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq) - static __rte_always_inline void - update_shadow_used_ring_split(struct vhost_virtqueue *vq, + static inline void __attribute__((always_inline)) + update_shadow_used_ring(struct vhost_virtqueue *vq, - uint16_t desc_idx, uint16_t len) + uint16_t desc_idx, uint32_t len) { uint16_t i = vq->shadow_used_idx++; -@@ -186,7 +186,7 @@ flush_shadow_used_ring_packed(struct virtio_net *dev, - - static __rte_always_inline void - update_shadow_used_ring_packed(struct vhost_virtqueue *vq, -- uint16_t desc_idx, uint16_t len, uint16_t count) -+ uint16_t desc_idx, uint32_t len, uint16_t count) - { - uint16_t i = vq->shadow_used_idx++; - -@@ -329,7 +329,7 @@ static __rte_always_inline int - fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - uint32_t avail_idx, uint16_t *vec_idx, +@@ -610,7 +610,7 @@ static inline int __attribute__((always_inline)) + fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq, + uint32_t avail_idx, uint32_t *vec_idx, struct buf_vector *buf_vec, uint16_t *desc_chain_head, -- uint16_t *desc_chain_len, uint8_t perm) -+ uint32_t *desc_chain_len, uint8_t perm) +- uint16_t *desc_chain_len) ++ uint32_t *desc_chain_len) { uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)]; - uint16_t vec_id = *vec_idx; -@@ -409,7 +409,7 @@ reserve_avail_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - uint16_t max_tries, tries = 0; + uint32_t vec_id = *vec_idx; +@@ -684,7 +684,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq, + uint16_t tries = 0; uint16_t head_idx = 0; - uint16_t len = 0; @@ -62,53 +54,6 @@ *num_buffers = 0; cur_idx = vq->last_avail_idx; -@@ -452,7 +452,7 @@ static __rte_always_inline int - fill_vec_buf_packed_indirect(struct virtio_net *dev, - struct vhost_virtqueue *vq, - struct vring_packed_desc *desc, uint16_t *vec_idx, -- struct buf_vector *buf_vec, uint16_t *len, uint8_t perm) -+ struct buf_vector *buf_vec, uint32_t *len, uint8_t perm) - { - uint16_t i; - uint32_t nr_descs; -@@ -508,7 +508,7 @@ static __rte_always_inline int - fill_vec_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, - uint16_t avail_idx, uint16_t *desc_count, - struct buf_vector *buf_vec, uint16_t *vec_idx, -- uint16_t *buf_id, uint16_t *len, uint8_t perm) -+ uint16_t *buf_id, uint32_t *len, uint8_t perm) - { - bool wrap_counter = vq->avail_wrap_counter; - struct vring_packed_desc *descs = vq->desc_packed; -@@ -573,7 +573,7 @@ reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, - uint16_t max_tries, tries = 0; - - uint16_t buf_id = 0; -- uint16_t len = 0; -+ uint32_t len = 0; - uint16_t desc_count; - - *num_buffers = 0; -@@ -1379,7 +1379,8 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, - - for (i = 0; i < count; i++) { - struct buf_vector buf_vec[BUF_VECTOR_MAX]; -- uint16_t head_idx, dummy_len; -+ uint16_t head_idx; -+ uint32_t dummy_len; - uint16_t nr_vec = 0; - int err; - -@@ -1486,7 +1487,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, - - for (i = 0; i < count; i++) { - struct buf_vector buf_vec[BUF_VECTOR_MAX]; -- uint16_t buf_id, dummy_len; -+ uint16_t buf_id; -+ uint32_t dummy_len; - uint16_t desc_count, nr_vec = 0; - int err; - -- 2.19.0