[PATCH] efi: adjust virt_addr when splitting descriptors in efi_memmap_insert()
From: Omar Sandoval
Date: Thu Mar 09 2017 - 04:46:19 EST
When we split efi memory descriptors, we adjust the physical address but
not the virtual address it maps to. This leads to bogus memory mappings
later when these virtual addresses are used.
This fixes a kexec boot regression since 8e80632fb23f ("efi/esrt: Use
efi_mem_reserve() and avoid a kmalloc()"), although the bug was only
exposed by that commit.
Signed-off-by: Omar Sandoval <osandov@xxxxxx>
---
drivers/firmware/efi/memmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
index 78686443cb37..ca614db76faf 100644
--- a/drivers/firmware/efi/memmap.c
+++ b/drivers/firmware/efi/memmap.c
@@ -298,6 +298,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
memcpy(new, old, old_memmap->desc_size);
md = new;
md->phys_addr = m_end + 1;
+ md->virt_addr += md->phys_addr - start;
md->num_pages = (end - md->phys_addr + 1) >>
EFI_PAGE_SHIFT;
}
@@ -312,6 +313,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
md = new;
md->attribute |= m_attr;
md->phys_addr = m_start;
+ md->virt_addr += md->phys_addr - start;
md->num_pages = (m_end - m_start + 1) >>
EFI_PAGE_SHIFT;
/* last part */
@@ -319,6 +321,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
memcpy(new, old, old_memmap->desc_size);
md = new;
md->phys_addr = m_end + 1;
+ md->virt_addr += md->phys_addr - start;
md->num_pages = (end - m_end) >>
EFI_PAGE_SHIFT;
}
@@ -333,6 +336,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
memcpy(new, old, old_memmap->desc_size);
md = new;
md->phys_addr = m_start;
+ md->virt_addr += md->phys_addr - start;
md->num_pages = (end - md->phys_addr + 1) >>
EFI_PAGE_SHIFT;
md->attribute |= m_attr;
--
2.12.0
--3MwIy2ne0vdjdPXF--