diff options
Diffstat (limited to 'kernel/kexec.c')
-rw-r--r-- | kernel/kexec.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c index d8de12e943cf..67828befbfc3 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
@@ -21,16 +21,26 @@ | |||
21 | #include <linux/hardirq.h> | 21 | #include <linux/hardirq.h> |
22 | #include <linux/elf.h> | 22 | #include <linux/elf.h> |
23 | #include <linux/elfcore.h> | 23 | #include <linux/elfcore.h> |
24 | #include <linux/utsrelease.h> | ||
25 | #include <linux/utsname.h> | ||
26 | #include <linux/numa.h> | ||
24 | 27 | ||
25 | #include <asm/page.h> | 28 | #include <asm/page.h> |
26 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
27 | #include <asm/io.h> | 30 | #include <asm/io.h> |
28 | #include <asm/system.h> | 31 | #include <asm/system.h> |
29 | #include <asm/semaphore.h> | 32 | #include <asm/semaphore.h> |
33 | #include <asm/sections.h> | ||
30 | 34 | ||
31 | /* Per cpu memory for storing cpu states in case of system crash. */ | 35 | /* Per cpu memory for storing cpu states in case of system crash. */ |
32 | note_buf_t* crash_notes; | 36 | note_buf_t* crash_notes; |
33 | 37 | ||
38 | /* vmcoreinfo stuff */ | ||
39 | unsigned char vmcoreinfo_data[VMCOREINFO_BYTES]; | ||
40 | u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4]; | ||
41 | unsigned int vmcoreinfo_size = 0; | ||
42 | unsigned int vmcoreinfo_max_size = sizeof(vmcoreinfo_data); | ||
43 | |||
34 | /* Location of the reserved area for the crash kernel */ | 44 | /* Location of the reserved area for the crash kernel */ |
35 | struct resource crashk_res = { | 45 | struct resource crashk_res = { |
36 | .name = "Crash kernel", | 46 | .name = "Crash kernel", |
@@ -1060,6 +1070,7 @@ void crash_kexec(struct pt_regs *regs) | |||
1060 | if (kexec_crash_image) { | 1070 | if (kexec_crash_image) { |
1061 | struct pt_regs fixed_regs; | 1071 | struct pt_regs fixed_regs; |
1062 | crash_setup_regs(&fixed_regs, regs); | 1072 | crash_setup_regs(&fixed_regs, regs); |
1073 | crash_save_vmcoreinfo(); | ||
1063 | machine_crash_shutdown(&fixed_regs); | 1074 | machine_crash_shutdown(&fixed_regs); |
1064 | machine_kexec(kexec_crash_image); | 1075 | machine_kexec(kexec_crash_image); |
1065 | } | 1076 | } |
@@ -1134,3 +1145,102 @@ static int __init crash_notes_memory_init(void) | |||
1134 | return 0; | 1145 | return 0; |
1135 | } | 1146 | } |
1136 | module_init(crash_notes_memory_init) | 1147 | module_init(crash_notes_memory_init) |
1148 | |||
1149 | void crash_save_vmcoreinfo(void) | ||
1150 | { | ||
1151 | u32 *buf; | ||
1152 | |||
1153 | if (!vmcoreinfo_size) | ||
1154 | return; | ||
1155 | |||
1156 | vmcoreinfo_append_str("CRASHTIME=%d", xtime.tv_sec); | ||
1157 | |||
1158 | buf = (u32 *)vmcoreinfo_note; | ||
1159 | |||
1160 | buf = append_elf_note(buf, VMCOREINFO_NOTE_NAME, 0, vmcoreinfo_data, | ||
1161 | vmcoreinfo_size); | ||
1162 | |||
1163 | final_note(buf); | ||
1164 | } | ||
1165 | |||
1166 | void vmcoreinfo_append_str(const char *fmt, ...) | ||
1167 | { | ||
1168 | va_list args; | ||
1169 | char buf[0x50]; | ||
1170 | int r; | ||
1171 | |||
1172 | va_start(args, fmt); | ||
1173 | r = vsnprintf(buf, sizeof(buf), fmt, args); | ||
1174 | va_end(args); | ||
1175 | |||
1176 | if (r + vmcoreinfo_size > vmcoreinfo_max_size) | ||
1177 | r = vmcoreinfo_max_size - vmcoreinfo_size; | ||
1178 | |||
1179 | memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r); | ||
1180 | |||
1181 | vmcoreinfo_size += r; | ||
1182 | } | ||
1183 | |||
1184 | /* | ||
1185 | * provide an empty default implementation here -- architecture | ||
1186 | * code may override this | ||
1187 | */ | ||
1188 | void __attribute__ ((weak)) arch_crash_save_vmcoreinfo(void) | ||
1189 | {} | ||
1190 | |||
1191 | unsigned long __attribute__ ((weak)) paddr_vmcoreinfo_note(void) | ||
1192 | { | ||
1193 | return __pa((unsigned long)(char *)&vmcoreinfo_note); | ||
1194 | } | ||
1195 | |||
1196 | static int __init crash_save_vmcoreinfo_init(void) | ||
1197 | { | ||
1198 | vmcoreinfo_append_str("OSRELEASE=%s\n", UTS_RELEASE); | ||
1199 | vmcoreinfo_append_str("PAGESIZE=%d\n", PAGE_SIZE); | ||
1200 | |||
1201 | SYMBOL(init_uts_ns); | ||
1202 | SYMBOL(node_online_map); | ||
1203 | SYMBOL(swapper_pg_dir); | ||
1204 | SYMBOL(_stext); | ||
1205 | |||
1206 | #ifndef CONFIG_NEED_MULTIPLE_NODES | ||
1207 | SYMBOL(mem_map); | ||
1208 | SYMBOL(contig_page_data); | ||
1209 | #endif | ||
1210 | #ifdef CONFIG_SPARSEMEM | ||
1211 | SYMBOL(mem_section); | ||
1212 | LENGTH(mem_section, NR_SECTION_ROOTS); | ||
1213 | SIZE(mem_section); | ||
1214 | OFFSET(mem_section, section_mem_map); | ||
1215 | #endif | ||
1216 | SIZE(page); | ||
1217 | SIZE(pglist_data); | ||
1218 | SIZE(zone); | ||
1219 | SIZE(free_area); | ||
1220 | SIZE(list_head); | ||
1221 | OFFSET(page, flags); | ||
1222 | OFFSET(page, _count); | ||
1223 | OFFSET(page, mapping); | ||
1224 | OFFSET(page, lru); | ||
1225 | OFFSET(pglist_data, node_zones); | ||
1226 | OFFSET(pglist_data, nr_zones); | ||
1227 | #ifdef CONFIG_FLAT_NODE_MEM_MAP | ||
1228 | OFFSET(pglist_data, node_mem_map); | ||
1229 | #endif | ||
1230 | OFFSET(pglist_data, node_start_pfn); | ||
1231 | OFFSET(pglist_data, node_spanned_pages); | ||
1232 | OFFSET(pglist_data, node_id); | ||
1233 | OFFSET(zone, free_area); | ||
1234 | OFFSET(zone, vm_stat); | ||
1235 | OFFSET(zone, spanned_pages); | ||
1236 | OFFSET(free_area, free_list); | ||
1237 | OFFSET(list_head, next); | ||
1238 | OFFSET(list_head, prev); | ||
1239 | LENGTH(zone.free_area, MAX_ORDER); | ||
1240 | |||
1241 | arch_crash_save_vmcoreinfo(); | ||
1242 | |||
1243 | return 0; | ||
1244 | } | ||
1245 | |||
1246 | module_init(crash_save_vmcoreinfo_init) | ||