diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-01-29 12:56:13 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-01-29 13:39:32 +0100 |
commit | 7410aa1ca377aa8c5ed340647b5228e7b5d0494a (patch) | |
tree | 385c54976772eac5e25c8de72682e722d6f2f6a2 /arch/x86/kernel | |
parent | x86/boot/e820: Fix and clean up e820_type switch() statements (diff) | |
download | linux-7410aa1ca377aa8c5ed340647b5228e7b5d0494a.tar.xz linux-7410aa1ca377aa8c5ed340647b5228e7b5d0494a.zip |
x86/boot/e820: Separate the E820 ABI structures from the in-kernel structures
Linus pointed out that relying on the compiler to pack structures with
enums is fragile not just for the kernel, but for external tooling as
well which might rely on our UAPI headers.
So separate the two from each other: introduce 'struct boot_e820_entry',
which is the boot protocol entry format.
This actually simplifies the code, as e820__update_table() is now never
called directly with boot protocol table entries - we can rely on
append_e820_table() and do a e820__update_table() call afterwards.
( This will allow further simplifications of __e820__update_table(),
but that will be done in a separate patch. )
This change also has the side effect of not modifying the bootparams structure
anymore - which might be useful for debugging. In theory we could even constify
the boot_params structure - at least from the E820 code's point of view.
Remove the uapi/asm/e820/types.h file, as it's not used anymore - all
kernel side E820 types are defined in asm/e820/types.h.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
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: 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>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/e820.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 20834a81854e..2da2f7238a72 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -366,9 +366,9 @@ int __init e820__update_table(struct e820_table *table) return __e820__update_table(table->entries, ARRAY_SIZE(table->entries), &table->nr_entries); } -static int __init __append_e820_table(struct e820_entry *entries, u32 nr_entries) +static int __init __append_e820_table(struct boot_e820_entry *entries, u32 nr_entries) { - struct e820_entry *entry = entries; + struct boot_e820_entry *entry = entries; while (nr_entries) { u64 start = entry->addr; @@ -397,7 +397,7 @@ static int __init __append_e820_table(struct e820_entry *entries, u32 nr_entries * will have given us a memory map that we can use to properly * set up memory. If we aren't, we'll fake a memory map. */ -static int __init append_e820_table(struct e820_entry *entries, u32 nr_entries) +static int __init append_e820_table(struct boot_e820_entry *entries, u32 nr_entries) { /* Only one memory region (or negative)? Ignore it */ if (nr_entries < 2) @@ -668,12 +668,12 @@ __init void e820__reallocate_tables(void) void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len) { int entries; - struct e820_entry *extmap; + struct boot_e820_entry *extmap; struct setup_data *sdata; sdata = early_memremap(phys_addr, data_len); entries = sdata->len / sizeof(*extmap); - extmap = (struct e820_entry *)(sdata->data); + extmap = (struct boot_e820_entry *)(sdata->data); __append_e820_table(extmap, entries); e820__update_table(e820_table); @@ -1140,7 +1140,6 @@ void __init e820__reserve_resources_late(void) char *__init e820__memory_setup_default(void) { char *who = "BIOS-e820"; - u32 new_nr; /* * Try to copy the BIOS-supplied E820-map. @@ -1148,10 +1147,6 @@ char *__init e820__memory_setup_default(void) * Otherwise fake a memory map; one section from 0k->640k, * the next section from 1mb->appropriate_mem_k */ - new_nr = boot_params.e820_entries; - __e820__update_table(boot_params.e820_table, ARRAY_SIZE(boot_params.e820_table), &new_nr); - boot_params.e820_entries = new_nr; - if (append_e820_table(boot_params.e820_table, boot_params.e820_entries) < 0) { u64 mem_size; @@ -1169,6 +1164,9 @@ char *__init e820__memory_setup_default(void) e820__range_add(HIGH_MEMORY, mem_size << 10, E820_TYPE_RAM); } + /* We just appended a lot of ranges, sanitize the table: */ + e820__update_table(e820_table); + return who; } @@ -1182,7 +1180,7 @@ void __init e820__memory_setup(void) char *who; /* This is a firmware interface ABI - make sure we don't break it: */ - BUILD_BUG_ON(sizeof(struct e820_entry) != 20); + BUILD_BUG_ON(sizeof(struct boot_e820_entry) != 20); who = x86_init.resources.memory_setup(); |