Implement a vm_block_address_range() function which creates an area with no

mapped pages and a non-read and non-write protection to block a certain address
range from being used by anything.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33030 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2009-09-10 01:40:46 +00:00
parent 425cb3d716
commit 0f4242de40
2 changed files with 41 additions and 0 deletions

View File

@ -60,6 +60,7 @@ area_id create_area_etc(team_id team, const char *name, void **address,
area_id transfer_area(area_id id, void** _address, uint32 addressSpec,
team_id target, bool kernel);
status_t vm_block_address_range(const char* name, void* address, addr_t size);
status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
status_t vm_reserve_address_range(team_id team, void **_address,
uint32 addressSpec, addr_t size, uint32 flags);

View File

@ -1672,6 +1672,46 @@ err1:
}
status_t
vm_block_address_range(const char* name, void* address, addr_t size)
{
if (!arch_vm_supports_protection(0))
return B_NOT_SUPPORTED;
AddressSpaceWriteLocker locker;
status_t status = locker.SetTo(vm_kernel_address_space_id());
if (status != B_OK)
return status;
vm_address_space* addressSpace = locker.AddressSpace();
// create an anonymous cache
vm_cache* cache;
status = VMCacheFactory::CreateAnonymousCache(cache, false, 0, 0, false);
if (status != B_OK)
return status;
cache->temporary = 1;
cache->virtual_end = size;
cache->scan_skip = 1;
cache->Lock();
vm_area* area;
void *areaAddress = address;
status = map_backing_store(addressSpace, cache, &areaAddress, 0, size,
B_EXACT_ADDRESS, B_ALREADY_WIRED, 0, REGION_NO_PRIVATE_MAP, &area, name,
false, true);
if (status != B_OK) {
cache->ReleaseRefAndUnlock();
return status;
}
cache->Unlock();
area->cache_type = CACHE_TYPE_RAM;
return area->id;
}
status_t
vm_unreserve_address_range(team_id team, void* address, addr_t size)
{