aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/kernel/machine_kexec.c30
-rw-r--r--arch/ia64/mm/discontig.c2
-rw-r--r--arch/x86/kernel/machine_kexec_32.c13
-rw-r--r--arch/x86/kernel/machine_kexec_64.c9
-rw-r--r--include/asm-ia64/numa.h1
-rw-r--r--include/linux/kexec.h26
-rw-r--r--kernel/kexec.c110
-rw-r--r--kernel/ksysfs.c10
8 files changed, 200 insertions, 1 deletions
diff --git a/arch/ia64/kernel/machine_kexec.c b/arch/ia64/kernel/machine_kexec.c
index 58e943a5d95c..40f9c3e19220 100644
--- a/arch/ia64/kernel/machine_kexec.c
+++ b/arch/ia64/kernel/machine_kexec.c
@@ -15,6 +15,8 @@
15#include <linux/cpu.h> 15#include <linux/cpu.h>
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/efi.h> 17#include <linux/efi.h>
18#include <linux/numa.h>
19#include <linux/mmzone.h>
18#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
19#include <asm/setup.h> 21#include <asm/setup.h>
20#include <asm/delay.h> 22#include <asm/delay.h>
@@ -121,3 +123,31 @@ void machine_kexec(struct kimage *image)
121 unw_init_running(ia64_machine_kexec, image); 123 unw_init_running(ia64_machine_kexec, image);
122 for(;;); 124 for(;;);
123} 125}
126
127void arch_crash_save_vmcoreinfo(void)
128{
129#ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
130 SYMBOL(pgdat_list);
131 LENGTH(pgdat_list, MAX_NUMNODES);
132
133 SYMBOL(node_memblk);
134 LENGTH(node_memblk, NR_NODE_MEMBLKS);
135 SIZE(node_memblk_s);
136 OFFSET(node_memblk_s, start_paddr);
137 OFFSET(node_memblk_s, size);
138#endif
139#ifdef CONFIG_PGTABLE_3
140 CONFIG(PGTABLE_3);
141#elif CONFIG_PGTABLE_4
142 CONFIG(PGTABLE_4);
143#endif
144}
145
146unsigned long paddr_vmcoreinfo_note(void)
147{
148 unsigned long vaddr, paddr;
149 vaddr = (unsigned long)(char *)&vmcoreinfo_note;
150 asm volatile ("tpa %0 = %1" : "=r"(paddr) : "r"(vaddr) : "memory");
151 return paddr;
152}
153
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 5628067a74d2..0b567398f38e 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -48,7 +48,7 @@ struct early_node_data {
48static struct early_node_data mem_data[MAX_NUMNODES] __initdata; 48static struct early_node_data mem_data[MAX_NUMNODES] __initdata;
49static nodemask_t memory_less_mask __initdata; 49static nodemask_t memory_less_mask __initdata;
50 50
51static pg_data_t *pgdat_list[MAX_NUMNODES]; 51pg_data_t *pgdat_list[MAX_NUMNODES];
52 52
53/* 53/*
54 * To prevent cache aliasing effects, align per-node structures so that they 54 * To prevent cache aliasing effects, align per-node structures so that they
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index deda9a221cf2..ae20fa5afa62 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -10,6 +10,7 @@
10#include <linux/kexec.h> 10#include <linux/kexec.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/numa.h>
13#include <asm/pgtable.h> 14#include <asm/pgtable.h>
14#include <asm/pgalloc.h> 15#include <asm/pgalloc.h>
15#include <asm/tlbflush.h> 16#include <asm/tlbflush.h>
@@ -169,3 +170,15 @@ static int __init parse_crashkernel(char *arg)
169 return 0; 170 return 0;
170} 171}
171early_param("crashkernel", parse_crashkernel); 172early_param("crashkernel", parse_crashkernel);
173
174void arch_crash_save_vmcoreinfo(void)
175{
176#ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
177 SYMBOL(node_data);
178 LENGTH(node_data, MAX_NUMNODES);
179#endif
180#ifdef CONFIG_X86_PAE
181 CONFIG(X86_PAE);
182#endif
183}
184
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index cd1899a2f0c5..e333ea110a58 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -10,6 +10,7 @@
10#include <linux/kexec.h> 10#include <linux/kexec.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/reboot.h> 12#include <linux/reboot.h>
13#include <linux/numa.h>
13#include <asm/pgtable.h> 14#include <asm/pgtable.h>
14#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
15#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
@@ -257,3 +258,11 @@ static int __init setup_crashkernel(char *arg)
257} 258}
258early_param("crashkernel", setup_crashkernel); 259early_param("crashkernel", setup_crashkernel);
259 260
261void arch_crash_save_vmcoreinfo(void)
262{
263#ifdef CONFIG_ARCH_DISCONTIGMEM_ENABLE
264 SYMBOL(node_data);
265 LENGTH(node_data, MAX_NUMNODES);
266#endif
267}
268
diff --git a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h
index 7d5e2ccc37a0..6a8a27cfae3e 100644
--- a/include/asm-ia64/numa.h
+++ b/include/asm-ia64/numa.h
@@ -24,6 +24,7 @@
24 24
25extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned; 25extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
26extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned; 26extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
27extern pg_data_t *pgdat_list[MAX_NUMNODES];
27 28
28/* Stuff below this line could be architecture independent */ 29/* Stuff below this line could be architecture independent */
29 30
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 8c2c7fcd58ce..99f2d6f0c83a 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -121,6 +121,23 @@ extern struct page *kimage_alloc_control_pages(struct kimage *image,
121extern void crash_kexec(struct pt_regs *); 121extern void crash_kexec(struct pt_regs *);
122int kexec_should_crash(struct task_struct *); 122int kexec_should_crash(struct task_struct *);
123void crash_save_cpu(struct pt_regs *regs, int cpu); 123void crash_save_cpu(struct pt_regs *regs, int cpu);
124void crash_save_vmcoreinfo(void);
125void arch_crash_save_vmcoreinfo(void);
126void vmcoreinfo_append_str(const char *fmt, ...);
127unsigned long paddr_vmcoreinfo_note(void);
128
129#define SYMBOL(name) \
130 vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
131#define SIZE(name) \
132 vmcoreinfo_append_str("SIZE(%s)=%d\n", #name, sizeof(struct name))
133#define OFFSET(name, field) \
134 vmcoreinfo_append_str("OFFSET(%s.%s)=%d\n", #name, #field, \
135 &(((struct name *)0)->field))
136#define LENGTH(name, value) \
137 vmcoreinfo_append_str("LENGTH(%s)=%d\n", #name, value)
138#define CONFIG(name) \
139 vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
140
124extern struct kimage *kexec_image; 141extern struct kimage *kexec_image;
125extern struct kimage *kexec_crash_image; 142extern struct kimage *kexec_crash_image;
126 143
@@ -148,11 +165,20 @@ extern struct kimage *kexec_crash_image;
148 165
149#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */ 166#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
150 167
168#define VMCOREINFO_BYTES (4096)
169#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
170#define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)
171#define VMCOREINFO_NOTE_SIZE (KEXEC_NOTE_HEAD_BYTES*2 + VMCOREINFO_BYTES \
172 + VMCOREINFO_NOTE_NAME_BYTES)
173
151/* Location of a reserved region to hold the crash kernel. 174/* Location of a reserved region to hold the crash kernel.
152 */ 175 */
153extern struct resource crashk_res; 176extern struct resource crashk_res;
154typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4]; 177typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
155extern note_buf_t *crash_notes; 178extern note_buf_t *crash_notes;
179extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
180extern unsigned int vmcoreinfo_size;
181extern unsigned int vmcoreinfo_max_size;
156 182
157 183
158#else /* !CONFIG_KEXEC */ 184#else /* !CONFIG_KEXEC */
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. */
32note_buf_t* crash_notes; 36note_buf_t* crash_notes;
33 37
38/* vmcoreinfo stuff */
39unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
40u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
41unsigned int vmcoreinfo_size = 0;
42unsigned 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 */
35struct resource crashk_res = { 45struct 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}
1136module_init(crash_notes_memory_init) 1147module_init(crash_notes_memory_init)
1148
1149void 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
1166void 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 */
1188void __attribute__ ((weak)) arch_crash_save_vmcoreinfo(void)
1189{}
1190
1191unsigned long __attribute__ ((weak)) paddr_vmcoreinfo_note(void)
1192{
1193 return __pa((unsigned long)(char *)&vmcoreinfo_note);
1194}
1195
1196static 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
1246module_init(crash_save_vmcoreinfo_init)
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 6046939d0804..38b38f957ef0 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -61,6 +61,15 @@ static ssize_t kexec_crash_loaded_show(struct kset *kset, char *page)
61 return sprintf(page, "%d\n", !!kexec_crash_image); 61 return sprintf(page, "%d\n", !!kexec_crash_image);
62} 62}
63KERNEL_ATTR_RO(kexec_crash_loaded); 63KERNEL_ATTR_RO(kexec_crash_loaded);
64
65static ssize_t vmcoreinfo_show(struct kset *kset, char *page)
66{
67 return sprintf(page, "%lx %x\n",
68 paddr_vmcoreinfo_note(),
69 vmcoreinfo_max_size);
70}
71KERNEL_ATTR_RO(vmcoreinfo);
72
64#endif /* CONFIG_KEXEC */ 73#endif /* CONFIG_KEXEC */
65 74
66/* 75/*
@@ -96,6 +105,7 @@ static struct attribute * kernel_attrs[] = {
96#ifdef CONFIG_KEXEC 105#ifdef CONFIG_KEXEC
97 &kexec_loaded_attr.attr, 106 &kexec_loaded_attr.attr,
98 &kexec_crash_loaded_attr.attr, 107 &kexec_crash_loaded_attr.attr,
108 &vmcoreinfo_attr.attr,
99#endif 109#endif
100 NULL 110 NULL
101}; 111};