From nobody Wed Feb 11 02:33:21 2026 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 1494506119020631.3270851045633; Thu, 11 May 2017 05:35:19 -0700 (PDT) Received: from localhost ([::1]:48029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8nJN-0003if-GL for importer@patchew.org; Thu, 11 May 2017 08:35:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8nHZ-0002bd-PY for qemu-devel@nongnu.org; Thu, 11 May 2017 08:33:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8nHZ-0004om-0C for qemu-devel@nongnu.org; Thu, 11 May 2017 08:33:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8nHY-0004nq-QZ for qemu-devel@nongnu.org; Thu, 11 May 2017 08:33:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C648864473; Thu, 11 May 2017 12:33:23 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-16.ams2.redhat.com [10.36.112.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3055918B52; Thu, 11 May 2017 12:33:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C648864473 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=maxime.coquelin@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C648864473 From: Maxime Coquelin To: mst@redhat.com, peterx@redhat.com, marcandre.lureau@gmail.com, vkaplans@redhat.com, jasowang@redhat.com, wexu@redhat.com, yuanhan.liu@linux.intel.com, qemu-devel@nongnu.org, jfreiman@redhat.com Date: Thu, 11 May 2017 14:32:43 +0200 Message-Id: <20170511123246.31308-4-maxime.coquelin@redhat.com> In-Reply-To: <20170511123246.31308-1-maxime.coquelin@redhat.com> References: <20170511123246.31308-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 11 May 2017 12:33:23 +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 3/6] vhost: Update rings information for IOTLB earlier 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: Maxime Coquelin 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" Vhost-kernel backend need to receive IOTLB entries for rings information early, but vhost-user need the same information earlier, before VHOST_USER_SET_VRING_ADDR is sent. This patch also trigger IOTLB miss for all rings informations for robustness, even if in practice these adresses are on the same page. Signed-off-by: Maxime Coquelin --- hw/virtio/vhost.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 748e331..817f6d0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -799,7 +799,17 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *= dev, .log_guest_addr =3D vq->used_phys, .flags =3D enable_log ? (1 << VHOST_VRING_F_LOG) : 0, }; - int r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); + int r; + + /* Update rings information for IOTLB to work correctly, + * vhost-kernel & vhost-user backends require for this.*/ + if (vhost_dev_has_iommu(dev)) { + vhost_device_iotlb_miss(dev, addr.desc_user_addr, true); + vhost_device_iotlb_miss(dev, addr.used_user_addr, true); + vhost_device_iotlb_miss(dev, addr.avail_user_addr, true); + } + + r =3D dev->vhost_ops->vhost_set_vring_addr(dev, &addr); if (r < 0) { VHOST_OPS_DEBUG("vhost_set_vring_addr failed"); return -errno; @@ -1551,13 +1561,6 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODe= vice *vdev) =20 if (vhost_dev_has_iommu(hdev)) { hdev->vhost_ops->vhost_set_iotlb_callback(hdev, true); - - /* Update used ring information for IOTLB to work correctly, - * vhost-kernel code requires for this.*/ - for (i =3D 0; i < hdev->nvqs; ++i) { - struct vhost_virtqueue *vq =3D hdev->vqs + i; - vhost_device_iotlb_miss(hdev, vq->used_phys, true); - } } return 0; fail_log: --=20 2.9.3