aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorLuoqi Chen <luoqi@FreeBSD.org>1999-10-11 20:33:17 +0000
committerLuoqi Chen <luoqi@FreeBSD.org>1999-10-11 20:33:17 +0000
commit645682fd40b5855a1dfbca5ddb330dda7cf5ddc0 (patch)
tree7cad9d7dad8a4c0a9a157153dada2dbbd270e491 /sys/amd64
parent456b2f80635b3455ab32f16fa5460146f93583c8 (diff)
Notes
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/genassym.c10
-rw-r--r--sys/amd64/amd64/locore.S30
-rw-r--r--sys/amd64/amd64/locore.s30
-rw-r--r--sys/amd64/amd64/machdep.c61
-rw-r--r--sys/amd64/amd64/support.S15
-rw-r--r--sys/amd64/amd64/support.s15
-rw-r--r--sys/amd64/include/md_var.h3
-rw-r--r--sys/amd64/include/ucontext.h2
8 files changed, 85 insertions, 81 deletions
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
index b95a9a7c79d9..d137b12d35ac 100644
--- a/sys/amd64/amd64/genassym.c
+++ b/sys/amd64/amd64/genassym.c
@@ -148,8 +148,18 @@ main()
printf("#define\tTF_EFLAGS %#x\n", OS(trapframe, tf_eflags));
printf("#define\tSIGF_HANDLER %#x\n", OS(sigframe, sf_ahu.sf_handler));
+ printf("#define\tSIGF_SC %#x\n", OS(osigframe, sf_siginfo.si_sc));
printf("#define\tSIGF_UC %#x\n", OS(sigframe, sf_uc));
+ printf("#define\tSC_PS %#x\n", OS(osigcontext, sc_ps));
+ printf("#define\tSC_FS %#x\n", OS(osigcontext, sc_fs));
+ printf("#define\tSC_GS %#x\n", OS(osigcontext, sc_gs));
+ printf("#define\tSC_TRAPNO %#x\n", OS(osigcontext, sc_trapno));
+
+ printf("#define\tUC_EFLAGS %#x\n",
+ OS(__ucontext, uc_mcontext.mc_eflags));
+ printf("#define\tUC_GS %#x\n", OS(__ucontext, uc_mcontext.mc_gs));
+
printf("#define\tB_READ %#x\n", B_READ);
printf("#define\tENOENT %d\n", ENOENT);
printf("#define\tEFAULT %d\n", EFAULT);
diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S
index a1b6ff7e95fe..2abcc803ce5f 100644
--- a/sys/amd64/amd64/locore.S
+++ b/sys/amd64/amd64/locore.S
@@ -417,19 +417,39 @@ NON_GPROF_ENTRY(sigcode)
call SIGF_HANDLER(%esp) /* call signal handler */
lea SIGF_UC(%esp),%eax /* get ucontext_t */
pushl %eax
- movl $SYS_osigreturn,%eax
+ testl $PSL_VM,UC_EFLAGS(%eax)
+ jne 9f
+ movl UC_GS(%eax),%gs /* restore %gs */
+9:
+ movl $SYS_sigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
- /* on stack */
-1:
- jmp 1b
+0: jmp 0b
+
+ ALIGN_TEXT
+_osigcode:
+ call SIGF_HANDLER(%esp) /* call signal handler */
+ lea SIGF_SC(%esp),%eax /* get sigcontext */
+ pushl %eax
+ testl $PSL_VM,SC_PS(%eax)
+ jne 9f
+ movl SC_GS(%eax),%gs /* restore %gs */
+9:
+ movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
+ movl $SYS_sigreturn,%eax
+ pushl %eax /* junk to fake return addr. */
+ int $0x80 /* enter kernel with args */
+0: jmp 0b
+
ALIGN_TEXT
_esigcode:
.data
- .globl _szsigcode
+ .globl _szsigcode, _oszsigcode
_szsigcode:
.long _esigcode-_sigcode
+_oszsigcode:
+ .long _esigcode-_osigcode
.text
/**********************************************************************
diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s
index a1b6ff7e95fe..2abcc803ce5f 100644
--- a/sys/amd64/amd64/locore.s
+++ b/sys/amd64/amd64/locore.s
@@ -417,19 +417,39 @@ NON_GPROF_ENTRY(sigcode)
call SIGF_HANDLER(%esp) /* call signal handler */
lea SIGF_UC(%esp),%eax /* get ucontext_t */
pushl %eax
- movl $SYS_osigreturn,%eax
+ testl $PSL_VM,UC_EFLAGS(%eax)
+ jne 9f
+ movl UC_GS(%eax),%gs /* restore %gs */
+9:
+ movl $SYS_sigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
- /* on stack */
-1:
- jmp 1b
+0: jmp 0b
+
+ ALIGN_TEXT
+_osigcode:
+ call SIGF_HANDLER(%esp) /* call signal handler */
+ lea SIGF_SC(%esp),%eax /* get sigcontext */
+ pushl %eax
+ testl $PSL_VM,SC_PS(%eax)
+ jne 9f
+ movl SC_GS(%eax),%gs /* restore %gs */
+9:
+ movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
+ movl $SYS_sigreturn,%eax
+ pushl %eax /* junk to fake return addr. */
+ int $0x80 /* enter kernel with args */
+0: jmp 0b
+
ALIGN_TEXT
_esigcode:
.data
- .globl _szsigcode
+ .globl _szsigcode, _oszsigcode
_szsigcode:
.long _esigcode-_sigcode
+_oszsigcode:
+ .long _esigcode-_osigcode
.text
/**********************************************************************
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index a6820985d6ff..0bc5838f694d 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -483,14 +483,14 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
int oonstack;
regs = p->p_md.md_regs;
- oonstack = (psp->ps_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
+ oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
/* Allocate and validate space for the signal handler context. */
- if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&
+ if ((p->p_flag & P_ALTSTACK) && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
- fp = (struct osigframe *)(psp->ps_sigstk.ss_sp +
- psp->ps_sigstk.ss_size - sizeof(struct osigframe));
- psp->ps_sigstk.ss_flags |= SS_ONSTACK;
+ fp = (struct osigframe *)(p->p_sigstk.ss_sp +
+ p->p_sigstk.ss_size - sizeof(struct osigframe));
+ p->p_sigstk.ss_flags |= SS_ONSTACK;
}
else
fp = (struct osigframe *)regs->tf_esp - 1;
@@ -594,7 +594,7 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
}
regs->tf_esp = (int)fp;
- regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
+ regs->tf_eip = PS_STRINGS - oszsigcode;
regs->tf_cs = _ucodesel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
@@ -610,37 +610,34 @@ sendsig(catcher, sig, mask, code)
sigset_t *mask;
u_long code;
{
- struct proc *p;
+ struct proc *p = curproc;
struct trapframe *regs;
- struct sigacts *psp;
+ struct sigacts *psp = p->p_sigacts;
struct sigframe sf, *sfp;
- int onstack;
-
- p = curproc;
+ int oonstack;
- if ((p->p_flag & P_NEWSIGSET) == 0) {
+ if (SIGISMEMBER(psp->ps_osigset, sig)) {
osendsig(catcher, sig, mask, code);
return;
}
regs = p->p_md.md_regs;
- psp = p->p_sigacts;
- onstack = (psp->ps_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
+ oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
/* save user context */
bzero(&sf, sizeof(struct sigframe));
sf.sf_uc.uc_sigmask = *mask;
- sf.sf_uc.uc_stack = psp->ps_sigstk;
- sf.sf_uc.uc_mcontext.mc_onstack = onstack;
+ sf.sf_uc.uc_stack = p->p_sigstk;
+ sf.sf_uc.uc_mcontext.mc_onstack = oonstack;
sf.sf_uc.uc_mcontext.mc_gs = rgs();
bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(struct trapframe));
/* Allocate and validate space for the signal handler context. */
- if ((psp->ps_flags & SAS_ALTSTACK) != 0 && !onstack &&
+ if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
- sfp = (struct sigframe *)(psp->ps_sigstk.ss_sp +
- psp->ps_sigstk.ss_size - sizeof(struct sigframe));
- psp->ps_sigstk.ss_flags |= SS_ONSTACK;
+ sfp = (struct sigframe *)(p->p_sigstk.ss_sp +
+ p->p_sigstk.ss_size - sizeof(struct sigframe));
+ p->p_sigstk.ss_flags |= SS_ONSTACK;
}
else
sfp = (struct sigframe *)regs->tf_esp - 1;
@@ -770,9 +767,6 @@ osigreturn(p, uap)
register struct trapframe *regs = p->p_md.md_regs;
int eflags;
- if ((p->p_flag & P_NEWSIGSET) != 0)
- return sigreturn(p, (struct sigreturn_args *)uap);
-
scp = uap->sigcntxp;
if (useracc((caddr_t)scp, sizeof (struct osigcontext), B_WRITE) == 0)
@@ -841,10 +835,6 @@ osigreturn(p, uap)
regs->tf_ds = scp->sc_ds;
regs->tf_es = scp->sc_es;
regs->tf_fs = scp->sc_fs;
- if (load_gs_param(scp->sc_gs)) {
- trapsignal(p, SIGBUS, T_SEGNPFLT);
- return (EFAULT);
- }
}
/* restore scratch registers */
@@ -859,11 +849,11 @@ osigreturn(p, uap)
regs->tf_isp = scp->sc_isp;
if (scp->sc_onstack & 01)
- p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ p->p_sigstk.ss_flags |= SS_ONSTACK;
else
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigstk.ss_flags &= ~SS_ONSTACK;
- OSIG2SIG(scp->sc_mask, p->p_sigmask);
+ SIGSETOLD(p->p_sigmask, scp->sc_mask);
SIG_CANTMASK(p->p_sigmask);
regs->tf_ebp = scp->sc_fp;
regs->tf_esp = scp->sc_sp;
@@ -883,7 +873,8 @@ sigreturn(p, uap)
ucontext_t *ucp;
int cs, eflags;
- p->p_flag |= P_NEWSIGSET;
+ if (((struct osigcontext *)uap->sigcntxp)->sc_trapno == 0x01d516)
+ return osigreturn(p, (struct osigreturn_args *)uap);
regs = p->p_md.md_regs;
ucp = uap->sigcntxp;
@@ -956,16 +947,12 @@ sigreturn(p, uap)
return(EINVAL);
}
bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(struct trapframe));
- if (load_gs_param(ucp->uc_mcontext.mc_gs)) {
- trapsignal(p, SIGBUS, T_SEGNPFLT);
- return (EFAULT);
- }
}
if (ucp->uc_mcontext.mc_onstack & 1)
- p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ p->p_sigstk.ss_flags |= SS_ONSTACK;
else
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ucp->uc_sigmask;
SIG_CANTMASK(p->p_sigmask);
diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S
index 6a6e9fc9b69c..ae99af947ab8 100644
--- a/sys/amd64/amd64/support.S
+++ b/sys/amd64/amd64/support.S
@@ -1586,21 +1586,6 @@ ENTRY(load_cr4)
movl %eax,%cr4
ret
-/* int load_gs_param(caddr_t gs) */
-ENTRY(load_gs_param)
- movl _curpcb,%ecx
- movl $load_gs_param_fault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%eax
- movl %eax,%gs
- xor %eax,%eax
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-load_gs_param_fault:
- movl _curpcb,%ecx
- movl $0,PCB_ONFAULT(%ecx)
- movl $EFAULT,%eax
- ret
-
/*****************************************************************************/
/* setjump, longjump */
/*****************************************************************************/
diff --git a/sys/amd64/amd64/support.s b/sys/amd64/amd64/support.s
index 6a6e9fc9b69c..ae99af947ab8 100644
--- a/sys/amd64/amd64/support.s
+++ b/sys/amd64/amd64/support.s
@@ -1586,21 +1586,6 @@ ENTRY(load_cr4)
movl %eax,%cr4
ret
-/* int load_gs_param(caddr_t gs) */
-ENTRY(load_gs_param)
- movl _curpcb,%ecx
- movl $load_gs_param_fault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%eax
- movl %eax,%gs
- xor %eax,%eax
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-load_gs_param_fault:
- movl _curpcb,%ecx
- movl $0,PCB_ONFAULT(%ecx)
- movl $EFAULT,%eax
- ret
-
/*****************************************************************************/
/* setjump, longjump */
/*****************************************************************************/
diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h
index d9a43fa29007..e0bc65acfb9a 100644
--- a/sys/amd64/include/md_var.h
+++ b/sys/amd64/include/md_var.h
@@ -58,7 +58,7 @@ extern void (*netisrs[32]) __P((void));
extern int nfs_diskless_valid;
extern void (*ovbcopy_vector) __P((const void *from, void *to, size_t len));
extern char sigcode[];
-extern int szsigcode;
+extern int szsigcode, oszsigcode;
typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss));
struct proc;
@@ -91,7 +91,6 @@ int i586_copyout __P((const void *kaddr, void *udaddr, size_t len));
void i686_pagezero __P((void *addr));
int is_physical_memory __P((vm_offset_t addr));
u_long kvtop __P((void *addr));
-int load_gs_param __P((u_int sel));
void setidt __P((int idx, alias_for_inthand_t *func, int typ, int dpl,
int selec));
void swi_vm __P((void));
diff --git a/sys/amd64/include/ucontext.h b/sys/amd64/include/ucontext.h
index 6397a31a309a..c0a3aa8e1c6e 100644
--- a/sys/amd64/include/ucontext.h
+++ b/sys/amd64/include/ucontext.h
@@ -31,8 +31,6 @@
#ifndef _MACHINE_UCONTEXT_H_
#define _MACHINE_UCONTEXT_H_
-#include <machine/frame.h>
-
typedef struct __mcontext {
/*
* The first 20 fields must match the definition of