diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c --- a/sys/x86/iommu/intel_idpgtbl.c +++ b/sys/x86/iommu/intel_idpgtbl.c @@ -722,6 +722,7 @@ { vm_object_t obj; vm_page_t m; + int r; obj = domain->pgtbl_obj; if (obj == NULL) { @@ -741,8 +742,12 @@ /* Obliterate ref_counts */ VM_OBJECT_ASSERT_WLOCKED(obj); - for (m = vm_page_lookup(obj, 0); m != NULL; m = vm_page_next(m)) - m->ref_count = 0; + for (m = vm_page_lookup(obj, 0); m != NULL; m = vm_page_next(m)) { + r = m->ref_count; + while (atomic_fcmpset_int(&m->ref_count, &r, + r & (VPRC_BLOCKED | VPRC_OBJREF)) == 0) + ; + } VM_OBJECT_WUNLOCK(obj); vm_object_deallocate(obj); }