* vm_map_delete: [ internal use only ] * * Deallocates the given address range from the target * map. */
| 3929 | * map. |
| 3930 | */ |
| 3931 | int |
| 3932 | vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) |
| 3933 | { |
| 3934 | vm_map_entry_t entry, next_entry, scratch_entry; |
| 3935 | int rv; |
| 3936 | |
| 3937 | VM_MAP_ASSERT_LOCKED(map); |
| 3938 | |
| 3939 | if (start == end) |
| 3940 | return (KERN_SUCCESS); |
| 3941 | |
| 3942 | /* |
| 3943 | * Find the start of the region, and clip it. |
| 3944 | * Step through all entries in this region. |
| 3945 | */ |
| 3946 | rv = vm_map_lookup_clip_start(map, start, &entry, &scratch_entry); |
| 3947 | if (rv != KERN_SUCCESS) |
| 3948 | return (rv); |
| 3949 | for (; entry->start < end; entry = next_entry) { |
| 3950 | /* |
| 3951 | * Wait for wiring or unwiring of an entry to complete. |
| 3952 | * Also wait for any system wirings to disappear on |
| 3953 | * user maps. |
| 3954 | */ |
| 3955 | if ((entry->eflags & MAP_ENTRY_IN_TRANSITION) != 0 || |
| 3956 | (vm_map_pmap(map) != kernel_pmap && |
| 3957 | vm_map_entry_system_wired_count(entry) != 0)) { |
| 3958 | unsigned int last_timestamp; |
| 3959 | vm_offset_t saved_start; |
| 3960 | |
| 3961 | saved_start = entry->start; |
| 3962 | entry->eflags |= MAP_ENTRY_NEEDS_WAKEUP; |
| 3963 | last_timestamp = map->timestamp; |
| 3964 | (void) vm_map_unlock_and_wait(map, 0); |
| 3965 | vm_map_lock(map); |
| 3966 | if (last_timestamp + 1 != map->timestamp) { |
| 3967 | /* |
| 3968 | * Look again for the entry because the map was |
| 3969 | * modified while it was unlocked. |
| 3970 | * Specifically, the entry may have been |
| 3971 | * clipped, merged, or deleted. |
| 3972 | */ |
| 3973 | rv = vm_map_lookup_clip_start(map, saved_start, |
| 3974 | &next_entry, &scratch_entry); |
| 3975 | if (rv != KERN_SUCCESS) |
| 3976 | break; |
| 3977 | } else |
| 3978 | next_entry = entry; |
| 3979 | continue; |
| 3980 | } |
| 3981 | |
| 3982 | /* XXXKIB or delete to the upper superpage boundary ? */ |
| 3983 | rv = vm_map_clip_end(map, entry, end); |
| 3984 | if (rv != KERN_SUCCESS) |
| 3985 | break; |
| 3986 | next_entry = vm_map_entry_succ(entry); |
| 3987 | |
| 3988 | /* |
no test coverage detected