[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.
This commit is contained in:
Justin C. Miller
2024-04-23 23:47:52 -07:00
parent 4909d15c20
commit 1bc6f422c5

View File

@@ -86,8 +86,6 @@ vm_space::add(uintptr_t base, obj::vm_area *area, util::bitset32 flags)
if (!base) if (!base)
base = min_auto_address; base = min_auto_address;
uintptr_t end = base + area->size();
//TODO: optimize find/insert //TODO: optimize find/insert
bool exact = flags.get(vm_flags::exact); bool exact = flags.get(vm_flags::exact);
for (size_t i = 0; i < m_areas.count(); ++i) { 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) if (base >= aend)
continue; continue;
uintptr_t end = base + area->size();
if (end <= a.base) if (end <= a.base)
break; break;
else if (exact) else if (exact)