changeset 13813:57f9d55c2a31

3181 t_onfault should be preserved across pagefaults Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Approved by: Garrett D'Amore <garrett@damore.org>
author Bryan Cantrill <bryan@joyent.com>
date Wed, 12 Sep 2012 04:54:49 +0000
parents 903032120792
children 829c00a55a37
files usr/src/uts/i86pc/os/trap.c usr/src/uts/sun4/os/trap.c
diffstat 2 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/i86pc/os/trap.c	Wed Sep 12 10:54:28 2012 -0400
+++ b/usr/src/uts/i86pc/os/trap.c	Wed Sep 12 04:54:49 2012 +0000
@@ -32,7 +32,7 @@
 /*								*/
 
 /*
- * Copyright 2011 Joyent, Inc. All rights reserved.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
  */
 
 #include <sys/types.h>
@@ -470,6 +470,7 @@
 	proc_t *p = ttoproc(ct);
 	klwp_t *lwp = ttolwp(ct);
 	uintptr_t lofault;
+	label_t *onfault;
 	faultcode_t pagefault(), res, errcode;
 	enum fault_type fault_type;
 	k_siginfo_t siginfo;
@@ -624,15 +625,16 @@
 		}
 
 		/*
-		 * See if we can handle as pagefault. Save lofault
-		 * across this. Here we assume that an address
-		 * less than KERNELBASE is a user fault.
-		 * We can do this as copy.s routines verify that the
-		 * starting address is less than KERNELBASE before
-		 * starting and because we know that we always have
-		 * KERNELBASE mapped as invalid to serve as a "barrier".
+		 * See if we can handle as pagefault. Save lofault and onfault
+		 * across this. Here we assume that an address less than
+		 * KERNELBASE is a user fault.  We can do this as copy.s
+		 * routines verify that the starting address is less than
+		 * KERNELBASE before starting and because we know that we
+		 * always have KERNELBASE mapped as invalid to serve as a
+		 * "barrier".
 		 */
 		lofault = ct->t_lofault;
+		onfault = ct->t_onfault;
 		ct->t_lofault = 0;
 
 		mstate = new_mstate(ct, LMS_KFAULT);
@@ -651,10 +653,11 @@
 		(void) new_mstate(ct, mstate);
 
 		/*
-		 * Restore lofault. If we resolved the fault, exit.
+		 * Restore lofault and onfault. If we resolved the fault, exit.
 		 * If we didn't and lofault wasn't set, die.
 		 */
 		ct->t_lofault = lofault;
+		ct->t_onfault = onfault;
 		if (res == 0)
 			goto cleanup;
 
--- a/usr/src/uts/sun4/os/trap.c	Wed Sep 12 10:54:28 2012 -0400
+++ b/usr/src/uts/sun4/os/trap.c	Wed Sep 12 04:54:49 2012 +0000
@@ -24,6 +24,9 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright (c) 2012 Joyent, Inc.  All rights reserved.
+ */
 
 #include <sys/mmu.h>
 #include <sys/systm.h>
@@ -152,6 +155,7 @@
 	enum fault_type fault_type;
 	enum seg_rw rw;
 	uintptr_t lofault;
+	label_t *onfault;
 	int instr;
 	int iskernel;
 	int watchcode;
@@ -415,6 +419,7 @@
 			}
 		}
 		lofault = curthread->t_lofault;
+		onfault = curthread->t_onfault;
 		curthread->t_lofault = 0;
 
 		mstate = new_mstate(curthread, LMS_KFAULT);
@@ -459,10 +464,11 @@
 		(void) new_mstate(curthread, mstate);
 
 		/*
-		 * Restore lofault.  If we resolved the fault, exit.
+		 * Restore lofault and onfault.  If we resolved the fault, exit.
 		 * If we didn't and lofault wasn't set, die.
 		 */
 		curthread->t_lofault = lofault;
+		curthread->t_onfault = onfault;
 
 		if (res == 0)
 			goto cleanup;