From nobody Mon Feb 9 08:55:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665489435; cv=none; d=zohomail.com; s=zohoarc; b=ixFeHT+3ESZqfX/yzD95xeb/XWlSgH1lpYtjJ7FDHNSAlnlb9Z+PMLgftb0I2+NJ8OvUflDLXAF+zo8Jly7+7/lWQ1G/0uj/au5mewUNQMJXzD2cxQ65SpjoD9ABNXMUJ5Jwj7fd5cyb4vvx6JEMeXkn5eFhGIsZH9CIdGpkDEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665489435; 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=JjLZSMxDoJzukfhronBWmF9VBo9r0DM5fgqfGZCuCT8=; b=Gd4WuqKnbP0kfvOgER6m8+EZxYBudTZrimzaJwhb3nKCizhhqd43YwB0cWkhBbgM3kfzcF8joQBi5Rt3nQ6AiP5kU3khstcmGUFTzZCJJw376L7ZNEzpwuDkdbj9KPXxR2KQa3gEvK6z+e81USPrFpGjQB8IdI4EN5/SPWiquLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665489435553616.8224141770568; Tue, 11 Oct 2022 04:57:15 -0700 (PDT) Received: from localhost ([::1]:44248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiDsn-0008HL-FK for importer@patchew.org; Tue, 11 Oct 2022 07:57:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCiO-0004r7-7z for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:42:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23487) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiCiM-0007pe-An for qemu-devel@nongnu.org; Tue, 11 Oct 2022 06:42:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-nV4AtLQ3Oxyct-JUmFvcQA-1; Tue, 11 Oct 2022 06:42:18 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD56F299E754; Tue, 11 Oct 2022 10:42:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5293492B10; Tue, 11 Oct 2022 10:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665484941; 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=JjLZSMxDoJzukfhronBWmF9VBo9r0DM5fgqfGZCuCT8=; b=eBT3NtbRWIWau6gBcbXn1I8EBLdBADmOCXX0DHBlk7Yas/xoxtsRl2Cu3Yze1VWRWiL6ez 3IA2ZF0wmzDOzCG/y7iOTidRRas6R7bHnIEUzAn58ujkrH4KKJyEZ6vnp/KRnG71uE6BOS ZBMqblsnUlAiJpbbsVZrXpx0qPAvzh0= X-MC-Unique: nV4AtLQ3Oxyct-JUmFvcQA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Gautam Dawar , "Michael S. Tsirkin" , Zhu Lingshan , Jason Wang , Si-Wei Liu , Paolo Bonzini , Eli Cohen , Parav Pandit , Laurent Vivier , Stefano Garzarella , Stefan Hajnoczi , "Gonglei (Arei)" , Cindy Lu , Liuxiangdong , Cornelia Huck , kvm@vger.kernel.org, Harpreet Singh Anand Subject: [PATCH v5 5/6] vdpa: Add listener_shadow_vq to vhost_vdpa Date: Tue, 11 Oct 2022 12:41:53 +0200 Message-Id: <20221011104154.1209338-6-eperezma@redhat.com> In-Reply-To: <20221011104154.1209338-1-eperezma@redhat.com> References: <20221011104154.1209338-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665489436681100003 The memory listener that thells the device how to convert GPA to qemu's va is registered against CVQ vhost_vdpa. This series try to map the memory listener translations to ASID 0, while it maps the CVQ ones to ASID 1. Let's tell the listener if it needs to register them on iova tree or not. Signed-off-by: Eugenio P=C3=A9rez --- v5: Solve conflict about vhost_iova_tree_remove accepting mem_region by value. --- include/hw/virtio/vhost-vdpa.h | 2 ++ hw/virtio/vhost-vdpa.c | 6 +++--- net/vhost-vdpa.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 6560bb9d78..0c3ed2d69b 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -34,6 +34,8 @@ typedef struct vhost_vdpa { struct vhost_vdpa_iova_range iova_range; uint64_t acked_features; bool shadow_vqs_enabled; + /* The listener must send iova tree addresses, not GPA */ + bool listener_shadow_vq; /* IOVA mapping used by the Shadow Virtqueue */ VhostIOVATree *iova_tree; GPtrArray *shadow_vqs; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index ad663feacc..29d009c02b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -220,7 +220,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, vaddr, section->readonly); =20 llsize =3D int128_sub(llend, int128_make64(iova)); - if (v->shadow_vqs_enabled) { + if (v->listener_shadow_vq) { int r; =20 mem_region.translated_addr =3D (hwaddr)(uintptr_t)vaddr, @@ -247,7 +247,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, return; =20 fail_map: - if (v->shadow_vqs_enabled) { + if (v->listener_shadow_vq) { vhost_iova_tree_remove(v->iova_tree, mem_region); } =20 @@ -292,7 +292,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, =20 llsize =3D int128_sub(llend, int128_make64(iova)); =20 - if (v->shadow_vqs_enabled) { + if (v->listener_shadow_vq) { const DMAMap *result; const void *vaddr =3D memory_region_get_ram_ptr(section->mr) + section->offset_within_region + diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e8c78e4813..f7831aeb8d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -604,6 +604,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; s->vhost_vdpa.shadow_vqs_enabled =3D svq; + s->vhost_vdpa.listener_shadow_vq =3D svq; s->vhost_vdpa.iova_tree =3D iova_tree; if (!is_datapath) { s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), --=20 2.31.1