xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	andrew.cooper3-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org,
	olaf-QOLJcTWqO2uzQB+pC5nmwQ@public.gmane.org,
	jbeulich-IBi9RG/b67k@public.gmane.org,
	ptesarik-AlSwsSmVLrQ@public.gmane.org,
	kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org
Subject: [PATCH 5/7] kexec: Get backup area start address and size directly from mem_range
Date: Mon, 10 Sep 2012 13:57:49 +0200	[thread overview]
Message-ID: <1347278271-5211-6-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1347278271-5211-5-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Get backup area start address and size directly from mem_range.
Under Xen /proc/iomem contains invalid values.

Signed-off-by: Daniel Kiper <daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 kexec/arch/i386/crashdump-x86.c |   55 +++++++++++++-------------------------
 1 files changed, 19 insertions(+), 36 deletions(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 77a1329..56ef59e 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -667,44 +667,28 @@ static int cmdline_add_memmap_acpi(char *cmdline, unsigned long start,
 	return 0;
 }
 
-static void get_backup_area(unsigned long *start, unsigned long *end)
+static void get_backup_area(struct kexec_info *info,
+				struct memory_range *range, int ranges)
 {
-	const char *iomem = proc_iomem();
-	char line[MAX_LINE];
-	FILE *fp;
+	int i;
 
-	fp = fopen(iomem, "r");
-	if (!fp) {
-		fprintf(stderr, "Cannot open %s: %s\n",
-			iomem, strerror(errno));
-		return;
-	}
+	/* Look for first 640 KiB RAM region. */
+	for (i = 0; i < ranges; ++i) {
+		if (range[i].type != RANGE_RAM || range[i].end > 0xa0000)
+			continue;
 
-	while(fgets(line, sizeof(line), fp) != 0) {
-		char *str;
-		int count, consumed;
-		unsigned long mstart, mend;
+		info->backup_src_start = range[i].start;
+		info->backup_src_size = range[i].end - range[i].start + 1;
 
-		count = sscanf(line, "%lx-%lx : %n",
-			&mstart, &mend, &consumed);
-		if (count != 2)
-			continue;
-		str = line + consumed;
-		dbgprintf("%016lx-%016lx : %s",
-			mstart, mend, str);
-
-		/* Hopefully there is only one RAM region in the first 640K */
-		if (memcmp(str, "System RAM\n", 11) == 0 && mend <= 0xa0000 ) {
-			dbgprintf("%s: %016lx-%016lx : %s", __func__, mstart, mend, str);
-			*start = mstart;
-			*end = mend;
-			fclose(fp);
-			return;
-		}
+		dbgprintf("%s: %016llx-%016llx : System RAM\n", __func__,
+						range[i].start, range[i].end);
+
+		return;
 	}
-	*start = BACKUP_SRC_START;
-	*end = BACKUP_SRC_END;
-	fclose(fp);
+
+	/* First 640 KiB RAM region not found. Assume defaults. */
+	info->backup_src_start = BACKUP_SRC_START;
+	info->backup_src_size = BACKUP_SRC_END - BACKUP_SRC_START + 1;
 }
 
 /* Loads additional segments in case of a panic kernel is being loaded.
@@ -720,15 +704,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	struct memory_range *mem_range, *memmap_p;
 	struct crash_elf_info elf_info;
 	unsigned kexec_arch;
-	unsigned long tmp_backup_end = 0;
 
 	memset(&elf_info, 0x0, sizeof(elf_info));
 
 	/* Constant parts of the elf_info */
 	memset(&elf_info, 0, sizeof(elf_info));
 	elf_info.data             = ELFDATA2LSB;
-	get_backup_area(&info->backup_src_start, &tmp_backup_end);
-	info->backup_src_size = tmp_backup_end - info->backup_src_start + 1;
 
 	/* Get the architecture of the running kernel */
 	kexec_arch = info->kexec_flags & KEXEC_ARCH_MASK;
@@ -756,6 +737,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 				    elf_info.lowmem_limit) < 0)
 		return -1;
 
+	get_backup_area(info, mem_range, nr_ranges);
+
 	/*
 	 * if the core type has not been set on command line, set it here
 	 * automatically
-- 
1.5.6.5

  parent reply	other threads:[~2012-09-10 11:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 11:57 [PATCH 0/7] kdump: Xen fixes Daniel Kiper
     [not found] ` <1347278271-5211-1-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57   ` [PATCH 1/7] kexec: Define some constants and structures conditionally Daniel Kiper
     [not found]     ` <1347278271-5211-2-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57       ` [PATCH 2/7] xen: Rename e820_to_kexec_type() to xen_e820_to_kexec_type() and export it Daniel Kiper
     [not found]         ` <1347278271-5211-3-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57           ` [PATCH 3/7] kexec: Move crash kernel area placement and size detection to is_crashkernel_mem_reserved() Daniel Kiper
     [not found]             ` <1347278271-5211-4-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57               ` [PATCH 4/7] kexec: Add segregate_lowmem_region() Daniel Kiper
     [not found]                 ` <1347278271-5211-5-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57                   ` Daniel Kiper [this message]
     [not found]                     ` <1347278271-5211-6-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57                       ` [PATCH 6/7] kexec: Move crash memory ranges logging Daniel Kiper
     [not found]                         ` <1347278271-5211-7-git-send-email-daniel.kiper-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-09-10 11:57                           ` [PATCH 7/7] xen: Fix Xen kdump support Daniel Kiper
2012-09-14  3:30 ` [PATCH 0/7] kdump: Xen fixes Simon Horman

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=1347278271-5211-6-git-send-email-daniel.kiper@oracle.com \
    --to=daniel.kiper-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=andrew.cooper3-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org \
    --cc=jbeulich-IBi9RG/b67k@public.gmane.org \
    --cc=kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=olaf-QOLJcTWqO2uzQB+pC5nmwQ@public.gmane.org \
    --cc=ptesarik-AlSwsSmVLrQ@public.gmane.org \
    --cc=xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.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;
as well as URLs for NNTP newsgroup(s).