diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/core/device_memory.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/code_set.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_address_space_info.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_page_table_base.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_process.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/physical_core.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 6 |
10 files changed, 26 insertions, 16 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c5805ec61..e0bfb5b95 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -926,7 +926,8 @@ if (ENABLE_WEB_SERVICE) | |||
| 926 | target_link_libraries(core PRIVATE web_service) | 926 | target_link_libraries(core PRIVATE web_service) |
| 927 | endif() | 927 | endif() |
| 928 | 928 | ||
| 929 | if (ARCHITECTURE_arm64) | 929 | if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")) |
| 930 | target_compile_definitions(core PRIVATE -DHAS_NCE) | ||
| 930 | enable_language(C ASM) | 931 | enable_language(C ASM) |
| 931 | set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") | 932 | set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") |
| 932 | 933 | ||
diff --git a/src/core/device_memory.cpp b/src/core/device_memory.cpp index 3a9151646..1aea56a99 100644 --- a/src/core/device_memory.cpp +++ b/src/core/device_memory.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | namespace Core { | 7 | namespace Core { |
| 8 | 8 | ||
| 9 | #ifdef ARCHITECTURE_arm64 | 9 | #ifdef HAS_NCE |
| 10 | constexpr size_t VirtualReserveSize = 1ULL << 38; | 10 | constexpr size_t VirtualReserveSize = 1ULL << 38; |
| 11 | #else | 11 | #else |
| 12 | constexpr size_t VirtualReserveSize = 1ULL << 39; | 12 | constexpr size_t VirtualReserveSize = 1ULL << 39; |
diff --git a/src/core/hle/kernel/code_set.h b/src/core/hle/kernel/code_set.h index d53da82f4..4d2d0098e 100644 --- a/src/core/hle/kernel/code_set.h +++ b/src/core/hle/kernel/code_set.h | |||
| @@ -75,6 +75,7 @@ struct CodeSet final { | |||
| 75 | return segments[2]; | 75 | return segments[2]; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | #ifdef HAS_NCE | ||
| 78 | Segment& PatchSegment() { | 79 | Segment& PatchSegment() { |
| 79 | return patch_segment; | 80 | return patch_segment; |
| 80 | } | 81 | } |
| @@ -82,13 +83,17 @@ struct CodeSet final { | |||
| 82 | const Segment& PatchSegment() const { | 83 | const Segment& PatchSegment() const { |
| 83 | return patch_segment; | 84 | return patch_segment; |
| 84 | } | 85 | } |
| 86 | #endif | ||
| 85 | 87 | ||
| 86 | /// The overall data that backs this code set. | 88 | /// The overall data that backs this code set. |
| 87 | Kernel::PhysicalMemory memory; | 89 | Kernel::PhysicalMemory memory; |
| 88 | 90 | ||
| 89 | /// The segments that comprise this code set. | 91 | /// The segments that comprise this code set. |
| 90 | std::array<Segment, 3> segments; | 92 | std::array<Segment, 3> segments; |
| 93 | |||
| 94 | #ifdef HAS_NCE | ||
| 91 | Segment patch_segment; | 95 | Segment patch_segment; |
| 96 | #endif | ||
| 92 | 97 | ||
| 93 | /// The entry point address for this code set. | 98 | /// The entry point address for this code set. |
| 94 | KProcessAddress entrypoint = 0; | 99 | KProcessAddress entrypoint = 0; |
diff --git a/src/core/hle/kernel/k_address_space_info.cpp b/src/core/hle/kernel/k_address_space_info.cpp index 3235a7a37..23258071e 100644 --- a/src/core/hle/kernel/k_address_space_info.cpp +++ b/src/core/hle/kernel/k_address_space_info.cpp | |||
| @@ -25,7 +25,7 @@ constexpr std::array<KAddressSpaceInfo, 13> AddressSpaceInfos{{ | |||
| 25 | { .bit_width = 36, .address = 2_GiB , .size = 64_GiB - 2_GiB , .type = KAddressSpaceInfo::Type::MapLarge, }, | 25 | { .bit_width = 36, .address = 2_GiB , .size = 64_GiB - 2_GiB , .type = KAddressSpaceInfo::Type::MapLarge, }, |
| 26 | { .bit_width = 36, .address = Size_Invalid, .size = 8_GiB , .type = KAddressSpaceInfo::Type::Heap, }, | 26 | { .bit_width = 36, .address = Size_Invalid, .size = 8_GiB , .type = KAddressSpaceInfo::Type::Heap, }, |
| 27 | { .bit_width = 36, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Alias, }, | 27 | { .bit_width = 36, .address = Size_Invalid, .size = 6_GiB , .type = KAddressSpaceInfo::Type::Alias, }, |
| 28 | #ifdef ARCHITECTURE_arm64 | 28 | #ifdef HAS_NCE |
| 29 | // With NCE, we use a 38-bit address space due to memory limitations. This should (safely) truncate ASLR region. | 29 | // With NCE, we use a 38-bit address space due to memory limitations. This should (safely) truncate ASLR region. |
| 30 | { .bit_width = 39, .address = 128_MiB , .size = 256_GiB - 128_MiB, .type = KAddressSpaceInfo::Type::Map39Bit, }, | 30 | { .bit_width = 39, .address = 128_MiB , .size = 256_GiB - 128_MiB, .type = KAddressSpaceInfo::Type::Map39Bit, }, |
| 31 | #else | 31 | #else |
diff --git a/src/core/hle/kernel/k_page_table_base.cpp b/src/core/hle/kernel/k_page_table_base.cpp index f7f1e8a3b..2b5e77ccf 100644 --- a/src/core/hle/kernel/k_page_table_base.cpp +++ b/src/core/hle/kernel/k_page_table_base.cpp | |||
| @@ -96,7 +96,7 @@ constexpr Common::MemoryPermission ConvertToMemoryPermission(KMemoryPermission p | |||
| 96 | if (True(perm & KMemoryPermission::UserWrite)) { | 96 | if (True(perm & KMemoryPermission::UserWrite)) { |
| 97 | perms |= Common::MemoryPermission::Write; | 97 | perms |= Common::MemoryPermission::Write; |
| 98 | } | 98 | } |
| 99 | #ifdef ARCHITECTURE_arm64 | 99 | #ifdef HAS_NCE |
| 100 | if (True(perm & KMemoryPermission::UserExecute)) { | 100 | if (True(perm & KMemoryPermission::UserExecute)) { |
| 101 | perms |= Common::MemoryPermission::Execute; | 101 | perms |= Common::MemoryPermission::Execute; |
| 102 | } | 102 | } |
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index e5f796ac7..d8cd0fdde 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h | |||
| @@ -112,7 +112,6 @@ private: | |||
| 112 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_pinned_threads{}; | 112 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> m_pinned_threads{}; |
| 113 | std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> m_watchpoints{}; | 113 | std::array<DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS> m_watchpoints{}; |
| 114 | std::map<KProcessAddress, u64> m_debug_page_refcounts{}; | 114 | std::map<KProcessAddress, u64> m_debug_page_refcounts{}; |
| 115 | std::unordered_map<u64, u64> m_post_handlers{}; | ||
| 116 | std::atomic<s64> m_cpu_time{}; | 115 | std::atomic<s64> m_cpu_time{}; |
| 117 | std::atomic<s64> m_num_process_switches{}; | 116 | std::atomic<s64> m_num_process_switches{}; |
| 118 | std::atomic<s64> m_num_thread_switches{}; | 117 | std::atomic<s64> m_num_thread_switches{}; |
| @@ -121,6 +120,9 @@ private: | |||
| 121 | std::atomic<s64> m_num_ipc_messages{}; | 120 | std::atomic<s64> m_num_ipc_messages{}; |
| 122 | std::atomic<s64> m_num_ipc_replies{}; | 121 | std::atomic<s64> m_num_ipc_replies{}; |
| 123 | std::atomic<s64> m_num_ipc_receives{}; | 122 | std::atomic<s64> m_num_ipc_receives{}; |
| 123 | #ifdef HAS_NCE | ||
| 124 | std::unordered_map<u64, u64> m_post_handlers{}; | ||
| 125 | #endif | ||
| 124 | 126 | ||
| 125 | private: | 127 | private: |
| 126 | Result StartTermination(); | 128 | Result StartTermination(); |
| @@ -468,9 +470,11 @@ public: | |||
| 468 | 470 | ||
| 469 | static void Switch(KProcess* cur_process, KProcess* next_process); | 471 | static void Switch(KProcess* cur_process, KProcess* next_process); |
| 470 | 472 | ||
| 473 | #ifdef HAS_NCE | ||
| 471 | std::unordered_map<u64, u64>& GetPostHandlers() noexcept { | 474 | std::unordered_map<u64, u64>& GetPostHandlers() noexcept { |
| 472 | return m_post_handlers; | 475 | return m_post_handlers; |
| 473 | } | 476 | } |
| 477 | #endif | ||
| 474 | 478 | ||
| 475 | public: | 479 | public: |
| 476 | // Attempts to insert a watchpoint into a free slot. Returns false if none are available. | 480 | // Attempts to insert a watchpoint into a free slot. Returns false if none are available. |
diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 15434212e..073039825 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 5 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | 5 | #include "core/arm/dynarmic/arm_dynarmic_32.h" |
| 6 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | 6 | #include "core/arm/dynarmic/arm_dynarmic_64.h" |
| 7 | #ifdef ARCHITECTURE_arm64 | 7 | #ifdef HAS_NCE |
| 8 | #include "core/arm/nce/arm_nce.h" | 8 | #include "core/arm/nce/arm_nce.h" |
| 9 | #endif | 9 | #endif |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| @@ -33,7 +33,7 @@ PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system, KSchedu | |||
| 33 | PhysicalCore::~PhysicalCore() = default; | 33 | PhysicalCore::~PhysicalCore() = default; |
| 34 | 34 | ||
| 35 | void PhysicalCore::Initialize(bool is_64_bit) { | 35 | void PhysicalCore::Initialize(bool is_64_bit) { |
| 36 | #if defined(ARCHITECTURE_arm64) | 36 | #if defined(HAS_NCE) |
| 37 | if (Settings::IsNceEnabled()) { | 37 | if (Settings::IsNceEnabled()) { |
| 38 | m_arm_interface = std::make_unique<Core::ARM_NCE>(m_system, m_system.Kernel().IsMulticore(), | 38 | m_arm_interface = std::make_unique<Core::ARM_NCE>(m_system, m_system.Kernel().IsMulticore(), |
| 39 | m_core_index); | 39 | m_core_index); |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 31c00f0a3..a1344f1c4 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | #include "core/loader/deconstructed_rom_directory.h" | 15 | #include "core/loader/deconstructed_rom_directory.h" |
| 16 | #include "core/loader/nso.h" | 16 | #include "core/loader/nso.h" |
| 17 | 17 | ||
| 18 | #ifdef ARCHITECTURE_arm64 | 18 | #ifdef HAS_NCE |
| 19 | #include "core/arm/nce/patch.h" | 19 | #include "core/arm/nce/patch.h" |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| @@ -141,12 +141,12 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect | |||
| 141 | std::size_t code_size{}; | 141 | std::size_t code_size{}; |
| 142 | 142 | ||
| 143 | // Define an nce patch context for each potential module. | 143 | // Define an nce patch context for each potential module. |
| 144 | #ifdef ARCHITECTURE_arm64 | 144 | #ifdef HAS_NCE |
| 145 | std::array<Core::NCE::Patcher, 13> module_patchers; | 145 | std::array<Core::NCE::Patcher, 13> module_patchers; |
| 146 | #endif | 146 | #endif |
| 147 | 147 | ||
| 148 | const auto GetPatcher = [&](size_t i) -> Core::NCE::Patcher* { | 148 | const auto GetPatcher = [&](size_t i) -> Core::NCE::Patcher* { |
| 149 | #ifdef ARCHITECTURE_arm64 | 149 | #ifdef HAS_NCE |
| 150 | if (Settings::IsNceEnabled()) { | 150 | if (Settings::IsNceEnabled()) { |
| 151 | return &module_patchers[i]; | 151 | return &module_patchers[i]; |
| 152 | } | 152 | } |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 49d4d7e43..2e7368349 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include "core/loader/nso.h" | 22 | #include "core/loader/nso.h" |
| 23 | #include "core/memory.h" | 23 | #include "core/memory.h" |
| 24 | 24 | ||
| 25 | #ifdef ARCHITECTURE_arm64 | 25 | #ifdef HAS_NCE |
| 26 | #include "core/arm/nce/patch.h" | 26 | #include "core/arm/nce/patch.h" |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| @@ -201,7 +201,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 201 | program_image.resize(static_cast<u32>(program_image.size()) + bss_size); | 201 | program_image.resize(static_cast<u32>(program_image.size()) + bss_size); |
| 202 | size_t image_size = program_image.size(); | 202 | size_t image_size = program_image.size(); |
| 203 | 203 | ||
| 204 | #ifdef ARCHITECTURE_arm64 | 204 | #ifdef HAS_NCE |
| 205 | const auto& code = codeset.CodeSegment(); | 205 | const auto& code = codeset.CodeSegment(); |
| 206 | 206 | ||
| 207 | // NROs always have a 39-bit address space. | 207 | // NROs always have a 39-bit address space. |
| @@ -247,7 +247,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 247 | 247 | ||
| 248 | // Relocate code patch and copy to the program_image if running under NCE. | 248 | // Relocate code patch and copy to the program_image if running under NCE. |
| 249 | // This needs to be after LoadFromMetadata so we can use the process entry point. | 249 | // This needs to be after LoadFromMetadata so we can use the process entry point. |
| 250 | #ifdef ARCHITECTURE_arm64 | 250 | #ifdef HAS_NCE |
| 251 | if (Settings::IsNceEnabled()) { | 251 | if (Settings::IsNceEnabled()) { |
| 252 | patch.RelocateAndCopy(process.GetEntryPoint(), code, program_image, | 252 | patch.RelocateAndCopy(process.GetEntryPoint(), code, program_image, |
| 253 | &process.GetPostHandlers()); | 253 | &process.GetPostHandlers()); |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 1ad2e917c..878c1c6cb 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | #include "core/loader/nso.h" | 20 | #include "core/loader/nso.h" |
| 21 | #include "core/memory.h" | 21 | #include "core/memory.h" |
| 22 | 22 | ||
| 23 | #ifdef ARCHITECTURE_arm64 | 23 | #ifdef HAS_NCE |
| 24 | #include "core/arm/nce/patch.h" | 24 | #include "core/arm/nce/patch.h" |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| @@ -93,7 +93,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: | |||
| 93 | 93 | ||
| 94 | // Allocate some space at the beginning if we are patching in PreText mode. | 94 | // Allocate some space at the beginning if we are patching in PreText mode. |
| 95 | const size_t module_start = [&]() -> size_t { | 95 | const size_t module_start = [&]() -> size_t { |
| 96 | #ifdef ARCHITECTURE_arm64 | 96 | #ifdef HAS_NCE |
| 97 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::PreText) { | 97 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::PreText) { |
| 98 | return patch->GetSectionSize(); | 98 | return patch->GetSectionSize(); |
| 99 | } | 99 | } |
| @@ -155,7 +155,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: | |||
| 155 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data()); | 155 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.data()); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | #ifdef ARCHITECTURE_arm64 | 158 | #ifdef HAS_NCE |
| 159 | // If we are computing the process code layout and using nce backend, patch. | 159 | // If we are computing the process code layout and using nce backend, patch. |
| 160 | const auto& code = codeset.CodeSegment(); | 160 | const auto& code = codeset.CodeSegment(); |
| 161 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::None) { | 161 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::None) { |