* [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes
@ 2013-08-19 9:28 yinyin
2013-08-19 14:30 ` Stefan Hajnoczi
0 siblings, 1 reply; 8+ messages in thread
From: yinyin @ 2013-08-19 9:28 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Hi,all:
in func virtqueue_get_avail_bytes, when found a indirect desc, we need loop over it.
/* loop over the indirect descriptor table */
indirect = 1;
max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
num_bufs = i = 0;
desc_pa = vring_desc_addr(desc_pa, i);
But, It init i to 0, then use i to update desc_pa. so we will always get :
desc_pa = vring_desc_addr(desc_pa, 0);
is it right?or should we update desc_pa first, then init i to 0?
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 09f62c6..554ae6f 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
/* loop over the indirect descriptor table */
indirect = 1;
max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
- num_bufs = i = 0;
desc_pa = vring_desc_addr(desc_pa, i);
+ num_bufs = i = 0;
}
do {
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes
2013-08-19 9:28 [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes yinyin
@ 2013-08-19 14:30 ` Stefan Hajnoczi
2013-08-22 6:47 ` [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table yinyin
2013-09-03 11:10 ` [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes Amit Shah
0 siblings, 2 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-08-19 14:30 UTC (permalink / raw)
To: yinyin; +Cc: Amit Shah, qemu-devel@nongnu.org, Michael S. Tsirkin
On Mon, Aug 19, 2013 at 05:28:44PM +0800, yinyin wrote:
> Hi,all:
> in func virtqueue_get_avail_bytes, when found a indirect desc, we need loop over it.
> /* loop over the indirect descriptor table */
> indirect = 1;
> max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> num_bufs = i = 0;
> desc_pa = vring_desc_addr(desc_pa, i);
> But, It init i to 0, then use i to update desc_pa. so we will always get :
> desc_pa = vring_desc_addr(desc_pa, 0);
> is it right?or should we update desc_pa first, then init i to 0?
Is there a way to trigger a crash or erorr from a normal running guest?
Affected devices: serial, rng, and net - they call
virtqueue_get_avail_bytes() directly or indirectly.
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 09f62c6..554ae6f 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
> /* loop over the indirect descriptor table */
> indirect = 1;
> max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> - num_bufs = i = 0;
> desc_pa = vring_desc_addr(desc_pa, i);
> + num_bufs = i = 0;
I agree, this looks wrong. git-blame(1) doesn't reveal anything
interesting. Looks like this bug has been around since 2009!
Please resend your patch according to the guidelines here:
http://qemu-project.org/Contribute/SubmitAPatch
In particular, please include a Signed-off-by: Your Name <your@email.org> line.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table
2013-08-19 14:30 ` Stefan Hajnoczi
@ 2013-08-22 6:47 ` yinyin
2013-08-22 11:59 ` Stefan Hajnoczi
2013-08-25 9:51 ` Michael S. Tsirkin
2013-09-03 11:10 ` [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes Amit Shah
1 sibling, 2 replies; 8+ messages in thread
From: yinyin @ 2013-08-22 6:47 UTC (permalink / raw)
To: qemu-devel@nongnu.org; +Cc: Amit Shah, Stefan Hajnoczi, Michael S. Tsirkin
virtqueue_get_avail_bytes: when found a indirect desc, we need loop over it.
/* loop over the indirect descriptor table */
indirect = 1;
max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
num_bufs = i = 0;
desc_pa = vring_desc_addr(desc_pa, i);
But, It init i to 0, then use i to update desc_pa. so we will always get:
desc_pa = vring_desc_addr(desc_pa, 0);
the last two line should swap.
Signed-off-by: Yin Yin <yin.yin@cs2c.com.cn>
---
hw/virtio/virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index f03c45d..2f1e73b 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
/* loop over the indirect descriptor table */
indirect = 1;
max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
- num_bufs = i = 0;
desc_pa = vring_desc_addr(desc_pa, i);
+ num_bufs = i = 0;
}
do {
--
1.7.12.4 (Apple Git-37)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table
2013-08-22 6:47 ` [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table yinyin
@ 2013-08-22 11:59 ` Stefan Hajnoczi
2013-08-25 9:51 ` Michael S. Tsirkin
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2013-08-22 11:59 UTC (permalink / raw)
To: yinyin; +Cc: Amit Shah, qemu-devel@nongnu.org, Michael S. Tsirkin
On Thu, Aug 22, 2013 at 02:47:16PM +0800, yinyin wrote:
> virtqueue_get_avail_bytes: when found a indirect desc, we need loop over it.
> /* loop over the indirect descriptor table */
> indirect = 1;
> max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> num_bufs = i = 0;
> desc_pa = vring_desc_addr(desc_pa, i);
> But, It init i to 0, then use i to update desc_pa. so we will always get:
> desc_pa = vring_desc_addr(desc_pa, 0);
> the last two line should swap.
>
> Signed-off-by: Yin Yin <yin.yin@cs2c.com.cn>
> ---
> hw/virtio/virtio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table
2013-08-22 6:47 ` [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table yinyin
2013-08-22 11:59 ` Stefan Hajnoczi
@ 2013-08-25 9:51 ` Michael S. Tsirkin
1 sibling, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2013-08-25 9:51 UTC (permalink / raw)
To: yinyin; +Cc: Amit Shah, Stefan Hajnoczi, qemu-devel@nongnu.org
On Thu, Aug 22, 2013 at 02:47:16PM +0800, yinyin wrote:
> virtqueue_get_avail_bytes: when found a indirect desc, we need loop over it.
> /* loop over the indirect descriptor table */
> indirect = 1;
> max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> num_bufs = i = 0;
> desc_pa = vring_desc_addr(desc_pa, i);
> But, It init i to 0, then use i to update desc_pa. so we will always get:
> desc_pa = vring_desc_addr(desc_pa, 0);
> the last two line should swap.
>
> Signed-off-by: Yin Yin <yin.yin@cs2c.com.cn>
Applied, thanks everyone
> ---
> hw/virtio/virtio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index f03c45d..2f1e73b 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
> /* loop over the indirect descriptor table */
> indirect = 1;
> max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> - num_bufs = i = 0;
> desc_pa = vring_desc_addr(desc_pa, i);
> + num_bufs = i = 0;
> }
>
> do {
> --
> 1.7.12.4 (Apple Git-37)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes
2013-08-19 14:30 ` Stefan Hajnoczi
2013-08-22 6:47 ` [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table yinyin
@ 2013-09-03 11:10 ` Amit Shah
2013-09-03 11:15 ` Michael S. Tsirkin
1 sibling, 1 reply; 8+ messages in thread
From: Amit Shah @ 2013-09-03 11:10 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: yinyin, qemu-devel@nongnu.org, Michael S. Tsirkin
On (Mon) 19 Aug 2013 [16:30:54], Stefan Hajnoczi wrote:
> On Mon, Aug 19, 2013 at 05:28:44PM +0800, yinyin wrote:
> > Hi,all:
> > in func virtqueue_get_avail_bytes, when found a indirect desc, we need loop over it.
> > /* loop over the indirect descriptor table */
> > indirect = 1;
> > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > num_bufs = i = 0;
> > desc_pa = vring_desc_addr(desc_pa, i);
> > But, It init i to 0, then use i to update desc_pa. so we will always get :
> > desc_pa = vring_desc_addr(desc_pa, 0);
> > is it right?or should we update desc_pa first, then init i to 0?
>
> Is there a way to trigger a crash or erorr from a normal running guest?
>
> Affected devices: serial, rng, and net - they call
> virtqueue_get_avail_bytes() directly or indirectly.
>
> > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > index 09f62c6..554ae6f 100644
> > --- a/hw/virtio/virtio.c
> > +++ b/hw/virtio/virtio.c
> > @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
> > /* loop over the indirect descriptor table */
> > indirect = 1;
> > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > - num_bufs = i = 0;
> > desc_pa = vring_desc_addr(desc_pa, i);
> > + num_bufs = i = 0;
>
> I agree, this looks wrong. git-blame(1) doesn't reveal anything
> interesting. Looks like this bug has been around since 2009!
Hm, why hasn't this bitten anyone yet?
Amit
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes
2013-09-03 11:10 ` [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes Amit Shah
@ 2013-09-03 11:15 ` Michael S. Tsirkin
2013-09-04 12:18 ` Amit Shah
0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2013-09-03 11:15 UTC (permalink / raw)
To: Amit Shah; +Cc: Stefan Hajnoczi, yinyin, qemu-devel@nongnu.org
On Tue, Sep 03, 2013 at 04:40:21PM +0530, Amit Shah wrote:
> On (Mon) 19 Aug 2013 [16:30:54], Stefan Hajnoczi wrote:
> > On Mon, Aug 19, 2013 at 05:28:44PM +0800, yinyin wrote:
> > > Hi,all:
> > > in func virtqueue_get_avail_bytes, when found a indirect desc, we need loop over it.
> > > /* loop over the indirect descriptor table */
> > > indirect = 1;
> > > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > > num_bufs = i = 0;
> > > desc_pa = vring_desc_addr(desc_pa, i);
> > > But, It init i to 0, then use i to update desc_pa. so we will always get :
> > > desc_pa = vring_desc_addr(desc_pa, 0);
> > > is it right?or should we update desc_pa first, then init i to 0?
> >
> > Is there a way to trigger a crash or erorr from a normal running guest?
> >
> > Affected devices: serial, rng, and net - they call
> > virtqueue_get_avail_bytes() directly or indirectly.
> >
> > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > > index 09f62c6..554ae6f 100644
> > > --- a/hw/virtio/virtio.c
> > > +++ b/hw/virtio/virtio.c
> > > @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
> > > /* loop over the indirect descriptor table */
> > > indirect = 1;
> > > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > > - num_bufs = i = 0;
> > > desc_pa = vring_desc_addr(desc_pa, i);
> > > + num_bufs = i = 0;
> >
> > I agree, this looks wrong. git-blame(1) doesn't reveal anything
> > interesting. Looks like this bug has been around since 2009!
>
> Hm, why hasn't this bitten anyone yet?
>
> Amit
net uses virtqueue_get_avail_bytes for RX only, and drivers
only post single buffers there.
Same seems to be true for other devices?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes
2013-09-03 11:15 ` Michael S. Tsirkin
@ 2013-09-04 12:18 ` Amit Shah
0 siblings, 0 replies; 8+ messages in thread
From: Amit Shah @ 2013-09-04 12:18 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Stefan Hajnoczi, yinyin, qemu-devel@nongnu.org
On (Tue) 03 Sep 2013 [14:15:55], Michael S. Tsirkin wrote:
> On Tue, Sep 03, 2013 at 04:40:21PM +0530, Amit Shah wrote:
> > On (Mon) 19 Aug 2013 [16:30:54], Stefan Hajnoczi wrote:
> > > On Mon, Aug 19, 2013 at 05:28:44PM +0800, yinyin wrote:
> > > > Hi,all:
> > > > in func virtqueue_get_avail_bytes, when found a indirect desc, we need loop over it.
> > > > /* loop over the indirect descriptor table */
> > > > indirect = 1;
> > > > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > > > num_bufs = i = 0;
> > > > desc_pa = vring_desc_addr(desc_pa, i);
> > > > But, It init i to 0, then use i to update desc_pa. so we will always get :
> > > > desc_pa = vring_desc_addr(desc_pa, 0);
> > > > is it right?or should we update desc_pa first, then init i to 0?
> > >
> > > Is there a way to trigger a crash or erorr from a normal running guest?
> > >
> > > Affected devices: serial, rng, and net - they call
> > > virtqueue_get_avail_bytes() directly or indirectly.
> > >
> > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > > > index 09f62c6..554ae6f 100644
> > > > --- a/hw/virtio/virtio.c
> > > > +++ b/hw/virtio/virtio.c
> > > > @@ -377,8 +377,8 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
> > > > /* loop over the indirect descriptor table */
> > > > indirect = 1;
> > > > max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
> > > > - num_bufs = i = 0;
> > > > desc_pa = vring_desc_addr(desc_pa, i);
> > > > + num_bufs = i = 0;
> > >
> > > I agree, this looks wrong. git-blame(1) doesn't reveal anything
> > > interesting. Looks like this bug has been around since 2009!
> >
> > Hm, why hasn't this bitten anyone yet?
>
> net uses virtqueue_get_avail_bytes for RX only, and drivers
> only post single buffers there.
>
> Same seems to be true for other devices?
Yes, we were lucky.
Amit
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-09-04 12:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 9:28 [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes yinyin
2013-08-19 14:30 ` Stefan Hajnoczi
2013-08-22 6:47 ` [Qemu-devel] [PATCH]virtio: virtqueue_get_avail_bytes: fix desc_pa when loop over the indirect descriptor table yinyin
2013-08-22 11:59 ` Stefan Hajnoczi
2013-08-25 9:51 ` Michael S. Tsirkin
2013-09-03 11:10 ` [Qemu-devel] [qemu-devel]question on virtqueue_get_avail_bytes Amit Shah
2013-09-03 11:15 ` Michael S. Tsirkin
2013-09-04 12:18 ` Amit Shah
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).