vm_map_protect(): move guard handling at the last phase into an empty dedicated helper
Restructure the first phase slightly, to facilitate further changes. Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41099
This commit is contained in:
parent
aa928a5216
commit
79169929f0
@ -2722,6 +2722,13 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot,
|
||||
VM_OBJECT_RUNLOCK(object);
|
||||
}
|
||||
|
||||
static void
|
||||
vm_map_protect_guard(vm_map_entry_t entry, vm_prot_t new_prot,
|
||||
vm_prot_t new_maxprot, int flags)
|
||||
{
|
||||
MPASS((entry->eflags & MAP_ENTRY_GUARD) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* vm_map_protect:
|
||||
*
|
||||
@ -2780,12 +2787,13 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
||||
check_prot |= new_maxprot;
|
||||
for (entry = first_entry; entry->start < end;
|
||||
entry = vm_map_entry_succ(entry)) {
|
||||
if ((entry->eflags & MAP_ENTRY_GUARD) != 0)
|
||||
continue;
|
||||
if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) {
|
||||
vm_map_unlock(map);
|
||||
return (KERN_INVALID_ARGUMENT);
|
||||
}
|
||||
if ((entry->eflags & MAP_ENTRY_GUARD) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (!CONTAINS_BITS(entry->max_protection, check_prot)) {
|
||||
vm_map_unlock(map);
|
||||
return (KERN_PROTECTION_FAILURE);
|
||||
@ -2884,10 +2892,15 @@ vm_map_protect(vm_map_t map, vm_offset_t start, vm_offset_t end,
|
||||
entry->start < end;
|
||||
vm_map_try_merge_entries(map, prev_entry, entry),
|
||||
prev_entry = entry, entry = vm_map_entry_succ(entry)) {
|
||||
if (rv != KERN_SUCCESS ||
|
||||
(entry->eflags & MAP_ENTRY_GUARD) != 0)
|
||||
if (rv != KERN_SUCCESS)
|
||||
continue;
|
||||
|
||||
if ((entry->eflags & MAP_ENTRY_GUARD) != 0) {
|
||||
vm_map_protect_guard(entry, new_prot, new_maxprot,
|
||||
flags);
|
||||
continue;
|
||||
}
|
||||
|
||||
old_prot = entry->protection;
|
||||
|
||||
if ((flags & VM_MAP_PROTECT_SET_MAXPROT) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user