From 7a894540b9cb234ece5bb0689e9a1da71b65bee6 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 6 Jun 2021 13:26:58 +0200 Subject: [DYNAREC] Fixed potential issue with longjmp native function call --- src/dynarec/dynarec_arm64_00.c | 2 ++ src/dynarec/dynarec_arm64_helper.h | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dynarec/dynarec_arm64_00.c b/src/dynarec/dynarec_arm64_00.c index 61c2d196..72d4d32b 100755 --- a/src/dynarec/dynarec_arm64_00.c +++ b/src/dynarec/dynarec_arm64_00.c @@ -1558,6 +1558,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin LDRw_U12(w1, xEmu, offsetof(x64emu_t, quit)); CBZw_NEXT(w1); MARK; + LOAD_XEMU_REM(); jump_to_epilog(dyn, 0, xRIP, ninst); } } else { @@ -1979,6 +1980,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin LDRw_U12(w1, xEmu, offsetof(x64emu_t, quit)); CBZw_NEXT(w1); // not quitting, so lets continue MARK; + LOAD_XEMU_REM(); // load remaining register, has they have changed jump_to_epilog(dyn, 0, xRIP, ninst); break; default: diff --git a/src/dynarec/dynarec_arm64_helper.h b/src/dynarec/dynarec_arm64_helper.h index 338a1cad..57b56633 100755 --- a/src/dynarec/dynarec_arm64_helper.h +++ b/src/dynarec/dynarec_arm64_helper.h @@ -413,6 +413,7 @@ #define STORE_REG(A) STRx_U12(x##A, xEmu, offsetof(x64emu_t, regs[_##A])) #define STP_REGS(A, B) STPx_S7_offset(x##A, x##B, xEmu, offsetof(x64emu_t, regs[_##A])) +#define LDP_REGS(A, B) LDPx_S7_offset(x##A, x##B, xEmu, offsetof(x64emu_t, regs[_##A])) #define STORE_XEMU_REGS(A) \ STORE_REG(RAX); \ STORE_REG(RCX); \ @@ -478,11 +479,16 @@ if(A) {STPx_S7_offset(xFlags, A, xEmu, offsetof(x64emu_t, eflags));} \ else {STRx_U12(xFlags, xEmu, offsetof(x64emu_t, eflags));} -#define LOAD_XEMU_CALL(A) \ +#define LOAD_XEMU_CALL(A) \ if(A) {LDPx_S7_offset(xFlags, A, xEmu, offsetof(x64emu_t, eflags));} \ else {LDRx_U12(xFlags, xEmu, offsetof(x64emu_t, eflags));}; \ if(A==xRIP) dyn->last_ip = 0 +#define LOAD_XEMU_REM() \ + LDP_REGS(R10, R11); \ + LDP_REGS(R12, R13); \ + LDP_REGS(R14, R15) + #define SET_DFNONE(S) if(!dyn->dfnone) {MOVZw(S, d_none); STRw_U12(S, xEmu, offsetof(x64emu_t, df)); dyn->dfnone=1;} #define SET_DF(S, N) if((N)!=d_none) {MOVZw(S, (N)); STRw_U12(S, xEmu, offsetof(x64emu_t, df)); dyn->dfnone=0;} else SET_DFNONE(S) #define SET_NODF() dyn->dfnone = 0 -- cgit 1.4.1