From: Rusty Russell <rusty@rustcorp.com.au>
To: Wang Sheng-Hui <shhuiw@gmail.com>, wanlong.gao@gmail.com
Cc: mst@redhat.com, virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virtio: fix size computation according to the definition of struct vring_used in vring_size
Date: Mon, 29 Aug 2011 12:23:12 +0930 [thread overview]
Message-ID: <87fwkl2ajr.fsf@rustcorp.com.au> (raw)
In-Reply-To: <4E58BE42.8030700@gmail.com>
On Sat, 27 Aug 2011 17:52:02 +0800, Wang Sheng-Hui <shhuiw@gmail.com> wrote:
> On 2011年08月27日 17:34, Wang Sheng-Hui wrote:
> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> index 4a32cb6..300af76 100644
> --- a/include/linux/virtio_ring.h
> +++ b/include/linux/virtio_ring.h
> @@ -135,13 +135,13 @@ 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_desc);
> - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
> - & ~(align - 1));
> + vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + 16
> + + align-1) & ~(align - 1));
> }
This + 16 should be + sizeof(__u16), right? It's just the
used_event_idx which has been added:
* __u16 available[num];
* __u16 used_event_idx;
*
* // Padding to the next align boundary.
* char pad[];
*
* [USED]
> static inline unsigned vring_size(unsigned int num, unsigned long align)
> {
> - return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
> + return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
> + align - 1) & ~(align - 1))
> + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
This is correct.
And, yes, since align is always 4096, it's currently just a cleanup, but
it makes things much less confusing!
Thanks,
Rusty.
next prev parent reply other threads:[~2011-08-29 5:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-27 1:07 [PATCH] virtio: fix size computation according to the definition of struct vring_used in vring_size Wang Sheng-Hui
2011-08-27 2:49 ` Wanlong Gao
2011-08-27 9:34 ` Wang Sheng-Hui
2011-08-27 9:52 ` Wang Sheng-Hui
2011-08-28 11:31 ` Michael S. Tsirkin
2011-08-28 12:48 ` Wang Sheng-Hui
2011-08-29 2:53 ` Rusty Russell [this message]
2011-08-29 6:51 ` Wang Sheng-Hui
2011-08-29 7:55 ` Wang Sheng-Hui
2011-08-30 0:12 ` Rusty Russell
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=87fwkl2ajr.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=shhuiw@gmail.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wanlong.gao@gmail.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