summaryrefslogtreecommitdiffstats
path: root/0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch
diff options
context:
space:
mode:
Diffstat (limited to '0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch')
-rw-r--r--0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch b/0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch
new file mode 100644
index 000000000..a69c6108c
--- /dev/null
+++ b/0004-efi-efi_memmap_insert-don-t-split-regions-with-inval.patch
@@ -0,0 +1,45 @@
+From 1c38760731eefdbd5e9ce288009d6d19afcff004 Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Wed, 7 Dec 2016 16:34:20 -0500
+Subject: [PATCH 4/4] efi: efi_memmap_insert(): don't split regions with
+ invalid sizes.
+
+Some machines, such as the Lenovo ThinkPad W541 with firmware GNET80WW
+(2.28), include memory map entries with phys_addr=0x0 and num_pages=0.
+
+If we're inserting a new memmap and we find a map that is either 0
+pages or all of possible memory (or more!), skip it. When a map exists
+at 0 that's 0 pages, the "end" math here winds up making *every* address
+within the range, and so it'll try to split that entry, and things go
+poorly after that. The same would be true if num_pages were (u64)-1LL
+(all bits set) or (u64)-1LL >> EFI_PAGE_SHIFT (i.e. all bits set as a
+size in bytes, but then shifted to page size to fill the table in).
+
+Don't even try to split those entries, they're nonsense.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ drivers/firmware/efi/memmap.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
+index 5b71c717..f8c6870 100644
+--- a/drivers/firmware/efi/memmap.c
++++ b/drivers/firmware/efi/memmap.c
+@@ -244,6 +244,13 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
+ /* copy original EFI memory descriptor */
+ memcpy(new, old, old_memmap->desc_size);
+ md = new;
++ if (md->num_pages == 0 ||
++ md->num_pages >= (((u64)-1LL) >> EFI_PAGE_SHIFT)) {
++ pr_warn("%s: Skipping absurd memory map entry for 0x%llx pages at 0x%016llx.\n",
++ __func__, md->num_pages, md->phys_addr);
++ continue;
++ }
++
+ start = md->phys_addr;
+ end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1;
+
+--
+2.9.3
+