aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-02-17 12:11:33 -0500
committerMichael S. Tsirkin <mst@redhat.com>2010-02-28 12:42:35 -0500
commit86e9424d7252bae5ad1c17b4b8088193e6b27cbe (patch)
treeff6bbcf61d5518bd4e06f4cd09c20a4b1f6fcaa4
parent655ffee284dfcf9a24ac0343f3e5ee6db85b85c5 (diff)
vhost: logging thinko fix
vhost was dong some complex math to get offset to log at, and got it wrong by a couple of bytes, while in fact it's simple: get address where we write, subtract start of buffer, add log base. Do it this way. Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/vhost/vhost.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 6eb15259f5ae..db21518f7e8d 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1004,10 +1004,14 @@ int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len)
1004 if (unlikely(vq->log_used)) { 1004 if (unlikely(vq->log_used)) {
1005 /* Make sure data is seen before log. */ 1005 /* Make sure data is seen before log. */
1006 smp_wmb(); 1006 smp_wmb();
1007 log_write(vq->log_base, vq->log_addr + sizeof *vq->used->ring * 1007 /* Log used ring entry write. */
1008 (vq->last_used_idx % vq->num), 1008 log_write(vq->log_base,
1009 sizeof *vq->used->ring); 1009 vq->log_addr + ((void *)used - (void *)vq->used),
1010 log_write(vq->log_base, vq->log_addr, sizeof *vq->used->ring); 1010 sizeof *used);
1011 /* Log used index update. */
1012 log_write(vq->log_base,
1013 vq->log_addr + offsetof(struct vring_used, idx),
1014 sizeof vq->used->idx);
1011 if (vq->log_ctx) 1015 if (vq->log_ctx)
1012 eventfd_signal(vq->log_ctx, 1); 1016 eventfd_signal(vq->log_ctx, 1);
1013 } 1017 }