The arguments to the free_initial_memory_range() call specify a memory range
beyond the end of system RAM. Subtract the reserved boot memory size from the
physical memory size so we don't exceed the end of physical RAM.

Signed-off-by: Stewart Hildebrand <[email protected]>
---
 arch/aarch64/arch-setup.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/aarch64/arch-setup.cc b/arch/aarch64/arch-setup.cc
index 30fb0db6..6aff9580 100644
--- a/arch/aarch64/arch-setup.cc
+++ b/arch/aarch64/arch-setup.cc
@@ -81,7 +81,8 @@ void arch_setup_free_memory()
     extern void *elf_start;
 
     mmu::phys addr = (mmu::phys)elf_start + elf_size;
-    mmu::free_initial_memory_range(addr, memory::phys_mem_size);
+    size_t reserved_size = addr - mmu::mem_addr;
+    mmu::free_initial_memory_range(addr, memory::phys_mem_size - 
reserved_size);
 
     /* linear_map [TTBR1] */
     for (auto&& area : mmu::identity_mapped_areas) {
-- 
2.30.0

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210217161838.77347-2-stewart.hildebrand%40dornerworks.com.

Reply via email to