diff mbox

[v2,10/28] linux-user: Support for restarting system calls for SPARC targets

Message ID 1463075272-9933-11-git-send-email-peter.maydell@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Maydell May 12, 2016, 5:47 p.m. UTC
From: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>

Update the SPARC main loop and sigreturn code:
 * on TARGET_ERESTARTSYS, wind guest PC backwards to repeat syscall insn
 * set all guest CPU state within signal.c code on sigreturn
 * handle TARGET_QEMU_ESIGRETURN in the main loop as the indication
   that the main loop should not touch any guest CPU state

Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
Message-id: 1441497448-32489-9-git-send-email-T.E.Baldwin99@members.leeds.ac.uk
[PMM: Commit message tweaks; drop TARGET_USE_ERESTARTSYS define]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/main.c                  | 3 +++
 linux-user/signal.c                | 2 +-
 linux-user/sparc/target_signal.h   | 1 +
 linux-user/sparc64/target_signal.h | 1 +
 4 files changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index be8dcdb..eec68c7 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1375,6 +1375,9 @@  void cpu_loop (CPUSPARCState *env)
                               env->regwptr[2], env->regwptr[3],
                               env->regwptr[4], env->regwptr[5],
                               0, 0);
+            if (ret == -TARGET_ERESTARTSYS || ret == -TARGET_QEMU_ESIGRETURN) {
+                break;
+            }
             if ((abi_ulong)ret >= (abi_ulong)(-515)) {
 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
                 env->xcc |= PSR_CARRY;
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 14e58b0..e742347 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2449,7 +2449,7 @@  long do_sigreturn(CPUSPARCState *env)
         goto segv_and_exit;
     }
     unlock_user_struct(sf, sf_addr, 0);
-    return env->regwptr[0];
+    return -TARGET_QEMU_ESIGRETURN;
 
 segv_and_exit:
     unlock_user_struct(sf, sf_addr, 0);
diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h
index c7de300..2df38c8 100644
--- a/linux-user/sparc/target_signal.h
+++ b/linux-user/sparc/target_signal.h
@@ -33,4 +33,5 @@  static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
     return state->regwptr[UREG_FP];
 }
 
+
 #endif /* TARGET_SIGNAL_H */
diff --git a/linux-user/sparc64/target_signal.h b/linux-user/sparc64/target_signal.h
index c7de300..2df38c8 100644
--- a/linux-user/sparc64/target_signal.h
+++ b/linux-user/sparc64/target_signal.h
@@ -33,4 +33,5 @@  static inline abi_ulong get_sp_from_cpustate(CPUSPARCState *state)
     return state->regwptr[UREG_FP];
 }
 
+
 #endif /* TARGET_SIGNAL_H */