[PATCH v4 05/27] lmb: make LMB memory map persistent and global

Vaishnav Achath vaishnav.a at ti.com
Mon Sep 16 08:04:03 CEST 2024


Hi Sughosh

On 26/08/24 17:29, Sughosh Ganu wrote:
> The current LMB API's for allocating and reserving memory use a
> per-caller based memory view. Memory allocated by a caller can then be
> overwritten by another caller. Make these allocations and reservations
> persistent using the alloced list data structure.
> 
> Two alloced lists are declared -- one for the available(free) memory,
> and one for the used memory. Once full, the list can then be extended
> at runtime.
> 
> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> [sjg: Optimise the logic to add a region in lmb_add_region_flags()]
> [sjg: Use a stack to store pointer of lmb struct when running lmb tests]
> ---
> Changes since V3:
> * Fix checkpatch warnings of spaces between function name and
>    open parantheses.
> * s/uint64_t/u64 as suggested by checkpatch.
> * Remove unneccessary parantheses in lmb.c as suggested by checkpatch.
> * Fix alignment in test/cmd/bdinfo.c as suggested by checkpatch.
> 
>   arch/arc/lib/cache.c                 |   4 +-
>   arch/arm/lib/stack.c                 |   4 +-
>   arch/arm/mach-apple/board.c          |  17 +-
>   arch/arm/mach-snapdragon/board.c     |  17 +-
>   arch/arm/mach-stm32mp/dram_init.c    |   8 +-
>   arch/arm/mach-stm32mp/stm32mp1/cpu.c |   6 +-
>   arch/m68k/lib/bootm.c                |   7 +-
>   arch/microblaze/lib/bootm.c          |   4 +-
>   arch/mips/lib/bootm.c                |  11 +-
>   arch/nios2/lib/bootm.c               |   4 +-
>   arch/powerpc/cpu/mpc85xx/mp.c        |   4 +-
>   arch/powerpc/include/asm/mp.h        |   4 +-
>   arch/powerpc/lib/bootm.c             |  14 +-
>   arch/riscv/lib/bootm.c               |   4 +-
>   arch/sh/lib/bootm.c                  |   4 +-
>   arch/x86/lib/bootm.c                 |   4 +-
>   arch/xtensa/lib/bootm.c              |   4 +-
>   board/xilinx/common/board.c          |   8 +-
>   boot/bootm.c                         |  26 +-
>   boot/bootm_os.c                      |   5 +-
>   boot/image-board.c                   |  34 +-
>   boot/image-fdt.c                     |  35 +-
>   cmd/bdinfo.c                         |   6 +-
>   cmd/booti.c                          |   2 +-
>   cmd/bootz.c                          |   2 +-
>   cmd/elf.c                            |   2 +-
>   cmd/load.c                           |   7 +-
>   drivers/iommu/apple_dart.c           |   8 +-
>   drivers/iommu/sandbox_iommu.c        |  16 +-
>   fs/fs.c                              |   7 +-

In fs the reserved region is not being freed after read, while
other loaders free them (cmd/load.c), this patch uncovers the issue
since now other loaders cannot use the same memory location for load.
For example now someone cannot do:

mmc load .. $loadaddr ...
<do something with above contents>
tftp $loadaddr ..

where this worked previously since it was not global, I have sent a
fix for this :
https://lore.kernel.org/all/20240916054038.2125910-1-vaishnav.a@ti.com/

Thanks and Regards,
Vaishnav

>   include/image.h                      |  28 +-
>   include/lmb.h                        | 111 ++----
>   lib/efi_loader/efi_dt_fixup.c        |   2 +-
>   lib/efi_loader/efi_helper.c          |   2 +-
>   lib/lmb.c                            | 446 +++++++++++++---------
>   net/tftp.c                           |   5 +-
>   net/wget.c                           |   5 +-
>   test/cmd/bdinfo.c                    |  41 +-
>   test/lib/lmb.c                       | 542 +++++++++++++--------------
>   39 files changed, 714 insertions(+), 746 deletions(-)
> 



More information about the U-Boot mailing list