From nobody Sat Apr 11 23:08:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1772768777; cv=none; d=zohomail.com; s=zohoarc; b=VyDBy9Yqq2x+0BCjLv+l7XovNFHMjuIgmWRsd7zLZwHhkftCvgoMCnqObH6mobnh1pNwgeLZUhmuJWw/hQrk4F8nyKHM+e2UvNSQUYps81xwfDnooknVlVRx7jFKZn1sbXiFv9fdO3yUHHFWKOt+8hEDqFDt8ZxagCfWFsP3hrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772768777; h=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=UoZoejKxI43bIwLkVnCFBsM5fQQNffbS7p3Mttofgbk=; b=ZQrECnpWcVwmyvaCClBvOL9nSpTHGNhR5YYOlCRdJnib/zxVpfYZJoZz9xSnoSZuBaW2d/xn4Ivhj8FSEnmpNiyYWRvyVnu2xzi5K5iVr3H40ksSCXZK1vCRneHhJVhDVUJpsPq6MSFMZPfqbYh5sO8gEmLg67ckNpc8fI6e6i8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772768777312197.8291312639683; Thu, 5 Mar 2026 19:46:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyM7d-0004Oy-2e; Thu, 05 Mar 2026 22:45:05 -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 1vyM7W-0004OH-HC for qemu-devel@nongnu.org; Thu, 05 Mar 2026 22:44:58 -0500 Received: from mgamail.intel.com ([192.198.163.8]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyM7T-00066q-RQ for qemu-devel@nongnu.org; Thu, 05 Mar 2026 22:44:58 -0500 Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2026 19:44:55 -0800 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2026 19:44:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772768695; x=1804304695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aO1S2Zzbk9Za9t2nHKvhIBMp482gunk92lqjS4Uk5DM=; b=Ru1ysyeYAeHYlPReA02nlF9UNCHtWyivP8ExM9fnk1HKTrKjQ+YM/clz xikKMs3y4mvFTJx7egP0w6VLjYryAP7QmVc8bcZ/J8nfP2A7nAFHJk2x3 segKSfmuMiRzFqV7U3UGcdswoHg+2JKBt2cf3Yz5gEf90+Y1+vt3F+e/3 WzmZ8hFIl/792m7tonD2RbS1nd1viH+tF7/8NKNfvWwFV3kBQlll2lgVF MCPfRztcAgtoThyqWZh5MK9ASY7mxlugwPuZXrxXBLkE3a9Ny9MC+6CG9 2HOLMvL5UPmwJoUele1j5Ugxw+UiUNJw5lNyNhFzpOCH5tJplRRUYAWub g==; X-CSE-ConnectionGUID: vtHlNh2OSTaV+Lfi9dDZdg== X-CSE-MsgGUID: y7HCTrDUQXeCuvPgt04spw== X-IronPort-AV: E=McAfee;i="6800,10657,11720"; a="91448325" X-IronPort-AV: E=Sophos;i="6.23,104,1770624000"; d="scan'208";a="91448325" X-CSE-ConnectionGUID: ILB2egHCQ7SAwP5aenAqgQ== X-CSE-MsgGUID: Atsf2fUrRa2wfsqnWukk5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,104,1770624000"; d="scan'208";a="215613410" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex@shazbot.org, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, skolothumtho@nvidia.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, xudong.hao@intel.com, Zhenzhong Duan Subject: [PATCH v1 10/13] intel_iommu_accel: Support pasid binding/unbinding and PIOTLB flushing Date: Thu, 5 Mar 2026 22:44:04 -0500 Message-ID: <20260306034409.184873-11-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306034409.184873-1-zhenzhong.duan@intel.com> References: <20260306034409.184873-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=192.198.163.8; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.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.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.892, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.622, 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: qemu development 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 @intel.com) X-ZM-MESSAGEID: 1772768779526158500 Content-Type: text/plain; charset="utf-8" We just switched to use VTDACCELPASIDCacheEntry to cache pasid entry of passthrough device, also need to switch the binding/unbinding and PIOTLB flushing functions to use the same structure. After the switching, we could remove accel related code from vtd_pasid_cache_[reset/sync]_locked() to make intel_iommu.c cleaner. The VTDAddressSpace of PASID_0 is still useful as VTD supports a legacy mode which needs shadow page table instead of nested page table. Signed-off-by: Zhenzhong Duan --- hw/i386/intel_iommu_accel.h | 2 +- include/hw/i386/intel_iommu.h | 2 - hw/i386/intel_iommu.c | 17 +---- hw/i386/intel_iommu_accel.c | 125 +++++++++++++++++----------------- 4 files changed, 64 insertions(+), 82 deletions(-) diff --git a/hw/i386/intel_iommu_accel.h b/hw/i386/intel_iommu_accel.h index 914c690c26..1ae46d9250 100644 --- a/hw/i386/intel_iommu_accel.h +++ b/hw/i386/intel_iommu_accel.h @@ -16,6 +16,7 @@ typedef struct VTDACCELPASIDCacheEntry { VTDHostIOMMUDevice *vtd_hiod; VTDPASIDEntry pe; uint32_t pasid; + uint32_t fs_hwpt_id; QLIST_ENTRY(VTDACCELPASIDCacheEntry) next; } VTDACCELPASIDCacheEntry; =20 @@ -23,7 +24,6 @@ typedef struct VTDACCELPASIDCacheEntry { bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOMMUDevice *vtd_hiod, Error **errp); VTDHostIOMMUDevice *vtd_find_hiod_iommufd(VTDAddressSpace *as); -bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as, Error **errp); void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *s, uint16_t domain_= id, uint32_t pasid, hwaddr addr, uint64_t npages, bool ih); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index bb957b93e0..64f963412a 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -154,8 +154,6 @@ struct VTDAddressSpace { * with the guest IOMMU pgtables for a device. */ IOVATree *iova_tree; - - uint32_t fs_hwpt_id; }; =20 struct VTDIOTLBEntry { diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index b7d487bf5a..edd2b8f0cc 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -86,8 +86,6 @@ static void vtd_pasid_cache_reset_locked(IntelIOMMUState = *s) VTDPASIDCacheEntry *pc_entry =3D &vtd_as->pasid_cache_entry; if (pc_entry->valid) { pc_entry->valid =3D false; - /* It's fatal to get failure during reset */ - vtd_propagate_guest_pasid(vtd_as, &error_fatal); } } } @@ -3126,8 +3124,6 @@ static void vtd_pasid_cache_sync_locked(gpointer key,= gpointer value, VTDPASIDEntry pe; IOMMUNotifier *n; uint16_t did; - const char *err_prefix =3D "Attaching to HWPT failed: "; - Error *local_err =3D NULL; =20 if (vtd_dev_get_pe_from_pasid(vtd_as, &pe)) { if (!pc_entry->valid) { @@ -3148,9 +3144,6 @@ static void vtd_pasid_cache_sync_locked(gpointer key,= gpointer value, vtd_address_space_unmap(vtd_as, n); } vtd_switch_address_space(vtd_as); - - err_prefix =3D "Detaching from HWPT failed: "; - goto do_bind_unbind; } =20 /* @@ -3178,20 +3171,12 @@ static void vtd_pasid_cache_sync_locked(gpointer ke= y, gpointer value, if (!pc_entry->valid) { pc_entry->pasid_entry =3D pe; pc_entry->valid =3D true; - } else if (vtd_pasid_entry_compare(&pe, &pc_entry->pasid_entry)) { - err_prefix =3D "Replacing HWPT attachment failed: "; - } else { + } else if (!vtd_pasid_entry_compare(&pe, &pc_entry->pasid_entry)) { return; } =20 vtd_switch_address_space(vtd_as); vtd_address_space_sync(vtd_as); - -do_bind_unbind: - /* TODO: Fault event injection into guest, report error to QEMU for no= w */ - if (!vtd_propagate_guest_pasid(vtd_as, &local_err)) { - error_reportf_err(local_err, "%s", err_prefix); - } } =20 static void vtd_pasid_cache_sync(IntelIOMMUState *s, VTDPASIDCacheInfo *pc= _info) diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c index c1890ca0a5..d7c1ff6b74 100644 --- a/hw/i386/intel_iommu_accel.c +++ b/hw/i386/intel_iommu_accel.c @@ -111,23 +111,24 @@ static bool vtd_create_fs_hwpt(VTDHostIOMMUDevice *vt= d_hiod, } =20 static void vtd_destroy_old_fs_hwpt(VTDHostIOMMUDevice *vtd_hiod, - VTDAddressSpace *vtd_as) + VTDACCELPASIDCacheEntry *vtd_pce) { HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->h= iod); =20 - if (!vtd_as->fs_hwpt_id) { + if (!vtd_pce->fs_hwpt_id) { return; } - iommufd_backend_free_id(idev->iommufd, vtd_as->fs_hwpt_id); - vtd_as->fs_hwpt_id =3D 0; + iommufd_backend_free_id(idev->iommufd, vtd_pce->fs_hwpt_id); + vtd_pce->fs_hwpt_id =3D 0; } =20 -static bool vtd_device_attach_iommufd(VTDHostIOMMUDevice *vtd_hiod, - VTDAddressSpace *vtd_as, Error **err= p) +static bool vtd_device_attach_iommufd(VTDACCELPASIDCacheEntry *vtd_pce, + Error **errp) { + VTDHostIOMMUDevice *vtd_hiod =3D vtd_pce->vtd_hiod; HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->h= iod); - VTDPASIDEntry *pe =3D &vtd_as->pasid_cache_entry.pasid_entry; - uint32_t hwpt_id =3D idev->hwpt_id; + VTDPASIDEntry *pe =3D &vtd_pce->pe; + uint32_t hwpt_id =3D idev->hwpt_id, pasid =3D vtd_pce->pasid; bool ret; =20 /* @@ -147,14 +148,13 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDev= ice *vtd_hiod, } } =20 - ret =3D host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, hw= pt_id, - errp); - trace_vtd_device_attach_hwpt(idev->devid, vtd_as->pasid, hwpt_id, ret); + ret =3D host_iommu_device_iommufd_attach_hwpt(idev, pasid, hwpt_id, er= rp); + trace_vtd_device_attach_hwpt(idev->devid, pasid, hwpt_id, ret); if (ret) { /* Destroy old fs_hwpt if it's a replacement */ - vtd_destroy_old_fs_hwpt(vtd_hiod, vtd_as); + vtd_destroy_old_fs_hwpt(vtd_hiod, vtd_pce); if (vtd_pe_pgtt_is_fst(pe)) { - vtd_as->fs_hwpt_id =3D hwpt_id; + vtd_pce->fs_hwpt_id =3D hwpt_id; } } else if (vtd_pe_pgtt_is_fst(pe)) { iommufd_backend_free_id(idev->iommufd, hwpt_id); @@ -163,16 +163,17 @@ static bool vtd_device_attach_iommufd(VTDHostIOMMUDev= ice *vtd_hiod, return ret; } =20 -static bool vtd_device_detach_iommufd(VTDHostIOMMUDevice *vtd_hiod, - VTDAddressSpace *vtd_as, Error **err= p) +static bool vtd_device_detach_iommufd(VTDACCELPASIDCacheEntry *vtd_pce, + Error **errp) { + VTDHostIOMMUDevice *vtd_hiod =3D vtd_pce->vtd_hiod; HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->h= iod); - IntelIOMMUState *s =3D vtd_as->iommu_state; - uint32_t pasid =3D vtd_as->pasid; + IntelIOMMUState *s =3D vtd_hiod->iommu_state; + uint32_t pasid =3D vtd_pce->pasid; bool ret; =20 - if (s->dmar_enabled && s->root_scalable) { - ret =3D host_iommu_device_iommufd_detach_hwpt(idev, IOMMU_NO_PASID= , errp); + if (pasid !=3D IOMMU_NO_PASID || (s->dmar_enabled && s->root_scalable)= ) { + ret =3D host_iommu_device_iommufd_detach_hwpt(idev, pasid, errp); trace_vtd_device_detach_hwpt(idev->devid, pasid, ret); } else { /* @@ -180,72 +181,47 @@ static bool vtd_device_detach_iommufd(VTDHostIOMMUDev= ice *vtd_hiod, * we fallback to the default HWPT which contains shadow page tabl= e. * So guest DMA could still work. */ - ret =3D host_iommu_device_iommufd_attach_hwpt(idev, IOMMU_NO_PASID, + ret =3D host_iommu_device_iommufd_attach_hwpt(idev, pasid, idev->hwpt_id, errp); trace_vtd_device_reattach_def_hwpt(idev->devid, pasid, idev->hwpt_= id, ret); } =20 if (ret) { - vtd_destroy_old_fs_hwpt(vtd_hiod, vtd_as); + vtd_destroy_old_fs_hwpt(vtd_hiod, vtd_pce); } =20 return ret; } =20 -bool vtd_propagate_guest_pasid(VTDAddressSpace *vtd_as, Error **errp) -{ - VTDPASIDCacheEntry *pc_entry =3D &vtd_as->pasid_cache_entry; - VTDHostIOMMUDevice *vtd_hiod =3D vtd_find_hiod_iommufd(vtd_as); - - /* Ignore emulated device or legacy VFIO backed device */ - if (!vtd_as->iommu_state->fsts || !vtd_hiod) { - return true; - } - - if (pc_entry->valid) { - return vtd_device_attach_iommufd(vtd_hiod, vtd_as, errp); - } - - return vtd_device_detach_iommufd(vtd_hiod, vtd_as, errp); -} - /* - * This function is a loop function for the s->vtd_address_spaces - * list with VTDPIOTLBInvInfo as execution filter. It propagates - * the piotlb invalidation to host. + * This function is a loop function for the s->vtd_host_iommu_dev + * and vtd_hiod->pasid_cache_list lists with VTDPIOTLBInvInfo as + * execution filter. It propagates the piotlb invalidation to host. */ -static void vtd_flush_host_piotlb_locked(gpointer key, gpointer value, - gpointer user_data) +static void vtd_flush_host_piotlb(VTDACCELPASIDCacheEntry *vtd_pce, + VTDPIOTLBInvInfo *piotlb_info) { - VTDPIOTLBInvInfo *piotlb_info =3D user_data; - VTDAddressSpace *vtd_as =3D value; - VTDHostIOMMUDevice *vtd_hiod =3D vtd_find_hiod_iommufd(vtd_as); - VTDPASIDCacheEntry *pc_entry =3D &vtd_as->pasid_cache_entry; + VTDHostIOMMUDevice *vtd_hiod =3D vtd_pce->vtd_hiod; + VTDPASIDEntry *pe =3D &vtd_pce->pe; uint16_t did; =20 - if (!vtd_hiod) { - return; - } - - assert(vtd_as->pasid =3D=3D PCI_NO_PASID); - /* Nothing to do if there is no first stage HWPT attached */ - if (!pc_entry->valid || - !vtd_pe_pgtt_is_fst(&pc_entry->pasid_entry)) { + if (!vtd_pe_pgtt_is_fst(pe)) { return; } =20 - did =3D VTD_SM_PASID_ENTRY_DID(&pc_entry->pasid_entry); + did =3D VTD_SM_PASID_ENTRY_DID(pe); =20 - if (piotlb_info->domain_id =3D=3D did && piotlb_info->pasid =3D=3D PAS= ID_0) { + if (piotlb_info->domain_id =3D=3D did && piotlb_info->pasid =3D=3D vtd= _pce->pasid) { HostIOMMUDeviceIOMMUFD *idev =3D HOST_IOMMU_DEVICE_IOMMUFD(vtd_hiod->hiod); uint32_t entry_num =3D 1; /* Only implement one request for simpli= city */ Error *local_err =3D NULL; struct iommu_hwpt_vtd_s1_invalidate *cache =3D piotlb_info->inv_da= ta; =20 - if (!iommufd_backend_invalidate_cache(idev->iommufd, vtd_as->fs_hw= pt_id, + if (!iommufd_backend_invalidate_cache(idev->iommufd, + vtd_pce->fs_hwpt_id, IOMMU_HWPT_INVALIDATE_DATA_V= TD_S1, sizeof(*cache), &entry_num, = cache, &local_err)) { @@ -261,6 +237,8 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState *= s, uint16_t domain_id, { struct iommu_hwpt_vtd_s1_invalidate cache_info =3D { 0 }; VTDPIOTLBInvInfo piotlb_info; + VTDHostIOMMUDevice *vtd_hiod; + GHashTableIter as_it; =20 cache_info.addr =3D addr; cache_info.npages =3D npages; @@ -271,12 +249,19 @@ void vtd_flush_host_piotlb_all_locked(IntelIOMMUState= *s, uint16_t domain_id, piotlb_info.inv_data =3D &cache_info; =20 /* - * Go through each vtd_as instance in s->vtd_address_spaces, find out - * affected host devices which need host piotlb invalidation. Piotlb - * invalidation should check pasid cache per architecture point of vie= w. + * Go through each vtd_pce in vtd_hiod->pasid_cache_list for each host + * device, find out affected host device pasid which need host piotlb + * invalidation. Piotlb invalidation should check pasid cache per + * architecture point of view. */ - g_hash_table_foreach(s->vtd_address_spaces, - vtd_flush_host_piotlb_locked, &piotlb_info); + g_hash_table_iter_init(&as_it, s->vtd_host_iommu_dev); + while (g_hash_table_iter_next(&as_it, NULL, (void **)&vtd_hiod)) { + VTDACCELPASIDCacheEntry *vtd_pce; + + QLIST_FOREACH(vtd_pce, &vtd_hiod->pasid_cache_list, next) { + vtd_flush_host_piotlb(vtd_pce, &piotlb_info); + } + } } =20 static void vtd_pasid_cache_invalidate_one(VTDACCELPASIDCacheEntry *vtd_pc= e, @@ -284,6 +269,7 @@ static void vtd_pasid_cache_invalidate_one(VTDACCELPASI= DCacheEntry *vtd_pce, { VTDPASIDEntry pe; uint16_t did; + Error *local_err =3D NULL; =20 /* * VTD_INV_DESC_PASIDC_G_DSI and VTD_INV_DESC_PASIDC_G_PASID_SI require @@ -309,6 +295,9 @@ static void vtd_pasid_cache_invalidate_one(VTDACCELPASI= DCacheEntry *vtd_pce, * to be either all-zero or non-present. Either case means existing * pasid cache should be invalidated. */ + if (!vtd_device_detach_iommufd(vtd_pce, &local_err)) { + error_reportf_err(local_err, "%s", "Detaching from HWPT failed= : "); + } QLIST_REMOVE(vtd_pce, next); g_free(vtd_pce); } @@ -329,11 +318,17 @@ static void vtd_find_add_pc(VTDHostIOMMUDevice *vtd_h= iod, uint32_t pasid, VTDPASIDEntry *pe) { VTDACCELPASIDCacheEntry *vtd_pce; + Error *local_err =3D NULL; =20 QLIST_FOREACH(vtd_pce, &vtd_hiod->pasid_cache_list, next) { if (vtd_pce->pasid =3D=3D pasid) { if (vtd_pasid_entry_compare(pe, &vtd_pce->pe)) { vtd_pce->pe =3D *pe; + + if (!vtd_device_attach_iommufd(vtd_pce, &local_err)) { + error_reportf_err(local_err, "%s", + "Replacing HWPT attachment failed: "= ); + } } return; } @@ -344,6 +339,10 @@ static void vtd_find_add_pc(VTDHostIOMMUDevice *vtd_hi= od, uint32_t pasid, vtd_pce->pasid =3D pasid; vtd_pce->pe =3D *pe; QLIST_INSERT_HEAD(&vtd_hiod->pasid_cache_list, vtd_pce, next); + + if (!vtd_device_attach_iommufd(vtd_pce, &local_err)) { + error_reportf_err(local_err, "%s", "Attaching to HWPT failed: "); + } } =20 /* --=20 2.47.3