machine_kexec.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * arch/s390/kernel/machine_kexec.c
  3. *
  4. * (C) Copyright IBM Corp. 2005
  5. *
  6. * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
  7. *
  8. */
  9. /*
  10. * s390_machine_kexec.c - handle the transition of Linux booting another kernel
  11. * on the S390 architecture.
  12. */
  13. #include <linux/device.h>
  14. #include <linux/mm.h>
  15. #include <linux/kexec.h>
  16. #include <linux/delay.h>
  17. #include <asm/cio.h>
  18. #include <asm/setup.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/pgalloc.h>
  21. #include <asm/system.h>
  22. #include <asm/smp.h>
  23. #include <asm/reset.h>
  24. static void kexec_halt_all_cpus(void *);
  25. typedef void (*relocate_kernel_t) (kimage_entry_t *, unsigned long);
  26. extern const unsigned char relocate_kernel[];
  27. extern const unsigned long long relocate_kernel_len;
  28. int
  29. machine_kexec_prepare(struct kimage *image)
  30. {
  31. unsigned long reboot_code_buffer;
  32. /* We don't support anything but the default image type for now. */
  33. if (image->type != KEXEC_TYPE_DEFAULT)
  34. return -EINVAL;
  35. /* Get the destination where the assembler code should be copied to.*/
  36. reboot_code_buffer = page_to_pfn(image->control_code_page)<<PAGE_SHIFT;
  37. /* Then copy it */
  38. memcpy((void *) reboot_code_buffer, relocate_kernel,
  39. relocate_kernel_len);
  40. return 0;
  41. }
  42. void
  43. machine_kexec_cleanup(struct kimage *image)
  44. {
  45. }
  46. void
  47. machine_shutdown(void)
  48. {
  49. printk(KERN_INFO "kexec: machine_shutdown called\n");
  50. }
  51. NORET_TYPE void
  52. machine_kexec(struct kimage *image)
  53. {
  54. on_each_cpu(kexec_halt_all_cpus, image, 0, 0);
  55. for (;;);
  56. }
  57. extern void pfault_fini(void);
  58. static void
  59. kexec_halt_all_cpus(void *kernel_image)
  60. {
  61. static atomic_t cpuid = ATOMIC_INIT(-1);
  62. int cpu;
  63. struct kimage *image;
  64. relocate_kernel_t data_mover;
  65. #ifdef CONFIG_PFAULT
  66. if (MACHINE_IS_VM)
  67. pfault_fini();
  68. #endif
  69. if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1)
  70. signal_processor(smp_processor_id(), sigp_stop);
  71. /* Wait for all other cpus to enter stopped state */
  72. for_each_online_cpu(cpu) {
  73. if (cpu == smp_processor_id())
  74. continue;
  75. while (!smp_cpu_not_running(cpu))
  76. cpu_relax();
  77. }
  78. s390_reset_system();
  79. image = (struct kimage *) kernel_image;
  80. data_mover = (relocate_kernel_t)
  81. (page_to_pfn(image->control_code_page) << PAGE_SHIFT);
  82. /* Call the moving routine */
  83. (*data_mover) (&image->head, image->start);
  84. }