Fix Mprotect on free memory

On real hardware, this just does nothing. If something did get protected, there's no way to query that information.
Therefore, it seems pretty safe to just behave like munmap and return size here.
This commit is contained in:
Stephen Miller 2025-05-27 11:40:25 -05:00
parent 5f6bf3a445
commit a6ec84b493

View File

@ -563,8 +563,9 @@ s64 MemoryManager::ProtectBytes(VAddr addr, VirtualMemoryArea vma_base, size_t s
vma_base.size - start_in_vma < size ? vma_base.size - start_in_vma : size;
if (vma_base.type == VMAType::Free) {
LOG_ERROR(Kernel_Vmm, "Cannot change protection on free memory region");
return ORBIS_KERNEL_ERROR_EINVAL;
// On PS4, protecting freed memory does nothing.
LOG_WARNING(Kernel_Vmm, "Attempting to protect free memory");
return adjusted_size;
}
// Validate protection flags