diff options
| author | Maufeat <sahyno1996@gmail.com> | 2026-02-07 22:59:38 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-02-07 22:59:38 +0100 |
| commit | e544cb3cf6702fdec9ce2edc9f601a9e37d91153 (patch) | |
| tree | 191b12e960651ee6de6d389cb922a30607fe2963 /src/core/hle/kernel | |
| parent | ca9f2d43beeb03ca2127a21ef34ead9f497bcb03 (diff) | |
[nce] add split patch mode to support modules bigger than 128MB (#3489)
nce patcher was extended to support modules larger than 128MB due to ARM64 branch limit. now added a pre-patch and (existing) post-patch module code. Allowwing MRS/MSR/SVC handler to remain within branch branch range
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3489
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Co-authored-by: Maufeat <sahyno1996@gmail.com>
Co-committed-by: Maufeat <sahyno1996@gmail.com>
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/code_set.h | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_process.cpp | 11 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/core/hle/kernel/code_set.h b/src/core/hle/kernel/code_set.h index 4d2d0098e7..1416fc52b1 100644 --- a/src/core/hle/kernel/code_set.h +++ b/src/core/hle/kernel/code_set.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -83,6 +86,14 @@ struct CodeSet final { const Segment& PatchSegment() const { return patch_segment; } + + Segment& PostPatchSegment() { + return post_patch_segment; + } + + const Segment& PostPatchSegment() const { + return post_patch_segment; + } #endif /// The overall data that backs this code set. @@ -93,6 +104,7 @@ struct CodeSet final { #ifdef HAS_NCE Segment patch_segment; + Segment post_patch_segment; #endif /// The entry point address for this code set. diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 082049f957..bd50f74c27 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project @@ -1258,6 +1258,7 @@ void KProcess::LoadModule(CodeSet code_set, KProcessAddress base_addr) { #ifdef HAS_NCE const auto& patch = code_set.PatchSegment(); + const auto& post_patch = code_set.PostPatchSegment(); if (this->IsApplication() && Settings::IsNceEnabled() && patch.size != 0) { auto& buffer = m_kernel.System().DeviceMemory().buffer; const auto& code = code_set.CodeSegment(); @@ -1265,7 +1266,15 @@ void KProcess::LoadModule(CodeSet code_set, KProcessAddress base_addr) { Common::MemoryPermission::Read | Common::MemoryPermission::Execute); buffer.Protect(GetInteger(base_addr + patch.addr), patch.size, Common::MemoryPermission::Read | Common::MemoryPermission::Execute); + // Protect post-patch segment if it exists like abve + if (post_patch.size != 0) { + buffer.Protect(GetInteger(base_addr + post_patch.addr), post_patch.size, + Common::MemoryPermission::Read | Common::MemoryPermission::Execute); + } ReprotectSegment(code_set.PatchSegment(), Svc::MemoryPermission::None); + if (post_patch.size != 0) { + ReprotectSegment(code_set.PostPatchSegment(), Svc::MemoryPermission::None); + } } #endif } |
