diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 814cb72..f8360c6 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -828,7 +828,7 @@ out: ept_sync_domain(p2m); /* For host p2m, may need to change VT-d page table.*/ - if ( entry_written && p2m_is_hostp2m(p2m) && need_iommu(d) && + if ( rc == 0 && p2m_is_hostp2m(p2m) && need_iommu(d) && need_modify_vtd_table ) { if ( iommu_hap_pt_share ) @@ -838,16 +838,13 @@ out: if ( iommu_flags ) for ( i = 0; i < (1 << order); i++ ) { - ret = iommu_map_page(d, gfn + i, mfn_x(mfn) + i, iommu_flags); + rc = iommu_map_page(d, gfn + i, mfn_x(mfn) + i, iommu_flags); - if ( unlikely(ret) ) + if ( unlikely(rc) ) { while ( i-- ) iommu_unmap_page(p2m->domain, gfn + i); - if ( !rc ) - rc = ret; - break; } }