aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-10-12efi_selftest: BitBlt testHeinrich Schuchardt1-20/+63
The BitBlt test leaves the serial console output in disarray. * Call ClearScreen() where needed. * Test CheckEvent() for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey via adding navigation keys * Correct timer comment For testing on the sandbox: CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CONSOLE_TRUETYPE=n $ ./u-boot -T -l => setenv efi_selftest block image transfer => bootefi selftest Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-10-09lmb: remove overlapping region with next rangeUdit Kumar1-4/+33
In case of new memory range to be added is coalesced with any already added non last lmb region. And there is possibility that, then region in which new memory range added is not adjacent to next region. But have some sections are overlapping. So along with adjacency check with next lmb region, check for overlap should be done. In case overlap is found, adjust and merge these two lmb region into one. Reported-by: Suman Anna <s-anna@ti.com> Signed-off-by: Udit Kumar <u-kumar1@ti.com>
2023-10-06dm: core: Add a way to convert a devicetree to a dtbSimon Glass1-0/+122
Add a way to flatten a devicetree into binary form. For livetree this involves generating the devicetree using fdt_property() and other calls. For flattree it simply involves providing the buffer containing the tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06dm: core: Add a function to create an empty treeSimon Glass1-0/+19
Provide a function to create a new, empty tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-10-06spl: Use SYS_MALLOC_F instead of SYS_MALLOC_F_LENSimon Glass1-1/+1
Use the new SPL/TPL/VPL_SYS_MALLOC_F symbols to determine whether the malloc pool exists. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
2023-09-24common: Drop linux/printk.h from common headerSimon Glass10-0/+10
This old patch was marked as deferred. Bring it back to life, to continue towards the removal of common.h Move this out of the common header and include it only where needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-09-22efi: Use the installed SMBIOS tablesSimon Glass4-32/+53
U-Boot should set up the SMBIOS tables during startup, as it does on x86. Ensure that it does this correctly on non-x86 machines too, by creating an event spy for last-stage init. Tidy up the installation-condition code while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-09-22x86: smbios: Add a Kconfig indicating SMBIOS-table presenceSimon Glass1-1/+14
When booted from coreboot, U-Boot does not build the SMBIOS tables, but it should still pass them on to the OS. Add a new option which indicates whether SMBIOS tables are present, however they were built. Flip the ordering so that the dependency is listed first, which is less confusing. Adjust GENERATE_SMBIOS_TABLE to depend on this new symbol. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-09-22efi: x86: Correct the condition for installing ACPI tablesSimon Glass2-6/+6
It is not always the case that U-Boot builds the ACPI tables itself. For example, when booting from coreboot, the ACPI tables are built by coreboot. Correct the Makefile condition so that U-Boot can pass on tables built by a previous firmware stage. Tidy up the installation-condition code while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-09-22x86: Allow APCI in SPLSimon Glass1-0/+8
This is needed so we can find the DBG2 table provided by coreboot. Add a Kconfig so it can be enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-09-19boot: Join FDT_FIXUP_PARTITIONS with related optionsSimon Glass1-9/+0
Move this to be with the other devicetree-fixup options. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-09-19FWU: Avoid showing an unselectable menu optionSimon Glass2-8/+5
Use a menuconfig to avoid showing a menu which cannot be selected in many cases. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-09-19lib: rational: Move the Kconfigs into the correct placeSimon Glass1-2/+2
These should not be part of the 'system tables' menu. Move them outside on their own. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 7d0f3fbb93c ("lib: rational: copy the rational fraction lib...") Reviewed-by: Tom Rini <trini@konsulko.com>
2023-09-14common: board_r: Remove unused NEEDS_MANUAL_RELOC code bitsMarek Vasut1-10/+0
The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-09-04Merge tag 'v2023.10-rc4' into nextTom Rini4-29/+80
Prepare v2023.10-rc4
2023-08-31event: Convert existing spy records to simpleSimon Glass1-2/+2
Very few of the existing event-spy records use the arguments they are passed. Update them to use a simple spy instead, to simplify the code. Where an adaptor function is currently used, remove it where possible. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31initcall: Support manual relocationSimon Glass1-0/+10
Move the manual-relocation code to the initcall file. Make sure to avoid manually relocating event types. Only true function pointers should be relocated. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31initcall: Support emitting eventsSimon Glass1-5/+45
At present the initcall list consists of a list of function pointers. Over time the initcall lists will likely change to mostly emitting events, since most of the calls are board- or arch-specific. As a first step, allow an initcall to be an event type instead of a function pointer. Add the required macro and update initcall_run_list() to emit an event in that case, or ignore it if events are not enabled. The bottom 8 bits of the function pointer are used to hold the event type, with the rest being all ones. This should avoid any collision, since initcalls should not be above 0xffffff00 in memory. Convert misc_init_f over to use this mechanism. Add comments to the initcall header file while we are here. Also fix up the trace test to handle the change. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31initcall: Adjust the failure message and return valueSimon Glass1-5/+7
Move the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along. Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with: grep -A1 -B1 serial_init u-boot.map Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31initcall: Adjust the loop logicSimon Glass1-12/+12
Use a variable to hold the function, so we don't need to repeat the pointer access each time. Rename the init pointer to 'ptr' since we only refer to it in the for() statement now. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31initcall: Factor out reloc_off calculationSimon Glass1-10/+15
Move this into a function and do it once, not each time around the loop. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-31Revert "initcall: Move to inline function"Simon Glass2-0/+53
Somehow I do not see any inlining with initcalls now. I was sure I saw it when this commit went in, but now it seems to make things worse. This reverts commit 47870afab92fca6e672c03d0dea802a55e200675. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-30fwu: Initialize global fwu library state during CI testMarek Vasut1-6/+6
The current CI test worked by sheer luck, the g_dev global pointer in the fwu library was never initialized and the test equally well failed on sandbox64. Trigger the main loop in sandbox tests too to initialize that global state, and move the sandbox specific exit from fwu_boottime_checks after g_dev is initialized. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-29scripts/Makefile.lib: Embed capsule public key in platform's dtbSughosh Ganu2-0/+19
The EFI capsule authentication logic in u-boot expects the public key in the form of an EFI Signature List(ESL) to be provided as part of the platform's dtb. Currently, the embedding of the ESL file into the dtb needs to be done manually. Add a target for generating a dtsi file which contains the signature node with the ESL file included as a property under the signature node. Include the dtsi file in the dtb. This brings the embedding of the ESL in the dtb into the U-Boot build flow. The path to the ESL file is specified through the CONFIG_EFI_CAPSULE_ESL_FILE symbol. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-28Revert "arm: imx: mx7: Move CONFIG_OPTEE_TZDRAM_SIZE from lib/optee"WIP/2023-08-28-assorted-important-fixesRicardo Salveti1-0/+8
This reverts commit c5b68ef8af3c2f515c1f5b8d63a69359a85d753b. CONFIG_OPTEE_TZDRAM_SIZE is used by imx6-based SoCs as well. Move the option back. Signed-off-by: Ricardo Salveti <ricardo@foundries.io> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2023-08-28spl: crypto: fix including SHA* object files in SPLOleksandr Suvorov1-3/+3
If one of SHA* algorithms is disabled in u-boot, its code is not included in SPL even if a given SHA* option is enabled in SPL. Fix this. Fixes: 603d15a572d ("spl: cypto: Bring back SPL_ versions of SHA") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-27efi_loader: delete handle from events when a protocol is uninstalledIlias Apalodimas1-24/+65
When a notification event is registered for a protocol the handle of the protocol is added in our event notification list. When all the protocols of the handle are uninstalled we delete the handle but we do not remove it from the event notification list. Clean up the protocol removal functions and add a wrapper which - Removes the to-be deleted handle from any lists it participates - Remove the handle if no more protocols are present Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-27lib: parameter check in hash_calculateHeinrich Schuchardt1-2/+4
If hash_calculate is invoked with region_count = 0, it will try to hash INT_MAX regions. We should check this parameter. * Avoid a comparison with different signedness. * Check that region_count is at least 1. * Avoid a superfluous assignment. Fixes: b37b46f042cc ("rsa: Use checksum algorithms from struct hash_algo") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-25uuid: Add ChromiumOS partition typesSimon Glass1-0/+7
Add some GUIDs for ChromiumOS so we can detect the partitions. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25uuid: Move function comments to header fileSimon Glass1-103/+0
These should be in the header file for easy browsing, not in the source code. Move them and add a missing Return on one of the functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25abuf: Allow incrementing the sizeSimon Glass1-0/+5
Provide a convenience function to increment the size of the abuf. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-21Merge tag 'v2023.10-rc3' into nextTom Rini5-9/+355
Prepare v2023.10-rc3 Signed-off-by: Tom Rini <trini@konsulko.com>
2023-08-15efi_loader: fix efi_add_known_memory()Heinrich Schuchardt1-1/+1
In efi_add_known_memory() we currently call board_get_usable_ram_top() with an incorrect value 0 of parameter total_size. This leads to an incorrect value for ram_top depending on the code in board_get_usable_ram_top(). Use the value of gd->ram_top instead which is set before relocation by calling board_get_usable_ram_top(). Fixes: 7b78d6438a2b ("efi_loader: Reserve unaccessible memory") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-09lib: Suppress E when writing error-string outputSimon Glass1-2/+3
When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the format string. Fix this. Fixes: 7f331941321 ("lib: Support printing an error string") Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-08-09treewide: unify the linker symbol reference formatShiji Yang2-4/+4
Now all linker symbols are declared as type char[]. Though we can reference the address via both the array name 'var' and its address '&var'. It's better to unify them to avoid confusing developers. This patch converts all '&var' linker symbol refrences to the most commonly used format 'var'. Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-09Kconfigs: Correct default of "0" on hex type entriesTom Rini1-1/+1
It is not a parse error to have a default value of "0" for a "hex" type entry, instead of "0x0". However, "0" and "0x0" are not treated the same even by the tools themselves. Correct this by changing the default value from "0" to "0x0" for all hex type questions that had the incorrect default. Fix one instance (in two configs) of a default of "0" being used on a hex question to be "0x0". Remove the cases where a defconfig had set a value of "0x0" to be used as the default had been "0". Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-08crc32: Drop duplicates crc header includesIlya Lukin1-1/+0
Fixes: 3db711085752 ("crc32: Use the crc.h header for crc functions") Signed-off-by: Ilya Lukin <4.shket@gmail.com>
2023-08-08lib/charset: fix u16_strlcat() return valueMatthias Schiffer1-4/+4
strlcat returns min(strlen(dest), count)+strlen(src). Make u16_strlcat's behaviour the same for consistency. Fixes: eca08ce94ceb ("lib/charset: add u16_strlcat() function") Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
2023-08-08Revert "lib: string: Fix strlcpy return value", fix callersMatthias Schiffer1-7/+7
Both the Linux kernel and libbsd agree that strlcpy() should always return strlen(src) and not include the NUL termination. The incorrect U-Boot implementation makes it impossible to check the return value for truncation, and breaks code written with the usual implementation in mind (for example, fdtdec_add_reserved_memory() was subtly broken). I reviewed all callers of strlcpy() and strlcat() and fixed them according to my understanding of the intended function. This reverts commit d3358ecc54be0bc3b4dd11f7a63eab0a2842f772 and adds related fixes. Fixes: d3358ecc54be ("lib: string: Fix strlcpy return value") Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
2023-08-08arm_ffa: efi: introduce FF-A MM communicationAbdellatif El Khlifi2-6/+303
Add MM communication support using FF-A transport This feature allows accessing MM partitions services through EFI MM communication protocol. MM partitions such as StandAlonneMM or smm-gateway secure partitions which reside in secure world. An MM shared buffer and a door bell event are used to exchange the data. The data is used by EFI services such as GetVariable()/SetVariable() and copied from the communication buffer to the MM shared buffer. The secure partition is notified about availability of data in the MM shared buffer by an FF-A message (door bell). On such event, MM SP can read the data and updates the MM shared buffer with the response data. The response data is copied back to the communication buffer and consumed by the EFI subsystem. MM communication protocol supports FF-A 64-bit direct messaging. We tested the FF-A MM communication on the Corstone-1000 platform. We ran the UEFI SCT test suite containing EFI setVariable, getVariable and getNextVariable tests which involve FF-A MM communication and all tests are passing with the current changes. We made the SCT test reports (part of the ACS results) public following the latest Corstone-1000 platform software release. Please find the test reports at [1]. [1]: https://gitlab.arm.com/arm-reference-solutions/arm-reference-solutions-test-report/-/tree/master/embedded-a/corstone1000/CORSTONE1000-2023.06/acs_results_fpga.zip Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Tested-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-08lib: uuid: introduce uuid_str_to_le_bin functionAbdellatif El Khlifi1-0/+48
convert UUID string to little endian binary data Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org>
2023-08-07spl: move SPL_CRC32 option to lib/KconfigOleksandr Suvorov1-0/+11
All SPL hash algorithm options are collected in lib/Kconfig. Move SPL_CRC32 there as well. Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-03efi_loader: check uuid_str_to_bin return valueMasahisa Kojima1-2/+6
Check the uuid_str_to_bin return value, skip the node if the image-type-id property is wrong format. Addresses-Coverity-ID: 463145 ("Error handling issues") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-03efi_loader: catch out of memory in file_openHeinrich Schuchardt1-0/+2
If calloc() return NULL, don't dereference it. Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: error handling in efi_disk_add_devHeinrich Schuchardt2-10/+17
* If an error occurs in efi_disk_add_dev(), don't leak resources. * If calloc() fails while creating the file system protocol interface, signal an error. * Rename efi_simple_file_system() to efi_create_simple_file_system(). * Drop a little helpful debug message. Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: memory leak efi_add_memory_map_pgHeinrich Schuchardt1-0/+2
Don't leak newlist if we error out. Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: out of memory in efi_mem_carve_outHeinrich Schuchardt1-0/+6
Handle out of memory situation in efi_mem_carve_out(). Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: overflow in efi_allocate_pagesHeinrich Schuchardt1-1/+6
On 32bit systems (pages << EFI_PAGE_SHIFT) may lead to an overflow which does not occur in 64bit arithmetics. An overflow of (pages << EFI_PAGE_SHIFT) on 64bit systems should be treated as an error. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-03efi_loader: error handling in tcg2_hash_pe_image()Heinrich Schuchardt1-4/+2
If the hard coded array hash_algo_list[] contains an entry for an unsupported algorithm, we should not leak resources new_efi and regs. We should still extend the log with the digests for the supported algorithms and not write any message. The same holds true of tcg2_create_digest(): just continue in case hash_algo_list[] contains an unsupported entry. Fixes: 163a0d7e2cbd ("efi_loader: add PE/COFF image measurement") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: out of memory in efi_add_memory_map_pgHeinrich Schuchardt1-0/+2
Handle out of memory situation in efi_add_memory_map_pg(). Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>