From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com
Cc: mlureau@redhat.com, Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] vhost-user: no more leak QEMU virtual addresses to user backend
Date: Tue, 19 Dec 2017 19:11:29 +0100 [thread overview]
Message-ID: <20171219181129.24189-4-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20171219181129.24189-1-maxime.coquelin@redhat.com>
The user backends use user address from VHOST_USER_SET_MEM_TABLE
to be able to handle VHOST_USER_SET_VRING_ADDR and
VHOST_USER_IOTLB_MSG payloads.
Now that Vhost code supports the use of Guest physical addresses
instead of QEMU process virtual addresses, let's do the switch
to avoid leaking QEMU process VAs to the user backend.
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
hw/virtio/vhost-user.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 5ebeb8401b..e783d88afe 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -317,7 +317,8 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
&offset);
fd = memory_region_get_fd(mr);
if (fd > 0) {
- msg.payload.memory.regions[fd_num].user_addr = reg->userspace_addr;
+ /* Use GPA as user address not to leak QEMU VAs to the backend */
+ msg.payload.memory.regions[fd_num].user_addr = reg->guest_phys_addr;
msg.payload.memory.regions[fd_num].memory_size = reg->memory_size;
msg.payload.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr;
msg.payload.memory.regions[fd_num].mmap_offset = offset;
@@ -924,7 +925,7 @@ static void vhost_user_set_iotlb_callback(struct vhost_dev *dev, int enabled)
const VhostOps user_ops = {
.backend_type = VHOST_BACKEND_TYPE_USER,
- .uaddr_type = VHOST_UADDR_TYPE_HVA,
+ .uaddr_type = VHOST_UADDR_TYPE_GPA,
.vhost_backend_init = vhost_user_init,
.vhost_backend_cleanup = vhost_user_cleanup,
.vhost_backend_memslots_limit = vhost_user_memslots_limit,
--
2.14.3
next prev parent reply other threads:[~2017-12-19 18:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 18:11 [Qemu-devel] [PATCH 0/3] Vhost: no more leak QEMU virtual addresses to user backend Maxime Coquelin
2017-12-19 18:11 ` [Qemu-devel] [PATCH 1/3] vhost-user: rename VhostUserMemory userspace_addr field to user_addr Maxime Coquelin
2017-12-19 18:11 ` [Qemu-devel] [PATCH 2/3] vhost: introduce backend's user address type Maxime Coquelin
2017-12-19 18:11 ` Maxime Coquelin [this message]
2017-12-20 16:07 ` [Qemu-devel] [PATCH 0/3] Vhost: no more leak QEMU virtual addresses to user backend Stefan Hajnoczi
2017-12-21 3:53 ` Michael S. Tsirkin
2017-12-21 14:01 ` Maxime Coquelin
2017-12-21 14:16 ` Maxime Coquelin
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=20171219181129.24189-4-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=mlureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).