From nobody Thu Mar 28 19:47:01 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.zohomail.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 1515755122746267.2360636667927; Fri, 12 Jan 2018 03:05:22 -0800 (PST) Received: from localhost ([::1]:33729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZx9G-0003bf-2a for importer@patchew.org; Fri, 12 Jan 2018 06:05:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZx8H-0003BG-RT for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:04:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZx8D-00052v-UY for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:04:21 -0500 Received: from [45.249.212.32] (port=44379 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZx8D-0004ww-IO for qemu-devel@nongnu.org; Fri, 12 Jan 2018 06:04:17 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 464B44267D9D2; Fri, 12 Jan 2018 18:16:42 +0800 (CST) Received: from HGHY1z004218071.china.huawei.com (10.177.29.32) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.361.1; Fri, 12 Jan 2018 18:16:34 +0800 From: Zheng Xiang To: Date: Fri, 12 Jan 2018 18:13:56 +0800 Message-ID: <20180112101356.27044-1-zhengxiang9@huawei.com> X-Mailer: git-send-email 2.15.1.windows.2 MIME-Version: 1.0 X-Originating-IP: [10.177.29.32] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues 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: "Michael S . Tsirkin" , Zheng Xiang , maxime.coquelin@redhat.com, zhaoshenglong@huawei.com, pbonzini@redhat.com, lersek@redhat.com, christoffer.dall@linaro.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 Content-Type: text/plain; charset="utf-8" When guest driver only setup part of queues declared in QEMU, it would corrupt guest's physical address 0 when using uninitialized queues in vhost_virtqueue_start. In AARCH64 virtual machines, the address of system memory starts at 0x40000000 and the address of rom starts at 0. So, when using qemu with vhost-scsi, it will fail with below error: qemu-kvm: Error start vhost dev qemu-kvm: unable to start vhost-scsi: Cannot allocate memory This patch fix this issue by skipping calling vhost_virtqueue_start for uninitialized queues. Cc: Michael S. Tsirkin Signed-off-by: Zheng Xiang Tested-by: Maxime Coquelin --- hw/virtio/vhost.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index e4290ce..ac79ffd 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1532,6 +1532,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) goto fail_mem; } for (i =3D 0; i < hdev->nvqs; ++i) { + if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) =3D=3D 0)=20 + continue; r =3D vhost_virtqueue_start(hdev, vdev, hdev->vqs + i, --=20 1.8.3.1