Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Oct 1999 15:01:02 +0200
From:      Marcel Moolenaar <marcel@scc.nl>
To:        freebsd-current@freebsd.org
Cc:        jdp@polstra.com
Subject:   CVSup segfaults identified/solved [PATCH]
Message-ID:  <37F9F68D.CADE38B3@scc.nl>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------1EF75A6A56C460C556506C8D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

It seems that the trampoline code got too long and resulted in the
coredumps people reported. The following patch solves that. it basicly
works as follows:

o  Simplify the trampoline code so that it doesn't have to distinguish
   between an old- and new sigframe and also restoring %gs in both
cases.
o  Which sigreturn to use is now determined by the process flag that
   is used to determine which sendsig is to be used (symmetry)
o  restoring %gs is now handled in the proper sigreturn.

I'll commit this if noone objects.

-- 
Marcel Moolenaar                        mailto:marcel@scc.nl
SCC Internetworking & Databases           http://www.scc.nl/
The FreeBSD project                mailto:marcel@FreeBSD.org
--------------1EF75A6A56C460C556506C8D
Content-Type: text/plain; charset=us-ascii;
 name="cvsup.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cvsup.diff"

Index: i386/i386/genassym.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/genassym.c,v
retrieving revision 1.80
diff -u -r1.80 genassym.c
--- genassym.c	1999/10/04 19:33:51	1.80
+++ genassym.c	1999/10/05 12:02:18
@@ -148,7 +148,6 @@
 	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_SIGRET %#x\n", OS(sigframe, sf_sigreturn));
 	printf("#define\tSIGF_SC %#x\n", OS(osigframe, sf_siginfo.si_sc));
 	printf("#define\tSIGF_UC %#x\n", OS(sigframe, sf_uc));
 
Index: i386/i386/locore.s
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/locore.s,v
retrieving revision 1.128
diff -u -r1.128 locore.s
--- locore.s	1999/09/29 15:06:19	1.128
+++ locore.s	1999/10/05 11:54:06
@@ -415,37 +415,14 @@
  */
 NON_GPROF_ENTRY(sigcode)
 	call	SIGF_HANDLER(%esp)		/* call signal handler */
-	movl	SIGF_SIGRET(%esp),%eax		/* Get sigreturn cookie */
-	cmpl	$0x0ABCDEF0,%eax		/* New one? */
-	jne	3f
-/* New signalling code */
-	lea	SIGF_UC(%esp),%eax		/* get ucontext */
+	lea	SIGF_UC(%esp),%eax		/* get ucontext_t */
 	pushl	%eax
-	testl	$PSL_VM,UC_EFLAGS(%eax)
-	jne	1f
-	movl	UC_GS(%eax),%gs			/* restore %gs */
-1:
 	movl	$SYS_sigreturn,%eax
 	pushl	%eax				/* junk to fake return addr. */
 	int	$0x80				/* enter kernel with args */
-						/* on stack */
-2:
-	jmp	2b
-/* Old signalling code */
-3:
-	lea	SIGF_SC(%esp),%eax		/* get sigcontext */
-	pushl	%eax
-	testl	$PSL_VM,SC_PS(%eax)
-	jne	4f
-	movl	SC_GS(%eax),%gs			/* restore %gs */
-4:
-	movl	$SYS_osigreturn,%eax
-	pushl	%eax				/* junk to fake return addr. */
-	int	$0x80				/* enter kernel with args */
 						/* on stack */
-5:
-	jmp	5b
-
+1:
+	jmp	1b
 	ALIGN_TEXT
 _esigcode:
 
Index: i386/i386/machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.366
diff -u -r1.366 machdep.c
--- machdep.c	1999/10/04 19:33:51	1.366
+++ machdep.c	1999/10/05 12:47:23
@@ -725,8 +725,6 @@
 		tf->tf_eflags &= ~(PSL_VM|PSL_NT|PSL_T|PSL_VIF|PSL_VIP);
 	}
 
-	sf.sf_sigreturn = 0x0ABCDEF0;
-
 	/*
 	 * Copy the sigframe out to the user's stack.
 	 */
@@ -789,6 +787,8 @@
 		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
 		struct vm86_kernel *vm86;
 
+		load_gs(scp->sc_gs);
+
 		/*
 		 * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
 		 * set up the vm86 area, and we can't enter vm86 mode.
@@ -888,6 +888,10 @@
 	ucontext_t *ucp;
 	int cs, eflags;
 
+	if ((p->p_flag & P_NEWSIGSET) == 0) {
+		return osigreturn(p, (struct osigreturn_args *)uap);
+	}
+
 	regs = p->p_md.md_regs;
 	ucp = uap->sigcntxp;
 	eflags = ucp->uc_mcontext.mc_tf.tf_eflags;
@@ -898,6 +902,8 @@
 	if (eflags & PSL_VM) {
 		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
 		struct vm86_kernel *vm86;
+
+		load_gs(ucp->uc_mcontext.mc_gs);
 
 		/*
 		 * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
Index: i386/include/sigframe.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/sigframe.h,v
retrieving revision 1.2
diff -u -r1.2 sigframe.h
--- sigframe.h	1999/10/03 12:55:58	1.2
+++ sigframe.h	1999/10/05 11:53:53
@@ -86,9 +86,8 @@
 		__siginfohandler_t	*sf_action;
 		__sighandler_t		*sf_handler;
 	} sf_ahu;
-	register_t	sf_sigreturn;	/* sigreturn to use */
-	siginfo_t	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
 	ucontext_t	sf_uc;		/* = *sf_ucontext */
+	siginfo_t	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
 };
 
 #endif /* !_MACHINE_SIGFRAME_H_ */

--------------1EF75A6A56C460C556506C8D--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37F9F68D.CADE38B3>