mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-22 03:15:01 +00:00
Fix VirtualQuery behavior on low addresses.
This commit is contained in:
parent
6c39bf229c
commit
3ce991f9d2
2 changed files with 9 additions and 4 deletions
|
@ -126,9 +126,6 @@ s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchE
|
|||
s32 PS4_SYSV_ABI sceKernelVirtualQuery(const void* addr, int flags, OrbisVirtualQueryInfo* info,
|
||||
size_t infoSize) {
|
||||
LOG_INFO(Kernel_Vmm, "called addr = {}, flags = {:#x}", fmt::ptr(addr), flags);
|
||||
if (!addr) {
|
||||
return ORBIS_KERNEL_ERROR_EACCES;
|
||||
}
|
||||
auto* memory = Core::Memory::Instance();
|
||||
return memory->VirtualQuery(std::bit_cast<VAddr>(addr), flags, info);
|
||||
}
|
||||
|
|
|
@ -571,7 +571,15 @@ int MemoryManager::VirtualQuery(VAddr addr, int flags,
|
|||
::Libraries::Kernel::OrbisVirtualQueryInfo* info) {
|
||||
std::scoped_lock lk{mutex};
|
||||
|
||||
auto it = FindVMA(addr);
|
||||
// FindVMA on addresses before the vma_map return garbage data.
|
||||
auto query_addr = addr < impl.SystemManagedVirtualBase() ?
|
||||
impl.SystemManagedVirtualBase() : addr;
|
||||
if (addr < query_addr && flags == 0) {
|
||||
LOG_WARNING(Kernel_Vmm, "VirtualQuery on free memory region");
|
||||
return ORBIS_KERNEL_ERROR_EACCES;
|
||||
}
|
||||
auto it = FindVMA(query_addr);
|
||||
|
||||
if (it->second.type == VMAType::Free && flags == 1) {
|
||||
++it;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue