Skip to content

Commit

Permalink
bootloader: ARM: Fix mmu_free()
Browse files Browse the repository at this point in the history
Allocation size was mixed up with page counts...
Allow freeing up to sNextVirtualAddress.
  • Loading branch information
mmuman committed Oct 26, 2013
1 parent 9703c9c commit 1804178
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/system/boot/arch/arm/arch_mmu.cpp
Expand Up @@ -513,18 +513,18 @@ mmu_free(void *virtualAddress, size_t size)
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));

addr_t address = (addr_t)virtualAddress;
size = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
// get number of pages to map
addr_t pageOffset = address % B_PAGE_SIZE;
address -= pageOffset;
size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE;

// is the address within the valid range?
if (address < KERNEL_BASE
|| address + size >= KERNEL_BASE + kMaxKernelSize) {
if (address < KERNEL_LOAD_BASE || address + size > sNextVirtualAddress) {
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
(void *)address, size);
}

// unmap all pages within the range
for (uint32 i = 0; i < size; i++) {
for (size_t i = 0; i < size; i += B_PAGE_SIZE) {
unmap_page(address);
address += B_PAGE_SIZE;
}
Expand Down

0 comments on commit 1804178

Please sign in to comment.