mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-03 11:47:11 +02:00
[core/arm] introduce vtable bouncing (#2943)
Basically this just makes functions that go into zero-page or invalid addresses "bounce" back (with a return err of 0) such that it emulates a subroutine returning appropriatedly... this is mainly inspired by [this particular commit](fbb4f5c015); with the key difference of accounting for the scheduler fucking up some random bs.
I don't like this hack but anyways maybe it fixes something?
Signed-off-by: lizzie lizzie@eden-emu.dev
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2943
Reviewed-by: Maufeat <sahyno1996@gmail.com>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
0e6ea2d9d6
commit
82eb5a03f4
3 changed files with 20 additions and 2 deletions
|
|
@ -240,7 +240,7 @@ struct Values {
|
||||||
Category::Cpu};
|
Category::Cpu};
|
||||||
SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto,
|
SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto,
|
||||||
"cpu_accuracy", Category::Cpu};
|
"cpu_accuracy", Category::Cpu};
|
||||||
|
SwitchableSetting<bool> vtable_bouncing{linkage, true, "vtable_bouncing", Category::Cpu};
|
||||||
SwitchableSetting<bool> use_fast_cpu_time{linkage,
|
SwitchableSetting<bool> use_fast_cpu_time{linkage,
|
||||||
false,
|
false,
|
||||||
"use_fast_cpu_time",
|
"use_fast_cpu_time",
|
||||||
|
|
|
||||||
|
|
@ -103,12 +103,26 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
|
||||||
const bool data_abort = True(hr & Core::HaltReason::DataAbort);
|
const bool data_abort = True(hr & Core::HaltReason::DataAbort);
|
||||||
const bool interrupt = True(hr & Core::HaltReason::BreakLoop);
|
const bool interrupt = True(hr & Core::HaltReason::BreakLoop);
|
||||||
|
|
||||||
|
bool may_abort = true; // Ignore aborting virtual functions (for debugging)
|
||||||
|
if (prefetch_abort && ::Settings::values.vtable_bouncing) {
|
||||||
|
auto& lock = m_kernel.GlobalSchedulerContext().SchedulerLock();
|
||||||
|
lock.Lock();
|
||||||
|
Kernel::Svc::ThreadContext ctx;
|
||||||
|
interface->GetContext(ctx);
|
||||||
|
LOG_WARNING(Core_ARM, "vtable bouncing {:016X}", ctx.lr);
|
||||||
|
ctx.pc = ctx.lr;
|
||||||
|
ctx.r[0] = 0;
|
||||||
|
interface->SetContext(ctx);
|
||||||
|
lock.Unlock();
|
||||||
|
may_abort = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Since scheduling may occur here, we cannot use any cached
|
// Since scheduling may occur here, we cannot use any cached
|
||||||
// state after returning from calls we make.
|
// state after returning from calls we make.
|
||||||
|
|
||||||
// Notify the debugger and go to sleep if a breakpoint was hit,
|
// Notify the debugger and go to sleep if a breakpoint was hit,
|
||||||
// or if the thread is unable to continue for any reason.
|
// or if the thread is unable to continue for any reason.
|
||||||
if (breakpoint || prefetch_abort) {
|
if (breakpoint || (prefetch_abort && may_abort)) {
|
||||||
if (breakpoint) {
|
if (breakpoint) {
|
||||||
interface->RewindBreakpointInstruction();
|
interface->RewindBreakpointInstruction();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent)
|
||||||
"cause deadlocks. A range of 77-21000 is recommended."));
|
"cause deadlocks. A range of 77-21000 is recommended."));
|
||||||
INSERT(Settings, cpu_backend, tr("Backend:"), QString());
|
INSERT(Settings, cpu_backend, tr("Backend:"), QString());
|
||||||
|
|
||||||
|
INSERT(Settings, vtable_bouncing,
|
||||||
|
tr("Virtual Table Bouncing"),
|
||||||
|
tr("Bounces (by emulating a 0-valued return) any functions that triggers a prefetch abort"));
|
||||||
|
|
||||||
// Cpu Debug
|
// Cpu Debug
|
||||||
|
|
||||||
// Cpu Unsafe
|
// Cpu Unsafe
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue