summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* acpi: Use I2cSerialBusV2() instead of I2cSerialBus()Simon Glass2020-09-251-1/+1
| | | | | | Use the correct name of the ACPI structure being created. Signed-off-by: Simon Glass <sjg@chromium.org>
* acpi: Add more support for generating processor tablesSimon Glass2020-09-251-0/+167
| | | | | | This adds tables relating to P-States and C-States. Signed-off-by: Simon Glass <sjg@chromium.org>
* acpi: Add support for generating processor tablesSimon Glass2020-09-251-0/+55
| | | | | | | 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>
* x86: acpi: Support generation of the DBG2 tableSimon Glass2020-09-251-0/+64
| | | | | | | | | | | | 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>
* dm: acpi: Use correct GPIO polarity type in acpi_dp_add_gpio()Simon Glass2020-09-251-2/+2
| | | | | | | This function currently accepts the IRQ-polarity type. Fix it to use the GPIO type instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* acpi: Support generating a multi-function _DSM for devicesSimon Glass2020-09-252-0/+97
| | | | | | | | | 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>
* acpi: Add support for conditions and return valuesSimon Glass2020-09-251-0/+68
| | | | | | | Add functions to support generating ACPI code for condition checks and return values. Signed-off-by: Simon Glass <sjg@chromium.org>
* acpi: Add support for writing a _PRWSimon Glass2020-09-251-0/+10
| | | | | | | 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>
* optee: add property no-map to secure reserved memoryEtienne Carriere2020-09-221-1/+1
| | | | | | | | | | | 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>
* fdtdec: optionally add property no-map to created reserved memory nodeEtienne Carriere2020-09-222-3/+9
| | | | | | | | | | | | | | | | | | 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>
* Merge branch 'master' into nextTom Rini2020-09-217-32/+74
|\ | | | | | | Merge in v2020.10-rc5
| * efi_selftest: check for RISC-V boot-hartid in FDTHeinrich Schuchardt2020-09-181-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * efi_selftest: rework device tree testHeinrich Schuchardt2020-09-181-14/+39
| | | | | | | | | | | | | | | | 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>
| * efi_memory: refine overlap_only_ram descriptionMaxim Uvarov2020-09-181-1/+1
| | | | | | | | | | | | | | | | | | 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>
| * lib: fdt: Fix fdtdec_setup_mem..() conversion to livetree APIMarek Vasut2020-09-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * efi_selftest: restore gd before do_reset()Heinrich Schuchardt2020-09-141-2/+4
| | | | | | | | | | | | | | | | 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>
| * efi_loader: save global data pointer on RISC-VHeinrich Schuchardt2020-09-141-9/+9
| | | | | | | | | | | | | | 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>
| * efi_loader: efi_var_mem_notify_exit_boot_servicesHeinrich Schuchardt2020-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * rsa: crash in br_i32_decode() called from rsa_gen_key_prop()Robert Reither2020-09-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'remove-config-nr-dram-banks-v9-2020-08-26' of ↵Tom Rini2020-09-072-12/+2
|\ \ | |/ |/| | | https://gitlab.denx.de/u-boot/custodians/u-boot-marvell into next
| * CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always definedStefan Roese2020-08-262-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_selftest: simplify MakefileHeinrich Schuchardt2020-09-061-6/+0
| | | | | | | | | | | | | | 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>
* | efi_loader: remove duplicate image size checkHeinrich Schuchardt2020-09-061-4/+0
| | | | | | | | | | | | The image size is checked in efi_load_pe(). Avoid checking it twice. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: error message if image not authenticatedHeinrich Schuchardt2020-09-061-2/+4
| | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: log function in image loaderHeinrich Schuchardt2020-09-061-22/+22
| | | | | | | | | | | | | | Use log_err() for error messages. Replace debug() by EFI_PRINT(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | lib/rsa: correct check after allocation in fdt_add_bignum()Heinrich Schuchardt2020-08-271-1/+1
|/ | | | | | | | 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>
* Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvellTom Rini2020-08-251-0/+16
|\ | | | | | | | | | | | | - 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)
| * fdtdec: Add API to read pci bus-range propertySuneel Garapati2020-08-251-0/+16
| | | | | | | | | | | | | | | | 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>
* | Merge branch '2020-08-24-misc-improvements'Tom Rini2020-08-251-1/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | - Squashfs compression support - Coverity fixes - XEN guest updates - Finish previous MediaTek updates - Arm Total Compute platform support
| * | xen: Code style conformityWIP/2020-08-24-misc-improvementsAnastasiia Lukianenko2020-08-241-1/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: validate device path length in boot managerHeinrich Schuchardt2020-08-241-4/+2
| | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: efi_dp_check_length()Heinrich Schuchardt2020-08-241-0/+33
| | | | | | | | | | | | | | | | | | | | 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>
* | efi_selftest: substitute ResetSystem() by do_reset()Heinrich Schuchardt2020-08-241-2/+8
| | | | | | | | | | | | | | If ResetSystem() is not implemented at runtime, call do_reset() after test completion. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: add a test for ResetSystem()Heinrich Schuchardt2020-08-242-0/+59
| | | | | | | | | | | | | | | | | | | | | | 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>
* | efi_loader: ResetSystem() should not hangHeinrich Schuchardt2020-08-241-3/+4
|/ | | | | | | | | | 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>
* lib: fdt: Convert fdtdes_setup_mem..() to livetree APIMichal Simek2020-08-201-32/+35
| | | | | | | | | | | 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>
* lib: fdt: Introduce fdtdec_setup_mem_size_base_lowest()Michal Simek2020-08-201-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge tag 'efi-2020-10-rc3-2' of ↵WIP/15Aug2020Tom Rini2020-08-154-281/+208
|\ | | | | | | | | | | | | | | | | | | | | | | | | 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
| * efi_loader: signature: correct a behavior against multiple signaturesAKASHI Takahiro2020-08-142-85/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * efi_loader: variable: fix secure state initializationAKASHI Takahiro2020-08-131-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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")
| * efi_loader: signature: rework for intermediate certificates supportAKASHI Takahiro2020-08-134-209/+184
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * efi_loader: variable: keep temporary buffer during the authenticationAKASHI Takahiro2020-08-131-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lib: sscanf: add sscanf implementationAndrii Anisov2020-08-143-0/+828
|/ | | | | | | | | 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>
* efi_loader: set load options in boot managerHeinrich Schuchardt2020-08-081-11/+27
| | | | | | | | | | | 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>
* efi_loader: factor out efi_set_load_options()Heinrich Schuchardt2020-08-081-0/+32
| | | | | | | | | | 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>
* efi_loader: add copyright noticeAKASHI Takahiro2020-08-081-0/+1
| | | | | | | | | | 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>
* lib/crypto: simplify public_key_verify_signatureHeinrich Schuchardt2020-08-081-4/+0
| | | | | | The variable region is filled but never used. Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* include/u-boot, lib/zlib: add sources for zlib decompressionJoao Marcos Costa2020-08-073-0/+107
| | | | | | | | | 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>
* lmb/bdinfo: dump lmb info via bdinfoTero Kristo2020-08-041-19/+23
| | | | | | | Dump lmb status from the bdinfo command. This is useful for seeing the reserved memory regions from the u-boot cmdline. Signed-off-by: Tero Kristo <t-kristo@ti.com>
* efi: Tidy up header includesSimon Glass2020-08-032-0/+3
| | | | | | | | Two files relies on efi_driver.h to include common.h and dm.h which is incorrect. The former should always be included in a non-host C file and the latter should be included if driver model is used. Signed-off-by: Simon Glass <sjg@chromium.org>