u-boot/boot
Sam Protsenko 5a6aa7d591 boot: fdt: Handle already reserved memory in boot_fdt_reserve_region()
The boot_fdt_add_mem_rsv_regions() function can be called twice, e.g.
first time during the board init (as a part of LMB init), and then when
booting the OS with 'booti' command:

    lmb_add_region_flags
    lmb_reserve_flags
    boot_fdt_reserve_region
    boot_fdt_add_mem_rsv_regions
               ^
               |
               +-----------------------+
               | (1)                   | (2)
    lmb_reserve_common        image_setup_linux
    lmb_init                  ...
    initr_lmb                 do_booti
    board_init_r              'booti'

That consequently leads to the attempt of reserving the same memory
areas (described in the 'reserved-memory' dts node) in LMB. The
lmb_add_region_flags() returns -EEXIST error code in such cases, but
boot_fdt_reserve_region() handles all negative error codes as a failure
to reserve fdt memory region, printing corresponding error messages,
which are essentially harmless, but misleading. For example, this is the
output of 'booti' command on E850-96 board:

    => booti $loadaddr - $fdtaddr
    ...
    ERROR: reserving fdt memory region failed
           (addr=bab00000 size=5500000 flags=2)
    ERROR: reserving fdt memory region failed
           (addr=f0000000 size=200000 flags=4)
    ...
    Starting kernel ...

