Skip to contentSkip to conversation

efi_loader: fix bug in efi_get_memory_map

PATCH Applied Rob Clark 3 participants 5 messages Jul 26, 2017 – Jul 28, 2017

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 efi_loader: fix bug in efi_get_memory_map

When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever.

---
 lib/efi_loader/efi_memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/efi_loader/efi_memory.c +2 -2
index f59e3ea327..9e079f1fa3 100644
@@ -407,11 +407,11 @@ efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
 
 	map_size = map_entries * sizeof(struct efi_mem_desc);
 
+	*memory_map_size = map_size;
+
 	if (provided_map_size < map_size)
 		return EFI_BUFFER_TOO_SMALL;
 
-	*memory_map_size = map_size;
-
 	if (descriptor_size)
 		*descriptor_size = sizeof(struct efi_mem_desc);
 
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/1 efi_loader: fix bug in efi_get_memory_map

Quoted 6 lines · Rob Clark

When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever.

The spec is actually very explicit about this case. It says in the EFI_BUFFER_TOO_SMALL case, we *have* to return the map size.

Alex

author
#2 lore raw

PATCH 1/1 efi_loader: fix bug in efi_get_memory_map

Quoted 9 lines · Alexander Graf
Quoted 6 lines · Rob Clark

When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever.

Quoted 6 lines
Quoted 1 line

The spec is actually very explicit about this case. It says in the EFI_BUFFER_TOO_SMALL case, we *have* to return the map size.

yes, that is what I fixed. We *weren't* returning the required buffer size before :-)

BR,
-R

#3 lore raw

PATCH 1/1 efi_loader: fix bug in efi_get_memory_map

Quoted 7 lines · On Mittwoch, 26. Juli 2017 22:25:29 CEST Rob Clark wrote:
Quoted 6 lines · Alexander Graf
Quoted 5 lines · Rob Clark

When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

The spec is actually very explicit about this case. It says in the EFI_BUFFER_TOO_SMALL case, we *have* to return the map size.

yes, that is what I fixed. We *weren't* returning the required buffer size before :-)

Sigh, yes, this was correct in the first 3 versions of the patch series, but unfortunately broken in v4 which was actually committed ...

See: https://lists.denx.de/pipermail/u-boot/2016-October/268766.html

Actually, the map_size variable is no longer needed, if you assign to *memory_map_size directly.

Anyway, this patch is:

Kind regards,

Stefan

#4 lore raw
In reply to Rob Clark
Quoted 6 lines

When booting shim -> fallback -> shim -> grub -> linux the memory map is a bit larger than the size linux passes in on the first call. But in the EFI_BUFFER_TOO_SMALL case we were not passing back the updated size to linux so it would loop forever.

Thanks, applied to efi-next

Alex