From owner-p4-projects@FreeBSD.ORG Tue May 13 19:38:47 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A5B6537B404; Tue, 13 May 2003 19:38:46 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E30537B401 for ; Tue, 13 May 2003 19:38:46 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCBF643F93 for ; Tue, 13 May 2003 19:38:45 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h4E2cj0U070352 for ; Tue, 13 May 2003 19:38:45 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h4E2cjpp070349 for perforce@freebsd.org; Tue, 13 May 2003 19:38:45 -0700 (PDT) Date: Tue, 13 May 2003 19:38:45 -0700 (PDT) Message-Id: <200305140238.h4E2cjpp070349@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 31115 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2003 02:38:47 -0000 http://perforce.freebsd.org/chv.cgi?CH=31115 Change 31115 by peter@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 #include #include +#include #include 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 */