about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/dynarec/dynarec_arm64_helper.c8
-rwxr-xr-xsrc/emu/x64run.c9
2 files changed, 17 insertions, 0 deletions
diff --git a/src/dynarec/dynarec_arm64_helper.c b/src/dynarec/dynarec_arm64_helper.c
index ea8274ae..e598c47b 100755
--- a/src/dynarec/dynarec_arm64_helper.c
+++ b/src/dynarec/dynarec_arm64_helper.c
@@ -462,12 +462,20 @@ void iret_to_epilog(dynarec_arm_t* dyn, int ninst, int is64bits)
     STRH_U12(x2, xEmu, offsetof(x64emu_t, segs[_CS]));
     MOVZw(x1, 0);
     STRx_U12(x1, xEmu, offsetof(x64emu_t, segs_serial[_CS]));
+    STRx_U12(x1, xEmu, offsetof(x64emu_t, segs_serial[_SS]));
     // POP EFLAGS
     POP1(xFlags);
     MOV32w(x1, 0x3F7FD7);
     ANDx_REG(xFlags, xFlags, x1);
     ORRx_mask(xFlags, xFlags, 1, 0b111111, 0);
     SET_DFNONE(x1);
+    // POP RSP
+    POP1(x3);
+    // POP SS
+    POP1(x2);
+    STRH_U12(x2, xEmu, offsetof(x64emu_t, segs[_SS]));
+    // set new RSP
+    MOVx_REG(xRSP, x3);
     // Ret....
     MOV64x(x2, (uintptr_t)arm64_epilog);  // epilog on purpose, CS might have changed!
     BR(x2);
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 782ed520..2699897a 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -46,6 +46,11 @@ int Run(x64emu_t *emu, int step)
 
     if(emu->quit)
         return 0;
+    if(R_RIP==0) {
+        emu->quit = 1;
+        printf_log(LOG_INFO, "Ask to run at NULL, quit silently\n");
+        return 0;
+    }
 
     //ref opcode: http://ref.x64asm.net/geek32.html#xA1
     printf_log(LOG_DEBUG, "Run X86 (%p), RIP=%p, Stack=%p\n", emu, (void*)R_RIP, (void*)R_RSP);
@@ -1067,6 +1072,10 @@ x64emurun:
             emu->segs[_CS] = Pop(emu)&0xffff;
             emu->segs_serial[_CS] = 0;
             emu->eflags.x64 = ((Pop(emu) & 0x3F7FD7)/* & (0xffff-40)*/ ) | 0x2; // mask off res2 and res3 and on res1
+            tmp64u = Pop(emu);  //RSP
+            emu->segs[_SS] = Pop(emu)&0xffff;
+            emu->segs_serial[_SS] = 0;
+            R_RSP= tmp64u;
             RESET_FLAGS(emu);
             goto fini;      // exit, to recompute CS if needed
             break;