summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-11-18net: net_utils: Move ip_to_string to lib/net_utils.cAdriano Cordova
The function string_to_ip is already in net_utils, which is compiled unconditionally, but ip_to_string is currently only accessible if the legacy network stack is selected. This commit puts ip_to_string in net_utils.c and removes it from the legacy network code. Signed-off-by: Adriano Cordova <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-11-17dm: sysinfo: Shorten the SYSINFO_ID prefixSimon Glass
We are about to add a large number of new entries. Update the prefix to be a little shorter. For SMBIOS items, use SYSID_SM_ (for System Management) which is enough to distinguish it. For now at least, it seems that most items will be for SMBIOS. Signed-off-by: Simon Glass <[email protected]> Acked-by: Raymond Mao <[email protected]>
2024-11-16tpm: use memmove() for overlapping buffersHeinrich Schuchardt
The behavior of memcpy() for overlapping buffers is undefined. Fixes: 4c57ec76b725 ("tpm: Implement state command for Cr50") Addresses-Coverity-ID: 356664 Overlapping buffer in memory copy Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-11-14lmb.c: add missing comma in lmb_dump_region()Heinrich Schuchardt
In the message string " %s[%d]\t[0x%llx-0x%llx], 0x%08llx bytes flags: " a comma is missing before flags. To avoid increasing the code size replace '0x%' by '%#'. Printing the size with leading zeros but not the addresses does not really make sense. Remove the leading zeros from the size output. Signed-off-by: Heinrich Schuchardt <[email protected]> [trini: Fix test/cmd/bdinfo.c for these changes] Signed-off-by: Tom Rini <[email protected]>
2024-11-14lmb: do not panic in lmb_print_region_flagsHeinrich Schuchardt
Commit c3cf0dc64f1c ("lmb: add a check to prevent memory overrun") addressed a possible buffer overrun using assert_noisy(). Resetting via panic() in lmb_print_region() while allowing invalid lmb flags elsewhere is not reasonable. Instead of panicking print a message indicating the problem. fls() returns an int. Using a u64 for bitpos does not match. Use int instead. fls() takes an int as argument. Using 1ull << bitpos generates a u64. Use 1u << bitpos instead. Signed-off-by: Heinrich Schuchardt <[email protected]> Acked-by: Sughosh Ganu <[email protected]>
2024-11-14lib: rsa: Set conventional salt length RSA-PSS parameterLoic Poulain
RFC 3447 says that Typical salt length are either 0 or the length of the output of the digest algorithm, RFC 4055 also recommends hash value length as the salt length. Moreover, By convention, most of the signing infrastructures/libraries use the length of the digest algorithm (such as google cloud kms: https://cloud.google.com/kms/docs/algorithms). If the salt-length parameter is not set, openssl default to the maximum allowed value, which is a openssl 'specificity', so this works well for local signing, but restricts compatibility with other engines (e.g pkcs11/libkmsp11): ``` returning 0x71 from C_SignInit due to status INVALID_ARGUMENT: at rsassa_pss.cc:53: expected salt length for key XX is 32, but 478 was supplied in the parameters Could not obtain signature: error:41000070:PKCS#11 module::Mechanism invalid ``` To improve compatibility, we set the default RSA-PSS salt-length value to the conventional one. A further improvement could consist in making it configurable as signature FIT node attribute. rfc3447: https://datatracker.ietf.org/doc/html/rfc3447 rfc4055: https://datatracker.ietf.org/doc/html/rfc4055 Signed-off-by: Loic Poulain <[email protected]>
2024-11-14lwip: fix code style issuesJerome Forissier
Fix various code style issues in the lwIP code. Reported-by: Tom Rini <[email protected]> Signed-off-by: Jerome Forissier <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2024-11-13lib: vsprintf: fix API buildHeinrich Schuchardt
Avoid a build failure when building with CONFIG_API=y, CONFIG_EXAMPLES=y: lib/vsprintf.c:312:14: warning: ‘device_path_string’ defined but not used [-Wunused-function] 312 | static char *device_path_string(char *buf, char *end, void *dp, int field_width, | ^~~~~~~~~~~~~~~~~~ Fixes: 64b5ba4d293a ("efi_loader: make device path to text protocol customizable") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-11-13Merge patch series "lib: uuid: fix uuid_str_to_le_bin() on 32-bit"Tom Rini
Heinrich Schuchardt <[email protected]> says: The lib_test_uuid_to_le and lib lib_test_dynamic_uuid tests fail on 32-bit systems. But we never caught this in our CI because we never ran any of our C unit tests on 32-bit. Enable CONFIG_UNIT_TEST on qemu_arm_defconfig. hextoul() cannot convert a string to a 64-bit number on a 32-bit system. Use the new function hextoull() instead. Link: https://lore.kernel.org/r/[email protected]
2024-11-13lib: uuid: fix uuid_str_to_bin() on 32-bitHeinrich Schuchardt
hextoul() cannot convert a string to a 64-bit number on a 32-bit system. Use function hextoull() instead. Reported-by: Patrick Delaunay <[email protected]> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Caleb Connolly <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Patrick Delaunay <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]>
2024-11-13lib: uuid: fix uuid_str_to_le_bin() on 32-bitHeinrich Schuchardt
hextoul() cannot convert a string to a 64-bit number on a 32-bit system. Use function hextoull() instead. Reported-by: Patrick Delaunay <[email protected]> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Caleb Connolly <[email protected]> Tested-by: Patrick Delaunay <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-11-13lib: provide function hextoull()Heinrich Schuchardt
We often convert hexadecimal strings to hextoull(). Provide a wrapper function to simple_strtoull() that does not require specifying the radix. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-11-12Merge patch series "Enable https for wget"Tom Rini
Ilias Apalodimas <[email protected]> says: Hi all, This is a respin of [1] adding https support to wget. In short patch#1 enables the crypto algorithms we need in mbedTLS patches#2, #3 enable anf fix the lwIP part we need patch#4 is adding https:// parsing support in our wget patch#5 is making https:// the default for QEMU lwip defconfig so people can easily test and finaly patch#6 updates our documentation [1] https://lore.kernel.org/u-boot/[email protected]/ Link: https://lore.kernel.org/r/[email protected]
2024-11-12net: lwip: Add Support Server Name Indication supportJavier Tia
SNI, or Server Name Indication, is an addition to the TLS encryption protocol that enables a client device to specify the domain name it is trying to reach in the first step of the TLS handshake, preventing common name mismatch errors and not reaching to HTTPS server that enforce this condition. Since most of the websites require it nowadays add support for it. It's worth noting that this is already sent to lwIP [0] [0] https://github.com/lwip-tcpip/lwip/pull/47 Signed-off-by: Javier Tia <[email protected]> Reviewed-by: Jerome Forissier <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-11-12net: lwip: Update lwIP for mbedTLS > 3.0 support and enable httpsJavier Tia
The current code support mbedTLS 2.28. Since we are using a newer version in U-Boot, update the necessary accessors and the lwIP codebase to work with mbedTLS 3.6.0. It's worth noting that the patches are already sent to lwIP [0] While at it enable LWIP_ALTCP_TLS and enable TLS support in lwIP [0] https://github.com/lwip-tcpip/lwip/pull/47 Signed-off-by: Javier Tia <[email protected]> Acked-by: Jerome Forissier <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-11-12mbedtls: Enable TLS 1.2 supportIlias Apalodimas
Since lwIP and mbedTLS have been merged we can tweak the config options and enable TLS1.2 support. Add RSA and ECDSA by default and enable enough block cipher modes of operation to be comatible with modern TLS requirements and webservers Reviewed-by: Raymond Mao <[email protected]> Acked-by: Jerome Forissier <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-11-11lmb: Add basic io_lmb functionalityJanne Grunau
These functions can be used with struct lmb pointers and will be used to manage IOVA space in the apple_dart iommu driver. This restores part of the pointer base struct lmb API from before commit ed17a33fed29 ("lmb: make LMB memory map persistent and global"). io_lmb_add() and io_lmb_free() can trivially reuse exisiting lmb functions. io_lmb_setup() is separate for unique error log messages. io_lmb_alloc() is a simplified copy of _lmb_alloc_base() since the later has unused features and internal use of the global LMB memory map. Signed-off-by: Janne Grunau <[email protected]>
2024-11-11lmb: cosmetic: reorder functions and global LMB variableJanne Grunau
Low lovel LMB functionality will be used to manage IOVA space in the Apple dart iommu driver. This reordering ensures that those function can not access the global LMB memory map variable. Signed-off-by: Janne Grunau <[email protected]>
2024-11-11lmb: Do not use global LMB variable in _lmb_free()Janne Grunau
It will be re-used with a lmb list pointer as argument for IOVA allocations in the apple_dart iommu driver. Reviewed-by: Tom Rini <[email protected]> Signed-off-by: Janne Grunau <[email protected]>
2024-11-09efi_loader: Drop sandbox PXE architectureSimon Glass
Rather than returning 0, just return an error, since sandbox is not used with PXE at present. Signed-off-by: Simon Glass <[email protected]>
2024-11-09sandbox: Report host default-filename in native modeSimon Glass
When the --native flag is given, pretend to be running the host architecture rather than sandbox. Allow the same control for PXE too. Signed-off-by: Simon Glass <[email protected]>
2024-11-09efi_loader: Move get_efi_pxe_arch() to efi_helperSimon Glass
Move this function from the EFI bootmeth to the common efi_helper file. No functional change is intended. Signed-off-by: Simon Glass <[email protected]>
2024-11-09efi: Move default filename to a functionSimon Glass
Use a function to obtain the device EFI filename, so that we can control how sandbox behaves. Signed-off-by: Simon Glass <[email protected]>
2024-11-09efi_loader: Add a test appSimon Glass
Add a simple app to use for testing. This is intended to do whatever it needs to for testing purposes. For now it just prints a message and exits boot services. There was a considerable amount of discussion about whether it is OK to call exit-boot-services and then return to U-Boot. This is not normally done in a real application, since exit-boot-services is used to completely disconnect from U-Boot. For now, this part is skipped. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-11-09efi_loader: Change efi_dp_from_mem() to use sizeMoritz Fischer
All call sites are using size rather than end addresses, so instead - as previously done - calculating an end address everywhere, just modify the function to use size and internally calculate the end address Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Patrick Wildt <[email protected]> Signed-off-by: Moritz Fischer <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-11-09lmb: Drop extra 16KB of stack spaceSimon Glass
There is already a defined stack-size which is used to reserve space for the stack. It is confusing to add more in the lmb module, since then the memory map (with meminfo command) seems to have a hole in it. Drop this unnecessary feature. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a way to efficiently filter an alistSimon Glass
Unlike linked lists, it is inefficient to remove items from an alist, particularly if it is large. If most items need to be removed, then the time-complexity approaches O(n2). Provide a way to do this efficiently, by working through the alist once and copying elements down. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a function to empty the listSimon Glass
Sometimes it is useful to empty the list without de-allocating any of the memory used, e.g. when the list will be re-populated immediately afterwards. Add a new function for this. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add for-loop helpersSimon Glass
Add some macros which permit easy iteration through an alist, similar to those provided by the 'list' implementation. Signed-off-by: Simon Glass <[email protected]>
2024-11-03alist: Add a way to get the next elementSimon Glass
Add a new function which returns the next element after the one provided, if it exists in the list. Signed-off-by: Simon Glass <[email protected]>
2024-11-01Merge patch series "fs: ext4: implement opendir, readdir, closedir"Tom Rini
Heinrich Schuchardt <[email protected]> says: With this series opendir, readdir, closedir are implemented for ext4. These functions are needed for the UEFI sub-system to interact with the ext4 file system. To reduce code growth the functions are reused to implement the ls command for ext4. A memory leak in ext4fs_exists is resolved. ext4fs_iterate_dir is simplified by removing a redundant pointer copy. Link: https://lore.kernel.org/r/[email protected]
2024-11-01efi_loader: fix GetInfo and SetInfoHeinrich Schuchardt
* Some of our file system drivers cannot report a file size for directories. Use a dummy value in this case. * For SetInfo the UEFI spec requires to ignore the file size field. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2024-11-01lmb: remove __maybe_unused from lmb_map_update_notifyHeinrich Schuchardt
Function lmb_map_update_notify() is always referenced. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-11-01acpi_table: Fix coverity defect in acpi_write_spcrPatrick Rudolph
Fix "Integer handling issues (SIGN_EXTENSION)" in newly added code: Cast serial_info.reg_offset to u64 to prevent an integer overflow when shifted too many bits to the left. Currently this never happens as the shift is supposed to be less than 4. Signed-off-by: Patrick Rudolph <[email protected]>
2024-10-31Merge tag 'efi-2025-01-rc2' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request efi-2025-01-rc2 Documentation: * include semihosting and K3 boards only once in table of contents * include file-system API into HTML docs * describe struct ext2_inode * update Python requirements UEFI: * mark local functions static * simplify efi_free_pages() * pass correct end address value to efi_dp_from_mem() * fix typos in HII test and eficonfig command
2024-10-31lib: efi_loader: Fix efi_dp_from_mem() callsMoritz Fischer
The function expects an end address but is being called with an size instead. Fixes: 6422820ac3 ("efi_loader: split unrelated code from efi_bootmgr.c") Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Moritz Fischer <[email protected]> Reviewed-by: Patrick Wildt <[email protected]>
2024-10-31efi_loader: Make tcg2_uninit() staticIlias Apalodimas
This function is only used locally, so make it static and quiesce the W=1 warning Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-10-30efi_loader: Remove unused diskidIlias Apalodimas
That variable is defined and assigned a value in two functions but it's never used. Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-10-30efi_loader: Mark static functions in smbiosdumpIlias Apalodimas
Mark functions that are only used locally as static and quiesce W=1 warnings Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-10-30efi_loader: Mark static function in dumpdtbIlias Apalodimas
A few functions are only used locally but miss the 'static' keyword. Add it and quiesce W=1 build wanrings Signed-off-by: Ilias Apalodimas <[email protected]>
2024-10-30efi_loader: Mark efi_bootmgr_release_uridp as staticIlias Apalodimas
This is only used locally so make it static Suggested-by: Andy Shevchenko <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]>
2024-10-30efi_loader: Simplify efi_free_pages()Ilias Apalodimas
We currently call efi_free_pages() with a notify flag and explicitly update the efi memory map. That's not needed as lmb_free_flags() will do that for us if the LMB_NONOTIFY flag is removed Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-10-30lmb: Correctly unmap memory after notificationsIlias Apalodimas
We never unmap the memory used to update the EFI memory map after notifications Fixes: commit 2f6191526a13 ("lmb: notify of any changes to the LMB memory map") Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-10-30efi_loader: fix CONFIG_EFI_HTTP dependenciesHeinrich Schuchardt
CONFIG_CMD_DNS and CONFIG_CMD_WGET depend on CONFIG_CMD_NET. CONFIG_CMD_NET depends on CONFIG_NET or CONFIG_NET_LWIP. We shall only enable CONFIG_EFI_HTTP if there is network support. We have to select CONFIG_CMD_NET. Fixes: d7d07a8b508b ("efi_loader: support boot from URI device path") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-10-30efi_selftest: make HII test data staticHeinrich Schuchardt
Variables that are only used locally in a module should not be exported. * Make the HII test data variables static. * Remove unused GUIDs. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-10-30efi_selftest: fix typo 'got languages' in HII testHeinrich Schuchardt
%s/got languages are/Available languages:/ Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2024-10-29lmb: Remove lmb_alloc_flags()Ilias Apalodimas
lmb_alloc_flags() & lmb_alloc_base_flags() are just a wrappers for _lmb_alloc_base(). Since the only difference is the max address of the allowed allocation which _lmb_alloc_base() already supports with the LMB_ALLOC_ANYWHERE flag, remove one of them. Keep the lmb_alloc_base_flags() which also prints an error on failures and adjust efi_allocate_pages() to only use one of them. While at it clean up the duplicate function description from the header file. Signed-off-by: Ilias Apalodimas <[email protected]>
2024-10-29lmb: Simplify lmb_should_notify usageIlias Apalodimas
We never call lmb_map_update_notify() without checking the result of lmb_should_notify(). Instead of running that function everytime fold it in there and add the additional flags parameter Signed-off-by: Ilias Apalodimas <[email protected]>
2024-10-29lmb: Fix lmb_add_region_flags() return codes and testingIlias Apalodimas
The function description says this should return 0 or -1 on failures. When regions coalesce though this returns the number of coalescedregions which is confusing and requires special handling of the return code. On top of that no one is using the number of coalesced regions. So let's just return 0 on success and adjust our selftests accordingly Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Caleb Connolly <[email protected]>
2024-10-29lmb: add a check to prevent memory overrunSughosh Ganu
When printing the LMB flags for a memory region, there is a need to check that the array index that is computed is a sane value. Put a noisy assert in case this check fails, as that implies something with the LMB code is not working as expected. Reported-by: Coverity (CID 510463) Signed-off-by: Sughosh Ganu <[email protected]>