PERFORCE change 31115 for review
Peter Wemm
peter at FreeBSD.org
Tue May 13 19:38:47 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=31115
Change 31115 by peter at peter_hammer on 2003/05/13 19:38:39
In theory, the user segment registers are never used while in long
mode. But I dont want to have to check during an iret to 32 bit
compatability mode, so let the sigtramp itself restore the segment
selectors rather than messing with them in the kernel.
Affected files ...
.. //depot/projects/hammer/sys/amd64/ia32/ia32_genassym.c#2 edit
.. //depot/projects/hammer/sys/amd64/ia32/ia32_signal.c#2 edit
.. //depot/projects/hammer/sys/amd64/ia32/ia32_sigtramp.S#2 edit
Differences ...
==== //depot/projects/hammer/sys/amd64/ia32/ia32_genassym.c#2 (text+ko) ====
@@ -5,13 +5,20 @@
#include <sys/param.h>
#include <sys/assym.h>
#include <sys/systm.h>
+#include <sys/signal.h>
#include <amd64/ia32/ia32_signal.h>
ASSYM(IA32_SIGF_HANDLER, offsetof(struct ia32_sigframe, sf_ah));
ASSYM(IA32_SIGF_UC, offsetof(struct ia32_sigframe, sf_uc));
ASSYM(IA32_UC_GS, offsetof(struct ia32_ucontext, uc_mcontext.mc_gs));
+ASSYM(IA32_UC_FS, offsetof(struct ia32_ucontext, uc_mcontext.mc_fs));
+ASSYM(IA32_UC_ES, offsetof(struct ia32_ucontext, uc_mcontext.mc_es));
+ASSYM(IA32_UC_DS, offsetof(struct ia32_ucontext, uc_mcontext.mc_ds));
#ifdef COMPAT_FREEBSD4
ASSYM(IA32_SIGF_UC4, offsetof(struct ia32_sigframe, sf_uc));
ASSYM(IA32_UC4_GS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_gs));
+ASSYM(IA32_UC4_FS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_fs));
+ASSYM(IA32_UC4_ES, offsetof(struct ia32_ucontext4, uc_mcontext.mc_es));
+ASSYM(IA32_UC4_DS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_ds));
#endif
==== //depot/projects/hammer/sys/amd64/ia32/ia32_signal.c#2 (text+ko) ====
@@ -268,8 +268,10 @@
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
load_ds(_udatasel);
+ td->td_pcb->pcb_ds = _udatasel;
load_es(_udatasel);
- load_fs(_udatasel);
+ td->td_pcb->pcb_es = _udatasel;
+ /* leave user %fs and %gs untouched */
PROC_LOCK(p);
}
#endif /* COMPAT_FREEBSD4 */
@@ -382,8 +384,10 @@
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
load_ds(_udatasel);
+ td->td_pcb->pcb_ds = _udatasel;
load_es(_udatasel);
- load_fs(_udatasel);
+ td->td_pcb->pcb_es = _udatasel;
+ /* leave user %fs and %gs untouched */
PROC_LOCK(p);
}
@@ -449,10 +453,7 @@
return (EINVAL);
}
- /* mc_gs is done by sigtramp.S */
- load_fs(ucp->uc_mcontext.mc_fs);
- load_es(ucp->uc_mcontext.mc_es);
- load_ds(ucp->uc_mcontext.mc_ds);
+ /* Segment selectors restored by sigtramp.S */
regs->tf_rdi = ucp->uc_mcontext.mc_edi;
regs->tf_rsi = ucp->uc_mcontext.mc_esi;
regs->tf_rbp = ucp->uc_mcontext.mc_ebp;
@@ -533,10 +534,7 @@
if (ret != 0)
return (ret);
- /* mc_gs is done by sigtramp.S */
- load_fs(ucp->uc_mcontext.mc_fs);
- load_es(ucp->uc_mcontext.mc_es);
- load_ds(ucp->uc_mcontext.mc_ds);
+ /* Segment selectors restored by sigtramp.S */
regs->tf_rdi = ucp->uc_mcontext.mc_edi;
regs->tf_rsi = ucp->uc_mcontext.mc_esi;
regs->tf_rbp = ucp->uc_mcontext.mc_ebp;
==== //depot/projects/hammer/sys/amd64/ia32/ia32_sigtramp.S#2 (text+ko) ====
@@ -62,6 +62,9 @@
leal IA32_SIGF_UC(%esp),%eax /* get ucontext */
pushl %eax
movl IA32_UC_GS(%eax),%gs /* restore %gs */
+ movl IA32_UC_FS(%eax),%fs /* restore %fs */
+ movl IA32_UC_ES(%eax),%es /* restore %es */
+ movl IA32_UC_DS(%eax),%ds /* restore %ds */
movl $SYS_sigreturn,%eax
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
@@ -76,6 +79,9 @@
leal IA32_SIGF_UC4(%esp),%eax/* get ucontext */
pushl %eax
movl IA32_UC4_GS(%eax),%gs /* restore %gs */
+ movl IA32_UC4_FS(%eax),%fs /* restore %fs */
+ movl IA32_UC4_ES(%eax),%es /* restore %es */
+ movl IA32_UC4_DS(%eax),%ds /* restore %ds */
movl $344,%eax /* 4.x SYS_sigreturn */
pushl %eax /* junk to fake return addr. */
int $0x80 /* enter kernel with args */
More information about the p4-projects
mailing list