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