changeset 10977:de59debacdeb

6895564 Ultra 40 panics with osol_1002-125: panic message:BAD TRAP: type=e (#pf Page fault) rp=ffffff0004222
author rui zang - Sun Microsystems - Beijing China <Aaron.Zang@Sun.COM>
date Fri, 06 Nov 2009 11:41:47 +0800
parents 03a10dbb75a3
children 5a4580d4e2b9
files usr/src/uts/common/io/vcons.c
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/vcons.c	Fri Nov 06 11:27:47 2009 +0800
+++ b/usr/src/uts/common/io/vcons.c	Fri Nov 06 11:41:47 2009 +0800
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -667,7 +667,7 @@
 /*
  * switch to vt_no from vc_active_console
  */
-static void
+static int
 vt_switch(uint_t vt_no, cred_t *credp)
 {
 	vc_state_t *pvc_active = vt_minor2vc(vc_active_console);
@@ -676,6 +676,14 @@
 
 	ASSERT(pvc_active && pvc);
 
+	/* sanity test for the target VT and the active VT */
+	if (!((pvc->vc_flags & WCS_ISOPEN) && (pvc->vc_flags & WCS_INIT)))
+		return (EINVAL);
+
+	if (!((pvc_active->vc_flags & WCS_ISOPEN) &&
+	    (pvc_active->vc_flags & WCS_INIT)))
+		return (EINVAL);
+
 	mutex_enter(&vc_lock);
 
 	tem_switch(pvc_active->vc_tem, pvc->vc_tem, credp);
@@ -721,6 +729,8 @@
 		}
 	}
 
+	return (0);
+
 }
 
 /*
@@ -800,10 +810,8 @@
 	pvc = vt_minor2vc(vc_active_console);
 	if (pvc == NULL)
 		return (ENXIO);
-	if (pvc->vc_switch_mode != VT_PROCESS) {
-		vt_switch(minor, credp);
-		return (0);
-	}
+	if (pvc->vc_switch_mode != VT_PROCESS)
+		return (vt_switch(minor, credp));
 
 	/*
 	 * Validate the process, reset the
@@ -857,8 +865,7 @@
 		return (0); /* refuse to release */
 
 	/* Xserver has left VT */
-	vt_switch(target_vtno, credp);
-	return (0);
+	return (vt_switch(target_vtno, credp));
 }
 
 void