From nobody Mon May 6 04:15:55 2024 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=1677864322; cv=none; d=zohomail.com; s=zohoarc; b=dKEJuYaxBo07gG4fyK2Tv83QaTaD1byTEDq8NE1FC/3nvcsS4xWZfdUed/FbxHuBUtS5dcj9NlETRGus9JhGCGkk+w1tbD4JKXpS04vDMTLMpBeTzGMUB1VFwLomfTgONNzPWfiaZpC+pJqqlcZ+BQzKT5lSB9fK8QE4exE1S3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864322; 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=Ree/bpw/Z6BjqG29yii2GlxwExTCb2gGeEn3gEwqnvs=; b=KpjqvRqi2G9rXj5zPKdfaCs4RGUOcQ9esygfCHeUNVt7Dvk4hW+evqolnSQLGxCdOxMPndQc8KYfwaAsNYD4/orMBIQY2F5KwCsqA+k+LhCYxTWDHRfW5Z1CVGnksc1YaYNWy/wHPx2+OY17uz1ANonBql9CjZE95kFP9Pkqo20= 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 1677864322917937.8714065233303; Fri, 3 Mar 2023 09:25:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99T-00072j-6c; Fri, 03 Mar 2023 12:25:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99R-00071h-9n for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99P-0005Jt-Er for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:01 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-_8P4qF2kPHGICr7nnRQ-VQ-1; Fri, 03 Mar 2023 12:24:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAE1081B13D; Fri, 3 Mar 2023 17:24:53 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id C204D440D8; Fri, 3 Mar 2023 17:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864298; 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=Ree/bpw/Z6BjqG29yii2GlxwExTCb2gGeEn3gEwqnvs=; b=gK73LLhs+ErchwE96tOLI5O+6bTv5py0tWvMJdB5n0lrRcRRdWibgY/FNyIjVGRl4sZ50V owsQjDYEXKn85HGdkZ677lShxyhvWdXyaRmFUkrJjVIvCtnbQAzkelp2xN/icjPRGVgHwI Yv9Z6255imoNIfTdmCNqpYAbfWQD3TQ= X-MC-Unique: _8P4qF2kPHGICr7nnRQ-VQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 01/14] vdpa net: move iova tree creation from init to start Date: Fri, 3 Mar 2023 18:24:32 +0100 Message-Id: <20230303172445.1089785-2-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864324024100003 Only create iova_tree if and when it is needed. The cleanup keeps being responsible for the last VQ but this change allows it to merge both cleanup functions. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- v4: * Remove leak of iova_tree because double allocation * Document better the sharing of IOVA tree between data and CVQ --- net/vhost-vdpa.c | 113 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 30 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index de5ed8ff22..d195f48776 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -178,13 +178,9 @@ err_init: static void vhost_vdpa_cleanup(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); - struct vhost_dev *dev =3D &s->vhost_net->dev; =20 qemu_vfree(s->cvq_cmd_out_buffer); qemu_vfree(s->status); - if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { - g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); - } if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); g_free(s->vhost_net); @@ -234,10 +230,64 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc,= const uint8_t *buf, return size; } =20 +/** From any vdpa net client, get the netclient of the first queue pair */ +static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(VhostVDPAState *s) +{ + NICState *nic =3D qemu_get_nic(s->nc.peer); + NetClientState *nc0 =3D qemu_get_peer(nic->ncs, 0); + + return DO_UPCAST(VhostVDPAState, nc, nc0); +} + +static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) +{ + struct vhost_vdpa *v =3D &s->vhost_vdpa; + + if (v->shadow_vqs_enabled) { + v->iova_tree =3D vhost_iova_tree_new(v->iova_range.first, + v->iova_range.last); + } +} + +static int vhost_vdpa_net_data_start(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + if (v->index =3D=3D 0) { + vhost_vdpa_net_data_start_first(s); + return 0; + } + + if (v->shadow_vqs_enabled) { + VhostVDPAState *s0 =3D vhost_vdpa_net_first_nc_vdpa(s); + v->iova_tree =3D s0->vhost_vdpa.iova_tree; + } + + return 0; +} + +static void vhost_vdpa_net_client_stop(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_dev *dev; + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + dev =3D s->vhost_vdpa.dev; + if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { + g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); + } +} + static NetClientInfo net_vhost_vdpa_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, + .start =3D vhost_vdpa_net_data_start, + .stop =3D vhost_vdpa_net_client_stop, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, .has_ufo =3D vhost_vdpa_has_ufo, @@ -351,7 +401,7 @@ dma_map_err: =20 static int vhost_vdpa_net_cvq_start(NetClientState *nc) { - VhostVDPAState *s; + VhostVDPAState *s, *s0; struct vhost_vdpa *v; uint64_t backend_features; int64_t cvq_group; @@ -415,8 +465,6 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) return r; } =20 - v->iova_tree =3D vhost_iova_tree_new(v->iova_range.first, - v->iova_range.last); v->shadow_vqs_enabled =3D true; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_ASID; =20 @@ -425,6 +473,27 @@ out: return 0; } =20 + s0 =3D vhost_vdpa_net_first_nc_vdpa(s); + if (s0->vhost_vdpa.iova_tree) { + /* + * SVQ is already configured for all virtqueues. Reuse IOVA tree = for + * simplicity, whether CVQ shares ASID with guest or not, because: + * - Memory listener need access to guest's memory addresses alloc= ated + * in the IOVA tree. + * - There should be plenty of IOVA address space for both ASID no= t to + * worry about collisions between them. Guest's translations are + * still validated with virtio virtqueue_pop so there is no risk= for + * the guest to access memory that it shouldn't. + * + * To allocate a iova tree per ASID is doable but it complicates t= he + * code and it is not worth it for the moment. + */ + v->iova_tree =3D s0->vhost_vdpa.iova_tree; + } else { + v->iova_tree =3D vhost_iova_tree_new(v->iova_range.first, + v->iova_range.last); + } + r =3D vhost_vdpa_cvq_map_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer, vhost_vdpa_net_cvq_cmd_page_len(), false); if (unlikely(r < 0)) { @@ -449,15 +518,9 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) if (s->vhost_vdpa.shadow_vqs_enabled) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); - if (!s->always_svq) { - /* - * If only the CVQ is shadowed we can delete this safely. - * If all the VQs are shadows this will be needed by the time = the - * device is started again to register SVQ vrings and similar. - */ - g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_dele= te); - } } + + vhost_vdpa_net_client_stop(nc); } =20 static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, @@ -667,8 +730,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, int nvqs, bool is_datapath, bool svq, - struct vhost_vdpa_iova_range iova_r= ange, - VhostIOVATree *iova_tree) + struct vhost_vdpa_iova_range iova_r= ange) { NetClientState *nc =3D NULL; VhostVDPAState *s; @@ -690,7 +752,6 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.iova_range =3D iova_range; s->vhost_vdpa.shadow_data =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(), vhost_vdpa_net_cvq_cmd_page_le= n()); @@ -760,7 +821,6 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, uint64_t features; int vdpa_device_fd; g_autofree NetClientState **ncs =3D NULL; - g_autoptr(VhostIOVATree) iova_tree =3D NULL; struct vhost_vdpa_iova_range iova_range; NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; @@ -812,12 +872,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, goto err; } =20 - if (opts->x_svq) { - if (!vhost_vdpa_net_valid_svq_features(features, errp)) { - goto err_svq; - } - - iova_tree =3D vhost_iova_tree_new(iova_range.first, iova_range.las= t); + if (opts->x_svq && !vhost_vdpa_net_valid_svq_features(features, errp))= { + goto err; } =20 ncs =3D g_malloc0(sizeof(*ncs) * queue_pairs); @@ -825,7 +881,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, true, opts->x_s= vq, - iova_range, iova_tree); + iova_range); if (!ncs[i]) goto err; } @@ -833,13 +889,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, false, - opts->x_svq, iova_range, iova_tree); + opts->x_svq, iova_range); if (!nc) goto err; } =20 - /* iova_tree ownership belongs to last NetClientState */ - g_steal_pointer(&iova_tree); return 0; =20 err: @@ -849,7 +903,6 @@ err: } } =20 -err_svq: qemu_close(vdpa_device_fd); =20 return -1; --=20 2.31.1 From nobody Mon May 6 04:15:55 2024 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=1677864318; cv=none; d=zohomail.com; s=zohoarc; b=Ub6Sl6xACKNJ7I9U7MzO/a5G+g16IFO/GKUoWt7YNQx51mBLZVBHRrUEoPrQk03gJAOb0CKqDmjVTcWpdvBTyCAzedNmwG0v+bywooa6d8LvMRAcDCwKQWs0eYotgiBi58FtR3BUsdxRylnNmFWlW3Fo+wHdAl61GNhgRq2HZUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864318; 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=sa9plcu6Gt4NlRW7q/7Dt298HPAyy3W4Esuq/YBsgQo=; b=ARHKaZ0ub5C+Vobc5FVm3t7Hm9tGJd3v5NsmhSzL7NvPh4WgD91GRfpE+OWxP5vd36mmX2p2zu56G8L8Mp6q4A9sdw4tLOyzxU7JxA52/8Am8/RdBWOHeVWnyhZciaJVWUCzgbOC+73Ad7/cjbbSzgkfJHWzbPOd6htxza+XwJ8= 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 1677864318145733.8438805910038; Fri, 3 Mar 2023 09:25:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99W-0007IB-Mw; Fri, 03 Mar 2023 12:25:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99U-00077D-Qq for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99T-0005L6-AL for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:04 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-p9lOaNTsPnCML69itO3jWA-1; Fri, 03 Mar 2023 12:24:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB48981B13D; Fri, 3 Mar 2023 17:24:56 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id E74B7440D8; Fri, 3 Mar 2023 17:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864302; 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=sa9plcu6Gt4NlRW7q/7Dt298HPAyy3W4Esuq/YBsgQo=; b=awplTRVXewr9HWLxb7aWuarH1r3FEX9SIOhtIj7mNVzLsliwrgFc8Pm/28S/X/KssJ421H pD8Ul6R0O7VGPB4zBNBI3xKSYav+UuHfKVPMX4EgcEjXgnJreDhqsQsqEGW+IT5O5Zu1A8 IWHzrJsUto1AUwifq/gR2h/OQXI9E2o= X-MC-Unique: p9lOaNTsPnCML69itO3jWA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 02/14] vdpa: Remember last call fd set Date: Fri, 3 Mar 2023 18:24:33 +0100 Message-Id: <20230303172445.1089785-3-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864319702100006 As SVQ can be enabled dynamically at any time, it needs to store call fd always. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- hw/virtio/vhost-vdpa.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index df3a1e92ac..108cd63289 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1227,16 +1227,16 @@ static int vhost_vdpa_set_vring_call(struct vhost_d= ev *dev, struct vhost_vring_file *file) { struct vhost_vdpa *v =3D dev->opaque; + int vdpa_idx =3D file->index - dev->vq_index; + VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, vdpa_id= x); =20 + /* Remember last call fd because we can switch to SVQ anytime. */ + vhost_svq_set_svq_call_fd(svq, file->fd); if (v->shadow_vqs_enabled) { - int vdpa_idx =3D file->index - dev->vq_index; - VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, vdp= a_idx); - - vhost_svq_set_svq_call_fd(svq, file->fd); return 0; - } else { - return vhost_vdpa_set_vring_dev_call(dev, file); } + + return vhost_vdpa_set_vring_dev_call(dev, file); } =20 static int vhost_vdpa_get_features(struct vhost_dev *dev, --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864381; cv=none; d=zohomail.com; s=zohoarc; b=jjEct8exFyhA9bfpKwfKeRrFBKyFwEWMYsCZLq8BaL2MrenSkSu1hKRlm2og/fQNfhWrmlCEc3SCBcME8gqjySttDjRe+O702mCAZyL8MHNHsKFgTGwzDu215/rhojlmCkkUkHKX18gYNo+9CyK99oh96i71PHaNol76TTHxRek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864381; 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=QOZ50hFoW+6UZawgNrYLyUQUJ8a0kdrsCLtxTYSnXLo=; b=gLVo1Y9dFlEne+z5MjvXnaGnenqAa2CED/hJWcNQTMQhjPGRvjFj6KklAol9YF0vCVIiq1/LSdIxEkzkBjx6ehS34NEDsp1SrSWgQSrA80vNIcMoxpQN4BtT7S6N6LcOmXrvDkjK1zKPVTAqkQ804lX/JCNorhA4YYaQptjbVKk= 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 1677864381504935.2257900660261; Fri, 3 Mar 2023 09:26:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99o-0000S8-H2; Fri, 03 Mar 2023 12:25:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99m-0000H4-JH for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99l-0005bb-5J for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:22 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-3QlcJ4OfPt-l4QS6Zv3skw-1; Fri, 03 Mar 2023 12:25:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE943857D07; Fri, 3 Mar 2023 17:24:59 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 127D3440D8; Fri, 3 Mar 2023 17:24:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864320; 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=QOZ50hFoW+6UZawgNrYLyUQUJ8a0kdrsCLtxTYSnXLo=; b=cAFlooMPJLXmpdPxS5sjjxLBSusxjXXR6b1nBlZ/0vixABEY6QM8zmaLFid4/AQvRVL0Mv vFDhXeUtMmYsjBy2dzrDJIct4UVwkJGjDrAB8WClgOC3PxOc4Sl+Nkso6SKTR3nfXJCtfr YWbRLdTlr/Wmq/+uW8oboAn3gol+CYA= X-MC-Unique: 3QlcJ4OfPt-l4QS6Zv3skw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 03/14] vdpa: Negotiate _F_SUSPEND feature Date: Fri, 3 Mar 2023 18:24:34 +0100 Message-Id: <20230303172445.1089785-4-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864382035100007 This is needed for qemu to know it can suspend the device to retrieve its status and enable SVQ with it, so all the process is transparent to the guest. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- hw/virtio/vhost-vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 108cd63289..5cfa9d5d27 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -659,7 +659,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev = *dev) uint64_t features; uint64_t f =3D 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 | 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH | - 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID; + 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID | + 0x1ULL << VHOST_BACKEND_F_SUSPEND; int r; =20 if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864373; cv=none; d=zohomail.com; s=zohoarc; b=P493WXD8WLKc9oWq0W9/1HoJbDeNHlgSDXVWNgXhud8d5xO2llOTvKI3UbO/lFOQdeHbV9dCpb/reAC/o6mnePFj+pu52WUe6cf2yN7epbO8+GlWKn3tyQnzqSHLRNeGFxjUHLSrSLyi0H5IuMsztXgsFzc11AomtM2gPee4L2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864373; 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=jq+BQ8eQ8jCCD6tjr6K9FCoUwxsrU+yilWsq6RAnpEQ=; b=e2AytcKcWXTxOcHbDPQoG8kBeAE+oY1u9klTxscV6TrjGEStbnSjNCDvl7+Q1F5vftGkY+mtAJOkg+D5UinXJIdCD3dB/0vDF6hWG5vchpkaCxF0hhpbnpKqlLp7Zu/Ua6BOmFcctyaLiztjhrcbWkAKeYkjrkhFPlPUBtfnGc4= 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 167786437323032.98679593450572; Fri, 3 Mar 2023 09:26:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99i-0008W0-Mq; Fri, 03 Mar 2023 12:25:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99h-0008Tv-VM for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99g-0005ZW-58 for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:17 -0500 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-539-o64UYtENOLSWLAw5xE0bAQ-1; Fri, 03 Mar 2023 12:25:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CD761C05AF7; Fri, 3 Mar 2023 17:25:03 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 383C9440D8; Fri, 3 Mar 2023 17:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864315; 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=jq+BQ8eQ8jCCD6tjr6K9FCoUwxsrU+yilWsq6RAnpEQ=; b=jHXMtykd2NVXb33xwbFe8faOffOk6s0fIjKIUlqSC7BYjROsaMOtJKZB0yDsjLuUVhkL90 7EbEhWfpASx/PQZ/vQG3Oy+Yyj4iih6Fo+BggMQGWnRCy4PL0W67irfczZ+pIA6SNl6UXG bPlEZMYdqQj520JrDakDuqjOTk1Xirk= X-MC-Unique: o64UYtENOLSWLAw5xE0bAQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 04/14] vdpa: rewind at get_base, not set_base Date: Fri, 3 Mar 2023 18:24:35 +0100 Message-Id: <20230303172445.1089785-5-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864374015100003 At this moment it is only possible to migrate to a vdpa device running with x-svq=3Don. As a protective measure, the rewind of the inflight descriptors was done at the destination. That way if the source sent a virtqueue with inuse descriptors they are always discarded. Since this series allows to migrate also to passthrough devices with no SVQ, the right thing to do is to rewind at the source so the base of vrings are correct. Support for inflight descriptors may be added in the future. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- v4: * Use virtqueue_unpop at vhost_svq_stop instead of rewinding at vhost_vdpa_get_vring_base. --- hw/virtio/vhost-shadow-virtqueue.c | 8 ++++++-- hw/virtio/vhost-vdpa.c | 11 ----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 515ccf870d..8361e70d1b 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -694,13 +694,17 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq) g_autofree VirtQueueElement *elem =3D NULL; elem =3D g_steal_pointer(&svq->desc_state[i].elem); if (elem) { - virtqueue_detach_element(svq->vq, elem, 0); + /* + * TODO: This is ok for networking, but other kinds of devices + * might have problems with just unpop these. + */ + virtqueue_unpop(svq->vq, elem, 0); } } =20 next_avail_elem =3D g_steal_pointer(&svq->next_guest_avail_elem); if (next_avail_elem) { - virtqueue_detach_element(svq->vq, next_avail_elem, 0); + virtqueue_unpop(svq->vq, next_avail_elem, 0); } svq->vq =3D NULL; g_free(svq->desc_next); diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 5cfa9d5d27..1550b1e26a 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1170,18 +1170,7 @@ static int vhost_vdpa_set_vring_base(struct vhost_de= v *dev, struct vhost_vring_state *ring) { struct vhost_vdpa *v =3D dev->opaque; - VirtQueue *vq =3D virtio_get_queue(dev->vdev, ring->index); =20 - /* - * vhost-vdpa devices does not support in-flight requests. Set all of = them - * as available. - * - * TODO: This is ok for networking, but other kinds of devices might - * have problems with these retransmissions. - */ - while (virtqueue_rewind(vq, 1)) { - continue; - } if (v->shadow_vqs_enabled) { /* * Device vring base was set at device start. SVQ base is handled = by --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864358; cv=none; d=zohomail.com; s=zohoarc; b=G3aS3qYJqf3jSd1hCTScevpFzG4+JOARroJ9p+Zhz+TupWY19ojPnu5FwUbPjq5Rsu4dlizvO5++GHLpUvY583J0n1ROCICZcC9NaxOt4nijOFiembTRwXm7BE1SopvKbtyfoAyGh0b+hN1wbB9aWjmOFsu+2WGuKhkCrDmNG10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864358; 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=tpAWF/+esxRRyJlmPaeI+Lu57Uweu1cLPZ4zp9M2GPo=; b=j4cbKnNLhQw81tygkfR8CbmBLh0O18Carch2+CtYAIqir8y6f1GPqpKd+ATpTQVMbqEDzeaSU5N6JeV/kBs/8CW7GJMH7bBbDZ+2/ly79pNLC3sQv2QqnzOhA7MvM+3RAJO00t5SKszbf5Ns1vRejgL5HnwRieETEoJd3qx5lMI= 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 1677864358461588.4426641757642; Fri, 3 Mar 2023 09:25:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99i-0008WO-PH; Fri, 03 Mar 2023 12:25:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99h-0008SM-Hq for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99f-0005ZR-Vb for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:17 -0500 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-77-VoFMp7cpNzigbrfywvNxgg-1; Fri, 03 Mar 2023 12:25:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5211C3C10C8A; Fri, 3 Mar 2023 17:25:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE11440D8; Fri, 3 Mar 2023 17:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864315; 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=tpAWF/+esxRRyJlmPaeI+Lu57Uweu1cLPZ4zp9M2GPo=; b=cq91JT4f0tmaeG9y/piVWKEv8HKrVOXh5XoEbzyGur+H72jzHxSCfJpYMwcpYK4qSgFMOJ vAv7TPa3tK06eXnRO6j4vWQG6n9BACuGK/bh2H3Q6KDzB2I02r0qt+1K6F7nLFQReJxtbq 5BmUD5IhwJ0c7mT7Z8mLAtm5bKgM6dU= X-MC-Unique: VoFMp7cpNzigbrfywvNxgg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 05/14] vdpa: add vhost_vdpa->suspended parameter Date: Fri, 3 Mar 2023 18:24:36 +0100 Message-Id: <20230303172445.1089785-6-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864359915100001 This allows vhost_vdpa to track if it is safe to get the vring base from the device or not. If it is not, vhost can fall back to fetch idx from the guest buffer again. No functional change intended in this patch, later patches will use this field. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- include/hw/virtio/vhost-vdpa.h | 2 ++ hw/virtio/vhost-vdpa.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 7997f09a8d..4a7d396674 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -42,6 +42,8 @@ typedef struct vhost_vdpa { bool shadow_vqs_enabled; /* Vdpa must send shadow addresses as IOTLB key for data queues, not G= PA */ bool shadow_data; + /* Device suspended successfully */ + bool suspended; /* 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 1550b1e26a..517e3cdc8d 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1193,6 +1193,14 @@ static int vhost_vdpa_get_vring_base(struct vhost_de= v *dev, return 0; } =20 + if (!v->suspended) { + /* + * Cannot trust in value returned by device, let vhost recover used + * idx from guest. + */ + return -1; + } + ret =3D vhost_vdpa_call(dev, VHOST_GET_VRING_BASE, ring); trace_vhost_vdpa_get_vring_base(dev, ring->index, ring->num); return ret; --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864385; cv=none; d=zohomail.com; s=zohoarc; b=MeldE47h/Q42TR0jC+QfzrdfzCp30r9d+GqTuCTCc/vJ5Urabiv4eYNEKOceVFwMBQm7O+h/zBmL3FGpZbjsDAGExR9F/NtuJ+Xi43XuY4pPDIh3dHFDjUDBYbio2wWW9gqy04itjsrhUil8pN39dh99adlwmp/e8cujuxxFM8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864385; 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=9MRg15iecJFcqPzVnfYjb93A0PQx0/yZcarEusnpsbQ=; b=IwyOS/dvXuGoRPP1DcCMbJP52Dr9JJWnXtZQh3hVuVl0hOd1jUiBqVG5ByrlQGaJ+GwTW/k5aPLKK8DsSKWZRcpPpE4AFc6bblvq2dEKR1tASpTTWLVpUur53S0XrDs9uY2y+M2Dwc/GoYZCwG/lTRNcInfQdsT4vIZ3BbUtFsA= 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 1677864385627571.8597869458416; Fri, 3 Mar 2023 09:26:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99k-00007n-Ct; Fri, 03 Mar 2023 12:25:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99i-0008Um-71 for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99g-0005Zg-Df for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:17 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-3eLmwFoBPq6d5pvzh2q5cw-1; Fri, 03 Mar 2023 12:25:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F51D811E9C; Fri, 3 Mar 2023 17:25:09 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EAD0440D8; Fri, 3 Mar 2023 17:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864315; 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=9MRg15iecJFcqPzVnfYjb93A0PQx0/yZcarEusnpsbQ=; b=cplyQ1p3HJUFqp6+MvdA1K760a5kHFQ9FyScITLv1jKNc965157vFaMwVcSo9tokk7ULm4 WqpgZoxzqzDa0EYtESL9YNBZHQLag53I9bZfisbk7NZFq4yfZVoNSMJxn+dZvK5/OJZv9a 3ybtiS9X+D3W8avqOv9WQe3fvDDDPf8= X-MC-Unique: 3eLmwFoBPq6d5pvzh2q5cw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 06/14] vdpa: add vhost_vdpa_suspend Date: Fri, 3 Mar 2023 18:24:37 +0100 Message-Id: <20230303172445.1089785-7-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864386123100021 The function vhost.c:vhost_dev_stop fetches the vring base so the vq state can be migrated to other devices. However, this is unreliable in vdpa, since we didn't signal the device to suspend the queues, making the value fetched useless. Suspend the device if possible before fetching first and subsequent vring bases. Moreover, vdpa totally reset and wipes the device at the last device before fetch its vrings base, making that operation useless in the last device. This will be fixed in later patches of this series. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v5: Fix backend_cap & suspend check polarity. v4: * Look for _F_SUSPEND at vhost_dev->backend_cap, not backend_features * Fall back on reset & fetch used idx from guest's memory --- hw/virtio/vhost-vdpa.c | 26 ++++++++++++++++++++++++++ hw/virtio/trace-events | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 517e3cdc8d..aecc01c6a7 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -692,11 +692,13 @@ static int vhost_vdpa_get_device_id(struct vhost_dev = *dev, =20 static int vhost_vdpa_reset_device(struct vhost_dev *dev) { + struct vhost_vdpa *v =3D dev->opaque; int ret; uint8_t status =3D 0; =20 ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); trace_vhost_vdpa_reset_device(dev, status); + v->suspended =3D false; return ret; } =20 @@ -1095,6 +1097,29 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *d= ev) } } =20 +static void vhost_vdpa_suspend(struct vhost_dev *dev) +{ + struct vhost_vdpa *v =3D dev->opaque; + int r; + + if (!vhost_vdpa_first_dev(dev)) { + return; + } + + if (dev->backend_cap & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) { + trace_vhost_vdpa_suspend(dev); + r =3D ioctl(v->device_fd, VHOST_VDPA_SUSPEND); + if (unlikely(r)) { + error_report("Cannot suspend: %s(%d)", g_strerror(errno), errn= o); + } else { + v->suspended =3D true; + return; + } + } + + vhost_vdpa_reset_device(dev); +} + static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) { struct vhost_vdpa *v =3D dev->opaque; @@ -1109,6 +1134,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) } vhost_vdpa_set_vring_ready(dev); } else { + vhost_vdpa_suspend(dev); vhost_vdpa_svqs_stop(dev); vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index a87c5f39a2..8f8d05cf9b 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -50,6 +50,7 @@ vhost_vdpa_set_vring_ready(void *dev) "dev: %p" vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t = flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: = %p config: %p config_len: %"PRIu32 +vhost_vdpa_suspend(void *dev) "dev: %p" vhost_vdpa_dev_start(void *dev, bool started) "dev: %p started: %d" vhost_vdpa_set_log_base(void *dev, uint64_t base, unsigned long long size,= int refcnt, int fd, void *log) "dev: %p base: 0x%"PRIx64" size: %llu refcn= t: %d fd: %d log: %p" vhost_vdpa_set_vring_addr(void *dev, unsigned int index, unsigned int flag= s, uint64_t desc_user_addr, uint64_t used_user_addr, uint64_t avail_user_ad= dr, uint64_t log_guest_addr) "dev: %p index: %u flags: 0x%x desc_user_addr:= 0x%"PRIx64" used_user_addr: 0x%"PRIx64" avail_user_addr: 0x%"PRIx64" log_g= uest_addr: 0x%"PRIx64 --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864332; cv=none; d=zohomail.com; s=zohoarc; b=X+IDT7c5Mksdb0hFSx6Z4cQo1QtgFSjFzgVLgcbZGg73XiV1rsRJIh37WqwfGKl7ncIVrFFV9t7iUtI/O7kimnwRTWkmBZSZefT9gBz53RLg92TY2SkAbXfre4nttqO2kusLde4eCdjn7AQya1n+YhZIC6kZLiCxDDS/4w1FIWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864332; 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=8aWl0J9N898h8Pvq0E7Tdf5Z9rDDK8cfkvlEBePRBSU=; b=dmR8V0anpHK8ezpKInFvcx0ZdHnkhdlNj7A2bvDwNpwSHYN9WM+8eso/LJ1FcXRQUHMRJQXw5FJQvOuL8hBNPd/es5sDwOMAjxiC1YHa6yZIoWmLQ67bEjLqeJ9ZOBCo7IVlL+XPcthlkvbSYYsHitWtV7fTMpebrlycVaCucc0= 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 1677864332496272.8049580251959; Fri, 3 Mar 2023 09:25:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99m-0000H2-L0; Fri, 03 Mar 2023 12:25:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99l-00009b-0F for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99j-0005bA-Dk for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:20 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-WV1bBEGOOIOWHi1_B2vsxg-1; Fri, 03 Mar 2023 12:25:13 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DB5485A5B1; Fri, 3 Mar 2023 17:25:12 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB84E440D8; Fri, 3 Mar 2023 17:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864318; 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=8aWl0J9N898h8Pvq0E7Tdf5Z9rDDK8cfkvlEBePRBSU=; b=KFb/77GP4zjCS3rquLYkx+vXhkeCdyNxSdV0+e5cgnVXD7tc3frdaha7KA+GDXuj/c2rAb CWG/4gxcJgSmpmUXhvKPwoaaIFdfGJl4V65GIMd/rzJFWnBZNcTEWaVLqM2alLGHokitpq g/uxE0hEtIlc+P5wE4OkacbVk+Ppt3Y= X-MC-Unique: WV1bBEGOOIOWHi1_B2vsxg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 07/14] vdpa: move vhost reset after get vring base Date: Fri, 3 Mar 2023 18:24:38 +0100 Message-Id: <20230303172445.1089785-8-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864334006100005 The function vhost.c:vhost_dev_stop calls vhost operation vhost_dev_start(false). In the case of vdpa it totally reset and wipes the device, making the fetching of the vring base (virtqueue state) totally useless. The kernel backend does not use vhost_dev_start vhost op callback, but vhost-user do. A patch to make vhost_user_dev_start more similar to vdpa is desirable, but it can be added on top. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- include/hw/virtio/vhost-backend.h | 4 ++++ hw/virtio/vhost-vdpa.c | 22 ++++++++++++++++------ hw/virtio/vhost.c | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index c5ab49051e..ec3fbae58d 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -130,6 +130,9 @@ typedef bool (*vhost_force_iommu_op)(struct vhost_dev *= dev); =20 typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev, int fd); + +typedef void (*vhost_reset_status_op)(struct vhost_dev *dev); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -177,6 +180,7 @@ typedef struct VhostOps { vhost_get_device_id_op vhost_get_device_id; vhost_force_iommu_op vhost_force_iommu; vhost_set_config_call_op vhost_set_config_call; + vhost_reset_status_op vhost_reset_status; } VhostOps; =20 int vhost_backend_update_device_iotlb(struct vhost_dev *dev, diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index aecc01c6a7..c9a82ce5e0 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1146,14 +1146,23 @@ static int vhost_vdpa_dev_start(struct vhost_dev *d= ev, bool started) if (started) { memory_listener_register(&v->listener, &address_space_memory); return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); - } else { - vhost_vdpa_reset_device(dev); - vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | - VIRTIO_CONFIG_S_DRIVER); - memory_listener_unregister(&v->listener); + } =20 - return 0; + return 0; +} + +static void vhost_vdpa_reset_status(struct vhost_dev *dev) +{ + struct vhost_vdpa *v =3D dev->opaque; + + if (dev->vq_index + dev->nvqs !=3D dev->vq_index_end) { + return; } + + vhost_vdpa_reset_device(dev); + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); + memory_listener_unregister(&v->listener); } =20 static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, @@ -1337,4 +1346,5 @@ const VhostOps vdpa_ops =3D { .vhost_vq_get_addr =3D vhost_vdpa_vq_get_addr, .vhost_force_iommu =3D vhost_vdpa_force_iommu, .vhost_set_config_call =3D vhost_vdpa_set_config_call, + .vhost_reset_status =3D vhost_vdpa_reset_status, }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index eb8c4c378c..a266396576 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2049,6 +2049,9 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev, bool vrings) hdev->vqs + i, hdev->vq_index + i); } + if (hdev->vhost_ops->vhost_reset_status) { + hdev->vhost_ops->vhost_reset_status(hdev); + } =20 if (vhost_dev_has_iommu(hdev)) { if (hdev->vhost_ops->vhost_set_iotlb_callback) { --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864382; cv=none; d=zohomail.com; s=zohoarc; b=lbXnXoGyTDXMbO55sHkvCeMZDqxGqDbaikN/oIjJU4myFXcEVFrHtSRAvIhgj0l/SzhfVvcdI09VA3eAoSfdq26MrprYqRe1MfvUabi+wV5fUqbBy8Mb2KDyfBleGJv/TikihrmDsFpbE3x9ejz7dNY2aFojvbIbiImp1SKEDJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864382; 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=36HXObT0IK6akZiTNkCoC/vHJoCI6P2P8iJddUIWLuQ=; b=fLF9o7kFbPlr0GeB3sE1xi9CTxirW7zVs0DDTcGfvrvkPzp8HqMr9ZE1bODtUjE4cOeIMzOeZNCrCe4lczsXFI2uEPW7ieMHef59Jk/zZzXqnRVB0oRqCwLNocjR+gIqsQAqXHiubPxzkMp5JqP81eIbYiI+wfSqN89Ki+cirs0= 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 1677864382240164.36567152300097; Fri, 3 Mar 2023 09:26:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99p-0000Ty-Ch; Fri, 03 Mar 2023 12:25:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99n-0000NU-GQ for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99l-0005bo-Kt for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:23 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-141-i_VgnqCmMFKKcF4TeYaMRw-1; Fri, 03 Mar 2023 12:25:16 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B47501815D17; Fri, 3 Mar 2023 17:25:15 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF053440D8; Fri, 3 Mar 2023 17:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864321; 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=36HXObT0IK6akZiTNkCoC/vHJoCI6P2P8iJddUIWLuQ=; b=ZRmRrEAMHqe5If4OW4pjVXf3A6L6azxuJGyVDaOTnhEhSzl7Mp2F5TTb0OPVaGQ2IB08Ap Pg/kyamHe7FvlEglvl1BWZ7MmCGnXTB7YpuZ974HDiDvRRX/+BEUP/94pC3Db/lvpy7XbF T2awItymBxqNoKlImWykH6gihJVjLHo= X-MC-Unique: i_VgnqCmMFKKcF4TeYaMRw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 08/14] vdpa: add vdpa net migration state notifier Date: Fri, 3 Mar 2023 18:24:39 +0100 Message-Id: <20230303172445.1089785-9-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864384093100016 This allows net to restart the device backend to configure SVQ on it. Ideally, these changes should not be net specific and they could be done in: * vhost_vdpa_set_features (with VHOST_F_LOG_ALL) * vhost_vdpa_set_vring_addr (with .enable_log) * vhost_vdpa_set_log_base. However, the vdpa net backend is the one with enough knowledge to configure everything because of some reasons: * Queues might need to be shadowed or not depending on its kind (control vs data). * Queues need to share the same map translations (iova tree). Also, there are other problems that may have solutions but complicates the implementation at this stage: * We're basically duplicating vhost_dev_start and vhost_dev_stop, and they could go out of sync. If we want to reuse them, we need a way to skip some function calls to avoid recursiveness (either vhost_ops -> vhost_set_features, vhost_set_vring_addr, ...). * We need to traverse all vhost_dev of a given net device twice: one to stop and get the vq state and another one after the reset to configure properties like address, fd, etc. Because of that it is cleaner to restart the whole net backend and configure again as expected, similar to how vhost-kernel moves between userspace and passthrough. If more kinds of devices need dynamic switching to SVQ we can: * Create a callback struct like VhostOps and move most of the code there. VhostOps cannot be reused since all vdpa backend share them, and to personalize just for networking would be too heavy. * Add a parent struct or link all the vhost_vdpa or vhost_dev structs so we can traverse them. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v5: * Expand patch message with latest conversation in mail thread. v4: * Delete duplication of set shadow_data and shadow_vqs_enabled moving it to data / cvq net start functions. v3: * Check for migration state at vdpa device start to enable SVQ in data vqs. v1 from RFC: * Add TODO to use the resume operation in the future. * Use migration_in_setup and migration_has_failed instead of a complicated switch case. --- net/vhost-vdpa.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index d195f48776..167b43679d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -26,12 +26,15 @@ #include #include "standard-headers/linux/virtio_net.h" #include "monitor/monitor.h" +#include "migration/migration.h" +#include "migration/misc.h" #include "hw/virtio/vhost.h" =20 /* Todo:need to add the multiqueue support here */ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; + Notifier migration_state; VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ @@ -239,10 +242,59 @@ static VhostVDPAState *vhost_vdpa_net_first_nc_vdpa(V= hostVDPAState *s) return DO_UPCAST(VhostVDPAState, nc, nc0); } =20 +static void vhost_vdpa_net_log_global_enable(VhostVDPAState *s, bool enabl= e) +{ + struct vhost_vdpa *v =3D &s->vhost_vdpa; + VirtIONet *n; + VirtIODevice *vdev; + int data_queue_pairs, cvq, r; + + /* We are only called on the first data vqs and only if x-svq is not s= et */ + if (s->vhost_vdpa.shadow_vqs_enabled =3D=3D enable) { + return; + } + + vdev =3D v->dev->vdev; + n =3D VIRTIO_NET(vdev); + if (!n->vhost_started) { + return; + } + + data_queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; + /* + * TODO: vhost_net_stop does suspend, get_base and reset. We can be sm= arter + * in the future and resume the device if read-only operations between + * suspend and reset goes wrong. + */ + vhost_net_stop(vdev, n->nic->ncs, data_queue_pairs, cvq); + + /* Start will check migration setup_or_active to configure or not SVQ = */ + r =3D vhost_net_start(vdev, n->nic->ncs, data_queue_pairs, cvq); + if (unlikely(r < 0)) { + error_report("unable to start vhost net: %s(%d)", g_strerror(-r), = -r); + } +} + +static void vdpa_net_migration_state_notifier(Notifier *notifier, void *da= ta) +{ + MigrationState *migration =3D data; + VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, + migration_state); + + if (migration_in_setup(migration)) { + vhost_vdpa_net_log_global_enable(s, true); + } else if (migration_has_failed(migration)) { + vhost_vdpa_net_log_global_enable(s, false); + } +} + static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) { struct vhost_vdpa *v =3D &s->vhost_vdpa; =20 + add_migration_state_change_notifier(&s->migration_state); if (v->shadow_vqs_enabled) { v->iova_tree =3D vhost_iova_tree_new(v->iova_range.first, v->iova_range.last); @@ -256,6 +308,15 @@ static int vhost_vdpa_net_data_start(NetClientState *n= c) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 + if (s->always_svq || + migration_is_setup_or_active(migrate_get_current()->state)) { + v->shadow_vqs_enabled =3D true; + v->shadow_data =3D true; + } else { + v->shadow_vqs_enabled =3D false; + v->shadow_data =3D false; + } + if (v->index =3D=3D 0) { vhost_vdpa_net_data_start_first(s); return 0; @@ -276,6 +337,10 @@ static void vhost_vdpa_net_client_stop(NetClientState = *nc) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 + if (s->vhost_vdpa.index =3D=3D 0) { + remove_migration_state_change_notifier(&s->migration_state); + } + dev =3D s->vhost_vdpa.dev; if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); @@ -412,11 +477,12 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) s =3D DO_UPCAST(VhostVDPAState, nc, nc); v =3D &s->vhost_vdpa; =20 - v->shadow_data =3D s->always_svq; + s0 =3D vhost_vdpa_net_first_nc_vdpa(s); + v->shadow_data =3D s0->vhost_vdpa.shadow_vqs_enabled; v->shadow_vqs_enabled =3D s->always_svq; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; =20 - if (s->always_svq) { + if (s->vhost_vdpa.shadow_data) { /* SVQ is already configured for all virtqueues */ goto out; } @@ -473,7 +539,6 @@ out: return 0; } =20 - s0 =3D vhost_vdpa_net_first_nc_vdpa(s); if (s0->vhost_vdpa.iova_tree) { /* * SVQ is already configured for all virtqueues. Reuse IOVA tree = for @@ -749,6 +814,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; + s->migration_state.notify =3D vdpa_net_migration_state_notifier; s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.iova_range =3D iova_range; s->vhost_vdpa.shadow_data =3D svq; --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864339; cv=none; d=zohomail.com; s=zohoarc; b=DGuBS0n0f/NXEefo+AUjvDpAg6vk/aSo8SPpixThUutIYAzOPEzlJCZ/LaJsZw4bS47YIMcqddH8coXWWQRjsUiLe8Z2hoOo7KjKEmrrK96oV+l97ofCWhfD6wacBI8quE5SwhDt1/RtSvYy9/wtVipWweDXviRGK1ccb5g8vhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864339; 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=MbMrm/5o7KL5RcJRFUbSHY5hxxvHx8R161EGdxHoJg8=; b=MJK3zVYc6HdmY4xk8sMMA7ftPHMPfwABebud7ihxlBsfAZHMyIWGrolChasyU6FRDGt0rihjuIOniv0H0ElBjgRlNakpKbZvPT1cWGc2N/pFaqU8ThxeMt9ixiQ+2EhH4L/aof+x25/hiDnVeLjXwbFcuYzabpErGgZ07/r+RBA= 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 16778643393049.554933135389433; Fri, 3 Mar 2023 09:25:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99r-0000Xg-Ie; Fri, 03 Mar 2023 12:25:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99p-0000Vx-UE for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99o-0005cq-C3 for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:25 -0500 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-438-sw01AhOLPlWOjK4QUl3iRg-1; Fri, 03 Mar 2023 12:25:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBC5E3C10ECC; Fri, 3 Mar 2023 17:25:18 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1E25440D8; Fri, 3 Mar 2023 17:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864323; 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=MbMrm/5o7KL5RcJRFUbSHY5hxxvHx8R161EGdxHoJg8=; b=YVmukzH8dZGmjORlpDRi64am5K6dGououhbaBIYE7PFMnn98DQhJLnmMFS0P3mzinkSGIc 5LVXZIWwmLWgLMetHP03TbBC7Ulvspm1NcfXXYfMuQ10gKjaWSCwwyRRFlaBfdGMaKLzwv /vfMN2M7MoYLaRLMCPrJjtxS0uh4/Ec= X-MC-Unique: sw01AhOLPlWOjK4QUl3iRg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 09/14] vdpa: disable RAM block discard only for the first device Date: Fri, 3 Mar 2023 18:24:40 +0100 Message-Id: <20230303172445.1089785-10-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864339817100003 Although it does not make a big difference, its more correct and simplifies the cleanup path in subsequent patches. Move ram_block_discard_disable(false) call to the top of vhost_vdpa_cleanup because: * We cannot use vhost_vdpa_first_dev after dev->opaque =3D NULL assignment. * Improve the stack order in cleanup: since it is the last action taken in init, it should be the first at cleanup. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- hw/virtio/vhost-vdpa.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index c9a82ce5e0..49afa59261 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -431,16 +431,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) trace_vhost_vdpa_init(dev, opaque); int ret; =20 - /* - * Similar to VFIO, we end up pinning all guest memory and have to - * disable discarding of RAM. - */ - ret =3D ram_block_discard_disable(true); - if (ret) { - error_report("Cannot set discarding of RAM broken"); - return ret; - } - v =3D opaque; v->dev =3D dev; dev->opaque =3D opaque ; @@ -452,6 +442,16 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) return 0; } =20 + /* + * Similar to VFIO, we end up pinning all guest memory and have to + * disable discarding of RAM. + */ + ret =3D ram_block_discard_disable(true); + if (ret) { + error_report("Cannot set discarding of RAM broken"); + return ret; + } + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); =20 @@ -577,12 +577,15 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev) assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); v =3D dev->opaque; trace_vhost_vdpa_cleanup(dev, v); + if (vhost_vdpa_first_dev(dev)) { + ram_block_discard_disable(false); + } + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); memory_listener_unregister(&v->listener); vhost_vdpa_svq_cleanup(dev); =20 dev->opaque =3D NULL; - ram_block_discard_disable(false); =20 return 0; } --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864417; cv=none; d=zohomail.com; s=zohoarc; b=hgqtDS807elxhCSAFFfj+qBOATfMBw6c3vDDf9xq0ugBPa2hlxAvckHNVW57MAwGNR4d6Rb9cgZi9rLvnLyqmnDW95ffvhETCtg6S65NkXZWxVWMMc45jk3sMdTMNuOI1P5sbYIkfh3O4VaWsPTuAwIYh94o7YO6yHJQ2H9tQ+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864417; 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=rQxGvAul/Q+ZehzUo/rRKfGfTW9rsOXJygSItA3NCgA=; b=Q2OYljvzpz0+1sXah3uQteLNUFQqpPbIVD5HFlszNFRVZcIbxdw86ScfzvfVvwmsiAoUeQc+kglrjVov+iBS9G69fAt6HFgG2y4PdpmDV1cnUO1I0+wj+21vSGwGlhSTwsdlv09bDJt+qEkwZ3tsI1MEkx2XuvlXo1UHMLDvizY= 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 1677864417792321.8225932866537; Fri, 3 Mar 2023 09:26:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY99u-0000iO-9E; Fri, 03 Mar 2023 12:25:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99s-0000cO-BJ for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99q-0005eQ-Sz for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:28 -0500 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-510-W8IVbMRWOdmftCiWT_0Txw-1; Fri, 03 Mar 2023 12:25:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14B5D3814591; Fri, 3 Mar 2023 17:25:22 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 246BD440D8; Fri, 3 Mar 2023 17:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864326; 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=rQxGvAul/Q+ZehzUo/rRKfGfTW9rsOXJygSItA3NCgA=; b=EJvn1/daEtCqvP00r06Kc/RYby0fyWSxp3LM6XYMf9wslkBz613HFelMPIwWPpjJgw/Crw u2iQjfMegANE8SW97eW0H5d0KbzPLF0lheATCH/kiDOzTTyoavtVJk3kAKem0p0D0nZwNh +qlrs9jy2065qT0soGks1B3ZGxiLjTQ= X-MC-Unique: W8IVbMRWOdmftCiWT_0Txw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 10/14] vdpa net: block migration if the device has CVQ Date: Fri, 3 Mar 2023 18:24:41 +0100 Message-Id: <20230303172445.1089785-11-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864418358100006 Devices with CVQ need to migrate state beyond vq state. Leaving this to future series. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v5: Fix comment (s/v/s->vhost_vdpa/). v3: Migration blocker is registered in vhost_dev. --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 1 + net/vhost-vdpa.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 4a7d396674..c278a2a8de 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -50,6 +50,7 @@ typedef struct vhost_vdpa { const VhostShadowVirtqueueOps *shadow_vq_ops; void *shadow_vq_ops_opaque; struct vhost_dev *dev; + Error *migration_blocker; VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX]; } VhostVDPA; =20 diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 49afa59261..e9167977d5 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -438,6 +438,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void = *opaque, Error **errp) v->msg_type =3D VHOST_IOTLB_MSG_V2; vhost_vdpa_init_svq(dev, v); =20 + error_propagate(&dev->migration_blocker, v->migration_blocker); if (!vhost_vdpa_first_dev(dev)) { return 0; } diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 167b43679d..533ba54317 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -828,6 +828,15 @@ static NetClientState *net_vhost_vdpa_init(NetClientSt= ate *peer, =20 s->vhost_vdpa.shadow_vq_ops =3D &vhost_vdpa_net_svq_ops; s->vhost_vdpa.shadow_vq_ops_opaque =3D s; + + /* + * TODO: We cannot migrate devices with CVQ as there is no way to = set + * the device state (MAC, MQ, etc) before starting the datapath. + * + * Migration blocker ownership now belongs to s->vhost_vdpa. + */ + error_setg(&s->vhost_vdpa.migration_blocker, + "net vdpa cannot migrate with CVQ feature"); } ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, queue_pair_index, n= vqs); if (ret) { --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864383; cv=none; d=zohomail.com; s=zohoarc; b=SXllqTNafY5aUOE2Vc9gYA1quvohiOZXfexewUevnPqeJo3lV49BCTqWJEGtVtBJzfToi/4F0iCySBByQQA6YG43kssegOMCsHAZWXSI6LiyVKvCyDUEk1B9qBdH6cTsn5iNoT6qeG+yiQk4mzYUDojUjgj9SZfgPMXn/IbkL0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864383; 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=aXv/w5pUqu4Xe3zCx5/W1q+NbgG8V0nkqCK9SpXcFKY=; b=Embwc/fo9IcIR6ZPopcDFZYoO58Fmj0yf/+ju9O1eWTVsuM3dt5jJwgZnioefCLYKZWUn5MSmpu9Mpe83uRR41wG4yAgjUevnAHnDePNWknm4UVFtvyjWE7xd6Xsyk6G+cSh7LRbeXpalK1/a7JP+Sn0bDBBCphDuYYpIoUPvbI= 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 1677864383546351.0079628209737; Fri, 3 Mar 2023 09:26:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY9AH-000170-A8; Fri, 03 Mar 2023 12:25:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99w-0000q5-P8 for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99t-0005hR-Vo for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:31 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-583-iEVtxzKdM5WnzR2_1CyCkA-1; Fri, 03 Mar 2023 12:25:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34C7985CCE4; Fri, 3 Mar 2023 17:25:25 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A0C440D8; Fri, 3 Mar 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864329; 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=aXv/w5pUqu4Xe3zCx5/W1q+NbgG8V0nkqCK9SpXcFKY=; b=CAh8OQtKgnUmzQSW//5qrW0oXMtVCqPNw6myWJCk1jwepPPBdgPW7HT4q38lLcvyAK1/Nx aPBUZJVBpq/DXUO8MUQLf0PPzAc3d03e0wimtoYwl/Sfv+EhR1+QrcMRVrzd4TXS+aQF/g TvT+OMAc2RW11KrWjleQntb3AuirC50= X-MC-Unique: iEVtxzKdM5WnzR2_1CyCkA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 11/14] vdpa: block migration if device has unsupported features Date: Fri, 3 Mar 2023 18:24:42 +0100 Message-Id: <20230303172445.1089785-12-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864384059100015 A vdpa net device must initialize with SVQ in order to be migratable at this moment, and initialization code verifies some conditions. If the device is not initialized with the x-svq parameter, it will not expose _F_LOG so the vhost subsystem will block VM migration from its initialization. Next patches change this, so we need to verify migration conditions differently. QEMU only supports a subset of net features in SVQ, and it cannot migrate state that cannot track or restore in the destination. Add a migration blocker if the device offers an unsupported feature. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- v3: add migration blocker properly so vhost_dev can handle it. --- net/vhost-vdpa.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 533ba54317..1089c35959 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -795,7 +795,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, int nvqs, bool is_datapath, bool svq, - struct vhost_vdpa_iova_range iova_r= ange) + struct vhost_vdpa_iova_range iova_r= ange, + uint64_t features) { NetClientState *nc =3D NULL; VhostVDPAState *s; @@ -818,7 +819,10 @@ static NetClientState *net_vhost_vdpa_init(NetClientSt= ate *peer, s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.iova_range =3D iova_range; s->vhost_vdpa.shadow_data =3D svq; - if (!is_datapath) { + if (queue_pair_index =3D=3D 0) { + vhost_vdpa_net_valid_svq_features(features, + &s->vhost_vdpa.migration_blocker= ); + } else if (!is_datapath) { s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_le= n()); memset(s->cvq_cmd_out_buffer, 0, vhost_vdpa_net_cvq_cmd_page_len()= ); @@ -956,7 +960,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, true, opts->x_s= vq, - iova_range); + iova_range, features); if (!ncs[i]) goto err; } @@ -964,7 +968,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, false, - opts->x_svq, iova_range); + opts->x_svq, iova_range, features); if (!nc) goto err; } --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864503; cv=none; d=zohomail.com; s=zohoarc; b=X8556yS0/JXzlMW+r1+U6SeXN7AJeg7xIPYCGYbEOb5DzbW1vwKi/pKZBjkCEV+K4QhIogYrfpC4sfvNc98aWOu6cjJ9oSnsomfVmzTNjPsB9kmMR8+ZvIdwGkCb/07UZGsQF0ViPRQUTcSdkOZjcOSJqHFKC53oXOdOpX25NfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864503; 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=sltYOkDZC6GUhGLiSaXl9teBLMzWcUrVY6DLMPI3pF4=; b=JE3KWv7jkyNmh6Tu90TleDEbnBnDvHwmOzjkDf5UtpvlpBnHIGBA/xSBoik1JI1aKMxlnd3LmFb7OIBKu9ZBmLbvoTu/7QHhfqUO6dnEm+jyTiKliolGVbh7TT3g8xnUPc7x+NcSwHkTEAPnWT9C9uHL1sAw5xPooTB3NyxTadc= 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 1677864503122418.7018345491357; Fri, 3 Mar 2023 09:28:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY9AO-0001fR-Rb; Fri, 03 Mar 2023 12:26:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY9A0-0000x4-GC for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY99x-0005jf-3b for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:35 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-U3sFvKa-NIOv9CThXKljaA-1; Fri, 03 Mar 2023 12:25:29 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A63D802D2F; Fri, 3 Mar 2023 17:25:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7072B440D8; Fri, 3 Mar 2023 17:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864332; 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=sltYOkDZC6GUhGLiSaXl9teBLMzWcUrVY6DLMPI3pF4=; b=jD5WqAFHB6VYTLnGFrtvTvKQU2G2r1tTG5vh7gYTPGDC2qqNR2AcotfIIbjI429JS+FVjG eom0/lNlZr50jr47IO0tcm4F3FE260IgACxMVSrLQDBzXafoijwA1NG/l9z3GSq14SuXr1 PBV2E73y63b2MYoEBk2a5RjwQxdOn4M= X-MC-Unique: U3sFvKa-NIOv9CThXKljaA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 12/14] vdpa: block migration if SVQ does not admit a feature Date: Fri, 3 Mar 2023 18:24:43 +0100 Message-Id: <20230303172445.1089785-13-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864504887100005 Next patches enable devices to be migrated even if vdpa netdev has not been started with x-svq. However, not all devices are migratable, so we need to block migration if we detect that. Block migration if we detect the device expose a feature SVQ does not know how to work with. Signed-off-by: Eugenio P=C3=A9rez Tested-by: Lei Yang --- hw/virtio/vhost-vdpa.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e9167977d5..48ffb67a34 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -443,6 +443,21 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) return 0; } =20 + /* + * If dev->shadow_vqs_enabled at initialization that means the device = has + * been started with x-svq=3Don, so don't block migration + */ + if (dev->migration_blocker =3D=3D NULL && !v->shadow_vqs_enabled) { + /* We don't have dev->features yet */ + uint64_t features; + ret =3D vhost_vdpa_get_dev_features(dev, &features); + if (unlikely(ret)) { + error_setg_errno(errp, -ret, "Could not get device features"); + return ret; + } + vhost_svq_valid_features(features, &dev->migration_blocker); + } + /* * Similar to VFIO, we end up pinning all guest memory and have to * disable discarding of RAM. --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864438; cv=none; d=zohomail.com; s=zohoarc; b=D5L6KdLDz72ORqmWMWjP/AqjCZhnmXLnKOxtY3buuRwG3N8k0KveH5Vx7PuwNr7YHFiNifbU0XxF8kCqEZiqEMBLQbv8wd678O4HNJ/m6jThd8Heanm9RM1xUnSq7L5U1yiFOhIISfhgvglJ/BPn6UypYaC3J9Xdph3T60TdVQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864438; 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=kpmXqZz3ODPWDj7MKkO2OC81CrDXTX2V7aX2M28sKqc=; b=TObrvI8lDNUw0J7vuWzropunfgaQZ+evNlCz1OiUWBOwoEV4VXmGPg18tzUKmKl2uD3kcOTrrx2OnpdcV5IDHjXnRNKYDVo1qj7lIZPe/PCJZ1FgZTFVYGyGMPODdNaQJELed7ThdYtnaboKZLCcY2FIBSWqJ0BelHbQbz+a/C8= 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 167786443817076.715298242171; Fri, 3 Mar 2023 09:27:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY9AP-0001p1-NN; Fri, 03 Mar 2023 12:26:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY9A1-0000y1-KG for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY9A0-0005kZ-7t for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:37 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-unRLVchJMg-exbyBdMw0cA-1; Fri, 03 Mar 2023 12:25:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 82D94802D2F; Fri, 3 Mar 2023 17:25:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97C56440D8; Fri, 3 Mar 2023 17:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864335; 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=kpmXqZz3ODPWDj7MKkO2OC81CrDXTX2V7aX2M28sKqc=; b=TPUpsS2q1c2sJUYenO5/dPmwgmhaJqvAd32pyBJfSiLpk4feT3aSuI9DHW7UXqx5uj95Wz X6EZ5kuyDUf7W8MffGzZt97aJk8UPooYlkK0ZPawmSAh6tjcrLzCAcaIVe93PCFRH8DPoF EcUNNtYd90LTezpj13jS1BFWDSbfOBA= X-MC-Unique: unRLVchJMg-exbyBdMw0cA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 13/14] vdpa net: allow VHOST_F_LOG_ALL Date: Fri, 3 Mar 2023 18:24:44 +0100 Message-Id: <20230303172445.1089785-14-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864438428100001 Since some actions move to the start function instead of init, the device features may not be the parent vdpa device's, but the one returned by vhost backend. If transition to SVQ is supported, the vhost backend will return _F_LOG_ALL to signal the device is migratable. Add VHOST_F_LOG_ALL. HW dirty page tracking can be added on top of this change if the device supports it in the future. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- net/vhost-vdpa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1089c35959..99904a0da7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -101,6 +101,8 @@ static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | + /* VHOST_F_LOG_ALL is exposed by SVQ */ + BIT_ULL(VHOST_F_LOG_ALL) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY); =20 --=20 2.31.1 From nobody Mon May 6 04:15:56 2024 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=1677864378; cv=none; d=zohomail.com; s=zohoarc; b=IRn7v1PuY3YSNIf63keaDuOpD21++IAAFFfnStGFvTpmPIRRsgUsU8MhjnfZWyLK1uw0rXwec56kA3aY4qE79HUpuIRxHOIvmHHVXZe78gkO/TaoEfyEZ99evS9nJAzau7qgTcrpqFEg3ysOgBkx919WiY1HqynTsRGuhsi5gNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677864378; 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=PNQyZOm/t2/DLCtmUTqu02MbFHrHAMggo+IbmoAkDcI=; b=m1yC2L0yab5vlpdzrmA9mUVg0bPzH3siu8mtf2JROca6zR/AJLxZwdy4los03Dm0/m/VLXSpB9pDGo6coPnFuAsYDXvj6S1Q35mtmnFScx6yCb1Gzc5SRhSFe5YXtx3Ijy4C5htL182dWQd0kaePFXzT0jrTSfUDf9ngEW3RRfA= 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 1677864378252757.357045370877; Fri, 3 Mar 2023 09:26:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY9AK-0001BN-7G; Fri, 03 Mar 2023 12:25:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY9A4-00010q-EO for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pY9A2-0005lI-RR for qemu-devel@nongnu.org; Fri, 03 Mar 2023 12:25:40 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-DA71nQwrP6KRyucyV_DE9w-1; Fri, 03 Mar 2023 12:25:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2250800050; Fri, 3 Mar 2023 17:25:35 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF1A0440D8; Fri, 3 Mar 2023 17:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677864338; 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=PNQyZOm/t2/DLCtmUTqu02MbFHrHAMggo+IbmoAkDcI=; b=G3DOJhjbqYwGq/zT0ffrD1yv+VPVrtc+2vT1iM9OZ4fTc68GlTZNQF3Qrga+oo6UZQNRyx 9/tz0p9t/7LR5ECX6/LNBNkg+zZZHCMrI8Q+T0gO2X1Gc0VygD5LCPrk0kj/GoT5yTQ2DQ fN3msleaemsS/PlOXzMBc8zvoeDfbOY= X-MC-Unique: DA71nQwrP6KRyucyV_DE9w-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Michael S. Tsirkin" , Gautam Dawar , Lei Yang , Harpreet Singh Anand , Shannon Nelson , Liuxiangdong , Cindy Lu , Parav Pandit , Zhu Lingshan , virtualization@lists.linux-foundation.org, Eli Cohen , si-wei.liu@oracle.com, longpeng2@huawei.com, Jason Wang , alvaro.karsz@solid-run.com, Stefan Hajnoczi , Stefano Garzarella , "Gonglei (Arei)" Subject: [PATCH v5 14/14] vdpa: return VHOST_F_LOG_ALL in vhost-vdpa devices Date: Fri, 3 Mar 2023 18:24:45 +0100 Message-Id: <20230303172445.1089785-15-eperezma@redhat.com> In-Reply-To: <20230303172445.1089785-1-eperezma@redhat.com> References: <20230303172445.1089785-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.5 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.129.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, RCVD_IN_MSPIKE_H2=-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.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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677864380100100003 vhost-vdpa devices can return this feature now that blockers have been set in case some features are not met. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Tested-by: Lei Yang --- hw/virtio/vhost-vdpa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 48ffb67a34..bc6bad23d5 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1294,10 +1294,9 @@ static int vhost_vdpa_set_vring_call(struct vhost_de= v *dev, static int vhost_vdpa_get_features(struct vhost_dev *dev, uint64_t *features) { - struct vhost_vdpa *v =3D dev->opaque; int ret =3D vhost_vdpa_get_dev_features(dev, features); =20 - if (ret =3D=3D 0 && v->shadow_vqs_enabled) { + if (ret =3D=3D 0) { /* Add SVQ logging capabilities */ *features |=3D BIT_ULL(VHOST_F_LOG_ALL); } --=20 2.31.1