summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/vm/vm_mmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 2071cc7..c912678 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -579,6 +579,7 @@ munmap(td, uap)
* Inform hwpmc if the address range being unmapped contains
* an executable region.
*/
+ pkm.pm_address = (uintptr_t) NULL;
if (vm_map_lookup_entry(map, addr, &entry)) {
for (;
entry != &map->header && entry->start < addr + size;
@@ -587,16 +588,23 @@ munmap(td, uap)
entry->end, VM_PROT_EXECUTE) == TRUE) {
pkm.pm_address = (uintptr_t) addr;
pkm.pm_size = (size_t) size;
- PMC_CALL_HOOK(td, PMC_FN_MUNMAP,
- (void *) &pkm);
break;
}
}
}
#endif
- /* returns nothing but KERN_SUCCESS anyway */
vm_map_delete(map, addr, addr + size);
+
+#ifdef HWPMC_HOOKS
+ /* downgrade the lock to prevent a LOR with the pmc-sx lock */
+ vm_map_lock_downgrade(map);
+ if (pkm.pm_address != (uintptr) NULL)
+ PMC_CALL_HOOK(td, PMC_FN_MUNMAP, (void *) &pkm);
+ vm_map_unlock_read(map);
+#else
vm_map_unlock(map);
+#endif
+ /* vm_map_delete returns nothing but KERN_SUCCESS anyway */
return (0);
}
OpenPOWER on IntegriCloud