Skip to content

Commit

Permalink
Bug fix. Fatal signals should also use SA_SIGINFO handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
staceyson committed Apr 22, 2013
1 parent 16e96e9 commit abf07d6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
8 changes: 6 additions & 2 deletions work/qemu-1.4.0/bsd-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions work/qemu-1.4.0/bsd-user/mips/target_vmparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ struct target_ps_strings {

#define TARGET_SZSIGCODE 0

#define TARGET_INSN_SIZE 4

#else

#define TARGET_USRSTACK 0
Expand Down
2 changes: 2 additions & 0 deletions work/qemu-1.4.0/bsd-user/mips64/target_vmparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions work/qemu-1.4.0/bsd-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions work/qemu-1.4.0/bsd-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit abf07d6

Please sign in to comment.