vm: address-space: fix incorrect op calculation in unmap and release

This commit is contained in:
2026-03-24 20:23:46 +00:00
parent 4be642f2e5
commit 4daffa804c

View File

@@ -141,16 +141,16 @@ static struct vm_area *get_entry(
if (address < child->vma_base) { if (address < child->vma_base) {
next = btree_left(cur); next = btree_left(cur);
if (LEFT_DIFF(address, child)
< LEFT_DIFF(address, closest_left)) {
closest_left = child;
}
} else if (address > child->vma_limit) {
next = btree_right(cur);
if (RIGHT_DIFF(address, child) if (RIGHT_DIFF(address, child)
< RIGHT_DIFF(address, closest_right)) { < RIGHT_DIFF(address, closest_right)) {
closest_right = child; closest_right = child;
} }
} else if (address > child->vma_limit) {
next = btree_right(cur);
if (LEFT_DIFF(address, child)
< LEFT_DIFF(address, closest_left)) {
closest_left = child;
}
} else { } else {
result = child; result = child;
break; break;
@@ -995,9 +995,11 @@ kern_status_t address_space_unmap(
= (area_base <= unmap_base = (area_base <= unmap_base
&& area_limit >= unmap_limit); && area_limit >= unmap_limit);
bool left_reduce bool left_reduce
= (unmap_base <= area_base && unmap_limit < area_limit); = (unmap_base <= area_base && unmap_limit > area_base
&& unmap_limit < area_limit);
bool right_reduce bool right_reduce
= (unmap_base > area_base && unmap_limit >= area_limit); = (unmap_base > area_base && unmap_base < area_limit
&& unmap_limit >= area_limit);
if (split) { if (split) {
status = split_area( status = split_area(
@@ -1135,9 +1137,10 @@ kern_status_t address_space_release(
&& area_limit >= release_limit); && area_limit >= release_limit);
bool left_reduce bool left_reduce
= (release_base <= area_base = (release_base <= area_base
&& release_limit > area_base
&& release_limit < area_limit); && release_limit < area_limit);
bool right_reduce bool right_reduce
= (release_base > area_base = (release_base > area_base && release_base < area_limit
&& release_limit >= area_limit); && release_limit >= area_limit);
if (split) { if (split) {