From 7d82b5d4abbc89f66396bf199dc7c4fa0983545c Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sun, 12 Apr 2015 17:52:24 +0200 Subject: [PATCH] arm/mmu: Fix boot on beagle-xm * The changes for pi2 support led to the virtual addresses overlapping with the page table again on the beagle, because the kernel address space overlaps with the physical RAM identity mapped. Try to find a memory range in a way that will work in both cases. --- src/system/boot/arch/arm/arch_mmu.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp index 35ea106541..6dac993dce 100644 --- a/src/system/boot/arch/arm/arch_mmu.cpp +++ b/src/system/boot/arch/arm/arch_mmu.cpp @@ -668,7 +668,8 @@ mmu_init(void) return /*B_ERROR*/; #endif } - dprintf("total physical memory = %" B_PRId64 "MB\n", total / (1024 * 1024)); + dprintf("total physical memory = %" B_PRId64 "MB\n", + total / (1024 * 1024)); } // see if subpages are disabled @@ -685,10 +686,17 @@ mmu_init(void) // Mark start for dynamic allocation sNextPhysicalAddress = sPageTableRegionEnd; + // We are going to allocate early kernel stuff there, so the virtual address + // has to be in kernel space. Either put it right after the identity mapped + // RAM (if it happens to be in the 0x80000000 range), or at the start of + // the kernel address space otherwise. sNextVirtualAddress = KERNEL_LOAD_BASE + kMaxKernelSize; + if (sPageTableRegionEnd > sNextVirtualAddress) + sNextVirtualAddress = sPageTableRegionEnd; // mark allocated ranges, so they don't get overwritten - insert_physical_allocated_range((addr_t)&_start, (addr_t)&_end - (addr_t)&_start); + insert_physical_allocated_range((addr_t)&_start, + (addr_t)&_end - (addr_t)&_start); insert_physical_allocated_range((addr_t)sPageDirectory, 0x200000); init_page_directory();