The mentioned false positive error messages are observed starting with
commit 1d9aa4a283 ("lmb: Fix the allocation of overlapping memory
areas with !LMB_NONE"), which removes the check for the already added
memory regions in lmb_add_region_flags(), making it return -1 for
!LMB_NONE cases. Another commit 827dee587b ("fdt: lmb: add reserved
regions as no-overwrite") changes flags used for reserving memory in
boot_fdt_add_mem_rsv_regions() from LMB_NONE to LMB_NOOVERWRITE. So
together with the patch mentioned earlier, it makes
lmb_add_region_flags() return -1 when called from
boot_fdt_reserve_region().

Since then, the different patch was implemented, returning -EEXIST error
code in described cases, which is:

   lmb: Return -EEXIST in lmb_add_region_flags() if region already added

Handle -EEXIST error code as a normal (successful) case in
lmb_reserve_flags() and don't print any messages.

Fixes: 1d9aa4a283 ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
2024-12-12 09:20:32 -06:00
..
android_ab.c common: android_ab: fix slot suffix for abc block 2024-10-24 09:45:55 +02:00
boot_fit.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
bootdev-uclass.c bootstd: Avoid calling unavailable block functions 2024-10-18 14:10:22 -06:00
bootflow_internal.h bootstd: Support creating a boot menu 2023-01-16 18:26:50 -05:00
bootflow_menu.c boot: bootflow_menu: fix crash for EFI BOOTMGR global bootmeth 2024-06-20 11:41:43 -06:00
bootflow.c serial: serial_pl01x: Implement .getinfo() for PL01 2024-10-27 17:24:12 -06:00
bootm_os.c lmb: make LMB memory map persistent and global 2024-09-03 14:08:50 -06:00
bootm.c bootm: adjust the print format 2024-10-02 13:32:56 -06:00
bootmeth_android.c bootstd: android: Add U-Boot version to cmdline 2024-10-01 10:57:05 +02:00
bootmeth_android.h bootstd: Add a bootmeth for Android 2024-07-18 13:51:30 -06:00
bootmeth_cros.c bootstd: cros: store partition type in an efi_guid_t 2024-07-16 17:09:33 -06:00
bootmeth_cros.h bootstd: cros: Bring in some ChromiumOS structures 2023-08-10 18:34:54 -06:00
bootmeth_efi_mgr.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
bootmeth_efi.c efi_loader: Move get_efi_pxe_arch() to efi_helper 2024-11-09 10:01:46 +01:00
bootmeth_extlinux.c boot: extlinux: Fix unaligned buffer for reading data from file system 2024-11-18 08:23:56 -06:00
bootmeth_pxe.c boot: Add logic to enable booting from fallback option 2024-10-15 10:24:27 -06:00
bootmeth_qfw.c doc: Add a description for bootmeth_qfw 2024-07-19 13:54:54 +02:00
bootmeth_sandbox.c doc: Add a description for bootmeth_sandbox 2024-07-19 13:57:44 +02:00
bootmeth_script.c bootstd: Correct handling of script from network 2024-07-19 13:57:50 +02:00
bootmeth-uclass.c bootstd: Add command to enable setting of bootmeth specific properties 2024-10-15 10:24:27 -06:00
bootretry.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
bootstd-uclass.c boot: typo boormethod 2024-10-09 22:04:56 -06:00
cedit.c boot: cedit: include u-boot/schedule.h 2024-10-23 06:52:38 +02:00
common_fit.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
expo_build_cb.c x86: coreboot: Allow building an expo for editing CMOS config 2024-11-03 21:27:12 -06:00
expo_build.c expo: Drop scene_title_set() 2024-10-18 14:10:22 -06:00
expo.c expo: Use standard numbering for save and discard 2024-10-18 14:10:22 -06:00
fdt_region.c doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
fdt_simplefb.c boot: fdt_simplefb: Remove conditional compilation checks for VIDEO Kconfig 2024-10-22 19:54:08 +02:00
fdt_support.c Merge patch series "automatically add /chosen/kaslr-seed and deduplicate code" 2024-06-28 17:31:28 -06:00
image-android-dt.c global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD 2024-10-11 11:44:48 -06:00
image-android.c image: android: handle ramdisk default address 2024-10-24 09:48:14 +02:00
image-board.c boot/image-board.c: boot_get_fpga(): pass compatible flag to fpga_load() 2024-11-15 14:32:47 +01:00
image-cipher.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
image-fdt.c boot: fdt: Handle already reserved memory in boot_fdt_reserve_region() 2024-12-12 09:20:32 -06:00
image-fit-sig.c image-fit-sig: Remove padding check 2024-10-21 17:52:52 -06:00
image-fit.c spl: Plumb in the Universal Payload handoff 2024-08-09 16:03:20 -06:00
image-host.c Create a new boot/ directory 2021-11-11 19:01:56 -05:00
image-pre-load.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
image-sig.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
image.c cmd: bootm: add ELF file support 2024-07-05 13:57:02 -06:00
Kconfig boot/Kconfig: correct fdt_fixup_memory_banks name typo 2024-10-30 13:03:54 -06:00
Makefile x86: coreboot: Allow building an expo for editing CMOS config 2024-11-03 21:27:12 -06:00
prog_boot.c bootstd: Introduce programmatic boot 2023-12-13 11:51:24 -05:00
pxe_utils.c menu: add support to check if menu needs to be reprinted 2024-11-04 16:41:38 -06:00
scene_internal.h expo: Allow menu items to have values 2024-10-18 14:10:22 -06:00
scene_menu.c expo: Support menu-item values in cedit 2024-10-18 14:10:22 -06:00
scene_textline.c expo: Place menu items to the right of all labels 2024-10-18 14:10:22 -06:00
scene.c expo: Drop scene_title_set() 2024-10-18 14:10:22 -06:00
upl_common.c upl: Add support for reading a upl handoff 2024-08-09 16:03:19 -06:00
upl_common.h upl: Add support for reading a upl handoff 2024-08-09 16:03:19 -06:00
upl_read.c upl: fix parsing of DT property 2024-11-14 18:14:06 -06:00
upl_write.c upl: Add support for writing a upl handoff 2024-08-09 16:03:20 -06:00
vbe_request.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
vbe_simple_fw.c xpl: Rename spl_phase() to xpl_phase() 2024-10-11 11:44:47 -06:00
vbe_simple_os.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
vbe_simple.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
vbe_simple.h vbe: Move OS implementation into a separate file 2022-10-31 11:03:36 -04:00
vbe.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00