mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernhard Walle <bwalle@suse.de>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, vgoyal@redhat.com,
	kexec@lists.infradead.org, yhlu.kernel@gmail.com,
	Bernhard Walle <bwalle@suse.de>
Subject: [PATCH 2/2] Use FIRMWARE_MEMMAP on x86/E820
Date: Wed, 25 Jun 2008 21:57:06 +0200	[thread overview]
Message-ID: <1214423826-12628-3-git-send-email-bwalle@suse.de> (raw)
In-Reply-To: <1214423826-12628-1-git-send-email-bwalle@suse.de>

This patch uses the /sys/firmware/memmap interface provided in the last patch
on the x86 architecture when E820 is used. The patch copies the E820
memory map very early, and registers the E820 map afterwards via
firmware_map_add_early().


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

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 3771386..14f5a83 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -19,6 +19,7 @@
 #include <linux/mm.h>
 #include <linux/pfn.h>
 #include <linux/suspend.h>
+#include <linux/firmware-map.h>
 
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -27,7 +28,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 for the
+ * /sys/firmware/memmap interface.
+ *
+ * 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;
@@ -1056,6 +1072,17 @@ void __init finish_e820_parsing(void)
 	}
 }
 
+static inline enum firmware_map_type firmware_map_type_from_e820(int e820_type)
+{
+	switch (e820_type) {
+	case E820_RAM:		return MAP_RAM;
+	case E820_ACPI:		return MAP_ACPI;
+	case E820_RESERVED:	return MAP_RESERVED;
+	case E820_NVS:		return MAP_NVS;
+	default:		return MAP_RESERVED;
+	}
+}
+
 /*
  * Mark e820 reserved areas as busy for the resource manager.
  */
@@ -1084,6 +1111,13 @@ void __init e820_reserve_resources(void)
 		insert_resource(&iomem_resource, res);
 		res++;
 	}
+
+	for (i = 0; i < e820_saved.nr_map; i++) {
+		struct e820entry *entry = &e820_saved.map[i];
+		firmware_map_add_early(entry->addr,
+			entry->addr + entry->size - 1,
+			firmware_map_type_from_e820(entry->type));
+	}
 }
 
 char *__init default_machine_specific_memory_setup(void)
@@ -1119,6 +1153,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 13a0a5f..607f940 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-25 19:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 19:57 x86: Add /sys/firmware/memmap Bernhard Walle
2008-06-25 19:57 ` [PATCH 1/2] " Bernhard Walle
2008-06-25 22:43   ` Vivek Goyal
2008-06-26  8:13     ` Mikael Pettersson
2008-06-26  8:45       ` Bernhard Walle
2008-06-26  9:11         ` Mikael Pettersson
2008-06-26 18:00           ` H. Peter Anvin
2008-06-26 18:18             ` Vivek Goyal
2008-06-26 19:18               ` H. Peter Anvin
2008-06-26 18:23             ` Bernhard Walle
2008-06-26 12:42       ` Vivek Goyal
2008-06-26  8:15     ` Bernhard Walle
2008-06-25 19:57 ` Bernhard Walle [this message]
2008-06-26  8:14 x86: " Bernhard Walle
2008-06-26  8:14 ` [PATCH 2/2] Use FIRMWARE_MEMMAP on x86/E820 Bernhard Walle
2008-06-26 20:19 x86: Add /sys/firmware/memmap Bernhard Walle
2008-06-26 20:19 ` [PATCH 2/2] Use FIRMWARE_MEMMAP on x86/E820 Bernhard Walle
2008-06-26 20:54   ` Yinghai Lu
2008-06-27 11:14     ` Bernhard Walle
2008-06-27 18:31       ` Yinghai Lu
2008-06-27 11:12 x86: Add /sys/firmware/memmap Bernhard Walle
2008-06-27 11:12 ` [PATCH 2/2] Use FIRMWARE_MEMMAP on x86/E820 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=1214423826-12628-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 \
    --cc=yhlu.kernel@gmail.com \
    /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®