machine_kexec.c 4.0 KB

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