VERY experimental Nintendo Switch 2 emulator
C++
kernel: restrict nce to applications
Liama7ff872a4cce
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cppindex 2bfb71b3ad..d6869c2287 100644--- a/src/core/hle/kernel/k_process.cpp+++ b/src/core/hle/kernel/k_process.cpp@@ -1233,7 +1233,7 @@ void KProcess::LoadModule(CodeSet code_set, KProcessAddress base_addr) {ReprotectSegment(code_set.DataSegment(), Svc::MemoryPermission::ReadWrite);#ifdef HAS_NCE- if (Settings::IsNceEnabled()) {+ if (this->IsApplication() && Settings::IsNceEnabled()) {auto& buffer = m_kernel.System().DeviceMemory().buffer;const auto& code = code_set.CodeSegment();const auto& patch = code_set.PatchSegment();@@ -1249,7 +1249,7 @@ void KProcess::InitializeInterfaces() {Core::MakeExclusiveMonitor(this->GetMemory(), Core::Hardware::NUM_CPU_CORES);#ifdef HAS_NCE- if (this->Is64Bit() && Settings::IsNceEnabled()) {+ if (this->IsApplication() && Settings::IsNceEnabled()) {for (size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {m_arm_interfaces[i] = std::make_unique<Core::ArmNce>(m_kernel.System(), true, i);}diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cppindex ada9987722..231e4d0e1b 100644--- a/src/core/hle/kernel/svc/svc_info.cpp+++ b/src/core/hle/kernel/svc/svc_info.cpp@@ -118,7 +118,6 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, HandleR_SUCCEED();case InfoType::IsApplication:- LOG_WARNING(Kernel_SVC, "(STUBBED) Assuming process is application");*result = process->IsApplication();R_SUCCEED();diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cppindex 60ee78e89a..c9f8707b75 100644--- a/src/core/loader/deconstructed_rom_directory.cpp+++ b/src/core/loader/deconstructed_rom_directory.cpp@@ -129,9 +129,10 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect}metadata.Print();- // Enable NCE only for programs with 39-bit address space.+ // Enable NCE only for applications with 39-bit address space.const bool is_39bit =metadata.GetAddressSpaceType() == FileSys::ProgramAddressSpaceType::Is39Bit;+ const bool is_application = metadata.GetPoolPartition() == FileSys::PoolPartition::Application;Settings::SetNceEnabled(is_39bit);const std::array static_modules = {"rtld", "main", "subsdk0", "subsdk1", "subsdk2",@@ -147,7 +148,7 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirectconst auto GetPatcher = [&](size_t i) -> Core::NCE::Patcher* {#ifdef HAS_NCE- if (Settings::IsNceEnabled()) {+ if (is_application && Settings::IsNceEnabled()) {return &module_patchers[i];}#endif@@ -175,7 +176,7 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect// Enable direct memory mapping in case of NCE.const u64 fastmem_base = [&]() -> size_t {- if (Settings::IsNceEnabled()) {+ if (is_application && Settings::IsNceEnabled()) {auto& buffer = system.DeviceMemory().buffer;buffer.EnableDirectMappedAddress();return reinterpret_cast<u64>(buffer.VirtualBasePointer());