Only iterate to next VMA if we're past the current VMA. (#4158)

It's possible we're merging with a later memory area. If that occurred here, we would end up iterating past where we need to be, which then messes up logic.
This commit is contained in:
Stephen Miller 2026-03-21 05:02:17 -05:00 committed by GitHub
parent 2bb20e4650
commit 0a722d69e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1223,13 +1223,16 @@ s32 MemoryManager::SetDirectMemoryType(VAddr addr, u64 size, s32 memory_type) {
// Increment phys_handle
phys_handle++;
}
// Check if VMA can be merged with adjacent areas after physical area modifications.
vma_handle = MergeAdjacent(vma_map, vma_handle);
}
current_addr += size_in_vma;
remaining_size -= size_in_vma;
vma_handle++;
// Check if VMA can be merged with adjacent areas after modifications.
vma_handle = MergeAdjacent(vma_map, vma_handle);
if (vma_handle->second.base + vma_handle->second.size <= current_addr) {
// If we're now in the next VMA, then go to the next handle.
vma_handle++;
}
}
return ORBIS_OK;
@ -1262,10 +1265,15 @@ void MemoryManager::NameVirtualRange(VAddr virtual_addr, u64 size, std::string_v
vma.name = name;
}
}
it = MergeAdjacent(vma_map, it);
remaining_size -= size_in_vma;
current_addr += size_in_vma;
it++;
// Check if VMA can be merged with adjacent areas after modifications.
it = MergeAdjacent(vma_map, it);
if (it->second.base + it->second.size <= current_addr) {
// If we're now in the next VMA, then go to the next handle.
it++;
}
}
}