aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot
diff options
context:
space:
mode:
authorJeffrey Hugo <jhugo@codeaurora.org>2016-08-29 16:38:51 -0400
committerMatt Fleming <matt@codeblueprint.co.uk>2016-09-05 07:18:17 -0400
commitdadb57abc37499f565b23933dbf49b435c3ba8af (patch)
tree80721c262bfd0a51f3448b09d6a4b392701f2202 /arch/x86/boot
parent4af9ed578a50cd331a725322cfd9d555251ce788 (diff)
efi/libstub: Allocate headspace in efi_get_memory_map()
efi_get_memory_map() allocates a buffer to store the memory map that it retrieves. This buffer may need to be reused by the client after ExitBootServices() is called, at which point allocations are not longer permitted. To support this usecase, provide the allocated buffer size back to the client, and allocate some additional headroom to account for any reasonable growth in the map that is likely to happen between the call to efi_get_memory_map() and the client reusing the buffer. Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r--arch/x86/boot/compressed/eboot.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index ff574dad95cc..c5b7c7b4f0d7 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -1008,7 +1008,7 @@ static efi_status_t exit_boot(struct boot_params *boot_params,
1008 void *handle, bool is64) 1008 void *handle, bool is64)
1009{ 1009{
1010 struct efi_info *efi = &boot_params->efi_info; 1010 struct efi_info *efi = &boot_params->efi_info;
1011 unsigned long map_sz, key, desc_size; 1011 unsigned long map_sz, key, desc_size, buff_size;
1012 efi_memory_desc_t *mem_map; 1012 efi_memory_desc_t *mem_map;
1013 struct setup_data *e820ext; 1013 struct setup_data *e820ext;
1014 const char *signature; 1014 const char *signature;
@@ -1019,14 +1019,20 @@ static efi_status_t exit_boot(struct boot_params *boot_params,
1019 bool called_exit = false; 1019 bool called_exit = false;
1020 u8 nr_entries; 1020 u8 nr_entries;
1021 int i; 1021 int i;
1022 1022 struct efi_boot_memmap map;
1023 nr_desc = 0; 1023
1024 e820ext = NULL; 1024 nr_desc = 0;
1025 e820ext_size = 0; 1025 e820ext = NULL;
1026 e820ext_size = 0;
1027 map.map = &mem_map;
1028 map.map_size = &map_sz;
1029 map.desc_size = &desc_size;
1030 map.desc_ver = &desc_version;
1031 map.key_ptr = &key;
1032 map.buff_size = &buff_size;
1026 1033
1027get_map: 1034get_map:
1028 status = efi_get_memory_map(sys_table, &mem_map, &map_sz, &desc_size, 1035 status = efi_get_memory_map(sys_table, &map);
1029 &desc_version, &key);
1030 1036
1031 if (status != EFI_SUCCESS) 1037 if (status != EFI_SUCCESS)
1032 return status; 1038 return status;