diff options
author | Luoqi Chen <luoqi@FreeBSD.org> | 1999-09-07 20:02:24 +0000 |
---|---|---|
committer | Luoqi Chen <luoqi@FreeBSD.org> | 1999-09-07 20:02:24 +0000 |
commit | ab6ec55891c11f6dffcc0d8546333c1b8f5cc3e1 (patch) | |
tree | d110e6fcffa16ad26f5b0651a5f0d8598eb72653 | |
parent | aa8fac6c4d3248b4ac1013fb61b9cf910a65ed61 (diff) | |
download | src-ab6ec55891c11f6dffcc0d8546333c1b8f5cc3e1.tar.gz src-ab6ec55891c11f6dffcc0d8546333c1b8f5cc3e1.zip |
Save %gs in sigcontext when delivering a signal and restore them upon
return (in signal trampoline code). I plan to do the same on -stable,
so that we have a consistent interface to userland applications.
Reviewed by: bde
Notes
Notes:
svn path=/head/; revision=51065
-rw-r--r-- | sys/amd64/amd64/genassym.c | 3 | ||||
-rw-r--r-- | sys/amd64/amd64/locore.S | 10 | ||||
-rw-r--r-- | sys/amd64/amd64/locore.s | 10 | ||||
-rw-r--r-- | sys/amd64/amd64/machdep.c | 1 | ||||
-rw-r--r-- | sys/i386/i386/genassym.c | 3 | ||||
-rw-r--r-- | sys/i386/i386/locore.s | 10 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 1 |
7 files changed, 26 insertions, 12 deletions
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 2df518268216..d4023ccf75a2 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -148,6 +148,9 @@ main() printf("#define\tSIGF_HANDLER %#x\n", OS(sigframe, sf_ahu.sf_handler)); printf("#define\tSIGF_SC %#x\n", OS(sigframe, sf_siginfo.si_sc)); + printf("#define\tSC_PS %#x\n", OS(sigcontext, sc_ps)); + printf("#define\tSC_FS %#x\n", OS(sigcontext, sc_fs)); + printf("#define\tSC_GS %#x\n", OS(sigcontext, sc_gs)); printf("#define\tB_READ %#x\n", B_READ); printf("#define\tENOENT %d\n", ENOENT); diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index f2627266353c..ad499bd56a27 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -410,8 +410,6 @@ NON_GPROF_ENTRY(prepare_usermode) ret /* goto user! */ -#define LCALL(x,y) .byte 0x9a ; .long y ; .word x - /* * Signal trampoline, copied to top of user stack */ @@ -421,9 +419,13 @@ NON_GPROF_ENTRY(sigcode) /* copy at 8(%esp)) */ pushl %eax pushl %eax /* junk to fake return address */ + testl $PSL_VM,SC_PS(%eax) + jne 1f + movl SC_GS(%eax),%gs /* restore %gs */ +1: movl $SYS_sigreturn,%eax /* sigreturn() */ - LCALL(0x7,0) /* enter kernel with args on stack */ - hlt /* never gets here */ + int $0x80 /* enter kernel with args on stack */ +2: jmp 2b ALIGN_TEXT _esigcode: diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s index f2627266353c..ad499bd56a27 100644 --- a/sys/amd64/amd64/locore.s +++ b/sys/amd64/amd64/locore.s @@ -410,8 +410,6 @@ NON_GPROF_ENTRY(prepare_usermode) ret /* goto user! */ -#define LCALL(x,y) .byte 0x9a ; .long y ; .word x - /* * Signal trampoline, copied to top of user stack */ @@ -421,9 +419,13 @@ NON_GPROF_ENTRY(sigcode) /* copy at 8(%esp)) */ pushl %eax pushl %eax /* junk to fake return address */ + testl $PSL_VM,SC_PS(%eax) + jne 1f + movl SC_GS(%eax),%gs /* restore %gs */ +1: movl $SYS_sigreturn,%eax /* sigreturn() */ - LCALL(0x7,0) /* enter kernel with args on stack */ - hlt /* never gets here */ + int $0x80 /* enter kernel with args on stack */ +2: jmp 2b ALIGN_TEXT _esigcode: diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index a3c33bfc293a..7b712d2753de 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -562,6 +562,7 @@ sendsig(catcher, sig, mask, code) sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; sf.sf_siginfo.si_sc.sc_es = regs->tf_es; sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; + sf.sf_siginfo.si_sc.sc_gs = rgs(); sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; /* diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 2df518268216..d4023ccf75a2 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -148,6 +148,9 @@ main() printf("#define\tSIGF_HANDLER %#x\n", OS(sigframe, sf_ahu.sf_handler)); printf("#define\tSIGF_SC %#x\n", OS(sigframe, sf_siginfo.si_sc)); + printf("#define\tSC_PS %#x\n", OS(sigcontext, sc_ps)); + printf("#define\tSC_FS %#x\n", OS(sigcontext, sc_fs)); + printf("#define\tSC_GS %#x\n", OS(sigcontext, sc_gs)); printf("#define\tB_READ %#x\n", B_READ); printf("#define\tENOENT %d\n", ENOENT); diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index f2627266353c..ad499bd56a27 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -410,8 +410,6 @@ NON_GPROF_ENTRY(prepare_usermode) ret /* goto user! */ -#define LCALL(x,y) .byte 0x9a ; .long y ; .word x - /* * Signal trampoline, copied to top of user stack */ @@ -421,9 +419,13 @@ NON_GPROF_ENTRY(sigcode) /* copy at 8(%esp)) */ pushl %eax pushl %eax /* junk to fake return address */ + testl $PSL_VM,SC_PS(%eax) + jne 1f + movl SC_GS(%eax),%gs /* restore %gs */ +1: movl $SYS_sigreturn,%eax /* sigreturn() */ - LCALL(0x7,0) /* enter kernel with args on stack */ - hlt /* never gets here */ + int $0x80 /* enter kernel with args on stack */ +2: jmp 2b ALIGN_TEXT _esigcode: diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index a3c33bfc293a..7b712d2753de 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -562,6 +562,7 @@ sendsig(catcher, sig, mask, code) sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; sf.sf_siginfo.si_sc.sc_es = regs->tf_es; sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; + sf.sf_siginfo.si_sc.sc_gs = rgs(); sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; /* |