From nobody Sat Apr 20 07:44:50 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523897429407887.9499440316599; Mon, 16 Apr 2018 09:50:29 -0700 (PDT) Received: from localhost ([::1]:57733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Ke-00085l-KH for importer@patchew.org; Mon, 16 Apr 2018 12:50:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87IG-0006i8-Ru for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:47:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87IC-0003Im-QI for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:47:52 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48152 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87IC-0003Hv-MW for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:47:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05C7B4023156; Mon, 16 Apr 2018 16:47:45 +0000 (UTC) Received: from redhat.com (ovpn-125-198.rdu2.redhat.com [10.10.125.198]) by smtp.corp.redhat.com (Postfix) with SMTP id B318E111DCE5; Mon, 16 Apr 2018 16:47:44 +0000 (UTC) Date: Mon, 16 Apr 2018 19:47:44 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1523895458-475479-2-git-send-email-mst@redhat.com> References: <1523895458-475479-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1523895458-475479-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 16 Apr 2018 16:47:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 16 Apr 2018 16:47:45 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/1] vhost: do not verify ring mappings when IOMMU is enabled 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: Peter Maydell , Jason Wang , "Dr . David Alan Gilbert" , Igor Mammedov 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" From: Jason Wang When IOMMU is enabled, we store virtqueue metadata as iova (though it may has _phys suffix) and access them through dma helpers. Any translation failures could be reported by IOMMU. In this case, trying to validate iova against gpa won't work and will cause a false error reporting. So this patch bypasses the ring verification if IOMMU is enabled which is similar to the behavior before 0ca1fd2d6878 that calls vhost_memory_map() which is a nop when IOMMU is enabled. Fixes: 0ca1fd2d6878 ("vhost: Simplify ring verification checks") Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f51bf57..9d5850a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -342,6 +342,10 @@ static int vhost_verify_ring_mappings(struct vhost_dev= *dev, "used ring" }; =20 + if (vhost_dev_has_iommu(dev)) { + return 0; + } + for (i =3D 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq =3D dev->vqs + i; =20 --=20 MST