* Reserved areas would also be created in existing reserved areas in case the
space was becoming tight. This actually fixes #4778. * Fixed overflow problem in find_reserved_area(). * Cleaned up the test app, added license. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1022,8 +1022,8 @@ find_reserved_area(vm_address_space* addressSpace, addr_t start,
|
|||||||
next = addressSpace->areas;
|
next = addressSpace->areas;
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
if (next->base <= start
|
if (next->base <= start
|
||||||
&& next->base + next->size > start + (size - 1)) {
|
&& next->base + (next->size - 1) >= start + (size - 1)) {
|
||||||
// this area covers the requested range
|
// This area covers the requested range
|
||||||
if (next->id != RESERVED_AREA_ID) {
|
if (next->id != RESERVED_AREA_ID) {
|
||||||
// but it's not reserved space, it's a real area
|
// but it's not reserved space, it's a real area
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1039,7 +1039,7 @@ find_reserved_area(vm_address_space* addressSpace, addr_t start,
|
|||||||
if (next == NULL)
|
if (next == NULL)
|
||||||
return B_ENTRY_NOT_FOUND;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
// now we have to transfer the requested part of the reserved
|
// Now we have to transfer the requested part of the reserved
|
||||||
// range to the new area - and remove, resize or split the old
|
// range to the new area - and remove, resize or split the old
|
||||||
// reserved area.
|
// reserved area.
|
||||||
|
|
||||||
@@ -1126,7 +1126,7 @@ find_and_insert_area_slot(vm_address_space* addressSpace, addr_t start,
|
|||||||
|| start + (size - 1) > end)
|
|| start + (size - 1) > end)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
if (addressSpec == B_EXACT_ADDRESS) {
|
if (addressSpec == B_EXACT_ADDRESS && area->id != RESERVED_AREA_ID) {
|
||||||
// search for a reserved area
|
// search for a reserved area
|
||||||
status_t status = find_reserved_area(addressSpace, start, size, area);
|
status_t status = find_reserved_area(addressSpace, start, size, area);
|
||||||
if (status == B_OK || status == B_BAD_VALUE)
|
if (status == B_OK || status == B_BAD_VALUE)
|
||||||
@@ -1206,7 +1206,7 @@ second_chance:
|
|||||||
foundSpot = true;
|
foundSpot = true;
|
||||||
area->base = alignedBase;
|
area->base = alignedBase;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else if (area->id != RESERVED_AREA_ID) {
|
||||||
// We didn't find a free spot - if there are any reserved areas,
|
// We didn't find a free spot - if there are any reserved areas,
|
||||||
// we can now test those for free space
|
// we can now test those for free space
|
||||||
// TODO: it would make sense to start with the biggest of them
|
// TODO: it would make sense to start with the biggest of them
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Test application that reproduces bug #4778.
|
//! Test application that reproduces bug #4778.
|
||||||
|
|
||||||
|
|
||||||
@@ -43,18 +49,17 @@ area_creator(void*)
|
|||||||
base = (void*)0x60000000;
|
base = (void*)0x60000000;
|
||||||
status = _kern_reserve_address_range((addr_t*)&base, B_BASE_ADDRESS,
|
status = _kern_reserve_address_range((addr_t*)&base, B_BASE_ADDRESS,
|
||||||
128 * 1024 * 1024);
|
128 * 1024 * 1024);
|
||||||
if (status != B_OK)
|
|
||||||
snooze(10000000LL);
|
|
||||||
addressSpec = status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS;
|
addressSpec = status == B_OK ? B_EXACT_ADDRESS : B_BASE_ADDRESS;
|
||||||
printf("\naddress spec = %lx, base %p (status %s)\n", addressSpec, base, strerror(status));
|
printf("\naddress spec = %lx, base %p (status %s)\n", addressSpec,
|
||||||
|
base, strerror(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
area_id area = create_area(readOnly ? "read-only memory" : "r/w memory",
|
area_id area = create_area(readOnly ? "read-only memory" : "r/w memory",
|
||||||
&base, addressSpec, B_PAGE_SIZE * 4, B_NO_LOCK,
|
&base, addressSpec, B_PAGE_SIZE * 4, B_NO_LOCK,
|
||||||
B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA));
|
B_READ_AREA | (readOnly ? 0 : B_WRITE_AREA));
|
||||||
if (area >= 0) {
|
if (area >= 0) {
|
||||||
printf("new %s area %ld at %p\n", readOnly ? "read-only" : "r/w", area, base);
|
printf("new %s area %ld at %p\n", readOnly ? "read-only" : "r/w",
|
||||||
// putchar('#');
|
area, base);
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user