From 8588e7fc6fbde8afd9d81ae3dca6a19d20fdb9dd Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 5 May 2010 21:15:33 +0000 Subject: [PATCH] Fixed broken mmu_allocate_physical(): * Now it checks whether the given physical range exists at all. * Not only check whether any range of the given size is free, but also check whether the given range is free. * B_BAD_VALUE is not a particularly good return value for a function supposed to return a bool Fixes #5911. With only 64 MB RAM the usual debug syslog buffer location may be outside the actually existing physical memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36632 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/bios_ia32/mmu.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index 8e324dbc5f..1bed6df7b6 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -450,11 +450,18 @@ mmu_allocate(void *virtualAddress, size_t size) bool mmu_allocate_physical(addr_t base, size_t size) { + // check whether the physical memory range exists at all + if (!is_address_range_covered(gKernelArgs.physical_memory_range, + gKernelArgs.num_physical_memory_ranges, base, size)) { + return false; + } + + // check whether the physical range is still free addr_t foundBase; if (!get_free_address_range(gKernelArgs.physical_allocated_range, gKernelArgs.num_physical_allocated_ranges, sNextPhysicalAddress, - size, &foundBase)) { - return B_BAD_VALUE; + size, &foundBase) || foundBase != base) { + return false; } return insert_physical_allocated_range(base, size) == B_OK; @@ -717,7 +724,7 @@ mmu_init(void) } } else { bios_regs regs; - + // We dont have an extended map, assume memory is contiguously mapped // at 0x0, but leave out the BIOS range ((640k - 1 page) to 1 MB). gKernelArgs.physical_memory_range[0].start = 0;