machine_kexec.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * arch/s390/kernel/machine_kexec.c
  3. *
  4. * Copyright IBM Corp. 2005,2006
  5. *
  6. * Author(s): Rolf Adelsberger,
  7. * Heiko Carstens <heiko.carstens@de.ibm.com>
  8. */
  9. #include <linux/device.h>
  10. #include <linux/mm.h>
  11. #include <linux/kexec.h>
  12. #include <linux/delay.h>
  13. #include <linux/reboot.h>
  14. #include <linux/ftrace.h>
  15. #include <asm/cio.h>
  16. #include <asm/setup.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/pgalloc.h>
  19. #include <asm/system.h>
  20. #include <asm/smp.h>
  21. #include <asm/reset.h>
  22. #include <asm/ipl.h>
  23. typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
  24. extern const unsigned char relocate_kernel[];
  25. extern const unsigned long long relocate_kernel_len;
  26. int machine_kexec_prepare(struct kimage *image)
  27. {
  28. void *reboot_code_buffer;
  29. /* Can't replace kernel image since it is read-only. */
  30. if (ipl_flags & IPL_NSS_VALID)
  31. return -ENOSYS;
  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 = (void *) page_to_phys(image->control_code_page);
  37. /* Then copy it */
  38. memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
  39. return 0;
  40. }
  41. void machine_kexec_cleanup(struct kimage *image)
  42. {
  43. }
  44. void machine_shutdown(void)
  45. {
  46. }
  47. static void __machine_kexec(void *data)
  48. {
  49. relocate_kernel_t data_mover;
  50. struct kimage *image = data;
  51. pfault_fini();
  52. s390_reset_system();
  53. data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page);
  54. /* Call the moving routine */
  55. (*data_mover)(&image->head, image->start);
  56. for (;;);
  57. }
  58. void machine_kexec(struct kimage *image)
  59. {
  60. tracer_disable();
  61. smp_send_stop();
  62. smp_switch_to_ipl_cpu(__machine_kexec, image);
  63. }