machine_kexec.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <asm/cio.h>
  14. #include <asm/setup.h>
  15. #include <linux/device.h>
  16. #include <linux/mm.h>
  17. #include <linux/kexec.h>
  18. #include <linux/delay.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/pgalloc.h>
  21. #include <asm/system.h>
  22. static void kexec_halt_all_cpus(void *);
  23. typedef void (*relocate_kernel_t) (kimage_entry_t *, unsigned long);
  24. const extern unsigned char relocate_kernel[];
  25. const extern unsigned long long relocate_kernel_len;
  26. int
  27. machine_kexec_prepare(struct kimage *image)
  28. {
  29. unsigned long reboot_code_buffer;
  30. /* We don't support anything but the default image type for now. */
  31. if (image->type != KEXEC_TYPE_DEFAULT)
  32. return -EINVAL;
  33. /* Get the destination where the assembler code should be copied to.*/
  34. reboot_code_buffer = page_to_pfn(image->control_code_page)<<PAGE_SHIFT;
  35. /* Then copy it */
  36. memcpy((void *) reboot_code_buffer, relocate_kernel,
  37. relocate_kernel_len);
  38. return 0;
  39. }
  40. void
  41. machine_kexec_cleanup(struct kimage *image)
  42. {
  43. }
  44. void
  45. machine_shutdown(void)
  46. {
  47. printk(KERN_INFO "kexec: machine_shutdown called\n");
  48. }
  49. NORET_TYPE void
  50. machine_kexec(struct kimage *image)
  51. {
  52. clear_all_subchannels();
  53. /* Disable lowcore protection */
  54. ctl_clear_bit(0,28);
  55. on_each_cpu(kexec_halt_all_cpus, image, 0, 0);
  56. for (;;);
  57. }
  58. extern void pfault_fini(void);
  59. static void
  60. kexec_halt_all_cpus(void *kernel_image)
  61. {
  62. static atomic_t cpuid = ATOMIC_INIT(-1);
  63. int cpu;
  64. struct kimage *image;
  65. relocate_kernel_t data_mover;
  66. #ifdef CONFIG_PFAULT
  67. if (MACHINE_IS_VM)
  68. pfault_fini();
  69. #endif
  70. if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1)
  71. signal_processor(smp_processor_id(), sigp_stop);
  72. /* Wait for all other cpus to enter stopped state */
  73. for_each_online_cpu(cpu) {
  74. if (cpu == smp_processor_id())
  75. continue;
  76. while (!smp_cpu_not_running(cpu))
  77. cpu_relax();
  78. }
  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. }