From patchwork Fri Jan 12 10:13:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang Zheng X-Patchwork-Id: 10160217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 372DA602A7 for ; Fri, 12 Jan 2018 11:05:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D51828743 for ; Fri, 12 Jan 2018 11:05:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FB262875E; Fri, 12 Jan 2018 11:05:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B1CC28743 for ; Fri, 12 Jan 2018 11:05:07 +0000 (UTC) Received: from localhost ([::1]:33729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZx90-0003bf-RY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Jan 2018 06:05:06 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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, VirtIODevice *vdev) goto fail_mem; } for (i = 0; i < hdev->nvqs; ++i) { + if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0) + continue; r = vhost_virtqueue_start(hdev, vdev, hdev->vqs + i,