summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2020-10-05Merge branch 'next'Tom Rini
Bring in the assorted changes that have been staged in the 'next' branch prior to release. Signed-off-by: Tom Rini <trini@konsulko.com>
2020-09-27efi_loader: installation of EFI_RNG_PROTOCOLHeinrich Schuchardt
Having an EFI_RNG_PROTOCOL without a backing RNG device leads to failure to boot Linux 5.8. Only install the EFI_RNG_PROTOCOL if we have a RNG device. Reported-by: Scott K Logan <logans@cottsay.net> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-25acpi: Use I2cSerialBusV2() instead of I2cSerialBus()Simon Glass
Use the correct name of the ACPI structure being created. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25acpi: Add more support for generating processor tablesSimon Glass
This adds tables relating to P-States and C-States. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25acpi: Add support for generating processor tablesSimon Glass
ACPI has a number of CPU-related tables. Add utility functions to write out the basic packages. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25x86: acpi: Support generation of the DBG2 tableSimon Glass
Add an implementation of the DBG2 (Debug Port Table 2) ACPI table. Adjust one of the header includes to be in the correct order, before adding more. Note that the DBG2 table is generic but the PCI UART is x86-specific at present since it assumes an ns16550 UART. It can be generalised later if necessary. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio()Simon Glass
This function currently accepts the IRQ-polarity type. Fix it to use the GPIO type instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25acpi: Support generating a multi-function _DSM for devicesSimon Glass
Add a function to generate ACPI code for a _DSM method for a device. This includes functions for starting and ending each part of the _DSM. Signed-off-by: Simon Glass <sjg@chromium.org> [bmeng: fix the "new blank line at EOF" git warning] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2020-09-25acpi: Add support for conditions and return valuesSimon Glass
Add functions to support generating ACPI code for condition checks and return values. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-25acpi: Add support for writing a _PRWSimon Glass
A 'Power Resource for Wake' list the resources a device depends on for wake. Add a function to generate this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22optee: add property no-map to secure reserved memoryEtienne Carriere
OP-TEE reserved memory node must set property "no-map" to prevent Linux kernel from mapping secure memory unless what non-secure world speculative accesses of the CPU can violate the memory firmware configuration. Fixes: 6ccb05eae01b ("image: fdt: copy possible optee nodes to a loaded devicetree") Signed-off-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
2020-09-22fdtdec: optionally add property no-map to created reserved memory nodeEtienne Carriere
Add boolean input argument @no_map to helper function fdtdec_add_reserved_memory() to add or not "no-map" property for an added reserved memory node. Property no-map is used by the Linux kernel to not not map memory in its static memory mapping. It is needed for example for the| consistency of system non-cached memory and to prevent speculative accesses to some firewalled memory. No functional change. A later change will update to OPTEE library to add no-map property to OP-TEE reserved memory nodes. Signed-off-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-09-21Merge branch 'master' into nextTom Rini
Merge in v2020.10-rc5
2020-09-18efi_selftest: check for RISC-V boot-hartid in FDTHeinrich Schuchardt
On RISC-V check that the /chosen node has a boot-hartid property. To run the test configure with CONFIG_CMD_BOOTEFI_SELFTEST=y and issue setenv efi_selftest device tree setenv serial# myserial bootefi selftest If the test succeeds, it reports the boot-hartid, e.g. boot-hartid: 1 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-18efi_selftest: rework device tree testHeinrich Schuchardt
Allow specifying the node on which a property is searched. Test the device tree consistency more rigorously. Some efi_st_printf() calls have been converted to efi_st_error(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-18efi_memory: refine overlap_only_ram descriptionMaxim Uvarov
Refine text for overlap_only_ram description to match to what exactly flag does and aling description with other functions. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-16lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree APIMarek Vasut
Repair incorrectly negated condition in the original patch which broke DT memory node parsing on everything which has more than one DT memory node, e.g. R-Car3. In case multiple valid memory nodes are present in the DT, the original patch would complete parsing cycle for the first memory node, then move on to the next one, identify it as a valid, and end the parsing. The fix is to invert the condition, to make the code behave as it did before the livetree conversion, so it would continue parsing the subsequent memory nodes as well. Fixes: c2f0950c33 ("lib: fdt: Convert fdtdes_setup_mem..() to livetree API") Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Tested-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
2020-09-14efi_selftest: restore gd before do_reset()Heinrich Schuchardt
Before calling do_reset() in the EFI selftest we must restore the global data pointer. Fixes: fa63753f86cc ("efi_selftest: substitute ResetSystem() by do_reset()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-14efi_loader: save global data pointer on RISC-VHeinrich Schuchardt
On RISC-V the global data pointer is stored in register gp. When a UEFI binary calls the EFI API we have to restore it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-14efi_loader: efi_var_mem_notify_exit_boot_servicesHeinrich Schuchardt
efi_var_mem_notify_exit_boot_services() is invoked when ExitBootServices() is called by the UEFI payload. efi_var_mem_notify_exit_boot_services() should not be defined as __efi_runtime as it is invoking EFI_ENTRY() and EFI_EXIT() which themselves are not __efi_runtime. Fixes: f1f990a8c958 ("efi_loader: memory buffer for variables") Fixes: e01aed47d6a0 ("efi_loader: Enable run-time variable support for tee based variables") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-09-14rsa: crash in br_i32_decode() called from rsa_gen_key_prop()Robert Reither
Fixes problem for unaligned 32bit big-endian access in lib/rsa/rsa-keyprop.c. Exchanges br_i32_decode() with get_unaligned_be32(). This will keep the unaligned access for architectures capable and will do some byte-shift magic for the not so capable ones. Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-by: Robert Reither <robert.reither@external.thalesgroup.com> Remove unused include. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-07Merge branch 'remove-config-nr-dram-banks-v9-2020-08-26' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-marvell into next
2020-09-06efi_selftest: simplify MakefileHeinrich Schuchardt
CONFIG_EFI_LOADER cannot be selected for ARMv7-M CPUs. So don't check it in the Makefile. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-06efi_loader: remove duplicate image size checkHeinrich Schuchardt
The image size is checked in efi_load_pe(). Avoid checking it twice. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-06efi_loader: error message if image not authenticatedHeinrich Schuchardt
Currently if the bootefi command fails due to missing authentication, the user gets no feedback. Write a log message 'Image not authenticated' if LoadImage() fails due to missing authentication. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-06efi_loader: log function in image loaderHeinrich Schuchardt
Use log_err() for error messages. Replace debug() by EFI_PRINT(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-27lib/rsa: correct check after allocation in fdt_add_bignum()Heinrich Schuchardt
After allocating to pointer ctx we should check that pointer and not another pointer already checked above. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-26CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always definedStefan Roese
Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") & commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"), CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Pali Rohár <pali@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-08-25Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvellTom Rini
- Add basic Marvell/Cavium OcteonTX/TX2 support (Suneel) - Infrastructure changes to PCI uclass to support these SoC's (Suneel) - Add PCI, MMC & watchdog driver drivers for OcteonTX/TX2 (Suneel) - Increase CONFIG_SYS_MALLOC_F_LEN for qemu-x86 (Stefan)
2020-08-25Merge branch '2020-08-24-misc-improvements'Tom Rini
- Squashfs compression support - Coverity fixes - XEN guest updates - Finish previous MediaTek updates - Arm Total Compute platform support
2020-08-25fdtdec: Add API to read pci bus-range propertySuneel Garapati
Add fdtdec_get_pci_bus_range to read bus-range property values. Signed-off-by: Suneel Garapati <sgarapati@marvell.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-24xen: Code style conformityAnastasiia Lukianenko
Cleaning up the following: ERROR: do not use assignment in if condition #281: FILE: drivers/xen/pvblock.c:260: + if ((err = xenbus_switch_state(XBT_NIL, nodename, CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "err" #52: FILE: drivers/xen/pvblock.c:298: + if (err != NULL) { ERROR: do not use assignment in if condition #176: FILE: drivers/xen/gnttab.c:103: + if ((flags = nflags) & (GTF_reading | GTF_writing)) { WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #329: FILE: include/xen/gnttab.h:1: +/* WARNING: Misplaced SPDX-License-Identifier tag - use line 1 instead #330: FILE: include/xen/gnttab.h:2: + * SPDX-License-Identifier: GPL-2.0 ERROR: do not use assignment in if condition #630: FILE: lib/sscanf.c:558: + if ((n = inr) < width) { Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-24efi_loader: validate device path length in boot managerHeinrich Schuchardt
Bootxxxx variables are provided by the user and therefore cannot be trusted. We have to validate them before usage. A device path provided by a Bootxxxx variable must have an end node within the indicated device path length. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_loader: efi_dp_check_length()Heinrich Schuchardt
We need to check that device paths provided via UEFI variables are not malformed. Provide function efi_dp_check_length() to check if a device path has an end node within a given number of bytes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_selftest: substitute ResetSystem() by do_reset()Heinrich Schuchardt
If ResetSystem() is not implemented at runtime, call do_reset() after test completion. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_selftest: add a test for ResetSystem()Heinrich Schuchardt
The unit test will reset the system by calling the ResetSystem() runtime service before or after ExitBootServices() according to the users choice by setting environment variable efi_selftest to: * 'reset system' or * 'reset system runtime'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_loader: ResetSystem() should not hangHeinrich Schuchardt
If ResetSystem() is not implemented at runtime, it should return instead of hanging in an endless loop. This allows the operating system to reset the system by other means as Linux does. It also matches what EDK II suggests in comments for functions ResetShutdown() and ResetWarm() in OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-20lib: fdt: Convert fdtdes_setup_mem..() to livetree APIMichal Simek
Convert fdtdec_setup_mem_size_base(), get_next_memory_node(), fdtdec_setup_memory_banksize() and fdtdec_setup_mem_size_base_lowest() to livetree API. Tested on ZynqMP zcu104 board. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-20lib: fdt: Introduce fdtdec_setup_mem_size_base_lowest()Michal Simek
New function should be called from board dram_init() because it initialized gd->ram_base/ram_size. It finds the lowest available memory. On systems with multiple memory nodes finding out the first memory node by fdtdec_setup_mem_size_base() is not enough because this memory can be above actual U-Boot VA mapping. Currently only mapping till 39bit is supported (Full 44bit mapping was removed by commit 7985cdf74b28 ("arm64: Remove non-full-va map code")). If DT starts with the first memory node above 39bit address then system can be unpredictable. The function is available only when multiple memory bank support is enabled. Calling fdtdec_setup_memory_banksize() from dram_init() is not possible because fdtdec_setup_memory_banksize() is saving dram information to bd structure which is placed on stack but not initialized at this time. Also stack is placed at location setup in dram_init(). Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-08-15Merge tag 'efi-2020-10-rc3-2' of ↵Tom Rini
https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-10-rc3 (2) This series includes bug fixes for: * UEFI secure boot - images with multiple signatures * UEFI secure boot - support for intermediate certificates * corrections for UEFI unit tests * missing loadaddr on MAIX board
2020-08-14lib: sscanf: add sscanf implementationAndrii Anisov
Port sscanf implementation from mini-os and introduce new Kconfig option to enable it: CONFIG_SSCANF. Disable by default. Signed-off-by: Andrii Anisov <andrii_anisov@epam.com> Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
2020-08-14efi_loader: signature: correct a behavior against multiple signaturesAKASHI Takahiro
Under the current implementation, all the signatures, if any, in a signed image must be verified before loading it. Meanwhile, UEFI specification v2.8b section 32.5.3.3 says, Multiple signatures are allowed to exist in the binary’s certificate table (as per PE/COFF Section “Attribute Certificate Table”). Only one hash or signature is required to be present in db in order to pass validation, so long as neither the SHA-256 hash of the binary nor any present signature is reflected in dbx. This patch makes the semantics of signature verification compliant with the specification mentioned above. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-13efi_loader: variable: fix secure state initializationAKASHI Takahiro
Under the new file-based variable implementation, the secure state is always and falsely set to 0 (hence, the secure boot gets disabled) after the reboot even if PK (and other signature database) has already been enrolled in the previous boot. This is because the secure state is set up *before* loading non-volatile variables' values from saved data. This patch fixes the order of variable initialization and secure state initialization. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Fixes: 5f7dcf079de8 ("efi_loader: UEFI variable persistence")
2020-08-13efi_loader: signature: rework for intermediate certificates supportAKASHI Takahiro
In this commit, efi_signature_verify(with_sigdb) will be re-implemented using pcks7_verify_one() in order to support certificates chain, where the signer's certificate will be signed by an intermediate CA (certificate authority) and the latter's certificate will also be signed by another CA and so on. What we need to do here is to search for certificates in a signature, build up a chain of certificates and verify one by one. pkcs7_verify_one() handles most of these steps except the last one. pkcs7_verify_one() returns, if succeeded, the last certificate to verify, which can be either a self-signed one or one that should be signed by one of certificates in "db". Re-worked efi_signature_verify() will take care of this step. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-08-13efi_loader: variable: keep temporary buffer during the authenticationAKASHI Takahiro
This is a bug fix; Setting an authenticated variable may fail due to a memory corruption in the authentication. A temporary buffer will, if needed, be allocated to parse a variable's authentication data, and some portion of buffer, specifically signer's certificates, will be referenced by efi_signature_verify(). So the buffer should be kept valid until the authentication process is finished. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-08efi_loader: set load options in boot managerHeinrich Schuchardt
Up to now we used the value of the bootargs environment variable as load options in the boot manager. This is not correct. The data has to be taken from the Boot#### variable. Let the boot manager copy the optional data of the EFI_LOAD_OPTION as load options to the loaded image protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-08efi_loader: factor out efi_set_load_options()Heinrich Schuchardt
The bootefi bootmgr command has to set the load options for a loaded image from the value of BootXXXX variable. If the boot manager is not used, the value is set from the environment variable bootargs (or efi_selftest). Factor out a common function efi_set_load_options(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-08efi_loader: add copyright noticeAKASHI Takahiro
Some amount of code was moved/derived from efi_variable.c regarding UEFI secure boot, in particluar in the commit 012c56ac76e1 ("efi_loader: restructure code for TEE variables"). So add the orignal author's copyright notice. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-08lib/crypto: simplify public_key_verify_signatureHeinrich Schuchardt
The variable region is filled but never used. Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-07include/u-boot, lib/zlib: add sources for zlib decompressionJoao Marcos Costa
Add zlib (v1.2.11) uncompr() function to U-Boot. SquashFS depends on this function to decompress data from a raw disk image. The actual support for zlib into SquashFS sources will be added in a follow-up commit. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>