1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3 #include <linux/export.h>
4 #include <linux/reboot.h>
5 #include <linux/init.h>
9 #include <linux/sched.h>
10 #include <linux/tboot.h>
11 #include <linux/delay.h>
12 #include <linux/frame.h>
13 #include <acpi/reboot.h>
16 #include <asm/io_apic.h>
19 #include <asm/pgtable.h>
20 #include <asm/proto.h>
21 #include <asm/reboot_fixups.h>
22 #include <asm/reboot.h>
23 #include <asm/pci_x86.h>
24 #include <asm/virtext.h>
29 #include <linux/ctype.h>
30 #include <linux/mc146818rtc.h>
31 #include <asm/realmode.h>
32 #include <asm/x86_init.h>
36 * Power off function, if any
38 void (*pm_power_off
)(void);
39 EXPORT_SYMBOL(pm_power_off
);
41 static const struct desc_ptr no_idt
= {};
44 * This is set if we need to go through the 'emergency' path.
45 * When machine_emergency_restart() is called, we may be on
46 * an inconsistent state and won't be able to do a clean cleanup
48 static int reboot_emergency
;
50 /* This is set by the PCI code if either type 1 or type 2 PCI is detected */
51 bool port_cf9_safe
= false;
54 * Reboot options and system auto-detection code provided by
55 * Dell Inc. so their systems "just work". :-)
59 * Some machines require the "reboot=a" commandline options
61 static int __init
set_acpi_reboot(const struct dmi_system_id
*d
)
63 if (reboot_type
!= BOOT_ACPI
) {
64 reboot_type
= BOOT_ACPI
;
65 pr_info("%s series board detected. Selecting %s-method for reboots.\n",
72 * Some machines require the "reboot=b" or "reboot=k" commandline options,
73 * this quirk makes that automatic.
75 static int __init
set_bios_reboot(const struct dmi_system_id
*d
)
77 if (reboot_type
!= BOOT_BIOS
) {
78 reboot_type
= BOOT_BIOS
;
79 pr_info("%s series board detected. Selecting %s-method for reboots.\n",
85 void __noreturn
machine_real_restart(unsigned int type
)
90 * Write zero to CMOS register number 0x0f, which the BIOS POST
91 * routine will recognize as telling it to do a proper reboot. (Well
92 * that's what this book in front of me says -- it may only apply to
93 * the Phoenix BIOS though, it's not clear). At the same time,
94 * disable NMIs by setting the top bit in the CMOS address register,
95 * as we're about to do peculiar things to the CPU. I'm not sure if
96 * `outb_p' is needed instead of just `outb'. Use it to be on the
97 * safe side. (Yes, CMOS_WRITE does outb_p's. - Paul G.)
100 CMOS_WRITE(0x00, 0x8f);
101 spin_unlock(&rtc_lock
);
104 * Switch back to the initial page table.
107 load_cr3(initial_page_table
);
109 write_cr3(real_mode_header
->trampoline_pgd
);
112 /* Jump to the identity-mapped low memory code */
114 asm volatile("jmpl *%0" : :
115 "rm" (real_mode_header
->machine_real_restart_asm
),
118 asm volatile("ljmpl *%0" : :
119 "m" (real_mode_header
->machine_real_restart_asm
),
124 #ifdef CONFIG_APM_MODULE
125 EXPORT_SYMBOL(machine_real_restart
);
127 STACK_FRAME_NON_STANDARD(machine_real_restart
);
130 * Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot
132 static int __init
set_pci_reboot(const struct dmi_system_id
*d
)
134 if (reboot_type
!= BOOT_CF9_FORCE
) {
135 reboot_type
= BOOT_CF9_FORCE
;
136 pr_info("%s series board detected. Selecting %s-method for reboots.\n",
142 static int __init
set_kbd_reboot(const struct dmi_system_id
*d
)
144 if (reboot_type
!= BOOT_KBD
) {
145 reboot_type
= BOOT_KBD
;
146 pr_info("%s series board detected. Selecting %s-method for reboot.\n",
153 * This is a single dmi_table handling all reboot quirks.
155 static struct dmi_system_id __initdata reboot_dmi_table
[] = {
158 { /* Handle reboot issue on Acer Aspire one */
159 .callback
= set_kbd_reboot
,
160 .ident
= "Acer Aspire One A110",
162 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
163 DMI_MATCH(DMI_PRODUCT_NAME
, "AOA110"),
168 { /* Handle problems with rebooting on Apple MacBook5 */
169 .callback
= set_pci_reboot
,
170 .ident
= "Apple MacBook5",
172 DMI_MATCH(DMI_SYS_VENDOR
, "Apple Inc."),
173 DMI_MATCH(DMI_PRODUCT_NAME
, "MacBook5"),
176 { /* Handle problems with rebooting on Apple MacBookPro5 */
177 .callback
= set_pci_reboot
,
178 .ident
= "Apple MacBookPro5",
180 DMI_MATCH(DMI_SYS_VENDOR
, "Apple Inc."),
181 DMI_MATCH(DMI_PRODUCT_NAME
, "MacBookPro5"),
184 { /* Handle problems with rebooting on Apple Macmini3,1 */
185 .callback
= set_pci_reboot
,
186 .ident
= "Apple Macmini3,1",
188 DMI_MATCH(DMI_SYS_VENDOR
, "Apple Inc."),
189 DMI_MATCH(DMI_PRODUCT_NAME
, "Macmini3,1"),
192 { /* Handle problems with rebooting on the iMac9,1. */
193 .callback
= set_pci_reboot
,
194 .ident
= "Apple iMac9,1",
196 DMI_MATCH(DMI_SYS_VENDOR
, "Apple Inc."),
197 DMI_MATCH(DMI_PRODUCT_NAME
, "iMac9,1"),
200 { /* Handle problems with rebooting on the iMac10,1. */
201 .callback
= set_pci_reboot
,
202 .ident
= "Apple iMac10,1",
204 DMI_MATCH(DMI_SYS_VENDOR
, "Apple Inc."),
205 DMI_MATCH(DMI_PRODUCT_NAME
, "iMac10,1"),
210 { /* Handle problems with rebooting on ASRock Q1900DC-ITX */
211 .callback
= set_pci_reboot
,
212 .ident
= "ASRock Q1900DC-ITX",
214 DMI_MATCH(DMI_BOARD_VENDOR
, "ASRock"),
215 DMI_MATCH(DMI_BOARD_NAME
, "Q1900DC-ITX"),
220 { /* Handle problems with rebooting on ASUS P4S800 */
221 .callback
= set_bios_reboot
,
222 .ident
= "ASUS P4S800",
224 DMI_MATCH(DMI_BOARD_VENDOR
, "ASUSTeK Computer INC."),
225 DMI_MATCH(DMI_BOARD_NAME
, "P4S800"),
228 { /* Handle problems with rebooting on ASUS EeeBook X205TA */
229 .callback
= set_acpi_reboot
,
230 .ident
= "ASUS EeeBook X205TA",
232 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
233 DMI_MATCH(DMI_PRODUCT_NAME
, "X205TA"),
236 { /* Handle problems with rebooting on ASUS EeeBook X205TAW */
237 .callback
= set_acpi_reboot
,
238 .ident
= "ASUS EeeBook X205TAW",
240 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
241 DMI_MATCH(DMI_PRODUCT_NAME
, "X205TAW"),
246 { /* Handle problems with rebooting on Certec BPC600 */
247 .callback
= set_pci_reboot
,
248 .ident
= "Certec BPC600",
250 DMI_MATCH(DMI_SYS_VENDOR
, "Certec"),
251 DMI_MATCH(DMI_PRODUCT_NAME
, "BPC600"),
256 { /* Handle problems with rebooting on Dell DXP061 */
257 .callback
= set_bios_reboot
,
258 .ident
= "Dell DXP061",
260 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
261 DMI_MATCH(DMI_PRODUCT_NAME
, "Dell DXP061"),
264 { /* Handle problems with rebooting on Dell E520's */
265 .callback
= set_bios_reboot
,
266 .ident
= "Dell E520",
268 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
269 DMI_MATCH(DMI_PRODUCT_NAME
, "Dell DM061"),
272 { /* Handle problems with rebooting on the Latitude E5410. */
273 .callback
= set_pci_reboot
,
274 .ident
= "Dell Latitude E5410",
276 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
277 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude E5410"),
280 { /* Handle problems with rebooting on the Latitude E5420. */
281 .callback
= set_pci_reboot
,
282 .ident
= "Dell Latitude E5420",
284 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
285 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude E5420"),
288 { /* Handle problems with rebooting on the Latitude E6320. */
289 .callback
= set_pci_reboot
,
290 .ident
= "Dell Latitude E6320",
292 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
293 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude E6320"),
296 { /* Handle problems with rebooting on the Latitude E6420. */
297 .callback
= set_pci_reboot
,
298 .ident
= "Dell Latitude E6420",
300 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
301 DMI_MATCH(DMI_PRODUCT_NAME
, "Latitude E6420"),
304 { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */
305 .callback
= set_bios_reboot
,
306 .ident
= "Dell OptiPlex 330",
308 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
309 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 330"),
310 DMI_MATCH(DMI_BOARD_NAME
, "0KP561"),
313 { /* Handle problems with rebooting on Dell Optiplex 360 with 0T656F */
314 .callback
= set_bios_reboot
,
315 .ident
= "Dell OptiPlex 360",
317 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
318 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 360"),
319 DMI_MATCH(DMI_BOARD_NAME
, "0T656F"),
322 { /* Handle problems with rebooting on Dell Optiplex 745's SFF */
323 .callback
= set_bios_reboot
,
324 .ident
= "Dell OptiPlex 745",
326 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
327 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 745"),
330 { /* Handle problems with rebooting on Dell Optiplex 745's DFF */
331 .callback
= set_bios_reboot
,
332 .ident
= "Dell OptiPlex 745",
334 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
335 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 745"),
336 DMI_MATCH(DMI_BOARD_NAME
, "0MM599"),
339 { /* Handle problems with rebooting on Dell Optiplex 745 with 0KW626 */
340 .callback
= set_bios_reboot
,
341 .ident
= "Dell OptiPlex 745",
343 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
344 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 745"),
345 DMI_MATCH(DMI_BOARD_NAME
, "0KW626"),
348 { /* Handle problems with rebooting on Dell OptiPlex 760 with 0G919G */
349 .callback
= set_bios_reboot
,
350 .ident
= "Dell OptiPlex 760",
352 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
353 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 760"),
354 DMI_MATCH(DMI_BOARD_NAME
, "0G919G"),
357 { /* Handle problems with rebooting on the OptiPlex 990. */
358 .callback
= set_pci_reboot
,
359 .ident
= "Dell OptiPlex 990",
361 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
362 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 990"),
365 { /* Handle problems with rebooting on Dell 300's */
366 .callback
= set_bios_reboot
,
367 .ident
= "Dell PowerEdge 300",
369 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer Corporation"),
370 DMI_MATCH(DMI_PRODUCT_NAME
, "PowerEdge 300/"),
373 { /* Handle problems with rebooting on Dell 1300's */
374 .callback
= set_bios_reboot
,
375 .ident
= "Dell PowerEdge 1300",
377 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer Corporation"),
378 DMI_MATCH(DMI_PRODUCT_NAME
, "PowerEdge 1300/"),
381 { /* Handle problems with rebooting on Dell 2400's */
382 .callback
= set_bios_reboot
,
383 .ident
= "Dell PowerEdge 2400",
385 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Computer Corporation"),
386 DMI_MATCH(DMI_PRODUCT_NAME
, "PowerEdge 2400"),
389 { /* Handle problems with rebooting on the Dell PowerEdge C6100. */
390 .callback
= set_pci_reboot
,
391 .ident
= "Dell PowerEdge C6100",
393 DMI_MATCH(DMI_SYS_VENDOR
, "Dell"),
394 DMI_MATCH(DMI_PRODUCT_NAME
, "C6100"),
397 { /* Handle problems with rebooting on the Precision M6600. */
398 .callback
= set_pci_reboot
,
399 .ident
= "Dell Precision M6600",
401 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
402 DMI_MATCH(DMI_PRODUCT_NAME
, "Precision M6600"),
405 { /* Handle problems with rebooting on Dell T5400's */
406 .callback
= set_bios_reboot
,
407 .ident
= "Dell Precision T5400",
409 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
410 DMI_MATCH(DMI_PRODUCT_NAME
, "Precision WorkStation T5400"),
413 { /* Handle problems with rebooting on Dell T7400's */
414 .callback
= set_bios_reboot
,
415 .ident
= "Dell Precision T7400",
417 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
418 DMI_MATCH(DMI_PRODUCT_NAME
, "Precision WorkStation T7400"),
421 { /* Handle problems with rebooting on Dell XPS710 */
422 .callback
= set_bios_reboot
,
423 .ident
= "Dell XPS710",
425 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
426 DMI_MATCH(DMI_PRODUCT_NAME
, "Dell XPS710"),
429 { /* Handle problems with rebooting on Dell Optiplex 7450 AIO */
430 .callback
= set_acpi_reboot
,
431 .ident
= "Dell OptiPlex 7450 AIO",
433 DMI_MATCH(DMI_SYS_VENDOR
, "Dell Inc."),
434 DMI_MATCH(DMI_PRODUCT_NAME
, "OptiPlex 7450 AIO"),
438 /* Hewlett-Packard */
439 { /* Handle problems with rebooting on HP laptops */
440 .callback
= set_bios_reboot
,
441 .ident
= "HP Compaq Laptop",
443 DMI_MATCH(DMI_SYS_VENDOR
, "Hewlett-Packard"),
444 DMI_MATCH(DMI_PRODUCT_NAME
, "HP Compaq"),
449 { /* Handle problems with rebooting on Sony VGN-Z540N */
450 .callback
= set_bios_reboot
,
451 .ident
= "Sony VGN-Z540N",
453 DMI_MATCH(DMI_SYS_VENDOR
, "Sony Corporation"),
454 DMI_MATCH(DMI_PRODUCT_NAME
, "VGN-Z540N"),
461 static int __init
reboot_init(void)
466 * Only do the DMI check if reboot_type hasn't been overridden
467 * on the command line
473 * The DMI quirks table takes precedence. If no quirks entry
474 * matches and the ACPI Hardware Reduced bit is set, force EFI
477 rv
= dmi_check_system(reboot_dmi_table
);
479 if (!rv
&& efi_reboot_required())
480 reboot_type
= BOOT_EFI
;
484 core_initcall(reboot_init
);
486 static inline void kb_wait(void)
490 for (i
= 0; i
< 0x10000; i
++) {
491 if ((inb(0x64) & 0x02) == 0)
497 static void vmxoff_nmi(int cpu
, struct pt_regs
*regs
)
499 cpu_emergency_vmxoff();
502 /* Use NMIs as IPIs to tell all CPUs to disable virtualization */
503 static void emergency_vmx_disable_all(void)
505 /* Just make sure we won't change CPUs while doing this */
509 * We need to disable VMX on all CPUs before rebooting, otherwise
510 * we risk hanging up the machine, because the CPU ignore INIT
511 * signals when VMX is enabled.
513 * We can't take any locks and we may be on an inconsistent
514 * state, so we use NMIs as IPIs to tell the other CPUs to disable
517 * For safety, we will avoid running the nmi_shootdown_cpus()
518 * stuff unnecessarily, but we don't have a way to check
519 * if other CPUs have VMX enabled. So we will call it only if the
520 * CPU we are running on has VMX enabled.
522 * We will miss cases where VMX is not enabled on all CPUs. This
523 * shouldn't do much harm because KVM always enable VMX on all
524 * CPUs anyway. But we can miss it on the small window where KVM
525 * is still enabling VMX.
527 if (cpu_has_vmx() && cpu_vmx_enabled()) {
528 /* Disable VMX on this CPU. */
531 /* Halt and disable VMX on the other CPUs */
532 nmi_shootdown_cpus(vmxoff_nmi
);
538 void __attribute__((weak
)) mach_reboot_fixups(void)
543 * To the best of our knowledge Windows compatible x86 hardware expects
544 * the following on reboot:
546 * 1) If the FADT has the ACPI reboot register flag set, try it
547 * 2) If still alive, write to the keyboard controller
548 * 3) If still alive, write to the ACPI reboot register again
549 * 4) If still alive, write to the keyboard controller again
550 * 5) If still alive, call the EFI runtime service to reboot
551 * 6) If no EFI runtime service, call the BIOS to do a reboot
553 * We default to following the same pattern. We also have
554 * two other reboot methods: 'triple fault' and 'PCI', which
555 * can be triggered via the reboot= kernel boot option or
558 * This means that this function can never return, it can misbehave
559 * by not rebooting properly and hanging.
561 static void native_machine_emergency_restart(void)
565 int orig_reboot_type
= reboot_type
;
568 if (reboot_emergency
)
569 emergency_vmx_disable_all();
571 tboot_shutdown(TB_SHUTDOWN_REBOOT
);
573 /* Tell the BIOS if we want cold or warm reboot */
574 mode
= reboot_mode
== REBOOT_WARM
? 0x1234 : 0;
575 *((unsigned short *)__va(0x472)) = mode
;
578 * If an EFI capsule has been registered with the firmware then
579 * override the reboot= parameter.
581 if (efi_capsule_pending(NULL
)) {
582 pr_info("EFI capsule is pending, forcing EFI reboot.\n");
583 reboot_type
= BOOT_EFI
;
587 /* Could also try the reset bit in the Hammer NB */
588 switch (reboot_type
) {
591 reboot_type
= BOOT_KBD
;
595 mach_reboot_fixups(); /* For board specific fixups */
597 for (i
= 0; i
< 10; i
++) {
600 outb(0xfe, 0x64); /* Pulse reset low */
603 if (attempt
== 0 && orig_reboot_type
== BOOT_ACPI
) {
605 reboot_type
= BOOT_ACPI
;
607 reboot_type
= BOOT_EFI
;
612 efi_reboot(reboot_mode
, NULL
);
613 reboot_type
= BOOT_BIOS
;
617 machine_real_restart(MRR_BIOS
);
619 /* We're probably dead after this, but... */
620 reboot_type
= BOOT_CF9_SAFE
;
624 port_cf9_safe
= true;
629 u8 reboot_code
= reboot_mode
== REBOOT_WARM
? 0x06 : 0x0E;
630 u8 cf9
= inb(0xcf9) & ~reboot_code
;
631 outb(cf9
|2, 0xcf9); /* Request hard reset */
633 /* Actually do the reset */
634 outb(cf9
|reboot_code
, 0xcf9);
637 reboot_type
= BOOT_TRIPLE
;
642 __asm__
__volatile__("int3");
644 /* We're probably dead after this, but... */
645 reboot_type
= BOOT_KBD
;
651 void native_machine_shutdown(void)
653 /* Stop the cpus and apics */
654 #ifdef CONFIG_X86_IO_APIC
656 * Disabling IO APIC before local APIC is a workaround for
657 * erratum AVR31 in "Intel Atom Processor C2000 Product Family
658 * Specification Update". In this situation, interrupts that target
659 * a Logical Processor whose Local APIC is either in the process of
660 * being hardware disabled or software disabled are neither delivered
661 * nor discarded. When this erratum occurs, the processor may hang.
663 * Even without the erratum, it still makes sense to quiet IO APIC
664 * before disabling Local APIC.
671 * Stop all of the others. Also disable the local irq to
672 * not receive the per-cpu timer interrupt which may trigger
673 * scheduler's load balance.
681 #ifdef CONFIG_HPET_TIMER
686 x86_platform
.iommu_shutdown();
690 static void __machine_emergency_restart(int emergency
)
692 reboot_emergency
= emergency
;
693 machine_ops
.emergency_restart();
696 static void native_machine_restart(char *__unused
)
698 pr_notice("machine restart\n");
702 __machine_emergency_restart(0);
705 static void native_machine_halt(void)
707 /* Stop other cpus and apics */
710 tboot_shutdown(TB_SHUTDOWN_HALT
);
715 static void native_machine_power_off(void)
722 /* A fallback in case there is no PM info available */
723 tboot_shutdown(TB_SHUTDOWN_HALT
);
726 struct machine_ops machine_ops __ro_after_init
= {
727 .power_off
= native_machine_power_off
,
728 .shutdown
= native_machine_shutdown
,
729 .emergency_restart
= native_machine_emergency_restart
,
730 .restart
= native_machine_restart
,
731 .halt
= native_machine_halt
,
732 #ifdef CONFIG_KEXEC_CORE
733 .crash_shutdown
= native_machine_crash_shutdown
,
737 void machine_power_off(void)
739 machine_ops
.power_off();
742 void machine_shutdown(void)
744 machine_ops
.shutdown();
747 void machine_emergency_restart(void)
749 __machine_emergency_restart(1);
752 void machine_restart(char *cmd
)
754 machine_ops
.restart(cmd
);
757 void machine_halt(void)
762 #ifdef CONFIG_KEXEC_CORE
763 void machine_crash_shutdown(struct pt_regs
*regs
)
765 machine_ops
.crash_shutdown(regs
);
770 /* This is the CPU performing the emergency shutdown work. */
771 int crashing_cpu
= -1;
773 #if defined(CONFIG_SMP)
775 static nmi_shootdown_cb shootdown_callback
;
777 static atomic_t waiting_for_crash_ipi
;
778 static int crash_ipi_issued
;
780 static int crash_nmi_callback(unsigned int val
, struct pt_regs
*regs
)
784 cpu
= raw_smp_processor_id();
787 * Don't do anything if this handler is invoked on crashing cpu.
788 * Otherwise, system will completely hang. Crashing cpu can get
789 * an NMI if system was initially booted with nmi_watchdog parameter.
791 if (cpu
== crashing_cpu
)
795 shootdown_callback(cpu
, regs
);
797 atomic_dec(&waiting_for_crash_ipi
);
798 /* Assume hlt works */
806 static void smp_send_nmi_allbutself(void)
808 apic
->send_IPI_allbutself(NMI_VECTOR
);
812 * Halt all other CPUs, calling the specified function on each of them
814 * This function can be used to halt all other CPUs on crash
815 * or emergency reboot time. The function passed as parameter
816 * will be called inside a NMI handler on all CPUs.
818 void nmi_shootdown_cpus(nmi_shootdown_cb callback
)
823 /* Make a note of crashing cpu. Will be used in NMI callback. */
824 crashing_cpu
= safe_smp_processor_id();
826 shootdown_callback
= callback
;
828 atomic_set(&waiting_for_crash_ipi
, num_online_cpus() - 1);
829 /* Would it be better to replace the trap vector here? */
830 if (register_nmi_handler(NMI_LOCAL
, crash_nmi_callback
,
831 NMI_FLAG_FIRST
, "crash"))
832 return; /* Return what? */
834 * Ensure the new callback function is set before sending
839 smp_send_nmi_allbutself();
841 /* Kick CPUs looping in NMI context. */
842 WRITE_ONCE(crash_ipi_issued
, 1);
844 msecs
= 1000; /* Wait at most a second for the other cpus to stop */
845 while ((atomic_read(&waiting_for_crash_ipi
) > 0) && msecs
) {
850 /* Leave the nmi callback set */
854 * Check if the crash dumping IPI got issued and if so, call its callback
855 * directly. This function is used when we have already been in NMI handler.
858 void run_crash_ipi_callback(struct pt_regs
*regs
)
860 if (crash_ipi_issued
)
861 crash_nmi_callback(0, regs
);
864 /* Override the weak function in kernel/panic.c */
865 void nmi_panic_self_stop(struct pt_regs
*regs
)
868 /* If no CPU is preparing crash dump, we simply loop here. */
869 run_crash_ipi_callback(regs
);
874 #else /* !CONFIG_SMP */
875 void nmi_shootdown_cpus(nmi_shootdown_cb callback
)
877 /* No other CPUs to shoot down */
880 void run_crash_ipi_callback(struct pt_regs
*regs
)