summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2020-04-01image: Use constants for 'required' and 'key-name-hint'Simon Glass1-3/+3
These are used in multiple places so update them to use a shared #define. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>
2020-03-22efi_loader: definition of GetNextVariableName()Heinrich Schuchardt1-2/+2
'vendor' is both an input and an output parameter. So it cannot be constant. Fixes: 0bda81bfdc5c ("efi_loader: use const efi_guid_t * for variable services") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_selftest: test CalculateCrc32, CopyMem, SetMemHeinrich Schuchardt2-0/+78
Provide unit tests for CalculateCrc32(), CopyMem(), SetMem(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: fix freestanding memmove()Heinrich Schuchardt1-1/+1
For EFI binaries we have to provide an implementation of memmove() in efi_freestanding.c. Before this patch the memmove() function was copying in the wrong direction. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: description efi_convert_pointer()Heinrich Schuchardt1-2/+2
Correct the description of function efi_convert_pointer(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: simplify logical expression in efi_disk_add_dev()Heinrich Schuchardt1-1/+1
To check if a variable is non-zero there is no need for '!= 0'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_selftest: check length reported by GetNextVariableName()Heinrich Schuchardt1-2/+8
GetNextVariableName should report the length of the variable including the final 0x0000 in bytes. Check this in the unit test. Increase the buffer size for variable names. 40 bytes is too short. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: correct reported length in GetNextVariable()Heinrich Schuchardt1-5/+6
The runtime service GetNextVariable() returns the length of the next variable including the closing 0x0000. This length should be in bytes. Comparing the output of EDK2 and U-Boot shows that this is currently not correctly implemented: EDK2: OsIndicationsSupported: 46 PlatformLang: 26 PlatformLangCodes: 36 U-Boot: OsIndicationsSupported: 23 PlatformLang: 13 PlatformLangCodes: 18 Provide correct length in GetNextVariable(). Fixes: d99a87f84b75 ("efi_loader: implement GetNextVariableName()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: fix function descriptions in efi_disk.cHeinrich Schuchardt1-22/+30
Use Sphinx style for function descriptions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_loader: description of efi_variable.cHeinrich Schuchardt1-2/+2
Correct the file description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-17efi_loader: export a couple of protocol related functionsAKASHI Takahiro1-8/+8
This is a preparatory patch. Those functions will be used in an implementation of UEFI firmware management protocol as part of my capsule update patch. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-03-11efi_loader: unnecessary assignment in efi_queue_eventHeinrich Schuchardt1-1/+1
The assigned value NULL is never used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-11efi_loader: get_memory_map: return parameters whenever possibleAKASHI Takahiro1-6/+6
Currently, if GetMemoryMap API returns EFI_BUFFER_TOO_SMALL, it doesn't set valid values to other parameters, descriptor_size and descriptor_version, except memory_map_size. Some efi applications, however, may use those value; in particular, xen uses descriptor_size to calculate a size of buffer to be allocated. While UEFI specification is ambiguous in this point, it would be better to address this issue proactively to maximize the compatibility with existing efi applications. With this patch, for example, xen.efi (and hence linux kernel) can be started via bootefi without modification. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-28efi_selftest: add selftests for loadfile2 used to load initramfsIlias Apalodimas2-0/+221
Provide a unit test loading an initial ramdisk using the EFI_LOAD_FILE2_PROTOCOL. The test is only executed on request. An example usage - given a file image with a file system in partition 1 holding file initrd - is: * Configure the sandbox with CONFIG_EFI_SELFTEST=y CONFIG_EFI_LOAD_FILE2_INITRD=y CONFIG_EFI_INITRD_FILESPEC="host 0:1 initrd" * Run ./u-boot and execute host bind 0 image setenv efi_selftest load initrd bootefi selftest This would provide a test output like: Testing EFI API implementation Selected test: 'load initrd' Setting up 'load initrd' Setting up 'load initrd' succeeded Executing 'load initrd' Loaded 12378613 bytes CRC32 2997478465 Executing 'load initrd' succeeded Now the size and CRC32 can be compared to the provided file. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-28efi_loader: Implement FileLoad2 for initramfs loadingIlias Apalodimas4-0/+219
Following kernel's proposal for an arch-agnostic initrd loading mechanism [1] let's implement the U-boot counterpart. This new approach has a number of advantages compared to what we did up to now. The file is loaded into memory only when requested limiting the area of TOCTOU attacks. Users will be allowed to place the initramfs file on any u-boot accessible partition instead of just the ESP one. Finally this is an attempt of a generic interface across architectures in the linux kernel so it makes sense to support that. The file location is intentionally only supported as a config option argument(CONFIG_EFI_INITRD_FILESPEC), in an effort to enhance security. Although U-boot is not responsible for verifying the integrity of the initramfs, we can enhance the offered security by only accepting a built-in option, which will be naturally verified by UEFI Secure Boot. This can easily change in the future if needed and configure that via ENV or UEFI variable. [1] https://lore.kernel.org/linux-efi/20200207202637.GA3464906@rani.riverdale.lan/T/#m4a25eb33112fab7a22faa0fd65d4d663209af32f Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-26efi_loader: implement EFI_RT_PROPERTIES_TABLEHeinrich Schuchardt2-12/+32
UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable defined in UEFI spec 2.8 by the configuration table EFI_RT_PROPERTIES_TABLE. So let's follow suit. Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Ard Biesheuvel <ardb@kernel.org>
2020-02-19efi_loader: EFI_RNG_PROTOCOLHeinrich Schuchardt1-2/+2
Do not use quotation marks for Kconfig help text. Replace rng abbreviation by full words. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-06dm: core: Create a new header file for 'compat' featuresSimon Glass24-0/+24
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-02-06dm: core: Require users of devres to include the headerSimon Glass7-0/+10
At present devres.h is included in all files that include dm.h but few make use of it. Also this pulls in linux/compat which adds several more headers. Drop the automatic inclusion and require files to include devres themselves. This provides a good indication of which files use devres. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Anatolij Gustschin <agust@denx.de>
2020-02-06string: Allow arch override of strndup() alsoSimon Glass1-1/+1
At present architectures can override strdup() but not strndup(). Use the same option for both. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-02-06dm: pci: Update a few more interfaces for const udevice *Simon Glass1-1/+1
Tidy up a few places where const * should be used. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-30libfdt: Revert 6dcb8ba4 from upstream libfdtTom Rini1-10/+10
In upstream libfdt, 6dcb8ba4 "libfdt: Add helpers for accessing unaligned words" introduced changes to support unaligned reads for ARM platforms and 11738cf01f15 "libfdt: Don't use memcpy to handle unaligned reads on ARM" improved the performance of these helpers. In practice however, this only occurs when the user has forced the device tree to be placed in memory in a non-aligned way, which in turn violates both our rules and the Linux Kernel rules for how things must reside in memory to function. This "in practice" part is important as handling these other cases adds visible (1 second or more) delay to boot in what would be considered the fast path of the code. Cc: Patrice CHOTARD <patrice.chotard@st.com> Cc: Patrick DELAUNAY <patrick.delaunay@st.com> Link: https://www.spinics.net/lists/devicetree-compiler/msg02972.html Signed-off-by: Tom Rini <trini@konsulko.com> Tested-by: Patrice Chotard <patrice.chotard@st.com>
2020-01-30optee: Replace uninitialized return variable by proper one.Christoph Müllner1-1/+1
As hinted by GCC 9, there is a return statement that returns an uninitialized variable in optee_copy_firmware_node(). This patch addresses this. Signed-off-by: Christoph Müllner <christoph.muellner@theobroma-systems.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
2020-01-25lib: Kconfig dependencies for pseudo-random libraryHeinrich Schuchardt1-1/+2
drivers/rng/sandbox_rng.c requires rand() to be defined but configuration option CONFIG_CONFIG_LIB_RAND selected in drivers/rng/Kconfig does not exist. test/lib/test_aes.c requires rand() to be defined. Fix the selection criteria for choice "Pseudo-random library support type". Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-25lib: rsa: consider CONFIG_SPL_RSAHeinrich Schuchardt1-1/+1
CONFIG_SPL_RSA is meant to control if lib/rsa/* is used for SPL. Adjust lib/Makefile to consider this setting. This was correctly setup with commit 51c14cd128f4 ("verified-boot: Minimal support for booting U-Boot proper from SPL") and got lost with commit 089df18bfe9d ("lib: move hash CONFIG options to Kconfig"). Fixes: 089df18bfe9d ("lib: move hash CONFIG options to Kconfig") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-23trace: provide Sphinx style commentsHeinrich Schuchardt1-18/+36
Correct some function comments. Convert to Sphinx style. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-01-23lib: ignore oid_registry_data.c fileDario Binacchi1-0/+1
The file is generated by scripts/build_OID_registry based on the include/linux/oid_registry.h file. Signed-off-by: Dario Binacchi <dariobin@libero.it>
2020-01-18common: Move and rename CONFIG_SYS_SUPPORT_64BIT_DATASimon Glass1-4/+4
This is not really a CONFIG since it is not intended to be set by boards. Move it into the compiler header with other similar defines, and rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-18common: Move hang() to the same header as panic()Simon Glass5-1/+6
At present panic() is in the vsprintf.h header file. That does not seem like an obvious choice for hang(), even though it relates to panic(). So let's put hang() in its own header. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Migrate a few more files] Signed-off-by: Tom Rini <trini@konsulko.com>
2020-01-17common: Move RAM-sizing functions to init.hSimon Glass1-0/+1
These functions relate to memory init so move them into the init header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-17common: Move the image globals into image.hSimon Glass1-0/+1
These three globals relate to image handling. Move them to the image header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-17common: Move reset_cpu() to the CPU headerSimon Glass1-0/+1
Move this function out of common.h and into a relevant header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-17u-boot: fit: add support to decrypt fit with aesPhilippe Reynes3-0/+47
This commit add to u-boot the support to decrypt fit image encrypted with aes. The FIT image contains the key name and the IV name. Then u-boot look for the key and IV in his device tree and decrypt images before moving to the next stage. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
2020-01-17mkimage: fit: add support to encrypt image with aesPhilippe Reynes1-0/+136
This commit add the support of encrypting image with aes in mkimage. To enable the ciphering, a node cipher with a reference to a key and IV (Initialization Vector) must be added to the its file. Then mkimage add the encrypted image to the FIT and add the key and IV to the u-boot device tree. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
2020-01-17aes: add support of aes192 and aes256Philippe Reynes1-23/+54
Until now, we only support aes128. This commit add the support of aes192 and aes256. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-01-17aes: add a define for the size of a blockPhilippe Reynes1-17/+17
In the code, we use the size of the key for the size of the block. It's true when the key is 128 bits, but it become false for key of 192 bits and 256 bits. So to prepare the support of aes192 and 256, we introduce a constant for the iaes block size. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-01-15efi_loader: imply VIDEO_ANSIHeinrich Schuchardt1-0/+1
UEFI programs like GRUB make change terminal colors which requires support for ANSI escape sequences. Let CONFIG_EFI_LOADER=y imply CONFIG_VIDEO_ANSI. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_driver: debug output efi_uc_start, efi_uc_stopHeinrich Schuchardt1-2/+2
Use the correct printf codes for the debug output in efi_uc_start() and efi_uc_stop(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_driver: fix efi_uc_stop()Heinrich Schuchardt2-5/+6
Use the correct protocol in efi_uc_stop() when detaching the driver from the controller. Change the block IO unit test for the block device driver to throw an error instead of a todo if teardown fails. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_selftest: enable CONFIG_CMD_POWEROFFHeinrich Schuchardt1-0/+1
For automating testing we should be able to power off the test system. The implementation of EFI_RESET_SHUTDOWN requires the do_poweroff() function which is only available if CONFIG_CMD_POWEROFF=y. Enable CONFIG_CMD_POWEROFF if PSCI reset is available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_loader: describe returning of controlHeinrich Schuchardt1-4/+4
Provide a sober description of how control can be returned by a UEFI binary. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_loader: document functions in efi_rng.cHeinrich Schuchardt1-0/+35
Add the missing Sphinx documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_selftest: unit test for EFI_RNG_PROTOCOLHeinrich Schuchardt2-0/+118
Provide a unit test for the EFI_RNG_PROTOCOL. The list of algorithms is read. Two random numbers are generated. The test checks that the two numbers differ. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_rng_protocol: Install the efi_rng_protocol on the root nodeSughosh Ganu2-0/+6
Install the EFI_RNG_PROTOCOL implementation for it's subsequent use by the kernel for features like kaslr. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi: qemu: arm64: Add efi_rng_protocol implementation for the platformSughosh Ganu3-0/+121
Add support for the EFI_RNG_PROTOCOL routines for the qemu arm64 platform. EFI_RNG_PROTOCOL is an uefi boottime service which is invoked by the efi stub in the kernel for getting random seed for kaslr. The routines are platform specific, and use the virtio-rng device on the platform to get random data. The feature can be enabled through the following config CONFIG_EFI_RNG_PROTOCOL Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Changed SPDX header to use /* instead of //. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: Add guidcpy functionSughosh Ganu1-2/+2
Add guidcpy function to copy the source guid to the destination guid. Use this function instead of memcpy for copying to the destination guid. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Use void * instead of efi_guid_t * for arguments to allow copying unaligned GUIDs. The GUIDs of configuration tables are __packed. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: __cyg_profile_func_enter/_exitHeinrich Schuchardt1-0/+32
U-Boot can be compiled with function tracing enabled. When compiling with FTRACE __cyg_profile_func_enter() is called when a function is entered and __cyg_profile_func_exit() when the function is left. To avoid a crash we have to define these function for the free-standing UEFI binaries. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: clear screen should move cursor to homeHeinrich Schuchardt1-1/+15
On a VT100 terminal <ESC>[2J should be enough to both clear the whole screen and set the cursor to position (1, 1). But the Linux console does not behave like this. So send an extra <ESC>[H. For reference see the console_codes(4) man page. Add a function description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: git ignore helloworld_efi.SHeinrich Schuchardt1-0/+1
Add *.S to .gitignore. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_selftest: Update .gitignoreSughosh Ganu1-2/+1
Add the following file to .gitignore efi_miniapp_file_image_exception.h Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Use efi_miniapp_*.h instead of file enumeration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>