From 9e7df6ae5406f54712c85e8cd28ee7d27284742b Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Thu, 11 Dec 2025 04:24:45 -0600 Subject: [PATCH] Kernel.Vmm: Remove hack from #2726 (#3864) * Remove SceKernelInternalMemory mapping Contrary to my initial beliefs, this is very much a hack. * Unreachable for unpatched code This will always infinitely loop, making logs extremely large. * Update linker.cpp --- src/core/cpu_patches.cpp | 9 +++++---- src/core/linker.cpp | 11 ----------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index 2788cfe58..e303417c3 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -790,11 +790,12 @@ static bool PatchesIllegalInstructionHandler(void* context) { Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address); if (ZYAN_SUCCESS(status) && instruction.mnemonic == ZydisMnemonic::ZYDIS_MNEMONIC_UD2) [[unlikely]] { - UNREACHABLE_MSG("ud2 at code address {:#x}", (u64)code_address); + UNREACHABLE_MSG("ud2 at code address {:#x}", reinterpret_cast(code_address)); } - LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}", (u64)code_address, - ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic) - : "Failed to decode"); + UNREACHABLE_MSG("Failed to patch address {:x} -- mnemonic: {}", + reinterpret_cast(code_address), + ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic) + : "Failed to decode"); } } diff --git a/src/core/linker.cpp b/src/core/linker.cpp index ac6b37769..8d7f9207e 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -104,17 +104,6 @@ void Linker::Execute(const std::vector& args) { memory->SetupMemoryRegions(fmem_size, use_extended_mem1, use_extended_mem2); - // Simulate sceKernelInternalMemory mapping, a mapping usually performed during libkernel init. - // Due to the large size of this mapping, failing to emulate it causes issues in some titles. - // This mapping belongs in the system reserved area, which starts at address 0x880000000. - static constexpr VAddr KernelAllocBase = 0x880000000ULL; - static constexpr s64 InternalMemorySize = 0x1000000; - void* addr_out{reinterpret_cast(KernelAllocBase)}; - - s32 ret = Libraries::Kernel::sceKernelMapNamedFlexibleMemory(&addr_out, InternalMemorySize, 3, - 0, "SceKernelInternalMemory"); - ASSERT_MSG(ret == 0, "Unable to perform sceKernelInternalMemory mapping"); - main_thread.Run([this, module, &args](std::stop_token) { Common::SetCurrentThreadName("GAME_MainThread"); if (auto& ipc = IPC::Instance()) {