linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi: get_memory_map: add sufficient slack for memory descriptors
@ 2015-02-12  5:24 Ard Biesheuvel
  2015-02-12  8:21 ` Roy Franz
  2015-02-12 10:22 ` Mark Rutland
  0 siblings, 2 replies; 13+ messages in thread
From: Ard Biesheuvel @ 2015-02-12  5:24 UTC (permalink / raw)
  To: linux-arm-kernel

As it turns out, when allocating room for the UEFI memory map using
UEFI's AllocatePool (), it may result in two new memory map entries
being created, for instance, when using Tianocore's preallocated region
feature. For example, the following region

0x00005ead5000-0x00005ebfffff [Conventional Memory|   |  |  |  |   |WB|WT|WC|UC]

may be split like this

0x00005ead5000-0x00005eae2fff [Conventional Memory|   |  |  |  |   |WB|WT|WC|UC]
0x00005eae3000-0x00005eae4fff [Loader Data        |   |  |  |  |   |WB|WT|WC|UC]
0x00005eae5000-0x00005ebfffff [Conventional Memory|   |  |  |  |   |WB|WT|WC|UC]

if the preallocated Loader Data region was chosen to be right in the
middle of the original free space.

After patch d1a8d66b9177 ("efi/libstub: Call get_memory_map() to
obtain map and desc sizes"), this is not being dealt with correctly
anymore, as the existing logic to allocate room for a single additional
entry has become insufficient.

So instead, add room for two additional entries instead.

Fixes: d1a8d66b9177 ("efi/libstub: Call get_memory_map() to obtain map and desc sizes")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/libstub/efi-stub-helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index af5d63c7cc53..ca0b07ed3b14 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -84,10 +84,10 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
 		return EFI_LOAD_ERROR;
 
 	/*
-	 * Add an additional efi_memory_desc_t because we're doing an
-	 * allocation which may be in a new descriptor region.
+	 * Add room for two additional efi_memory_desc_t entries because we're
+	 * doing an allocation which may be in a new descriptor region.
 	 */
-	*map_size += *desc_size;
+	*map_size += *desc_size * 2;
 	status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
 				*map_size, (void **)&m);
 	if (status != EFI_SUCCESS)
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-02-13 16:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12  5:24 [PATCH] efi: get_memory_map: add sufficient slack for memory descriptors Ard Biesheuvel
2015-02-12  8:21 ` Roy Franz
2015-02-12 10:22 ` Mark Rutland
2015-02-12 10:39   ` Ard Biesheuvel
2015-02-12 10:56     ` Mark Rutland
2015-02-12 14:47     ` Matt Fleming
2015-02-12 14:56       ` Ard Biesheuvel
2015-02-12 15:16         ` Mark Rutland
2015-02-12 15:31           ` Ard Biesheuvel
2015-02-13 16:04             ` Matt Fleming
2015-02-13 16:23               ` Ard Biesheuvel
2015-02-13 16:34               ` Mark Rutland
2015-02-13 16:33             ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).