From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544310; cv=none; d=zohomail.com; s=zohoarc; b=ZbLIertch9pe1IavN8lKQtV+PGr5z7Eel/OqMWIRpxo1TQ3EFvAIjr4vRPqEdlo/hLmU9XpVSK8RGLNLyFtFezMXIbqY5OVnU43sDbZ+IRybPvGHHwkcJXEVhEv0nxBYrl1+79VVL8zIu/Vi+ul8ilwzGfjHXPOazirs2jtBcFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544310; 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=qJD1HzXwvSk3GARzG3sqpjY2KsnVtRYY9MyobLbYX+0=; b=dUxf4yDE+f9MTu45ltaiKDoiivJHHWXRsqNumREUux3fZiebR6o1yACxlXXqZsVnyGwMlXJpNpZNPfKP0EcW9+Ov5TcklBGksjOFskGBypSTSOO2Cft2r03LKMRMCzAZGJxEdUjfKRLPjaLKMtvC795WZOPLxdnyUiDTdZG0/D0= 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+importer2=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 1673544310240932.9435024397968; Thu, 12 Jan 2023 09:25:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1Jr-0006Rn-QJ; Thu, 12 Jan 2023 12:24:51 -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 1pG1Jp-0006R6-Px for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:49 -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 1pG1Jo-0008Ea-7S for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:49 -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-206-iQOdy1CHOFeBWk9Ms_6crw-1; Thu, 12 Jan 2023 12:24:44 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9127B2999B38; Thu, 12 Jan 2023 17:24:43 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46F6B4078903; Thu, 12 Jan 2023 17:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544287; 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=qJD1HzXwvSk3GARzG3sqpjY2KsnVtRYY9MyobLbYX+0=; b=Tpqn+4ndjIrN2dmhVSbvX02tVVUiVJwsmzniNXuksSOp1AEjadTU4S4tILz49Rk/970J4T YR7tjPZpI6E5e2nEV4X/BRQNydWM7xo9X1anbCk2G404q9IrNTqZ2CEmzTh9r4pJrjCrnj ecPG2bZVXKCrG3YDkyTBcPW8kcUU1NA= X-MC-Unique: iQOdy1CHOFeBWk9Ms_6crw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 01/13] vdpa: fix VHOST_BACKEND_F_IOTLB_ASID flag check Date: Thu, 12 Jan 2023 18:24:22 +0100 Message-Id: <20230112172434.760850-2-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544312758100001 VHOST_BACKEND_F_IOTLB_ASID is the feature bit, not the bitmask. Since the device under test also provided VHOST_BACKEND_F_IOTLB_MSG_V2 and VHOST_BACKEND_F_IOTLB_BATCH, this went unnoticed. Fixes: c1a1008685 ("vdpa: always start CVQ in SVQ mode if possible") Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- net/vhost-vdpa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1a13a34d35..de5ed8ff22 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -384,7 +384,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) g_strerror(errno), errno); return -1; } - if (!(backend_features & VHOST_BACKEND_F_IOTLB_ASID) || + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) || !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { return 0; } --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544395; cv=none; d=zohomail.com; s=zohoarc; b=aVXYsnzsOOinLqePJK4NgemAf8ZgQhDPopOa/Hma50zmU1T+nmJcoK6K0yqdeuB9FLF/n8aItYHJWOaASPkp0zYGPxrkp0rCNkjTFbUjURdS8Wmhh4aB3Z+GYu8JYII/C7I7MPIuC5ioo1uIU/nS3j2Wc6nHAQmOCwKyU9GfyPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544395; 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=Un6dMgF/0xEF5kZf4lTzV6BHwFya8ps6TKHefhZmer0=; b=Vw0ZEt5bO0UyrNVWbOLvL1u8OzdfL/Ta/XfTCAGF0DMiZBJMlrd/IvaTSMaCQbrjqVvPwgAz9bzFSgyOMywsE2rsTFTXsG2PCPbaaTf/xNfKF+4GMB7i+WNMNw9JrrhwpYhZj3DbX+/iy1INvEBqfqFn+tjBxbxsEJRgvZWcfPI= 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+importer2=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 SMTP id 167354439558777.41399914244573; Thu, 12 Jan 2023 09:26:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1Jv-0006WR-GB; Thu, 12 Jan 2023 12:24:55 -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 1pG1Jt-0006TW-H2 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:53 -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 1pG1Jr-0008En-Kx for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:53 -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-416-9srk3AtiOsueAVlUlLC-4Q-1; Thu, 12 Jan 2023 12:24:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1879485D06A; Thu, 12 Jan 2023 17:24:47 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAC484078903; Thu, 12 Jan 2023 17:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544291; 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=Un6dMgF/0xEF5kZf4lTzV6BHwFya8ps6TKHefhZmer0=; b=KQm+Gu6s9q208N8PrOJ8cqaVdM/a/hrs7SX/cSzSs5e5k4+3VxB2eQ2lDC/l59CcInMr0T 4g/rkcQT9WV89CQBeqEk++Upb5o5rfL8AvD5KEOeTCcP9TTdm0YKU2H/AnGJQaltfOrZnf 4ntbTt9ay2aIV/oSKw471bAZB25BJMQ= X-MC-Unique: 9srk3AtiOsueAVlUlLC-4Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 02/13] vdpa net: move iova tree creation from init to start Date: Thu, 12 Jan 2023 18:24:23 +0100 Message-Id: <20230112172434.760850-3-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544396748100001 Only create iova_tree if and when it is needed. The cleanup keeps being responsability of last VQ but this change allows to merge both cleanup functions. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- net/vhost-vdpa.c | 101 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index de5ed8ff22..75cca497c8 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 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,15 @@ 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 */ + 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 +506,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 +718,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 +740,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 +809,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 +860,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 +869,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 +877,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 +891,6 @@ err: } } =20 -err_svq: qemu_close(vdpa_device_fd); =20 return -1; --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544314; cv=none; d=zohomail.com; s=zohoarc; b=a3iFqx0QBSdtUvA6+rqpJx6a/DXD0KLhU7amsMtswOmEdbyBHPr2s8bzB+UhKE/HsnjrrIUScGJ4NZYvRNfxWKFlVFiNRr+uJqEmpx4hMYj2GCMUEmzKFC+le0WbEqMdkySX3lVYFjOd+0Yb7aFljBDbCwcf5+z1i+3Pc2E1yZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544314; 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=WtglQDGt1tKSyIon9wCh+pG9fJLpZeGeDD6u2deNBw0=; b=fdYnaC64VneL2/vP4zClgFEamimP+SBVXFxVMIrwHiM0Vk7mMi2Oun8XbplLDLo/PCJBZVMaqqc1K27wt3UP72n5SjOYgmfXm38YbDQO4peXu7syk1hoWHthFdzxxp8Ajr0R5HLvQB0SY5zl2CNBXyTP4Ng4mP7s4y+LxtA8XbU= 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+importer2=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 1673544314994672.0742560286043; Thu, 12 Jan 2023 09:25:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1Jz-0006Z9-6J; Thu, 12 Jan 2023 12:24:59 -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 1pG1Jx-0006Xn-W1 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:58 -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 1pG1Jw-0008F5-3c for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:24:57 -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-507-Dh34RW00OsixZYPfxSxMeA-1; Thu, 12 Jan 2023 12:24:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81404382C971; Thu, 12 Jan 2023 17:24:50 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC2D4078903; Thu, 12 Jan 2023 17:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544295; 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=WtglQDGt1tKSyIon9wCh+pG9fJLpZeGeDD6u2deNBw0=; b=WrZZ9R7nlMwWYqUeG6MG9Z8eWiRUyqCv6ZOxeZngPF4lfXYsU5VpGB8CissuKR9UWlUj0y Ify4eS5mHa/CqfE2XPks2xDOeRHxrjn/lYCflbH5ldCx/lMfTTsYo9Ao5+RrZOoqXJmUNi B2aywGX9CaN0EGB4qmsooNTPCKBVbt4= X-MC-Unique: Dh34RW00OsixZYPfxSxMeA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 03/13] vdpa: copy cvq shadow_data from data vqs, not from x-svq Date: Thu, 12 Jan 2023 18:24:24 +0100 Message-Id: <20230112172434.760850-4-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544316185100004 This allows to passthrough or shadow the data depending on migration state in next patches. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 75cca497c8..631424d9c4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -412,7 +412,6 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) s =3D DO_UPCAST(VhostVDPAState, nc, nc); v =3D &s->vhost_vdpa; =20 - v->shadow_data =3D s->always_svq; v->shadow_vqs_enabled =3D s->always_svq; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_GUEST_PA_ASID; =20 @@ -482,6 +481,12 @@ out: v->iova_range.last); } =20 + /* + * Memory listener is registered against CVQ vhost device, but differe= nt + * ASID may enable individually SVQ. Let's copy data vqs value here. + */ + v->shadow_data =3D s0->vhost_vdpa.shadow_data; + 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)) { --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544529; cv=none; d=zohomail.com; s=zohoarc; b=MUW2MMzs6FbpzknvgcxZladeMWTxQU7HZEBTKIEfUB/8tz8dqvCRG8cilw+msuNbosqFhUFo55B2s81LJZpPRi++6uPt8DmI/1Eq0sJAtyKd8+Ljc3OVMtEn7qYPWMii34ttNTBmBii2LL+nZCOQC/F0o9cRPzLC5VudTg3CeTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544529; 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=nYcFDZQuxT8/AMv4CeTT3PJQmkzddtBExbKUq1RE9cQ=; b=Gt/ay/da098xSSqCZ6HpbBcj/LcPH/M7m6A2qbQkqH1QWccIQp5N7+PFqODFqql+aa8mrV4Vc5j+VJn8yXAUnh7p0bFyyYmUmlVjta4qt4ndd6mVhQ9i4ucufLpfb/iYZ5T0w5FUTwPxYpWym9343rXjw9RWJf3Oz/3vNiMiekI= 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+importer2=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 SMTP id 167354452990030.409044008437718; Thu, 12 Jan 2023 09:28:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1K3-0006cJ-RS; Thu, 12 Jan 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 1pG1K1-0006aK-SR for qemu-devel@nongnu.org; Thu, 12 Jan 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 1pG1K0-0008Fh-0p for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:01 -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-227-IxgshAdMOluuqX5IwncfsQ-1; Thu, 12 Jan 2023 12:24:54 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E84F71C0512F; Thu, 12 Jan 2023 17:24:53 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6A404078903; Thu, 12 Jan 2023 17:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544299; 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=nYcFDZQuxT8/AMv4CeTT3PJQmkzddtBExbKUq1RE9cQ=; b=COhb8+mAy+ULZDZYWVp3oJo79elh292tGv/MBe0bi5OcPKs5ne7m4aTneVEh7SnTrJPc3A Nx3DUIl8sJ0WjSdk/KXzCg4Xuv91zOp4JczSr0bU0+uoBE9kebzA2DlImD7BbNR+Q2/CnN 88gphvU/FtY8gvtaXtBFspqIw3oY4FQ= X-MC-Unique: IxgshAdMOluuqX5IwncfsQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 04/13] vdpa: rewind at get_base, not set_base Date: Thu, 12 Jan 2023 18:24:25 +0100 Message-Id: <20230112172434.760850-5-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544531737100002 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 base of vrings are correct. Support for inflight descriptors may be added in the future. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost-backend.h | 4 +++ hw/virtio/vhost-vdpa.c | 46 +++++++++++++++++++------------ hw/virtio/vhost.c | 3 ++ 3 files changed, 36 insertions(+), 17 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 542e003101..28a52ddc78 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1132,14 +1132,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, @@ -1182,18 +1191,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 @@ -1212,6 +1210,19 @@ static int vhost_vdpa_get_vring_base(struct vhost_de= v *dev, int ret; =20 if (v->shadow_vqs_enabled) { + VirtQueue *vq =3D virtio_get_queue(dev->vdev, ring->index); + + /* + * 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 mig= ht + * have problems with these retransmissions. + */ + while (virtqueue_rewind(vq, 1)) { + continue; + } + ring->num =3D virtio_queue_get_last_avail_idx(dev->vdev, ring->ind= ex); return 0; } @@ -1326,4 +1337,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 Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544389; cv=none; d=zohomail.com; s=zohoarc; b=M1Uy8dzmVI8Gl5NKJhrwc6ecBmQ/g23T4fT7NxNNTkQzHNKO3CYxX9D0EwtRoip9lPKGwXv5zPICPgWFUEC/1sfNjnce0eqZ/fbNiahY2DBKOieXpSq39xX0yyY7mLwR0lNr90VPKnvi0V9L4DO4xziWRu9ZxgLxPNG4ne1Kj9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544389; 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=w+vbnLVHFE98xu6DQxprtLM0Tqst2JAJDVkWqUTLcr4=; b=HsfCl5kn+vndDY4hsL5x2RjNmycmNqUPwFmDzqnaeRd+Frb/fCjpUQuYdrPK7fXdraY7QC8BrViYdtfwXv0UX2lnKEcyc2LnJmNVo6xZj7JVngJi/1S3EiJ4PeveMMBjPCJdF5nNsoJwHx+w90zUMefmRxwU7KGRYBKJ79ysn+E= 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+importer2=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 SMTP id 1673544389105653.2666362275572; Thu, 12 Jan 2023 09:26:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1K6-0006d6-JS; Thu, 12 Jan 2023 12:25:07 -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 1pG1K4-0006cZ-91 for qemu-devel@nongnu.org; Thu, 12 Jan 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 1pG1K2-0008GL-Mv for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:04 -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-664-9mAnowN2OSinIJx8dmY-pQ-1; Thu, 12 Jan 2023 12:24:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EB48382C96F; Thu, 12 Jan 2023 17:24:57 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3ADC04078903; Thu, 12 Jan 2023 17:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544302; 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=w+vbnLVHFE98xu6DQxprtLM0Tqst2JAJDVkWqUTLcr4=; b=Gne680FICwLrelc3brA244sbGi6FpY7C/GrORAzIt/8GPovDmFrsDpMfL2ecRdckLF54oh DVs2e1TgMe1lSDa/YOIIvt/7nxF3lLCSNldI9LgNH6aIaiiZnr04akcFqcaE0Ymtvw2HeB rcq4UZMkFJw5ksO2jvwqUYJ5zef7emY= X-MC-Unique: 9mAnowN2OSinIJx8dmY-pQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 05/13] vdpa net: add migration blocker if cannot migrate cvq Date: Thu, 12 Jan 2023 18:24:26 +0100 Message-Id: <20230112172434.760850-6-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544390794100003 A vdpa net device must initialize with SVQ in order to be migratable, and initialization code verifies conditions. If the device is not initialized with the x-svq parameter, it will not expose _F_LOG so vhost sybsystem will block VM migration from its initialization. Next patches change this. Net data VQs will be shadowed only at migration time and vdpa net devices need to expose _F_LOG as long as it can go to SVQ. Since we don't know that at initialization time but at start, add an independent blocker at CVQ. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 631424d9c4..2ca93e850a 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -26,12 +26,14 @@ #include #include "standard-headers/linux/virtio_net.h" #include "monitor/monitor.h" +#include "migration/blocker.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; + Error *migration_blocker; VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ @@ -433,9 +435,15 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) g_strerror(errno), errno); return -1; } - if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) || - !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { - return 0; + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) { + error_setg(&s->migration_blocker, + "vdpa device %s does not support ASID", + nc->name); + goto out; + } + if (!vhost_vdpa_net_valid_svq_features(v->dev->features, + &s->migration_blocker)) { + goto out; } =20 /* @@ -455,7 +463,10 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) } =20 if (group =3D=3D cvq_group) { - return 0; + error_setg(&s->migration_blocker, + "vdpa %s vq %d group %"PRId64" is the same as cvq group " + "%"PRId64, nc->name, i, group, cvq_group); + goto out; } } =20 @@ -468,8 +479,15 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_ASID; =20 out: - if (!s->vhost_vdpa.shadow_vqs_enabled) { - return 0; + if (s->migration_blocker) { + Error *errp =3D NULL; + r =3D migrate_add_blocker(s->migration_blocker, &errp); + if (unlikely(r !=3D 0)) { + g_clear_pointer(&s->migration_blocker, error_free); + error_report_err(errp); + } + + return r; } =20 s0 =3D vhost_vdpa_net_first_nc_vdpa(s); @@ -513,6 +531,11 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->status); } =20 + if (s->migration_blocker) { + migrate_del_blocker(s->migration_blocker); + g_clear_pointer(&s->migration_blocker, error_free); + } + vhost_vdpa_net_client_stop(nc); } =20 --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544387; cv=none; d=zohomail.com; s=zohoarc; b=Gi6hASE9UGFVSCHnQftA1+r1zUGeBUv9prx0XE4B6Wc9xHdJwqNcVbk/+dMgMGBFo8TyUTMzYl1NkshxfFmsTanu9+Yl6kHHJQSmRsW0AtIv6Bf1CYIZrQIE9qI9H0GwCBzHLLZ5/3B4CmJpX+uGefVoRz8Fqd9nBcQew7KOh4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544387; 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=OPoj2lVJsWprqpmTaHUkjMZg3CvrA3oSBniXKgLWMks=; b=HsPiHW7PTStFlxRTQ6wz7TYh2py6kbL6YN10gLXPJRkHzlof4fMUJLcYvaf/Hr6Lr24ge1etbMD7cEYuT7KTIrWanlZYczBEdVKaxq0eeNrucAW8uGvYwgQ+iyM8Ht/HoEqT7JzZY0UdRok5NQrt6NymaqzmzIbAo0nhQMCwaXg= 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+importer2=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 1673544387423876.6773641925918; Thu, 12 Jan 2023 09:26:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1K9-0006e6-8L; Thu, 12 Jan 2023 12:25:09 -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 1pG1K7-0006dB-9E for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:07 -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 1pG1K5-0008RP-P9 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:07 -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-617-CJIBQHQXO_e4oCaU984VEA-1; Thu, 12 Jan 2023 12:25:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE74D85D067; Thu, 12 Jan 2023 17:25:00 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3DAC4078903; Thu, 12 Jan 2023 17:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544305; 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=OPoj2lVJsWprqpmTaHUkjMZg3CvrA3oSBniXKgLWMks=; b=FI9AIQmFq5zCQPY+7nk+bFc4Lm+j1VbCvf1/BogUVNNZ6CCO7gDadGdklEVxc4d9hneKtT wDfqDm57nZFWauz74iO7hA0aOfYxtmsRSRCXfNWkDuaWUhRLykrEBuu5meHVyjeVBEtHBh J2g7r0aLJgCIGONQTjkDYMpRKc7KX58= X-MC-Unique: CJIBQHQXO_e4oCaU984VEA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 06/13] vhost: delay set_vring_ready after DRIVER_OK Date: Thu, 12 Jan 2023 18:24:27 +0100 Message-Id: <20230112172434.760850-7-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544388754100001 To restore the device at the destination of a live migration we send the commands through control virtqueue. For a device to read CVQ it must have received the DRIVER_OK status bit. However this opens a window where the device could start receiving packets in rx queue 0 before it receives the RSS configuration. To avoid that, we will not send vring_enable until all configuration is used by the device. As a first step, run vhost_set_vring_ready for all vhost_net backend after all of them are started (with DRIVER_OK). This code should not affect vdpa. Signed-off-by: Eugenio P=C3=A9rez --- hw/net/vhost_net.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index c4eecc6f36..3900599465 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -399,6 +399,18 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, } else { peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } + r =3D vhost_net_start_one(get_vhost_net(peer), dev); + if (r < 0) { + goto err_start; + } + } + + for (int j =3D 0; j < nvhosts; j++) { + if (j < data_queue_pairs) { + peer =3D qemu_get_peer(ncs, j); + } else { + peer =3D qemu_get_peer(ncs, n->max_queue_pairs); + } =20 if (peer->vring_enable) { /* restore vring enable state */ @@ -408,11 +420,6 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, goto err_start; } } - - r =3D vhost_net_start_one(get_vhost_net(peer), dev); - if (r < 0) { - goto err_start; - } } =20 return 0; --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544524; cv=none; d=zohomail.com; s=zohoarc; b=TAllMc7EIIkgnYbRCKgrxMP72reAAcvab4Oi+wX3OVLmcX+9DEex55Hr0/TcJjWcN+fiwZhXenudW1FdxOjGxHKiBrpuLQGjAa0aeUoifAkLpJk0I5stuiDFfTjhp6HLW0Z+uoBleCw0cWYKhcoYTw8OXkhkO6VecyZUuaNM3mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544524; 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=LiaTOpqMF28Kc4TLRxud3gd9roZpZlxsAr/zuMH5FLE=; b=VGbBZG7vN+cehQCFe5qtYemUZzP04KCRlgULIomKGspBcrw7MNSTESo4n0MHwyxkArcRGmIHhf8lEWhgbnyArsFFHDddKQLMCTwoEnddGN67khyO8AxY0m6Upm8baY5ApqUb0871qZHscI9h925PDMgTkdMKaP6rbwLqU3yQMVY= 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+importer2=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 SMTP id 1673544524866157.45151638792015; Thu, 12 Jan 2023 09:28:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KC-0006j7-57; Thu, 12 Jan 2023 12:25:12 -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 1pG1KA-0006gP-UJ for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:11 -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 1pG1K9-0008S1-AK for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:10 -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-389-V_glhRUbPdWCY5Odgu_x6g-1; Thu, 12 Jan 2023 12:25:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76A8785A588; Thu, 12 Jan 2023 17:25:04 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EA474078903; Thu, 12 Jan 2023 17:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544308; 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=LiaTOpqMF28Kc4TLRxud3gd9roZpZlxsAr/zuMH5FLE=; b=E96EQpe6TfEtoFZJ+5YhNlic4+mX1vOosiFcuTO6JQY9z7jygA+/U7jxFjfcUL8EO6HwuT kswfukFeLZ6rgwHuD5qJ/g2V3wg6QLHGBxCIAwVmXqyg26sU2s8frmk1ldXzbkE4IpvpBQ 11pEVLCwOvFMeQgSWfLARDoTSFlblx0= X-MC-Unique: V_glhRUbPdWCY5Odgu_x6g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 07/13] vdpa: delay set_vring_ready after DRIVER_OK Date: Thu, 12 Jan 2023 18:24:28 +0100 Message-Id: <20230112172434.760850-8-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544525632100001 To restore the device at the destination of a live migration we send the commands through control virtqueue. For a device to read CVQ it must have received the DRIVER_OK status bit. However this opens a window where the device could start receiving packets in rx queue 0 before it receives the RSS configuration. To avoid that, we will not send vring_enable until all configuration is used by the device. Delegating the sending of VHOST_VDPA_SET_VRING_ENABLE to the vhost_set_vring_ready VhostOp. Signed-off-by: Eugenio P=C3=A9rez --- hw/net/vhost_net.c | 8 ++++++-- hw/virtio/vhost-vdpa.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 3900599465..87938b4449 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -406,15 +406,19 @@ int vhost_net_start(VirtIODevice *dev, NetClientState= *ncs, } =20 for (int j =3D 0; j < nvhosts; j++) { + int enable; + if (j < data_queue_pairs) { peer =3D qemu_get_peer(ncs, j); } else { peer =3D qemu_get_peer(ncs, n->max_queue_pairs); } =20 - if (peer->vring_enable) { + enable =3D net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA= || + peer->vring_enable; + if (enable) { /* restore vring enable state */ - r =3D vhost_set_vring_enable(peer, peer->vring_enable); + r =3D vhost_set_vring_enable(peer, enable); =20 if (r < 0) { goto err_start; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 28a52ddc78..4296427a69 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -722,9 +722,13 @@ static int vhost_vdpa_get_vq_index(struct vhost_dev *d= ev, int idx) return idx; } =20 -static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev) +static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev, int ready) { int i; + + if (unlikely(!ready)) { + return -ENOTSUP; + } trace_vhost_vdpa_set_vring_ready(dev); for (i =3D 0; i < dev->nvqs; ++i) { struct vhost_vring_state state =3D { @@ -1119,7 +1123,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) if (unlikely(!ok)) { return -1; } - vhost_vdpa_set_vring_ready(dev); } else { vhost_vdpa_svqs_stop(dev); vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); @@ -1324,6 +1327,7 @@ const VhostOps vdpa_ops =3D { .vhost_set_features =3D vhost_vdpa_set_features, .vhost_reset_device =3D vhost_vdpa_reset_device, .vhost_get_vq_index =3D vhost_vdpa_get_vq_index, + .vhost_set_vring_enable =3D vhost_vdpa_set_vring_ready, .vhost_get_config =3D vhost_vdpa_get_config, .vhost_set_config =3D vhost_vdpa_set_config, .vhost_requires_shm_log =3D NULL, --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544367; cv=none; d=zohomail.com; s=zohoarc; b=m2HJQj3VuLUNNhhkBawncf75/JDJfZFwhcaybdLhoAsxGduICv4B9PkwbQgfnnk0I8fYMm6yJpFlmYN3QOO7zemUxo5wORE/0iw2xz0iWpCqFF9FTRnUOhOemkyApsNfiZjrRScN/BEU3EWOD3mzQYYfOV5b6pbssDNAQWdj1eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544367; 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=xEQcdFPrEC4oVjvdoYYSoSNd7lJaDG6LYVIDvCsNd+4=; b=U+IKlJ8VzB5YvF6ZfLSPDDoPqUEUXORWJmWgjtOWBysV6Wy+z9F85zs2528CDKyM8x4XzBbKtKrYc79VGbG4B20w1VmX3S5LWHtAAG1MMFLh8vf9jkOaYfp/c4P+KKAh88HycaoqtdAM6DnC4Ptg5LcNvVku2CtUDTDnS6Rf4Ac= 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+importer2=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 SMTP id 1673544367284579.4738718999241; Thu, 12 Jan 2023 09:26:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KH-0006t6-MD; Thu, 12 Jan 2023 12:25:17 -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 1pG1KG-0006s4-C6 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:16 -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 1pG1KE-0008SU-Kh for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:15 -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-221-g8IqAqb5NRq_qvFUr3I9bg-1; Thu, 12 Jan 2023 12:25:08 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA7F7857A85; Thu, 12 Jan 2023 17:25:07 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAF844078904; Thu, 12 Jan 2023 17:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544313; 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=xEQcdFPrEC4oVjvdoYYSoSNd7lJaDG6LYVIDvCsNd+4=; b=CbWyltW0SOwA+LdgE7NtjSLtSkHwdzumCV9ufqXId/3gnPdyB8ctm4h3lmz1bCcl1O/N8u 2bdgUNFDycHaA01NifTG/EPd3CmUY2jz7ZNvFK0OQu/fMDgLJOyRV9hU1bJ7JWzR5GXGZT 2EBRVIetS7hTPcG1zIWC1269oaMwQ4A= X-MC-Unique: g8IqAqb5NRq_qvFUr3I9bg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 08/13] vdpa: Negotiate _F_SUSPEND feature Date: Thu, 12 Jan 2023 18:24:29 +0100 Message-Id: <20230112172434.760850-9-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544368512100001 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 --- 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 4296427a69..a61a6b2a74 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 Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673545409; cv=none; d=zohomail.com; s=zohoarc; b=FnlkrkaCLb49SZ+2kuyDwJ3YFj8IoF/YtJwtsDo97r4dUXknv/0VnUmzNJM9DWZteZpoIEc+TRLOA+qIcfKMJ5ynEz6xsotiVx0zDVp6NIDhvf4rvqSIx9P89c2wxNZi36FyB4/6GYewD1LnS5hqQUMqthW4+QZ2eFnB9urNU5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673545409; 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=bmItYCfF8FtD42XV6m/zdJug8lLQieOGAxYYZ+c59hM=; b=K8Y6FQotd8Orl8HGVJ1Jx3ZPisgjh+DHGfwvuLL21jw0zeXu4seQwBs+WjtcyJYsJTjDdrSN61Ujw1XOaY0V37LZ8zYVMDine7JRGJGxFt83/uvLwAj1rLXuF9zplW6sQm41uWvDZqqLvBhiBar10zKFOZ1KiQIxUZC+2dj82n0= 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+importer2=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 167354540949179.010903500788; Thu, 12 Jan 2023 09:43:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KK-0006wN-Rj; Thu, 12 Jan 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 1pG1KI-0006tg-Sp for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:18 -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 1pG1KH-0008Sr-Dh for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:18 -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-197--uEY-YQxNACEgq3tHOgudw-1; Thu, 12 Jan 2023 12:25:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49C1118E092A; Thu, 12 Jan 2023 17:25:11 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B4274078903; Thu, 12 Jan 2023 17:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544316; 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=bmItYCfF8FtD42XV6m/zdJug8lLQieOGAxYYZ+c59hM=; b=WPO79/4VN2WOks9Zx3yvsrcEZZgUJ+O5AxyV4DUVEtfxyRW0jG6doRS7nH02F48kcrSXkS HFyMdQI/fYSQ7JsXGYajNbJp+lar95DVNpbuzljIylLsCWvy3aLEjmGE7AbPd4FIU7srva QHBLckz29P8DQLZZIVyHOuU39uGeFfQ= X-MC-Unique: -uEY-YQxNACEgq3tHOgudw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 09/13] vdpa: add feature_log parameter to vhost_vdpa Date: Thu, 12 Jan 2023 18:24:30 +0100 Message-Id: <20230112172434.760850-10-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673545411215100003 This way the device's vhost_vdpa can make the choice about exposing or not the _F_LOG feature. At the moment it is always false. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 7997f09a8d..7bcbcdb1dd 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -39,6 +39,7 @@ typedef struct vhost_vdpa { MemoryListener listener; struct vhost_vdpa_iova_range iova_range; uint64_t acked_features; + bool feature_log; bool shadow_vqs_enabled; /* Vdpa must send shadow addresses as IOTLB key for data queues, not G= PA */ bool shadow_data; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index a61a6b2a74..40b7e8706a 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1273,7 +1273,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *= dev, 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 && (v->shadow_vqs_enabled || v->feature_log)) { /* Add SVQ logging capabilities */ *features |=3D BIT_ULL(VHOST_F_LOG_ALL); } --=20 2.31.1 From nobody Sat May 4 11:07:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673545193; cv=none; d=zohomail.com; s=zohoarc; b=DzbcJolo6CkLDRjEK5S4xwFp6KtcW2fwd0Z+njP2/BHjhPT0ERp6OmcNNJF4fL+KRHTACFkTn1YuXWnYvwvfQu8GwjNweRWXOALWig9GsltGMZ2jSn9z9u14u8NMtoVkEcl4oH6y0BxGSg8GlzOFdypmCKBy245J+9DtaJDnmHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673545193; 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=EV/ttNYIcmAzEJ7Upvz/hcgtDxs25Vtm8T4TuWAhNKc=; b=X13DzVTAzmAQCaVIEBOaisjSzt77nNKKS4TtlttWuqNp4cStEdBXRTjtKv1gXLv93/Kx0D+ODz5MMGV4zEzHnyG0Oz4JDTYuy9KMkyZSe4jl9zXPebddT12v5ZvSsTDjpMgB4rujlqMed1kf+WkOANKg7JNipv2yQKYL0945wbE= 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+importer2=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 SMTP id 1673545193234851.7254114792534; Thu, 12 Jan 2023 09:39:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KM-00070k-Nu; Thu, 12 Jan 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 1pG1KK-0006wP-W8 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:21 -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 1pG1KJ-0008Uv-LO for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:20 -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-251-sbQKv7B8NzGaCw3Eaa8lvg-1; Thu, 12 Jan 2023 12:25:15 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B357B2999B35; Thu, 12 Jan 2023 17:25:14 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EE274078903; Thu, 12 Jan 2023 17:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544319; 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=EV/ttNYIcmAzEJ7Upvz/hcgtDxs25Vtm8T4TuWAhNKc=; b=jCUfE/GSGlc5x1u41W41w+3zhAWFMtS29tjdpHxVAq2oNMa6TQ4DYFvPo5pt1qkUkxK17X p+thkvnjZ6tqpxLQSZgvymvT0v2CMqkP3g6gtlSnwvz64noAURvzI6oLfdwM1ZV5mF3bv/ PMbHc6BBVkfqbvINt0ZQrVVpHLhZo1w= X-MC-Unique: sbQKv7B8NzGaCw3Eaa8lvg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 10/13] vdpa net: allow VHOST_F_LOG_ALL Date: Thu, 12 Jan 2023 18:24:31 +0100 Message-Id: <20230112172434.760850-11-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673545195172100001 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 --- net/vhost-vdpa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 2ca93e850a..5d7ad6e4d7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -100,6 +100,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 Sat May 4 11:07:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673545091; cv=none; d=zohomail.com; s=zohoarc; b=QixrEo4qWnUGXdfAGo5PnqYV+G3+7BBG6X0M2z6YScvhBqh976MkJYGLm8Evh6gAVccG6wfGFf659mOAb/fykbGDUp3a5avZ7OHBUYqDMybMBTPjSbh75NxQtO/Tzj24TuWpkmON5AZUCdG2Ew66XJ8EYSGV/L9SlhUhoki5Xv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673545091; 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=/o+Q7rasy1fqv7eDwj8XY+QEs1GE3kULQsMVaKGwbYk=; b=GpOfXMt4d8pWvlrjkgeBh1EdmixFQ00ZrhgKhneiDWH+cTN0KNbn5KHXeVOMYflI5MVrpVed8g98OXBZkKm8WmUaCFkM8IIFUCq5FWlgfDGBKc9wVZ2rofq13g8JqqM3TgsJAs91N9UBa5M6UidIMC18WSUd1jf8WLRh7invyVY= 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+importer2=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 SMTP id 1673545091608546.6876095303643; Thu, 12 Jan 2023 09:38:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KR-0007Gy-Bw; Thu, 12 Jan 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 1pG1KQ-0007ES-DQ for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:26 -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 1pG1KO-0008V7-PW for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:26 -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-602-UG5Kv0t0M3eM16-veu3YAA-1; Thu, 12 Jan 2023 12:25:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30D10802D2A; Thu, 12 Jan 2023 17:25:18 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05AF74078903; Thu, 12 Jan 2023 17:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544324; 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=/o+Q7rasy1fqv7eDwj8XY+QEs1GE3kULQsMVaKGwbYk=; b=dS/KUpb6SbYxzBe9U4y6UKLUmLv8sGoFzZcoXXuyAaj0krfqos8ZiTfei8wdbdSFLR8717 JQRFW6zlo40/abDAZ1uNS3SRu+qCSeHHqrhG2RCma0gbMZFzRBCPA57/PHmV7LnmXGegTn 9eQN3vykI0z8IQNbZaNbK6V59HQriRE= X-MC-Unique: UG5Kv0t0M3eM16-veu3YAA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 11/13] vdpa: add vdpa net migration state notifier Date: Thu, 12 Jan 2023 18:24:32 +0100 Message-Id: <20230112172434.760850-12-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673545092677100001 This allows net to restart the device backend to configure SVQ on it. Ideally, these changes should not be net specific. 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). 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. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5d7ad6e4d7..f38532b1df 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -26,6 +26,8 @@ #include #include "standard-headers/linux/virtio_net.h" #include "monitor/monitor.h" +#include "migration/migration.h" +#include "migration/misc.h" #include "migration/blocker.h" #include "hw/virtio/vhost.h" =20 @@ -33,6 +35,7 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; + Notifier migration_state; Error *migration_blocker; VHostNetState *vhost_net; =20 @@ -243,10 +246,86 @@ 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; + NetClientState *peer; + + /* 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; + } + + if (enable) { + ioctl(v->device_fd, VHOST_VDPA_SUSPEND); + } + 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; + vhost_net_stop(vdev, n->nic->ncs, data_queue_pairs, cvq); + + peer =3D s->nc.peer; + for (int i =3D 0; i < data_queue_pairs + cvq; i++) { + VhostVDPAState *vdpa_state; + NetClientState *nc; + + if (i < data_queue_pairs) { + nc =3D qemu_get_peer(peer, i); + } else { + nc =3D qemu_get_peer(peer, n->max_queue_pairs); + } + + vdpa_state =3D DO_UPCAST(VhostVDPAState, nc, nc); + vdpa_state->vhost_vdpa.shadow_data =3D enable; + + if (i < data_queue_pairs) { + /* Do not override CVQ shadow_vqs_enabled */ + vdpa_state->vhost_vdpa.shadow_vqs_enabled =3D enable; + } + } + + 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); + + switch (migration->state) { + case MIGRATION_STATUS_SETUP: + vhost_vdpa_net_log_global_enable(s, true); + return; + + case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_CANCELLED: + case MIGRATION_STATUS_FAILED: + vhost_vdpa_net_log_global_enable(s, false); + return; + }; +} + static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) { struct vhost_vdpa *v =3D &s->vhost_vdpa; =20 + if (v->feature_log) { + 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); @@ -280,6 +359,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 && s->vhost_vdpa.feature_log) { + 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); @@ -767,6 +850,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 Sat May 4 11:07:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544487; cv=none; d=zohomail.com; s=zohoarc; b=GWlBOfclzK7NK2y86Ow3ucle2Q807fDqjLIiEFqJZEpYwb9vMcauKoygL5lairLX54FlWf2YnBA3D8zSCcVZAk8b6WVwS53EsUTrExmrHiqA8EpqsZ0f8wDZI3sZEB3a4gtZW8T+sUDvdqSIhhbcLSvX/G27XSI77AMnwPyikL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544487; 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=lTtatn89Waf5av3fH7wUp46vSF647elQrXj1zIupcQU=; b=BTPXpvK1gjXqF596RowHGPcMXbQHKQu76MUtbOHBTYGgq0bZllj6UzF6vx4ZQ+QrXku+TG+nY4L1IHTGJaocHXBOhCKTCEfZtHBNYzvmLeX2KB8UxNyxkZiG82rDCAuq5MGT39/NEvk046ZcpXHzEdmj7wquKrdeawxNwYnrjjo= 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+importer2=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 SMTP id 1673544487022342.66811022093304; Thu, 12 Jan 2023 09:28:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KV-0007Ha-Ud; Thu, 12 Jan 2023 12:25:31 -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 1pG1KT-0007HK-Up for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:29 -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 1pG1KR-0008VS-47 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:29 -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-620-sqwm21ebMr6Tiq-5YITsdQ-1; Thu, 12 Jan 2023 12:25:22 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 963F33C42204; Thu, 12 Jan 2023 17:25:21 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7654C4078906; Thu, 12 Jan 2023 17:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544326; 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=lTtatn89Waf5av3fH7wUp46vSF647elQrXj1zIupcQU=; b=QouXaXj2VDPrGpu3WyBP2mYyuV6ZQqUsIMqVezXLs2Crty0bATDycph3Z3ciH3VR8xRgXq uviIqIlwmCX0D9HeHmO2ZxzppeXhefHjh+dPMJfmH+zHd1pYoJEQNDp57Rsm3uHgTn5wXG WJJFkXrqwYl272w4/YP6pghO1YYmXDE= X-MC-Unique: sqwm21ebMr6Tiq-5YITsdQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 12/13] vdpa: preemptive kick at enable Date: Thu, 12 Jan 2023 18:24:33 +0100 Message-Id: <20230112172434.760850-13-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544488445100001 Spuriously kick the destination device's queue so it knows in case there are new descriptors. RFC: This is somehow a gray area. The guest may have placed descriptors in a virtqueue but not kicked it, so it might be surprised if the device starts processing it. However, that information is not in the migration stream and it should be an edge case anyhow, being resilient to parallel notifications from the guest. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 40b7e8706a..dff94355dd 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -732,11 +732,16 @@ static int vhost_vdpa_set_vring_ready(struct vhost_de= v *dev, int ready) } trace_vhost_vdpa_set_vring_ready(dev); for (i =3D 0; i < dev->nvqs; ++i) { + VirtQueue *vq; struct vhost_vring_state state =3D { .index =3D dev->vq_index + i, .num =3D 1, }; vhost_vdpa_call(dev, VHOST_VDPA_SET_VRING_ENABLE, &state); + + /* Preemptive kick */ + vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); + event_notifier_set(virtio_queue_get_host_notifier(vq)); } return 0; } --=20 2.31.1 From nobody Sat May 4 11:07:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673544536; cv=none; d=zohomail.com; s=zohoarc; b=A+yWDFJtPlSqr1wNaOW7+elX2MHoAltj00uTKt3jdO8x9gWq7pgo9UekemY4Up593yGZ2ckAu6e+hgtJC42aaSCj9P1uqV8+jw4jQ64Kc0YKB8bPbBRH58YuQ2FsFjFmqMZ8s7zt6RNeeE8o9N7aMCYy1pUxL8DBzo1q+aBzi9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673544536; 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=CklSSM2yoSQ5DuSf0oh87A7pvDhsywraUVO8LLe4E1Q=; b=Y1Du9CXZg8b9TjEJ6TDH2vkspTaCvAFwQypHfgrE930tAQMAIbee9bu9f2qHr5g/js2nCsAPSotwFU+HDgwV4v9+gPFf6GL2FCNGHH2ICHADZcdS83SSxCjn2V5bSILfLw7kg5slzsO4CJpEGlg5DlhvPNJePjiM6WNeHx12fIw= 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+importer2=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 1673544536327588.7537057461174; Thu, 12 Jan 2023 09:28:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pG1KZ-0007IQ-V3; Thu, 12 Jan 2023 12:25:35 -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 1pG1KY-0007I8-6s for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:34 -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 1pG1KW-00005Q-JF for qemu-devel@nongnu.org; Thu, 12 Jan 2023 12:25:33 -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-176-4_3ccBsZM3yANWtqT1W7lg-1; Thu, 12 Jan 2023 12:25:26 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C4FE1C29D46; Thu, 12 Jan 2023 17:25:25 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC27F4078903; Thu, 12 Jan 2023 17:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673544331; 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=CklSSM2yoSQ5DuSf0oh87A7pvDhsywraUVO8LLe4E1Q=; b=J2syqdWnnUc6Gs31CK/au9ivbLZfNn+Es0etfzutm9FdSQQPTM+JlgvuEkHbNa/N5rJ7vr 62gol5NzCNtP9+6IIwLYy3BcmffAFEHnMcbUwbo20Bn5N+C8Y6X3mkW7kvFs0bpMddGVzB U6FNg1OtXDenn1DOxI5REuQ+2iuP8qM= X-MC-Unique: 4_3ccBsZM3yANWtqT1W7lg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: si-wei.liu@oracle.com, Liuxiangdong , Zhu Lingshan , "Gonglei (Arei)" , alvaro.karsz@solid-run.com, Shannon Nelson , Laurent Vivier , Harpreet Singh Anand , Gautam Dawar , Stefano Garzarella , Cornelia Huck , Cindy Lu , Eli Cohen , Paolo Bonzini , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Parav Pandit Subject: [RFC v2 13/13] vdpa: Conditionally expose _F_LOG in vhost_net devices Date: Thu, 12 Jan 2023 18:24:34 +0100 Message-Id: <20230112172434.760850-14-eperezma@redhat.com> In-Reply-To: <20230112172434.760850-1-eperezma@redhat.com> References: <20230112172434.760850-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.2 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673544537802100003 Vhost-vdpa networking devices need to meet a few conditions to be migratable. If SVQ is not enabled from the beginning, to suspend the device to retrieve the vq state is the first requirement. Expose _F_LOG only in that case. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index f38532b1df..9cf931010b 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -831,6 +831,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, int nvqs, bool is_datapath, bool svq, + bool feature_log, struct vhost_vdpa_iova_range iova_r= ange) { NetClientState *nc =3D NULL; @@ -854,6 +855,7 @@ 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.feature_log =3D feature_log; if (!is_datapath) { s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_le= n()); @@ -920,12 +922,13 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; - uint64_t features; + uint64_t features, backend_features; int vdpa_device_fd; g_autofree NetClientState **ncs =3D NULL; struct vhost_vdpa_iova_range iova_range; NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; + bool feature_log; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -955,6 +958,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, } } =20 + r =3D ioctl(vdpa_device_fd, VHOST_GET_BACKEND_FEATURES, &backend_featu= res); + if (unlikely(r < 0)) { + error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); + goto err; + } + r =3D vhost_vdpa_get_features(vdpa_device_fd, &features, errp); if (unlikely(r < 0)) { goto err; @@ -980,10 +989,17 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, =20 ncs =3D g_malloc0(sizeof(*ncs) * queue_pairs); =20 + /* + * Offer VHOST_F_LOG_ALL as long as the device met basic requisites, a= nd + * let more complicated ones to vhost_vdpa_net_{cvq,data}_start. + */ + feature_log =3D opts->x_svq || + ((backend_features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && + vhost_vdpa_net_valid_svq_features(features, NULL)); 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); + feature_log, iova_range); if (!ncs[i]) goto err; } @@ -991,7 +1007,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *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, feature_log, iova_range); if (!nc) goto err; } --=20 2.31.1