Only the to be protected range needs to be non-wired.
When setting memory protection, only ensure/wait for the range that needs to be protected to not be wired instead of requiering the whole area to be non-wired. The memory protection is done page wise and having some parts of the area wired shouldn't preclude other parts to be protected.
This commit is contained in:
@@ -6261,15 +6261,6 @@ _user_set_memory_protection(void* _address, size_t size, uint32 protection)
|
|||||||
if ((area->protection & B_KERNEL_AREA) != 0)
|
if ((area->protection & B_KERNEL_AREA) != 0)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
AreaCacheLocker cacheLocker(area);
|
|
||||||
|
|
||||||
if (wait_if_area_is_wired(area, &locker, &cacheLocker)) {
|
|
||||||
restart = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheLocker.Unlock();
|
|
||||||
|
|
||||||
// TODO: For (shared) mapped files we should check whether the new
|
// TODO: For (shared) mapped files we should check whether the new
|
||||||
// protections are compatible with the file permissions. We don't
|
// protections are compatible with the file permissions. We don't
|
||||||
// have a way to do that yet, though.
|
// have a way to do that yet, though.
|
||||||
@@ -6277,6 +6268,16 @@ _user_set_memory_protection(void* _address, size_t size, uint32 protection)
|
|||||||
addr_t offset = currentAddress - area->Base();
|
addr_t offset = currentAddress - area->Base();
|
||||||
size_t rangeSize = min_c(area->Size() - offset, sizeLeft);
|
size_t rangeSize = min_c(area->Size() - offset, sizeLeft);
|
||||||
|
|
||||||
|
AreaCacheLocker cacheLocker(area);
|
||||||
|
|
||||||
|
if (wait_if_area_range_is_wired(area, currentAddress, rangeSize,
|
||||||
|
&locker, &cacheLocker)) {
|
||||||
|
restart = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheLocker.Unlock();
|
||||||
|
|
||||||
currentAddress += rangeSize;
|
currentAddress += rangeSize;
|
||||||
sizeLeft -= rangeSize;
|
sizeLeft -= rangeSize;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user