There are a couple of places in the sys/boot/efi tree that calls `BS->GetMemoryMap`. There appears to be a problem with the way it's called though, due to a corner case. In some cases, allocating the memory requires to store the memory map can cause the map to become fragmented; this means a _second_ call to `BS->GetMemoryMap` can also return EFI_BUFFER_TOO_SMALL. One workaround is to call it in a loop (with a max of, say 10 times) until the memory needed to store the map doesn't change.
I saw this occur today on my MinnowBoard Turbot running firmware 1.0 X64 DEBUG, after doing some work in the shell before running fs2:\efi\boot\bootx64.efi : Loading kernel... /boot/kernel/kernel text=0x16d3d96 data=0x1d58e8+0x819650 syms=[0x8+0x182358+0x8+0x19f7dd] Loading configured modules... can't find '/boot/entropy' Start @ 0xffffffff8036d000 ... bi_load_efi_data: GetMemoryMap error 5 Error 5 means the buffer was too small.
Getting the same "GetMemoryMap error 5" on boot with Asus H81M-K motherboard, EFI version 2.31, EFI firmware: American Megatrends 4.654. Also see bug #235714
Fixed in r344839 (https://svnweb.freebsd.org/base?view=revision&revision=344839). I'll MFC it to 11.x and 12.x in the coming weeks.