aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/k_thread.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-02-23 20:32:03 -0500
committerLiam <byteslice@airmail.cc>2023-03-01 10:42:45 -0500
commit97f7f7bad59cdd42bf5f504089e5cecd441da3ce (patch)
tree1d7489c0bda11fb4e99e0a6d1acea4d4406861d4 /src/core/hle/kernel/k_thread.cpp
parentc4ba088a5df13ff4b4d8853216231d690f2c79c0 (diff)
kernel: be more careful about kernel address keys
Diffstat (limited to 'src/core/hle/kernel/k_thread.cpp')
-rw-r--r--src/core/hle/kernel/k_thread.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 2831df733..8c403f5fd 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -933,12 +933,14 @@ void KThread::AddHeldLock(LockWithPriorityInheritanceInfo* lock_info) {
held_lock_info_list.push_front(*lock_info);
}
-KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key_) {
+KThread::LockWithPriorityInheritanceInfo* KThread::FindHeldLock(VAddr address_key_,
+ bool is_kernel_address_key_) {
ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel));
// Try to find an existing held lock.
for (auto& held_lock : held_lock_info_list) {
- if (held_lock.GetAddressKey() == address_key_) {
+ if (held_lock.GetAddressKey() == address_key_ &&
+ held_lock.GetIsKernelAddressKey() == is_kernel_address_key_) {
return std::addressof(held_lock);
}
}
@@ -961,7 +963,7 @@ void KThread::AddWaiterImpl(KThread* thread) {
}
// Get the relevant lock info.
- auto* lock_info = this->FindHeldLock(address_key_);
+ auto* lock_info = this->FindHeldLock(address_key_, is_kernel_address_key_);
if (lock_info == nullptr) {
// Create a new lock for the address key.
lock_info =
@@ -1067,11 +1069,11 @@ void KThread::RemoveWaiter(KThread* thread) {
}
}
-KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key) {
+KThread* KThread::RemoveWaiterByKey(bool* out_has_waiters, VAddr key, bool is_kernel_address_key_) {
ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel));
// Get the relevant lock info.
- auto* lock_info = this->FindHeldLock(key);
+ auto* lock_info = this->FindHeldLock(key, is_kernel_address_key_);
if (lock_info == nullptr) {
*out_has_waiters = false;
return nullptr;