machine_kexec.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/numa.h>
  20. #include <asm/mmu_context.h>
  21. #include <asm/setup.h>
  22. #include <asm/delay.h>
  23. #include <asm/meminit.h>
  24. #include <asm/processor.h>
  25. #include <asm/sal.h>
  26. #include <asm/mca.h>
  27. typedef void (*relocate_new_kernel_t)(
  28. unsigned long indirection_page,
  29. unsigned long start_address,
  30. struct ia64_boot_param *boot_param,
  31. unsigned long pal_addr) __noreturn;
  32. struct kimage *ia64_kimage;
  33. struct resource efi_memmap_res = {
  34. .name = "EFI Memory Map",
  35. .start = 0,
  36. .end = 0,
  37. .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  38. };
  39. struct resource boot_param_res = {
  40. .name = "Boot parameter",
  41. .start = 0,
  42. .end = 0,
  43. .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  44. };
  45. /*
  46. * Do what every setup is needed on image and the
  47. * reboot code buffer to allow us to avoid allocations
  48. * later.
  49. */
  50. int machine_kexec_prepare(struct kimage *image)
  51. {
  52. void *control_code_buffer;
  53. const unsigned long *func;
  54. func = (unsigned long *)&relocate_new_kernel;
  55. /* Pre-load control code buffer to minimize work in kexec path */
  56. control_code_buffer = page_address(image->control_code_page);
  57. memcpy((void *)control_code_buffer, (const void *)func[0],
  58. relocate_new_kernel_size);
  59. flush_icache_range((unsigned long)control_code_buffer,
  60. (unsigned long)control_code_buffer + relocate_new_kernel_size);
  61. ia64_kimage = image;
  62. return 0;
  63. }
  64. void machine_kexec_cleanup(struct kimage *image)
  65. {
  66. }
  67. /*
  68. * Do not allocate memory (or fail in any way) in machine_kexec().
  69. * We are past the point of no return, committed to rebooting now.
  70. */
  71. static void ia64_machine_kexec(struct unw_frame_info *info, void *arg)
  72. {
  73. struct kimage *image = arg;
  74. relocate_new_kernel_t rnk;
  75. void *pal_addr = efi_get_pal_addr();
  76. unsigned long code_addr;
  77. int ii;
  78. u64 fp, gp;
  79. ia64_fptr_t *init_handler = (ia64_fptr_t *)ia64_os_init_on_kdump;
  80. BUG_ON(!image);
  81. code_addr = (unsigned long)page_address(image->control_code_page);
  82. if (image->type == KEXEC_TYPE_CRASH) {
  83. crash_save_this_cpu();
  84. current->thread.ksp = (__u64)info->sw - 16;
  85. /* Register noop init handler */
  86. fp = ia64_tpa(init_handler->fp);
  87. gp = ia64_tpa(ia64_getreg(_IA64_REG_GP));
  88. ia64_sal_set_vectors(SAL_VECTOR_OS_INIT, fp, gp, 0, fp, gp, 0);
  89. } else {
  90. /* Unregister init handlers of current kernel */
  91. ia64_sal_set_vectors(SAL_VECTOR_OS_INIT, 0, 0, 0, 0, 0, 0);
  92. }
  93. /* Unregister mca handler - No more recovery on current kernel */
  94. ia64_sal_set_vectors(SAL_VECTOR_OS_MCA, 0, 0, 0, 0, 0, 0);
  95. /* Interrupts aren't acceptable while we reboot */
  96. local_irq_disable();
  97. /* Mask CMC and Performance Monitor interrupts */
  98. ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
  99. ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
  100. /* Mask ITV and Local Redirect Registers */
  101. ia64_set_itv(1 << 16);
  102. ia64_set_lrr0(1 << 16);
  103. ia64_set_lrr1(1 << 16);
  104. /* terminate possible nested in-service interrupts */
  105. for (ii = 0; ii < 16; ii++)
  106. ia64_eoi();
  107. /* unmask TPR and clear any pending interrupts */
  108. ia64_setreg(_IA64_REG_CR_TPR, 0);
  109. ia64_srlz_d();
  110. while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
  111. ia64_eoi();
  112. platform_kernel_launch_event();
  113. rnk = (relocate_new_kernel_t)&code_addr;
  114. (*rnk)(image->head, image->start, ia64_boot_param,
  115. GRANULEROUNDDOWN((unsigned long) pal_addr));
  116. BUG();
  117. }
  118. void machine_kexec(struct kimage *image)
  119. {
  120. BUG_ON(!image);
  121. unw_init_running(ia64_machine_kexec, image);
  122. for(;;);
  123. }
  124. void arch_crash_save_vmcoreinfo(void)
  125. {
  126. #if defined(CONFIG_DISCONTIGMEM) || defined(CONFIG_SPARSEMEM)
  127. VMCOREINFO_SYMBOL(pgdat_list);
  128. VMCOREINFO_LENGTH(pgdat_list, MAX_NUMNODES);
  129. #endif
  130. #ifdef CONFIG_NUMA
  131. VMCOREINFO_SYMBOL(node_memblk);
  132. VMCOREINFO_LENGTH(node_memblk, NR_NODE_MEMBLKS);
  133. VMCOREINFO_STRUCT_SIZE(node_memblk_s);
  134. VMCOREINFO_OFFSET(node_memblk_s, start_paddr);
  135. VMCOREINFO_OFFSET(node_memblk_s, size);
  136. #endif
  137. #if CONFIG_PGTABLE_LEVELS == 3
  138. VMCOREINFO_CONFIG(PGTABLE_3);
  139. #elif CONFIG_PGTABLE_LEVELS == 4
  140. VMCOREINFO_CONFIG(PGTABLE_4);
  141. #endif
  142. }
  143. phys_addr_t paddr_vmcoreinfo_note(void)
  144. {
  145. return ia64_tpa((unsigned long)(char *)&vmcoreinfo_note);
  146. }