EFI memory allocation

Simon Glass sjg at chromium.org
Sun Dec 3 18:44:05 CET 2023


Hi Heinrich, Ilias,

I had a bit of a look at how memory is allocated in EFI.

I see that efi_memory_init() is called quite early in U-Boot. It
sometimes allocates memory for a bounce buffer, placing it somewhere
in memory. How do we know that that memory is free and not being used
by U-Boot?

To answer my own question, it excludes U-Boot's malloc() region from
the map, so that it cannot overwrite that.

But then, what if we use lmb and start loading images into memory.
Won't that conflict with EFI?

I also see that efi_allocate_pages() is called to allocate memory in
the EFI code. But this just grabs memory from 'anywhere'...it doesn't
respect the U-Boot malloc region.

It seems to me that most of the memory allocation in EFI should be
done using malloc(). Of course the boot services need to
efi_allocate_pages(), etc., but I am not sure that the internal tables
should be skipping malloc()?

What do you think?

Regards,
Simon


More information about the U-Boot mailing list