changeset 10916:b5c9d492b177

6856732 Further reduce the window for panic reboot loop
author Sherry Moore <Sherry.Moore@Sun.COM>
date Fri, 30 Oct 2009 10:44:28 -0700
parents 71a2d5440e59
children 2c1f18099a3e
files usr/src/uts/i86pc/os/fastboot.c usr/src/uts/i86pc/os/machdep.c usr/src/uts/i86pc/sys/fastboot.h
diffstat 3 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/i86pc/os/fastboot.c	Fri Oct 30 10:10:33 2009 -0700
+++ b/usr/src/uts/i86pc/os/fastboot.c	Fri Oct 30 10:44:28 2009 -0700
@@ -149,6 +149,20 @@
 static size_t fastboot_pagetable_size = 0x5000;	/* 20K */
 
 /*
+ * Minimum system uptime in clock_t before Fast Reboot should be used
+ * on panic.  Will be initialized in fastboot_post_startup().
+ */
+clock_t fastreboot_onpanic_uptime = LONG_MAX;
+
+/*
+ * lbolt value when the system booted.  This value will be used if the system
+ * panics to calculate how long the system has been up.  If the uptime is less
+ * than fastreboot_onpanic_uptime, a reboot through BIOS will be performed to
+ * avoid a potential panic/reboot loop.
+ */
+clock_t lbolt_at_boot = LONG_MAX;
+
+/*
  * Use below 1G for page tables as
  *	1. we are only doing 1:1 mapping of the bottom 1G of physical memory.
  *	2. we are using 2G as the fake virtual address for the new kernel and
@@ -1411,6 +1425,12 @@
 void
 fastboot_post_startup()
 {
+	lbolt_at_boot = ddi_get_lbolt();
+
+	/* Default to 10 minutes */
+	if (fastreboot_onpanic_uptime == LONG_MAX)
+		fastreboot_onpanic_uptime = SEC_TO_TICK(10 * 60);
+
 	if (!fastreboot_capable)
 		return;
 
--- a/usr/src/uts/i86pc/os/machdep.c	Fri Oct 30 10:10:33 2009 -0700
+++ b/usr/src/uts/i86pc/os/machdep.c	Fri Oct 30 10:44:28 2009 -0700
@@ -265,12 +265,16 @@
 	}
 
 	/*
-	 * If the system is panicking, the preloaded kernel is valid,
-	 * and fastreboot_onpanic has been set, choose Fast Reboot.
+	 * If the system is panicking, the preloaded kernel is valid, and
+	 * fastreboot_onpanic has been set, and the system has been up for
+	 * longer than fastreboot_onpanic_uptime (default to 10 minutes),
+	 * choose Fast Reboot.
 	 */
 	if (fcn == AD_BOOT && panicstr && newkernel.fi_valid &&
-	    fastreboot_onpanic)
+	    fastreboot_onpanic &&
+	    (panic_lbolt - lbolt_at_boot) > fastreboot_onpanic_uptime) {
 		fcn = AD_FASTREBOOT;
+	}
 
 	/*
 	 * Try to quiesce devices.
--- a/usr/src/uts/i86pc/sys/fastboot.h	Fri Oct 30 10:10:33 2009 -0700
+++ b/usr/src/uts/i86pc/sys/fastboot.h	Fri Oct 30 10:44:28 2009 -0700
@@ -176,6 +176,10 @@
 extern volatile int fastreboot_onpanic;
 extern char fastreboot_onpanic_cmdline[FASTBOOT_SAVED_CMDLINE_LEN];
 
+/* Variables for avoiding panic/reboot loop */
+extern clock_t fastreboot_onpanic_uptime;
+extern clock_t lbolt_at_boot, panic_lbolt;
+
 #endif	/* _ASM */
 
 #ifdef __cplusplus