bootloader: M68K: Fix mmu_free()
Same bug as in ARM code...
This commit is contained in:
parent
585830a55e
commit
b3025a8642
@ -373,18 +373,18 @@ mmu_free(void *virtualAddress, size_t size)
|
|||||||
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
||||||
|
|
||||||
addr_t address = (addr_t)virtualAddress;
|
addr_t address = (addr_t)virtualAddress;
|
||||||
size = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
|
addr_t pageOffset = address % B_PAGE_SIZE;
|
||||||
// get number of pages to map
|
address -= pageOffset;
|
||||||
|
size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE;
|
||||||
|
|
||||||
// is the address within the valid range?
|
// is the address within the valid range?
|
||||||
if (address < KERNEL_LOAD_BASE
|
if (address < KERNEL_LOAD_BASE || address + size > sNextVirtualAddress) {
|
||||||
|| address + size >= KERNEL_LOAD_BASE + kMaxKernelSize) {
|
|
||||||
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
||||||
(void *)address, size);
|
(void *)address, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmap all pages within the range
|
// 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);
|
unmap_page(address);
|
||||||
address += B_PAGE_SIZE;
|
address += B_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -373,18 +373,18 @@ mmu_free(void *virtualAddress, size_t size)
|
|||||||
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
||||||
|
|
||||||
addr_t address = (addr_t)virtualAddress;
|
addr_t address = (addr_t)virtualAddress;
|
||||||
size = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
|
addr_t pageOffset = address % B_PAGE_SIZE;
|
||||||
// get number of pages to map
|
address -= pageOffset;
|
||||||
|
size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE;
|
||||||
|
|
||||||
// is the address within the valid range?
|
// is the address within the valid range?
|
||||||
if (address < KERNEL_LOAD_BASE
|
if (address < KERNEL_LOAD_BASE || address + size > sNextVirtualAddress) {
|
||||||
|| address + size >= KERNEL_LOAD_BASE + kMaxKernelSize) {
|
|
||||||
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
||||||
(void *)address, size);
|
(void *)address, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmap all pages within the range
|
// 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);
|
unmap_page(address);
|
||||||
address += B_PAGE_SIZE;
|
address += B_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -374,17 +374,18 @@ mmu_free(void *virtualAddress, size_t size)
|
|||||||
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
TRACE(("mmu_free(virtualAddress = %p, size: %ld)\n", virtualAddress, size));
|
||||||
|
|
||||||
addr_t address = (addr_t)virtualAddress;
|
addr_t address = (addr_t)virtualAddress;
|
||||||
size = (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE;
|
addr_t pageOffset = address % B_PAGE_SIZE;
|
||||||
// get number of pages to map
|
address -= pageOffset;
|
||||||
|
size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE;
|
||||||
|
|
||||||
// is the address within the valid range?
|
// is the address within the valid range?
|
||||||
if (address < KERNEL_LOAD_BASE) {
|
if (address < KERNEL_LOAD_BASE || address + size > sNextVirtualAddress) {
|
||||||
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
||||||
(void *)address, size);
|
(void *)address, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmap all pages within the range
|
// 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);
|
unmap_page(address);
|
||||||
address += B_PAGE_SIZE;
|
address += B_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user