|
|
@ -29,55 +29,76 @@ using namespace Common::Literals;
|
|
|
|
class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks {
|
|
|
|
class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_)
|
|
|
|
explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_)
|
|
|
|
: parent{parent_}, memory(parent.system.Memory()) {}
|
|
|
|
: parent{parent_},
|
|
|
|
|
|
|
|
memory(parent.system.Memory()), debugger_enabled{parent.system.DebuggerEnabled()} {}
|
|
|
|
|
|
|
|
|
|
|
|
u8 MemoryRead8(u64 vaddr) override {
|
|
|
|
u8 MemoryRead8(u64 vaddr) override {
|
|
|
|
|
|
|
|
CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read);
|
|
|
|
return memory.Read8(vaddr);
|
|
|
|
return memory.Read8(vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
u16 MemoryRead16(u64 vaddr) override {
|
|
|
|
u16 MemoryRead16(u64 vaddr) override {
|
|
|
|
|
|
|
|
CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Read);
|
|
|
|
return memory.Read16(vaddr);
|
|
|
|
return memory.Read16(vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
u32 MemoryRead32(u64 vaddr) override {
|
|
|
|
u32 MemoryRead32(u64 vaddr) override {
|
|
|
|
|
|
|
|
CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Read);
|
|
|
|
return memory.Read32(vaddr);
|
|
|
|
return memory.Read32(vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
u64 MemoryRead64(u64 vaddr) override {
|
|
|
|
u64 MemoryRead64(u64 vaddr) override {
|
|
|
|
|
|
|
|
CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Read);
|
|
|
|
return memory.Read64(vaddr);
|
|
|
|
return memory.Read64(vaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Vector MemoryRead128(u64 vaddr) override {
|
|
|
|
Vector MemoryRead128(u64 vaddr) override {
|
|
|
|
|
|
|
|
CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Read);
|
|
|
|
return {memory.Read64(vaddr), memory.Read64(vaddr + 8)};
|
|
|
|
return {memory.Read64(vaddr), memory.Read64(vaddr + 8)};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MemoryWrite8(u64 vaddr, u8 value) override {
|
|
|
|
void MemoryWrite8(u64 vaddr, u8 value) override {
|
|
|
|
memory.Write8(vaddr, value);
|
|
|
|
if (CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write)) {
|
|
|
|
|
|
|
|
memory.Write8(vaddr, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MemoryWrite16(u64 vaddr, u16 value) override {
|
|
|
|
void MemoryWrite16(u64 vaddr, u16 value) override {
|
|
|
|
memory.Write16(vaddr, value);
|
|
|
|
if (CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write)) {
|
|
|
|
|
|
|
|
memory.Write16(vaddr, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MemoryWrite32(u64 vaddr, u32 value) override {
|
|
|
|
void MemoryWrite32(u64 vaddr, u32 value) override {
|
|
|
|
memory.Write32(vaddr, value);
|
|
|
|
if (CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write)) {
|
|
|
|
|
|
|
|
memory.Write32(vaddr, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MemoryWrite64(u64 vaddr, u64 value) override {
|
|
|
|
void MemoryWrite64(u64 vaddr, u64 value) override {
|
|
|
|
memory.Write64(vaddr, value);
|
|
|
|
if (CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write)) {
|
|
|
|
|
|
|
|
memory.Write64(vaddr, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void MemoryWrite128(u64 vaddr, Vector value) override {
|
|
|
|
void MemoryWrite128(u64 vaddr, Vector value) override {
|
|
|
|
memory.Write64(vaddr, value[0]);
|
|
|
|
if (CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write)) {
|
|
|
|
memory.Write64(vaddr + 8, value[1]);
|
|
|
|
memory.Write64(vaddr, value[0]);
|
|
|
|
|
|
|
|
memory.Write64(vaddr + 8, value[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MemoryWriteExclusive8(u64 vaddr, std::uint8_t value, std::uint8_t expected) override {
|
|
|
|
bool MemoryWriteExclusive8(u64 vaddr, std::uint8_t value, std::uint8_t expected) override {
|
|
|
|
return memory.WriteExclusive8(vaddr, value, expected);
|
|
|
|
return CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Write) &&
|
|
|
|
|
|
|
|
memory.WriteExclusive8(vaddr, value, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool MemoryWriteExclusive16(u64 vaddr, std::uint16_t value, std::uint16_t expected) override {
|
|
|
|
bool MemoryWriteExclusive16(u64 vaddr, std::uint16_t value, std::uint16_t expected) override {
|
|
|
|
return memory.WriteExclusive16(vaddr, value, expected);
|
|
|
|
return CheckMemoryAccess(vaddr, 2, Kernel::DebugWatchpointType::Write) &&
|
|
|
|
|
|
|
|
memory.WriteExclusive16(vaddr, value, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool MemoryWriteExclusive32(u64 vaddr, std::uint32_t value, std::uint32_t expected) override {
|
|
|
|
bool MemoryWriteExclusive32(u64 vaddr, std::uint32_t value, std::uint32_t expected) override {
|
|
|
|
return memory.WriteExclusive32(vaddr, value, expected);
|
|
|
|
return CheckMemoryAccess(vaddr, 4, Kernel::DebugWatchpointType::Write) &&
|
|
|
|
|
|
|
|
memory.WriteExclusive32(vaddr, value, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool MemoryWriteExclusive64(u64 vaddr, std::uint64_t value, std::uint64_t expected) override {
|
|
|
|
bool MemoryWriteExclusive64(u64 vaddr, std::uint64_t value, std::uint64_t expected) override {
|
|
|
|
return memory.WriteExclusive64(vaddr, value, expected);
|
|
|
|
return CheckMemoryAccess(vaddr, 8, Kernel::DebugWatchpointType::Write) &&
|
|
|
|
|
|
|
|
memory.WriteExclusive64(vaddr, value, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool MemoryWriteExclusive128(u64 vaddr, Vector value, Vector expected) override {
|
|
|
|
bool MemoryWriteExclusive128(u64 vaddr, Vector value, Vector expected) override {
|
|
|
|
return memory.WriteExclusive128(vaddr, value, expected);
|
|
|
|
return CheckMemoryAccess(vaddr, 16, Kernel::DebugWatchpointType::Write) &&
|
|
|
|
|
|
|
|
memory.WriteExclusive128(vaddr, value, expected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InterpreterFallback(u64 pc, std::size_t num_instructions) override {
|
|
|
|
void InterpreterFallback(u64 pc, std::size_t num_instructions) override {
|
|
|
@ -118,8 +139,8 @@ public:
|
|
|
|
case Dynarmic::A64::Exception::Yield:
|
|
|
|
case Dynarmic::A64::Exception::Yield:
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if (parent.system.DebuggerEnabled()) {
|
|
|
|
if (debugger_enabled) {
|
|
|
|
parent.jit.load()->SetPC(pc);
|
|
|
|
parent.SaveContext(parent.breakpoint_context);
|
|
|
|
parent.jit.load()->HaltExecution(ARM_Interface::breakpoint);
|
|
|
|
parent.jit.load()->HaltExecution(ARM_Interface::breakpoint);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -160,10 +181,27 @@ public:
|
|
|
|
return parent.system.CoreTiming().GetClockTicks();
|
|
|
|
return parent.system.CoreTiming().GetClockTicks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CheckMemoryAccess(VAddr addr, u64 size, Kernel::DebugWatchpointType type) {
|
|
|
|
|
|
|
|
if (!debugger_enabled) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto match{parent.MatchingWatchpoint(addr, size, type)};
|
|
|
|
|
|
|
|
if (match) {
|
|
|
|
|
|
|
|
parent.SaveContext(parent.breakpoint_context);
|
|
|
|
|
|
|
|
parent.jit.load()->HaltExecution(ARM_Interface::watchpoint);
|
|
|
|
|
|
|
|
parent.halted_watchpoint = match;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ARM_Dynarmic_64& parent;
|
|
|
|
ARM_Dynarmic_64& parent;
|
|
|
|
Core::Memory::Memory& memory;
|
|
|
|
Core::Memory::Memory& memory;
|
|
|
|
u64 tpidrro_el0 = 0;
|
|
|
|
u64 tpidrro_el0 = 0;
|
|
|
|
u64 tpidr_el0 = 0;
|
|
|
|
u64 tpidr_el0 = 0;
|
|
|
|
|
|
|
|
bool debugger_enabled{};
|
|
|
|
static constexpr u64 minimum_run_cycles = 1000U;
|
|
|
|
static constexpr u64 minimum_run_cycles = 1000U;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -214,6 +252,11 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
|
|
|
|
config.code_cache_size = 512_MiB;
|
|
|
|
config.code_cache_size = 512_MiB;
|
|
|
|
config.far_code_offset = 400_MiB;
|
|
|
|
config.far_code_offset = 400_MiB;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Allow memory fault handling to work
|
|
|
|
|
|
|
|
if (system.DebuggerEnabled()) {
|
|
|
|
|
|
|
|
config.check_halt_on_memory_access = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// null_jit
|
|
|
|
// null_jit
|
|
|
|
if (!page_table) {
|
|
|
|
if (!page_table) {
|
|
|
|
// Don't waste too much memory on null_jit
|
|
|
|
// Don't waste too much memory on null_jit
|
|
|
@ -308,6 +351,14 @@ u32 ARM_Dynarmic_64::GetSvcNumber() const {
|
|
|
|
return svc_swi;
|
|
|
|
return svc_swi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Kernel::DebugWatchpoint* ARM_Dynarmic_64::HaltedWatchpoint() const {
|
|
|
|
|
|
|
|
return halted_watchpoint;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ARM_Dynarmic_64::RewindBreakpointInstruction() {
|
|
|
|
|
|
|
|
LoadContext(breakpoint_context);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_,
|
|
|
|
ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_,
|
|
|
|
bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
|
|
|
bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
|
|
|
std::size_t core_index_)
|
|
|
|
std::size_t core_index_)
|
|
|
|