* [Qemu-devel] [PATCH] qtest: virtio: zeroed last VRingDesc after allocate
@ 2017-01-14 9:59 Longpeng(Mike)
2017-01-16 14:13 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Longpeng(Mike) @ 2017-01-14 9:59 UTC (permalink / raw)
To: stefanha, lvivier, eblake, peter.maydell, groug
Cc: arei.gonglei, qemu-devel, Longpeng(Mike)
As qvring_indirect_desc_setup() wouldn't initialize last VRingDesc,
so it's filled with dirty data, this might cause virtio backend broken.
For example, the last bit of this VRingDesc's flags might be 1, so
virtqueue_read_next_desc() would report "Desc next is ***".
This patch zeored the last VRingDesc in qvring_indirect_desc_setup().
Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
---
tests/libqos/virtio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index ec30cb9..b29c69e 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -171,12 +171,20 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
for (i = 0; i < elem - 1; ++i) {
/* indirect->desc[i].addr */
writeq(indirect->desc + (16 * i), 0);
+ /* indirect->desc[i].len */
+ writeq(indirect->desc + (16 * i) + 8, 0);
/* indirect->desc[i].flags */
writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
/* indirect->desc[i].next */
writew(indirect->desc + (16 * i) + 14, i + 1);
}
+ /* zeroed last element */
+ writeq(indirect->desc + (16 * i), 0); /* addr */
+ writeq(indirect->desc + (16 * i) + 8, 0); /*len*/
+ writew(indirect->desc + (16 * i) + 12, 0); /*flags*/
+ writew(indirect->desc + (16 * i) + 14, 0); /*next*/
+
return indirect;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qtest: virtio: zeroed last VRingDesc after allocate
2017-01-14 9:59 [Qemu-devel] [PATCH] qtest: virtio: zeroed last VRingDesc after allocate Longpeng(Mike)
@ 2017-01-16 14:13 ` Stefan Hajnoczi
2017-01-17 2:57 ` Longpeng (Mike)
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2017-01-16 14:13 UTC (permalink / raw)
To: Longpeng(Mike)
Cc: stefanha, lvivier, eblake, peter.maydell, groug, arei.gonglei,
qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]
On Sat, Jan 14, 2017 at 05:59:36PM +0800, Longpeng(Mike) wrote:
> As qvring_indirect_desc_setup() wouldn't initialize last VRingDesc,
> so it's filled with dirty data, this might cause virtio backend broken.
>
> For example, the last bit of this VRingDesc's flags might be 1, so
> virtqueue_read_next_desc() would report "Desc next is ***".
>
> This patch zeored the last VRingDesc in qvring_indirect_desc_setup().
>
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---
> tests/libqos/virtio.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
> index ec30cb9..b29c69e 100644
> --- a/tests/libqos/virtio.c
> +++ b/tests/libqos/virtio.c
> @@ -171,12 +171,20 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
> for (i = 0; i < elem - 1; ++i) {
> /* indirect->desc[i].addr */
> writeq(indirect->desc + (16 * i), 0);
> + /* indirect->desc[i].len */
> + writeq(indirect->desc + (16 * i) + 8, 0);
The len field is 32 bits long. Please use writel().
> /* indirect->desc[i].flags */
> writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
> /* indirect->desc[i].next */
> writew(indirect->desc + (16 * i) + 14, i + 1);
> }
>
> + /* zeroed last element */
> + writeq(indirect->desc + (16 * i), 0); /* addr */
> + writeq(indirect->desc + (16 * i) + 8, 0); /*len*/
Same here.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qtest: virtio: zeroed last VRingDesc after allocate
2017-01-16 14:13 ` Stefan Hajnoczi
@ 2017-01-17 2:57 ` Longpeng (Mike)
0 siblings, 0 replies; 3+ messages in thread
From: Longpeng (Mike) @ 2017-01-17 2:57 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: stefanha, lvivier, eblake, peter.maydell, groug, arei.gonglei,
qemu-devel
Hi Stefan,
On 2017/1/16 22:13, Stefan Hajnoczi wrote:
> On Sat, Jan 14, 2017 at 05:59:36PM +0800, Longpeng(Mike) wrote:
......
>> diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
>> index ec30cb9..b29c69e 100644
>> --- a/tests/libqos/virtio.c
>> +++ b/tests/libqos/virtio.c
>> @@ -171,12 +171,20 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
>> for (i = 0; i < elem - 1; ++i) {
>> /* indirect->desc[i].addr */
>> writeq(indirect->desc + (16 * i), 0);
>> + /* indirect->desc[i].len */
>> + writeq(indirect->desc + (16 * i) + 8, 0);
>
> The len field is 32 bits long. Please use writel().
>
>> /* indirect->desc[i].flags */
>> writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
>> /* indirect->desc[i].next */
>> writew(indirect->desc + (16 * i) + 14, i + 1);
>> }
>>
>> + /* zeroed last element */
>> + writeq(indirect->desc + (16 * i), 0); /* addr */
>> + writeq(indirect->desc + (16 * i) + 8, 0); /*len*/
>
> Same here.
OK. I will fix it in V2.
--
Regards,
Longpeng(Mike)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-17 2:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-14 9:59 [Qemu-devel] [PATCH] qtest: virtio: zeroed last VRingDesc after allocate Longpeng(Mike)
2017-01-16 14:13 ` Stefan Hajnoczi
2017-01-17 2:57 ` Longpeng (Mike)
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).