From nobody Mon Feb 9 22:24:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1751619169; cv=none; d=zohomail.com; s=zohoarc; b=mp4DijB5MTTyrPNdDVeneIbXD9PmIWenQMAMTxhKVcl5QoR7f7c5cMht5SrThNVjb39T6xz8AIT066GF7/6rYr8RXUX05IfsiHMqH3RSlww5vxOZFRSh4Sdds1fresEELkdviCKYm9oXE7FiJ3CeCZSw7mWRyiInZpaFkFnieI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751619169; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2/QQHxzSBwOZry8dpMse9+bQu7EIO9GAsfRgmGz5QH8=; b=MCQQGpdhHtmITzlZ8MOIoANPg7D38yk4BJug+8eMOYnq5EFvaj1iUE9fskmdZgmMc4ikfNHdD4isXVuinPw1lXkxK9GVAT2zIFjJloSY3VYQCxUSCpZe1XioDS0ejheKIpcjYfxP0jBjbcN8otaTUnp/+IoECpze8UgPQ8nJbLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17516191699383.6019945322052536; Fri, 4 Jul 2025 01:52:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uXc4R-0000b1-Fj; Fri, 04 Jul 2025 04:47:00 -0400 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 1uXc4F-0000QX-OS for qemu-devel@nongnu.org; Fri, 04 Jul 2025 04:46:49 -0400 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 1uXc4D-0001OF-QP for qemu-devel@nongnu.org; Fri, 04 Jul 2025 04:46:47 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-m3YTmIjENKOznhQTtCof_A-1; Fri, 04 Jul 2025 04:46:40 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8CC141944AA6; Fri, 4 Jul 2025 08:46:39 +0000 (UTC) Received: from corto.redhat.com (unknown [10.44.32.43]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 98F5219560A7; Fri, 4 Jul 2025 08:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751618805; 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=2/QQHxzSBwOZry8dpMse9+bQu7EIO9GAsfRgmGz5QH8=; b=QskD0r/MbpGNa3/CAmVOH8Q8u1GNA+8xHuLdzEcCirBhYsRTGaaj7K0R+yg6UXKlwHvPwL OJEPNEURrtr+Tlr0VaX28GB8HpM2ls0OEVCekI66bo+CqTgTzt2baq2BkJ+gz1FZfpKkPh jOLttlTdFGZPpvMKRK3i/meuT//w+9s= X-MC-Unique: m3YTmIjENKOznhQTtCof_A-1 X-Mimecast-MFC-AGG-ID: m3YTmIjENKOznhQTtCof_A_1751618799 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Steve Sistare , Zhenzhong Duan , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 24/27] vfio/iommufd: change process Date: Fri, 4 Jul 2025 10:45:25 +0200 Message-ID: <20250704084528.1412959-25-clg@redhat.com> In-Reply-To: <20250704084528.1412959-1-clg@redhat.com> References: <20250704084528.1412959-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1751619171084116600 From: Steve Sistare Finish CPR by change the owning process of the iommufd device in post load. Signed-off-by: Steve Sistare Reviewed-by: Zhenzhong Duan Link: https://lore.kernel.org/qemu-devel/1751493538-202042-19-git-send-emai= l-steven.sistare@oracle.com [ clg: Fixed missing "qemu/error-report.h" include ] Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/cpr-iommufd.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index a72b68daa8e4da19b9cbf3ab50631211965cdf37..148a06d552ff3d8e8420366c6b7= 1437e81a1f877 100644 --- a/hw/vfio/cpr-iommufd.c +++ b/hw/vfio/cpr-iommufd.c @@ -5,6 +5,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "hw/vfio/vfio-cpr.h" #include "hw/vfio/vfio-device.h" @@ -112,10 +113,40 @@ static bool vfio_cpr_supported(IOMMUFDBackend *be, Er= ror **errp) return true; } =20 +static int iommufd_cpr_pre_save(void *opaque) +{ + IOMMUFDBackend *be =3D opaque; + + /* + * The process has not changed yet, but proactively try the ioctl, + * and it will fail if any DMA mappings are not supported. + */ + if (!iommufd_change_process_capable(be)) { + error_report("some memory regions do not support " + "IOMMU_IOAS_CHANGE_PROCESS"); + return -1; + } + return 0; +} + +static int iommufd_cpr_post_load(void *opaque, int version_id) +{ + IOMMUFDBackend *be =3D opaque; + Error *local_err =3D NULL; + + if (!iommufd_change_process(be, &local_err)) { + error_report_err(local_err); + return -1; + } + return 0; +} + static const VMStateDescription iommufd_cpr_vmstate =3D { .name =3D "iommufd", .version_id =3D 0, .minimum_version_id =3D 0, + .pre_save =3D iommufd_cpr_pre_save, + .post_load =3D iommufd_cpr_post_load, .needed =3D cpr_incoming_needed, .fields =3D (VMStateField[]) { VMSTATE_END_OF_LIST() --=20 2.50.0