36
39
static int reboot_cpu = -1;
39
/* reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old]
42
/* This is set if we need to go through the 'emergency' path.
43
* When machine_emergency_restart() is called, we may be on
44
* an inconsistent state and won't be able to do a clean cleanup
46
static int reboot_emergency;
48
/* This is set by the PCI code if either type 1 or type 2 PCI is detected */
49
bool port_cf9_safe = false;
51
/* reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci]
40
52
warm Don't set the cold reboot flag
41
53
cold Set the cold reboot flag
42
54
bios Reboot by jumping through the BIOS (only for X86_32)
45
57
kbd Use the keyboard controller. cold reset (default)
46
58
acpi Use the RESET_REG in the FADT
47
59
efi Use efi reset_system runtime service
60
pci Use the so-called "PCI reset register", CF9
48
61
force Avoid anything that could hang.
50
63
static int __init reboot_setup(char *str)
211
225
DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq"),
228
{ /* Handle problems with rebooting on Dell XPS710 */
229
.callback = set_bios_reboot,
230
.ident = "Dell XPS710",
232
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
233
DMI_MATCH(DMI_PRODUCT_NAME, "Dell XPS710"),
236
{ /* Handle problems with rebooting on Dell DXP061 */
237
.callback = set_bios_reboot,
238
.ident = "Dell DXP061",
240
DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
241
DMI_MATCH(DMI_PRODUCT_NAME, "Dell DXP061"),
214
244
#ifdef CONFIG_X86_LPIA
215
245
{ /* Handle problems with rebooting on Intel Crown Beach board */
216
246
.callback = set_bios_reboot,
422
static void vmxoff_nmi(int cpu, struct die_args *args)
424
cpu_emergency_vmxoff();
427
/* Use NMIs as IPIs to tell all CPUs to disable virtualization
429
static void emergency_vmx_disable_all(void)
431
/* Just make sure we won't change CPUs while doing this */
434
/* We need to disable VMX on all CPUs before rebooting, otherwise
435
* we risk hanging up the machine, because the CPU ignore INIT
436
* signals when VMX is enabled.
438
* We can't take any locks and we may be on an inconsistent
439
* state, so we use NMIs as IPIs to tell the other CPUs to disable
442
* For safety, we will avoid running the nmi_shootdown_cpus()
443
* stuff unnecessarily, but we don't have a way to check
444
* if other CPUs have VMX enabled. So we will call it only if the
445
* CPU we are running on has VMX enabled.
447
* We will miss cases where VMX is not enabled on all CPUs. This
448
* shouldn't do much harm because KVM always enable VMX on all
449
* CPUs anyway. But we can miss it on the small window where KVM
450
* is still enabling VMX.
452
if (cpu_has_vmx() && cpu_vmx_enabled()) {
453
/* Disable VMX on this CPU.
457
/* Halt and disable VMX on the other CPUs */
458
nmi_shootdown_cpus(vmxoff_nmi);
392
464
void __attribute__((weak)) mach_reboot_fixups(void)
433
508
reboot_type = BOOT_KBD;
439
efi.reset_system(reboot_mode ? EFI_RESET_WARM : EFI_RESET_COLD,
513
efi.reset_system(reboot_mode ?
440
516
EFI_SUCCESS, 0, NULL);
517
reboot_type = BOOT_KBD;
521
port_cf9_safe = true;
526
u8 cf9 = inb(0xcf9) & ~6;
527
outb(cf9|2, 0xcf9); /* Request hard reset */
529
outb(cf9|6, 0xcf9); /* Actually do the reset */
442
532
reboot_type = BOOT_KBD;
465
555
reboot_cpu_id = smp_processor_id();
467
557
/* Make certain I only run on the appropriate processor */
468
set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id));
558
set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));
470
560
/* O.K Now that I'm on the appropriate processor,
471
561
* stop all of the others.
581
static void __machine_emergency_restart(int emergency)
583
reboot_emergency = emergency;
584
machine_ops.emergency_restart();
491
587
static void native_machine_restart(char *__unused)
493
589
printk("machine restart\n");
495
591
if (!reboot_force)
496
592
machine_shutdown();
497
machine_emergency_restart();
593
__machine_emergency_restart(0);
500
596
static void native_machine_halt(void)
598
/* stop other cpus and apics */
504
605
static void native_machine_power_off(void)
552
653
machine_ops.crash_shutdown(regs);
658
#if defined(CONFIG_SMP)
660
/* This keeps a track of which one is crashing cpu. */
661
static int crashing_cpu;
662
static nmi_shootdown_cb shootdown_callback;
664
static atomic_t waiting_for_crash_ipi;
666
static int crash_nmi_callback(struct notifier_block *self,
667
unsigned long val, void *data)
671
if (val != DIE_NMI_IPI)
674
cpu = raw_smp_processor_id();
676
/* Don't do anything if this handler is invoked on crashing cpu.
677
* Otherwise, system will completely hang. Crashing cpu can get
678
* an NMI if system was initially booted with nmi_watchdog parameter.
680
if (cpu == crashing_cpu)
684
shootdown_callback(cpu, (struct die_args *)data);
686
atomic_dec(&waiting_for_crash_ipi);
687
/* Assume hlt works */
695
static void smp_send_nmi_allbutself(void)
697
apic->send_IPI_allbutself(NMI_VECTOR);
700
static struct notifier_block crash_nmi_nb = {
701
.notifier_call = crash_nmi_callback,
704
/* Halt all other CPUs, calling the specified function on each of them
706
* This function can be used to halt all other CPUs on crash
707
* or emergency reboot time. The function passed as parameter
708
* will be called inside a NMI handler on all CPUs.
710
void nmi_shootdown_cpus(nmi_shootdown_cb callback)
715
/* Make a note of crashing cpu. Will be used in NMI callback.*/
716
crashing_cpu = safe_smp_processor_id();
718
shootdown_callback = callback;
720
atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
721
/* Would it be better to replace the trap vector here? */
722
if (register_die_notifier(&crash_nmi_nb))
723
return; /* return what? */
724
/* Ensure the new callback function is set before sending
729
smp_send_nmi_allbutself();
731
msecs = 1000; /* Wait at most a second for the other cpus to stop */
732
while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
737
/* Leave the nmi callback set */
739
#else /* !CONFIG_SMP */
740
void nmi_shootdown_cpus(nmi_shootdown_cb callback)
742
/* No other CPUs to shoot down */