From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id E54581B1B3 for ; Wed, 24 Jan 2018 16:42:48 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9911922723; Wed, 24 Jan 2018 10:42:48 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:42:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=p61ei5s16WuO1isE2 4GV1aG9ltp/eJ2qhLxT7klEQ6Y=; b=dKj08wtSons3sHUGbaPpMpfvisxrEcCDG lMeIBPim3pj28GFO8AWl+jM7O7WGzstbL7KnmzOhjuFUzFZc8CvaxDReqxhNV/Ht I8F4jHTGTz/1hX6LeX4E4kSjNnzEOoq/A8u6O+nSraTDGMczyK6M4LWQxUBpHaTw ZPaKE5hxRDCR/8ySYTSKQstOi4m9U0orS10C7lJeheVCYoOuj8doQ5nFiqt1+uL9 Ugqnif5gFBU5A/JHm20wsKQQsyBaKWYR9JD6v3XbMaCI73OCMT3Dkhn+LuDlfl5o pNl9fYJO22RwYRAojBOQA+Tx2cDMYZZFVUMwUH+NtnbUaKcW6Yj6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=p61ei5s16WuO1isE24GV1aG9ltp/eJ2qhLxT7klEQ6Y=; b=ELYxgG0y VJ4JD7ZiUdGrfm5/XkVPo+5tK/J0MeoMn2TA6cFVxnzX/aG07fa8ZZzye/1sJ3PF 9qJ9Jn/P/rjKLYUWM8pcv16uvpBahxl6zRNCsuuHTZuVWwhATG2YM1VvNgKYeIAG NjsQuxkwjTfdJkTVXbhf0bjHVkw1Lx0iHwYbWqrXT2A+Mcnu+jnB5uj4PNP/SZtf fem59T71cMI9dtrU/ITK7mBzxk7sXIXWQMAStBqpL2xYt/ppnphdQqYCSfAaVsfI HWjtcVw+3iBMP0GLZe3CYNtFIXTkbkAc+MwIeQae3V/d+9Mv4fCHCLSApeGnxNfw K8HixzHOxxgdaA== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 9830E7E354; Wed, 24 Jan 2018 10:42:45 -0500 (EST) From: Yuanhan Liu To: Junjie Chen Cc: Maxime Coquelin , Yuanhan Liu , dpdk stable Date: Wed, 24 Jan 2018 23:33:42 +0800 Message-Id: <1516808026-25523-154-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'vhost: fix mbuf free' has been queued to LTS release 17.11.1 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, 24 Jan 2018 15:42:49 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 92462daad716340aebc973312faba7dce1c7376b Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Wed, 17 Jan 2018 10:45:53 -0500 Subject: [PATCH] vhost: fix mbuf free [ upstream commit 3ebd930588b7847906e08e2645a35761a90abf2a ] dequeue zero copy change buf_addr and buf_iova of mbuf, and return to mbuf pool without restore them, it breaks vm memory if others allocate mbuf from same pool since mbuf reset doesn't reset buf_addr and buf_iova. Fixes: b0a985d1f340 ("vhost: add dequeue zero copy") Signed-off-by: Junjie Chen Reviewed-by: Maxime Coquelin Acked-by: Yuanhan Liu --- lib/librte_vhost/virtio_net.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 79d80f7..17158c1 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -1157,6 +1157,22 @@ mbuf_is_consumed(struct rte_mbuf *m) return true; } +static __rte_always_inline void +restore_mbuf(struct rte_mbuf *m) +{ + uint32_t mbuf_size, priv_size; + + while (m) { + priv_size = rte_pktmbuf_priv_size(m->pool); + mbuf_size = sizeof(struct rte_mbuf) + priv_size; + /* start of buffer is after mbuf structure and priv data */ + + m->buf_addr = (char *)m + mbuf_size; + m->buf_iova = rte_mempool_virt2iova(m) + mbuf_size; + m = m->next; + } +} + uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count) @@ -1208,6 +1224,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, nr_updated += 1; TAILQ_REMOVE(&vq->zmbuf_list, zmbuf, next); + restore_mbuf(zmbuf->mbuf); rte_pktmbuf_free(zmbuf->mbuf); put_zmbuf(zmbuf); vq->nr_zmbuf -= 1; -- 2.7.4