machine_kexec.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * arch/ia64/kernel/machine_kexec.c
  3. *
  4. * Handle transition of Linux booting another kernel
  5. * Copyright (C) 2005 Hewlett-Packard Development Comapny, L.P.
  6. * Copyright (C) 2005 Khalid Aziz <khalid.aziz@hp.com>
  7. * Copyright (C) 2006 Intel Corp, Zou Nan hai <nanhai.zou@intel.com>
  8. *
  9. * This source code is licensed under the GNU General Public License,
  10. * Version 2. See the file COPYING for more details.
  11. */
  12. #include <linux/mm.h>
  13. #include <linux/kexec.h>
  14. #include <linux/cpu.h>
  15. #include <linux/irq.h>
  16. #include <linux/efi.h>
  17. #include <linux/numa.h>
  18. #include <linux/mmzone.h>
  19. #include <asm/mmu_context.h>
  20. #include <asm/setup.h>
  21. #include <asm/delay.h>
  22. #include <asm/meminit.h>
  23. typedef NORET_TYPE void (*relocate_new_kernel_t)(
  24. unsigned long indirection_page,
  25. unsigned long start_address,
  26. struct ia64_boot_param *boot_param,
  27. unsigned long pal_addr) ATTRIB_NORET;
  28. struct kimage *ia64_kimage;
  29. struct resource efi_memmap_res = {
  30. .name = "EFI Memory Map",
  31. .start = 0,
  32. .end = 0,
  33. .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  34. };
  35. struct resource boot_param_res = {
  36. .name = "Boot parameter",
  37. .start = 0,
  38. .end = 0,
  39. .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  40. };
  41. /*
  42. * Do what every setup is needed on image and the
  43. * reboot code buffer to allow us to avoid allocations
  44. * later.
  45. */
  46. int machine_kexec_prepare(struct kimage *image)
  47. {
  48. void *control_code_buffer;
  49. const unsigned long *func;
  50. func = (unsigned long *)&relocate_new_kernel;
  51. /* Pre-load control code buffer to minimize work in kexec path */
  52. control_code_buffer = page_address(image->control_code_page);
  53. memcpy((void *)control_code_buffer, (const void *)func[0],
  54. relocate_new_kernel_size);
  55. flush_icache_range((unsigned long)control_code_buffer,
  56. (unsigned long)control_code_buffer + relocate_new_kernel_size);
  57. ia64_kimage = image;
  58. return 0;
  59. }
  60. void machine_kexec_cleanup(struct kimage *image)
  61. {
  62. }
  63. /*
  64. * Do not allocate memory (or fail in any way) in machine_kexec().
  65. * We are past the point of no return, committed to rebooting now.
  66. */
  67. static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
  68. {
  69. struct kimage *image = arg;
  70. relocate_new_kernel_t rnk;
  71. void *pal_addr = efi_get_pal_addr();
  72. unsigned long code_addr = (unsigned long)page_address(image->control_code_page);
  73. int ii;
  74. BUG_ON(!image);
  75. if (image->type == KEXEC_TYPE_CRASH) {
  76. crash_save_this_cpu();
  77. current->thread.ksp = (__u64)info->sw - 16;
  78. }
  79. /* Interrupts aren't acceptable while we reboot */
  80. local_irq_disable();
  81. /* Mask CMC and Performance Monitor interrupts */
  82. ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
  83. ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
  84. /* Mask ITV and Local Redirect Registers */
  85. ia64_set_itv(1 << 16);
  86. ia64_set_lrr0(1 << 16);
  87. ia64_set_lrr1(1 << 16);
  88. /* terminate possible nested in-service interrupts */
  89. for (ii = 0; ii < 16; ii++)
  90. ia64_eoi();
  91. /* unmask TPR and clear any pending interrupts */
  92. ia64_setreg(_IA64_REG_CR_TPR, 0);
  93. ia64_srlz_d();
  94. while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
  95. ia64_eoi();
  96. platform_kernel_launch_event();
  97. rnk = (relocate_new_kernel_t)&code_addr;
  98. (*rnk)(image->head, image->start, ia64_boot_param,
  99. GRANULEROUNDDOWN((unsigned long) pal_addr));
  100. BUG();
  101. }
  102. void machine_kexec(struct kimage *image)
  103. {
  104. BUG_ON(!image);
  105. unw_init_running(ia64_machine_kexec, image);
  106. for(;;);
  107. }
  108. void arch_crash_save_vmcoreinfo(void)
  109. {
  110. #ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
  111. SYMBOL(pgdat_list);
  112. LENGTH(pgdat_list, MAX_NUMNODES);
  113. SYMBOL(node_memblk);
  114. LENGTH(node_memblk, NR_NODE_MEMBLKS);
  115. SIZE(node_memblk_s);
  116. OFFSET(node_memblk_s, start_paddr);
  117. OFFSET(node_memblk_s, size);
  118. #endif
  119. #ifdef CONFIG_PGTABLE_3
  120. CONFIG(PGTABLE_3);
  121. #elif CONFIG_PGTABLE_4
  122. CONFIG(PGTABLE_4);
  123. #endif
  124. }
  125. unsigned long paddr_vmcoreinfo_note(void)
  126. {
  127. unsigned long vaddr, paddr;
  128. vaddr = (unsigned long)(char *)&vmcoreinfo_note;
  129. asm volatile ("tpa %0 = %1" : "=r"(paddr) : "r"(vaddr) : "memory");
  130. return paddr;
  131. }