From patchwork Wed Aug 10 18:42:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A563C25B07 for ; Wed, 10 Aug 2022 18:53:58 +0000 (UTC) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqq5-0002MB-9d for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:53:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfE-00027c-SS for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006h5-6Q for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8z3qhSzG4xe38qyIY4qics2r2QDCs0AchsGOJ8UEk8=; b=gJ7Jh5x+CxlwhH44fGwIhhkTpMwhqBS8v/0FXpEu26DO25ZIBpcRai5O7ELPbqHk+tTmnD Ee26DTzVPJ0Xw97bcAgxKXLD/xTDcjfl5EXLf/2Oiu2k1Qowd90ysZ+jk2HcbyaSuDEI8V dLZCNOhFmR5h3y5d8oUgVs4Zs3QO3B0= 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-256-3kDloFI2NymFQY74KhmyfQ-1; Wed, 10 Aug 2022 14:42:29 -0400 X-MC-Unique: 3kDloFI2NymFQY74KhmyfQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E1193C10237; Wed, 10 Aug 2022 18:42:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA831C15BA3; Wed, 10 Aug 2022 18:42:25 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 1/8] [NOTMERGE] Update linux headers Date: Wed, 10 Aug 2022 20:42:13 +0200 Message-Id: <20220810184220.2362292-2-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add _F_SUSPEND and suspend ioctl. TODO: This is still not merged in Linux upstream, so it may change. --- include/standard-headers/linux/vhost_types.h | 3 +++ linux-headers/linux/vhost.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/standard-headers/linux/vhost_types.h b/include/standard-headers/linux/vhost_types.h index ce78551b0f..c93ed1b920 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -161,5 +161,8 @@ struct vhost_vdpa_iova_range { * message */ #define VHOST_BACKEND_F_IOTLB_ASID 0x3 +/* Stop device from processing virtqueue buffers */ +#define VHOST_BACKEND_F_SUSPEND 0x4 + #endif diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index cab645d4a6..f3f5bea3cb 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -171,4 +171,7 @@ #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ struct vhost_vring_state) +/* Stop or resume a device so it does not process virtqueue requests anymore */ +#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) + #endif From patchwork Wed Aug 10 18:42:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD448C19F2A for ; Wed, 10 Aug 2022 18:46:45 +0000 (UTC) Received: from localhost ([::1]:49232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqj6-0004q7-N5 for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfF-00028v-EG for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006h9-G3 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156954; 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=GVnZ2eKVmApuP3yb5NRmJJpEHJ0ByEkMjNlf+83PBe4=; b=BqvoDfe/24qBefcCzmQGbRPcxXGTPG+jBASrFapC6LlIcJLWdzVKNNTujTh8RpUma89Pyq nAu4tNgpfUUW6U6GFTEiMalJNEFYMsp5Dt6ORBSxWUyjKKe+rHtei1T4dIRqT+36v9rvxe eHfZwVhL7AWKbWdmV52RuaOlblc1yqM= 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-228-UZG9jtC1PJi8mjVY-bAVRg-1; Wed, 10 Aug 2022 14:42:31 -0400 X-MC-Unique: UZG9jtC1PJi8mjVY-bAVRg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 437E7804196; Wed, 10 Aug 2022 18:42:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6DD7C15BA3; Wed, 10 Aug 2022 18:42:28 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 2/8] vdpa: Extract get_backend_features from vhost_vdpa_get_as_num Date: Wed, 10 Aug 2022 20:42:14 +0200 Message-Id: <20220810184220.2362292-3-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The series reuses it to check for SUSPEND feature bit. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 11241ebac4..85b10799bd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -602,9 +602,17 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = { .avail_handler = vhost_vdpa_net_handle_ctrl_avail, }; -static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd) +static uint64_t vhost_vdpa_get_backend_features(int fd) { uint64_t features; + + /* No need to treat the error, only to know there is one */ + int ret = ioctl(fd, VHOST_GET_BACKEND_FEATURES, &features); + return ret < 0 ? 0 : features; +} + +static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd, uint64_t features) +{ unsigned num_as; int r; @@ -733,7 +741,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; - uint64_t features; + uint64_t features, backend_features; int vdpa_device_fd; g_autofree NetClientState **ncs = NULL; g_autoptr(VhostIOVATree) iova_tree = NULL; @@ -765,9 +773,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, goto err; } + backend_features = vhost_vdpa_get_backend_features(vdpa_device_fd); svq_cvq = opts->x_svq; if (has_cvq && !opts->x_svq) { - num_as = vhost_vdpa_get_as_num(vdpa_device_fd); + num_as = vhost_vdpa_get_as_num(vdpa_device_fd, backend_features); svq_cvq = num_as > 1; } From patchwork Wed Aug 10 18:42:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BEECC00140 for ; Wed, 10 Aug 2022 18:53:58 +0000 (UTC) Received: from localhost ([::1]:57566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqq4-0002PY-PS for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:53:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028u-FM for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006hD-6c for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156956; 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=kTgbAuKIFtbiTbct78PH3a5nyxF/B2YC+cxL9w/h+/A=; b=a5d2jHuhAjq6UNSgjwcjWn9vFW7BsMwt5vS7XuLkgdZ4w8ZIZBDN7jcmUuM28s6/nurUS5 2XmD9ejRphkN460/rUTW52utnFhWAZ7/aCvRz/sXHWvLEvlKrCDHSnCujNkPdIJHaODtz4 nBRV7c4b0Yd7i1lIbv09335l/ZEH/7c= 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-674-1R6qhDMSNDmCdJcEso_lzA-1; Wed, 10 Aug 2022 14:42:34 -0400 X-MC-Unique: 1R6qhDMSNDmCdJcEso_lzA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2674D29DD99A; Wed, 10 Aug 2022 18:42:34 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84C56C15BA3; Wed, 10 Aug 2022 18:42:31 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 3/8] vhost: expose memory listener priority Date: Wed, 10 Aug 2022 20:42:15 +0200 Message-Id: <20220810184220.2362292-4-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We need to perform changes to vhost_vdpa devices before the memory listener inform them about the migration. Otherwise, it will reach them with no SVQ enabled and it cannot be guaranteed that it will be enabled afterwards. Expose the vhost memory listener priority so we can assign a lower one to net/vhost-vdpa one. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost.h | 2 ++ hw/virtio/vhost.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..ccd6cc5549 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -104,6 +104,8 @@ struct vhost_dev { const VhostDevConfigOps *config_ops; }; +#define VHOST_DEV_MEMORY_LISTENER_PRIORITY 10 + extern const VhostOps kernel_ops; extern const VhostOps user_ops; extern const VhostOps vdpa_ops; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..a1e822b871 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1411,7 +1411,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, - .priority = 10 + .priority = VHOST_DEV_MEMORY_LISTENER_PRIORITY }; hdev->iommu_listener = (MemoryListener) { From patchwork Wed Aug 10 18:42:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60640C00140 for ; Wed, 10 Aug 2022 18:46:43 +0000 (UTC) Received: from localhost ([::1]:49226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqj4-0004px-3O for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028w-Gi for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfC-0006iZ-1K for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156961; 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=JIy294Nk8MMn2A5k68elxAY+jDuXdJrJI/yT3QsTNOo=; b=S8w6MCj0IIaGRJI3drYS2NwRdkvx4uBIOAhsPqot0ZZETD25vnwkKKT4UmQUU9Lnm2zkta sR6LH9PrEEHBlJhN9cyb+vYH3E84IQvc9Z2RokrTFpidcZUbx8qoBP0pXZIyVZz87dBce0 9T+EEtyz+8ArcpvZk5bTKQBlErZbUJg= 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-616-j1rJP7exM_uCUuxEyiNgfA-1; Wed, 10 Aug 2022 14:42:37 -0400 X-MC-Unique: j1rJP7exM_uCUuxEyiNgfA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFD253800C34; Wed, 10 Aug 2022 18:42:36 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 690B0C15BA3; Wed, 10 Aug 2022 18:42:34 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 4/8] vdpa: Add log_enabled to VhostVDPAState Date: Wed, 10 Aug 2022 20:42:16 +0200 Message-Id: <20220810184220.2362292-5-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This enables VhostVDPAState to track the logging of the memory. It cannot be merged with s->always_svq because always_svq is immutable from the moment the device is parsed, and log_enabled must be enabled or disabled depending on the log state. Apart from that, they will affect the same to vhost vdpa device, enabling the shadow virtqueue unconditionally. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85b10799bd..a035c89c34 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -42,6 +42,10 @@ typedef struct VhostVDPAState { /* The device always have SVQ enabled */ bool always_svq; + + /* Device log enabled */ + bool log_enabled; + bool started; } VhostVDPAState; @@ -346,15 +350,15 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) cvq_group.index = v->dev->vq_index_end - 1; /* Default values */ - v->listener_shadow_vq = s->always_svq; - v->shadow_vqs_enabled = s->always_svq; + v->listener_shadow_vq = s->always_svq || s->log_enabled; + v->shadow_vqs_enabled = s->always_svq || s->log_enabled; s->vhost_vdpa.address_space_id = VHOST_VDPA_NET_CVQ_PASSTHROUGH; if (s->address_space_num < 2) { return 0; } - if (s->always_svq) { + if (s->always_svq || s->log_enabled) { goto out; } From patchwork Wed Aug 10 18:42:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6037EC25B0C for ; Wed, 10 Aug 2022 18:46:44 +0000 (UTC) Received: from localhost ([::1]:49204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqj4-0004or-3z for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028x-NO for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfF-0006kT-6C for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156964; 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=sdWfPImGYnxmxXNlua6fqa5IUyRe5dPjNA7afa0LHj0=; b=DWmnwvVKcyp45g8KloH5C7MpZojfWEC7/yHaZe4uVHxw1nj5XRhXO1e6oRSii9821E55YL mxtkGkYNx7FYvbgmETJD7OTx1D0O+xf31XWbFEmG8Oa/04khDcaOgxzjFIoNFbz7NiGQdw ag92OY/XYOb1WkSIDfH5dcHJq1vTU9w= 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-401-Rtw7x0VwPtOmWZbn4LnDyA-1; Wed, 10 Aug 2022 14:42:40 -0400 X-MC-Unique: Rtw7x0VwPtOmWZbn4LnDyA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEFC385A58F; Wed, 10 Aug 2022 18:42:39 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4021BC15BA3; Wed, 10 Aug 2022 18:42:37 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 5/8] vdpa: Add vdpa memory listener Date: Wed, 10 Aug 2022 20:42:17 +0200 Message-Id: <20220810184220.2362292-6-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This enable net/vdpa to restart the full device when a migration is started or stopped. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a035c89c34..4c6947feb8 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -21,6 +21,7 @@ #include "qemu/memalign.h" #include "qemu/option.h" #include "qapi/error.h" +#include "exec/address-spaces.h" #include #include #include @@ -32,6 +33,8 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; + MemoryListener memory_listener; + VHostNetState *vhost_net; /* Control commands shadow buffers */ @@ -110,6 +113,16 @@ static const uint64_t vdpa_svq_device_features = #define VHOST_VDPA_NET_CVQ_PASSTHROUGH 0 #define VHOST_VDPA_NET_CVQ_ASID 1 +/* + * Vdpa memory listener must run before vhost one, so vhost_vdpa does not get + * _F_LOG_ALL without SVQ. + */ +#define VHOST_VDPA_NET_MEMORY_LISTENER_PRIORITY \ + (VHOST_DEV_MEMORY_LISTENER_PRIORITY - 1) +/* Check for underflow */ +QEMU_BUILD_BUG_ON(VHOST_DEV_MEMORY_LISTENER_PRIORITY < + VHOST_VDPA_NET_MEMORY_LISTENER_PRIORITY); + VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -172,6 +185,9 @@ static void vhost_vdpa_cleanup(NetClientState *nc) qemu_vfree(s->cvq_cmd_out_buffer); qemu_vfree(s->cvq_cmd_in_buffer); + if (dev->vq_index == 0) { + memory_listener_unregister(&s->memory_listener); + } if (dev->vq_index + dev->nvqs == dev->vq_index_end) { g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); } @@ -224,6 +240,69 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc, const uint8_t *buf, return 0; } +static void vhost_vdpa_net_log_global_enable(MemoryListener *listener, + bool enable) +{ + VhostVDPAState *s = container_of(listener, VhostVDPAState, + memory_listener); + struct vhost_vdpa *v = &s->vhost_vdpa; + VirtIONet *n; + VirtIODevice *vdev; + int data_queue_pairs, cvq, r; + NetClientState *peer; + + if (s->always_svq || s->log_enabled == enable) { + return; + } + + s->log_enabled = enable; + vdev = v->dev->vdev; + n = VIRTIO_NET(vdev); + if (!n->vhost_started) { + return; + } + + if (enable) { + ioctl(v->device_fd, VHOST_VDPA_SUSPEND); + } + data_queue_pairs = n->multiqueue ? n->max_queue_pairs : 1; + cvq = 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 = s->nc.peer; + for (int i = 0; i < data_queue_pairs + cvq; i++) { + VhostVDPAState *vdpa_state; + NetClientState *nc; + + if (i < data_queue_pairs) { + nc = qemu_get_peer(peer, i); + } else { + nc = qemu_get_peer(peer, n->max_queue_pairs); + } + + vdpa_state = DO_UPCAST(VhostVDPAState, nc, nc); + vdpa_state->vhost_vdpa.listener_shadow_vq = enable; + vdpa_state->vhost_vdpa.shadow_vqs_enabled = enable; + vdpa_state->log_enabled = enable; + } + + r = 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 vhost_vdpa_net_log_global_start(MemoryListener *listener) +{ + vhost_vdpa_net_log_global_enable(listener, true); +} + +static void vhost_vdpa_net_log_global_stop(MemoryListener *listener) +{ + vhost_vdpa_net_log_global_enable(listener, false); +} + static NetClientInfo net_vhost_vdpa_info = { .type = NET_CLIENT_DRIVER_VHOST_VDPA, .size = sizeof(VhostVDPAState), @@ -413,6 +492,7 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); + memory_listener_unregister(&s->memory_listener); 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->cvq_cmd_in_buffer); @@ -671,6 +751,13 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, s->vhost_vdpa.shadow_vqs_enabled = svq; s->vhost_vdpa.listener_shadow_vq = svq; s->vhost_vdpa.iova_tree = iova_tree; + if (queue_pair_index == 0) { + s->memory_listener = (MemoryListener) { + .log_global_start = vhost_vdpa_net_log_global_start, + .log_global_stop = vhost_vdpa_net_log_global_stop, + }; + memory_listener_register(&s->memory_listener, &address_space_memory); + } if (!is_datapath) { s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_len()); From patchwork Wed Aug 10 18:42:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02DDAC00140 for ; Wed, 10 Aug 2022 18:58:53 +0000 (UTC) Received: from localhost ([::1]:36952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLquq-0007jM-LY for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:58:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfI-00029Y-8n for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-0006mC-Ta for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156966; 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=1mVJ38EwGXY+QEpr9DKXujdIXKFlc84PBGl+acvszhU=; b=izFpp5Fs1hAE34535p8I41DRzM2Z1rkuHZDgZtxxRzxaPx2NhQxDARkW7vTTiYJcJflbG3 F6uPCLuG4CI2ltmhfg7sbhzXAAHB7fAtkm7whYRCa+RbDnsnFomUNZkrlggS9MX5wRAg+Z zlUz2dj9VM1VWXxkYGCq0Ts/OHWKdpg= 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-314--aoavij5NHCX3WWFdp4PfQ-1; Wed, 10 Aug 2022 14:42:43 -0400 X-MC-Unique: -aoavij5NHCX3WWFdp4PfQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4A8C3C0ED69; Wed, 10 Aug 2022 18:42:42 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C43DC15BA3; Wed, 10 Aug 2022 18:42:39 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 6/8] vdpa: Negotiate _F_SUSPEND feature Date: Wed, 10 Aug 2022 20:42:18 +0200 Message-Id: <20220810184220.2362292-7-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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érez --- 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 3607983422..d750d9cec1 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -679,7 +679,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) uint64_t features; uint64_t f = 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; if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { From patchwork Wed Aug 10 18:42:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4843CC00140 for ; Wed, 10 Aug 2022 18:53:55 +0000 (UTC) Received: from localhost ([::1]:57468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqq2-0002LS-4B for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:53:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfM-00029o-Uu for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfL-0006nd-He for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156971; 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=0D0uPqxFiZAmKNPRxQy9w0W+GrBjiwe7DR8oCJ3dPlc=; b=RSp41mJodcpbecevie36kvDaLNR587WWw+hJn2eGBN73P1iPTEX+TFAcxbYUN8A8eXwQlK ffympc6GfJXcus5+jjh9/3W+p/5no3fNxvVyGUAj66R7lriLUNynESZD9tavtSEJE6haBa EuYwIfo5qgCEg1XdDNaMpkR5JfHBt4Q= 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-160-E4v9qChnNQu5mI8Nj3A0Qw-1; Wed, 10 Aug 2022 14:42:46 -0400 X-MC-Unique: E4v9qChnNQu5mI8Nj3A0Qw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BF163C0F39B; Wed, 10 Aug 2022 18:42:45 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13377C15BA3; Wed, 10 Aug 2022 18:42:42 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 7/8] vdpa: Add feature_log member to vhost_vdpa Date: Wed, 10 Aug 2022 20:42:19 +0200 Message-Id: <20220810184220.2362292-8-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This way device's vhost_vdpa can make the choice about exposing or not the _F_LOG feature. At the moment is always false. Signed-off-by: Eugenio Pérez --- 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 0c3ed2d69b..b09eae133a 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -33,6 +33,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; /* The listener must send iova tree addresses, not GPA */ bool listener_shadow_vq; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d750d9cec1..17513ee820 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1246,7 +1246,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev, struct vhost_vdpa *v = dev->opaque; int ret = vhost_vdpa_get_dev_features(dev, features); - if (ret == 0 && v->shadow_vqs_enabled) { + if (ret == 0 && (v->shadow_vqs_enabled || v->feature_log)) { /* Add SVQ logging capabilities */ *features |= BIT_ULL(VHOST_F_LOG_ALL); } From patchwork Wed Aug 10 18:42:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 12940897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54D5FC25B07 for ; Wed, 10 Aug 2022 18:58:54 +0000 (UTC) Received: from localhost ([::1]:36954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqur-0007jV-BG for qemu-devel@archiver.kernel.org; Wed, 10 Aug 2022 14:58:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfO-0002AR-BI for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfM-0006nk-Pw for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156972; 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=oeyBAG6aT1XeG4X0sacNDdNhmDyM8S/qNFDxSwuCWuI=; b=GhKqYMgFODaIliJHlemk+eMKuZeDNsHhDMqRY+Z5AFIL54myc8Pa6vSlBnmsgkL1owxi+K lJjuf2BdbUbWmFph5yAMWdyM52RQcQkiVZwkqAkcum4cXM3eETs87SZyqyke7AhvbGe1xs 1L7muRWXC+m4M0VJur6vvcCxC3cQqrg= 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-675-tgNjXTU-P-qyKAFHqDjcZQ-1; Wed, 10 Aug 2022 14:42:49 -0400 X-MC-Unique: tgNjXTU-P-qyKAFHqDjcZQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FA498039A1; Wed, 10 Aug 2022 18:42:48 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDC52C15BA4; Wed, 10 Aug 2022 18:42:45 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 8/8] vdpa: Conditionally expose _F_LOG in vhost_net devices Date: Wed, 10 Aug 2022 20:42:20 +0200 Message-Id: <20220810184220.2362292-9-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Vhost-vdpa networking devices need to met a few conditions to be migratable. If SVQ is not enabled from the beginnig, to suspend the device to retrieve the vq state is the first requirement. However, qemu also needs to be able to intercept SVQ from the beginning. To be able to do so, the vdpa device needs to expose certains features. Expose _F_LOG only if all of these are met. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4c6947feb8..73c27cd315 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -49,6 +49,9 @@ typedef struct VhostVDPAState { /* Device log enabled */ bool log_enabled; + /* Device can suspend */ + bool feature_suspend; + bool started; } VhostVDPAState; @@ -431,6 +434,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) /* Default values */ v->listener_shadow_vq = s->always_svq || s->log_enabled; v->shadow_vqs_enabled = s->always_svq || s->log_enabled; + v->feature_log = s->always_svq || s->log_enabled; s->vhost_vdpa.address_space_id = VHOST_VDPA_NET_CVQ_PASSTHROUGH; if (s->address_space_num < 2) { @@ -455,6 +459,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (unlikely(vq_group.num == cvq_group.num)) { warn_report("CVQ %u group is the same as VQ %u one (%u)", cvq_group.index, vq_group.index, cvq_group.num); + v->feature_log = false; return 0; } } @@ -464,6 +469,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (r == 0) { v->shadow_vqs_enabled = true; s->vhost_vdpa.address_space_id = VHOST_VDPA_NET_CVQ_ASID; + v->feature_log = s->feature_suspend; } out: @@ -728,6 +734,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, unsigned nas, bool is_datapath, bool svq, + bool feature_suspend, VhostIOVATree *iova_tree) { NetClientState *nc = NULL; @@ -748,9 +755,11 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, s->vhost_vdpa.device_fd = vdpa_device_fd; s->vhost_vdpa.index = queue_pair_index; s->always_svq = svq; + s->feature_suspend = feature_suspend; s->vhost_vdpa.shadow_vqs_enabled = svq; s->vhost_vdpa.listener_shadow_vq = svq; s->vhost_vdpa.iova_tree = iova_tree; + s->vhost_vdpa.feature_log = feature_suspend; if (queue_pair_index == 0) { s->memory_listener = (MemoryListener) { .log_global_start = vhost_vdpa_net_log_global_start, @@ -839,7 +848,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *nc; int queue_pairs, r, i = 0, has_cvq = 0; unsigned num_as = 1; - bool svq_cvq; + bool svq_cvq, feature_suspend; assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA); opts = &netdev->u.vhost_vdpa; @@ -892,10 +901,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, ncs = g_malloc0(sizeof(*ncs) * queue_pairs); + feature_suspend = backend_features & BIT_ULL(VHOST_BACKEND_F_SUSPEND); for (i = 0; i < queue_pairs; i++) { ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, num_as, true, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tree); if (!ncs[i]) goto err; } @@ -903,7 +913,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, if (has_cvq) { nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, num_as, false, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tree); if (!nc) goto err; }