Skip to content

Commit 88e9a5b

Browse files
djbwtorvalds
authored andcommitted
efi/fake_mem: arrange for a resource entry per efi_fake_mem instance
In preparation for attaching a platform device per iomem resource teach the efi_fake_mem code to create an e820 entry per instance. Similar to E820_TYPE_PRAM, bypass merging resource when the e820 map is sanitized. Signed-off-by: Dan Williams <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Ben Skeggs <[email protected]> Cc: Brice Goglin <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Dave Jiang <[email protected]> Cc: David Airlie <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jeff Moyer <[email protected]> Cc: Jia He <[email protected]> Cc: Joao Martins <[email protected]> Cc: Jonathan Cameron <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Vishal Verma <[email protected]> Cc: Wei Yang <[email protected]> Cc: Will Deacon <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Bjorn Helgaas <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Hulk Robot <[email protected]> Cc: Jason Yan <[email protected]> Cc: "Jérôme Glisse" <[email protected]> Cc: Juergen Gross <[email protected]> Cc: kernel test robot <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Stefano Stabellini <[email protected]> Cc: Vivek Goyal <[email protected]> Link: https://lkml.kernel.org/r/159643096068.4062302.11590041070221681669.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3b0d310 commit 88e9a5b

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

arch/x86/kernel/e820.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,20 @@ static int __init cpcompare(const void *a, const void *b)
305305
return (ap->addr != ap->entry->addr) - (bp->addr != bp->entry->addr);
306306
}
307307

308+
static bool e820_nomerge(enum e820_type type)
309+
{
310+
/*
311+
* These types may indicate distinct platform ranges aligned to
312+
* numa node, protection domain, performance domain, or other
313+
* boundaries. Do not merge them.
314+
*/
315+
if (type == E820_TYPE_PRAM)
316+
return true;
317+
if (type == E820_TYPE_SOFT_RESERVED)
318+
return true;
319+
return false;
320+
}
321+
308322
int __init e820__update_table(struct e820_table *table)
309323
{
310324
struct e820_entry *entries = table->entries;
@@ -380,7 +394,7 @@ int __init e820__update_table(struct e820_table *table)
380394
}
381395

382396
/* Continue building up new map based on this information: */
383-
if (current_type != last_type || current_type == E820_TYPE_PRAM) {
397+
if (current_type != last_type || e820_nomerge(current_type)) {
384398
if (last_type != 0) {
385399
new_entries[new_nr_entries].size = change_point[chg_idx]->addr - last_addr;
386400
/* Move forward only if the new size was non-zero: */

drivers/firmware/efi/x86_fake_mem.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void __init efi_fake_memmap_early(void)
3838
m_start = mem->range.start;
3939
m_end = mem->range.end;
4040
for_each_efi_memory_desc(md) {
41-
u64 start, end;
41+
u64 start, end, size;
4242

4343
if (md->type != EFI_CONVENTIONAL_MEMORY)
4444
continue;
@@ -58,11 +58,17 @@ void __init efi_fake_memmap_early(void)
5858
*/
5959
start = max(start, m_start);
6060
end = min(end, m_end);
61+
size = end - start + 1;
6162

6263
if (end <= start)
6364
continue;
64-
e820__range_update(start, end - start + 1, E820_TYPE_RAM,
65-
E820_TYPE_SOFT_RESERVED);
65+
66+
/*
67+
* Ensure each efi_fake_mem instance results in
68+
* a unique e820 resource
69+
*/
70+
e820__range_remove(start, size, E820_TYPE_RAM, 1);
71+
e820__range_add(start, size, E820_TYPE_SOFT_RESERVED);
6672
e820__update_table(e820_table);
6773
}
6874
}

0 commit comments

Comments
 (0)