public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] X86: Revamp reboot behaviour to match Windows more closely
@ 2010-12-09 21:46 Matthew Garrett
  2010-12-09 21:46 ` [PATCH 2/3] ACPICA: Fix access width for reset vector Matthew Garrett
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Matthew Garrett @ 2010-12-09 21:46 UTC (permalink / raw)
  To: x86; +Cc: hpa, linux-acpi, lenb, linux-kernel, Matthew Garrett

Windows reboots by hitting the ACPI reboot vector (if available), trying
the keyboard controller, hitting the ACPI reboot vector again and then
giving the keyboard controller one last go. Rework our reboot process a
little to default to matching this behaviour, although we'll fall through
to attempting a triple fault if nothing else works.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
 arch/x86/kernel/reboot.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index c495aa8..c770e66 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -34,7 +34,7 @@ EXPORT_SYMBOL(pm_power_off);
 
 static const struct desc_ptr no_idt = {};
 static int reboot_mode;
-enum reboot_type reboot_type = BOOT_KBD;
+enum reboot_type reboot_type = BOOT_ACPI;
 int reboot_force;
 
 #if defined(CONFIG_X86_32) && defined(CONFIG_SMP)
@@ -538,9 +538,23 @@ void __attribute__((weak)) mach_reboot_fixups(void)
 {
 }
 
+/*
+ * Windows does the following on reboot:
+ * 1) If the FADT has the ACPI reboot register flag set, try it
+ * 2) If still alive, write to the keyboard controller
+ * 3) If still alive, write to the ACPI reboot register again
+ * 4) Ig still alive, write to the keyboard controller again
+ *
+ * If the machine is still alive at this stage, it gives up. We default to
+ * following the same pattern, except that if we're still alive after (4) we'll
+ * try to force a triple fault and then cycle between hitting the keyboard
+ * controller and doing that
+ */
 static void native_machine_emergency_restart(void)
 {
 	int i;
+	int attempt = 0;
+	int orig_reboot_type = reboot_type;
 
 	if (reboot_emergency)
 		emergency_vmx_disable_all();
@@ -562,6 +576,13 @@ static void native_machine_emergency_restart(void)
 				outb(0xfe, 0x64); /* pulse reset low */
 				udelay(50);
 			}
+			if (attempt == 0 && orig_reboot_type == BOOT_ACPI) {
+				attempt = 1;
+				reboot_type = BOOT_ACPI;
+			} else {
+				reboot_type = BOOT_TRIPLE;
+			}
+			break;
 
 		case BOOT_TRIPLE:
 			load_idt(&no_idt);
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-12-09 23:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-09 21:46 [PATCH 1/3] X86: Revamp reboot behaviour to match Windows more closely Matthew Garrett
2010-12-09 21:46 ` [PATCH 2/3] ACPICA: Fix access width for reset vector Matthew Garrett
2010-12-09 22:41   ` Rafael J. Wysocki
2010-12-09 23:12   ` H. Peter Anvin
2010-12-09 23:26     ` Matthew Garrett
2010-12-09 21:46 ` [PATCH 3/3] ACPI: Bug compatibility for Windows on the ACPI reboot vector Matthew Garrett
2010-12-09 22:36   ` H. Peter Anvin
2010-12-09 22:41     ` Rafael J. Wysocki
2010-12-09 22:25 ` [PATCH 1/3] X86: Revamp reboot behaviour to match Windows more closely H. Peter Anvin
2010-12-09 22:32   ` Matthew Garrett
2010-12-09 22:32     ` H. Peter Anvin
2010-12-09 22:38       ` Matthew Garrett
2010-12-09 22:40         ` H. Peter Anvin
2010-12-09 22:51           ` Matthew Garrett
2010-12-09 22:53             ` H. Peter Anvin
2010-12-09 22:58               ` Matthew Garrett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox