From: Ingo Molnar <mingo@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>,
Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 18/50] x86/boot/e820: Rename e820_table_saved to e820_table_firmware and improve the description
Date: Sat, 28 Jan 2017 23:11:39 +0100 [thread overview]
Message-ID: <1485641531-22124-19-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1485641531-22124-1-git-send-email-mingo@kernel.org>
So the 'e820_table_saved' is a bit of a misnomer that hides its real purpose.
At first sight the name suggests that it's some sort save/restore mechanism,
as this is how we typically name such facilities in the kernel.
But that is not so, e820_table_saved is the original firmware version of the
e820 table, not modified by the kernel. This table is displayed in the
/sys/firmware/memmap file, and it's also used by the hibernation code to
calculate a physical memory layout MD5 fingerprint checksum which is
invariant of the kernel.
So rename it to 'e820_table_firmware' and update all the comments to better
describe the main e820 data strutures.
Also rename:
'initial_e820_table_saved' => 'e820_table_firmware_init'
'e820_update_range_saved' => 'e820_update_range_firmware'
... to better match the new nomenclature.
No change in functionality.
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Huang, Ying <ying.huang@intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Jackson <pj@sgi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/e820/api.h | 3 +--
arch/x86/kernel/e820.c | 78 +++++++++++++++++++++++++++++++++++++----------------------
arch/x86/kernel/kexec-bzimage64.c | 4 +--
arch/x86/kernel/setup.c | 4 +--
arch/x86/power/hibernate_64.c | 4 +--
5 files changed, 56 insertions(+), 37 deletions(-)
diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index 2a6de16ad9b5..2c336d8a8593 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -3,9 +3,8 @@
#include <asm/e820/types.h>
-/* see comment in arch/x86/kernel/e820.c */
extern struct e820_table *e820_table;
-extern struct e820_table *e820_table_saved;
+extern struct e820_table *e820_table_firmware;
extern unsigned long pci_mem_start;
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 7d12433ad056..86d6d823e47e 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -27,23 +27,43 @@
#include <asm/cpufeature.h>
/*
- * The e820 table is the array 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 firmware and bootloader passes us an E820 table that is the primary
+ * physical memory layout description available about x86 systems.
*
- * The e820_table_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.
+ * The kernel takes the e820 memory layout and optionally modifies it with
+ * quirks and other tweaks, and feeds that into the generic Linux memory
+ * allocation code routines via a platform independent interface (memblock, etc.).
*
- * 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.
+ * We organize the E820 table into two main data structures:
+ *
+ * - 'e820_table_firmware': the original firmware version passed to us by the
+ * bootloader - not modified by the kernel. We use this to:
+ *
+ * - inform the user about the firmware's notion of memory layout
+ * via /sys/firmware/memmap
+ *
+ * - the hibernation code uses it to generate a kernel-independent MD5
+ * fingerprint of the physical memory layout of a system.
+ *
+ * - kexec, which is a bootloader in disguise, uses the original e820
+ * layout to pass to the kexec-ed kernel. This way the original kernel
+ * can have a restricted e820 map while the kexec()-ed kexec-kernel
+ * can have access to full memory - etc.
+ *
+ * - 'e820_table': this is the main e820 table that is massaged by the
+ * low level x86 platform code, or modified by boot parameters, before
+ * passed on to higher level MM layers.
+ *
+ * Once the e820 map has been converted to the standard Linux memory layout
+ * information its role stops - modifying it has no effect and does not get
+ * re-propagated. So itsmain role is a temporary bootstrap storage of firmware
+ * specific memory layout data during early bootup.
*/
-static struct e820_table e820_table_init __initdata;
-static struct e820_table initial_e820_table_saved __initdata;
-struct e820_table *e820_table __refdata = &e820_table_init;
-struct e820_table *e820_table_saved __refdata = &initial_e820_table_saved;
+static struct e820_table e820_table_init __initdata;
+static struct e820_table e820_table_firmware_init __initdata;
+
+struct e820_table *e820_table __refdata = &e820_table_init;
+struct e820_table *e820_table_firmware __refdata = &e820_table_firmware_init;
/* For PCI or other memory-mapped resources */
unsigned long pci_mem_start = 0xaeedbabe;
@@ -497,10 +517,10 @@ u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
return __e820_update_range(e820_table, start, size, old_type, new_type);
}
-static u64 __init e820_update_range_saved(u64 start, u64 size,
+static u64 __init e820_update_range_firmware(u64 start, u64 size,
unsigned old_type, unsigned new_type)
{
- return __e820_update_range(e820_table_saved, start, size, old_type,
+ return __e820_update_range(e820_table_firmware, start, size, old_type,
new_type);
}
@@ -572,9 +592,9 @@ void __init update_e820(void)
printk(KERN_INFO "e820: modified physical RAM map:\n");
e820_print_map("modified");
}
-static void __init update_e820_table_saved(void)
+static void __init update_e820_table_firmware(void)
{
- sanitize_e820_table(e820_table_saved->entries, ARRAY_SIZE(e820_table_saved->entries), &e820_table_saved->nr_entries);
+ sanitize_e820_table(e820_table_firmware->entries, ARRAY_SIZE(e820_table_firmware->entries), &e820_table_firmware->nr_entries);
}
#define MAX_GAP_END 0x100000000ull
/*
@@ -648,7 +668,7 @@ __init void e820_setup_gap(void)
/*
* Called late during init, in free_initmem().
*
- * Initial e820 and e820_table_saved are largish __initdata arrays.
+ * Initial e820 and e820_table_firmware are largish __initdata arrays.
* Copy them to (usually much smaller) dynamically allocated area.
* This is done after all tweaks we ever do to them:
* all functions which modify them are __init functions,
@@ -665,11 +685,11 @@ __init void e820_reallocate_tables(void)
memcpy(n, e820_table, size);
e820_table = n;
- size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * e820_table_saved->nr_entries;
+ size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * e820_table_firmware->nr_entries;
n = kmalloc(size, GFP_KERNEL);
BUG_ON(!n);
- memcpy(n, e820_table_saved, size);
- e820_table_saved = n;
+ memcpy(n, e820_table_firmware, size);
+ e820_table_firmware = n;
}
/**
@@ -745,7 +765,7 @@ core_initcall(e820_mark_nvs_memory);
#endif
/*
- * pre allocated 4k and reserved it in memblock and e820_table_saved
+ * pre allocated 4k and reserved it in memblock and e820_table_firmware
*/
u64 __init early_reserve_e820(u64 size, u64 align)
{
@@ -753,9 +773,9 @@ u64 __init early_reserve_e820(u64 size, u64 align)
addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
if (addr) {
- e820_update_range_saved(addr, size, E820_RAM, E820_RESERVED);
- printk(KERN_INFO "e820: update e820_table_saved for early_reserve_e820\n");
- update_e820_table_saved();
+ e820_update_range_firmware(addr, size, E820_RAM, E820_RESERVED);
+ printk(KERN_INFO "e820: update e820_table_firmware for early_reserve_e820\n");
+ update_e820_table_firmware();
}
return addr;
@@ -1034,8 +1054,8 @@ void __init e820_reserve_resources(void)
res++;
}
- for (i = 0; i < e820_table_saved->nr_entries; i++) {
- struct e820_entry *entry = &e820_table_saved->entries[i];
+ for (i = 0; i < e820_table_firmware->nr_entries; i++) {
+ struct e820_entry *entry = &e820_table_firmware->entries[i];
firmware_map_add_early(entry->addr,
entry->addr + entry->size,
e820_type_to_string(entry->type));
@@ -1145,7 +1165,7 @@ void __init e820__memory_setup(void)
char *who;
who = x86_init.resources.memory_setup();
- memcpy(e820_table_saved, e820_table, sizeof(struct e820_table));
+ memcpy(e820_table_firmware, e820_table, sizeof(struct e820_table));
printk(KERN_INFO "e820: BIOS-provided physical RAM map:\n");
e820_print_map(who);
}
diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
index 3e5c995e1718..a8c9563557c9 100644
--- a/arch/x86/kernel/kexec-bzimage64.c
+++ b/arch/x86/kernel/kexec-bzimage64.c
@@ -100,14 +100,14 @@ static int setup_e820_entries(struct boot_params *params)
{
unsigned int nr_e820_entries;
- nr_e820_entries = e820_table_saved->nr_entries;
+ nr_e820_entries = e820_table_firmware->nr_entries;
/* TODO: Pass entries more than E820MAX in bootparams setup data */
if (nr_e820_entries > E820MAX)
nr_e820_entries = E820MAX;
params->e820_entries = nr_e820_entries;
- memcpy(¶ms->e820_table, &e820_table_saved->entries, nr_e820_entries*sizeof(struct e820_entry));
+ memcpy(¶ms->e820_table, &e820_table_firmware->entries, nr_e820_entries*sizeof(struct e820_entry));
return 0;
}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index a8d0e388b358..f905430d7b04 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -459,7 +459,7 @@ static void __init e820_reserve_setup_data(void)
}
sanitize_e820_table(e820_table->entries, ARRAY_SIZE(e820_table->entries), &e820_table->nr_entries);
- memcpy(e820_table_saved, e820_table, sizeof(struct e820_table));
+ memcpy(e820_table_firmware, e820_table, sizeof(struct e820_table));
printk(KERN_INFO "extended physical RAM map:\n");
e820_print_map("reserve setup_data");
}
@@ -1026,7 +1026,7 @@ void __init setup_arch(char **cmdline_p)
early_dump_pci_devices();
#endif
- /* update the e820_table_saved too */
+ /* update the e820_table_firmware too */
e820_reserve_setup_data();
finish_e820_parsing();
diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 1bfda425879c..053801b022dd 100644
--- a/arch/x86/power/hibernate_64.c
+++ b/arch/x86/power/hibernate_64.c
@@ -231,7 +231,7 @@ static int get_e820_md5(struct e820_table *table, void *buf)
static void hibernation_e820_save(void *buf)
{
- get_e820_md5(e820_table_saved, buf);
+ get_e820_md5(e820_table_firmware, buf);
}
static bool hibernation_e820_mismatch(void *buf)
@@ -244,7 +244,7 @@ static bool hibernation_e820_mismatch(void *buf)
if (!memcmp(result, buf, MD5_DIGEST_SIZE))
return false;
- ret = get_e820_md5(e820_table_saved, result);
+ ret = get_e820_md5(e820_table_firmware, result);
if (ret)
return true;
--
2.7.4
next prev parent reply other threads:[~2017-01-29 0:01 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-28 22:11 [PATCH 00/50] x86: Clean up and reorganize the E820 table handling code Ingo Molnar
2017-01-28 22:11 ` [PATCH 01/50] x86/boot/e820: Introduce arch/x86/include/asm/e820/types.h Ingo Molnar
2017-01-29 17:13 ` Sam Ravnborg
2017-01-30 7:58 ` Ingo Molnar
2017-01-31 5:41 ` Sam Ravnborg
2017-01-31 16:35 ` Ingo Molnar
2017-01-31 17:22 ` Sam Ravnborg
2017-01-31 18:00 ` Ingo Molnar
2017-01-31 18:04 ` Joe Perches
2017-01-31 19:17 ` Sam Ravnborg
2017-02-01 8:56 ` Ingo Molnar
2017-01-28 22:11 ` [PATCH 02/50] x86/boot/e820: Clean up and improve comments in asm/e820/types.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 03/50] x86/boot/e820: Move asm/e820.h to asm/e820/api.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 04/50] x86/boot/e820: Split minimal UAPI types out into uapi/asm/e820/types.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 05/50] x86/boot/e820: Clean up the E820_X_MAX definition Ingo Molnar
2017-01-28 22:11 ` [PATCH 06/50] x86/boot/e820: Remove spurious asm/e820/api.h inclusions Ingo Molnar
2017-01-28 22:11 ` [PATCH 07/50] x86/boot/e820: Remove assembly guard from asm/e820/types.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 08/50] x86/boot/e820: Clean up asm/e820/api.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 09/50] x86/boot/e820: Remove unnecessary __ASSEMBLY__ guard Ingo Molnar
2017-01-28 22:11 ` [PATCH 10/50] x86/boot/e820: Move HIGH_MEMORY define to asm/e820/types.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 11/50] x86/boot/e820: Rename the basic e820 data types to 'struct e820_entry' and 'struct e820_array' Ingo Molnar
2017-01-28 22:11 ` [PATCH 12/50] x86/boot/e820: Remove unnecessary #include <linux/ioport.h> from asm/e820/api.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 13/50] x86/boot/e820: Remove e820_mark_nosave_regions() definition uglies Ingo Molnar
2017-01-28 22:11 ` [PATCH 14/50] x86/boot/e820: Rename 'e820_map' variables to 'e820_array' Ingo Molnar
2017-01-28 22:11 ` [PATCH 15/50] x86/boot/e820: Rename everything to e820_table Ingo Molnar
2017-01-28 22:11 ` [PATCH 16/50] x86/boot/e820: Harmonize the 'struct e820_table' fields Ingo Molnar
2017-01-28 22:11 ` [PATCH 17/50] x86/boot/e820: Rename default_machine_specific_memory_setup() to e820__memory_setup_default() Ingo Molnar
2017-01-28 22:11 ` Ingo Molnar [this message]
2017-01-28 22:11 ` [PATCH 19/50] x86/boot/e820: Basic cleanup of e820.c Ingo Molnar
2017-01-28 22:11 ` [PATCH 20/50] x86/boot/e820: Rename memblock_x86_fill() to e820__memblock_setup() and improve the explanations Ingo Molnar
2017-01-28 22:11 ` [PATCH 21/50] x86/boot/e820: Consolidate 'struct e820_entry *entry' local variable names Ingo Molnar
2017-01-28 22:11 ` [PATCH 22/50] x86/boot/e820: Convert printk(KERN_* ...) to pr_*() Ingo Molnar
2017-01-28 22:59 ` Joe Perches
2017-01-28 22:11 ` [PATCH 23/50] x86/boot/e820: Move the memblock_find_dma_reserve() function and rename it to memblock_set_dma_reserve() Ingo Molnar
2017-01-28 22:11 ` [PATCH 24/50] x86/boot/e820: Rename parse_e820_ext() to e820__memory_setup_extended() Ingo Molnar
2017-01-28 22:11 ` [PATCH 25/50] x86/boot/e820: Move e820_reserve_setup_data() to e820.c Ingo Molnar
2017-01-28 22:11 ` [PATCH 26/50] x86/boot/e820: Clarify the role of finish_e820_parsing() and rename it to e820__finish_early_params() Ingo Molnar
2017-01-28 22:11 ` [PATCH 27/50] x86/boot/e820: Rename early_reserve_e820() to e820__memblock_alloc() and document it Ingo Molnar
2017-01-28 22:11 ` [PATCH 28/50] x86/boot/e820: Rename update_e820() to e820__update_table() Ingo Molnar
2017-01-28 22:11 ` [PATCH 29/50] x86/boot/e820: Rename sanitize_e820_table() " Ingo Molnar
2017-01-28 22:11 ` [PATCH 30/50] x86/boot/e820: Rename e820_any_mapped()/e820_all_mapped() to e820__mapped_any()/e820__mapped_all() Ingo Molnar
2017-01-28 22:11 ` [PATCH 31/50] x86/boot/e820: Rename e820_setup_gap() to e820__setup_pci_gap() Ingo Molnar
2017-01-28 22:11 ` [PATCH 32/50] x86/boot/e820: Create coherent API function names for E820 range operations Ingo Molnar
2017-01-28 22:11 ` [PATCH 33/50] x86/boot/e820: Rename e820_print_map() to e820__print_table() Ingo Molnar
2017-01-28 22:11 ` [PATCH 34/50] x86/boot/e820: Reorder the function prototypes in api.h Ingo Molnar
2017-01-28 22:11 ` [PATCH 35/50] x86/boot/e820: Simplify e820_reserve_resources() Ingo Molnar
2017-01-28 22:11 ` [PATCH 36/50] x86/boot/e820: Introduce 'enum e820_type' Ingo Molnar
2017-01-28 22:11 ` [PATCH 37/50] x86/boot/e820: Use 'enum e820_type' in 'struct e820_entry' Ingo Molnar
2017-01-28 23:07 ` Linus Torvalds
2017-01-29 9:19 ` Ingo Molnar
2017-01-29 12:38 ` [PATCH] x86/boot/e820: Separate the E820 ABI structures from the in-kernel structures Ingo Molnar
2017-01-29 18:53 ` [PATCH 37/50] x86/boot/e820: Use 'enum e820_type' in 'struct e820_entry' Linus Torvalds
2017-01-28 22:11 ` [PATCH 38/50] x86/boot/e820: Use 'enum e820_type' when handling the e820 region type Ingo Molnar
2017-01-28 22:12 ` [PATCH 39/50] x86/boot/e820: Prefix the E820_* type names with "E820_TYPE_" Ingo Molnar
2017-01-28 22:12 ` [PATCH 40/50] x86/boot/e820: Clean up the E820 table size define names Ingo Molnar
2017-01-28 22:12 ` [PATCH 41/50] x86/boot/e820: Clean up and standardize sizeof() uses Ingo Molnar
2017-01-28 22:12 ` [PATCH 42/50] xen, x86/boot/e820: Simplify Xen's xen_e820_table construct Ingo Molnar
2017-01-28 22:12 ` [PATCH 43/50] x86/boot/e820: Simplify the e820__update_table() interface Ingo Molnar
2017-01-28 22:12 ` [PATCH 44/50] x86/boot/e820: Clean up __e820__update_table() et al Ingo Molnar
2017-01-28 22:12 ` [PATCH 45/50] x86/boot/e820: Document e820__reserve_setup_data() Ingo Molnar
2017-01-28 22:12 ` [PATCH 46/50] x86/boot/e820: Use bool in query APIs Ingo Molnar
2017-01-28 22:12 ` [PATCH 47/50] x86/boot/e820: Rename e820_reserve_resources*() to e820__reserve_resources*() Ingo Molnar
2017-01-28 22:12 ` [PATCH 48/50] x86/boot/e820: Rename e820_mark_nosave_regions() to e820__register_nosave_regions() Ingo Molnar
2017-01-28 22:12 ` [PATCH 49/50] x86/boot/e820: Remove unnecessary #include's Ingo Molnar
2017-01-28 22:12 ` [PATCH 50/50] x86/boot/e820: Rename the remaining E820 APIs to the e820__*() prefix Ingo Molnar
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=1485641531-22124-19-git-send-email-mingo@kernel.org \
--to=mingo@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yinghai@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;
as well as URLs for NNTP newsgroup(s).