Skip to content

Commit

Permalink
efi_loader: get_memory_map: return parameters whenever possible
Browse files Browse the repository at this point in the history
Currently, if GetMemoryMap API returns EFI_BUFFER_TOO_SMALL, it doesn't
set valid values to other parameters, descriptor_size and
descriptor_version, except memory_map_size.
Some efi applications, however, may use those value; in particular,
xen uses descriptor_size to calculate a size of buffer to be allocated.

While UEFI specification is ambiguous in this point, it would be better
to address this issue proactively to maximize the compatibility with
existing efi applications.

With this patch, for example, xen.efi (and hence linux kernel) can be
started via bootefi without modification.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
  • Loading branch information
AKASHI Takahiro authored and xypron committed Mar 11, 2020
1 parent db41d98 commit b484296
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/efi_loader/efi_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,18 +627,18 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,

*memory_map_size = map_size;

if (provided_map_size < map_size)
return EFI_BUFFER_TOO_SMALL;

if (!memory_map)
return EFI_INVALID_PARAMETER;

if (descriptor_size)
*descriptor_size = sizeof(struct efi_mem_desc);

if (descriptor_version)
*descriptor_version = EFI_MEMORY_DESCRIPTOR_VERSION;

if (provided_map_size < map_size)
return EFI_BUFFER_TOO_SMALL;

if (!memory_map)
return EFI_INVALID_PARAMETER;

/* Copy list into array */
/* Return the list in ascending order */
memory_map = &memory_map[map_entries - 1];
Expand Down

0 comments on commit b484296

Please sign in to comment.