aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/machdep.c22
-rw-r--r--sys/i386/include/cpu.h3
-rw-r--r--sys/i386/linux/linux.h1
-rw-r--r--sys/i386/linux/linux_machdep.c2
-rw-r--r--sys/i386/linux/linux_sysvec.c29
-rw-r--r--sys/i386/svr4/svr4_machdep.c2
6 files changed, 32 insertions, 27 deletions
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 2e6416745bb5..5c059291c6b5 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -494,14 +494,16 @@ osendsig(catcher, sig, mask, code)
p = curproc;
psp = p->p_sigacts;
regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ oonstack = sigonstack(regs->tf_esp);
/* Allocate and validate space for the signal handler context. */
if ((p->p_flag & P_ALTSTACK) && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
fp = (struct osigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - sizeof(struct osigframe));
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
p->p_sigstk.ss_flags |= SS_ONSTACK;
+#endif
} else
fp = (struct osigframe *)regs->tf_esp - 1;
@@ -560,7 +562,7 @@ osendsig(catcher, sig, mask, code)
sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp;
/* Build the signal context to be used by osigreturn(). */
- sf.sf_siginfo.si_sc.sc_onstack = oonstack;
+ sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0;
SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask);
sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp;
sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp;
@@ -633,13 +635,15 @@ sendsig(catcher, sig, mask, code)
return;
}
regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ oonstack = sigonstack(regs->tf_esp);
/* Save user context. */
bzero(&sf, sizeof(sf));
sf.sf_uc.uc_sigmask = *mask;
sf.sf_uc.uc_stack = p->p_sigstk;
- sf.sf_uc.uc_mcontext.mc_onstack = oonstack;
+ sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
+ ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
+ sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
sf.sf_uc.uc_mcontext.mc_gs = rgs();
bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs));
@@ -648,7 +652,9 @@ sendsig(catcher, sig, mask, code)
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - sizeof(struct sigframe));
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
p->p_sigstk.ss_flags |= SS_ONSTACK;
+#endif
} else
sfp = (struct sigframe *)regs->tf_esp - 1;
@@ -849,10 +855,13 @@ osigreturn(p, uap)
regs->tf_ss = scp->sc_ss;
regs->tf_isp = scp->sc_isp;
- if (scp->sc_onstack & 01)
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+ if (scp->sc_onstack & 1)
p->p_sigstk.ss_flags |= SS_ONSTACK;
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
+#endif
+
SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
regs->tf_ebp = scp->sc_fp;
@@ -958,10 +967,13 @@ sigreturn(p, uap)
bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
}
+
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
if (ucp->uc_mcontext.mc_onstack & 1)
p->p_sigstk.ss_flags |= SS_ONSTACK;
else
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
+#endif
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h
index 669af64c1b47..9293ba29b741 100644
--- a/sys/i386/include/cpu.h
+++ b/sys/i386/include/cpu.h
@@ -58,7 +58,8 @@
#define cpu_exec(p) /* nothing */
#define cpu_swapin(p) /* nothing */
-#define cpu_setstack(p, ap) ((p)->p_md.md_regs[SP] = (ap))
+#define cpu_getstack(p) ((p)->p_md.md_regs->tf_esp)
+#define cpu_setstack(p, ap) ((p)->p_md.md_regs->tf_esp = (ap))
#define CLKF_USERMODE(framep) \
((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM))
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index d253897cd941..8aff68a2ec98 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -163,7 +163,6 @@ struct linux_new_utsname {
/* sigaltstack */
#define LINUX_MINSIGSTKSZ 2048
-#define LINUX_SS_ONSTACK_BC 0 /* backwards compat SS_ONSTACK */
#define LINUX_SS_ONSTACK 1
#define LINUX_SS_DISABLE 2
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index c152a108d2bf..7e4b37e4b320 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -82,8 +82,6 @@ linux_to_bsd_sigaltstack(int lsa)
bsa |= SS_DISABLE;
if (lsa & LINUX_SS_ONSTACK)
bsa |= SS_ONSTACK;
- if (lsa == LINUX_SS_ONSTACK_BC)
- bsa = SS_ONSTACK;
return (bsa);
}
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 7d7fccbdfc2f..cd944a2a4880 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -205,7 +205,7 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
int oonstack;
regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ oonstack = sigonstack(regs->tf_esp);
#ifdef DEBUG
printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n",
@@ -218,10 +218,8 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else {
+ } else
fp = (struct linux_rt_sigframe *)regs->tf_esp - 1;
- }
/*
* grow() will return FALSE if the fp will not fit inside the stack
@@ -240,8 +238,8 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
SIGDELSET(p->p_sigcatch, SIGILL);
SIGDELSET(p->p_sigmask, SIGILL);
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, SS_ONSTACK: 0x%x ",
- (long)p->p_pid, fp, p->p_sigstk.ss_flags & SS_ONSTACK);
+ printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, "
+ "oonstack=%x\n", (long)p->p_pid, fp, oonstack);
#endif
psignal(p, SIGILL);
return;
@@ -271,9 +269,9 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
frame.sf_sc.uc_link = NULL; /* XXX ??? */
frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp;
- frame.sf_sc.uc_stack.ss_flags =
- bsd_to_linux_sigaltstack(p->p_sigstk.ss_flags);
frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size;
+ frame.sf_sc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
+ ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
@@ -298,9 +296,10 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
frame.sf_sc.uc_mcontext.sc_trapno = code; /* XXX ???? */
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n",
- (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags, p->p_sigstk.ss_sp,
- p->p_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask);
+ printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, "
+ "mask: 0x%x\n", (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags,
+ p->p_sigstk.ss_sp, p->p_sigstk.ss_size,
+ frame.sf_sc.uc_mcontext.sc_mask);
#endif
if (copyout(&frame, fp, sizeof(frame)) != 0) {
@@ -355,7 +354,7 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
}
regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ oonstack = sigonstack(regs->tf_esp);
#ifdef DEBUG
printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n",
@@ -369,10 +368,8 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - sizeof(struct linux_sigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else {
+ } else
fp = (struct linux_sigframe *)regs->tf_esp - 1;
- }
/*
* grow() will return FALSE if the fp will not fit inside the stack
@@ -521,7 +518,6 @@ linux_sigreturn(p, args)
return(EINVAL);
}
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
lmask.__bits[0] = frame.sf_sc.sc_mask;
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
lmask.__bits[i+1] = frame.sf_extramask[i];
@@ -621,7 +617,6 @@ linux_rt_sigreturn(p, args)
return(EINVAL);
}
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
SIG_CANTMASK(p->p_sigmask);
diff --git a/sys/i386/svr4/svr4_machdep.c b/sys/i386/svr4/svr4_machdep.c
index 38c5cc8fb500..018fb74d3b0f 100644
--- a/sys/i386/svr4/svr4_machdep.c
+++ b/sys/i386/svr4/svr4_machdep.c
@@ -404,7 +404,7 @@ svr4_sendsig(catcher, sig, mask, code)
#endif
tf = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ oonstack = sigonstack(tf->tf_esp);
/*
* Allocate space for the signal handler context.