From nobody Tue May 7 04:32:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489476361290428.16746450972516; Tue, 14 Mar 2017 00:26:01 -0700 (PDT) Received: from localhost ([::1]:56808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cngqF-0003KO-TL for importer@patchew.org; Tue, 14 Mar 2017 03:25:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cngpX-0003Iq-PM for qemu-devel@nongnu.org; Tue, 14 Mar 2017 03:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cngpU-0003eY-L7 for qemu-devel@nongnu.org; Tue, 14 Mar 2017 03:25:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50210) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cngpU-0003eH-Fd; Tue, 14 Mar 2017 03:25:12 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35AD67E9CF; Tue, 14 Mar 2017 07:25:12 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (vpn1-6-24.pek2.redhat.com [10.72.6.24]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2E7P7rk004666; Tue, 14 Mar 2017 03:25:09 -0400 From: Jason Wang To: mst@redhat.com, qemu-devel@nongnu.org Date: Tue, 14 Mar 2017 15:25:05 +0800 Message-Id: <1489476305-27139-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 14 Mar 2017 07:25:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] virtio-pci: reset modern vq meta data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We don't reset proxy->vqs[].{num|desc[]|avail[]|used[]}. This means if a driver enable the vq without setting vq address after reset. The old addresses were leaked. Fixing this by resetting modern vq meta data during device reset. Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Reviewed-by: Stefan Hajnoczi --- hw/virtio/virtio-pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b76f3f6..7c36b9c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1857,6 +1857,10 @@ static void virtio_pci_reset(DeviceState *qdev) =20 for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { proxy->vqs[i].enabled =3D 0; + proxy->vqs[i].num =3D 0; + proxy->vqs[i].desc[0] =3D proxy->vqs[i].desc[1] =3D 0; + proxy->vqs[i].avail[0] =3D proxy->vqs[i].avail[1] =3D 0; + proxy->vqs[i].used[0] =3D proxy->vqs[i].used[1] =3D 0; } } =20 --=20 2.7.4