aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2024-02-02smbios: correctly name Structure Table Maximum Size fieldHeinrich Schuchardt4-7/+7
In the SMBIOS 3 entry point the Structure Table Maximum Size field was incorrectly named max_struct_size. A Maximum Structure Size field only exists in the SMBIOS 2.1 entry point and has a different meaning. Call the Structure Table Length field table_maximum_size. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02smbios: do not determine maximum structure sizeHeinrich Schuchardt1-6/+1
Only the SMBIOS 2.1 entry point has a field for the maximum structure size. As we have switched to an SMBIOS 3 entry point remove the superfluous calculation. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02smbios: correctly fill chassis handleHeinrich Schuchardt1-0/+2
The chassis handle field in the type 2 structure must point to the handle of the type 3 structure. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-02-02smbios: if a string value is unknown, use string number 0Heinrich Schuchardt1-15/+18
The SMBIOS specification describes: "If a string field references no string, a null (0) is placed in that string field." Accordingly we should avoid writing a string "Unknown" to the SMBIOS table. dmidecode displays 'Not Specified' if the string number is 0. Commit 00a871d34e2f ("smbios: empty strings in smbios_add_string()") correctly identified that strings may not have length 0 as two consecutive NULs indentify the end of the string list. But the suggested solution did not match the intent of the SMBIOS specification. Fixes: 00a871d34e2f ("smbios: empty strings in smbios_add_string()") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-02-02smbios: Fix table when no string is presentMatthias Brugger1-0/+4
When no string is present in a table, next_ptr points to the same location as eos. When calculating the string table length, we would only reserve one \0. By spec a SMBIOS table has to end with two \0\0 when no strings a present. Signed-off-by: Matthias Brugger <mbrugger@suse.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02smbios: get_str_from_dt() - add sysinfo_id descriptionHeinrich Schuchardt1-0/+1
Add description for parameter sysinfo_id of function get_str_from_dt(). Fixes: 07c9e683a484 ("smbios: Allow a few values to come from sysinfo") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-02-02lib: smbios_entr() use logical or for booleansHeinrich Schuchardt1-1/+1
As a matter of programming style use logical or to combine two boolean results. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-29efi_loader: check efi_get_variable_int return valueMasahisa Kojima1-5/+5
efi_get_variable_int() may fail, the buffer should be cleared before using it. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Addresses-Coverity-ID: 478333 ("Error handling issues")
2024-01-29efi_loader: replace find_smbios_table by library functionHeinrich Schuchardt1-18/+1
The code in find_smbios_table() is redundant to efi_get_configuration_table(). Replace it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-29efi_loader: export efi_get_configuration_tableHeinrich Schuchardt1-3/+3
In multiple places we need a function to find an EFI configuration table. Rename get_config_table() to efi_get_configuration_table() and export it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-29efi_selftest: add missing line feed in efi_selftest_miniapp_exitHeinrich Schuchardt1-1/+1
If an error occurs we may see an output like: EFI application calling Exit Could not open loaded image protocolLoaded image protocol missing Add the missing line feed. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-26lib: support SMBIOS3 table in uuid_guid_get_str()Heinrich Schuchardt1-0/+4
As we support installing SMBIOS3 tables in U-Boot we need to add this GUID to the translation table used buy uuid_guid_get_str(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2024-01-26efi_loader: migrate SMBIOS 3.0 entry point structure for measurementMasahisa Kojima3-62/+63
Current U-Boot only supports the SMBIOS 3.0 entry point structure. TCG2 measurement code should migrate to SMBIOS 3.0 entry point structure. efi_selftest tcg2 test also needs to be updated, and expected PCR[1] result is changed since guid for SMBIOS EFI system table uses different guid SMBIOS3_TABLE_GUID instead of SMBIOS_TABLE_GUID. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-24lib: add comment in utf8_to_utf32_stream()Heinrich Schuchardt1-0/+4
The logic of utf8_to_utf32_stream() is not easy to understand. Add a comment. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: return immediately in UCLASS_EFI_LOADER removalMasahisa Kojima1-6/+10
In case of UCLASS_EFI_LOADER, EFI handles are managed by EFI application/driver, we must not delete EFI handles. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: create common function to free struct efi_disk_objMasahisa Kojima1-7/+19
Current error handling of creating raw disk/partition has following issues. - duplicate free for EFI handle, EFI handle is already freed in efi_delete_handle() - missing free for struct efi_device_path and struct efi_simple_file_system_protocol in some error paths To address those issues, this commit creates the common function to free the struct efi_disk_obj resources and calls it in case of error. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-21efi_loader: avoid pointer access after calling efi_delete_handleMasahisa Kojima1-6/+14
efi_delete_handle() calls efi_purge_handle(), then it finally frees the EFI handle. Both diskobj and handle variables in efi_disk_remove() have the same pointer, we can not access diskobj->dp after calling efi_delete_handle(). This commit saves the struct efi_device_path pointer before calling efi_delete_handle(). This commit also fixes the missing free for volume member in struct efi_disk_obj. This commit also removes the container_of() calls, and adds the TODO comment of missing efi_close_protocol() call for the parent EFI_BLOCK_IO_PROTOCOL. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-21efi_loader: auto-generate removable media boot option firstMasahisa Kojima1-7/+26
This commit auto-generates the boot option for removable block io devices followed by fixed block io devices. This is what EDK II reference implementation does. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: auto-generate boot option for each blkio deviceMasahisa Kojima1-26/+75
Current efibootmgr auto-generates the boot option for all disks and partitions installing EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, while EDK II reference implementation auto-generates the boot option for all devices installing EFI_BLOCK_IO_PROTOCOL with eliminating logical partitions. This commit modifies the efibootmgr to get aligned to EDK II. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: rename check_disk_has_default_file functionMasahisa Kojima1-5/+8
check_disk_has_default_file() function checks if the architecture-specific default file exists on the block device, and fills the default file device path if it exists. Rename the function name to fill_default_file_path(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-18smbios: fix matching issues for table typesIlias Apalodimas1-17/+28
commit 738b34668f28 ("smbios: Fallback to the default DT if sysinfo nodes are missing") allowed the code to fallback and fill in SMBIOS tables with properties from the compatible and product nodes of the DT, in case the 'smbios,sysinfo' node is missing. That works fine for Type1/2 tables, but for other types we need to match the smbios,sysinfo subnode name as well. So add it to the smbios_ctx and check it during the sysinfo <-> DT mathcing Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-18smbios: shorten sysinfo_str declarations and useIlias Apalodimas1-6/+6
sysinfo_str is a bit too long and makes indentation weird. Shorten it to si_str. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-18smbios: buffer overflow when zeroing entry pointHeinrich Schuchardt1-2/+2
A SMBIOS 3 entry point has a different length than an SMBIOS 2.1 entry point. Fixes: 70924294f375 ("smbios: Use SMBIOS 3.0 to support an address above 4GB") Fixes: 1c5f6fa3883d ("smbios: Drop support for SMBIOS2 tables") Addresses-Coverity-ID: 477212 ("Wrong sizeof argument") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-18lib: rsa: Allow legacy URI specification without "pkcs11:"Csókás Bence1-12/+30
But emit a warning for it. Then we can remove support when everyone had time to update their scripts, docs, CI etc. Fixes: ece85cc020 rsa: use pkcs11 uri as defined in rfc7512 Signed-off-by: Csókás Bence <csokas.bence@prolan.hu>
2024-01-18lib: rsa: Fix PKCS11 URI if one is not given in `keydir`Csókás Bence1-2/+2
If `keydir` is not present, we need to build a PKCS11 URI from just the key name. In this case, we *do* need 'pkcs11:' Fixes: ece85cc020 rsa: use pkcs11 uri as defined in rfc7512 Signed-off-by: Csókás Bence <csokas.bence@prolan.hu>
2024-01-17Merge tag 'efi-2024-04-rc1-2' of ↵Tom Rini6-491/+511
https://source.denx.de/u-boot/custodians/u-boot-efi Documentation: * add generated index to table of contents * create index entries for commands * update Python packages used to build the documentation * fix typos in dfu documentation UEFI: * split unrelated code from efi_bootmgr.c * rename CONFIG_BOOTEFI_BOOTMGR to CONFIG_EFI_BOOTMGR * net: tftp: remove explicit EFI configuration dependency * fs: remove explicit EFI configuration dependency Other: * Add Goldfish RTC driver and make it available on RISC-V QEMU
2024-01-17efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGRAKASHI Takahiro2-2/+2
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 Takahiro6-489/+509
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-16lib: smbios: remove redundant next_header()Heinrich Schuchardt1-9/+2
next_header() and get_next_header() only differ in how the const attribute is used. One function taking a const parameter and returning a non-const is good enough. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-16smbios: copy QEMU tablesHeinrich Schuchardt1-1/+3
QEMU provides SMBIOS tables with detailed information. We should not try to replicate them in U-Boot. If we want to inform about U-Boot, we can add a Firmware Inventory Information (type 45) table in future. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-13efi_loader: support fmp versioning for multi bank updateMasahisa Kojima1-15/+60
This commit stores the firmware version into the array of fmp_state structure to support the fmp versioning for multi bank update. The index of the array is identified by the bank index. This modification keeps the backward compatibility with the existing versioning feature. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13fwu: fix fwu_get_image_index interfaceMasahisa Kojima2-22/+21
The capsule update uses the DFU framework for updating storage. fwu_get_image_index() currently returns the image_index calculated by (dfu_alt_num + 1), but this is different from the image_index in UEFI terminology. Since capsule update implementation calls dfu_write_by_alt function, it is better that FWU returns the dfu_alt_num. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13efi_loader: Clean up efi_dp_append and efi_dp_concatIlias Apalodimas4-54/+26
Looking back at the initrd storing functionality, we introduced three functions, efi_dp_append_or_concatenate(), efi_dp_append/concat(). In hindsight we could have simplified that by a lot. First of all none of the functions append anything. They all allocate a new device path and concatenate the contents of two device paths in one. A boolean parameter controls the final device path -- if that's true an end node is injected between the two device paths. So let's rewrite this and make it a bit easier to read. Get rid of efi_dp_append(), efi_dp_concat() and rename efi_dp_append_or_concatenate() to efi_dp_concat(). This is far more intuitive and the only adjustment that is needed is an extra boolean argument on all callsites. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13efi_loader: remove unused members from struct efi_disk_objMasahisa Kojima1-12/+3
part and dev_index in struct efi_disk_obj are not used, let's remove it. This commit also removes the invalid structure comment for @dev, it does not exist. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-13efi: Avoid using dm_scan_other()Simon Glass3-188/+206
This function is defined by bootstd so using it precludes using that feature. Use the board_early_init_r() feature instead. Nove the affected code into a new file, so that it is clear that this relates to board init. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-13efi_loader: fix iteration of FMP protocolsMasahisa Kojima1-6/+12
If one of the FMP protocols fails when calling GetImageInfo(), populating the ESRT ends up with failure and other FMP protocols are not added to the ESRT. We should still add all other FMP protocols to the ESRT. With this commit, iteration of all FMP protocols continues even though one of the FMP protocols fails. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-11Merge tag 'u-boot-dfu-20240111' of ↵Tom Rini1-2/+2
https://source.denx.de/u-boot/custodians/u-boot-dfu u-boot-dfu-20240111 - Implement fastboot multi-response. This allows multi-line response and most importantly, finally adds support for fastboot getvar all command. - New 'fastboot oem console' command. Useful for debugging to send data the u-boot shell via fastboot - Console recording fixes
2024-01-09lib: membuff: fix readline not returning line in case of overflowIon Agorria1-2/+2
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>
2024-01-09efi_loader: provide tool to dump SMBIOS tableHeinrich Schuchardt2-0/+629
An EFI binary smbiosdump.efi is provided that can be used to check the SMBIOS table for consistency and to dump it as a file. The tool provides the following commands: check Check the SMBIOS table for consistency. exit Leave the tool. help Show available commands. save Save the SMBIOS table to a file on the EFI system partition. The file can be further analyzed with the dmidecode command line tool:: dmidecode --from-dump <filename> Specifying 'nocolor' as load option data suppresses colored output and clearing of the screen. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-09smbios: smbios.h should not import ofnode.hHeinrich Schuchardt2-0/+6
The smbios.h include does not use any definitions from ofnode.h. So don't include it. As DECLARE_GLOBAL_DATA_PTR is no longer defined via dm/of.h we need to add it to efi_smbios.c. Add now missing includes to smbios-parser.c. Remove a superfluous check comparing the sizes of the SMBIOS 2.1 and SMBIOS 3.0 anchors. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-09smbios: enable setting processor family > 0xffHeinrich Schuchardt1-2/+2
Many value of processor type exceed 0xff and have to be stored as u16 value. In the type 4 table set processor_family = 0xfe signaling that field processor_family2 is used and write the actual value into the processor_family2 field. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-09lib: smbios: verify_checksum() is duplicateHeinrich Schuchardt1-16/+2
The function verify_checksum() duplicates what table_compute_checksum() does. Replace it. table_compute_checksum() is always compiled. Fixes: 415eab0655a8 ("smbios: add parsing API") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-09lib: make table_compute_checksum() arguments constHeinrich Schuchardt1-2/+2
table_compute_checksum() does neither changes the content of the checksummed buffer nor the buffer length. Adding const to the definition makes the function wider usable. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-07acpi: Kconfig symbol CONFIG_QFW_ACPIHeinrich Schuchardt2-3/+3
We have two implementations of write_acpi_tables(). One for writing ACPI tables based on ACPI_WRITER() entries another based on copying tables from QEMU. Create a symbol CONFIG_QFW_ACPI that signifies copying ACPI tables from QEMU and use it consistently. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-07acpi: support 64bit in acpi_find_table for DSDT and FACSHeinrich Schuchardt1-5/+24
Use X_DSDT and X_FIRMWARE_CTRL if available. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Rebased on -next to use nomap: Signed-off-by: Simon Glass <sjg@chromium.org>
2024-01-07fdt: Allow the devicetree to come from a bloblistSimon Glass1-10/+34
Standard passage provides for a bloblist to be passed from one firmware phase to the next. That can be used to pass the devicetree along as well. Add an option to support this. Tests for this will be added as part of the Universal Payload work. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-07efi: Correct smbios-table installationSimon Glass1-9/+7
At present this code allocates memory when writing the tables and then unnecessarily adds another memory map when installing it. Adjust the code to allocate the tables using the normal U-Boot mechanism. This avoids doing an EFI memory allocation early in U-Boot, which may use memory that would be overwritten by a 'load' command, for example. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-01-07acpi: Write pointers to tables instead of addressesSimon Glass3-10/+10
Sandbox uses an API to map between addresses and pointers. This allows it to have (emulated) memory at zero and avoid arch-specific addressing details. It also allows memory-mapped peripherals to work. As an example, on many machines sandbox maps address 100 to pointer value 10000000. However this is not correct for ACPI, if sandbox starts another program (e.g EFI app) and passes it the tables. That app has no knowledge of sandbox's address mapping. So to make this work we want to store 10000000 as the value in the table. Add two new 'nomap' functions which clearly make this exeption to how sandbox works. This should allow EFI apps to access ACPI tables with sandbox, e.g. for testing purposes. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-07efi: smbios: Drop support for SMBIOS2 tablesSimon Glass1-3/+1
Only the v3 table is supported now, so always use this when installing the EFI table. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-07smbios: Drop support for SMBIOS2 tablesSimon Glass1-59/+17
These tables are a pain since there is no way to handle memory above 4GB. Use SMBIOS3 always. This should hopefully not create problems on x86 devices, since SMBIOS3 was released seven years ago (2015). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Peter Robinson <pbrobinson@gmail.com>