summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-20 14:24:50 -0800
committerGravatar GitHub2021-12-20 14:24:50 -0800
commitee6d40d414199f1b957499b4cc07d63e5c0b7ec5 (patch)
treec1c31b6a204407dd13de214c8781d9fde0930d1b
parentMerge pull request #7603 from ameerj/here-we-go-again (diff)
parentcore: hle: Remove global HLE lock. (diff)
downloadyuzu-ee6d40d414199f1b957499b4cc07d63e5c0b7ec5.tar.gz
yuzu-ee6d40d414199f1b957499b4cc07d63e5c0b7ec5.tar.xz
yuzu-ee6d40d414199f1b957499b4cc07d63e5c0b7ec5.zip
Merge pull request #7597 from bunnei/remove-global-lock
core: hle: Remove global HLE lock.
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/kernel/k_process.cpp2
-rw-r--r--src/core/hle/kernel/svc.cpp9
-rw-r--r--src/core/hle/lock.cpp9
-rw-r--r--src/core/hle/lock.h18
-rw-r--r--src/core/hle/service/bcat/backend/backend.cpp12
-rw-r--r--src/core/hle/service/bcat/backend/backend.h5
-rw-r--r--src/core/hle/service/nfp/nfp.cpp2
-rw-r--r--src/yuzu/applets/qt_controller.cpp3
-rw-r--r--src/yuzu/applets/qt_error.cpp3
-rw-r--r--src/yuzu/applets/qt_profile_select.cpp3
11 files changed, 1 insertions, 67 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 49bed614a..698c4f912 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -265,8 +265,6 @@ add_library(core STATIC
265 hle/kernel/svc_wrap.h 265 hle/kernel/svc_wrap.h
266 hle/kernel/time_manager.cpp 266 hle/kernel/time_manager.cpp
267 hle/kernel/time_manager.h 267 hle/kernel/time_manager.h
268 hle/lock.cpp
269 hle/lock.h
270 hle/result.h 268 hle/result.h
271 hle/service/acc/acc.cpp 269 hle/service/acc/acc.cpp
272 hle/service/acc/acc.h 270 hle/service/acc/acc.h
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index 90dda40dc..aee313995 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -28,7 +28,6 @@
28#include "core/hle/kernel/k_thread.h" 28#include "core/hle/kernel/k_thread.h"
29#include "core/hle/kernel/kernel.h" 29#include "core/hle/kernel/kernel.h"
30#include "core/hle/kernel/svc_results.h" 30#include "core/hle/kernel/svc_results.h"
31#include "core/hle/lock.h"
32#include "core/memory.h" 31#include "core/memory.h"
33 32
34namespace Kernel { 33namespace Kernel {
@@ -543,7 +542,6 @@ void KProcess::FreeTLSRegion(VAddr tls_address) {
543} 542}
544 543
545void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) { 544void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) {
546 std::lock_guard lock{HLE::g_hle_lock};
547 const auto ReprotectSegment = [&](const CodeSet::Segment& segment, 545 const auto ReprotectSegment = [&](const CodeSet::Segment& segment,
548 KMemoryPermission permission) { 546 KMemoryPermission permission) {
549 page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission); 547 page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission);
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index a9f7438ea..bb9475c56 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -41,7 +41,6 @@
41#include "core/hle/kernel/svc_results.h" 41#include "core/hle/kernel/svc_results.h"
42#include "core/hle/kernel/svc_types.h" 42#include "core/hle/kernel/svc_types.h"
43#include "core/hle/kernel/svc_wrap.h" 43#include "core/hle/kernel/svc_wrap.h"
44#include "core/hle/lock.h"
45#include "core/hle/result.h" 44#include "core/hle/result.h"
46#include "core/memory.h" 45#include "core/memory.h"
47#include "core/reporter.h" 46#include "core/reporter.h"
@@ -137,7 +136,6 @@ enum class ResourceLimitValueType {
137 136
138/// Set the process heap to a given Size. It can both extend and shrink the heap. 137/// Set the process heap to a given Size. It can both extend and shrink the heap.
139static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) { 138static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) {
140 std::lock_guard lock{HLE::g_hle_lock};
141 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); 139 LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
142 140
143 // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB. 141 // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB.
@@ -168,7 +166,6 @@ static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_s
168 166
169static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, 167static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask,
170 u32 attribute) { 168 u32 attribute) {
171 std::lock_guard lock{HLE::g_hle_lock};
172 LOG_DEBUG(Kernel_SVC, 169 LOG_DEBUG(Kernel_SVC,
173 "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address, 170 "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address,
174 size, mask, attribute); 171 size, mask, attribute);
@@ -212,7 +209,6 @@ static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 si
212 209
213/// Maps a memory range into a different range. 210/// Maps a memory range into a different range.
214static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 211static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
215 std::lock_guard lock{HLE::g_hle_lock};
216 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 212 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
217 src_addr, size); 213 src_addr, size);
218 214
@@ -232,7 +228,6 @@ static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr,
232 228
233/// Unmaps a region that was previously mapped with svcMapMemory 229/// Unmaps a region that was previously mapped with svcMapMemory
234static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { 230static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
235 std::lock_guard lock{HLE::g_hle_lock};
236 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, 231 LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
237 src_addr, size); 232 src_addr, size);
238 233
@@ -642,7 +637,6 @@ static void OutputDebugString(Core::System& system, VAddr address, u64 len) {
642/// Gets system/memory information for the current process 637/// Gets system/memory information for the current process
643static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, 638static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
644 u64 info_sub_id) { 639 u64 info_sub_id) {
645 std::lock_guard lock{HLE::g_hle_lock};
646 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, 640 LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
647 info_sub_id, handle); 641 info_sub_id, handle);
648 642
@@ -924,7 +918,6 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h
924 918
925/// Maps memory at a desired address 919/// Maps memory at a desired address
926static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 920static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
927 std::lock_guard lock{HLE::g_hle_lock};
928 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 921 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
929 922
930 if (!Common::Is4KBAligned(addr)) { 923 if (!Common::Is4KBAligned(addr)) {
@@ -978,7 +971,6 @@ static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size)
978 971
979/// Unmaps memory previously mapped via MapPhysicalMemory 972/// Unmaps memory previously mapped via MapPhysicalMemory
980static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { 973static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
981 std::lock_guard lock{HLE::g_hle_lock};
982 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); 974 LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
983 975
984 if (!Common::Is4KBAligned(addr)) { 976 if (!Common::Is4KBAligned(addr)) {
@@ -1520,7 +1512,6 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han
1520static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, 1512static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address,
1521 VAddr page_info_address, Handle process_handle, 1513 VAddr page_info_address, Handle process_handle,
1522 VAddr address) { 1514 VAddr address) {
1523 std::lock_guard lock{HLE::g_hle_lock};
1524 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); 1515 LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
1525 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 1516 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
1526 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); 1517 KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
diff --git a/src/core/hle/lock.cpp b/src/core/hle/lock.cpp
deleted file mode 100644
index be4bfce3b..000000000
--- a/src/core/hle/lock.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <core/hle/lock.h>
6
7namespace HLE {
8std::recursive_mutex g_hle_lock;
9}
diff --git a/src/core/hle/lock.h b/src/core/hle/lock.h
deleted file mode 100644
index 5c99fe996..000000000
--- a/src/core/hle/lock.h
+++ /dev/null
@@ -1,18 +0,0 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <mutex>
8
9namespace HLE {
10/*
11 * Synchronizes access to the internal HLE kernel structures, it is acquired when a guest
12 * application thread performs a syscall. It should be acquired by any host threads that read or
13 * modify the HLE kernel state. Note: Any operation that directly or indirectly reads from or writes
14 * to the emulated memory is not protected by this mutex, and should be avoided in any threads other
15 * than the CPU thread.
16 */
17extern std::recursive_mutex g_hle_lock;
18} // namespace HLE
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp
index 4c7d3bb6e..ee49edbb9 100644
--- a/src/core/hle/service/bcat/backend/backend.cpp
+++ b/src/core/hle/service/bcat/backend/backend.cpp
@@ -6,7 +6,6 @@
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/kernel/k_event.h" 8#include "core/hle/kernel/k_event.h"
9#include "core/hle/lock.h"
10#include "core/hle/service/bcat/backend/backend.h" 9#include "core/hle/service/bcat/backend/backend.h"
11 10
12namespace Service::BCAT { 11namespace Service::BCAT {
@@ -29,10 +28,6 @@ DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() {
29 return impl; 28 return impl;
30} 29}
31 30
32void ProgressServiceBackend::SetNeedHLELock(bool need) {
33 need_hle_lock = need;
34}
35
36void ProgressServiceBackend::SetTotalSize(u64 size) { 31void ProgressServiceBackend::SetTotalSize(u64 size) {
37 impl.total_bytes = size; 32 impl.total_bytes = size;
38 SignalUpdate(); 33 SignalUpdate();
@@ -88,12 +83,7 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) {
88} 83}
89 84
90void ProgressServiceBackend::SignalUpdate() { 85void ProgressServiceBackend::SignalUpdate() {
91 if (need_hle_lock) { 86 update_event->GetWritableEvent().Signal();
92 std::lock_guard lock(HLE::g_hle_lock);
93 update_event->GetWritableEvent().Signal();
94 } else {
95 update_event->GetWritableEvent().Signal();
96 }
97} 87}
98 88
99Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {} 89Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h
index 59c6d4740..63833c927 100644
--- a/src/core/hle/service/bcat/backend/backend.h
+++ b/src/core/hle/service/bcat/backend/backend.h
@@ -71,10 +71,6 @@ class ProgressServiceBackend {
71public: 71public:
72 ~ProgressServiceBackend(); 72 ~ProgressServiceBackend();
73 73
74 // Clients should call this with true if any of the functions are going to be called from a
75 // non-HLE thread and this class need to lock the hle mutex. (default is false)
76 void SetNeedHLELock(bool need);
77
78 // Sets the number of bytes total in the entire download. 74 // Sets the number of bytes total in the entire download.
79 void SetTotalSize(u64 size); 75 void SetTotalSize(u64 size);
80 76
@@ -109,7 +105,6 @@ private:
109 105
110 DeliveryCacheProgressImpl impl{}; 106 DeliveryCacheProgressImpl impl{};
111 Kernel::KEvent* update_event; 107 Kernel::KEvent* update_event;
112 bool need_hle_lock = false;
113}; 108};
114 109
115// A class representing an abstract backend for BCAT functionality. 110// A class representing an abstract backend for BCAT functionality.
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 693ffc71a..761d0d3c6 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -9,7 +9,6 @@
9#include "core/core.h" 9#include "core/core.h"
10#include "core/hle/ipc_helpers.h" 10#include "core/hle/ipc_helpers.h"
11#include "core/hle/kernel/k_event.h" 11#include "core/hle/kernel/k_event.h"
12#include "core/hle/lock.h"
13#include "core/hle/service/nfp/nfp.h" 12#include "core/hle/service/nfp/nfp.h"
14#include "core/hle/service/nfp/nfp_user.h" 13#include "core/hle/service/nfp/nfp_user.h"
15 14
@@ -337,7 +336,6 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
337} 336}
338 337
339bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { 338bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
340 std::lock_guard lock{HLE::g_hle_lock};
341 if (buffer.size() < sizeof(AmiiboFile)) { 339 if (buffer.size() < sizeof(AmiiboFile)) {
342 return false; 340 return false;
343 } 341 }
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp
index c5685db2e..c6222b571 100644
--- a/src/yuzu/applets/qt_controller.cpp
+++ b/src/yuzu/applets/qt_controller.cpp
@@ -12,7 +12,6 @@
12#include "core/hid/emulated_controller.h" 12#include "core/hid/emulated_controller.h"
13#include "core/hid/hid_core.h" 13#include "core/hid/hid_core.h"
14#include "core/hid/hid_types.h" 14#include "core/hid/hid_types.h"
15#include "core/hle/lock.h"
16#include "core/hle/service/hid/controllers/npad.h" 15#include "core/hle/service/hid/controllers/npad.h"
17#include "core/hle/service/hid/hid.h" 16#include "core/hle/service/hid/hid.h"
18#include "core/hle/service/sm/sm.h" 17#include "core/hle/service/sm/sm.h"
@@ -664,7 +663,5 @@ void QtControllerSelector::ReconfigureControllers(
664} 663}
665 664
666void QtControllerSelector::MainWindowReconfigureFinished() { 665void QtControllerSelector::MainWindowReconfigureFinished() {
667 // Acquire the HLE mutex
668 std::lock_guard lock(HLE::g_hle_lock);
669 callback(); 666 callback();
670} 667}
diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp
index 45cf64603..879e73660 100644
--- a/src/yuzu/applets/qt_error.cpp
+++ b/src/yuzu/applets/qt_error.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <QDateTime> 5#include <QDateTime>
6#include "core/hle/lock.h"
7#include "yuzu/applets/qt_error.h" 6#include "yuzu/applets/qt_error.h"
8#include "yuzu/main.h" 7#include "yuzu/main.h"
9 8
@@ -57,7 +56,5 @@ void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_te
57} 56}
58 57
59void QtErrorDisplay::MainWindowFinishedError() { 58void QtErrorDisplay::MainWindowFinishedError() {
60 // Acquire the HLE mutex
61 std::lock_guard lock{HLE::g_hle_lock};
62 callback(); 59 callback();
63} 60}
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp
index 7b19f1f8d..5b32da923 100644
--- a/src/yuzu/applets/qt_profile_select.cpp
+++ b/src/yuzu/applets/qt_profile_select.cpp
@@ -14,7 +14,6 @@
14#include "common/fs/path_util.h" 14#include "common/fs/path_util.h"
15#include "common/string_util.h" 15#include "common/string_util.h"
16#include "core/constants.h" 16#include "core/constants.h"
17#include "core/hle/lock.h"
18#include "yuzu/applets/qt_profile_select.h" 17#include "yuzu/applets/qt_profile_select.h"
19#include "yuzu/main.h" 18#include "yuzu/main.h"
20#include "yuzu/util/controller_navigation.h" 19#include "yuzu/util/controller_navigation.h"
@@ -170,7 +169,5 @@ void QtProfileSelector::SelectProfile(
170} 169}
171 170
172void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) { 171void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
173 // Acquire the HLE mutex
174 std::lock_guard lock{HLE::g_hle_lock};
175 callback(uuid); 172 callback(uuid);
176} 173}