2007-11-07 02:52:32

by Anthony Liguori

[permalink] [raw]
Subject: [PATCH][VIRTIO] Fix vring_init() ring computations

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 <[email protected]>

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)


2007-11-07 05:57:21

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH][VIRTIO] Fix vring_init() ring computations

On Wednesday 07 November 2007 13:52:29 Anthony Liguori wrote:
> This patch fixes a typo in vring_init().

Thanks, applied.

I've put it in the new, experimental virtio git tree on git.kernel.org.

Cheers,
Rusty.

2007-11-08 01:06:17

by Anthony Liguori

[permalink] [raw]
Subject: Re: [PATCH][VIRTIO] Fix vring_init() ring computations

Rusty Russell wrote:
> On Wednesday 07 November 2007 13:52:29 Anthony Liguori wrote:
>
>> This patch fixes a typo in vring_init().
>>
>
> Thanks, applied.
>
> I've put it in the new, experimental virtio git tree on git.kernel.org.
>

Hrm, perhaps you forgot to push? I don't see it in the tree although I
see the config ops refactoring.

Regards,

Anthony Liguori

> Cheers,
> Rusty.
>

2007-11-08 02:25:27

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH][VIRTIO] Fix vring_init() ring computations

On Thursday 08 November 2007 12:06:07 Anthony Liguori wrote:
> Rusty Russell wrote:
> > On Wednesday 07 November 2007 13:52:29 Anthony Liguori wrote:
> >> This patch fixes a typo in vring_init().
> >
> > Thanks, applied.
> >
> > I've put it in the new, experimental virtio git tree on git.kernel.org.
>
> Hrm, perhaps you forgot to push? I don't see it in the tree although I
> see the config ops refactoring.

It should be in the patches/1 branch. I've pushed again...

Thanks,
Rusty.