mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernhard Walle <bwalle@suse.de>
To: kexec@lists.infradead.org
Cc: x86@kernel.org, linux-kernel@vger.kernel.org, vgoyal@redhat.com,
	Bernhard Walle <bwalle@suse.de>
Subject: [PATCH 2/3] Use /proc/firmware_mem for x86 (e820)
Date: Fri, 20 Jun 2008 17:56:59 +0200	[thread overview]
Message-ID: <1213977420-1555-3-git-send-email-bwalle@suse.de> (raw)
In-Reply-To: <1213977420-1555-1-git-send-email-bwalle@suse.de>

This patch copies the E820 map very early, before the kernel applies various
operations. That copy is used later to register only the BIOS-provided E820
map later in the resource tree for /proc/firmware_mem.


Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
 arch/x86/kernel/e820.c |   44 ++++++++++++++++++++++++++++++++++----------
 include/asm-x86/e820.h |    2 ++
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 7b613d2..f5b1736 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -27,7 +27,22 @@
 #include <asm/setup.h>
 #include <asm/trampoline.h>
 
+/*
+ * The e820 map is the map that gets modified e.g. with command line parameters
+ * and that is also registered with modifications in the kernel resource tree
+ * with the iomem_resource as parent.
+ *
+ * The e820_saved is directly saved after the BIOS-provided memory map is
+ * copied. It doesn't get modified afterwards. It's registered in the
+ * resource system of the kernel with firmware_mem_resource as parent.
+ *
+ * That memory map is not modified and is used as base for kexec. The kexec'd
+ * kernel should get the same memory map as the firmware provides. Then the
+ * user can e.g. boot the original kernel with mem=1G while still booting the
+ * next kernel with full memory.
+ */
 struct e820map e820;
+struct e820map e820_saved;
 
 /* For PCI or other memory-mapped resources */
 unsigned long pci_mem_start = 0xaeedbabe;
@@ -999,24 +1014,22 @@ void __init finish_e820_parsing(void)
 	}
 }
 
-/*
- * Mark e820 reserved areas as busy for the resource manager.
- */
-void __init e820_reserve_resources(void)
+static void __init e820_reserve_resources_map(struct e820map  *map,
+					      struct resource *root)
 {
 	int i;
 	struct resource *res;
 
-	res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map);
-	for (i = 0; i < e820.nr_map; i++) {
-		switch (e820.map[i].type) {
+	res = alloc_bootmem_low(sizeof(struct resource) * map->nr_map);
+	for (i = 0; i < map->nr_map; i++) {
+		switch (map->map[i].type) {
 		case E820_RAM:	res->name = "System RAM"; break;
 		case E820_ACPI:	res->name = "ACPI Tables"; break;
 		case E820_NVS:	res->name = "ACPI Non-volatile Storage"; break;
 		default:	res->name = "reserved";
 		}
-		res->start = e820.map[i].addr;
-		res->end = res->start + e820.map[i].size - 1;
+		res->start = map->map[i].addr;
+		res->end = res->start + map->map[i].size - 1;
 #ifndef CONFIG_RESOURCES_64BIT
 		if (res->end > 0x100000000ULL) {
 			res++;
@@ -1024,11 +1037,20 @@ void __init e820_reserve_resources(void)
 		}
 #endif
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		insert_resource(&iomem_resource, res);
+		insert_resource(root, res);
 		res++;
 	}
 }
 
+/*
+ * Mark e820 reserved areas as busy for the resource manager.
+ */
+void __init e820_reserve_resources(void)
+{
+	e820_reserve_resources_map(&e820, &iomem_resource);
+	e820_reserve_resources_map(&e820_saved, &firmware_mem_resource);
+}
+
 char *__init default_machine_specific_memory_setup(void)
 {
 	char *who = "BIOS-e820";
@@ -1062,6 +1084,8 @@ char *__init default_machine_specific_memory_setup(void)
 		e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
 	}
 
+	memcpy(&e820_saved, &e820, sizeof(struct e820map));
+
 	/* In case someone cares... */
 	return who;
 }
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h
index 668a0d7..48e7181 100644
--- a/include/asm-x86/e820.h
+++ b/include/asm-x86/e820.h
@@ -56,7 +56,9 @@ struct e820map {
 	struct e820entry map[E820_X_MAX];
 };
 
+/* see comment in arch/x86/kernel/e820.c */
 extern struct e820map e820;
+extern struct e820map e820_saved;
 
 extern int e820_any_mapped(u64 start, u64 end, unsigned type);
 extern int e820_all_mapped(u64 start, u64 end, unsigned type);
-- 
1.5.4.5


  parent reply	other threads:[~2008-06-20 15:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 15:56 Introduce userspace interface for Firmware-provided memory map Bernhard Walle
2008-06-20 15:56 ` [PATCH 1/3] Introduce /proc/firmware_mem Bernhard Walle
2008-06-20 15:56 ` Bernhard Walle [this message]
2008-06-24 18:28   ` [PATCH 2/3] Use /proc/firmware_mem for x86 (e820) Pavel Machek
2008-06-26  8:21     ` Bernhard Walle
2008-06-20 15:57 ` [PATCH 3/3] Limit E820 map when a user-defined memory map is specified Bernhard Walle
2008-06-20 19:45   ` Vivek Goyal
2008-06-20 20:34   ` Yinghai Lu
2008-06-22 19:46     ` Bernhard Walle
2008-06-22 19:56     ` Bernhard Walle
2008-06-22 20:11       ` Yinghai Lu
2008-06-24 14:07         ` Bernhard Walle
2008-06-20 15:58 ` Introduce userspace interface for Firmware-provided memory map Bernhard Walle
2008-06-20 19:42 ` Vivek Goyal
2008-06-20 20:35   ` H. Peter Anvin
2008-06-22 19:59     ` Bernhard Walle

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=1213977420-1555-3-git-send-email-bwalle@suse.de \
    --to=bwalle@suse.de \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®