From 1bc6f422c58c7a35edc6d45f05ee5d6d78bee599 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Tue, 23 Apr 2024 23:47:52 -0700 Subject: [PATCH] [kernel] Fix a bug with auto-assigned VMA addresses When calling vma_map or vma_create_map with an address of 0, the kernel would return colliding addresses. --- src/kernel/vm_space.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/kernel/vm_space.cpp b/src/kernel/vm_space.cpp index 1172af4..b380995 100644 --- a/src/kernel/vm_space.cpp +++ b/src/kernel/vm_space.cpp @@ -86,8 +86,6 @@ vm_space::add(uintptr_t base, obj::vm_area *area, util::bitset32 flags) if (!base) base = min_auto_address; - uintptr_t end = base + area->size(); - //TODO: optimize find/insert bool exact = flags.get(vm_flags::exact); for (size_t i = 0; i < m_areas.count(); ++i) { @@ -96,6 +94,7 @@ vm_space::add(uintptr_t base, obj::vm_area *area, util::bitset32 flags) if (base >= aend) continue; + uintptr_t end = base + area->size(); if (end <= a.base) break; else if (exact)