mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
ppu: fix a bug where arm64 sp wasn't being saved
ASMJIT can silently fail and drop instructions when invalid operations are performed (e.g. loading/storing sp). Explicitly move sp to a gp register before doing loads/stores to fix this.
This commit is contained in:
parent
488982f424
commit
2755d9941c
@ -287,7 +287,9 @@ const auto ppu_gateway = build_function_asm<void(*)(ppu_thread*)>("ppu_gateway",
|
|||||||
// Save sp for native longjmp emulation
|
// Save sp for native longjmp emulation
|
||||||
Label native_sp_offset = c.newLabel();
|
Label native_sp_offset = c.newLabel();
|
||||||
c.ldr(a64::x10, arm::Mem(native_sp_offset));
|
c.ldr(a64::x10, arm::Mem(native_sp_offset));
|
||||||
c.str(a64::sp, arm::Mem(args[0], a64::x10));
|
// sp not allowed to be used in load/stores directly
|
||||||
|
c.mov(a64::x15, a64::sp);
|
||||||
|
c.str(a64::x15, arm::Mem(args[0], a64::x10));
|
||||||
|
|
||||||
// Load REG_Base - use absolute jump target to bypass rel jmp range limits
|
// Load REG_Base - use absolute jump target to bypass rel jmp range limits
|
||||||
Label exec_addr = c.newLabel();
|
Label exec_addr = c.newLabel();
|
||||||
@ -342,7 +344,8 @@ const auto ppu_gateway = build_function_asm<void(*)(ppu_thread*)>("ppu_gateway",
|
|||||||
|
|
||||||
// Restore stack ptr
|
// Restore stack ptr
|
||||||
c.ldr(a64::x10, arm::Mem(native_sp_offset));
|
c.ldr(a64::x10, arm::Mem(native_sp_offset));
|
||||||
c.ldr(a64::sp, arm::Mem(args[0], a64::x10));
|
c.ldr(a64::x15, arm::Mem(a64::x20, a64::x10));
|
||||||
|
c.mov(a64::sp, a64::x15);
|
||||||
// Restore registers from the stack
|
// Restore registers from the stack
|
||||||
c.ldp(a64::x18, a64::x19, arm::Mem(a64::sp));
|
c.ldp(a64::x18, a64::x19, arm::Mem(a64::sp));
|
||||||
c.ldp(a64::x20, a64::x21, arm::Mem(a64::sp, 16));
|
c.ldp(a64::x20, a64::x21, arm::Mem(a64::sp, 16));
|
||||||
|
Loading…
Reference in New Issue
Block a user