kernel/{x86, vm}: Add more error checks in VM initialization

This commit is contained in:
Pawel Dziepak
2014-01-27 05:36:30 +01:00
parent 931ce674a9
commit 819824e020
3 changed files with 14 additions and 0 deletions
@@ -101,6 +101,11 @@ X86PagingMethod32Bit::PhysicalPageSlotPool::InitInitial(kernel_args* args)
size_t areaSize = B_PAGE_SIZE + sizeof(PhysicalPageSlot[1024]);
page_table_entry* pageTable = (page_table_entry*)vm_allocate_early(args,
areaSize, ~0L, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0);
if (pageTable == 0) {
panic("X86PagingMethod32Bit::PhysicalPageSlotPool::InitInitial(): "
"Failed to allocate memory for page table!");
return B_ERROR;
}
// prepare the page table
_EarlyPreparePageTables(pageTable, virtualBase, 1024 * B_PAGE_SIZE);
@@ -409,6 +409,11 @@ X86PagingMethodPAE::PhysicalPageSlotPool::InitInitial(
+ sizeof(PhysicalPageSlot[kPAEPageTableEntryCount]);
pae_page_table_entry* pageTable = (pae_page_table_entry*)vm_allocate_early(
args, areaSize, ~0L, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0);
if (pageTable == 0) {
panic("X86PagingMethodPAE::PhysicalPageSlotPool::InitInitial(): Failed "
"to allocate memory for page table!");
return B_ERROR;
}
// clear the page table and put it in the page dir
memset(pageTable, 0, B_PAGE_SIZE);
+4
View File
@@ -3910,6 +3910,10 @@ vm_allocate_early(kernel_args* args, size_t virtualSize, size_t physicalSize,
// find the vaddr to allocate at
addr_t virtualBase = allocate_early_virtual(args, virtualSize, alignment);
//dprintf("vm_allocate_early: vaddr 0x%lx\n", virtualBase);
if (virtualBase == 0) {
panic("vm_allocate_early: could not allocate virtual address\n");
return 0;
}
// map the pages
for (uint32 i = 0; i < PAGE_ALIGN(physicalSize) / B_PAGE_SIZE; i++) {