Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2801333rdg; Mon, 16 Oct 2023 15:49:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa4W3ftdqeml2E2TUpIKkBpDusYq/ZiOJ0990gQH4MDsj6WKIZfaouexob9wXksIymNX6T X-Received: by 2002:a05:6808:6399:b0:3ae:1d7:9c9 with SMTP id ec25-20020a056808639900b003ae01d709c9mr651283oib.50.1697496559091; Mon, 16 Oct 2023 15:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697496559; cv=none; d=google.com; s=arc-20160816; b=ReTBwA0P2h+rLE9rFlzbMvZV/E4pXtV0KI7TzzQ1eKZ+MsH4ZhuPKX47j1O64ii31j TittvVJPm+QalfWFTEUuPK+JfcbeEyMgTJlVPSgfn7HJ/N+ChwMXkMdz5J7uvXNFNkmh F/WhjIGeZjU0vHDWe4NDm/QLvoqUwA5nqzHWnMxvDhN24mdCKOtE3EGnuvayLJrLgz5U h0EAJGRUi33EFcuPLtqL9AzPYlAj26mkZ2XUqAOuThW2UrG5eQFq9I652xpXhaYeCDXV VGePrKrK89cmizf1CMpSJk8Z8QC9Pr9ScqzzbWqkWZ+KS+3wutMBhAVCxeos/KGAkl/v Y6ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Y5N64g2qnbcVxmrUMZtOSoLgR2kLXvRWoQ4hTvxyx6Y=; fh=+Cb2XQ2PA67VLAGJa+jxW1LjaBXcHfLinB2fMRnx8lg=; b=FYqktaXepNVX7RTv4vtMYBtRM287czxswz3lKeEOGY+At3GxE06NJTZq6A2UBhIsCk 93XKcwhjQUfkObTq+nIDD0/FagQwd20wfJI4G3zBAHEvlHPNipL6zMQak2FiRyN2E9go XwKC7XTpbyTDmmV1p5ZP35/o09xdF1ofloe5qs6qxp1ghjI/2a84eaWvCOg98zOBz5a5 zGxcImaLp23tNg4CaN1XPwhjQnDjxEF4nRv3Sn6PB2Q3Prr6BFS7PuZiOwRiidWRnMUC 2h7UQroh4i/sGs3SG/SjdPlcEFfcT7brxA6T/v9HlsaeVZLdVHYazUXtKdzWFYd0uclT yDaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BKU5e4OO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w17-20020a63fb51000000b0057cf9be76c2si320487pgj.580.2023.10.16.15.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 15:49:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BKU5e4OO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 27F3D8026ADA; Mon, 16 Oct 2023 15:49:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234213AbjJPWso (ORCPT + 99 others); Mon, 16 Oct 2023 18:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233854AbjJPWsh (ORCPT ); Mon, 16 Oct 2023 18:48:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC832B4 for ; Mon, 16 Oct 2023 15:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697496470; 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; bh=Y5N64g2qnbcVxmrUMZtOSoLgR2kLXvRWoQ4hTvxyx6Y=; b=BKU5e4OO4gZLFfJn3bP+kMhOF5tVUYMNdsNiJPU7vzB39UV4gFvYZhhmn5UDUXMqTYODWN 7QICor1jsB7oAGm/ModgAXcoWZZg1RQO8XCNr9y9db+EQP2HoNtx50bKbmM8x9knsm5ywA shzhGUBdS7TTvDc9kHD+VuM/GAOH4H4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-gcxiGaN3PWW9JERgctSV5g-1; Mon, 16 Oct 2023 18:47:41 -0400 X-MC-Unique: gcxiGaN3PWW9JERgctSV5g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0599A805BC3; Mon, 16 Oct 2023 22:47:41 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.10.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A821225C9; Mon, 16 Oct 2023 22:47:40 +0000 (UTC) From: Alex Williamson To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, clg@redhat.com Subject: [PATCH v2 0/2] vfio/mtty: Add migration support Date: Mon, 16 Oct 2023 16:47:34 -0600 Message-Id: <20231016224736.2575718-1-alex.williamson@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 15:49:18 -0700 (PDT) We've seen a request for CI and development to have access to migratable vfio devices without any specific hardware requirements. One way to do that is to enable migration support on the mtty mdev sample driver, as done here. This device is particularly easy to migrate because it doesn't actually do DMA, or in fact much of anything. Therefore we can claim P2P and dirty logging as well. PRE_COPY support is also included in a similar fashion to hisi_acc. This provides early compatibility testing, which is probably over-done, but perhaps illustrates good practice with matching data stream magic, versioning, and feature flags. These might later be used for backwards compatibility, particularly since I'm not positive that copying the struct serial_port between source and destination is sufficient. Along the way, testing migration where the source and target are incompatible revealed an eventfd leak, where peeling back the onion of mtty handling of SET_IRQS proved to require a substantial overhaul. v2: Incorporate comments from Cédric - Fixing eventfd leak turned into SET_IRQS overhaul - Factored out mtty_data_size() - Factored mtty_save_state() and paired with mtty_load_state() Alex Williamson (2): vfio/mtty: Overhaul mtty interrupt handling vfio/mtty: Enable migration support samples/vfio-mdev/mtty.c | 829 +++++++++++++++++++++++++++++++++++---- 1 file changed, 756 insertions(+), 73 deletions(-) -- 2.40.1