From ead5978b34561eb3a709dfd0c61169e9c2c036a2 Mon Sep 17 00:00:00 2001 From: JPikachu Date: Fri, 31 Oct 2025 19:49:37 +0100 Subject: [kernel] Implement code address offset for Skyline compatibility (#2858) - Add debug logging for 32-bit syscall argument tracking. - Add CodeStartOffset constant (0x500000) applied to only 32-bit code address space types in KProcess::LoadFromMetadata. - Replace CheckMemoryStateContiguous with two-stage CheckMemoryState in KPageTableBase::UnmapCodeMemory to discover and verify memory state more accurately. Based on similar fixes in Ryujinx (commit 5e9678c8fe) Fixes compatibility with: - Skyline 32-bit modding framework - CTGP-DX (Mario Kart 8 Deluxe mod) - Other homebrew using 32bit Skyline Co-authored-by: JPikachu Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2858 Reviewed-by: Shinmegumi Reviewed-by: Caio Oliveira Reviewed-by: Lizzie Co-authored-by: JPikachu Co-committed-by: JPikachu --- src/core/hle/kernel/k_process.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/k_process.cpp') diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 51f86b2afd..355a2a5f3b 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -28,6 +28,9 @@ namespace Kernel { namespace { +// TODO: Remove this workaround when proper ASLR is implemented for all address spaces. +constexpr u64 CodeStartOffset = 0x500000UL; + Result TerminateChildren(KernelCore& kernel, KProcess* process, const KThread* thread_to_not_terminate) { // Request that all children threads terminate. @@ -1198,11 +1201,11 @@ Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std: break; case FileSys::ProgramAddressSpaceType::Is32Bit: flag |= Svc::CreateProcessFlag::AddressSpace32Bit; - code_address = 0x20'0000; + code_address = 0x20'0000 + CodeStartOffset; break; case FileSys::ProgramAddressSpaceType::Is32BitNoMap: flag |= Svc::CreateProcessFlag::AddressSpace32BitWithoutAlias; - code_address = 0x20'0000; + code_address = 0x20'0000 + CodeStartOffset; break; } -- cgit v1.2.3