From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bd7ft-0002lm-OX for qemu-devel@nongnu.org; Thu, 25 Aug 2016 23:19:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bd7fp-0005py-IS for qemu-devel@nongnu.org; Thu, 25 Aug 2016 23:19:20 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:47176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bd7fo-0005pP-T7 for qemu-devel@nongnu.org; Thu, 25 Aug 2016 23:19:17 -0400 From: zhangshuai Date: Fri, 26 Aug 2016 11:18:22 +0800 Message-ID: <1472181502-6588-1-git-send-email-zhangshuai13@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] libqos: fix bugs in qvirtqueue_kick() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stefanha@redhat.com Cc: qemu-devel@nongnu.org, wu.wubin@huawei.com, eric.fangyi@huawei.com, subo7@huawei.com, kathy.wangting@huawei.com, lina.lulina@huawei.com, zhangshuai13@huawei.com From: Zhang Shuai The idx and ring[] of vring_avail is 16-bit, but the writel is 32-bit, the second writel will cover the ring[free_head] with 0. So use writew to replace writel to fix the bug. Signed-off-by: zhangshuai --- tests/libqos/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c index d8c2970..801690f 100644 --- a/tests/libqos/virtio.c +++ b/tests/libqos/virtio.c @@ -264,9 +264,9 @@ void qvirtqueue_kick(const QVirtioBus *bus, QVirtioDevice *d, QVirtQueue *vq, uint16_t avail_event; /* vq->avail->ring[idx % vq->size] */ - writel(vq->avail + 4 + (2 * (idx % vq->size)), free_head); + writew(vq->avail + 4 + (2 * (idx % vq->size)), free_head); /* vq->avail->idx */ - writel(vq->avail + 2, idx + 1); + writew(vq->avail + 2, idx + 1); /* Must read after idx is updated */ flags = readw(vq->avail); -- 1.8.3.4