crash.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Architecture specific (i386/x86_64) functions for kexec based crash dumps.
  3. *
  4. * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
  5. *
  6. * Copyright (C) IBM Corporation, 2004. All rights reserved.
  7. *
  8. */
  9. #include <linux/init.h>
  10. #include <linux/types.h>
  11. #include <linux/kernel.h>
  12. #include <linux/smp.h>
  13. #include <linux/reboot.h>
  14. #include <linux/kexec.h>
  15. #include <linux/delay.h>
  16. #include <linux/elf.h>
  17. #include <linux/elfcore.h>
  18. #include <asm/processor.h>
  19. #include <asm/hardirq.h>
  20. #include <asm/nmi.h>
  21. #include <asm/hw_irq.h>
  22. #include <asm/apic.h>
  23. #include <asm/hpet.h>
  24. #include <linux/kdebug.h>
  25. #include <asm/smp.h>
  26. #include <asm/reboot.h>
  27. #include <mach_ipi.h>
  28. #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
  29. static void kdump_nmi_callback(int cpu, struct die_args *args)
  30. {
  31. struct pt_regs *regs;
  32. #ifdef CONFIG_X86_32
  33. struct pt_regs fixed_regs;
  34. #endif
  35. regs = args->regs;
  36. #ifdef CONFIG_X86_32
  37. if (!user_mode_vm(regs)) {
  38. crash_fixup_ss_esp(&fixed_regs, regs);
  39. regs = &fixed_regs;
  40. }
  41. #endif
  42. crash_save_cpu(regs, cpu);
  43. disable_local_APIC();
  44. }
  45. static void kdump_nmi_shootdown_cpus(void)
  46. {
  47. nmi_shootdown_cpus(kdump_nmi_callback);
  48. disable_local_APIC();
  49. }
  50. #else
  51. static void kdump_nmi_shootdown_cpus(void)
  52. {
  53. /* There are no cpus to shootdown */
  54. }
  55. #endif
  56. void native_machine_crash_shutdown(struct pt_regs *regs)
  57. {
  58. /* This function is only called after the system
  59. * has panicked or is otherwise in a critical state.
  60. * The minimum amount of code to allow a kexec'd kernel
  61. * to run successfully needs to happen here.
  62. *
  63. * In practice this means shooting down the other cpus in
  64. * an SMP system.
  65. */
  66. /* The kernel is broken so disable interrupts */
  67. local_irq_disable();
  68. kdump_nmi_shootdown_cpus();
  69. lapic_shutdown();
  70. #if defined(CONFIG_X86_IO_APIC)
  71. disable_IO_APIC();
  72. #endif
  73. #ifdef CONFIG_HPET_TIMER
  74. hpet_disable();
  75. #endif
  76. crash_save_cpu(regs, safe_smp_processor_id());
  77. }