aboutsummaryrefslogtreecommitdiff
path: root/boot
AgeCommit message (Collapse)Author
2024-04-12fdt: Fix fdt_pack_reg() on 64-bit platformsSam Protsenko
When "memory" node is being processed in fdt_pack_reg() on ARM64 platforms, an unaligned bus access might happen, which leads to "synchronous abort" CPU exception. Consider next dts example: / { #address-cells = <2>; #size-cells = <1>; memory@80000000 { device_type = "memory"; reg = <0x0 0x80000000 0x3ab00000>, <0x0 0xc0000000 0x40000000>, <0x8 0x80000000 0x80000000>; }; }; After fdt_pack_reg() reads the first addr/size entry from such memory node, the "p" pointer becomes 12 bytes shifted from its original value (8 bytes for two address cells + 4 bytes for one size cell). So now it's not 64-bit aligned, and an attempt to do 64-bit bus access to that address will cause an abort like this: "Synchronous Abort" handler, esr 0x96000021, far 0xba235efc This issue was originally reported by David Virag [1] who observed it happening on Samsung Exynos7885 SoC (ARM64), and later the same issue was observed on Samsung Exynos850 (ARM64). Fix the issue by using put_unaligned_be64() helper, which takes care of possible unaligned 64-bit accesses. That solution was proposed by Simon Glass in the original thread [1]. [1] https://lists.denx.de/pipermail/u-boot/2023-July/522074.html Fixes: 739a01ed8e02 ("fdt_support: fix an endian bug of fdt_fixup_memory_banks") Suggested-by: Simon Glass <sjg@google.com> Reported-by: David Virag <virag.david003@gmail.com> Closes: https://lists.denx.de/pipermail/u-boot/2023-July/522074.html Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-04-11Merge patch series "boot: fdt: Change type of env_get_bootm_low() to ↵Tom Rini
phys_addr_t"
2024-04-11boot: fdt: Move usable variable below updated commentMarek Vasut
Move the variable below comment which explains what the variable means. Update the comment. No functional change. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-11boot: fdt: Drop lmb_alloc*() typecastsMarek Vasut
The lmb_alloc_base() returns phys_addr_t , map_sysmem() accepts phys_addr_t as first parameter. Declare 'addr' as phys_addr_t and get rid of the casts. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-11boot: fdt: Clean up env_get_bootm_mapsize()Marek Vasut
Reduce tmp variable use and remove unnecessary type cast in env_get_bootm_mapsize(). This aligns the env variable parsing with env_get_bootm_low(). No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-11boot: fdt: Fix tmp type in env_get_bootm_size() and rename to lowMarek Vasut
Change type of 'tmp' variable from phys_size_t to phys_addr_t and rename it to 'low' to better describe what the variable represents, which is either the bootm_low address from environment or start of DRAM address. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-11boot: fdt: Clean up env_get_bootm_size()Marek Vasut
Reduce tmp variable use and remove unnecessary type cast in env_get_bootm_size(). This aligns the env variable parsing with env_get_bootm_low(). No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-11boot: fdt: Change type of env_get_bootm_low() to phys_addr_tMarek Vasut
Change type of ulong env_get_bootm_low() to phys_addr_t env_get_bootm_low(). The PPC/LS systems already treat env_get_bootm_low() result as phys_addr_t, while the function itself still returns ulong. This is potentially dangerous on 64bit systems, where ulong might not be large enough to hold the content of "bootm_low" environment variable. Fix it by using phys_addr_t, similar to what env_get_bootm_size() does, which returns phys_size_t . Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-04-10Merge patch series "pxe: Allow extlinux booting without CMDLINE enabled"Tom Rini
Simon Glass <sjg@chromium.org> says: This series is the culmanation of the current line of refactoring series. It adjusts pxe to call the booting functionality directly rather than going through the command-line interface. With this is is possible to boot using the extlinux bootmeth without the command line enabled. It also updates fastboot to do a similar thing.
2024-04-10pxe: Allow booting without CMDLINE for the zboot methodSimon Glass
Use zboot_run() to boot rather than the command line. This allows extlinux to be used (on x86) without CMDLINE being enabled. Collect any error but do not return it, to match the existing code. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10pxe: Allow booting without CMDLINE for bootm methodsSimon Glass
Use bootm_run() and booti_run() to boot rather than the command line. This allows extlinux to be used without CMDLINE being enabled. Collect any error but do not return it, to match the existing code. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10pxe: Move calculation of FDT file into a functionSimon Glass
This code undertakes a separate task from the main logic of label_run_boot() so move it into its own function. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10pxe: Refactor to avoid over-using bootm_argvSimon Glass
The bootm_argv[3] expression is used in many places. It is the FDT address, so use that name throughout. Assign it to bootm_argv[3] only at the end, when all the conditions are resolved. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10pxe: Refactor to reduce the size of label_boot()Simon Glass
This function is far too long and complicated. Split out the part which actually calls the boot commands into a separate function. Change a strncpy() to strlcpy() to keep checkpatch happy. No functional change is intended. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10pxe: Use strlcpy() instead of strcpy() in label_boot()Simon Glass
The intention here is to nul-terminate the result string, so use the correct function for that. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10boot: Update SYS_BOOTM_LEN to depend on BOOTMSimon Glass
Use the new CONFIG_BOOTM symbol to determine whether SYS_BOOT_LEN is visible or not, since we want to support decompression when CMDLINE is disabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10bootm: Make OS booting dependent on BOOTMSimon Glass
Booting an OS does not require the 'bootm' command, so change the condition for these options. Move them into boot/ so they don't depend on CMDLINE Note that CMD_BOOTM_PRE_LOAD has been put directly into the bootm code so will need some additional refactoring (and a test!) to allow it to change over. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2024-04-10bootm: Add a Kconfig option for bootm functionalitySimon Glass
Create a separate Kconfig option which enables the bootm logic, separate from the 'bootm' command. This will eventually allow booting without CMDLINE enabled. Update boards which disable CMD_BOOTM to disable BOOTM instead, since CMD_BOOTM now depends on BOOTM Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10boot: Reorder FIT and BOOTSTD to be firstSimon Glass
The boot menu shows Android first and then a timestamp option. Move these later since they are less commonly used. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-10Merge patch series "Complete decoupling of zboot logic from commands"Tom Rini
Simon Glass <sjg@chromium.org> says: This series refactors the zboot code to allow it to be used with CONFIG_COMMAND disabled. A new zboot_run() function is used to boot a zimage.
2024-04-10x86: zboot: Rename zboot_start() to zboot_run()Simon Glass
The term 'start' is used withint bootm and zboot to indicate the first phase of booting an image. Since zboot_start() does the whole boot, rename it to zboot_run() to align with bootm_run() etc. Fix a log message while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-04-08boot: correct finding the default EFI binaryHeinrich Schuchardt
* The sandbox must not use an arbitrary file name bootsbox.efi but the file name matching the host architecture to properly boot the respective file. We already have an include which provides a macro with the name of the EFI binary. Use it. * The path to the EFI binary should be absolute. * The path and the file name must be capitalized to conform to the UEFI specification. This is important when reading from case sensitive file systems. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-04-08boot: enable booting via EFI boot manager by defaultHeinrich Schuchardt
If UEFI is enabled in U-Boot, we want it to conform to the UEFI specification. This requires enabling the boot manager boot method. Reported-by: E Shattow <lucent@gmail.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-04-08boot: correct the default sequence of boot methodsHeinrich Schuchardt
The default sequence of boot methods is determined by alphabetical sorting during linkage. * efi_mgr must run before efi to be UEFI compliant * pxe should run as last resort Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-04-02Merge tag 'u-boot-dfu-20240402' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dfu u-boot-dfu-20240402 - Fix #if logic in android_ab command - Fix ANDROID_AB_BACKUP_OFFSET in android_ab
2024-04-02android_ab: Fix ANDROID_AB_BACKUP_OFFSETColin McAllister
Currently, setting CONFIG_AB_BACKUP_OFFSET in a target's defconfig will not actually enable the #if protected code in android_ab.c. This is because "CONFIG_" should have been prepended to the config macro, or the macros defined in kconfig.h could have been used. The code included by ANDROID_AB_BACKUP_OFFSET has been refactored to no longer be conditionally compiled by preprocessor conditionals and instead use C conditionals. This better aligns with the Linux kernel style guide. Fixes: 3430f24bc6 ("android_ab: Try backup booloader_message") Signed-off-by: Colin McAllister <colin.mcallister@garmin.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Colin McAllister <colinmca242@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Link: https://lore.kernel.org/r/20240312125729.82695-3-colinmca242@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-04-02android_ab: Add missing semicolonColin McAllister
Found a missing semicolon in code protected by a #if that will never evaluate to true due to a separate issue. Fixing this issue before addressing the #if. Fixes: 3430f24bc6 ("android_ab: Try backup booloader_message") Signed-off-by: Colin McAllister <colin.mcallister@garmin.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Colin McAllister <colinmca242@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com> Link: https://lore.kernel.org/r/20240312125729.82695-2-colinmca242@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-03-13fdt: Fix bootm_low handlingMarek Vasut
According to README CFG_SYS_BOOTMAPSZ section, in case both "bootm_low" and "bootm_size" variables are defined, "bootm_mapsize" variable is not defined and CFG_SYS_BOOTMAPSZ macro is not defined, all data for the Linux kernel must be between "bootm_low" and "bootm_low" + "bootm_size". Currently, for systems with DRAM between 0x4000_0000..0x7fff_ffff and with e.g. bootm_low=0x60000000 and bootm_size=0x10000000, the code will attempt to reserve memory from 0x4000_0000..0x4fff_ffff, which is incorrect. This is because "bootm_low" is not taken into consideration correctly. The last parameter of lmb_alloc_base() is the maximum physical address of the to be reserved LMB area. Currently this is the start of DRAM bank that is considered for LMB area reservation + min(DRAM bank size, bootm_size). In case bootm_low is set to non-zero, this maximum physical address has to be shifted upward, to min(DRAM bank start + size, bootm_low + bootm_size), otherwise the reserved memory may be below bootm_low address. In case of multiple DRAM banks, the current change reserves top part of the first bank, and reserves the rest of memory in the follow up banks. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-03-04bootstd: support scanning a single partitionNam Cao
The "bootflow" command currently doesn't support scanning a single partition. This is inconvenient in setups with multiple bootable partitions within a single disk, but only one is desired. Support scanning a single disk partition. Specifically, support the syntax: bootflow scan mmc1:4 which scans only mmc device 1, partition 4. Signed-off-by: Nam Cao <namcao@linutronix.de>
2024-03-02boot: Only define checksum algos when the hashes are enabledSean Anderson
Don't define checksum algos when the underlying hashes are not enabled. This allows disabling these hashes in SPL (or U-Boot). Fixes: d16b38f4270 ("Add support for SHA384 and SHA512") Fixes: 646257d1f40 ("rsa: add sha256-rsa2048 algorithm") Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2024-03-02bootdev: drop unnecessary assert on bootflow->bdevThomas Weißschuh
Not all flows have a device and the function already contains logic to handle this case. Fixes: eccb25cd5922 ("bootstd: Allow the bootdev to be optional in bootflows") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2024-03-01boot: pxe_utils: skip fdt setup in case legacy kernel is bootedSvyatoslav Ryhel
Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass `-` in the fdt extlinux field as a signal that no tree should be used. Suggested-by: Jonas Schwöbel <jonasschwoebel@yahoo.de> Tested-by: Jethro Bull <jethrob@hotmail.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
2024-02-13boot: add support for button commandsCaleb Connolly
With the relatively new button API in U-Boot, it's now much easier to model the common usecase of mapping arbitrary actions to different buttons during boot - for example entering fastboot mode, setting some additional kernel cmdline arguments, or booting with a custom recovery ramdisk, to name a few. Historically, this functionality has been implemented in board code, making it fixed for a given U-Boot binary and requiring the code be duplicated and modified for every board. Implement a generic abstraction to run an arbitrary command during boot when a specific button is pressed. The button -> command mapping is configured via environment variables with the following format: button_cmd_N_name=<button label> button_cmd_N=<command to run> Where N is the mapping number starting from 0. For example: button_cmd_0_name=vol_down button_cmd_0=fastboot usb 0 This will cause the device to enter fastboot mode if volume down is held during boot. After we enter the cli loop the button commands are no longer valid, this allows the buttons to additionally be used for navigating a boot menu. Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # Tegra30 Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-01-19Kconfig: boot: Imply BOOTSTD_DEFAULT when BOOTSTD_FULL=yShantur Rathore
We need BOOTSTD_DEFAULT when BOOTSTD_FULL is selected. Signed-off-by: Shantur Rathore <i@shantur.com>
2024-01-18boot: superfluous assignment in bootflow_menu_new()Heinrich Schuchardt
ret is assigned a value 0 which is never used but is immediately overwritten in the next statement. Addresses-Coverity-ID: 453304 ("Unused value") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-18boot: remove dead code in bootflow_check()Heinrich Schuchardt
The 'return 0;' statement is not reachable. Remove it. 'else' is superfluous after an if statement with return. Addresses-Coverity-ID: 352451 ("Logically dead code") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-18bootdev: avoid infinite probe loopCaleb Connolly
Sometimes, when only one bootdev is available, and it fails to probe, we end up in an infinite loop calling probe() on the same device over and over. With only debug level log output. Break the loop if we fail to probe the same device twice in a row, and promote the probe failure message to log_warning(). Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Dragan Simic <dsimic@manjaro.org>
2024-01-17efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGRAKASHI Takahiro
At this point, EFI boot manager interfaces is fully independent from bootefi command. So just rename the configuration parameter. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-17efi_loader: split unrelated code from efi_bootmgr.cAKASHI Takahiro
Some code moved from cmd/bootefi.c is actually necessary only for "bootefi <addr>" command (starting an image manually loaded by a user using U-Boot load commands or other methods (like JTAG debugger). The code will never been opted out as unused code by a compiler which doesn't know how EFI boot manager is implemented. So introduce a new configuration, CONFIG_EFI_BINARY_EXEC, to enforce them opted out explicitly. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2024-01-11android_ab: don't ignore ab_control_store return codeAlexey Romanov
ab_control_store() can return an error if writing to disk fails. In this case, we have to pass the error code to the caller. Signed-off-by: Alexey Romanov <avromanov@salutedevices.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2024-01-11boot: CONFIG_CEDIT must depend on CONFIG_EXPOHeinrich Schuchardt
Building sandbox_defconfig with CONFIG_CMD_CEDIT=y CONFIG_EXPO=n fails with cmd/cedit.c:258:(.text.do_cedit_run+0x4c): undefined reference to `expo_apply_theme Fix the dependencies. Fixes: a0874dc4ac71 ("expo: Add a configuration editor") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-11boot: Support decompressing non-kernel OS imagesSimon Glass
Sometimes the kernel is built as an EFI application rather than a binary. We still want to support compression for this case. For arm64 the entry point is set later in the bootm_load_os() function, since these images are typically relocated due to the 2MB-alignment requirement of arm64 images. But since the EFI image is not in the same format, we need to update the entry point earlier. Set the entry point always, for kernel_noload to resolve this problem. It should be harmless to do this always. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-01-09lib: membuff: fix readline not returning line in case of overflowIon Agorria
If line overflows readline it will not be returned, fix this behavior, make it optional and documented properly. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20240105072212.6615-6-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-12-22bootmeth: pass size to efi_binary_run()Heinrich Schuchardt
If we call efi_binary_run() with size parameter set to zero, we get an error Not a PE-COFF file Fill the missing value. Fixes: 1373ffde52e1 ("Merge tag 'v2024.01-rc5' into next") Fixes: 7017fc54a5bc ("bootmeth: use efi_loader interfaces instead of bootefi command") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-21Merge patch series "Complete decoupling of bootm logic from commands"Tom Rini
Simon Glass <sjg@chromium.org> says: This series continues refactoring the bootm code to allow it to be used with CONFIG_COMMAND disabled. The OS-handling code is refactored and a new bootm_run() function is created to run through the bootm stages. This completes the work. A booti_go() function is created also, in case it proves useful, but at last for now standard boot does not use this. This is cmdd (part d of CMDLINE refactoring) It depends on dm/bootstda-working which depends on dm/cmdc-working
2023-12-21bootm: Create a new boot_run() function to handle bootingSimon Glass
Create a common function used by the three existing bootz/i/m_run() functions, to reduce duplicated code. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Tom Rini <trini@konsulko.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-21bootm: Create a function to run through the booti statesSimon Glass
In a few places, the booti command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new booti_run() function to handle this. So far this is not used. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-21bootm: Create a function to run through the bootz statesSimon Glass
In a few places, the bootz command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new bootz_run() function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-21bootm: Create a function to run through the bootm statesSimon Glass
In quite a few places, the bootm command is used to handle a boot. We want these to be done without needing CONFIG_CMDLINE, so add a new bootm_run() function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-21bootm: Tidy up boot_selected_os()Simon Glass
Use struct bootm_info with this function, to avoiding needing to create a new one. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>