linux-user: Reindent signal handling

Some of the signal handling was a mess with a mixture of tabs and 8 space
indents.

Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
Message-id: 1441497448-32489-3-git-send-email-T.E.Baldwin99@members.leeds.ac.uk
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: just rebased]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
This commit is contained in:
Timothy E Baldwin 2016-05-12 18:47:27 +01:00 committed by Riku Voipio
parent a3ca7bb259
commit da7c8647e5
1 changed files with 775 additions and 736 deletions

View File

@ -873,17 +873,18 @@ get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size)
esp = env->regs[R_ESP];
/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa_flags & TARGET_SA_ONSTACK) {
if (sas_ss_flags(esp) == 0)
if (sas_ss_flags(esp) == 0) {
esp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
}
} else {
/* This is the legacy signal stack switching. */
else
if ((env->segs[R_SS].selector & 0xffff) != __USER_DS &&
!(ka->sa_flags & TARGET_SA_RESTORER) &&
ka->sa_restorer) {
esp = (unsigned long) ka->sa_restorer;
}
}
return (esp - frame_size) & -8ul;
}
@ -943,8 +944,9 @@ static void setup_frame(int sig, struct target_sigaction *ka,
return;
give_sigsegv:
if (sig == TARGET_SIGSEGV)
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
force_sig(TARGET_SIGSEGV /* , current */);
}
@ -1015,8 +1017,9 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
return;
give_sigsegv:
if (sig == TARGET_SIGSEGV)
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
force_sig(TARGET_SIGSEGV /* , current */);
}
@ -1108,12 +1111,14 @@ long do_rt_sigreturn(CPUX86State *env)
target_to_host_sigset(&set, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax))
if (restore_sigcontext(env, &frame->uc.tuc_mcontext, &eax)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe, uc.tuc_stack), 0,
get_sp_from_cpustate(env)) == -EFAULT)
get_sp_from_cpustate(env)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return eax;
@ -1696,8 +1701,9 @@ static void setup_frame_v1(int usig, struct target_sigaction *ka,
int i;
trace_user_setup_frame(regs, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
return;
}
setup_sigcontext(&frame->sc, regs, set->sig[0]);
@ -1718,8 +1724,9 @@ static void setup_frame_v2(int usig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
return;
}
setup_sigframe_v2(&frame->uc, set, regs);
@ -1751,8 +1758,9 @@ static void setup_rt_frame_v1(int usig, struct target_sigaction *ka,
abi_ulong info_addr, uc_addr;
trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
return /* 1 */;
}
info_addr = frame_addr + offsetof(struct rt_sigframe_v1, info);
__put_user(info_addr, &frame->pinfo);
@ -1792,8 +1800,9 @@ static void setup_rt_frame_v2(int usig, struct target_sigaction *ka,
abi_ulong info_addr, uc_addr;
trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
return /* 1 */;
}
info_addr = frame_addr + offsetof(struct rt_sigframe_v2, info);
uc_addr = frame_addr + offsetof(struct rt_sigframe_v2, uc);
@ -1872,8 +1881,9 @@ static long do_sigreturn_v1(CPUARMState *env)
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
__get_user(set.sig[0], &frame->sc.oldmask);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
@ -1883,8 +1893,9 @@ static long do_sigreturn_v1(CPUARMState *env)
target_to_host_sigset_internal(&host_set, &set);
do_sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->sc))
if (restore_sigcontext(env, &frame->sc)) {
goto badframe;
}
#if 0
/* Send SIGTRAP if we're single-stepping */
@ -2009,11 +2020,13 @@ static long do_sigreturn_v2(CPUARMState *env)
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc))
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
@ -2050,14 +2063,16 @@ static long do_rt_sigreturn_v1(CPUARMState *env)
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
target_to_host_sigset(&host_set, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &host_set, NULL);
if (restore_sigcontext(env, &frame->uc.tuc_mcontext))
if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) {
goto badframe;
}
if (do_sigaltstack(frame_addr + offsetof(struct rt_sigframe_v1, uc.tuc_stack), 0, get_sp_from_cpustate(env)) == -EFAULT)
goto badframe;
@ -2092,11 +2107,13 @@ static long do_rt_sigreturn_v2(CPUARMState *env)
goto badframe;
}
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
if (do_sigframe_return_v2(env, frame_addr, &frame->uc))
if (do_sigframe_return_v2(env, frame_addr, &frame->uc)) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return env->regs[0];
@ -2226,9 +2243,10 @@ static inline abi_ulong get_sigframe(struct target_sigaction *sa,
/* This is the X/Open sanctioned signal stack switching. */
if (sa->sa_flags & TARGET_SA_ONSTACK) {
if (!on_sig_stack(sp)
&& !((target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size) & 7))
&& !((target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size) & 7)) {
sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
}
}
return sp - framesize;
}
@ -2287,9 +2305,9 @@ static void setup_frame(int sig, struct target_sigaction *ka,
sf = lock_user(VERIFY_WRITE, sf_addr,
sizeof(struct target_signal_frame), 0);
if (!sf)
if (!sf) {
goto sigsegv;
}
#if 0
if (invalid_frame_pointer(sf, sigframe_size))
goto sigill_and_return;
@ -2327,9 +2345,9 @@ static void setup_frame(int sig, struct target_sigaction *ka,
env->pc = ka->_sa_handler;
env->npc = (env->pc + 4);
/* 5. return to kernel instructions */
if (ka->sa_restorer)
if (ka->sa_restorer) {
env->regwptr[UREG_I7] = ka->sa_restorer;
else {
} else {
uint32_t val32;
env->regwptr[UREG_I7] = sf_addr +
@ -2346,8 +2364,8 @@ static void setup_frame(int sig, struct target_sigaction *ka,
goto sigsegv;
/* Flush instruction space. */
//flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
// tb_flush(CPU(sparc_env_get_cpu(env)));
// flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
// tb_flush(env);
}
unlock_user(sf, sf_addr, sizeof(struct target_signal_frame));
return;
@ -2378,8 +2396,9 @@ long do_sigreturn(CPUSPARCState *env)
sf_addr = env->regwptr[UREG_FP];
trace_user_do_sigreturn(env, sf_addr);
if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1))
if (!lock_user_struct(VERIFY_READ, sf, sf_addr, 1)) {
goto segv_and_exit;
}
/* 1. Make sure we are not getting garbage from the user */
@ -2389,8 +2408,9 @@ long do_sigreturn(CPUSPARCState *env)
__get_user(pc, &sf->info.si_regs.pc);
__get_user(npc, &sf->info.si_regs.npc);
if ((pc | npc) & 3)
if ((pc | npc) & 3) {
goto segv_and_exit;
}
/* 2. Restore the state */
__get_user(up_psr, &sf->info.si_regs.psr);
@ -2426,8 +2446,9 @@ long do_sigreturn(CPUSPARCState *env)
target_to_host_sigset_internal(&host_set, &set);
do_sigprocmask(SIG_SETMASK, &host_set, NULL);
if (err)
if (err) {
goto segv_and_exit;
}
unlock_user_struct(sf, sf_addr, 0);
return env->regwptr[0];
@ -2522,13 +2543,15 @@ void sparc64_set_context(CPUSPARCState *env)
unsigned int i;
ucp_addr = env->regwptr[UREG_I0];
if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1))
if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) {
goto do_sigsegv;
}
grp = &ucp->tuc_mcontext.mc_gregs;
__get_user(pc, &((*grp)[MC_PC]));
__get_user(npc, &((*grp)[MC_NPC]));
if ((pc | npc) & 3)
if ((pc | npc) & 3) {
goto do_sigsegv;
}
if (env->regwptr[UREG_I1]) {
target_sigset_t target_set;
sigset_t set;
@ -2574,11 +2597,13 @@ void sparc64_set_context(CPUSPARCState *env)
w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6];
if (put_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]),
abi_ulong) != 0)
abi_ulong) != 0) {
goto do_sigsegv;
}
if (put_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]),
abi_ulong) != 0)
abi_ulong) != 0) {
goto do_sigsegv;
}
/* FIXME this does not match how the kernel handles the FPU in
* its sparc64_set_context implementation. In particular the FPU
* is only restored if fenab is non-zero in:
@ -2601,7 +2626,7 @@ void sparc64_set_context(CPUSPARCState *env)
&(ucp->tuc_mcontext.mc_fpregs.mcfpu_gsr));
unlock_user_struct(ucp, ucp_addr, 0);
return;
do_sigsegv:
do_sigsegv:
unlock_user_struct(ucp, ucp_addr, 0);
force_sig(TARGET_SIGSEGV);
}
@ -2619,8 +2644,9 @@ void sparc64_get_context(CPUSPARCState *env)
sigset_t set;
ucp_addr = env->regwptr[UREG_I0];
if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0))
if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) {
goto do_sigsegv;
}
mcp = &ucp->tuc_mcontext;
grp = &mcp->mc_gregs;
@ -2671,11 +2697,13 @@ void sparc64_get_context(CPUSPARCState *env)
w_addr = TARGET_STACK_BIAS+env->regwptr[UREG_I6];
fp = i7 = 0;
if (get_user(fp, w_addr + offsetof(struct target_reg_window, ins[6]),
abi_ulong) != 0)
abi_ulong) != 0) {
goto do_sigsegv;
}
if (get_user(i7, w_addr + offsetof(struct target_reg_window, ins[7]),
abi_ulong) != 0)
abi_ulong) != 0) {
goto do_sigsegv;
}
__put_user(fp, &(mcp->mc_fp));
__put_user(i7, &(mcp->mc_i7));
@ -2697,7 +2725,7 @@ void sparc64_get_context(CPUSPARCState *env)
goto do_sigsegv;
unlock_user_struct(ucp, ucp_addr, 1);
return;
do_sigsegv:
do_sigsegv:
unlock_user_struct(ucp, ucp_addr, 1);
force_sig(TARGET_SIGSEGV);
}
@ -2899,8 +2927,9 @@ static void setup_frame(int sig, struct target_sigaction * ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
install_sigtramp(frame->sf_code, TARGET_NR_sigreturn);
@ -2994,8 +3023,9 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
install_sigtramp(frame->rs_code, TARGET_NR_rt_sigreturn);
@ -3053,8 +3083,9 @@ long do_rt_sigreturn(CPUMIPSState *env)
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))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
target_to_host_sigset(&blocked, &frame->rs_uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
@ -3210,8 +3241,9 @@ static void setup_frame(int sig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
setup_sigcontext(&frame->sc, regs, set->sig[0]);
@ -3258,8 +3290,9 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
tswap_siginfo(&frame->info, info);
@ -3319,8 +3352,9 @@ long do_sigreturn(CPUSH4State *regs)
frame_addr = regs->gregs[15];
trace_user_do_sigreturn(regs, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
__get_user(target_set.sig[0], &frame->sc.oldmask);
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
@ -3353,8 +3387,9 @@ long do_rt_sigreturn(CPUSH4State *regs)
frame_addr = regs->gregs[15];
trace_user_do_rt_sigreturn(regs, frame_addr);
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) {
goto badframe;
}
target_to_host_sigset(&blocked, &frame->uc.tuc_sigmask);
do_sigprocmask(SIG_SETMASK, &blocked, NULL);
@ -3363,8 +3398,9 @@ long do_rt_sigreturn(CPUSH4State *regs)
if (do_sigaltstack(frame_addr +
offsetof(struct target_rt_sigframe, uc.tuc_stack),
0, get_sp_from_cpustate(regs)) == -EFAULT)
0, get_sp_from_cpustate(regs)) == -EFAULT) {
goto badframe;
}
unlock_user_struct(frame, frame_addr, 0);
return r0;
@ -3548,7 +3584,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
unlock_user_struct(frame, frame_addr, 1);
return;
badframe:
badframe:
force_sig(TARGET_SIGSEGV);
}
@ -3588,7 +3624,7 @@ long do_sigreturn(CPUMBState *env)
unlock_user_struct(frame, frame_addr, 0);
return env->regs[10];
badframe:
badframe:
force_sig(TARGET_SIGSEGV);
}
@ -3718,7 +3754,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
unlock_user_struct(frame, frame_addr, 1);
return;
badframe:
badframe:
force_sig(TARGET_SIGSEGV);
}
@ -3740,8 +3776,9 @@ long do_sigreturn(CPUCRISState *env)
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1)) {
goto badframe;
}
/* Restore blocked signals */
__get_user(target_set.sig[0], &frame->sc.oldmask);
@ -3754,7 +3791,7 @@ long do_sigreturn(CPUCRISState *env)
restore_sigcontext(&frame->sc, env);
unlock_user_struct(frame, frame_addr, 0);
return env->regs[10];
badframe:
badframe:
force_sig(TARGET_SIGSEGV);
}
@ -5022,8 +5059,9 @@ static void setup_frame(int sig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
__put_user(sig, &frame->sig);
@ -5139,8 +5177,9 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
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))
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
__put_user(sig, &frame->sig);
@ -5402,7 +5441,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
unlock_user_struct(frame, frame_addr, 1);
if (err) {
give_sigsegv:
give_sigsegv:
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
@ -5459,7 +5498,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
}
if (err) {
give_sigsegv:
give_sigsegv:
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
@ -5495,7 +5534,7 @@ long do_sigreturn(CPUAlphaState *env)
unlock_user_struct(sc, sc_addr, 0);
return env->ir[IR_V0];
badframe:
badframe:
force_sig(TARGET_SIGSEGV);
}
@ -5523,7 +5562,7 @@ long do_rt_sigreturn(CPUAlphaState *env)
return env->ir[IR_V0];
badframe:
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
}