Signed-off-by: Timothy Edward Baldwin <t.e.baldwi...@members.leeds.ac.uk>
---

WARNING - NOT TESTED

 linux-user/main.c          | 12 +++++++++---
 linux-user/s390x/syscall.h |  2 ++
 linux-user/signal.c        |  4 ++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index 0863945..a59907e 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3355,6 +3355,7 @@ void cpu_loop(CPUS390XState *env)
     int trapnr, n, sig;
     target_siginfo_t info;
     target_ulong addr;
+    abi_long ret;
 
     while (1) {
         cpu_exec_start(cs);
@@ -3372,9 +3373,14 @@ void cpu_loop(CPUS390XState *env)
                 n = env->regs[1];
             }
             env->psw.addr += env->int_svc_ilen;
-            env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3],
-                                      env->regs[4], env->regs[5],
-                                      env->regs[6], env->regs[7], 0, 0);
+            ret = do_syscall(env, n, env->regs[2], env->regs[3],
+                             env->regs[4], env->regs[5],
+                             env->regs[6], env->regs[7], 0, 0);
+            if (ret == -TARGET_ERESTARTSYS) {
+                env->psw.addr -= env->int_svc_ilen;;
+            } else if (ret != -TARGET_QEMU_ESIGRETURN) {
+                env->regs[2] = ret;
+            }
             break;
 
         case EXCP_DEBUG:
diff --git a/linux-user/s390x/syscall.h b/linux-user/s390x/syscall.h
index 35f170a..914ec98 100644
--- a/linux-user/s390x/syscall.h
+++ b/linux-user/s390x/syscall.h
@@ -27,3 +27,5 @@ struct target_pt_regs {
 #define TARGET_MINSIGSTKSZ        2048
 #define TARGET_MLOCKALL_MCL_CURRENT 1
 #define TARGET_MLOCKALL_MCL_FUTURE  2
+
+#define TARGET_USE_ERESTARTSYS 1
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 3bae33b..e17514e 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -4267,7 +4267,7 @@ long do_sigreturn(CPUS390XState *env)
     }
 
     unlock_user_struct(frame, frame_addr, 0);
-    return env->regs[2];
+    return -TARGET_QEMU_ESIGRETURN;
 
 badframe:
     force_sig(TARGET_SIGSEGV);
@@ -4298,7 +4298,7 @@ long do_rt_sigreturn(CPUS390XState *env)
         goto badframe;
     }
     unlock_user_struct(frame, frame_addr, 0);
-    return env->regs[2];
+    return -TARGET_QEMU_ESIGRETURN;
 
 badframe:
     unlock_user_struct(frame, frame_addr, 0);
-- 
2.1.4


Reply via email to