aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/signal.c118
1 files changed, 58 insertions, 60 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 9d62e027e3..919aa836fa 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -28,8 +28,7 @@
#include "qemu.h"
#include "qemu-common.h"
#include "target_signal.h"
-
-//#define DEBUG_SIGNAL
+#include "trace.h"
static struct target_sigaltstack target_sigaltstack_used = {
.ss_sp = 0,
@@ -444,7 +443,9 @@ static void QEMU_NORETURN force_sig(int target_sig)
TaskState *ts = (TaskState *)cpu->opaque;
int host_sig, core_dumped = 0;
struct sigaction act;
+
host_sig = target_to_host_signal(target_sig);
+ trace_user_force_sig(env, target_sig, host_sig);
gdb_signalled(env, target_sig);
/* dump core if supported by target binary format */
@@ -499,10 +500,7 @@ int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
abi_ulong handler;
int queue;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "queue_signal: sig=%d\n",
- sig);
-#endif
+ trace_user_queue_signal(env, sig);
k = &ts->sigtab[sig - 1];
queue = gdb_queuesig ();
handler = sigact_table[sig - 1]._sa_handler;
@@ -587,9 +585,7 @@ static void host_signal_handler(int host_signum, siginfo_t *info,
sig = host_to_target_signal(host_signum);
if (sig < 1 || sig > TARGET_NSIG)
return;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "qemu: got signal %d\n", sig);
-#endif
+ trace_user_host_signal(env, host_signum, sig);
host_to_target_siginfo_noswap(&tinfo, info);
if (queue_signal(env, sig, &tinfo) == 1) {
/* interrupt the virtual CPU as soon as possible */
@@ -682,10 +678,6 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (sig < 1 || sig > TARGET_NSIG || sig == TARGET_SIGKILL || sig == TARGET_SIGSTOP)
return -EINVAL;
k = &sigact_table[sig - 1];
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "sigaction sig=%d act=0x%p, oact=0x%p\n",
- sig, act, oact);
-#endif
if (oact) {
__put_user(k->_sa_handler, &oact->_sa_handler);
__put_user(k->sa_flags, &oact->sa_flags);
@@ -909,6 +901,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -970,6 +963,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -1081,9 +1075,7 @@ long do_sigreturn(CPUX86State *env)
sigset_t set;
int eax, i;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "do_sigreturn\n");
-#endif
+ trace_user_do_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
/* set blocked signals */
@@ -1115,6 +1107,7 @@ long do_rt_sigreturn(CPUX86State *env)
int eax;
frame_addr = env->regs[R_ESP] - 4;
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
@@ -1318,6 +1311,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
abi_ulong frame_addr, return_addr;
frame_addr = get_sigframe(ka, env);
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
@@ -1377,6 +1371,7 @@ long do_rt_sigreturn(CPUARMState *env)
struct target_rt_sigframe *frame = NULL;
abi_ulong frame_addr = env->xregs[31];
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 15) {
goto badframe;
}
@@ -1703,6 +1698,7 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka,
abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
int i;
+ trace_user_setup_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
return;
@@ -1724,6 +1720,7 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka,
struct sigframe_v2 *frame;
abi_ulong frame_addr = get_sigframe(ka, regs, sizeof(*frame));
+ trace_user_setup_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
return;
@@ -1756,6 +1753,7 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,
int i;
abi_ulong info_addr, uc_addr;
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
return /* 1 */;
@@ -1796,6 +1794,7 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
abi_ulong frame_addr = get_sigframe(ka, env, sizeof(*frame));
abi_ulong info_addr, uc_addr;
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
return /* 1 */;
@@ -1871,6 +1870,7 @@ static long do_sigreturn_v1(CPUARMState *env)
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
+ trace_user_do_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
@@ -2007,6 +2007,7 @@ static long do_sigreturn_v2(CPUARMState *env)
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
+ trace_user_do_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
@@ -2047,6 +2048,7 @@ static long do_rt_sigreturn_v1(CPUARMState *env)
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
@@ -2088,6 +2090,7 @@ static long do_rt_sigreturn_v2(CPUARMState *env)
* not, then the user is trying to mess with us.
*/
frame_addr = env->regs[13];
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (frame_addr & 7) {
goto badframe;
}
@@ -2283,13 +2286,13 @@ static void setup_frame(int sig, struct target_sigaction *ka,
sigframe_size = NF_ALIGNEDSZ;
sf_addr = get_sigframe(ka, env, sigframe_size);
+ trace_user_setup_frame(env, sf_addr);
sf = lock_user(VERIFY_WRITE, sf_addr,
sizeof(struct target_signal_frame), 0);
if (!sf)
goto sigsegv;
- //fprintf(stderr, "sf: %x pc %x fp %x sp %x\n", sf, env->pc, env->regwptr[UREG_FP], env->regwptr[UREG_SP]);
#if 0
if (invalid_frame_pointer(sf, sigframe_size))
goto sigill_and_return;
@@ -2356,7 +2359,6 @@ sigill_and_return:
force_sig(TARGET_SIGILL);
#endif
sigsegv:
- //fprintf(stderr, "force_sig\n");
unlock_user(sf, sf_addr, sizeof(struct target_signal_frame));
force_sig(TARGET_SIGSEGV);
}
@@ -2378,13 +2380,9 @@ long do_sigreturn(CPUSPARCState *env)
int err=0, i;
sf_addr = env->regwptr[UREG_FP];
+ trace_user_do_sigreturn(env, sf_addr);
if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1))
goto segv_and_exit;
-#if 0
- fprintf(stderr, "sigreturn\n");
- fprintf(stderr, "sf: %x pc %x fp %x sp %x\n", sf, env->pc, env->regwptr[UREG_FP], env->regwptr[UREG_SP]);
-#endif
- //cpu_dump_state(env, stderr, fprintf, 0);
/* 1. Make sure we are not getting garbage from the user */
@@ -2443,6 +2441,7 @@ segv_and_exit:
long do_rt_sigreturn(CPUSPARCState *env)
{
+ trace_user_do_rt_sigreturn(env, 0);
fprintf(stderr, "do_rt_sigreturn: not implemented\n");
return -TARGET_ENOSYS;
}
@@ -2902,6 +2901,7 @@ static void setup_frame(int sig, struct target_sigaction * ka,
int i;
frame_addr = get_sigframe(ka, regs, sizeof(*frame));
+ trace_user_setup_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -2948,10 +2948,8 @@ long do_sigreturn(CPUMIPSState *regs)
target_sigset_t target_set;
int i;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "do_sigreturn\n");
-#endif
frame_addr = regs->active_tc.gpr[29];
+ trace_user_do_sigreturn(regs, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -2998,6 +2996,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -3055,10 +3054,8 @@ long do_rt_sigreturn(CPUMIPSState *env)
abi_ulong frame_addr;
sigset_t blocked;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "do_rt_sigreturn\n");
-#endif
frame_addr = env->active_tc.gpr[29];
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -3216,6 +3213,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int err = 0;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
+ trace_user_setup_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -3265,6 +3263,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
int err = 0;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
+ trace_user_setup_rt_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -3325,10 +3324,8 @@ long do_sigreturn(CPUSH4State *regs)
int i;
int err = 0;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "do_sigreturn\n");
-#endif
frame_addr = regs->gregs[15];
+ trace_user_do_sigreturn(regs, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -3361,10 +3358,8 @@ long do_rt_sigreturn(CPUSH4State *regs)
sigset_t blocked;
target_ulong r0;
-#if defined(DEBUG_SIGNAL)
- fprintf(stderr, "do_rt_sigreturn\n");
-#endif
frame_addr = regs->gregs[15];
+ trace_user_do_rt_sigreturn(regs, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -3514,6 +3509,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto badframe;
@@ -3579,6 +3575,7 @@ long do_sigreturn(CPUMBState *env)
int i;
frame_addr = env->regs[R_SP];
+ trace_user_do_sigreturn(env, frame_addr);
/* Make sure the guest isn't playing games. */
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
goto badframe;
@@ -3604,6 +3601,7 @@ long do_sigreturn(CPUMBState *env)
long do_rt_sigreturn(CPUMBState *env)
{
+ trace_user_do_rt_sigreturn(env, 0);
fprintf(stderr, "Microblaze do_rt_sigreturn: not implemented\n");
return -TARGET_ENOSYS;
}
@@ -3693,6 +3691,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(env, sizeof *frame);
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto badframe;
@@ -3746,6 +3745,7 @@ long do_sigreturn(CPUCRISState *env)
int i;
frame_addr = env->regs[R_SP];
+ trace_user_do_sigreturn(env, frame_addr);
/* Make sure the guest isn't playing games. */
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
goto badframe;
@@ -3767,6 +3767,7 @@ long do_sigreturn(CPUCRISState *env)
long do_rt_sigreturn(CPUCRISState *env)
{
+ trace_user_do_rt_sigreturn(env, 0);
fprintf(stderr, "CRIS do_rt_sigreturn: not implemented\n");
return -TARGET_ENOSYS;
}
@@ -3911,6 +3912,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
abi_ulong info_addr, uc_addr;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
@@ -3972,14 +3974,15 @@ give_sigsegv:
long do_sigreturn(CPUOpenRISCState *env)
{
-
- qemu_log("do_sigreturn: not implemented\n");
+ trace_user_do_sigreturn(env, 0);
+ fprintf(stderr, "do_sigreturn: not implemented\n");
return -TARGET_ENOSYS;
}
long do_rt_sigreturn(CPUOpenRISCState *env)
{
- qemu_log("do_rt_sigreturn: not implemented\n");
+ trace_user_do_rt_sigreturn(env, 0);
+ fprintf(stderr, "do_rt_sigreturn: not implemented\n");
return -TARGET_ENOSYS;
}
/* TARGET_OPENRISC */
@@ -4102,13 +4105,11 @@ static void setup_frame(int sig, struct target_sigaction *ka,
abi_ulong frame_addr;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
- qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
- (unsigned long long)frame_addr);
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
- qemu_log("%s: 1\n", __FUNCTION__);
__put_user(set->sig[0], &frame->sc.oldmask[0]);
save_sigregs(env, &frame->sregs);
@@ -4149,7 +4150,6 @@ static void setup_frame(int sig, struct target_sigaction *ka,
return;
give_sigsegv:
- qemu_log("%s: give_sigsegv\n", __FUNCTION__);
force_sig(TARGET_SIGSEGV);
}
@@ -4162,13 +4162,11 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
abi_ulong frame_addr;
frame_addr = get_sigframe(ka, env, sizeof *frame);
- qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
- (unsigned long long)frame_addr);
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
- qemu_log("%s: 1\n", __FUNCTION__);
tswap_siginfo(&frame->info, info);
/* Create the ucontext. */
@@ -4207,7 +4205,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
return;
give_sigsegv:
- qemu_log("%s: give_sigsegv\n", __FUNCTION__);
force_sig(TARGET_SIGSEGV);
}
@@ -4222,9 +4219,8 @@ restore_sigregs(CPUS390XState *env, target_sigregs *sc)
}
__get_user(env->psw.mask, &sc->regs.psw.mask);
- qemu_log("%s: sc->regs.psw.addr 0x%llx env->psw.addr 0x%llx\n",
- __FUNCTION__, (unsigned long long)sc->regs.psw.addr,
- (unsigned long long)env->psw.addr);
+ trace_user_s390x_restore_sigregs(env, (unsigned long long)sc->regs.psw.addr,
+ (unsigned long long)env->psw.addr);
__get_user(env->psw.addr, &sc->regs.psw.addr);
/* FIXME: 31-bit -> | PSW_ADDR_AMODE */
@@ -4242,11 +4238,10 @@ long do_sigreturn(CPUS390XState *env)
{
sigframe *frame;
abi_ulong frame_addr = env->regs[15];
- qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
- (unsigned long long)frame_addr);
target_sigset_t target_set;
sigset_t set;
+ trace_user_do_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
@@ -4271,10 +4266,9 @@ long do_rt_sigreturn(CPUS390XState *env)
{
rt_sigframe *frame;
abi_ulong frame_addr = env->regs[15];
- qemu_log("%s: frame_addr 0x%llx\n", __FUNCTION__,
- (unsigned long long)frame_addr);
sigset_t set;
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
@@ -4659,6 +4653,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
#endif
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
goto sigsegv;
sc = &frame->sctx;
@@ -4723,7 +4718,6 @@ static void setup_frame(int sig, struct target_sigaction *ka,
sigsegv:
unlock_user_struct(frame, frame_addr, 1);
- qemu_log("segfaulting from setup_frame\n");
force_sig(TARGET_SIGSEGV);
}
@@ -4819,7 +4813,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
sigsegv:
unlock_user_struct(rt_sf, rt_sf_addr, 1);
- qemu_log("segfaulting from setup_rt_frame\n");
force_sig(TARGET_SIGSEGV);
}
@@ -4857,7 +4850,6 @@ long do_sigreturn(CPUPPCState *env)
sigsegv:
unlock_user_struct(sr, sr_addr, 1);
unlock_user_struct(sc, sc_addr, 1);
- qemu_log("segfaulting from do_sigreturn\n");
force_sig(TARGET_SIGSEGV);
return 0;
}
@@ -4913,7 +4905,6 @@ long do_rt_sigreturn(CPUPPCState *env)
sigsegv:
unlock_user_struct(rt_sf, rt_sf_addr, 1);
- qemu_log("segfaulting from do_rt_sigreturn\n");
force_sig(TARGET_SIGSEGV);
return 0;
}
@@ -5037,6 +5028,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -5153,6 +5145,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
int i;
frame_addr = get_sigframe(ka, env, sizeof *frame);
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
@@ -5220,6 +5213,7 @@ long do_sigreturn(CPUM68KState *env)
sigset_t set;
int d0, i;
+ trace_user_do_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -5254,6 +5248,7 @@ long do_rt_sigreturn(CPUM68KState *env)
sigset_t set;
int d0;
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
@@ -5393,6 +5388,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
int err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
@@ -5437,6 +5433,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
int i, err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
@@ -5515,6 +5512,7 @@ long do_rt_sigreturn(CPUAlphaState *env)
struct target_rt_sigframe *frame;
sigset_t set;
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
@@ -5622,6 +5620,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
unsigned long restorer;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
+ trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
@@ -5672,6 +5671,7 @@ long do_rt_sigreturn(CPUTLGState *env)
struct target_rt_sigframe *frame;
sigset_t set;
+ trace_user_do_rt_sigreturn(env, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
@@ -5750,9 +5750,7 @@ void process_pending_signals(CPUArchState *cpu_env)
return;
handle_signal:
-#ifdef DEBUG_SIGNAL
- fprintf(stderr, "qemu: process signal %d\n", sig);
-#endif
+ trace_user_handle_signal(cpu_env, sig);
/* dequeue signal */
q = k->first;
k->first = q->next;