Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 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 | |
| 13 | #include <linux/mm.h> |
| 14 | #include <linux/kexec.h> |
| 15 | #include <linux/cpu.h> |
| 16 | #include <linux/irq.h> |
Horms | abac08db | 2007-02-05 10:16:20 +0900 | [diff] [blame] | 17 | #include <linux/efi.h> |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 18 | #include <linux/numa.h> |
| 19 | #include <linux/mmzone.h> |
Andrew Morton | 7259888 | 2007-10-17 14:28:38 -0700 | [diff] [blame] | 20 | |
| 21 | #include <asm/numa.h> |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 22 | #include <asm/mmu_context.h> |
| 23 | #include <asm/setup.h> |
| 24 | #include <asm/delay.h> |
| 25 | #include <asm/meminit.h> |
Ken'ichi Ohmichi | 00cab92 | 2007-10-16 23:27:29 -0700 | [diff] [blame] | 26 | #include <asm/processor.h> |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 27 | |
Horms | 53da576 | 2006-12-12 18:06:13 +0900 | [diff] [blame] | 28 | typedef NORET_TYPE void (*relocate_new_kernel_t)( |
| 29 | unsigned long indirection_page, |
| 30 | unsigned long start_address, |
| 31 | struct ia64_boot_param *boot_param, |
| 32 | unsigned long pal_addr) ATTRIB_NORET; |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 33 | |
| 34 | struct kimage *ia64_kimage; |
| 35 | |
| 36 | struct resource efi_memmap_res = { |
| 37 | .name = "EFI Memory Map", |
| 38 | .start = 0, |
| 39 | .end = 0, |
| 40 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM |
| 41 | }; |
| 42 | |
| 43 | struct resource boot_param_res = { |
| 44 | .name = "Boot parameter", |
| 45 | .start = 0, |
| 46 | .end = 0, |
| 47 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | /* |
| 52 | * Do what every setup is needed on image and the |
| 53 | * reboot code buffer to allow us to avoid allocations |
| 54 | * later. |
| 55 | */ |
| 56 | int machine_kexec_prepare(struct kimage *image) |
| 57 | { |
| 58 | void *control_code_buffer; |
| 59 | const unsigned long *func; |
| 60 | |
| 61 | func = (unsigned long *)&relocate_new_kernel; |
| 62 | /* Pre-load control code buffer to minimize work in kexec path */ |
| 63 | control_code_buffer = page_address(image->control_code_page); |
| 64 | memcpy((void *)control_code_buffer, (const void *)func[0], |
| 65 | relocate_new_kernel_size); |
| 66 | flush_icache_range((unsigned long)control_code_buffer, |
| 67 | (unsigned long)control_code_buffer + relocate_new_kernel_size); |
| 68 | ia64_kimage = image; |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | void machine_kexec_cleanup(struct kimage *image) |
| 74 | { |
| 75 | } |
| 76 | |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 77 | /* |
| 78 | * Do not allocate memory (or fail in any way) in machine_kexec(). |
| 79 | * We are past the point of no return, committed to rebooting now. |
| 80 | */ |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 81 | static void ia64_machine_kexec(struct unw_frame_info *info, void *arg) |
| 82 | { |
| 83 | struct kimage *image = arg; |
| 84 | relocate_new_kernel_t rnk; |
| 85 | void *pal_addr = efi_get_pal_addr(); |
| 86 | unsigned long code_addr = (unsigned long)page_address(image->control_code_page); |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 87 | int ii; |
| 88 | |
Bernhard Walle | c2c77fe | 2007-01-28 13:47:02 +0100 | [diff] [blame] | 89 | BUG_ON(!image); |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 90 | if (image->type == KEXEC_TYPE_CRASH) { |
| 91 | crash_save_this_cpu(); |
| 92 | current->thread.ksp = (__u64)info->sw - 16; |
| 93 | } |
| 94 | |
| 95 | /* Interrupts aren't acceptable while we reboot */ |
| 96 | local_irq_disable(); |
| 97 | |
| 98 | /* Mask CMC and Performance Monitor interrupts */ |
| 99 | ia64_setreg(_IA64_REG_CR_PMV, 1 << 16); |
| 100 | ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16); |
| 101 | |
| 102 | /* Mask ITV and Local Redirect Registers */ |
| 103 | ia64_set_itv(1 << 16); |
| 104 | ia64_set_lrr0(1 << 16); |
| 105 | ia64_set_lrr1(1 << 16); |
| 106 | |
| 107 | /* terminate possible nested in-service interrupts */ |
| 108 | for (ii = 0; ii < 16; ii++) |
| 109 | ia64_eoi(); |
| 110 | |
| 111 | /* unmask TPR and clear any pending interrupts */ |
| 112 | ia64_setreg(_IA64_REG_CR_TPR, 0); |
| 113 | ia64_srlz_d(); |
Simon Horman | a62c9fe | 2007-09-19 14:02:20 +0900 | [diff] [blame] | 114 | while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR) |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 115 | ia64_eoi(); |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 116 | platform_kernel_launch_event(); |
| 117 | rnk = (relocate_new_kernel_t)&code_addr; |
| 118 | (*rnk)(image->head, image->start, ia64_boot_param, |
| 119 | GRANULEROUNDDOWN((unsigned long) pal_addr)); |
| 120 | BUG(); |
| 121 | } |
| 122 | |
| 123 | void machine_kexec(struct kimage *image) |
| 124 | { |
Bernhard Walle | c2c77fe | 2007-01-28 13:47:02 +0100 | [diff] [blame] | 125 | BUG_ON(!image); |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 126 | unw_init_running(ia64_machine_kexec, image); |
| 127 | for(;;); |
| 128 | } |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 129 | |
| 130 | void arch_crash_save_vmcoreinfo(void) |
| 131 | { |
Andrew Morton | 7259888 | 2007-10-17 14:28:38 -0700 | [diff] [blame] | 132 | #if defined(CONFIG_ARCH_DISCONTIGMEM_ENABLE) && defined(CONFIG_NUMA) |
Ken'ichi Ohmichi | bcbba6c | 2007-10-16 23:27:30 -0700 | [diff] [blame] | 133 | VMCOREINFO_SYMBOL(pgdat_list); |
| 134 | VMCOREINFO_LENGTH(pgdat_list, MAX_NUMNODES); |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 135 | |
Ken'ichi Ohmichi | bcbba6c | 2007-10-16 23:27:30 -0700 | [diff] [blame] | 136 | VMCOREINFO_SYMBOL(node_memblk); |
| 137 | VMCOREINFO_LENGTH(node_memblk, NR_NODE_MEMBLKS); |
Ken'ichi Ohmichi | c76f860 | 2008-02-07 00:15:20 -0800 | [diff] [blame^] | 138 | VMCOREINFO_STRUCT_SIZE(node_memblk_s); |
Ken'ichi Ohmichi | bcbba6c | 2007-10-16 23:27:30 -0700 | [diff] [blame] | 139 | VMCOREINFO_OFFSET(node_memblk_s, start_paddr); |
| 140 | VMCOREINFO_OFFSET(node_memblk_s, size); |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 141 | #endif |
| 142 | #ifdef CONFIG_PGTABLE_3 |
Ken'ichi Ohmichi | bcbba6c | 2007-10-16 23:27:30 -0700 | [diff] [blame] | 143 | VMCOREINFO_CONFIG(PGTABLE_3); |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 144 | #elif CONFIG_PGTABLE_4 |
Ken'ichi Ohmichi | bcbba6c | 2007-10-16 23:27:30 -0700 | [diff] [blame] | 145 | VMCOREINFO_CONFIG(PGTABLE_4); |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 146 | #endif |
| 147 | } |
| 148 | |
| 149 | unsigned long paddr_vmcoreinfo_note(void) |
| 150 | { |
Ken'ichi Ohmichi | 00cab92 | 2007-10-16 23:27:29 -0700 | [diff] [blame] | 151 | return ia64_tpa((unsigned long)(char *)&vmcoreinfo_note); |
Ken'ichi Ohmichi | fd59d23 | 2007-10-16 23:27:27 -0700 | [diff] [blame] | 152 | } |
| 153 | |