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>
This commit is contained in:

committed by
Matt Fleming

parent
4af9ed578a
commit
dadb57abc3
@@ -118,6 +118,15 @@ typedef struct {
|
||||
u32 imagesize;
|
||||
} efi_capsule_header_t;
|
||||
|
||||
struct efi_boot_memmap {
|
||||
efi_memory_desc_t **map;
|
||||
unsigned long *map_size;
|
||||
unsigned long *desc_size;
|
||||
u32 *desc_ver;
|
||||
unsigned long *key_ptr;
|
||||
unsigned long *buff_size;
|
||||
};
|
||||
|
||||
/*
|
||||
* EFI capsule flags
|
||||
*/
|
||||
@@ -1371,11 +1380,7 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
|
||||
efi_loaded_image_t *image, int *cmd_line_len);
|
||||
|
||||
efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
|
||||
efi_memory_desc_t **map,
|
||||
unsigned long *map_size,
|
||||
unsigned long *desc_size,
|
||||
u32 *desc_ver,
|
||||
unsigned long *key_ptr);
|
||||
struct efi_boot_memmap *map);
|
||||
|
||||
efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
|
||||
unsigned long size, unsigned long align,
|
||||
|
Reference in New Issue
Block a user