Skip to content
Snippets Groups Projects
Commit cee752fa authored by Alexander Graf's avatar Alexander Graf Committed by Tom Rini
Browse files

efi_loader: Expose ascending efi memory map


The EFI memory map does not need to be in a strict order, but 32bit
grub2 does expect it to be ascending. If it's not, it may try to
allocate memory inside the U-Boot data memory region.

We already sort the memory map in descending order, so let's just
reverse it when we pass it to a payload.

Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
Tested-by: default avatarAndreas Färber <afaerber@suse.de>
parent ad0c1a3d
Branches
Tags
No related merge requests found
...@@ -286,10 +286,13 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, ...@@ -286,10 +286,13 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
uint32_t *descriptor_version) uint32_t *descriptor_version)
{ {
ulong map_size = 0; ulong map_size = 0;
int map_entries = 0;
struct list_head *lhandle; struct list_head *lhandle;
list_for_each(lhandle, &efi_mem) list_for_each(lhandle, &efi_mem)
map_size += sizeof(struct efi_mem_desc); map_entries++;
map_size = map_entries * sizeof(struct efi_mem_desc);
*memory_map_size = map_size; *memory_map_size = map_size;
...@@ -301,12 +304,14 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size, ...@@ -301,12 +304,14 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
/* Copy list into array */ /* Copy list into array */
if (memory_map) { if (memory_map) {
/* Return the list in ascending order */
memory_map = &memory_map[map_entries - 1];
list_for_each(lhandle, &efi_mem) { list_for_each(lhandle, &efi_mem) {
struct efi_mem_list *lmem; struct efi_mem_list *lmem;
lmem = list_entry(lhandle, struct efi_mem_list, link); lmem = list_entry(lhandle, struct efi_mem_list, link);
*memory_map = lmem->desc; *memory_map = lmem->desc;
memory_map++; memory_map--;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment