kernel/vm: Fix allocating virtual ranges downwards from the bottom.

Another regression from hrev58236: the code assigned start then size
previously, but there was another temporary that made things work
properly that was removed in that commit.

Fixes #18140.
This commit is contained in:
Augustin Cavalier
2024-10-15 12:12:21 -04:00
parent 64854db4af
commit 7a8e5c8c53
+2 -2
View File
@@ -4297,7 +4297,7 @@ allocate_early_virtual(kernel_args* args, size_t size, addr_t alignment)
const addr_t lastRangeEnd = lastRange.start + lastRange.size;
addr_t base = alignment > 0
? ROUNDUP(lastRangeEnd, alignment) : lastRangeEnd;
if (KERNEL_BASE + (KERNEL_SIZE - 1) - base >= size) {
if ((KERNEL_BASE + (KERNEL_SIZE - 1) - base) >= size) {
lastRange.size += base + size - lastRangeEnd;
return base;
}
@@ -4310,8 +4310,8 @@ allocate_early_virtual(kernel_args* args, size_t size, addr_t alignment)
base = ROUNDDOWN(base, alignment);
if (base >= KERNEL_BASE) {
firstRange.start = base;
firstRange.size += firstRange.start - base;
firstRange.start = base;
return base;
}
}