From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2686EA04B5 for ; Tue, 3 Dec 2019 19:29:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A6D01BFB7; Tue, 3 Dec 2019 19:29:10 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id C81771BFA9 for ; Tue, 3 Dec 2019 19:29:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575397748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VyBtMzJSz42+TRYOU4k+maflyqVSosob+WmqiwEo6wY=; b=GDLX3Et2fr3QyqJZtuK056uKhUxokedKxVQSNwm2I4sLv39O8BAFAFwF234CufUsE//gIZ vdOiflUXgoVMia3wDbTC0uB/9NLeTLHpDGMsQx6hwVcCaY3HKEU1/QILUTd8Axx/NszuSA +Aj0flmoatM1SUBA4FCqiPli54JlamA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-_pBx0yJgNXuBrkccYpoAiA-1; Tue, 03 Dec 2019 13:27:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3908B800D4C; Tue, 3 Dec 2019 18:27:40 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5CDE5C557; Tue, 3 Dec 2019 18:27:38 +0000 (UTC) From: Kevin Traynor To: Tiwei Bie Cc: Yilong Lv , Maxime Coquelin , dpdk stable Date: Tue, 3 Dec 2019 18:26:16 +0000 Message-Id: <20191203182714.17297-7-ktraynor@redhat.com> In-Reply-To: <20191203182714.17297-1-ktraynor@redhat.com> References: <20191203182714.17297-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: _pBx0yJgNXuBrkccYpoAiA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'vhost: fix vring address handling during live migration' has been queued to LTS release 18.11.6 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/10/19. 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. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/9e564f00737fd16e04= 2c1a68a8ddd5b3d4eb88fa Thanks. Kevin. --- >From 9e564f00737fd16e042c1a68a8ddd5b3d4eb88fa Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Mon, 19 Aug 2019 19:34:56 +0800 Subject: [PATCH] vhost: fix vring address handling during live migration [ upstream commit 72d002b3ebda4686306cc5124b7a8bdf627dba0a ] When live migration starts, QEMU will set ring addrs again for each virtqueue. In this case, we should try to translate ring addrs after we invalidating the ring, otherwise virtqueues can be enabled with the addrs untranslated. Besides, also leverage the access_ok flag in non-IOMMU case to prevent the data path accessing invalidated virtqueues. Fixes: 5a4933e56be4 ("vhost: postpone ring address translations at kick tim= e only") Reported-by: Yilong Lv Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- lib/librte_vhost/vhost.c | 3 +-- lib/librte_vhost/vhost_user.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 488cf1694..0b5ee0307 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -195,5 +195,5 @@ vring_translate(struct virtio_net *dev, struct vhost_vi= rtqueue *vq) =20 =09if (!(dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) -=09=09goto out; +=09=09return -1; =20 =09if (vq_is_packed(dev)) { @@ -204,5 +204,4 @@ vring_translate(struct virtio_net *dev, struct vhost_vi= rtqueue *vq) =09=09=09return -1; =09} -out: =09vq->access_ok =3D 1; =20 diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 15688ded5..bb74d0b93 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -678,4 +678,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09=09} =20 +=09=09vq->access_ok =3D 1; =09=09return dev; =09} @@ -736,4 +737,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =20 =09vq->log_guest_addr =3D addr->log_guest_addr; +=09vq->access_ok =3D 1; =20 =09VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n", @@ -760,4 +762,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, str= uct VhostUserMsg *msg, =09struct vhost_virtqueue *vq; =09struct vhost_vring_addr *addr =3D &msg->payload.addr; +=09bool access_ok; =20 =09if (validate_msg_fds(msg, 0) !=3D 0) @@ -770,4 +773,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, str= uct VhostUserMsg *msg, =09vq =3D dev->virtqueue[msg->payload.addr.index]; =20 +=09access_ok =3D vq->access_ok; + =09/* =09 * Rings addresses should not be interpreted as long as the ring is not @@ -778,6 +783,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, str= uct VhostUserMsg *msg, =09vring_invalidate(dev, vq); =20 -=09if (vq->enabled && (dev->features & -=09=09=09=09(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { +=09if ((vq->enabled && (dev->features & +=09=09=09=09(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) || +=09=09=09access_ok) { =09=09dev =3D translate_ring_addresses(dev, msg->payload.addr.index); =09=09if (!dev) @@ -1412,4 +1418,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev, =09msg->fd_num =3D 0; =20 +=09vring_invalidate(dev, vq); + =09return VH_RESULT_REPLY; } --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-03 17:29:52.229861657 +0000 +++ 0007-vhost-fix-vring-address-handling-during-live-migrati.patch=092019-= 12-03 17:29:51.701750973 +0000 @@ -1 +1 @@ -From 72d002b3ebda4686306cc5124b7a8bdf627dba0a Mon Sep 17 00:00:00 2001 +From 9e564f00737fd16e042c1a68a8ddd5b3d4eb88fa Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 72d002b3ebda4686306cc5124b7a8bdf627dba0a ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -25 +26 @@ -index 981837b5d..77be16069 100644 +index 488cf1694..0b5ee0307 100644 @@ -28 +29 @@ -@@ -359,5 +359,5 @@ vring_translate(struct virtio_net *dev, struct vhost_v= irtqueue *vq) +@@ -195,5 +195,5 @@ vring_translate(struct virtio_net *dev, struct vhost_v= irtqueue *vq) @@ -35 +36 @@ -@@ -368,5 +368,4 @@ vring_translate(struct virtio_net *dev, struct vhost_v= irtqueue *vq) +@@ -204,5 +204,4 @@ vring_translate(struct virtio_net *dev, struct vhost_v= irtqueue *vq) @@ -42 +43 @@ -index e4ae027a0..3d2db6edf 100644 +index 15688ded5..bb74d0b93 100644 @@ -45 +46 @@ -@@ -623,4 +623,5 @@ translate_ring_addresses(struct virtio_net *dev, int v= q_index) +@@ -678,4 +678,5 @@ translate_ring_addresses(struct virtio_net *dev, int v= q_index) @@ -51 +52 @@ -@@ -681,4 +682,5 @@ translate_ring_addresses(struct virtio_net *dev, int v= q_index) +@@ -736,4 +737,5 @@ translate_ring_addresses(struct virtio_net *dev, int v= q_index) @@ -57 +58 @@ -@@ -705,4 +707,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, +@@ -760,4 +762,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, @@ -62,2 +63,2 @@ - =09if (dev->mem =3D=3D NULL) -@@ -712,4 +715,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, + =09if (validate_msg_fds(msg, 0) !=3D 0) +@@ -770,4 +773,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, @@ -70 +71 @@ -@@ -720,6 +725,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, +@@ -778,6 +783,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, @@ -80 +81 @@ -@@ -1326,4 +1332,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev, +@@ -1412,4 +1418,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev, @@ -85 +86 @@ - =09return RTE_VHOST_MSG_RESULT_REPLY; + =09return VH_RESULT_REPLY;