#include "target_signal.h"
#include "trace.h"
-static struct target_sigaltstack target_sigaltstack_used = {
- .ss_sp = 0,
- .ss_size = 0,
- .ss_flags = TARGET_SS_DISABLE,
-};
-
static struct target_sigaction sigact_table[TARGET_NSIG];
static void host_signal_handler(int host_signum, siginfo_t *info,
static inline int on_sig_stack(unsigned long sp)
{
- return (sp - target_sigaltstack_used.ss_sp
- < target_sigaltstack_used.ss_size);
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
+ return (sp - ts->sigaltstack_used.ss_sp
+ < ts->sigaltstack_used.ss_size);
}
static inline int sas_ss_flags(unsigned long sp)
{
- return (target_sigaltstack_used.ss_size == 0 ? SS_DISABLE
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
+ return (ts->sigaltstack_used.ss_size == 0 ? SS_DISABLE
: on_sig_stack(sp) ? SS_ONSTACK : 0);
}
{
int ret;
struct target_sigaltstack oss;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* XXX: test errors */
if(uoss_addr)
{
- __put_user(target_sigaltstack_used.ss_sp, &oss.ss_sp);
- __put_user(target_sigaltstack_used.ss_size, &oss.ss_size);
+ __put_user(ts->sigaltstack_used.ss_sp, &oss.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_size, &oss.ss_size);
__put_user(sas_ss_flags(sp), &oss.ss_flags);
}
}
}
- target_sigaltstack_used.ss_sp = ss.ss_sp;
- target_sigaltstack_used.ss_size = ss.ss_size;
+ ts->sigaltstack_used.ss_sp = ss.ss_sp;
+ ts->sigaltstack_used.ss_size = ss.ss_size;
}
if (uoss_addr) {
get_sigframe(struct target_sigaction *ka, CPUX86State *env, size_t frame_size)
{
unsigned long esp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* Default to using normal stack */
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) {
- esp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ esp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
} else {
abi_ulong frame_addr, addr;
struct rt_sigframe *frame;
int i;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
trace_user_setup_rt_frame(env, frame_addr);
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext, &frame->fpstate, env,
set->sig[0], frame_addr + offsetof(struct rt_sigframe, fpstate));
abi_ulong sp;
sp = env->xregs[31];
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/*
* This is the X/Open sanctioned signal stack switching.
*/
if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
sp = (sp - sizeof(struct target_rt_sigframe)) & ~15;
{
struct target_rt_sigframe *frame;
abi_ulong frame_addr, return_addr;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env);
trace_user_setup_frame(env, frame_addr);
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp,
+ __put_user(ts->sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->xregs[31]),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
target_setup_sigframe(frame, env, set);
if (ka->sa_flags & TARGET_SA_RESTORER) {
get_sigframe(struct target_sigaction *ka, CPUARMState *regs, int framesize)
{
unsigned long sp = regs->regs[13];
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/*
* This is the X/Open sanctioned signal stack switching.
*/
if ((ka->sa_flags & TARGET_SA_ONSTACK) && !sas_ss_flags(sp)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
/*
* ATPCS B01 mandates 8-byte alignment
struct target_sigaltstack stack;
int i;
abi_ulong *regspace;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* Clear all the bits of the ucontext we don't use. */
memset(uc, 0, offsetof(struct target_ucontext_v2, tuc_mcontext));
memset(&stack, 0, sizeof(stack));
- __put_user(target_sigaltstack_used.ss_sp, &stack.ss_sp);
- __put_user(target_sigaltstack_used.ss_size, &stack.ss_size);
+ __put_user(ts->sigaltstack_used.ss_sp, &stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_size, &stack.ss_size);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)), &stack.ss_flags);
memcpy(&uc->tuc_stack, &stack, sizeof(stack));
struct target_sigaltstack stack;
int i;
abi_ulong info_addr, uc_addr;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
trace_user_setup_rt_frame(env, frame_addr);
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
memset(&frame->uc, 0, offsetof(struct target_ucontext_v1, tuc_mcontext));
memset(&stack, 0, sizeof(stack));
- __put_user(target_sigaltstack_used.ss_sp, &stack.ss_sp);
- __put_user(target_sigaltstack_used.ss_size, &stack.ss_size);
+ __put_user(ts->sigaltstack_used.ss_sp, &stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_size, &stack.ss_size);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)), &stack.ss_flags);
memcpy(&frame->uc.tuc_stack, &stack, sizeof(stack));
unsigned long framesize)
{
abi_ulong sp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
sp = env->regwptr[UREG_FP];
/* 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)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ && !((ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size) & 7)) {
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
}
return sp - framesize;
get_sigframe(struct target_sigaction *ka, CPUMIPSState *regs, size_t frame_size)
{
unsigned long sp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* Default to using normal stack */
sp = regs->active_tc.gpr[29];
/* This is the X/Open sanctioned signal stack switching. */
if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags (sp) == 0)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
return (sp - frame_size) & ~7;
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
int i;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
trace_user_setup_rt_frame(env, frame_addr);
__put_user(0, &frame->rs_uc.tuc_flags);
__put_user(0, &frame->rs_uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp, &frame->rs_uc.tuc_stack.ss_sp);
- __put_user(target_sigaltstack_used.ss_size, &frame->rs_uc.tuc_stack.ss_size);
+ __put_user(ts->sigaltstack_used.ss_sp, &frame->rs_uc.tuc_stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_size, &frame->rs_uc.tuc_stack.ss_size);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->rs_uc.tuc_stack.ss_flags);
static abi_ulong get_sigframe(struct target_sigaction *ka,
unsigned long sp, size_t frame_size)
{
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
+
if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags(sp) == 0)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
return (sp - frame_size) & -8ul;
struct target_rt_sigframe *frame;
abi_ulong frame_addr;
int i;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, regs->gregs[15], sizeof(*frame));
trace_user_setup_rt_frame(regs, frame_addr);
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, (unsigned long *)&frame->uc.tuc_link);
- __put_user((unsigned long)target_sigaltstack_used.ss_sp,
+ __put_user((unsigned long)ts->sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(regs->gregs[15]),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext,
regs, set->sig[0]);
CPUMBState *env, int frame_size)
{
abi_ulong sp = env->regs[1];
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
if ((ka->sa_flags & TARGET_SA_ONSTACK) != 0 && !on_sig_stack(sp)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
return ((sp - frame_size) & -8UL);
{
unsigned long sp = regs->gpr[1];
int onsigstack = on_sig_stack(sp);
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* redzone */
/* This is the X/Open sanctioned signal stack switching. */
if ((ka->sa_flags & TARGET_SA_ONSTACK) != 0 && !onsigstack) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
sp = align_sigframe(sp - frame_size);
unsigned long return_ip;
struct target_rt_sigframe *frame;
abi_ulong info_addr, uc_addr;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
trace_user_setup_rt_frame(env, frame_addr);
/*err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));*/
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp,
+ __put_user(ts->sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->gpr[1]), &frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->sc, env, set->sig[0]);
get_sigframe(struct target_sigaction *ka, CPUS390XState *env, size_t frame_size)
{
abi_ulong sp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* Default to using normal stack */
sp = env->regs[15];
/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa_flags & TARGET_SA_ONSTACK) {
if (!sas_ss_flags(sp)) {
- sp = target_sigaltstack_used.ss_sp +
- target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp +
+ ts->sigaltstack_used.ss_size;
}
}
int i;
rt_sigframe *frame;
abi_ulong frame_addr;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof *frame);
trace_user_setup_rt_frame(env, frame_addr);
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user((abi_ulong)0, (abi_ulong *)&frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(get_sp_from_cpustate(env)),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
+ __put_user(ts->sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
save_sigregs(env, &frame->uc.tuc_mcontext);
for (i = 0; i < TARGET_NSIG_WORDS; i++) {
__put_user((abi_ulong)set->sig[i],
int frame_size)
{
target_ulong oldsp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
oldsp = env->gpr[1];
if ((ka->sa_flags & TARGET_SA_ONSTACK) &&
(sas_ss_flags(oldsp) == 0)) {
- oldsp = (target_sigaltstack_used.ss_sp
- + target_sigaltstack_used.ss_size);
+ oldsp = (ts->sigaltstack_used.ss_sp
+ + ts->sigaltstack_used.ss_size);
}
return (oldsp - frame_size) & ~0xFUL;
#if defined(TARGET_PPC64)
struct image_info *image = ((TaskState *)thread_cpu->opaque)->info;
#endif
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
rt_sf_addr = get_sigframe(ka, env, sizeof(*rt_sf));
if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1))
__put_user(0, &rt_sf->uc.tuc_flags);
__put_user(0, &rt_sf->uc.tuc_link);
- __put_user((target_ulong)target_sigaltstack_used.ss_sp,
+ __put_user((target_ulong)ts->sigaltstack_used.ss_sp,
&rt_sf->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->gpr[1]),
&rt_sf->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&rt_sf->uc.tuc_stack.ss_size);
#if !defined(TARGET_PPC64)
__put_user(h2g (&rt_sf->uc.tuc_mcontext),
size_t frame_size)
{
unsigned long sp;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
sp = regs->aregs[7];
/* This is the X/Open sanctioned signal stack switching. */
if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags (sp) == 0)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
return ((sp - frame_size) & -8UL);
abi_ulong uc_addr;
int err = 0;
int i;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof *frame);
trace_user_setup_rt_frame(env, frame_addr);
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp,
+ __put_user(ts->sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->aregs[7]),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
err |= target_rt_setup_ucontext(&frame->uc, env);
unsigned long framesize)
{
abi_ulong sp = env->ir[IR_SP];
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
/* This is the X/Open sanctioned signal stack switching. */
if ((sa->sa_flags & TARGET_SA_ONSTACK) != 0 && !sas_ss_flags(sp)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
return (sp - framesize) & -32;
}
abi_ulong frame_addr, r26;
struct target_rt_sigframe *frame;
int i, err = 0;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
trace_user_setup_rt_frame(env, frame_addr);
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
__put_user(set->sig[0], &frame->uc.tuc_osf_sigmask);
- __put_user(target_sigaltstack_used.ss_sp,
+ __put_user(ts->sigaltstack_used.ss_sp,
&frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->ir[IR_SP]),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size,
+ __put_user(ts->sigaltstack_used.ss_size,
&frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext, env, frame_addr, set);
for (i = 0; i < TARGET_NSIG_WORDS; ++i) {
size_t frame_size)
{
unsigned long sp = env->regs[TILEGX_R_SP];
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size))) {
return -1UL;
}
if ((ka->sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) {
- sp = target_sigaltstack_used.ss_sp + target_sigaltstack_used.ss_size;
+ sp = ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size;
}
sp -= frame_size;
abi_ulong frame_addr;
struct target_rt_sigframe *frame;
unsigned long restorer;
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
trace_user_setup_rt_frame(env, frame_addr);
/* Create the ucontext. */
__put_user(0, &frame->uc.tuc_flags);
__put_user(0, &frame->uc.tuc_link);
- __put_user(target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
+ __put_user(ts->sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp);
__put_user(sas_ss_flags(env->regs[TILEGX_R_SP]),
&frame->uc.tuc_stack.ss_flags);
- __put_user(target_sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
+ __put_user(ts->sigaltstack_used.ss_size, &frame->uc.tuc_stack.ss_size);
setup_sigcontext(&frame->uc.tuc_mcontext, env, info->si_signo);
if (ka->sa_flags & TARGET_SA_RESTORER) {