Module Name: src
Committed By: dsl
Date: Sun Jan 10 15:37:36 UTC 2010
Modified Files:
src/sys/arch/i386/i386: trap.c
Log Message:
If we fault on the iret during return to userspace, see if we need to
do a lazy update of %cs to make the stack executable.
If a change is made, just retry the failing sequence.
Signal handlers as gcc nested local functions now work!
To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/i386/i386/trap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.251 src/sys/arch/i386/i386/trap.c:1.252
--- src/sys/arch/i386/i386/trap.c:1.251 Sun Jan 10 15:21:36 2010
+++ src/sys/arch/i386/i386/trap.c Sun Jan 10 15:37:36 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $ */
+/* $NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $ */
/*-
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -423,6 +423,11 @@
* the kernel address of the iret.
* We must copy the registers next to the userspace
* return address so we have a frame for md_regs.
+ *
+ * Also, we might have faulted trying to execute the
+ * trampoline for a local (nested) signal handler.
+ * If we change the %cs (eg to include the stack)
+ * just return the return to user.
*/
vframe = (void *)((int *)frame + 3);
if (KERNELMODE(vframe->tf_cs, vframe->tf_eflags))
@@ -431,7 +436,9 @@
offsetof(struct trapframe, tf_eip));
l->l_md.md_regs = vframe;
ksi.ksi_addr = (void *)vframe->tf_eip;
- (*p->p_emul->e_trapsignal)(l, &ksi);
+ if (!pmap_exec_fixup(&p->p_vmspace->vm_map, vframe,
+ lwp_getpcb(l)))
+ (*p->p_emul->e_trapsignal)(l, &ksi);
trap_return_iret(vframe);
/* NOTREACHED */
case 0x8e: