From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, jasowang@redhat.com
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
jfreimann@redhat.com, tiwei.bie@intel.com,
maxime.coquelin@redhat.com
Subject: [PATCH V3 12/15] vhost: vhost_put_user() can accept metadata type
Date: Wed, 17 Jul 2019 06:52:52 -0400 [thread overview]
Message-ID: <20190717105255.63488-13-jasowang@redhat.com> (raw)
In-Reply-To: <20190717105255.63488-1-jasowang@redhat.com>
We assumes used ring update is the only user for vhost_put_user() in
the past. This may not be the case for the incoming packed ring which
may update the descriptor ring for used. So introduce a new type
parameter.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/vhost/vhost.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 6044cdea124f..3fa1adf2cb90 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1178,7 +1178,7 @@ static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
return __vhost_get_user_slow(vq, addr, size, type);
}
-#define vhost_put_user(vq, x, ptr) \
+#define vhost_put_user(vq, x, ptr, type) \
({ \
int ret = -EFAULT; \
if (!vq->iotlb) { \
@@ -1186,7 +1186,7 @@ static inline void __user *__vhost_get_user(struct vhost_virtqueue *vq,
} else { \
__typeof__(ptr) to = \
(__typeof__(ptr)) __vhost_get_user(vq, ptr, \
- sizeof(*ptr), VHOST_ADDR_USED); \
+ sizeof(*ptr), type); \
if (to != NULL) \
ret = __put_user(x, to); \
else \
@@ -1230,7 +1230,7 @@ static inline int vhost_put_avail_event(struct vhost_virtqueue *vq)
#endif
return vhost_put_user(vq, cpu_to_vhost16(vq, vq->avail_idx),
- vhost_avail_event(vq));
+ vhost_avail_event(vq), VHOST_ADDR_USED);
}
static inline int vhost_put_used(struct vhost_virtqueue *vq,
@@ -1267,7 +1267,7 @@ static inline int vhost_put_used_flags(struct vhost_virtqueue *vq)
#endif
return vhost_put_user(vq, cpu_to_vhost16(vq, vq->used_flags),
- &vq->used->flags);
+ &vq->used->flags, VHOST_ADDR_USED);
}
static inline int vhost_put_used_idx(struct vhost_virtqueue *vq)
@@ -1284,7 +1284,7 @@ static inline int vhost_put_used_idx(struct vhost_virtqueue *vq)
#endif
return vhost_put_user(vq, cpu_to_vhost16(vq, vq->last_used_idx),
- &vq->used->idx);
+ &vq->used->idx, VHOST_ADDR_USED);
}
#define vhost_get_user(vq, x, ptr, type) \
--
2.18.1
next prev parent reply other threads:[~2019-07-17 10:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-17 10:52 [PATCH V3 00/15] Packed virtqueue support for vhost Jason Wang
2019-07-17 10:52 ` [PATCH V3 01/15] vhost: simplify meta data pointer accessing Jason Wang
2019-07-17 10:52 ` [PATCH V3 02/15] vhost: remove the unnecessary parameter of vhost_vq_avail_empty() Jason Wang
2019-07-17 10:52 ` [PATCH V3 03/15] vhost: remove unnecessary parameter of vhost_enable_notify()/vhost_disable_notify Jason Wang
2019-07-17 10:52 ` [PATCH V3 04/15] vhost-net: don't use vhost_add_used_n() for zerocopy Jason Wang
2019-07-17 10:52 ` [PATCH V3 05/15] vhost: introduce helpers to manipulate shadow used ring Jason Wang
2019-07-17 10:52 ` [PATCH V3 06/15] vhost_net: switch TX to use shadow used ring API Jason Wang
2019-07-17 10:52 ` [PATCH V3 07/15] vhost_net: calculate last used length once for mergeable buffer Jason Wang
2019-07-17 10:52 ` [PATCH V3 08/15] vhost_net: switch to use shadow used ring API for RX Jason Wang
2019-07-17 10:52 ` [PATCH V3 09/15] vhost: do not export vhost_add_used_n() and vhost_add_used_and_signal_n() Jason Wang
2019-07-17 10:52 ` [PATCH V3 10/15] vhost: hide used ring layout from device Jason Wang
2019-07-17 10:52 ` [PATCH V3 11/15] vhost: do not use vring_used_elem Jason Wang
2019-07-17 10:52 ` Jason Wang [this message]
2019-07-17 10:52 ` [PATCH V3 13/15] vhost: packed ring support Jason Wang
2019-07-17 10:52 ` [PATCH V3 14/15] vhost: event suppression for packed ring Jason Wang
2019-07-17 10:52 ` [PATCH V3 15/15] vhost: enable packed virtqueues Jason Wang
2019-07-17 11:02 ` [PATCH V3 00/15] Packed virtqueue support for vhost Michael S. Tsirkin
2019-07-17 12:27 ` Jason Wang
2019-07-17 14:28 ` Michael S. Tsirkin
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=20190717105255.63488-13-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=jfreimann@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.coquelin@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tiwei.bie@intel.com \
--cc=virtualization@lists.linux-foundation.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).