public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-m68k@lists.linux-m68k.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Eric Biederman <ebiederm@xmission.com>
Subject: [PATCH 1/3] kexec: Add debug printing of kimage table entries
Date: Tue, 15 Oct 2013 19:48:25 +0200	[thread overview]
Message-ID: <1381859307-11932-2-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1381859307-11932-1-git-send-email-geert@linux-m68k.org>

Print a list of pages to be copied if debugging is enabled.
Consecutive entries are merged to reduce screen clutter.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Eric Biederman <ebiederm@xmission.com>
---
 kernel/kexec.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 490afc03627e..e25022ac229e 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1073,6 +1073,80 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
 }
 #endif
 
+#ifdef DEBUG
+struct kimage_block {
+	unsigned long dst, src, len;
+};
+
+static void kimage_print_block(const struct kimage_block *block)
+{
+	pr_info("Copy from 0x%lx-0x%lx to 0x%lx-0x%lx (0x%lx bytes)\n",
+		block->src, block->src + block->len - 1, block->dst,
+		block->dst + block->len - 1, block->len);
+}
+
+static void kimage_print(const struct kimage *image)
+{
+	void *control_code_page;
+	const kimage_entry_t *ptr;
+	kimage_entry_t entry;
+	struct kimage_block block;
+	unsigned long dnext = KIMAGE_NO_DEST, snext = KIMAGE_NO_DEST;
+	unsigned long total = 0;
+
+	control_code_page = page_address(image->control_code_page);
+	pr_info("Control code page 0x%p (phys 0x%lx)\n",
+		control_code_page, virt_to_phys(control_code_page));
+
+	ptr = &image->head;
+	block.dst = KIMAGE_NO_DEST;
+	block.src = KIMAGE_NO_DEST;
+	block.len = 0;
+	while ((entry = *ptr)) {
+		if (entry & IND_DONE)
+			break;
+
+		if (entry & IND_DESTINATION) {
+			if (block.len > 0) {
+				kimage_print_block(&block);
+				total += block.len;
+			}
+			dnext = block.dst = entry & PAGE_MASK;
+			block.src = KIMAGE_NO_DEST;
+			block.len = 0;
+		}
+
+		if (entry & IND_SOURCE) {
+			if (!block.len) {
+				snext = block.src = entry & PAGE_MASK;
+			} else if ((entry & PAGE_MASK) != snext) {
+				kimage_print_block(&block);
+				total += block.len;
+				block.dst = dnext;
+				snext = block.src = entry & PAGE_MASK;
+				block.len = 0;
+			}
+			dnext += PAGE_SIZE;
+			snext += PAGE_SIZE;
+			block.len += PAGE_SIZE;
+		}
+
+		if (entry & IND_INDIRECTION) {
+			pr_info("Indirection page 0x%lx\n", entry & PAGE_MASK);
+			ptr = phys_to_virt(entry & PAGE_MASK);
+		} else
+			ptr++;
+	}
+	if (block.len) {
+		kimage_print_block(&block);
+		total += block.len;
+	}
+	pr_info("Total: 0x%lx/%ld bytes\n", total, total);
+}
+#else
+static inline void kimage_print(const struct kimage *image) {}
+#endif
+
 void crash_kexec(struct pt_regs *regs)
 {
 	/* Take the kexec_mutex here to prevent sys_kexec_load
@@ -1090,6 +1164,7 @@ void crash_kexec(struct pt_regs *regs)
 			crash_setup_regs(&fixed_regs, regs);
 			crash_save_vmcoreinfo();
 			machine_crash_shutdown(&fixed_regs);
+			kimage_print(kexec_crash_image);
 			machine_kexec(kexec_crash_image);
 		}
 		mutex_unlock(&kexec_mutex);
@@ -1680,6 +1755,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kimage_print(kexec_image);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP
-- 
1.7.9.5


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2013-10-15 17:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 17:48 [PATCH v2] kexec support for Linux/m68k (kernel part) Geert Uytterhoeven
2013-10-15 17:48 ` Geert Uytterhoeven [this message]
2013-10-15 17:58   ` [PATCH 1/3] kexec: Add debug printing of kimage table entries Joe Perches
2013-10-15 19:25   ` Eric W. Biederman
2013-10-15 20:03     ` Geert Uytterhoeven
2013-10-15 17:48 ` [PATCH 2/3] m68k: Add kexec support Geert Uytterhoeven
2013-10-15 17:48 ` [PATCH 3/3] m68k: Add support to export bootinfo in procfs Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1381859307-11932-2-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox