Save and restore %fs and %gs across signals.

This commit is contained in:
mycroft 1995-05-01 14:15:07 +00:00
parent 4eea138a48
commit 8792c8e284
7 changed files with 193 additions and 57 deletions

@ -1,4 +1,4 @@
/* $NetBSD: genassym.c,v 1.40 1995/05/01 13:16:16 mycroft Exp $ */
/* $NetBSD: genassym.c,v 1.41 1995/05/01 14:15:07 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -72,15 +72,18 @@ main()
struct pcb *pcb = 0;
struct trapframe *tf = 0;
struct sigframe *sigf = 0;
struct sigcontext *sc = 0;
struct uprof *uprof = 0;
#if NISA > 0
struct intrhand *ih = 0;
#endif
#ifdef COMPAT_SVR4
struct svr4_sigframe *svr4_sigf = 0;
struct svr4_ucontext *svr4_uc = 0;
#endif
#ifdef COMPAT_LINUX
struct linux_sigframe *lsigf = 0;
struct linux_sigframe *linux_sigf = 0;
struct linux_sigcontext *linux_sc = 0;
#endif
#define def(N,V) printf("#define\t%s %d\n", N, V)
@ -122,6 +125,25 @@ main()
def("SIGF_HANDLER", &sigf->sf_handler);
def("SIGF_SC", &sigf->sf_sc);
def("SC_FS", &sc->sc_fs);
def("SC_GS", &sc->sc_gs);
def("SC_EFLAGS", &sc->sc_eflags);
#ifdef COMPAT_SVR4
def("SVR4_SIGF_HANDLER", &svr4_sigf->sf_handler);
def("SVR4_SIGF_UC", &svr4_sigf->sf_uc);
def("SVR4_UC_FS", &svr4_uc->uc_mcontext.greg[SVR4_X86_FS]);
def("SVR4_UC_GS", &svr4_uc->uc_mcontext.greg[SVR4_X86_GS]);
def("SVR4_UC_EFLAGS", &svr4_uc->uc_mcontext.greg[SVR4_X86_EFLAGS]);
#endif
#ifdef COMPAT_LINUX
def("LINUX_SIGF_HANDLER", &linux_sigf->ls_handler);
def("LINUX_SIGF_SC", &linux_sigf->ls_sc);
def("LINUX_SC_FS", &linux_sc->lsc_fs);
def("LINUX_SC_GS", &linux_sc->lsc_gs);
def("LINUX_SC_EFLAGS", &linux_sc->lsc_eflags);
#endif
#if NISA > 0
def("IH_FUN", &ih->ih_fun);
@ -130,14 +152,5 @@ main()
def("IH_NEXT", &ih->ih_next);
#endif
#ifdef COMPAT_SVR4
def("SVR4_SIGF_HANDLER", &svr4_sigf->sf_handler);
def("SVR4_SIGF_UC", &svr4_sigf->sf_uc);
#endif
#ifdef COMPAT_LINUX
def("LINUX_SIGF_HANDLER", &lsigf->ls_handler);
def("LINUX_SIGF_SC", &lsigf->ls_sc);
#endif
exit(0);
}

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.c,v 1.3 1995/05/01 08:06:22 mycroft Exp $ */
/* $NetBSD: linux_machdep.c,v 1.4 1995/05/01 14:15:09 mycroft Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@ -114,10 +114,21 @@ linux_sendsig(catcher, sig, mask, code)
* Build the signal context to be used by sigreturn.
*/
frame.ls_sc.lsc_mask = mask;
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_fs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_gs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_ds = tf->tf_ds;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.ls_sc.lsc_gs = tf->tf_vm86_gs;
frame.ls_sc.lsc_fs = tf->tf_vm86_fs;
frame.ls_sc.lsc_es = tf->tf_vm86_es;
frame.ls_sc.lsc_ds = tf->tf_vm86_ds;
} else
#else
{
__asm("movl %%gs,%w0" : "=r" (frame.ls_sc.sc_gs));
__asm("movl %%fs,%w0" : "=r" (frame.ls_sc.sc_fs));
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_ds = tf->tf_ds;
}
#endif
frame.ls_sc.lsc_edi = tf->tf_edi;
frame.ls_sc.lsc_esi = tf->tf_esi;
frame.ls_sc.lsc_ebp = tf->tf_ebp;
@ -202,8 +213,19 @@ linux_sigreturn(p, uap, retval)
/*
* Restore signal context.
*/
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
#ifdef VM86
if (context.lsc_eflags & PSL_VM) {
tf->tf_vm86_gs = context.lsc_gs;
tf->tf_vm86_fs = context.lsc_fs;
tf->tf_vm86_es = context.lsc_es;
tf->tf_vm86_ds = context.lsc_ds;
} else
#endif
{
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
}
tf->tf_edi = context.lsc_edi;
tf->tf_esi = context.lsc_esi;
tf->tf_ebp = context.lsc_ebp;

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.129 1995/05/01 13:02:24 mycroft Exp $ */
/* $NetBSD: locore.s,v 1.130 1995/05/01 14:15:13 mycroft Exp $ */
#undef DIAGNOSTIC
#define DIAGNOSTIC
@ -520,7 +520,15 @@ ENTRY(sigcode)
call SIGF_HANDLER(%esp)
leal SIGF_SC(%esp),%eax # scp (the call may have clobbered the
# copy at SIGF_SCP(%esp))
pushl %eax
#ifdef VM86
testl $PSL_VM,SC_EFLAGS(%eax)
jnz 1f
#endif
movl SC_FS(%eax),%ecx
movl SC_GS(%eax),%edx
movl %cx,%fs
movl %dx,%gs
1: pushl %eax
pushl %eax # junk to fake return address
movl $SYS_sigreturn,%eax
int $0x80 # enter kernel with args on stack
@ -536,7 +544,15 @@ ENTRY(svr4_sigcode)
call SVR4_SIGF_HANDLER(%esp)
leal SVR4_SIGF_UC(%esp),%eax # ucp (the call may have clobbered the
# copy at SIGF_UCP(%esp))
pushl %eax
#ifdef VM86
testl $PSL_VM,SVR4_UC_EFLAGS(%eax)
jnz 1f
#endif
movl SVR4_UC_FS(%eax),%ecx
movl SVR4_UC_GS(%eax),%edx
movl %cx,%fs
movl %dx,%gs
1: pushl %eax
pushl $1 # setcontext(p) == syscontext(1, p)
pushl %eax # junk to fake return address
movl $SVR4_SYS_svr4_context,%eax
@ -557,7 +573,15 @@ ENTRY(linux_sigcode)
call LINUX_SIGF_HANDLER(%esp)
leal LINUX_SIGF_SC(%esp),%ebx # scp (the call may have clobbered the
# copy at SIGF_SCP(%esp))
pushl %eax # junk to fake return address
#ifdef VM86
testl $PSL_VM,LINUX_SC_EFLAGS(%ebx)
jnz 1f
#endif
movl LINUX_SC_FS(%eax),%ecx
movl LINUX_SC_GS(%eax),%edx
movl %cx,%fs
movl %dx,%gs
1: pushl %eax # junk to fake return address
movl $LINUX_SYS_linux_sigreturn,%eax
int $0x80 # enter kernel with args on stack
movl $LINUX_SYS_exit,%eax

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.156 1995/05/01 13:02:29 mycroft Exp $ */
/* $NetBSD: machdep.c,v 1.157 1995/05/01 14:15:18 mycroft Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
@ -530,8 +530,20 @@ sendsig(catcher, sig, mask, code)
*/
frame.sf_sc.sc_onstack = oonstack;
frame.sf_sc.sc_mask = mask;
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.sf_sc.sc_gs = tf->tf_vm86_gs;
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
} else
#endif
{
__asm("movl %%gs,%w0" : "=r" (frame.sf_sc.sc_gs));
__asm("movl %%fs,%w0" : "=r" (frame.sf_sc.sc_fs));
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
}
frame.sf_sc.sc_edi = tf->tf_edi;
frame.sf_sc.sc_esi = tf->tf_esi;
frame.sf_sc.sc_ebp = tf->tf_ebp;
@ -618,8 +630,19 @@ sigreturn(p, uap, retval)
/*
* Restore signal context.
*/
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
#ifdef VM86
if (context.sc_eflags & PSL_VM) {
tf->tf_vm86_gs = context.sc_gs;
tf->tf_vm86_fs = context.sc_fs;
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
} else
#endif
{
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
}
tf->tf_edi = context.sc_edi;
tf->tf_esi = context.sc_esi;
tf->tf_ebp = context.sc_ebp;

@ -1,4 +1,4 @@
/* $NetBSD: svr4_machdep.c,v 1.7 1995/05/01 08:06:49 mycroft Exp $ */
/* $NetBSD: svr4_machdep.c,v 1.8 1995/05/01 14:15:20 mycroft Exp $ */
/*
* Copyright (c) 1994 Christos Zoulas
@ -73,15 +73,20 @@ svr4_getcontext(p, uc, mask, oonstack)
/*
* Set the general purpose registers
*/
#ifdef notyet
__asm("movl %%gs,%w0" : "=r" (r[SVR4_X86_GS]));
__asm("movl %%fs,%w0" : "=r" (r[SVR4_X86_FS]));
#else
r[SVR4_X86_GS] = 0;
r[SVR4_X86_FS] = 0;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
r[SVR4_X86_GS] = tf->tf_vm86_gs;
r[SVR4_X86_FS] = tf->tf_vm86_fs;
r[SVR4_X86_ES] = tf->tf_vm86_es;
r[SVR4_X86_DS] = tf->tf_vm86_ds;
} else
#endif
r[SVR4_X86_ES] = tf->tf_es;
r[SVR4_X86_DS] = tf->tf_ds;
{
__asm("movl %%gs,%w0" : "=r" (r[SVR4_X86_GS]));
__asm("movl %%fs,%w0" : "=r" (r[SVR4_X86_FS]));
r[SVR4_X86_ES] = tf->tf_es;
r[SVR4_X86_DS] = tf->tf_ds;
}
r[SVR4_X86_EDI] = tf->tf_edi;
r[SVR4_X86_ESI] = tf->tf_esi;
r[SVR4_X86_EBP] = tf->tf_ebp;
@ -170,14 +175,19 @@ svr4_setcontext(p, uc)
/*
* Restore register context.
*/
#ifdef notyet
__asm("movl %w0,%%gs" : "=r" (r[SVR4_X86_GS]));
__asm("movl %w0,%%fs" : "=r" (r[SVR4_X86_FS]));
tf->tf_vm86_gs = r[SVR4_X86_GS];
tf->tf_vm86_fs = r[SVR4_X86_FS];
#ifdef VM86
if (r[SVR4_X86_EFL] & PSL_VM) {
tf->tf_vm86_gs = r[SVR4_X86_GS];
tf->tf_vm86_fs = r[SVR4_X86_FS];
tf->tf_vm86_es = r[SVR4_X86_ES];
tf->tf_vm86_ds = r[SVR4_X86_DS];
} else
#endif
tf->tf_es = r[SVR4_X86_ES];
tf->tf_ds = r[SVR4_X86_DS];
{
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = r[SVR4_X86_ES];
tf->tf_ds = r[SVR4_X86_DS];
}
tf->tf_edi = r[SVR4_X86_EDI];
tf->tf_esi = r[SVR4_X86_ESI];
tf->tf_ebp = r[SVR4_X86_EBP];

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.c,v 1.3 1995/05/01 08:06:22 mycroft Exp $ */
/* $NetBSD: linux_machdep.c,v 1.4 1995/05/01 14:15:09 mycroft Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@ -114,10 +114,21 @@ linux_sendsig(catcher, sig, mask, code)
* Build the signal context to be used by sigreturn.
*/
frame.ls_sc.lsc_mask = mask;
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_fs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_gs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_ds = tf->tf_ds;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.ls_sc.lsc_gs = tf->tf_vm86_gs;
frame.ls_sc.lsc_fs = tf->tf_vm86_fs;
frame.ls_sc.lsc_es = tf->tf_vm86_es;
frame.ls_sc.lsc_ds = tf->tf_vm86_ds;
} else
#else
{
__asm("movl %%gs,%w0" : "=r" (frame.ls_sc.sc_gs));
__asm("movl %%fs,%w0" : "=r" (frame.ls_sc.sc_fs));
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_ds = tf->tf_ds;
}
#endif
frame.ls_sc.lsc_edi = tf->tf_edi;
frame.ls_sc.lsc_esi = tf->tf_esi;
frame.ls_sc.lsc_ebp = tf->tf_ebp;
@ -202,8 +213,19 @@ linux_sigreturn(p, uap, retval)
/*
* Restore signal context.
*/
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
#ifdef VM86
if (context.lsc_eflags & PSL_VM) {
tf->tf_vm86_gs = context.lsc_gs;
tf->tf_vm86_fs = context.lsc_fs;
tf->tf_vm86_es = context.lsc_es;
tf->tf_vm86_ds = context.lsc_ds;
} else
#endif
{
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
}
tf->tf_edi = context.lsc_edi;
tf->tf_esi = context.lsc_esi;
tf->tf_ebp = context.lsc_ebp;

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.c,v 1.3 1995/05/01 08:06:22 mycroft Exp $ */
/* $NetBSD: linux_machdep.c,v 1.4 1995/05/01 14:15:09 mycroft Exp $ */
/*
* Copyright (c) 1995 Frank van der Linden
@ -114,10 +114,21 @@ linux_sendsig(catcher, sig, mask, code)
* Build the signal context to be used by sigreturn.
*/
frame.ls_sc.lsc_mask = mask;
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_fs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_gs = LSEL(LUDATA_SEL, SEL_UPL);
frame.ls_sc.lsc_ds = tf->tf_ds;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.ls_sc.lsc_gs = tf->tf_vm86_gs;
frame.ls_sc.lsc_fs = tf->tf_vm86_fs;
frame.ls_sc.lsc_es = tf->tf_vm86_es;
frame.ls_sc.lsc_ds = tf->tf_vm86_ds;
} else
#else
{
__asm("movl %%gs,%w0" : "=r" (frame.ls_sc.sc_gs));
__asm("movl %%fs,%w0" : "=r" (frame.ls_sc.sc_fs));
frame.ls_sc.lsc_es = tf->tf_es;
frame.ls_sc.lsc_ds = tf->tf_ds;
}
#endif
frame.ls_sc.lsc_edi = tf->tf_edi;
frame.ls_sc.lsc_esi = tf->tf_esi;
frame.ls_sc.lsc_ebp = tf->tf_ebp;
@ -202,8 +213,19 @@ linux_sigreturn(p, uap, retval)
/*
* Restore signal context.
*/
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
#ifdef VM86
if (context.lsc_eflags & PSL_VM) {
tf->tf_vm86_gs = context.lsc_gs;
tf->tf_vm86_fs = context.lsc_fs;
tf->tf_vm86_es = context.lsc_es;
tf->tf_vm86_ds = context.lsc_ds;
} else
#endif
{
/* %fs and %gs were restored by the trampoline. */
tf->tf_es = context.lsc_es;
tf->tf_ds = context.lsc_ds;
}
tf->tf_edi = context.lsc_edi;
tf->tf_esi = context.lsc_esi;
tf->tf_ebp = context.lsc_ebp;