aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2021-06-28Merge tag 'v2021.07-rc5' into nextTom Rini5-5/+8
Prepare v2021.07-rc5 # gpg: Signature made Mon 28 Jun 2021 03:39:36 PM EDT # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <trini@konsulko.com>" [ultimate] # Conflicts: # configs/am64x_evm_r5_defconfig
2021-06-28arm64: Fix relocation of env_addr if POSITION_INDEPENDENT=yKunihiko Hayashi1-0/+2
If both POSITION_INDEPENDENT and SYS_RELOC_GD_ENV_ADDR are enabled, wherever original env is placed anywhere, it should be relocated to the right address. Relocation offset gd->reloc_off is calculated with SYS_TEXT_BASE in setup_reloc() and env address gd->env_addr is relocated by the offset in initr_reloc_global_data(). gd->env_addr = (orig env) + gd->reloc_off = (orig env) + (gd->relocaddr - SYS_TEXT_BASE) However, SYS_TEXT_BASE isn't always runtime base address when POSITION_INDEPENDENT is enabled. So the relocated env_addr might point to wrong address. For example, if SYS_TEXT_BASE is zero, gd->env_addr is out of memory location and memory exception will occur. There is a difference between linked address such as SYS_TEXT_BASE and runtime base address. In _main, the difference is calculated as "run-vs-link" offset. The env_addr should also be added to the offset to fix the address. gd->env_addr = (orig env) + ("run-vs-link" offset) + gd->reloc_off = (orig env) + (SYS_TEXT_BASE - _start) + (gd->relocaddr - SYS_TEXT_BASE) = (orig env) + (gd->relocaddr - _start) Cc: Marek Vasut <marex@denx.de> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Acked-by: Marek Vasut <marex@denx.de> Tested-by: Marek Vasut <marex@denx.de>
2021-06-11lib: rational: copy the rational fraction lib routines from LinuxTero Kristo3-0/+108
Copy the best rational approximation calculation routines from Linux. Typical usecase for these routines is to calculate the M/N divider values for PLLs to reach a specific clock rate. This is based on linux kernel commit: "lib/math/rational.c: fix possible incorrect result from rational fractions helper" (sha1: 323dd2c3ed0641f49e89b4e420f9eef5d3d5a881) Signed-off-by: Tero Kristo <t-kristo@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Tero Kristo <kristo@kernel.org>
2021-06-09efi_loader: fix Sphinx warningHeinrich Schuchardt1-1/+1
Brackets '[' need to be escaped to avoid a build warning lib/efi_loader/efi_image_loader.c:223: WARNING: Inline strong start-string without end-string. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-06-09efi_loader: efi_capsule_delete_file() NULL dereferenceHeinrich Schuchardt1-1/+2
If opening a file fails, the file handle pointer is not valid and must not be dereferenced. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-09efi_loader: partition numbers are hexadecimalHeinrich Schuchardt2-3/+3
If we want to address partition 15 of virtio block device 11, we have to write: virtio b:f When calling sprintf() we must use %x for the device and partition numbers. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-08display_options: Split print_buffer() into two functionsSimon Glass1-45/+70
At present print_buffer() outputs a hex dump but it is not possible to place this dump in a string. Refactor it into a top-level function which does the printing and a utility function that dumps a line into a string. This makes the code more generally useful. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Allow ctrl-c to interrupt outputSimon Glass1-4/+9
If a long hexdump is initated the user may wish to interrupt it. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Support any rowsizeSimon Glass1-3/+9
At present print_hex_dump() only supports either 16- or 32-byte lines. With U-Boot we want to support any line length up to a maximum of 64. Update the function to support this, with 0 defaulting to 16, as with print_buffer(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Add support for sandboxSimon Glass1-1/+4
The current implementation outputs an address as a pointer. Update the code to use an address instead, respecting the 32/64 nature of the CPU. Add some initial tests copied from print_test_display_buffer(), just the ones that can pass with the current implementation. Note that for this case print_hex_dump() and print_bufffer() produce the same result. For now the tests are duplicated sine we have separate functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Move API to header fileSimon Glass1-75/+3
Move the comments to the header file so people can find the function info without digging in the implementation. Fix up the code style and add an enum for the first arg. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Drop two spaces before the ASCII columnSimon Glass1-1/+1
At present with print_buffer() U-Boot shows four spaces between the hex and ASCII data. Two seems enough and matches print_hex_dump(). Change it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-07lmb: add lmb_dump_region() functionPatrick Delaunay1-20/+20
Add lmb_dump_region() function, to simplify lmb_dump_all_force(). This patch is based on Linux memblock dump function. An example of bdinfo output is: ..... fdt_size = 0x000146a0 FB base = 0xfdd00000 lmb_dump_all: memory.cnt = 0x1 memory[0] [0xc0000000-0xffffffff], 0x40000000 bytes flags: 0 reserved.cnt = 0x6 reserved[0] [0x10000000-0x10045fff], 0x00046000 bytes flags: 4 reserved[1] [0x30000000-0x3003ffff], 0x00040000 bytes flags: 4 reserved[2] [0x38000000-0x3800ffff], 0x00010000 bytes flags: 4 reserved[3] [0xe8000000-0xefffffff], 0x08000000 bytes flags: 4 reserved[4] [0xfbaea344-0xfdffffff], 0x02515cbc bytes flags: 0 reserved[5] [0xfe000000-0xffffffff], 0x02000000 bytes flags: 4 arch_number = 0x00000000 TLB addr = 0xfdff0000 .... Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-07lmb: add lmb_is_reserved_flagsPatrick Delaunay1-2/+7
Add a new function lmb_is_reserved_flags to check if an address is reserved with a specific flags. This function can be used to check if an address was reserved with no-map flags with: lmb_is_reserved_flags(lmb, addr, LMB_NOMAP); Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-06-07lmb: Add support of flags for no-map propertiesPatrick Delaunay1-9/+43
Add "flags" in lmb_property to save the "no-map" property of reserved region and a new function lmb_reserve_flags() to check this flag. The default allocation use flags = LMB_NONE. The adjacent reserved memory region are merged only when they have the same flags value. This patch is partially based on flags support done in Linux kernel mm/memblock .c (previously lmb.c); it is why LMB_NOMAP = 0x4, it is aligned with MEMBLOCK_NOMAP value. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-01fastboot: Fix overflow when calculating chunk sizeWIP/01Jun2021Sean Anderson1-8/+9
If a chunk was larger than 4GiB, then chunk_data_sz would overflow and blkcnt would not be calculated correctly. Upgrade it to a u64 and cast its multiplicands as well. Also fix bytes_written while we're at it. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-05-28efi_loader: add PE/COFF image measurementMasahisa Kojima3-26/+244
"TCG PC Client Platform Firmware Profile Specification" requires to measure every attempt to load and execute a OS Loader(a UEFI application) into PCR[4]. This commit adds the PE/COFF image measurement, extends PCR, and appends measurement into Event Log. Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Replace CONFIG_HASH_CALCULATE by CONFIG_HASH Fix conversions between pointers and u64. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-28efi_loader: Work-around build issue due to missing hash_calculate()Alexandru Gagniuc2-1/+3
The hash_calculate() symbol is provided by hash-checksum.c. It depends on hash_progressive_lookup_algo(), provided when CONFIG_HASH=y. The issue is that hash_calculate() is used by the efi_loader, irregardless of CONFIG_FIT_SIGNATURE. As pointed out in commit 87316da05f2f ("lib: introduce HASH_CALCULATE option"), enabling hash_calculate() based on CONFIG_FIT_SIGNATURE is incorrect. To resolve this, use CONFIG_HASH as the compile switch for hash-checksum.c. This ensures that all dependencies are compiled, and is the most natural Kconfig to use. There is the issue of having to 'select HASH' in a couple of places that already 'select SHA256'. This is a deeper problem with how hashes are organized, and fixing it is beyonf the scope of this change. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Acked-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-05-28Revert "lib: introduce HASH_CALCULATE option"Alexandru Gagniuc3-6/+1
When we think of Kconfig, we usually think of features that we like to enable or not. Ideally, we wouldn't use Kconfig to fix a build issue, although sometimes it might make sense. With Kconfig it's hard to guarantee that the fix is universal. We can only say that it works for the set of tested configurations. In the majority of cases, it's preferable to let the linker figure things out for us. The reverted commit attempted to fix a build issue by adding an invisible Kconfig option. This is wrong in several ways: It invents a new Kconfig variable when CONFIG_HASH already exists for the same purpose. Second, hash-checksum.c makes use of the hash_progressive_lookup_algo() symbol, which is only provided with CONFIG_HASH, but this dependency was not expressed in the reverted patch. It feels like Kconfig is turning into a listing of all available source files, and a buffet to 'select' which ones to compile. The purpose of this revert is to enable the next change to make use of CONFIG_HASH instead of adding to Kconfig. This reverts commit 87316da05f2fd49d3709275e64ef0c5980366ade. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Acked-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-05-28efi_loader: Fix coverity warnings for efi tcg2 protocolIlias Apalodimas1-2/+5
Coverity reported 3 warnings on the current code. CID 331856, 331855, 331854 on the latest scan. Fix the rest of the warnings by initializing the variables before passing them to tpm2_get_pcr_info(). In order to avoid future warnings and errors initialize them to 0 within the function as well, since the values are always OR'ed after querying the hardware. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: Fix -Wextra warning for EFI TCG2Ilias Apalodimas1-18/+22
Compiling with -Wextra produces a number of (harmless) warnings for the EFI TCG2 protocol. Let's fix those in case we ever enable the flag on the EFI subsystem Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: path length in efi_dp_from_name()Heinrich Schuchardt1-2/+7
Before this patch efi_dp_from_name() only accommodated a maximum file path length of 31 characters. This leads to boot failures due to file name truncation. Allow arbitrary path lengths. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-25efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabledMasahisa Kojima5-68/+73
This is preparation for PE/COFF measurement support. PE/COFF image hash calculation is same in both UEFI Secure Boot image verification and measurement in measured boot. PE/COFF image parsing functions are gathered into efi_image_loader.c, and exposed even if UEFI Secure Boot is not enabled. This commit also adds the EFI_SIGNATURE_SUPPORT option to decide if efi_signature.c shall be compiled. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-25efi_loader: remove weak efi_get_public_key_data()Heinrich Schuchardt1-10/+0
Configuring a system with CONFIG_EFI_CAPSULE_AUTHENTICATE=y but without a method to retrieve the public key data is a misconfiguration. We should get a build failure for it. Therefore remove the weak efi_get_public_key_data() implementation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-24sandbox: errno: avoid conflict with libc's errnoMarek Behún1-1/+3
When building with LTO, the system libc's `errno` variable used in arch/sandbox/cpu/os.c conflicts with U-Boot's `errno` (defined in lib/errno.c) with the following error: .../ld: errno@@GLIBC_PRIVATE: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/u-boot.EQlEXz.ltrans0.ltrans.o To avoid this conflict use different asm label for this variable when CONFIG_SANDBOX is enabled. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24lib: crc32: put the crc_table variable into efi_runtime_rodata sectionMarek Behún1-1/+2
When compiling with LTO, the compiler fails with an error saying that `crc_table` causes a section type conflict with `efi_var_buf`. This is because both are declared to be in the same section (via macro `__efi_runtime_data`), but one is const while the other is not. Put this variable into the section .rodata.efi_runtime, instead of .data.efi_runtime, via macro __efi_runtime_rodata. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Heinrich Schuchardt <xypron.gpk@gmx.de>
2021-05-24efi_selftest: compiler flags for efi_selftest_miniapp_exception.oMarek Behún1-0/+2
Add $(CFLAGS_EFI) and remove $(CFLAGS_NON_EFI) for efi_selftest_miniapp_exception.o. The removal is needed when compiling with LTO - this object file needs to be compiled without -flto. The adding is for consistency with other miniapps. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-24string: make memcpy(), memset(), memcmp() and memmove() visible for LTOMarek Behún1-4/+5
It seems that sometimes (happening on ARM64, for example with turris_mox_defconfig) GCC, when linking with LTO, changes the symbol names of some functions, for example lib/string.c's memcpy() function to memcpy.isra.0. This is a problem however when GCC for a code such as this: struct some_struct *info = get_some_struct(); struct some struct tmpinfo; tmpinfo = *info; emits a call to memcpy() by builtin behaviour, to copy *info to tmpinfo. This then results in the following linking error: .../lz4.c:93: undefined reference to `memcpy' .../uuid.c:206: more undefined references to `memcpy' follow GCC's documentation says this about -nodefaultlibs option: The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified. Make these functions visible by using the __used macro to avoid this error. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24treewide: Convert macro and uses of __section(foo) to __section("foo")Marek Behún1-2/+2
This commit does the same thing as Linux commit 33def8498fdd. Use a more generic form for __section that requires quotes to avoid complications with clang and gcc differences. Remove the quote operator # from compiler_attributes.h __section macro. Convert all unquoted __section(foo) uses to quoted __section("foo"). Also convert __attribute__((section("foo"))) uses to __section("foo") even if the __attribute__ has multiple list entry forms. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-19lib: kconfig: Limit BINMAN_FDT for OF_SEPARATE or OF_EMBEDBin Meng1-1/+1
Generally speaking BINMAN_FDT makes sense for OF_SEPARATE or OF_EMBED. For the other OF_CONTROL methods, it's quite possible binman node is not available as binman is invoked during the build phase instead of runtime. Let's only turn it on for OF_SEPARATE or OF_EMBED by default. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-18lib: introduce HASH_CALCULATE optionMasahisa Kojima3-1/+6
Build error occurs when CONFIG_EFI_SECURE_BOOT or CONFIG_EFI_CAPSULE_AUTHENTICATE is enabled, because hash-checksum.c is not compiled. Since hash_calculate() implemented in hash-checksum.c can be commonly used aside from FIT image signature verification, this commit itroduces HASH_CALCULATE option to decide if hash-checksum.c shall be compiled. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Fix Kconfig for EFI_TCG2 protocolIlias Apalodimas1-0/+6
EFI_TCG2 depends not only on TPMv2 but also on the underlying algorithms. So select the missing SHA1, SHA256, SHA384 and SHA512 we currently support Reported-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Add 'default y'. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Don't stop EFI subsystem init if installing TCG2 failsIlias Apalodimas1-5/+28
Up to now we are stopping the EFI subsystem if a TPMv2 exists but the protocol fails to install. Now that we've switched the config to 'default y' the sandbox TPM fails, since it doesn't support all the required capabilities of the protocol. Not installing the protocol is not catastrophic. If the protocol fails to install the PCRs will never be extended to the expected values, so some other entity later in the boot flow will eventually figure it out and take the necessary actions. While at it fix a corner case were the user can see an invalid error message when the protocol failed to install. We do have a tcg2_uninit() which we call when the protocol installation fails. There are cases though that this might be called before the configuration table is installed (e.g probing the TPM for capabilities failed). In that case the user will see "Failed to delete final events config table". So stop printing it since it's not an actual failure , simply because the config table was never installed in the first place. In order to stop printing it make efi_init_event_log() and create_final_event() cleanup themselves and only call tcg2_uninit() when the protocol installation fails. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Uninstall the TCG2 protocol if logging s-crtm failsIlias Apalodimas1-5/+3
Instead of just failing, clean up the installed config table and EventLog memory if logging an s-crtm event fails during the protocol installation Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Eliminate label 'out:' by using return. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: Clean up tcg2 once in case of failureIlias Apalodimas1-4/+0
efi_init_event_log() calls tcg2_uninit() in case of failure. We can skip that since the function is called on efi_tcg2_register() which also cleans up if an error occurs Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: loosen buffer parameter check in efi_file_read_intPeng Fan1-1/+1
This is same issue as https://bugzilla.redhat.com/show_bug.cgi?id=1733817, but that fix was wrongly partial reverted. When reading a directory, EFI_BUFFER_TOO_SMALL should be returned when the supplied buffer is too small, so a use-case is to call EFI_FILE_PROTOCOL.Read() with *buffer_size=0 and buffer=NULL to obtain the needed size before doing the actual read. So remove the check only for directory reading, file reading already do the check by itself. Fixes: db12f518edb0("efi_loader: implement non-blocking file services") Signed-off-by: Peng Fan <peng.fan@nxp.com> Cc: Stefan Sørensen <stefan.sorensen@spectralink.com> Tested-by: Peter Robinson <pbrobinson@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18efi_loader: capsule: Remove the check for capsule_authentication_enabled ↵Sughosh Ganu1-3/+2
environment variable The current capsule authentication code checks if the environment variable capsule_authentication_enabled is set, for authenticating the capsule. This is in addition to the check for the config symbol CONFIG_EFI_CAPSULE_AUTHENTICATE. Remove the check for the environment variable. The capsule will now be authenticated if the config symbol is set. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-18hash: Kconfig option for SHA512 hardware accelerationHeinrich Schuchardt1-5/+16
Commit a479f103dc1c ("hash: Allow for SHA512 hardware implementations") defined function definitions for hardware accelerated SHA384 and SHA512. If CONFIG_SHA_HW_ACCEL=y, these functions are used. We already have boards using CONFIG_SHA_HW_ACCEL=y but none implements the new functions hw_sha384() and hw_sha512(). For implementing the EFI TCG2 protocol we need SHA384 and SHA512. The missing hardware acceleration functions lead to build errors on boards like peach-pi_defconfig. Introduce a new Kconfig symbol CONFIG_SHA512_HW_ACCEL to control if the functions hw_sha384() and hw_sha512() shall be used to implement the SHA384 and SHA512 algorithms. Fixes: a479f103dc1c ("hash: Allow for SHA512 hardware implementations") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-18efi_loader: build warning in efi_tcg2_hash_log_extend_eventHeinrich Schuchardt1-2/+2
Building 32bit boards with the TCG2 protocol enabled leads to a build warning due to a missing conversion. lib/efi_loader/efi_tcg2.c:774:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 774 | ret = tcg2_create_digest((u8 *)data_to_hash, data_to_hash_len, | ^ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-04-29dm: core: Add address translation in fdt_get_resourcePatrick Delaunay1-1/+5
Today of_address_to_resource() is called only in ofnode_read_resource() for livetree support and fdt_get_resource() is called when livetree is not supported. The fdt_get_resource() doesn't do the address translation so when it is required, but the address translation is done by ofnode_read_resource() caller, for example in drivers/firmware/scmi/smt.c::scmi_dt_get_smt_buffer() { ... ret = ofnode_read_resource(args.node, 0, &resource); if (ret) return ret; faddr = cpu_to_fdt32(resource.start); paddr = ofnode_translate_address(args.node, &faddr); ... The both behavior should be aligned and the address translation must be called in fdt_get_resource() and removed for each caller. Fixes: a44810123f9e ("dm: core: Add dev_read_resource() to read device resources") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
2021-04-24efi_loader: capsule: return a correct error code at find_boot_device()AKASHI Takahiro1-1/+1
In case of failure at efi_get_variable_int("BootOrder"), we should skip examining boot option variables and return an appropriate error code which is the one the function returned. Fixes: CID 331153 Code maintainability issues (UNUSED_VALUE) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi: Fix ESRT refresh after Capsule updateJose Marinho1-1/+1
Indicated by Coverity Scan CID 331147 The ESRT was being refreshed in situations where the UpdateCapsule procedure failed. In that scenario: 1) the ESRT refresh was superfluous. 2) a failed ESRT refresh return code overwrites the UpdateCapsule error return code. This commit ensures that the ESRT is only refreshed when the UpdateCapsule performs successfully. CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Tom Rini <trini@konsulko.com> CC: Andre Przywara <andre.przywara@arm.com> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi_loader: simplify tcg2_create_digest()Ilias Apalodimas1-4/+1
Bumping the digest list count, for all supported algorithms, can be calculated outside of the individual switch statements. So let's do that for every loop iteration instead and simplify the code a bit. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-24efi_loader: missing include in efi_string.cHeinrich Schuchardt1-0/+1
To avoid diverging function definitions we need to include efi_loader.h. Fixes: fe179d7fb5c1 ("efi_loader: Add size checks to efi_create_indexed_name()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-22lmb: Add 2 config to define the max number of regionsPatrick Delaunay2-2/+35
Add 2 configs CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS to change independently the max number of the regions in lmb library. When CONFIG_LMB_USE_MAX_REGIONS=y, move the lmb property arrays to struct lmb and manage the array size with the element 'max' of struct lmb_region; their are still allocated in stack. When CONFIG_LMB_USE_MAX_REGIONS=n, keep the current location in struct lmb_region to allow compiler optimization. Increase CONFIG_LMB_RESERVED_REGIONS is useful to avoid lmb errors in bootm when the number of reserved regions (not adjacent) is reached: + 1 region for relocated U-Boot + 1 region for initrd + 1 region for relocated linux device tree + reserved memory regions present in Linux device tree. The current limit of 8 regions is reached with only 5 reserved regions in DT. see Linux kernel commit bf23c51f1f49 ("memblock: Move memblock arrays to static storage in memblock.c and make their size a variable") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-22lmb: move MAX_LMB_REGIONS value in KconfigPatrick Delaunay2-3/+11
Move MAX_LMB_REGIONS value in Kconfig, the max number of the regions in lmb library. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-22lmb: add a max parameter in the struct lmb_regionPatrick Delaunay1-1/+4
Add a max parameter in lmb_region struct to handle test in lmb_add_region without using the MAX_LMB_REGIONS define. This patch allows to modify these size independently for memory of reserved regions in the next patches. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-22lmb: remove lmb_region.sizePatrick Delaunay1-6/+0
Remove the unused field size of struct lmb_region as it is initialized to 0 and never used after in lmb library. See Linux kernel commit 4734b594c6ca ("memblock: Remove memblock_type.size and add memblock.memory_size instead") Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-22lmb: move CONFIG_LMB in KconfigPatrick Delaunay1-0/+7
Migrate CONFIG_LMB in Kconfig. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-20lz4: Fix unaligned accessesKarl Beldan1-3/+12
Signed-off-by: Karl Beldan <karl.beldan+oss@gmail.com>