From nobody Mon Feb 9 15:11:02 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621443299; cv=none; d=zohomail.com; s=zohoarc; b=gLiAcz2gdR8PeB3m0guoKro0TZKhubAocT0/DZ4CdKOsgcm3Ndb2FusBVenXDbYAnZq/idaCCar2cuFqMrdQ8hsPMq9hJyE3vZorsax1jnZ4kUYJN4Ruy/SIU4TadRe/H51QHAy3xxrtap/J2gohRQkol8df6r7TgSdeoWL7HjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621443299; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1i1NEzjfpXbKffh1W/jtWwyo2lcMMIpkTS0taNvfQeE=; b=TI7S1W9f8WfFzAeuQoVVzWDefj8eP+f14Z2t2nGwu7YKrd4Q/1qGUoYvv5DeFVgb8YMfsxnL0OO6JVaLm/Cue2rEJe9GNi+lOBaJ6IZbzGeo1rmcq2O+ZSMV45eDci0XgSwRJypUrPLxwNlw9VEp9moaHL82L19O2qFTZ8rV+as= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621443299627117.62894751478905; Wed, 19 May 2021 09:54:59 -0700 (PDT) Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljPTG-0002Gb-9V for importer@patchew.org; Wed, 19 May 2021 12:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljP7T-0007Ki-Nt for qemu-devel@nongnu.org; Wed, 19 May 2021 12:32:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljP7Q-0006AC-UZ for qemu-devel@nongnu.org; Wed, 19 May 2021 12:32:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-74_U5WOZOrqi5la8NF6WbA-1; Wed, 19 May 2021 12:32:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BE64107ACCA; Wed, 19 May 2021 16:32:21 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-113-65.ams2.redhat.com [10.36.113.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCC225D6AC; Wed, 19 May 2021 16:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621441944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1i1NEzjfpXbKffh1W/jtWwyo2lcMMIpkTS0taNvfQeE=; b=TAWpo8zbX0QN16fp+NN1KBIWjrFecDDTHg9mRgI9i81rQkrihKX9ZyADbMCc4FhTu1Rzcm 594IfzLFIJTJyYSAKEvmElh79NT9/3xroS7gLRRxp24l/w6ZjOc0bVNlLnBcuwTq0YwRBP yIh593zU6L0sHLNv+jtkMXN8XHjRGpk= X-MC-Unique: 74_U5WOZOrqi5la8NF6WbA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [RFC v3 26/29] vhost: Map in vdpa-dev Date: Wed, 19 May 2021 18:29:00 +0200 Message-Id: <20210519162903.1172366-27-eperezma@redhat.com> In-Reply-To: <20210519162903.1172366-1-eperezma@redhat.com> References: <20210519162903.1172366-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Parav Pandit , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Michael Lilja , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use and export vhost-vpda functions directly. In the final version, these methods needs to be exposed through VhostOps, or vhost-vdpa backend needs to be adapted to work with vhost_send_device_iotlb_msg in case its custom iommu is disabled. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost-backend.h | 4 ++++ hw/virtio/vhost-vdpa.c | 2 +- hw/virtio/vhost.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index f8eed2ace5..9d88074e4d 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -203,4 +203,8 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *de= v, =20 int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd); =20 +struct vhost_vdpa; +int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size, + void *vaddr, bool readonly); + #endif /* VHOST_BACKEND_H */ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 9e7a0ce5e0..c742e6944e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -36,7 +36,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryReg= ionSection *section) section->offset_within_address_space & (1ULL << 63); } =20 -static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr si= ze, +int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size, void *vaddr, bool readonly) { struct vhost_msg_v2 msg =3D {}; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4339b899ea..286863ad42 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1314,9 +1314,19 @@ static bool vhost_shadow_vq_start_store_sections(str= uct vhost_dev *dev) r =3D vhost_iova_tree_insert(&dev->iova_map, ®ion); } assert(r =3D=3D VHOST_DMA_MAP_OK); + r =3D vhost_vdpa_dma_map(dev->opaque, region.iova, region_size, + (void *)dev->mem->regions[idx].userspace_ad= dr, + false); + if (r !=3D 0) { + goto fail; + } } =20 return true; + +fail: + assert(0); + return false; } =20 /* @@ -1377,6 +1387,14 @@ static bool vhost_sw_live_migration_start_vq(struct = vhost_dev *dev, } =20 vhost_virtqueue_stop(dev, dev->vdev, &dev->vqs[idx], dev->vq_index + i= dx); + /* TODO: Why cannot make this read only? */ + r =3D vhost_vdpa_dma_map(dev->opaque, addr.desc_user_addr, driver_regi= on.size, + (void *)driver_region.translated_addr, false); + assert(r =3D=3D 0); + r =3D vhost_vdpa_dma_map(dev->opaque, addr.used_user_addr, device_regi= on.size, + (void *)device_region.translated_addr, false); + assert(r =3D=3D 0); + ok =3D vhost_shadow_vq_start(dev, idx, dev->shadow_vqs[idx]); if (unlikely(!ok)) { return false; --=20 2.27.0