Merge pull request #7597 from bunnei/remove-global-lock
core: hle: Remove global HLE lock.
This commit is contained in:
commit
ee6d40d414
|
@ -265,8 +265,6 @@ add_library(core STATIC
|
||||||
hle/kernel/svc_wrap.h
|
hle/kernel/svc_wrap.h
|
||||||
hle/kernel/time_manager.cpp
|
hle/kernel/time_manager.cpp
|
||||||
hle/kernel/time_manager.h
|
hle/kernel/time_manager.h
|
||||||
hle/lock.cpp
|
|
||||||
hle/lock.h
|
|
||||||
hle/result.h
|
hle/result.h
|
||||||
hle/service/acc/acc.cpp
|
hle/service/acc/acc.cpp
|
||||||
hle/service/acc/acc.h
|
hle/service/acc/acc.h
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "core/hle/kernel/k_thread.h"
|
#include "core/hle/kernel/k_thread.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -543,7 +542,6 @@ void KProcess::FreeTLSRegion(VAddr tls_address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) {
|
void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
const auto ReprotectSegment = [&](const CodeSet::Segment& segment,
|
const auto ReprotectSegment = [&](const CodeSet::Segment& segment,
|
||||||
KMemoryPermission permission) {
|
KMemoryPermission permission) {
|
||||||
page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission);
|
page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission);
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
#include "core/hle/kernel/svc_types.h"
|
#include "core/hle/kernel/svc_types.h"
|
||||||
#include "core/hle/kernel/svc_wrap.h"
|
#include "core/hle/kernel/svc_wrap.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/reporter.h"
|
#include "core/reporter.h"
|
||||||
|
@ -137,7 +136,6 @@ enum class ResourceLimitValueType {
|
||||||
|
|
||||||
/// Set the process heap to a given Size. It can both extend and shrink the heap.
|
/// Set the process heap to a given Size. It can both extend and shrink the heap.
|
||||||
static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) {
|
static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
|
LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size);
|
||||||
|
|
||||||
// Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB.
|
// 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
|
||||||
|
|
||||||
static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask,
|
static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask,
|
||||||
u32 attribute) {
|
u32 attribute) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_DEBUG(Kernel_SVC,
|
LOG_DEBUG(Kernel_SVC,
|
||||||
"called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address,
|
"called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address,
|
||||||
size, mask, attribute);
|
size, mask, attribute);
|
||||||
|
@ -212,7 +209,6 @@ static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 si
|
||||||
|
|
||||||
/// Maps a memory range into a different range.
|
/// Maps a memory range into a different range.
|
||||||
static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
|
static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
|
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
|
||||||
src_addr, size);
|
src_addr, size);
|
||||||
|
|
||||||
|
@ -232,7 +228,6 @@ static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr,
|
||||||
|
|
||||||
/// Unmaps a region that was previously mapped with svcMapMemory
|
/// Unmaps a region that was previously mapped with svcMapMemory
|
||||||
static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
|
static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
|
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
|
||||||
src_addr, size);
|
src_addr, size);
|
||||||
|
|
||||||
|
@ -642,7 +637,6 @@ static void OutputDebugString(Core::System& system, VAddr address, u64 len) {
|
||||||
/// Gets system/memory information for the current process
|
/// Gets system/memory information for the current process
|
||||||
static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
|
static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
|
||||||
u64 info_sub_id) {
|
u64 info_sub_id) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
|
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
|
||||||
info_sub_id, handle);
|
info_sub_id, handle);
|
||||||
|
|
||||||
|
@ -924,7 +918,6 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h
|
||||||
|
|
||||||
/// Maps memory at a desired address
|
/// Maps memory at a desired address
|
||||||
static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
|
static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
|
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
|
||||||
|
|
||||||
if (!Common::Is4KBAligned(addr)) {
|
if (!Common::Is4KBAligned(addr)) {
|
||||||
|
@ -978,7 +971,6 @@ static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size)
|
||||||
|
|
||||||
/// Unmaps memory previously mapped via MapPhysicalMemory
|
/// Unmaps memory previously mapped via MapPhysicalMemory
|
||||||
static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
|
static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
|
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
|
||||||
|
|
||||||
if (!Common::Is4KBAligned(addr)) {
|
if (!Common::Is4KBAligned(addr)) {
|
||||||
|
@ -1520,7 +1512,6 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han
|
||||||
static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address,
|
static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address,
|
||||||
VAddr page_info_address, Handle process_handle,
|
VAddr page_info_address, Handle process_handle,
|
||||||
VAddr address) {
|
VAddr address) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
|
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
|
||||||
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
|
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
|
||||||
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
|
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Copyright 2017 Citra Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include <core/hle/lock.h>
|
|
||||||
|
|
||||||
namespace HLE {
|
|
||||||
std::recursive_mutex g_hle_lock;
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
// Copyright 2017 Citra Emulator Project
|
|
||||||
// Licensed under GPLv2 or any later version
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
namespace HLE {
|
|
||||||
/*
|
|
||||||
* Synchronizes access to the internal HLE kernel structures, it is acquired when a guest
|
|
||||||
* application thread performs a syscall. It should be acquired by any host threads that read or
|
|
||||||
* modify the HLE kernel state. Note: Any operation that directly or indirectly reads from or writes
|
|
||||||
* to the emulated memory is not protected by this mutex, and should be avoided in any threads other
|
|
||||||
* than the CPU thread.
|
|
||||||
*/
|
|
||||||
extern std::recursive_mutex g_hle_lock;
|
|
||||||
} // namespace HLE
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "core/hle/service/bcat/backend/backend.h"
|
#include "core/hle/service/bcat/backend/backend.h"
|
||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service::BCAT {
|
||||||
|
@ -29,10 +28,6 @@ DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() {
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressServiceBackend::SetNeedHLELock(bool need) {
|
|
||||||
need_hle_lock = need;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProgressServiceBackend::SetTotalSize(u64 size) {
|
void ProgressServiceBackend::SetTotalSize(u64 size) {
|
||||||
impl.total_bytes = size;
|
impl.total_bytes = size;
|
||||||
SignalUpdate();
|
SignalUpdate();
|
||||||
|
@ -88,12 +83,7 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressServiceBackend::SignalUpdate() {
|
void ProgressServiceBackend::SignalUpdate() {
|
||||||
if (need_hle_lock) {
|
update_event->GetWritableEvent().Signal();
|
||||||
std::lock_guard lock(HLE::g_hle_lock);
|
|
||||||
update_event->GetWritableEvent().Signal();
|
|
||||||
} else {
|
|
||||||
update_event->GetWritableEvent().Signal();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
|
Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {}
|
||||||
|
|
|
@ -71,10 +71,6 @@ class ProgressServiceBackend {
|
||||||
public:
|
public:
|
||||||
~ProgressServiceBackend();
|
~ProgressServiceBackend();
|
||||||
|
|
||||||
// Clients should call this with true if any of the functions are going to be called from a
|
|
||||||
// non-HLE thread and this class need to lock the hle mutex. (default is false)
|
|
||||||
void SetNeedHLELock(bool need);
|
|
||||||
|
|
||||||
// Sets the number of bytes total in the entire download.
|
// Sets the number of bytes total in the entire download.
|
||||||
void SetTotalSize(u64 size);
|
void SetTotalSize(u64 size);
|
||||||
|
|
||||||
|
@ -109,7 +105,6 @@ private:
|
||||||
|
|
||||||
DeliveryCacheProgressImpl impl{};
|
DeliveryCacheProgressImpl impl{};
|
||||||
Kernel::KEvent* update_event;
|
Kernel::KEvent* update_event;
|
||||||
bool need_hle_lock = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class representing an abstract backend for BCAT functionality.
|
// A class representing an abstract backend for BCAT functionality.
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "core/hle/service/nfp/nfp.h"
|
#include "core/hle/service/nfp/nfp.h"
|
||||||
#include "core/hle/service/nfp/nfp_user.h"
|
#include "core/hle/service/nfp/nfp_user.h"
|
||||||
|
|
||||||
|
@ -337,7 +336,6 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
|
bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
if (buffer.size() < sizeof(AmiiboFile)) {
|
if (buffer.size() < sizeof(AmiiboFile)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "core/hid/emulated_controller.h"
|
#include "core/hid/emulated_controller.h"
|
||||||
#include "core/hid/hid_core.h"
|
#include "core/hid/hid_core.h"
|
||||||
#include "core/hid/hid_types.h"
|
#include "core/hid/hid_types.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
@ -664,7 +663,5 @@ void QtControllerSelector::ReconfigureControllers(
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtControllerSelector::MainWindowReconfigureFinished() {
|
void QtControllerSelector::MainWindowReconfigureFinished() {
|
||||||
// Acquire the HLE mutex
|
|
||||||
std::lock_guard lock(HLE::g_hle_lock);
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "yuzu/applets/qt_error.h"
|
#include "yuzu/applets/qt_error.h"
|
||||||
#include "yuzu/main.h"
|
#include "yuzu/main.h"
|
||||||
|
|
||||||
|
@ -57,7 +56,5 @@ void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_te
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtErrorDisplay::MainWindowFinishedError() {
|
void QtErrorDisplay::MainWindowFinishedError() {
|
||||||
// Acquire the HLE mutex
|
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/constants.h"
|
#include "core/constants.h"
|
||||||
#include "core/hle/lock.h"
|
|
||||||
#include "yuzu/applets/qt_profile_select.h"
|
#include "yuzu/applets/qt_profile_select.h"
|
||||||
#include "yuzu/main.h"
|
#include "yuzu/main.h"
|
||||||
#include "yuzu/util/controller_navigation.h"
|
#include "yuzu/util/controller_navigation.h"
|
||||||
|
@ -170,7 +169,5 @@ void QtProfileSelector::SelectProfile(
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
|
void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) {
|
||||||
// Acquire the HLE mutex
|
|
||||||
std::lock_guard lock{HLE::g_hle_lock};
|
|
||||||
callback(uuid);
|
callback(uuid);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue