aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-02-12lmb: Treat a region which is a subset as equalSjoerd Simons1-1/+3
In various cases logical memory blocks are coalesced; As a result doing a strict check whether memory blocks are the same doesn't necessarily work as a previous addition of a given block might have been merged into a bigger block. Fix this by considering a block is already registered if it's a pure subset of one of the existing blocks. Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2023-02-11trace: Detect an infinite loopSimon Glass1-0/+10
If something is wrong with a board's timer function such that it calls functions not marked with notrace, U-Boot will hang. Detect this, print a message and disable the trace. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Correct the relocation handover with buffer overflowSimon Glass1-3/+10
When the early trace buffer overflows it leaves a gap in the trace buffer between where the actual data finished and where it would have finished if there were enough buffer space. This results in corrupted output. Adjust the logic to resolve this and add a message when the buffer overflows. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Show a few more stats about tracingSimon Glass1-2/+6
Add a few more useful items into the output. Update the buffers to use hex consistently. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Track the minimum stack depthSimon Glass1-8/+16
The trace does not necessarily start at the top level, so we can see it go negative. Track this so that we can show an accurate value for the stack depth. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Reduce the number of function sitesSimon Glass1-2/+17
Given that the compiler adds two function calls into each function, the current spacing is overkill. Drop it down to 16 bytes per function, which is still plenty. This saves some space in the trace buffer. Also move the calculation into a function, so it is common code. Add a check for gd->mon_len being unset, which breaks tracing. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Update the file headerSimon Glass1-15/+4
It seems better to put the TEXT_BASE value in the file header rather than in an entry record. While it is true that there is a separate base for pre-relocation, this can be handled by using offsets in the file. It is useful to have a version number in case we need to change the trace format again. Update the header to make these changes. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11abuf: Support use from toolsSimon Glass1-1/+20
Update the code slightly so that abuf can be used in U-Boot tools. It will soon be needed for proftool. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11trace: Reduce the default for TRACE_EARLY_CALL_DEPTH_LIMITSimon Glass1-1/+1
This is a silly value at present, since U-Boot's call depth never reaches 200. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11time: Tidy up some unnecessary #ifdefsSimon Glass1-8/+6
Avoid using the preprocessor with TIMER_EARLY. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Merge tag 'efi-2023-04-rc2' of ↵WIP/10Feb2023Tom Rini10-23/+43
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2023-04-rc2 Documentation: * Provide page with links to talks on U-Boot UEFI: * Enable CTRL+S to save the boot order in eficonfig command * Run attribute check for QueryVariableInfo() only for the file store * Bug fixes Others: * Improve output formatting of the coninfo command # -----END PGP SIGNATURE----- # gpg: Signature made Fri 10 Feb 2023 12:15:45 PM EST # gpg: using RSA key 6DC4F9C71F29A6FA06B76D33C481DBBC2C051AC4 # gpg: Good signature from "Heinrich Schuchardt <xypron.glpk@gmx.de>" [unknown] # gpg: aka "[jpeg image of size 1389]" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6DC4 F9C7 1F29 A6FA 06B7 6D33 C481 DBBC 2C05 1AC4
2023-02-10efi_loader: static efi_query_variable_info_runtime()Heinrich Schuchardt1-1/+1
This function is not used externally and hence should be static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: make gop_blt() staticHeinrich Schuchardt1-5/+6
This function is not used externally. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: include definition of allow_unaligned()Heinrich Schuchardt1-0/+1
Add missing include. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: static functions in efi_runtime.cHeinrich Schuchardt1-2/+2
Functions that are not used externally should be static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: static functions in efi_console.cHeinrich Schuchardt1-1/+1
Define function set_shift_mask() as static as it is not used externally. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: static functions in efi_boottime.cHeinrich Schuchardt1-2/+4
Make functions that are no used externally static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: static functions in helloworld.cHeinrich Schuchardt1-1/+2
Make functions that are not used externally static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: fix efi_ecpt_register()Heinrich Schuchardt1-1/+1
num_entries should be unsigned to avoid warnings. As the target field is u16 we should use this type. lib/efi_loader/efi_conformance.c: In function ‘efi_ecpt_register’: lib/efi_loader/efi_conformance.c:30:33: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion] 30 | ecpt_size = num_entries * sizeof(efi_guid_t) | ^ lib/efi_loader/efi_conformance.c:46:36: warning: conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’} may change value [-Wconversion] 46 | ecpt->number_of_profiles = num_entries; | ^~~~~~~~~~~ Fixes: 6b92c1735205 ("efi: Create ECPT table") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: make get_load_options() staticHeinrich Schuchardt1-1/+1
In program initrddump.efi function get_load_options() can be static. This avoids a warning when building with 'make W=1': lib/efi_loader/initrddump.c:442:6: warning: no previous prototype for ‘get_load_options’ [-Wmissing-prototypes] 442 | u16 *get_load_options(void) | ^~~~~~~~~~~~~~~~ Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10efi_loader: update attribute check for QueryVariableInfo()Masahisa Kojima2-9/+24
Current U-Boot supports two EFI variable service, U-Boot own implementation and op-tee based StMM variable service. With ACS Security Interface Extension(SIE) v22.10_SIE_REL1.1.0, there are several failure items of QueryVariableInfo(). Current attribute check for QueryVariableInfo() was implemented based on the Self Certification Test (SCT) II Case Specification, June 2017, chapter 4.1.4 QueryVariableInfo(). This test case specification is outdated and don't align at all with the SCT test case code, and UEFI specification v2.10 does not clearly define the priority of the attribute check. For U-Boot standard case that EFI variables are stored in a file in the ESP, this commit modifies the attribute check to get align to the EDK2 implementation. For latter case(op-tee based StMM variable service), parameter check should be delegated to StMM. Now all ACS SIE QueryVariableInfo() test cases passed both EFI variable storage implementations. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-09Correct SPL use of ENV_WRITEABLE_LISTSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_ENV_WRITEABLE_LIST defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of EFI_UNICODE_COLLATION_PROTOCOL2Simon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_UNICODE_COLLATION_PROTOCOL2 defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of EFI_TCG2_PROTOCOLSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_TCG2_PROTOCOL defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of EFI_LOADER_HIISimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_LOADER_HII defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of EFI_DEVICE_PATH_UTILSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_DEVICE_PATH_UTIL defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09Correct SPL use of EFI_APPSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_APP defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-08Bump LMB_MAX_REGIONS default to 16Sjoerd Simons1-1/+1
Since commit 06d514d77c37 ("lmb: consider EFI memory map") the EFI regions are also pushed into the lmb if EFI_LOADER is enabled (which is by default on most system). Which can cause the number of entries to go over the maximum as it's default is only 8. Specifically i ran into this case on an TI am62 which has an fdt with 4 reserved regions (in practice 3 lmb entries due to adjecent ranges). As this is likely to impact more devices bump the default max regions to 16 so there is a bit more slack. Fixes: 06d514d77c ("lmb: consider EFI memory map") Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1207562 Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com> Signed-off-by: Sjoerd Simons <sjoerd@collabora.com> Signed-off-by: Michal Suchanek <msuchanek@suse.de> [trini: collect tags from the other equivalent patch]
2023-02-08Revert "lmb: Default to not-LMB_USE_MAX_REGIONS"Tom Rini1-0/+1
As explained by Philippe Schenker, I was misinterpreting what happened in the case where we do not set LMB_USE_MAX_REGIONS and so had re-introduced the problem I was attempting to more widely resolve. This reverts commit 007ae5d108a37564905ea1588cb279f3a522cc3d. Reported-by: Philippe Schenker <philippe.schenker@toradex.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-02-06lmb: Set correct lmb flags for EFI memory map entriesSjoerd Simons1-5/+8
When adding reserved memory areas from the EFI memory map set the NOMAP flag when applicable. When this isn't done adding "no-map" flagged entries from the fdt after receiving the same from the EFI memory map fails due to non-matching flags. Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2023-02-06lmb: Default to not-LMB_USE_MAX_REGIONSTom Rini1-1/+0
The LMB code allows for picking a hard limit on the number of regions it can know of, or to dynamically allocate these regions. The reason for this choice is to allow for the compiler to perform a size optimization in the common case. This optimization however, is very small, ranging from 196 bytes to 15 bytes saved, or in some cases, being larger. Now that we also have more regions covered by LMB (in order to protect various parts of our self at run time), the default of 8 is also much easier to hit and leads to non-obvious error messages (which imply that an area is protected, not that we're out of areas to add to the list). Switch to the dynamic use as the default. Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-27efi_loader: don't use HandleProtocolHeinrich Schuchardt1-2/+3
HandleProtocol() is deprecrated. According to the UEFI specification it should be implemented as a call to OpenProtocolInterface() with a hard coded agent handle. This implies that we would have to call CloseProtocolInterfaces() after usage with the same handle. Getting rid of an EFI_CALL() is also appreciated. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-27efi_loader: fix comment in ESRT codeHeinrich Schuchardt1-1/+1
There is no variable num_pages in function efi_esrt_allocate_install(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-23efi: Improve logging in efi_diskSimon Glass1-9/+21
When this fails it can be time-consuming to debug. Add some debugging to help with this. Also try to return error codes instead of just using -1. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23lib: Support printing an error stringSimon Glass1-0/+12
It is often useful to show an error code to give the user a clue as to what went wrong. When error strings are compiled into U-Boot it is possible to show a message as well. But at present it is not very convenient, since code must check if the error strings are present, then obtain the error string and use it in a printf() string. Add a %dE option which shows an error code along with an error string, if available. This makes it easy to show one or both. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23lib: Add a function to split a string into substringsSimon Glass1-0/+41
Some environment variables provide a space-separated list of strings. It is easier to process these when they are broken out into an array of strings. Add a utility function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-20Merge tag 'efi-2023-04-rc1-2' of ↵WIP/20Jan2023Tom Rini5-6/+34
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2023-04-rc1-2 Documentation * man-pages for source, blkcache, bdinfo * fix references to distro documentation UEFI: * allow clear screen by scrolling * ensure that file ubootefi.var is created * fix CapsuleMax variable reporting Others: * reduce verbosity of fat_read_file()
2023-01-20global: Finish CONFIG -> CFG migrationTom Rini2-10/+10
At this point, the remaining places where we have a symbol that is defined as CONFIG_... are in fairly odd locations. While as much dead code has been removed as possible, some of these locations are simply less obvious at first. In other cases, this code is used, but was defined in such a way as to have been missed by earlier checks. Perform a rename of all such remaining symbols to be CFG_... rather than CONFIG_... Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-20efi_loader: fix CapsuleMax variable reportingIlias Apalodimas1-1/+1
Currently the code that adds the CapsuleMax variable is under a Kconfig named 'EFI_HAVE_CAPSULE_UPDATE. Git history only shows a single occurrence of that. The IS_ENABLED should be checking for EFI_HAVE_CAPSULE_SUPPORT Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20efi_loader: update the error message of TCG protocol installationIlias Apalodimas1-1/+1
"Unable to find TPMv2 device" doesn't explain much with regards to the error origin. Update it to match what we have in the RNG protocol installation. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20efi_loader: ensure that file ubootefi.var is createdHeinrich Schuchardt1-3/+5
Currently file ubootefi.var is only created if the user sets a non-volatile EFI variable. If the file is missing, a warning is written. With the change PlatformLang is always persisted. So the file will exist on second boot. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20efi_loader: Avoid overwriting previous outputs on console screen clearingJan Kiszka2-1/+21
Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs. Tested regarding multi-output against qemu-x86_defconfig. Still, there were remaining concerns about side effects, so this is provided as an opt-in feature. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20efi_loader: Set default console colors on efi_cout_clear_screen if neededJan Kiszka1-0/+6
Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-19Merge tag 'dm-pull-18jan23' of ↵WIP/19Jan2023Tom Rini5-52/+103
https://source.denx.de/u-boot/custodians/u-boot-dm convert rockchip to use binman patman fix for checkpatch binman optional entries, improved support for ELF symbols trace improvements minor fdt refactoring
2023-01-18lib: zstd: update to latest Linux zstd 1.5.2Brandon Maier41-6570/+10732
Update the zstd implementation to match Linux zstd 1.5.2 from commit 2aa14b1ab2. This was motivated by running into decompression corruption issues when trying to uncompress files compressed with newer versions of zstd. zstd users also claim significantly improved decompression times with newer zstd versions which is a side benefit. Original zstd code was copied from Linux commit 2aa14b1ab2 which is a custom-built implementation based on zstd 1.3.1. Linux switched to an implementation that is a copy of the upstream zstd code in Linux commit e0c1b49f5b, this results in a large code diff. However this should make future updates easier along with other benefits[1]. This commit is a straight mirror of the Linux zstd code, except to: - update a few #include that do not translate cleanly - linux/swab.h -> asm/byteorder.h - linux/limits.h -> linux/kernel.h - linux/module.h -> linux/compat.h - remove assert() from debug.h so it doesn't conflict with u-boot's assert() - strip out the compressor code as was done in the previous u-boot zstd - update existing zstd users to the new Linux zstd API - change the #define for MEM_STATIC to use INLINE_KEYWORD for codesize - add a new KConfig option that sets zstd build options to minify code based on zstd's ZSTD_LIB_MINIFY[2]. These changes were tested by booting a zstd 1.5.2 compressed kernel inside a FIT. And the squashfs changes by loading a file from zstd compressed squashfs with sqfsload. buildman was used to compile test other boards and check for binary bloat, as follows: > $ buildman -b zstd2 --boards dh_imx6,m53menlo,mvebu_espressobin-88f3720,sandbox,sandbox64,stm32mp15_dhcom_basic,stm32mp15_dhcor_basic,turris_mox,turris_omnia -sS > Summary of 6 commits for 9 boards (8 threads, 1 job per thread) > 01: Merge branch '2023-01-10-platform-updates' > arm: w+ m53menlo dh_imx6 > 02: lib: zstd: update to latest Linux zstd 1.5.2 > aarch64: (for 2/2 boards) all -3186.0 rodata +920.0 text -4106.0 > arm: (for 5/5 boards) all +1254.4 rodata +940.0 text +314.4 > sandbox: (for 2/2 boards) all -4452.0 data -16.0 rodata +640.0 text -5076.0 [1] https://github.com/torvalds/linux/commit/e0c1b49f5b674cca7b10549c53b3791d0bbc90a8 [2] https://github.com/facebook/zstd/blob/f302ad8811643c428c4e3498e28f53a0578020d3/lib/libzstd.mk#L31 Signed-off-by: Brandon Maier <brandon.maier@collins.com> [trini: Set ret to -EINVAL for the error of "failed to detect compressed" to fix warning, drop ZSTD_SRCSIZEHINT_MAX for non-Linux host tool builds] Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-18Revert "fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQ"Simon Glass2-2/+12
The fdt_path_offset() function is slow since it must scan the tree. This substantial overhead now applies to all boards. The original code may not be ideal but it is fit for purpose and is only needed on a few boards. Reverting this reduces time to set up driver model by about 30ms. Before revert: Accumulated time: 47,170 dm_r 53,237 dm_spl 572,986 dm_f Accumulated time: 44,598 dm_r 50,347 dm_spl 549,133 dm_f This reverts commit 26f981f295d00351b6f0c69b5317b254b2361cc0. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18trace: Don't require TIMER_EARLYSimon Glass1-1/+1
Some platforms cannot honour this and don't need trace before relocation. Use 'imply' instead, so boards can disable this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18trace: Move trace pointer to data sectionSimon Glass1-1/+2
This can be written before relocation. Move it to the data section, since accessing BSS before relocation is not permitted. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Check for overlapping data and FDTSimon Glass1-0/+23
If the FDT overlaps with the data region of the image, or with the stack, it can become corrupted before relocation. Add a check for this, behind a debug flag, as it can be very confusing and time-consuming to debug. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Pass the device tree to fdtdec_prepare_fdt()Simon Glass1-11/+11
This function uses gd->fdt_blob a lot and cannot be used to check any other device tree. Use a parameter instead. Signed-off-by: Simon Glass <sjg@chromium.org>