Skip to content
Browse files

Bug fix. Fatal signals should also use SA_SIGINFO handler.

  • Loading branch information...
1 parent 16e96e9 commit abf07d643e1f4f3cb0de7a761b82751fb57decbf @staceyson committed Apr 22, 2013
View
8 work/qemu-1.4.0/bsd-user/main.c
@@ -1022,7 +1022,7 @@ void cpu_loop(CPUMIPSState *env)
switch(trapnr) {
case EXCP_SYSCALL: /* syscall exception */
syscall_num = env->active_tc.gpr[2]; /* v0 */
- env->active_tc.PC += 4;
+ env->active_tc.PC += TARGET_INSN_SIZE;
if (syscall_num >= SYS_MAXSYSCALL) {
ret = -TARGET_ENOSYS;
} else {
@@ -1094,7 +1094,11 @@ void cpu_loop(CPUMIPSState *env)
*/
break;
}
- /* XXX need to handle ERESTART */
+ if (-TARGET_ERESTART == ret) {
+ /* Backup the pc to point at the swi. */
+ env->active_tc.PC -= TARGET_INSN_SIZE;
+ break;
+ }
if ((unsigned int)ret >= (unsigned int)(-1133)) {
env->active_tc.gpr[7] = 1;
ret = -ret;
View
2 work/qemu-1.4.0/bsd-user/mips/target_vmparam.h
@@ -33,6 +33,8 @@ struct target_ps_strings {
#define TARGET_SZSIGCODE 0
+#define TARGET_INSN_SIZE 4
+
#else
#define TARGET_USRSTACK 0
View
2 work/qemu-1.4.0/bsd-user/mips64/target_vmparam.h
@@ -31,6 +31,8 @@ struct target_ps_strings {
#define TARGET_PS_STRINGS (TARGET_USRSTACK - sizeof(struct target_ps_strings))
+#define TARGET_INSN_SIZE 4
+
#else
#define TARGET_USRSTACK 0
View
10 work/qemu-1.4.0/bsd-user/signal.c
@@ -124,6 +124,10 @@ host_to_target_signal(int sig)
if (sig >= _NSIG)
return (sig);
+ if (sig < 0) {
+ printf("host_to_target_signal: sig = %d\n", sig);
+ return (0);
+ }
return (host_to_target_signal_table[sig]);
}
@@ -598,11 +602,13 @@ do_sigaction(int sig, const struct target_sigaction *act,
if (k->_sa_handler == TARGET_SIG_IGN) {
act1.sa_sigaction = (void *)SIG_IGN;
} else if (k->_sa_handler == TARGET_SIG_DFL) {
- if (fatal_signal(sig))
+ if (fatal_signal(sig)) {
+ act1.sa_flags = SA_SIGINFO;
act1.sa_sigaction =
host_signal_handler;
- else
+ } else {
act1.sa_sigaction = (void *)SIG_DFL;
+ }
} else {
act1.sa_flags = SA_SIGINFO;
act1.sa_sigaction = host_signal_handler;
View
9 work/qemu-1.4.0/bsd-user/syscall.c
@@ -3120,6 +3120,15 @@ do_lock_umutex(abi_ulong target_addr, uint32_t id, struct timespec *ts,
0, ts));
}
+ if (NULL == ts) {
+ /*
+ * In the case of no timeout do a restart on this syscall,
+ * if interrupted.
+ */
+ if (-TARGET_EINTR == ret)
+ ret = -TARGET_ERESTART;
+ }
+
return (0);
}

0 comments on commit abf07d6

Please sign in to comment.
Something went wrong with that request. Please try again.