summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'v2021.04-rc4' into nextTom Rini2021-03-155-33/+96
|\ | | | | | | Prepare v2021.04-rc4
| * lib/charset: UTF-8 stream conversionHeinrich Schuchardt2021-03-071-9/+46
| | | | | | | | | | | | | | | | Provide functions to convert an UTF-8 stream to code page 437 or UTF-32. Add unit tests. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * lib/charset: utf8_get() should return errorHeinrich Schuchardt2021-03-071-9/+16
| | | | | | | | | | | | | | | | | | | | | | utf8_get() should return an error if hitting an illegal UTF-8 sequence and not silently convert the input to a question mark. Correct utf_8() and the its unit test. console_read_unicode() now will ignore illegal UTF-8 sequences. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: carve out utf_to_cp()Heinrich Schuchardt2021-03-072-16/+31
| | | | | | | | | | | | | | | | Carve out a function to translate a Unicode code point to an 8bit codepage. Provide a unit test for the new function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: move codepage 437 tableHeinrich Schuchardt2021-03-072-1/+7
| | | | | | | | | | | | Move the Unicode to codepage 437 table to charset.c Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: console size of vidconsoleHeinrich Schuchardt2021-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | If stdout is 'vidconsole', we correctly set the console size. If stdout is 'vidconsole,serial', the video console is ignored. We should always evaluate the size of vidconsole if it is the primary console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * lib: kconfig: Mention CONFIG_ADDR_MAP limitation in the helpBin Meng2021-03-051-0/+2
| | | | | | | | | | | | | | | | Mention that CONFIG_ADDR_MAP only works in the post-relocation phase. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
| * lib: addr_map: Move address_map[] type to the header fileBin Meng2021-03-051-5/+1
| | | | | | | | | | | | | | | | | | | | At present address_map[] is static and its type is unknown to external modules. In preparation to create a command to list its contents, this patch moves its type definition and declaration to the header file. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
| * lib: Fix BINMAN_FDT dependencyBin Meng2021-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | lib/binman.c references the following 3 ofnode APIs: ofnode_first_subnode(), ofnode_path() and ofnode_read_bool(). These APIs get built only when DM is on. Fix the dependency then. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | tpm: Allow disabling platform hierarchy with TPM2Simon Glass2021-03-021-0/+35
| | | | | | | | | | | | | | | | | | With TPM2 we don't actually lock the TPM once verified boot is finished. Instead we disable the platform hierarchy which serves the same purpose. Add an implementation of this so we can safely boot into the kernel. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add TPM2 support for write_lockSimon Glass2021-03-022-1/+24
| | | | | | | | | | | | | | Implement this API function for TPM2. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add TPM2 support for read/write valuesSimon Glass2021-03-022-2/+86
| | | | | | | | | | | | | | Implement this API function for TPM2. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add an implementation of define_spaceSimon Glass2021-03-021-0/+47
| | | | | | | | | | | | | | | | Add support for this so that the TPM can be set up for use with Chromium OS verified boot. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Reduce duplication in a few functionsSimon Glass2021-03-021-5/+8
| | | | | | | | | | | | | | | | Update tpm2_clear() and tpm2_pcr_extend() so that the command size is not repeated twice. Add a small comment to the latter. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add a basic API implementation for TPMv2Simon Glass2021-03-021-7/+77
| | | | | | | | | | | | | | | | | | Add support for TPMv2 versions of API functions. So far this is not complete as the standard is quite large, but it implements everything currently available for TPMv2 in U-Boot. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Switch TPMv1 over to use the new APISimon Glass2021-03-022-61/+55
| | | | | | | | | | | | | | | | | | | | | | | | Take over the plain 'tpm_...' functions for use by the new TPM API. Rename all the TPMv1 functions so they are called from the API. Update the TPMv1 functions so that they are called from the API. Change existing users to use the tpm1_ prefix so they don't need to go through the API, which might introduce uncertainty. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add an API that can support v1.2 and v2Simon Glass2021-03-021-0/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | There are two different TPM standards. U-Boot supports both but each has its own set of functions. We really need a single TPM API that can call one or the other. This is not always possible as there are some differences between the two standards, but it is mostly possible. Add an API to handle this. So far it is not plumbed into the build and only supports TPMv1. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | tpm: Add debugging of request in tpm_sendrecv_command()Simon Glass2021-03-021-2/+8
|/ | | | | | | | | | The response is shown but not the request. Update the code to show both if debugging is enabled. Use a 'uint' type for size so it matches the register-word size on both 32- and 64-bit machines. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: limit output length for VenHw, VenMediaHeinrich Schuchardt2021-02-261-2/+4
| | | | | | | | | | | | | | VenHw and VenMedia device path nodes may carry vendor defined data of arbitrary length. When converting a device path node to text ensure that we do not overrun our internal buffer. In our implementation of EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() we could first determine the output length and then allocate buffers but that would nearly double the code size. Therefore keep the preallocated buffers and truncate excessive device paths instead. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: ACPI tables must be in EfiACPIReclaimMemoryHeinrich Schuchardt2021-02-261-2/+1
| | | | | | | | | | | The UEFI spec does not allow ACPI tables to be in runtime services memory. It recommends EfiACPIReclaimMemory. Remove a superfluous check that the allocated pages are 16 byte aligned. EFI pages are 4 KiB aligned. Fixes: 86df34d42b05 ("efi_loader: Install ACPI configuration tables") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib: sha512: include "compiler.h"Siew Chin Lim2021-02-241-0/+1
| | | | | | | | Include "compiler.h" in sha512.c. This is needed by 'cpu_to_be64' macro that used in 'sha512_base_do_finalize' function. Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* lib: rsa: Add debug message on algo mismatchSean Anderson2021-02-241-1/+4
| | | | | | | Currently we fail silently if there is an algorithm mismatch. To help distinguish this failure condition. Signed-off-by: Sean Anderson <sean.anderson@seco.com>
* efi_loader: multi part device paths to textHeinrich Schuchardt2021-02-211-5/+12
| | | | | | | | | | | | Our current implementation of EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() truncates multi part device paths after the first part. We should convert all parts. Render device path instance ends as commas. This is not explicitly described in the UEFI spec but mimics what EDK II does. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_selftest: multi part device path to textHeinrich Schuchardt2021-02-211-0/+65
| | | | | | | | Test EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() for a multi part device path. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_selftest: compiler flags for dtbdump.oHeinrich Schuchardt2021-02-211-1/+1
| | | | | | Fix a typo. Apply the correct compiler flags to dtbdump.o. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Allow last block to be readJesper Schmitz Mouridsen2021-02-211-2/+2
| | | | | | | | | | | The last block is of size media->block_size Signed-off-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer> Simplify expression. Apply same change to efi_disk_write_blocks(). Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge branch '2021-02-02-drop-asm_global_data-when-unused'Tom Rini2021-02-1516-1/+16
|\ | | | | | | - Merge the patch to take <asm/global_data.h> out of <common.h>
| * common: Drop asm/global_data.h from common headerSimon Glass2021-02-0216-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* | Revert "fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()"Tom Rini2021-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | On Rockchip platforms we need this area of code in TPL, but there is no TPL_SEPARATE_BSS symbol. This reverts commit 0a2aaab0b678fd1778ff2fc59d0770fc82995532. Reported-by: Markus Reichl <m.reichl@fivetechno.de> Reported-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer> Reported-by: Peter Robinson <pbrobinson@gmail.com> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Tom Rini <trini@konsulko.com>
* | efi_loader: fix get_last_capsule()Heinrich Schuchardt2021-02-141-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix get_last_capsule() leads to writes beyond the stack allocated buffer. This was indicated when enabling the stack protector. utf16_utf8_strcpy() only stops copying when reaching '\0'. The current invocation always writes beyond the end of value[]. The output length of utf16_utf8_strcpy() may be longer than the number of UTF-16 tokens. E.g has "CapsuleКиев" has 11 UTF-16 tokens but 15 UTF-8 tokens. Hence, using utf16_utf8_strcpy() without checking the input may lead to further writes beyond value[]. The current invocation of strict_strtoul() reads beyond the end of value[]. A non-hexadecimal value after "Capsule" (e.g. "CapsuleZZZZ") must result in an error. We cat catch this by checking the return value of strict_strtoul(). A value that is too short after "Capsule" (e.g. "Capsule0") must result in an error. We must check the string length of value[]. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: '.' and '..' are directoriesHeinrich Schuchardt2021-02-141-3/+1
| | | | | | | | | | | | | | | | '.' and '..' are directories. So when looking for capsule files it is sufficient to check that the attribute EFI_FILE_DIRECTORY is not set. We don't have to check for these special names. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: don't load beyond VirtualSizeAsherah Connor2021-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PE section table entries' SizeOfRawData must be a multiple of FileAlignment, and thus may be rounded up and larger than their VirtualSize. We should not load beyond the VirtualSize, which is "the total size of the section when loaded into memory" -- we may clobber real data at the target in some other section, since we load sections in reverse order and sections are usually laid out sequentially. Signed-off-by: Asherah Connor <ashe@kivikakk.ee> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | smbios: Allow a few values to come from sysinfoSimon Glass2021-02-061-3/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While static configuration is useful it cannot cover every case. Sometimes board revisions are encoded in resistor straps and must be read at runtime. The easiest way to provide this information is via sysinfo, since the board can then provide a driver to read whatever is needed. Add some standard sysinfo options for this, and use them to obtain the required information. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Add more options for the BIOS version stringSimon Glass2021-02-061-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present the version string is obtained from PLAIN_VERSION. Some boards may want to configure this using the device tree, since the build system can more easily insert things there after U-Boot itself is built. Add this option to the code. Also in some cases the version needs to be generated programmatically, such as when it is stored elsewhere in the ROM and must be read first. To handle this, keep a pointer around so that it can be updated later. This works by storing the last string in the context, since it is easier than passing out a little-used extra parameter. Provide a function to update the version string. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Track the end of the string tableSimon Glass2021-02-061-17/+15
| | | | | | | | | | | | | | | | Add a new member to the context struct which tracks the end of the string table. This allows us to avoid recalculating this at the end. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Drop the eos parameterSimon Glass2021-02-061-24/+36
| | | | | | | | | | | | | | | | | | | | | | We can store this in the context and avoid passing it to each function. This makes it easier to follow and will also allow keeping track of the end of the string table (in future patches). Add an 'eos' field to the context and create a function to set it up. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Use a struct to keep track of contextSimon Glass2021-02-061-32/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present we pass the ofnode to each function. We also pass the 'eos' pointer for adding new strings. We don't track the current end of the string table, so have smbios_string_table_len() to find that. The code can be made more efficient if it keeps information in a context struct. This also makes it easier to add more features. As a first step, switch the ofnode parameter to be a context pointer. Update smbios_add_prop() at the same time to avoid changing the same lines of code in consecutive patches. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Set BIOS release versionSimon Glass2021-02-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | We may as well include the U-Boot release information in the type-0 table since it is designed for that purpose. U-Boot uses release versions based on the year and month. The year cannot fit in a byte, so drop the century. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | smbios: Move smbios_write_type to the C fileSimon Glass2021-02-061-0/+10
| | | | | | | | | | | | | | | | | | This type is not used outside the smbios.c file so there is no need for it to be in the header file. Move it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* | Merge tag 'efi-2021-04-rc2' of ↵Tom Rini2021-02-044-53/+87
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2021-04-rc2 Bug fixes: * do not allow creating of files with filenames on FAT file system * install UEFI System Partition GUID on ESP handle * in dtbdump.efi test tool use GUID to find ESP handle Documentation: * man-page for load command * describe end of life of plat_auto
| * | efi_loader: VenMedia device path nodeHeinrich Schuchardt2021-02-041-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | The Load File2 protocol exposes a device path with a VenMedia() node. Hence our implementation of the device path to text protocol should support this node. Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * | efi_selftest: use GUID to find ESP in dtbdumpHeinrich Schuchardt2021-02-041-33/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | If dtbdump.efi is loaded from memory when calling LoadImage the loaded image protocol will not indicate the partition from where it was loaded. In this case use the EFI system partition for the 'load' and 'save' commands. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * | efi_loader: install UEFI System Partition GUIDHeinrich Schuchardt2021-02-041-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | On the handle for the UEFI System Partition we must install the System Partition GUID (with a NULL interface). Let the efidebug command display the GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * | efi_loader: only check size if EFI_DT_APPLY_FIXUPSHeinrich Schuchardt2021-02-041-12/+13
| |/ | | | | | | | | | | | | | | | | | | | | In the implementation of the EFI_DT_FIXUP_PROTOCOL: * Only check the buffer size when EFI_DT_APPLY_FIXUPS is set. * In this case the field totalsize of the device-tree may not exceed the buffer size. * Install device-tree only if EFI_DT_INSTALL_TABLE is set. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* / fdtdec: Cast prior_stage_fdt_address with uintptr_tBin Meng2021-02-031-1/+1
|/ | | | | | | | | | | At present prior_stage_fdt_address is declared as phys_addr_t. On a 32-bit platform where phys_addr_t can be 64-bit, assigning its value to gd->fdt_blob which is a pointer, can cause warnings. Cast it to uintptr_t before the assignment. Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge tag 'dm-pull-30jan21' of ↵Tom Rini2021-01-311-0/+2
|\ | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-dm tpm fixes for coral binman fixes support for symbols in sub-sections support for additional cros_ec commands various minor fixes / tweaks
| * binman: Print a debug message when binman selects a nodeSimon Glass2021-01-301-0/+2
| | | | | | | | | | | | | | Add some debugging to indicate which node the binman library is looking at. Signed-off-by: Simon Glass <sjg@chromium.org>
* | efi_loader: switch to non-secure mode laterHeinrich Schuchardt2021-01-291-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Some ARMv7 boards using PSCI require to be in secure-mode when booted via 'bootz' or 'bootm'. During distro-boot 'bootefi bootmgr' is called to check if booting via UEFI is possible. With the change we change the switch from secure mode to non-secure mode is moved from the UEFI subsystem setup to just before calling StartImage(). Cc: Jernej Škrabec <jernej.skrabec@gmail.com> Reported by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: correct block IO alignment checkHeinrich Schuchardt2021-01-291-4/+6
| | | | | | | | | | | | | | | | | | | | If the field Media->IoAlign of the EFI block IO protocol is zero, no alignment is required. Our code required 4 GiB alignment in this case. Don't check buffer alignment if Media->IoAlign == 0. Fixes: f59f0825e8b9 ("efi_loader: parameter checks BLOCK_IO_PROTOCOL") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_selftest: test EFI_BLOCK_IO_PROTOCOL.Media->LastBlockHeinrich Schuchardt2021-01-291-1/+20
|/ | | | | | | | | | | | The field Media->LastBlock of the EFI_BLOCK_IO_PROTOCOL must be filled with the index of the last logical block (LBA) for the block device that our test driver provides. After calling ConnectController() U-Boot exposes the block IO protocol for the partition check that the value of Media->LastBlock equals the partition size minus one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>