machine_kexec.c 2.2 KB

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