vserver 1.9.5.x5
[linux-2.6.git] / arch / x86_64 / kernel / reboot.c
index 3dac339..be4b36f 100644 (file)
@@ -22,18 +22,18 @@ void (*pm_power_off)(void);
 
 static long no_idt[3];
 static enum { 
-       BOOT_BIOS = 'b',
        BOOT_TRIPLE = 't',
        BOOT_KBD = 'k'
 } reboot_type = BOOT_KBD;
 static int reboot_mode = 0;
+int reboot_force;
 
-/* reboot=b[ios] | t[riple] | k[bd] [, [w]arm | [c]old]
-   bios          Use the CPU reboot vector for warm reset
+/* reboot=t[riple] | k[bd] [, [w]arm | [c]old]
    warm   Don't set the cold reboot flag
    cold   Set the cold reboot flag
    triple Force a triple fault (init)
    kbd    Use the keyboard controller. cold reset (default)
+   force  Avoid anything that could hang.
  */ 
 static int __init reboot_setup(char *str)
 {
@@ -52,6 +52,9 @@ static int __init reboot_setup(char *str)
                case 'k':
                        reboot_type = *str;
                        break;
+               case 'f':
+                       reboot_force = 1;
+                       break;
                }
                if((str = strchr(str,',')) != NULL)
                        str++;
@@ -63,44 +66,19 @@ static int __init reboot_setup(char *str)
 
 __setup("reboot=", reboot_setup);
 
-/* overwrites random kernel memory. Should not be kernel .text */
-#define WARMBOOT_TRAMP 0x1000UL
-
-static void reboot_warm(void)
-{
-       extern unsigned char warm_reboot[], warm_reboot_end[];
-       printk("warm reboot\n");
-
-       local_irq_disable(); 
-               
-       /* restore identity mapping */
-       init_level4_pgt[0] = __pml4(__pa(level3_ident_pgt) | 7); 
-       __flush_tlb_all(); 
-
-       /* Move the trampoline to low memory */
-       memcpy(__va(WARMBOOT_TRAMP), warm_reboot, warm_reboot_end - warm_reboot); 
-
-       /* Start it in compatibility mode. */
-       asm volatile( "   pushq $0\n"           /* ss */
-                    "   pushq $0x2000\n"       /* rsp */
-                    "   pushfq\n"              /* eflags */
-                    "   pushq %[cs]\n"
-                    "   pushq %[target]\n"
-                    "   iretq" :: 
-                     [cs] "i" (__KERNEL_COMPAT32_CS), 
-                     [target] "b" (WARMBOOT_TRAMP));
-}
-
 #ifdef CONFIG_SMP
 static void smp_halt(void)
 {
        int cpuid = safe_smp_processor_id(); 
-               static int first_entry = 1;
+       static int first_entry = 1;
+
+       if (reboot_force)
+               return;
 
-               if (first_entry) { 
-                       first_entry = 0;
-                       smp_call_function((void *)machine_restart, NULL, 1, 0);
-               } 
+       if (first_entry) {
+               first_entry = 0;
+               smp_call_function((void *)machine_restart, NULL, 1, 0);
+       }
                        
        smp_stop_cpu(); 
 
@@ -129,19 +107,20 @@ void machine_restart(char * __unused)
 {
        int i;
 
+       printk("machine restart\n");
+
 #ifdef CONFIG_SMP
        smp_halt(); 
 #endif
 
-       local_irq_disable();
-       
+       if (!reboot_force) {
+               local_irq_disable();
 #ifndef CONFIG_SMP
-       disable_local_APIC();
+               disable_local_APIC();
 #endif
-
-       disable_IO_APIC();
-       
-       local_irq_enable();
+               disable_IO_APIC();
+               local_irq_enable();
+       }
        
        /* Tell the BIOS if we want cold or warm reboot */
        *((unsigned short *)__va(0x472)) = reboot_mode;
@@ -149,9 +128,6 @@ void machine_restart(char * __unused)
        for (;;) {
                /* Could also try the reset bit in the Hammer NB */
                switch (reboot_type) { 
-               case BOOT_BIOS:
-                       reboot_warm();
-
                case BOOT_KBD:
                for (i=0; i<100; i++) {
                        kb_wait();
@@ -161,8 +137,8 @@ void machine_restart(char * __unused)
                }
 
                case BOOT_TRIPLE: 
-               __asm__ __volatile__("lidt (%0)": :"r" (&no_idt));
-               __asm__ __volatile__("int3");
+                       __asm__ __volatile__("lidt (%0)": :"r" (&no_idt));
+                       __asm__ __volatile__("int3");
 
                        reboot_type = BOOT_KBD;
                        break;