[PATCH v2 0/3] efi: Start tidying up memory management

Simon Glass sjg at chromium.org
Thu Aug 1 19:36:34 CEST 2024


We have been discussing the state of EFI memory management for some
years so I thought it might be best to send a short series showing some
of the issues we have talked about.

This one just deals with memory allocation. It updates EFI to use
U-Boot memory allocation for the pool where possible. Most functions use
that anyway and it is much more efficient. It also avoids allocating
things 'in space' in conflict with the loaded images.

For v2 I have dropped patches which are not germane to the main idea.

Note that this series is independent from Sugosh's lmb series[1],
although I believe it will point the way to simplifying some of the
later patches in that series.

Overall, some issues which should be resolved in future are:
- allocation inconsistency, e.g. efi_add_protocol() uses malloc() but
  efi_dp_dup() does not (this series makes a start)
- change efi_bl_init() to register events later, when the devices are
  actually used
- rather than efi_set_bootdev(), provide a bootstd way to take note of
  the device images came from and allow EFI to query that when needed
- EFI_LOADER_BOUNCE_BUFFER - can use U-Boot bounce buffers?

Minor questions on my mind:
- is unaligned access useful? Is there a performance penalty?
- API confusion about whether something is an address or a pointer

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=416441

Changes in v2:
- Drop patch 'Show more information in efi index'
- Drop patch 'Avoid pool allocation in efi_get_memory_map_alloc()'
- Add the word 'warning', use log_warning() and show the end address
- Reorder patches a little

Simon Glass (3):
  efi: Allow use of malloc() for the EFI pool
  efi: Convert device_path allocation to use malloc()
  efi: Show the location of the bounce buffer

 common/dlmalloc.c                        |   7 ++
 include/efi_loader.h                     |  18 ++++
 include/malloc.h                         |   7 ++
 lib/efi_loader/efi_bootbin.c             |  11 +++
 lib/efi_loader/efi_device_path.c         |  43 +++++----
 lib/efi_loader/efi_device_path_to_text.c |   2 +-
 lib/efi_loader/efi_memory.c              | 110 +++++++++++++++++------
 7 files changed, 148 insertions(+), 50 deletions(-)

-- 
2.34.1



More information about the U-Boot mailing list