Browse Source
[dynarmic] use constant resolution instead of clobbering a register when doing spinlocks
[dynarmic] use constant resolution instead of clobbering a register when doing spinlocks
Signed-off-by: lizzie <lizzie@eden-emu.dev>lizzie/dynarmic-exclusive-fixups
committed by
crueter
12 changed files with 164 additions and 348 deletions
-
24src/core/arm/dynarmic/dynarmic_exclusive_monitor.cpp
-
4src/dynarmic/src/dynarmic/CMakeLists.txt
-
18src/dynarmic/src/dynarmic/backend/arm64/a64_address_space.cpp
-
61src/dynarmic/src/dynarmic/backend/arm64/exclusive_monitor.cpp
-
54src/dynarmic/src/dynarmic/backend/riscv64/exclusive_monitor.cpp
-
50src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp
-
62src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp
-
44src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.cpp.inc
-
49src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.h
-
54src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp
-
4src/dynarmic/src/dynarmic/common/spin_lock_x64.h
-
88src/dynarmic/src/dynarmic/interface/exclusive_monitor.h
@ -1,61 +0,0 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|||
|
|||
/* This file is part of the dynarmic project.
|
|||
* Copyright (c) 2022 MerryMage |
|||
* SPDX-License-Identifier: 0BSD |
|||
*/ |
|||
|
|||
#include "dynarmic/interface/exclusive_monitor.h"
|
|||
|
|||
#include <algorithm>
|
|||
|
|||
#include "common/assert.h"
|
|||
|
|||
namespace Dynarmic { |
|||
|
|||
ExclusiveMonitor::ExclusiveMonitor(std::size_t processor_count) |
|||
: exclusive_addresses(processor_count, INVALID_EXCLUSIVE_ADDRESS), exclusive_values(processor_count) {} |
|||
|
|||
size_t ExclusiveMonitor::GetProcessorCount() const { |
|||
return exclusive_addresses.size(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::Lock() { |
|||
lock.Lock(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::Unlock() { |
|||
lock.Unlock(); |
|||
} |
|||
|
|||
bool ExclusiveMonitor::CheckAndClear(std::size_t processor_id, VAddr address) { |
|||
const VAddr masked_address = address & RESERVATION_GRANULE_MASK; |
|||
|
|||
Lock(); |
|||
if (exclusive_addresses[processor_id] != masked_address) { |
|||
Unlock(); |
|||
return false; |
|||
} |
|||
|
|||
for (VAddr& other_address : exclusive_addresses) { |
|||
if (other_address == masked_address) { |
|||
other_address = INVALID_EXCLUSIVE_ADDRESS; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
void ExclusiveMonitor::Clear() { |
|||
Lock(); |
|||
std::fill(exclusive_addresses.begin(), exclusive_addresses.end(), INVALID_EXCLUSIVE_ADDRESS); |
|||
Unlock(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::ClearProcessor(std::size_t processor_id) { |
|||
Lock(); |
|||
exclusive_addresses[processor_id] = INVALID_EXCLUSIVE_ADDRESS; |
|||
Unlock(); |
|||
} |
|||
|
|||
} // namespace Dynarmic
|
|||
@ -1,54 +0,0 @@ |
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|||
|
|||
#include "dynarmic/interface/exclusive_monitor.h"
|
|||
|
|||
#include <algorithm>
|
|||
|
|||
namespace Dynarmic { |
|||
|
|||
ExclusiveMonitor::ExclusiveMonitor(std::size_t processor_count) |
|||
: exclusive_addresses(processor_count, INVALID_EXCLUSIVE_ADDRESS), exclusive_values(processor_count) {} |
|||
|
|||
size_t ExclusiveMonitor::GetProcessorCount() const { |
|||
return exclusive_addresses.size(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::Lock() { |
|||
lock.Lock(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::Unlock() { |
|||
lock.Unlock(); |
|||
} |
|||
|
|||
bool ExclusiveMonitor::CheckAndClear(size_t processor_id, VAddr address) { |
|||
const VAddr masked_address = address & RESERVATION_GRANULE_MASK; |
|||
|
|||
Lock(); |
|||
if (exclusive_addresses[processor_id] != masked_address) { |
|||
Unlock(); |
|||
return false; |
|||
} |
|||
|
|||
for (VAddr& other_address : exclusive_addresses) { |
|||
if (other_address == masked_address) { |
|||
other_address = INVALID_EXCLUSIVE_ADDRESS; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
void ExclusiveMonitor::Clear() { |
|||
Lock(); |
|||
std::fill(exclusive_addresses.begin(), exclusive_addresses.end(), INVALID_EXCLUSIVE_ADDRESS); |
|||
Unlock(); |
|||
} |
|||
|
|||
void ExclusiveMonitor::ClearProcessor(size_t processor_id) { |
|||
Lock(); |
|||
exclusive_addresses[processor_id] = INVALID_EXCLUSIVE_ADDRESS; |
|||
Unlock(); |
|||
} |
|||
|
|||
} // namespace Dynarmic
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue