diff options
author | Magnus Damm <magnus@valinux.co.jp> | 2006-12-06 23:40:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 11:39:46 -0500 |
commit | 85916f8166b59eeac63d2b4f7f1df8de849334b4 (patch) | |
tree | 176176a0a75cfe42043c463a4391dd9f7975a69c /arch/i386/kernel/crash.c | |
parent | 6d4df677f8a60ea6bc0ef1a596c1a3a79b1d4882 (diff) |
[PATCH] Kexec / Kdump: Unify elf note code
The elf note saving code is currently duplicated over several
architectures. This cleanup patch simply adds code to a common file and
then replaces the arch-specific code with calls to the newly added code.
The only drawback with this approach is that s390 doesn't fully support
kexec-on-panic which for that arch leads to introduction of unused code.
Signed-off-by: Magnus Damm <magnus@valinux.co.jp>
Cc: Vivek Goyal <vgoyal@in.ibm.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel/crash.c')
-rw-r--r-- | arch/i386/kernel/crash.c | 66 |
1 files changed, 2 insertions, 64 deletions
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c index 144b43288965..a5e0e990ea95 100644 --- a/arch/i386/kernel/crash.c +++ b/arch/i386/kernel/crash.c | |||
@@ -31,68 +31,6 @@ | |||
31 | /* This keeps a track of which one is crashing cpu. */ | 31 | /* This keeps a track of which one is crashing cpu. */ |
32 | static int crashing_cpu; | 32 | static int crashing_cpu; |
33 | 33 | ||
34 | static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data, | ||
35 | size_t data_len) | ||
36 | { | ||
37 | struct elf_note note; | ||
38 | |||
39 | note.n_namesz = strlen(name) + 1; | ||
40 | note.n_descsz = data_len; | ||
41 | note.n_type = type; | ||
42 | memcpy(buf, ¬e, sizeof(note)); | ||
43 | buf += (sizeof(note) +3)/4; | ||
44 | memcpy(buf, name, note.n_namesz); | ||
45 | buf += (note.n_namesz + 3)/4; | ||
46 | memcpy(buf, data, note.n_descsz); | ||
47 | buf += (note.n_descsz + 3)/4; | ||
48 | |||
49 | return buf; | ||
50 | } | ||
51 | |||
52 | static void final_note(u32 *buf) | ||
53 | { | ||
54 | struct elf_note note; | ||
55 | |||
56 | note.n_namesz = 0; | ||
57 | note.n_descsz = 0; | ||
58 | note.n_type = 0; | ||
59 | memcpy(buf, ¬e, sizeof(note)); | ||
60 | } | ||
61 | |||
62 | static void crash_save_this_cpu(struct pt_regs *regs, int cpu) | ||
63 | { | ||
64 | struct elf_prstatus prstatus; | ||
65 | u32 *buf; | ||
66 | |||
67 | if ((cpu < 0) || (cpu >= NR_CPUS)) | ||
68 | return; | ||
69 | |||
70 | /* Using ELF notes here is opportunistic. | ||
71 | * I need a well defined structure format | ||
72 | * for the data I pass, and I need tags | ||
73 | * on the data to indicate what information I have | ||
74 | * squirrelled away. ELF notes happen to provide | ||
75 | * all of that, so there is no need to invent something new. | ||
76 | */ | ||
77 | buf = (u32*)per_cpu_ptr(crash_notes, cpu); | ||
78 | if (!buf) | ||
79 | return; | ||
80 | memset(&prstatus, 0, sizeof(prstatus)); | ||
81 | prstatus.pr_pid = current->pid; | ||
82 | elf_core_copy_regs(&prstatus.pr_reg, regs); | ||
83 | buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus, | ||
84 | sizeof(prstatus)); | ||
85 | final_note(buf); | ||
86 | } | ||
87 | |||
88 | static void crash_save_self(struct pt_regs *regs) | ||
89 | { | ||
90 | int cpu; | ||
91 | |||
92 | cpu = safe_smp_processor_id(); | ||
93 | crash_save_this_cpu(regs, cpu); | ||
94 | } | ||
95 | |||
96 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) | 34 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) |
97 | static atomic_t waiting_for_crash_ipi; | 35 | static atomic_t waiting_for_crash_ipi; |
98 | 36 | ||
@@ -121,7 +59,7 @@ static int crash_nmi_callback(struct notifier_block *self, | |||
121 | crash_fixup_ss_esp(&fixed_regs, regs); | 59 | crash_fixup_ss_esp(&fixed_regs, regs); |
122 | regs = &fixed_regs; | 60 | regs = &fixed_regs; |
123 | } | 61 | } |
124 | crash_save_this_cpu(regs, cpu); | 62 | crash_save_cpu(regs, cpu); |
125 | disable_local_APIC(); | 63 | disable_local_APIC(); |
126 | atomic_dec(&waiting_for_crash_ipi); | 64 | atomic_dec(&waiting_for_crash_ipi); |
127 | /* Assume hlt works */ | 65 | /* Assume hlt works */ |
@@ -195,5 +133,5 @@ void machine_crash_shutdown(struct pt_regs *regs) | |||
195 | #if defined(CONFIG_X86_IO_APIC) | 133 | #if defined(CONFIG_X86_IO_APIC) |
196 | disable_IO_APIC(); | 134 | disable_IO_APIC(); |
197 | #endif | 135 | #endif |
198 | crash_save_self(regs); | 136 | crash_save_cpu(regs, safe_smp_processor_id()); |
199 | } | 137 | } |