Re: [U-Boot] [PATCH 2/2] efi_loader: Expose ascending efi memory map

2016-04-13 Thread Andreas Färber
Am 11.04.2016 um 23:51 schrieb Alexander Graf:
> 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: Alexander Graf 

Tested-by: Andreas Färber 

This fixed clearfog for me.

Thanks,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] efi_loader: Expose ascending efi memory map

2016-04-11 Thread Alexander Graf
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: Alexander Graf 
---
 lib/efi_loader/efi_memory.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 8a1e249..df99585 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -286,10 +286,13 @@ efi_status_t efi_get_memory_map(unsigned long 
*memory_map_size,
   uint32_t *descriptor_version)
 {
ulong map_size = 0;
+   int map_entries = 0;
struct list_head *lhandle;
 
list_for_each(lhandle, _mem)
-   map_size += sizeof(struct efi_mem_desc);
+   map_entries++;
+
+   map_size = map_entries * sizeof(struct efi_mem_desc);
 
*memory_map_size = map_size;
 
@@ -301,12 +304,14 @@ efi_status_t efi_get_memory_map(unsigned long 
*memory_map_size,
 
/* Copy list into array */
if (memory_map) {
+   /* Return the list in ascending order */
+   memory_map = _map[map_entries - 1];
list_for_each(lhandle, _mem) {
struct efi_mem_list *lmem;
 
lmem = list_entry(lhandle, struct efi_mem_list, link);
*memory_map = lmem->desc;
-   memory_map++;
+   memory_map--;
}
}
 
-- 
1.8.5.6

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot