public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Put each per-cpu kdump ELF notes into a single page
@ 2014-09-05 16:33 Petr Tesarik
  2014-09-11 19:37 ` Petr Tesarik
  2014-09-11 20:01 ` Vivek Goyal
  0 siblings, 2 replies; 7+ messages in thread
From: Petr Tesarik @ 2014-09-05 16:33 UTC (permalink / raw)
  To: Eric Biederman; +Cc: kexec, linux-kernel

On architectures that use percpu-vm, the percpu region is not guaranteed
to be contiguous in physical space. However, fs/proc/vmcore.c expects
all ELF notes to be contiguous. If the ELF note happens to occupy
two non-adjacent physical pages, part of the note may be read from an
incorrect memory location by the kdump kernel, resulting in failure to
initialize /proc/vmcore (if the content of the following physical page,
incorrectly interpreted as an ELF note specifies a large number), wrong
register values or other apparent random memory corruption.

There is currently no mechanism to pass the virtual-to-physical mapping
of the percpu allocation to the kdump kernel. So, instead, I'm changing
the alignment of the ELF note buffer. Since sizeof(note_buf_t) is less
than PAGE_SIZE, aligning the buffer to the nearest higher power of 2
is enough to make sure that the buffer cannot cross a page boundary,
effectively ensuring that the whole buffer is contiguous in physical
space.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
 kernel/kexec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 2bee072..cdab59d 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1610,7 +1610,8 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
 static int __init crash_notes_memory_init(void)
 {
 	/* Allocate memory for saving cpu registers. */
-	crash_notes = alloc_percpu(note_buf_t);
+	crash_notes = __alloc_percpu(sizeof(note_buf_t),
+				     roundup_pow_of_two(sizeof(note_buf_t)));
 	if (!crash_notes) {
 		pr_warn("Kexec: Memory allocation for saving cpu register states failed\n");
 		return -ENOMEM;
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-12 11:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-05 16:33 [PATCH] Put each per-cpu kdump ELF notes into a single page Petr Tesarik
2014-09-11 19:37 ` Petr Tesarik
2014-09-11 20:01 ` Vivek Goyal
2014-09-11 20:43   ` Petr Tesarik
2014-09-11 21:16     ` Vivek Goyal
2014-09-11 22:15       ` Petr Tesarik
2014-09-12 11:52         ` Vivek Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox