{"id":2225848,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2225848/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421163438.3447280-11-clg@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260421163438.3447280-11-clg@redhat.com>","date":"2026-04-21T16:34:34","name":"[PULL,10/14] hw/vfio/iommufd: Control dirty tracking for nesting parent HWPT","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b92cb1130809f331a7c60d87f93e370a0cd1547d","submitter":{"id":85406,"url":"http://patchwork.ozlabs.org/api/1.1/people/85406/?format=json","name":"Cédric Le Goater","email":"clg@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421163438.3447280-11-clg@redhat.com/mbox/","series":[{"id":500853,"url":"http://patchwork.ozlabs.org/api/1.1/series/500853/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500853","date":"2026-04-21T16:34:24","name":"[PULL,01/14] hw/vfio/listener.c: remove CONFIG_KVM","version":1,"mbox":"http://patchwork.ozlabs.org/series/500853/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225848/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225848/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=agN1j8Ki;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0Sgh2h8Bz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 02:37:20 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFE5N-0005eB-HP; Tue, 21 Apr 2026 12:36:29 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <clg@redhat.com>) id 1wFE4B-0004jb-M1\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:35:18 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <clg@redhat.com>) id 1wFE47-0007Qa-92\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 12:35:13 -0400","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-5Utkm1NqOlqx8OgkUovcTg-1; Tue,\n 21 Apr 2026 12:35:06 -0400","from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 0CFE719560AA; Tue, 21 Apr 2026 16:35:05 +0000 (UTC)","from corto.redhat.com (unknown [10.44.32.70])\n by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 193701956095; Tue, 21 Apr 2026 16:35:02 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776789307;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=VvTNqp++Rdp2v3KRck3Tf7+xvqfTdXk5NH7kjqmKGWw=;\n b=agN1j8Kij/1KOslJruKoNThLQtgca0YOmx04NtZVtVG2ws2t1g4d3WpQyv4LTlN8P9jK8/\n Nl8IoUNMSojilF8q8sM5QH5p6YlW4mh9T/xqhRHrPBWUVhC812gWuPFYBmU5kozKrfsJJG\n uf7056QnkqO7fY5lyfztDwwqiNiMNyc=","X-MC-Unique":"5Utkm1NqOlqx8OgkUovcTg-1","X-Mimecast-MFC-AGG-ID":"5Utkm1NqOlqx8OgkUovcTg_1776789305","From":"=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Alex Williamson <alex@shazbot.org>,\n Shameer Kolothum <skolothumtho@nvidia.com>,\n Zhenzhong Duan <zhenzhong.duan@intel.com>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>","Subject":"[PULL 10/14] hw/vfio/iommufd: Control dirty tracking for nesting\n parent HWPT","Date":"Tue, 21 Apr 2026 18:34:34 +0200","Message-ID":"<20260421163438.3447280-11-clg@redhat.com>","In-Reply-To":"<20260421163438.3447280-1-clg@redhat.com>","References":"<20260421163438.3447280-1-clg@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.17","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=clg@redhat.com;\n 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,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001,\n 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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Shameer Kolothum <skolothumtho@nvidia.com>\n\nQEMU smmuv3 accel does not support live migration yet, so dirty\ntracking for the nesting parent HWPT is not useful.\n\nAlso, nested vIOMMU use cases can break on some platforms. For\nexample, SMMUv3 with HTTU may advertise dirty tracking capability,\nbut the kernel supports it only for stage-1. Requesting dirty\ntracking for a nesting parent HWPT (stage-2) can fail.\n\nAdd a vIOMMU flag to explicitly request dirty tracking for the\nnesting parent HWPT. For nested cases, dirty tracking is enabled\nonly when requested by the vIOMMU.\n\nNon-nested cases and Intel vIOMMU keep the existing behavior.\n\nFixes: fc6dafb98cec (\"hw/arm/smmuv3: Implement get_viommu_cap() callback\")\nSigned-off-by: Shameer Kolothum <skolothumtho@nvidia.com>\nReviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>\nLink: https://lore.kernel.org/qemu-devel/20260401084133.56266-1-skolothumtho@nvidia.com\nSigned-off-by: Cédric Le Goater <clg@redhat.com>\n---\n include/hw/core/iommu.h       |  2 ++\n include/hw/vfio/vfio-device.h |  1 +\n hw/i386/intel_iommu.c         |  7 +++++--\n hw/vfio/device.c              | 11 +++++++++++\n hw/vfio/iommufd.c             | 11 +++++++++--\n 5 files changed, 28 insertions(+), 4 deletions(-)","diff":"diff --git a/include/hw/core/iommu.h b/include/hw/core/iommu.h\nindex 86af315c153763d4d217a2e255c3f7aced228e91..cd59a367ceb9517885a5a8c14a40af3404e99832 100644\n--- a/include/hw/core/iommu.h\n+++ b/include/hw/core/iommu.h\n@@ -21,6 +21,8 @@ enum viommu_flags {\n     /* vIOMMU needs nesting parent HWPT to create nested HWPT */\n     VIOMMU_FLAG_WANT_NESTING_PARENT = BIT_ULL(0),\n     VIOMMU_FLAG_PASID_SUPPORTED = BIT_ULL(1),\n+    /* vIOMMU needs dirty tracking on the nesting parent HWPT for nested use */\n+    VIOMMU_FLAG_WANT_NESTING_DIRTY_TRACKING = BIT_ULL(2),\n };\n \n /* Host IOMMU quirks. Extracted from host IOMMU capabilities */\ndiff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h\nindex 828a31c006ec9fc372760fee023da31b0e7acc4b..a95c5bf50302a7394582dcc493d96aef00b47dc8 100644\n--- a/include/hw/vfio/vfio-device.h\n+++ b/include/hw/vfio/vfio-device.h\n@@ -268,6 +268,7 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainer *bcontainer,\n void vfio_device_unprepare(VFIODevice *vbasedev);\n \n bool vfio_device_get_viommu_flags_want_nesting(VFIODevice *vbasedev);\n+bool vfio_device_get_viommu_flags_want_nesting_dirty(VFIODevice *vbasedev);\n bool vfio_device_get_host_iommu_quirk_bypass_ro(VFIODevice *vbasedev,\n                                                 uint32_t type, void *caps,\n                                                 uint32_t size);\ndiff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c\nindex f395fa248c009c663be281774c8455ee3b85d8a2..b784c5f10aebbd3fe1f1c332c4ecc5aecc2b9136 100644\n--- a/hw/i386/intel_iommu.c\n+++ b/hw/i386/intel_iommu.c\n@@ -4825,9 +4825,12 @@ static void vtd_dev_unset_iommu_device(PCIBus *bus, void *opaque, int devfn)\n static uint64_t vtd_get_viommu_flags(void *opaque)\n {\n     IntelIOMMUState *s = opaque;\n-    uint64_t flags;\n+    uint64_t flags = 0;\n \n-    flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0;\n+    if (s->fsts) {\n+        flags = VIOMMU_FLAG_WANT_NESTING_PARENT |\n+                VIOMMU_FLAG_WANT_NESTING_DIRTY_TRACKING;\n+    }\n \n     return flags;\n }\ndiff --git a/hw/vfio/device.c b/hw/vfio/device.c\nindex 973fc35b59d4bdaa34c0f2773ec78df0f151dfa2..8f7ae919a55dd9e08bdd072eee33f5b46a91aa2a 100644\n--- a/hw/vfio/device.c\n+++ b/hw/vfio/device.c\n@@ -522,6 +522,17 @@ void vfio_device_unprepare(VFIODevice *vbasedev)\n     vbasedev->bcontainer = NULL;\n }\n \n+bool vfio_device_get_viommu_flags_want_nesting_dirty(VFIODevice *vbasedev)\n+{\n+    VFIOPCIDevice *vdev = vfio_pci_from_vfio_device(vbasedev);\n+\n+    if (vdev) {\n+        return !!(pci_device_get_viommu_flags(PCI_DEVICE(vdev)) &\n+                  VIOMMU_FLAG_WANT_NESTING_DIRTY_TRACKING);\n+    }\n+    return false;\n+}\n+\n bool vfio_device_get_viommu_flags_want_nesting(VFIODevice *vbasedev)\n {\n     VFIOPCIDevice *vdev = vfio_pci_from_vfio_device(vbasedev);\ndiff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c\nindex 399b36aa752ebe24d5ea7eb4d0a991785c51e642..df148a49a762b1f6b05d548cb9f9b0413b743439 100644\n--- a/hw/vfio/iommufd.c\n+++ b/hw/vfio/iommufd.c\n@@ -352,6 +352,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,\n     ERRP_GUARD();\n     IOMMUFDBackend *iommufd = vbasedev->iommufd;\n     VFIOContainer *bcontainer = VFIO_IOMMU(container);\n+    bool viommu_nesting, viommu_nesting_dirty;\n     uint32_t type, flags = 0;\n     uint64_t hw_caps;\n     VendorCaps caps;\n@@ -405,8 +406,14 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,\n         return false;\n     }\n \n+    viommu_nesting = vfio_device_get_viommu_flags_want_nesting(vbasedev);\n+    viommu_nesting_dirty =\n+        vfio_device_get_viommu_flags_want_nesting_dirty(vbasedev);\n+\n     if (hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING) {\n-        flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING;\n+        if (!viommu_nesting || viommu_nesting_dirty) {\n+            flags |= IOMMU_HWPT_ALLOC_DIRTY_TRACKING;\n+        }\n     }\n \n     /*\n@@ -414,7 +421,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,\n      * force to create it so that it could be reused by vIOMMU to create\n      * nested HWPT.\n      */\n-    if (vfio_device_get_viommu_flags_want_nesting(vbasedev)) {\n+    if (viommu_nesting) {\n         flags |= IOMMU_HWPT_ALLOC_NEST_PARENT;\n \n         if (vfio_device_get_host_iommu_quirk_bypass_ro(vbasedev, type,\n","prefixes":["PULL","10/14"]}