[PATCH][VIRTIO] Fix vring_init() ring computations

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Anthony Liguori <aliguori@...>, Rusty Russell <rusty@...>, <virtualization@...>
Date: Tuesday, November 6, 2007 - 10:52 pm

This patch fixes a typo in vring_init().  This happens to work today in lguest
because the sizeof(struct vring_desc) is 16 and struct vring contains 3
pointers and an unsigned int so on 32-bit
sizeof(struct vring_desc) == sizeof(struct vring).  However, this is no longer
true on 64-bit where the bug is exposed.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index ac69e7b..5b88d21 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -92,8 +92,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p)
 {
 	vr->num = num;
 	vr->desc = p;
-	vr->avail = p + num*sizeof(struct vring);
-	vr->used = p + (num+1)*(sizeof(struct vring) + sizeof(__u16));
+	vr->avail = p + num*sizeof(struct vring_desc);
+	vr->used = p + (num+1)*(sizeof(struct vring_desc) + sizeof(__u16));
 }
 
 static inline unsigned vring_size(unsigned int num)
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH][VIRTIO] Fix vring_init() ring computations, Anthony Liguori, (Tue Nov 6, 10:52 pm)
Re: [PATCH][VIRTIO] Fix vring_init() ring computations, Rusty Russell, (Wed Nov 7, 1:57 am)
Re: [PATCH][VIRTIO] Fix vring_init() ring computations, Anthony Liguori, (Wed Nov 7, 9:06 pm)
Re: [PATCH][VIRTIO] Fix vring_init() ring computations, Rusty Russell, (Wed Nov 7, 10:25 pm)