From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, yliu@fridaylinux.org, tiwei.bie@intel.com,
jianfeng.tan@intel.com, vkaplans@redhat.com
Cc: stable@dpdk.org, jfreiman@redhat.com,
Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH v2 3/3] vhost: don't invalidate vrings if new addresses are identical
Date: Fri, 24 Nov 2017 19:08:26 +0100 [thread overview]
Message-ID: <20171124180826.18439-4-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20171124180826.18439-1-maxime.coquelin@redhat.com>
In VHOST_USER_SET_VRING_ADDR handling, don't invalidate the vring
if it has already been mapped and new addresses are identical.
When initiating live-migration, VHOST_USER_SET_VRING_ADDR is sent
again by QEMU, but the queues are enabled, so invalidating them
can result in NULL pointer de-referencing. In this case, it is
not needed to perform the invalidation, as the new addresses provided
by QEMU are indentical to the initial ones.
Fixes: eefac9536a90 ("vhost: postpone device creation until rings are mapped")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost_user.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 4b03dbbca..29a431687 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -436,6 +436,14 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
return dev;
}
+static int
+is_same_vring_addrs(struct vhost_vring_addr *a1, struct vhost_vring_addr *a2)
+{
+ return ((a1->desc_user_addr == a2->desc_user_addr) &&
+ (a1->used_user_addr == a2->used_user_addr) &&
+ (a1->avail_user_addr == a2->avail_user_addr));
+}
+
/*
* The virtio device sends us the desc, used and avail ring addresses.
* This function then converts these to our address space.
@@ -453,6 +461,13 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, VhostUserMsg *msg)
/* addr->index refers to the queue index. The txq 1, rxq is 0. */
vq = dev->virtqueue[msg->payload.addr.index];
+ /*
+ * If it is trying to set the same rings addresses, don't invalidate as
+ * PMD threads might be using them.
+ */
+ if (is_same_vring_addrs(addr, &vq->ring_addrs))
+ return 0;
+
/*
* Rings addresses should not be interpreted as long as the ring is not
* started and enabled
--
2.14.3
prev parent reply other threads:[~2017-11-24 18:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 18:08 [dpdk-dev] [PATCH v2 0/3] vhost: MQ live-migration fixes Maxime Coquelin
2017-11-24 18:08 ` [dpdk-dev] [PATCH v2 1/3] vhost: fix fd leak in VHOST_USER_SET_LOG_BASE Maxime Coquelin
2017-11-24 18:08 ` [dpdk-dev] [PATCH v2 2/3] vhost: protect dirty logging against logging base change Maxime Coquelin
2017-11-27 8:16 ` Victor Kaplansky
2017-11-27 8:27 ` Maxime Coquelin
2017-11-27 8:42 ` Victor Kaplansky
2017-11-27 9:00 ` Maxime Coquelin
2017-11-28 10:06 ` Maxime Coquelin
2018-02-14 2:03 ` Tan, Jianfeng
2018-02-14 7:52 ` Maxime Coquelin
2018-02-22 2:54 ` Tan, Jianfeng
2017-11-24 18:08 ` Maxime Coquelin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171124180826.18439-4-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=dev@dpdk.org \
--cc=jfreiman@redhat.com \
--cc=jianfeng.tan@intel.com \
--cc=stable@dpdk.org \
--cc=tiwei.bie@intel.com \
--cc=vkaplans@redhat.com \
--cc=yliu@fridaylinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).