summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2024-09-21efi_loader: fix some function descriptionsHeinrich Schuchardt4-4/+4
* The function name must be provided in the description. * The function name must match the name used in the description. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-08-24efi_loader: allow EFI_LOADER_BOUNCE_BUFFER on all architecturesHeinrich Schuchardt1-1/+0
There not only ARM64 boards but also RISC-V boards that require a bounce buffer to read block devices. Drop the architecture restriction. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-08-24efi_loader: fix memory freeing in efi_get_dp_from_boot()Ilias Apalodimas1-2/+3
efi_get_var() allocates memory which must be freed after the variable is used. Since the device path is duplicated after we deserialize the load options free the memory used for the variable payload Fixes: db61e70e0d2a efi_loader: efi_dp_from_lo() should skip VenMedia node Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinric Schuchardt <heinrich.schuchardt@canonical.com>
2024-08-11efi_loader: correct description of efi_get_distro_fdt_nameHeinrich Schuchardt1-1/+1
Use the correct function name. 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-08-11efi_loader: use list_count_nodes() in efi_protocols_per_handle()Heinrich Schuchardt1-5/+1
Simplify the code by using the list_count_nodes() function. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-08-05fdt: Correct condition for bloblist existingSimon Glass1-2/+10
On some boards, the bloblist is created in SPL once SDRAM is ready. It cannot be accessed until that point, so is not available early in SPL. Add a condition to avoid a hang in this case. This fixes a hang in chromebook_coral Fixes: 70fe2385943 ("fdt: Allow the devicetree to come from a bloblist") Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Raymond Mao <raymond.mao@linaro.org>
2024-07-31efi_memory: get the efi_mem_list node directlySughosh Ganu1-17/+8
Use the list_for_each_entry() API to get the efi_mem_list node directly, instead of making an additional call to list_entry(). Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-31efi_memory: avoid possible null pointer dereferenceSughosh Ganu1-1/+2
Populate the previous memory descriptor node pointer only after it's parent struct has been initialised. The compiler fixes this logic to do the right thing, but it is better to have correct code in place. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-31efi_memory: use list_count_nodes() to count list entriesSughosh Ganu1-3/+2
Use the API function list_count_nodes() to count the number of EFI memory map entries. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-07-31efi_loader: correct check in efi_load_option_dp_join()Heinrich Schuchardt1-1/+1
After assigning to *dp we must check this value and not dp. Addresses-Coverity-ID: 501792 Control flow issues (DEADCODE) Fixes: 58bef195f94e ("cmd: eficonfig: add support for setting fdt") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-31smbios: add extended Extended BIOS ROM SizeHeinrich Schuchardt1-1/+8
U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has a field Extended BIOS ROM Size since version 3.1. BIOS ROM sizes of 16 MiB or above must be written to this field. Add and fill the missing field. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-07-31efi_loader: add /dtbs search pathCaleb Connolly1-0/+3
Add an additional search path /dtbs, this is where dtbs are installed on postmarketOS and potentially other distros. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-31efi_loader: require EFI boot manager for EBBR complianceHeinrich Schuchardt1-0/+1
A system has to support booting via the boot manager to be EBBR compliant. See the reference to variables Boot#### in the specification. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-31efi_loader: adjust config options for capsule updatesIlias Apalodimas1-0/+1
EFI_IGNORE_OSINDICATIONS is used to ignore OsIndications if setvariable at runtime is not supported and allow the platform to perform capsule updates on disk. With the recent changes boards can conditionally enable setvariable at runtime using EFI_RT_VOLATILE_STORE. Let's make that visible in our Kconfigs and enable EFI_IGNORE_OSINDICATIONS when set variable at runtime is disabled. Since EFI_RT_VOLATILE_STORE needs help from the OS to persist the variables, allow users to ignore OsIndications even if setvariable at runtime is enabled. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-07-19zlib: Fix big performance regressionChristophe Leroy2-12/+40
Commit 340fdf1303dc ("zlib: Port fix for CVE-2016-9841 to U-Boot") brings a big performance regression in inflate_fast(), which leads to watchdog timer reset on powerpc 8xx. It looks like that commit does more than what it describe, it especially removed an important optimisation that was doing copies using halfwords instead of bytes. That unexpected change multiplied by almost 4 the time spent in inflate_fast() and increased by 40% the overall time needed to uncompress linux kernel image. So partially revert that commit but keep post incrementation as it is the initial purpose of said commit. [trini: Combine assorted patches in to this one, just restoring the performance commit] Fixes: 340fdf1303dc ("zlib: Port fix for CVE-2016-9841 to U-Boot") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Acked-by: Michal Simek <michal.simek@amd.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-07-19efi_loader: Fix typo in EFI_RT_VOLATILE_STORE descriptionMichal Simek1-1/+1
Fix typo in EFI_RT_VOLATILE_STORE description. Fixes: c28d32f946f0 ("efi_loader: conditionally enable SetvariableRT") Signed-off-by: Michal Simek <michal.simek@amd.com>
2024-07-19efi_loader: find distro device-path for media devicesHeinrich Schuchardt2-15/+20
The auto-generated load options for media device do not contain a partition node. We cannot expect the simple file protocol here. Get the partition device-path via the loaded image protocol. Fixes: e91b68fd6b83 ("efi_loader: load distro dtb in bootmgr") Reported-by: E Shattow <lucent@gmail.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Tested-by: E Shattow <lucent@gmail.com>
2024-07-15Merge patch series "api: Remove duplicate newlines"Tom Rini58-336/+0
This removes a number of duplicate newlines throughout the codebase.
2024-07-15lib: Remove duplicate newlinesMarek Vasut58-336/+0
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-07-14efi_loader: print device-tree in dtbdump.efiHeinrich Schuchardt1-0/+261
The dtbdump.efi binary can be used for testing the EFI_DT_FIXUP_PROTOCOL. It provides a command to load a file and have it fixed up and a command to save the resulting file. Add a command 'dump' for displaying the device-tree. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-07-14scripts/Makefile.lib: EFI: Use capsule CRT instead of ESL fileJonathan Humphreys1-5/+7
The EFI Capsule ESL file (EFI Signature List File) used for authentication is a binary generated from the EFI Capsule public key certificate. Instead of including it in the source repo, automatically generate it from the certificate file during the build process. Currently, sandbox is the only device using this, so removed its ESL file and set the (new) CONFIG_EFI_CAPSULE_CRT_FILE config to point to its public key certificate. Signed-off-by: Jonathan Humphreys <j-humphreys@ti.com>
2024-07-05Revert "Revert "Merge patch series "zlib: Address CVE-2016-9841"""Tom Rini6-141/+84
Now that the release has happened, bring back the update to zlib. This reverts commit bbacdd3ef7762fbdeab43ceea5205d1fd0f25bbd. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-07-05Fix Kconfig coding style from spaces to tabAnand Moon1-1/+1
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Anand Moon <linux.amoon@gmail.com>
2024-07-04smbios: Correct error handling when writing tablesSimon Glass1-2/+8
Since write_smbios_table() returns an address, we cannot use it to return and error number. Also, failing on sysinfo_detect() breaks existing boards, e.g. chromebook_link Correct this by logging and swallowing the error. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: a5a57562856 ("lib: smbios: Detect system properties via...")
2024-07-04initcall: Correct use of relocation offsetSimon Glass1-2/+4
The relocation offset can change in some initcall sequences. Handle this and make sure it is used for all debugging statements in init_run_list() Update the trace test to match. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-07-03Merge patch series "m68k: Implement a default flush_dcache_all"Tom Rini2-7/+13
Tom Rini <trini@konsulko.com> says: Prior to this series we had some de-facto required cache functions that were either unimplemented on some architectures or differently named. This would lead in some cases to having multiple "weak" functions available as well. Rework things so that an architecture must provide these functions and it is up to that architecture if a "weak" default function makes sense, or not.
2024-07-03acpi: set creator_revision in acpi_fill_headerHeinrich Schuchardt2-2/+1
We should have a single place where we write the default value to the creator revision field. If we ever will have any table created by another tool, we can overwrite the value afterwards. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-07-01Merge branch 'next'Tom Rini31-849/+1774
2024-06-30Revert "Merge patch series "zlib: Address CVE-2016-9841""Tom Rini6-84/+141
This series brings our zlib code more up to date. However, it drops an important performance improvement that is required on some of our supported platforms in order to boot Linux before the watchdog resets the system. Furthermore, the "post increment" version of this performance loop was not tested, so while we can fix it, it would then require re-testing all platforms. At this point in time, we will revert updating zlib (which has had a potential security issue since 2016) and fix this in the v2024.10 release. This reverts commit 4914263c9a14315390d3ccc4816cf3a94cfd156d, reversing changes made to ef8ef5f77c9a998f76a48277a883af1645b54117. Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-06-30tpm: allow the user to select the compiled algorithmsIlias Apalodimas2-6/+40
Simon reports that after enabling all algorithms on the TPM some boards fail since they don't have enough storage to accommodate the ~5KB growth. The choice of hash algorithms is determined by the platform and the TPM configuration. Failing to cap a PCR in a bank which the platform left active is a security vulnerability. It might allow unsealing of secrets if an attacker can replay a good set of measurements into an unused bank. If MEASURED_BOOT or EFI_TCG2_PROTOCOL is enabled our Kconfig will enable all supported hashing algorithms. We still want to allow users to add a TPM and not enable measured boot via EFI or bootm though and at the same time, control the compiled algorithms for size reasons. So let's add a function tpm2_allow_extend() which checks the TPM active PCRs banks against the one U-Boot was compiled with. We only allow extending PCRs if the algorithms selected during build match the TPM configuration. It's worth noting that this is only added for TPM2.0, since TPM1.2 is lacking a lot of code at the moment to read the available PCR banks. We unconditionally enable SHA1 when a TPM is selected, which is the only hashing algorithm v1.2 supports. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> # chromebook-link
2024-06-30tpm: Untangle tpm2_get_pcr_info()Ilias Apalodimas3-51/+62
This function was used on measured boot to retrieve the number of active PCR banks and was designed to work with the TCG protocols. Since we now have the need to retrieve the active PCRs outside the measured boot context -- e.g use the in the command line, decouple the function. Create one that will only adheres to TCG TSS2.0 [0] specification called tpm2_get_pcr_info() which can be used by the TPM2.0 APIs and a new one that is called from the measured boot context called tcg2_get_pcr_info() [0] https://trustedcomputinggroup.org/wp-content/uploads/TSS_Overview_Common_Structures_Version-0.9_Revision-03_Review_030918.pdf Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-30efi_loader: remove unneeded header filesIlias Apalodimas1-1/+0
efi_tcg2.h already includes tpm-v2.h. Remove it Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-30tpm: Move TCG functions into a separate fileIlias Apalodimas3-674/+698
The previous patch is moving the TPM TCG headers in their own file for a cleaner API. Move the functions in their own file as well. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-30tpm: Move TCG headers into a separate fileIlias Apalodimas1-0/+1
commit 97707f12fdab ("tpm: Support boot measurements") moved out code from the EFI subsystem into the TPM one to support measurements when booting with !EFI. Those were moved directly into the TPM subsystem and in the tpm-v2.c library. In hindsight, it would have been better to move it in new files since the TCG2 is governed by its own spec, it's overeall cleaner and also easier to enable certain parts of the TPM functionality. So let's start moving the headers in a new file containing the TCG specific bits. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-30efi_selftest: can't have measured device-tree with kaslr-seedHeinrich Schuchardt1-0/+7
Test that we don't have a /chosen/kaslr-seed property if we measure the device-tree. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-28tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOLSimon Glass1-4/+0
It does not make sense to enable all SHA algorithms unless they are needed. It bloats the code and in this case, causes chromebook_link to fail to build. That board does use the TPM, but not with measured boot, nor EFI. Since EFI_TCG2_PROTOCOL already selects these options, we just need to add them to MEASURED_BOOT as well. Note that the original commit combines refactoring and new features, which makes it hard to see what is going on. Fixes: 97707f12fda tpm: Support boot measurements Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2024-06-24Merge tag 'v2024.07-rc5' into nextTom Rini4-64/+76
Prepare v2024.07-rc5
2024-06-24efi_loader: fix the return values on efi_tcgIlias Apalodimas1-57/+69
A while back we moved the core functions of the EFI TCG protocol to the TPM APIs in order for them to be used with bootm, booti etc. Some prototypes changed from returning efi_status_t to int, which is more appropriate for the non-EFI APIs. However, some of the EFI callsites never changed and we ended up assigning the int value to efi_status_t. This is unlikely to cause any problems, apart from returning invalid values on failures and violating the EFI spec. Let's fix them by looking at the new return code and map it to the proper EFI return code on failures. Fixes: commit 97707f12fdab ("tpm: Support boot measurements") Fixes: commit d6b55a420cfc ("efi_loader: startup the tpm device when installing the protocol") Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-24tpm: fix the return code, if the eventlog buffer is fullIlias Apalodimas1-1/+1
We currently return 'No space left on device' if the eventlong buffer we allocated is not enough. On a similar check later on that function during the call to tcg2_log_init() we return 'No buffer space available'. So switch both error codes to -ENOBUFS since we are always checking a buffer and not a device. Fixes: commit 97707f12fdab ("tpm: Support boot measurements") Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-20lib: smbios: Detect system properties via SYSINFO IDsMichal Simek1-8/+26
Code is pretty much supports only DT properties and completely ignore information coming from sysinfo driver. Code is calling smbios_add_prop() which calls with smbios_add_prop_si(SYSINFO_ID_NONE). But SYSINFO_ID_NONE can't differentiate different entries from sysinfo driver. That's why introduce separate SYSINFO macros which can be used in sysinfo driver and passed to smbios structure. Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-06-20lib: smbios: Let detect the system via sysinfoMichal Simek1-1/+7
Currently code looks like that it sysinfo drivers are supported but actually none checking that system is detected. That's why call sysinfo_detect() to make sure that priv->detected in sysinfo uclass is setup hence information from driver can be passed to smbios. Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-06-19efi_loader: avoid duplicate weak invalidate_icache_all()Heinrich Schuchardt2-7/+13
If multiple weak implementations of a weak function exist, it is unclear which one the linker should chose. cmd/cache.c already defines a weak invalidate_icache_all(). We don't need a call to invalidate_icache_all() on x86. ARM, RISC-V, and Sandbox provide an implementation. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-18smbios: only look for a SYSINFO udevice if SYSINFO support is enabledQuentin Schulz1-1/+1
If SYSINFO support isn't enabled, it's a given that uclass_first_device for UCLASS_SYSINFO will not find anything, therefore let's skip the test entirely. This allows to get rid of the following debug message that may be confusing: Cannot find uclass for id 118: please add the UCLASS_DRIVER() declaration for this UCLASS_... id Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-06-16tpm: measure DTB in PCR1 instead of PCR0Ilias Apalodimas1-1/+1
The PC client spec [0], doesn't describe measurements for DTBs. It does describe what do to for ACPI tables though. There is a description for ACPI in 3.3.4.1 PCR[0] – SRTM, POST BIOS, and Embedded Drivers and they explicitly mention ACPI in there. There's no mention of ACPI in 3.3.4.2 PCR[1] – Host Platform Configuration. However, in Figure 6 -- PCR Mapping of UEFI Components ACPI is shown in PCR1. The general description also mentions PCR0 is for code and PCR1 is for data such as ACPI and SMBIOS. So let's switch over the DTB measurements to PCR1 which seems a better fit. [0] https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Eddie James <eajames@linux.ibm.com>
2024-06-14cmd: move ELF load and boot to lib/elf.cMaxim Moskalets1-0/+54
Loading and running the ELF image is the responsibility of the library and should not be associated with the command line interface. It is also required to run ELF images from FIT with the bootm command so as not to depend on the command line interface. Signed-off-by: Maxim Moskalets <maximmosk4@gmail.com>
2024-06-14Merge patch series "efi_loader: select BLK not depends on BLK"Tom Rini1-1/+1
Tom Rini <trini@konsulko.com> says: Rework how the BLK symbol is used now that so much DM migration has been completed.
2024-06-14efi_loader: select BLK not depends on BLKTom Rini1-1/+1
The BLK symbol is used both for "we have a block device subsystem enabled" and "we need to utilize the block device library functions". In the case of efi_loader, it is the case of "we need to utilize the block device library", so select rather than depends on it. In turn, also disable EFI_LOADER on platforms which did not have it on previously due to a lack of block devices. They can enable it themselves if desired. Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-06-10efi_loader: Fix capsule_esl.dtsi.in comment styleMichal Simek1-2/+2
Comment is not kernel-doc format that's why don't label it like that and also fix indentation to have proper multiline comment. Signed-off-by: Michal Simek <michal.simek@amd.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-06-10efi_loader: Fix EFI_VARIABLE_APPEND_WRITE hash checkWeizhao Ouyang1-3/+3
According to UEFI v2.10 spec section 8.2.6, if a caller invokes the SetVariables() service, it will produce a digest from hash(VariableName, VendorGuid, Attributes, TimeStamp, DataNew_variable_content), then the firmware that implements the SetVariable() service will compare the digest with the result of applying the signer’s public key to the signature. For EFI variable append write, efitools sign-efi-sig-list has an option "-a" to add EFI_VARIABLE_APPEND_WRITE attr, and u-boot will drop this attribute in efi_set_variable_int(). So if a caller uses "sign-efi-sig-list -a" to create the authenticated variable, this append write will fail in the u-boot due to "hash check failed". This patch resumes writing the EFI_VARIABLE_APPEND_WRITE attr to ensure that the hash check is correct. And also update the "test_efi_secboot" test case to compliance with the change. Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
2024-06-10efi_loader: rename struct efi_initrd_dp to efi_lo_dp_prefixHeinrich Schuchardt2-2/+2
As we now also store device-tree device-paths in load options rename struct efi_initrd_dp to efi_lo_dp_prefix. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>