Index: head/sys/vm/vm_map.c =================================================================== --- head/sys/vm/vm_map.c +++ head/sys/vm/vm_map.c @@ -2736,6 +2736,18 @@ if (current->eflags & MAP_ENTRY_IS_SUB_MAP) continue; + /* + * MADV_FREE would otherwise rewind time to + * the creation of the shadow object. Because + * we hold the VM map read-locked, neither the + * entry's object nor the presence of a + * backing object can change. + */ + if (behav == MADV_FREE && + current->object.vm_object != NULL && + current->object.vm_object->backing_object != NULL) + continue; + pstart = OFF_TO_IDX(current->offset); pend = pstart + atop(current->end - current->start); useStart = current->start;