summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | lib: cosmetic update of CONFIG_LIB_ELF descriptionPatrick Delaunay2021-01-161-2/+2
| | | | | | | | | | | | | | | | | | Change 2 typo error in CONFIG_LIB_ELF description: - Supoort => Support - fir => for Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | lib: zlib: our putc() takes only one argumentHeinrich Schuchardt2021-01-161-1/+1
| | | | | | | | | | | | | | | | In contrast to the C99 standard [1] our putc() takes only one argument. [1] ISO/IEC 9899:1999 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | lib: zlib: include ctype.hHeinrich Schuchardt2021-01-161-1/+1
| | | | | | | | | | | | Our ctype.h is in include/linux/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | lib: aes: build failure with DEBUG=1Heinrich Schuchardt2021-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Building fails with DEBUG=1: lib/aes.c: In function ‘debug_print_vector’: lib/aes.c:622:45: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 622 | printf("%s [%d] @0x%08x", name, num_bytes, (u32)data); Pointers can only be cast to (uintptr_t). But anyway we have %p for printing pointers. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* | string: Use memcpy() within memmove() when we canPatrick Delaunay2021-01-161-1/+13
| | | | | | | | | | | | | | | | | | | | | | A common use of memmove() can be handled by memcpy(). Also memcpy() includes an optimization for large sizes: it copies a word at a time. So we can get a speed-up by calling memcpy() to handle our move in this case. Update memmove() to call also memcpy() if the source don't overlap the destination (src + count <= dest). Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* | doc/README.gpt: define partition type GUID for U-Boot environmentRasmus Villemoes2021-01-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting aside a GPT partition for holding the U-Boot environment, having a partition type GUID [1] indicating "Linux filesystem" (as most tools default to) is somewhat misleading - and there's no other well-known type GUID that is better suited. So to have a canonical value to put into the type field, define 3de21764-95bd-54bd-a5c3-4abe786f38a8 to mean a partition holding a U-Boot environment. This is a v5 namespace-name GUID [2], generated [3] from a namespace of "25cbcde0-8642-47c6-a298-1a3a57cd256b" and name "U-Boot environment". Should future type GUIDs be defined in the context of U-Boot, it's sensible to use that same namespace GUID. [1] https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs [2] https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based) [3] https://www.uuidtools.com/v5 Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
* | lib/uuid.c: change prototype of uuid_guid_get_str()Rasmus Villemoes2021-01-161-6/+5
|/ | | | | | | | | | | | | | There's no reason to require an appropriately sized output parameter for the string, that's error-prone should the table ever grow an element with a longer string. We can just return the const char* pointer directly. Update the only caller accordingly, and get rid of pointless ifdeffery in the header so that the compiler always sees a declaration and can thus do type-checking, whether or not PARTITION_TYPE_GUID is enabled or not. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
* efi_selftest: dtbdump support EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt2021-01-131-37/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | The dtbdump.efi binary can already be used to dump the configuration table with the device-tree to a file. With this patch a device-tree file can be loaded. The EFI_DT_FIXUP_PROTOCOL is called to * apply U-Boot's fix-ups * let U-Boot make memory reservations as required by the device-tree * install the new device-tree as configuration table In a next step this configuration table can be dumped. A dtbdump.efi session would look like: DTB Dump ======== => load test.dtb device-tree installed => save fixed-up.dtb fixed-up.dtb written => exit Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt2021-01-133-0/+169
| | | | | | | | | | A boot manager like GRUB can use the protocol to * apply U-Boot's fix-ups to the a device-tree * let U-Boot make memory reservations according to the device-tree * install the device-tree as a configuration table Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: remove outdated TODO in efi_memory.cHeinrich Schuchardt2021-01-131-2/+0
| | | | | | | In efi_mem_sort() adjacent memory regions of same type are coalesced. Remove the remark "Merging of adjacent free regions is missing". Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: typedef efi_string_t text output protocolHeinrich Schuchardt2021-01-131-3/+3
| | | | | | | | We do not want to use typedefs in U-Boot. Do not use efi_string_t in the EFI_TEXT_OUTPUT_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: carve out efi_check_pe()Heinrich Schuchardt2021-01-131-34/+46
| | | | | | Carve out a function to check that a buffer contains a PE-COFF image. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: print boot device and file path in helloworldHeinrich Schuchardt2021-01-131-30/+137
| | | | | | | Let helloworld.efi print the device path of the boot device and the file path as provided by the loaded image protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement non-blocking file servicesHeinrich Schuchardt2021-01-131-51/+266
| | | | | | | Implement services OpenEx(), ReadEx(), WriteEx(), FlushEx() of the EFI_FILE_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge tag 'dm-pull-5jan21' of git://git.denx.de/u-boot-dm into nextTom Rini2021-01-053-4/+10
|\ | | | | | | | | | | | | | | | | Driver model: make some udevice fields private Driver model: Rename U_BOOT_DEVICE et al. dtoc: Tidy up and add more tests ns16550 code clean-up x86 and sandbox minor fixes for of-platdata dtoc prepration for adding build-time instantiation
| * timer: Use a shorter error in TPLSimon Glass2021-01-051-2/+8
| | | | | | | | | | | | | | | | | | This error should not happen in normal use. Reduce the length of it to save space in the image. Add an empty spl.h file to sh since it appears to lack this. Signed-off-by: Simon Glass <sjg@chromium.org>
| * dm: Use access methods for dev/uclass private dataSimon Glass2021-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | Most drivers use these access methods but a few do not. Update them. In some cases the access is not permitted, so mark those with a FIXME tag for the maintainer to check. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Pratyush Yadav <p.yadav@ti.com>
| * serial: Update NS16550_t and struct NS16550Simon Glass2021-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | Typedefs should not be used in U-Boot and structs should be lower case. Update the code to use struct ns16550 consistently. Put a header guard on the file while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
* | Merge tag 'v2021.01-rc5' into nextTom Rini2021-01-051-1/+1
|\ \ | |/ |/| | | | | | | Prepare v2021.01-rc5 Signed-off-by: Tom Rini <trini@konsulko.com>
| * efi_loader: use after free in efi_exit()Heinrich Schuchardt2020-12-291-5/+12
| | | | | | | | | | | | | | Do not use data from the loaded image object after deleting it. Fixes: 126a43f15b36 ("efi_loader: unload applications upon Exit()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: efi_signal_event() fix comment typosHeinrich Schuchardt2020-12-291-2/+2
| | | | | | | | | | | | Add missing commas. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: avoid invalid freeHeinrich Schuchardt2020-12-291-1/+1
| | | | | | | | | | | | | | | | load_options passed from do_efibootmgr() to do_bootefi_exec() may contain invalid data from the stack which will lead to an invalid free(). Fixes: 0ad64007feb9 ("efi_loader: set load options in boot manager") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: escape key handlingHeinrich Schuchardt2020-12-291-0/+12
| | | | | | | | | | | | | | | | | | | | Up to now the escape key was not correctly detected in UEFI applications. We had to hit it twice for a single escape to be recognized. Use a 10 ms delay to detect if we are dealing with the escape key or an escape sequence. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: missing parentheses after ifHeinrich Schuchardt2020-12-291-1/+1
| | | | | | | | | | | | | | IS_ENABLED() contains parentheses. But we should still put extra parentheses around it in an if statement for readability. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: Extra checks while opening an OPTEE sessionIlias Apalodimas2020-12-261-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | When opening an OP-TEE session we need to check the internal return value of OP-TEE call arguments as well the return code of the function itself. The code was also ignoring to close the OP-TEE session in case the shared memory registration failed. Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: make variable store size customizableHeinrich Schuchardt2020-12-201-0/+14
| | | | | | | | | | | | | | | | | | | | | | Currently the size of the buffer to keep UEFI variables in memory is fixed at 16384 bytes. This size has proven to be too small for some use cases. Make the size of the memory buffer for UEFI variables customizable. Reported-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * binman: Remove additional backslashMichal Simek2020-11-301-1/+1
| | | | | | | | | | | | | | | | | | The origin patch didn't have this change and it was caused by manual resolution where additional backslash was added. Fixes: 6723b4c6ca7b ("binman: Call helper function binman_set_rom_offset() to fill offset") Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | efi_loader: Enable uefi capsule authenticationSughosh Ganu2020-12-311-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for enabling uefi capsule authentication. This feature is enabled by setting the environment variable "capsule_authentication_enabled". The following configs are needed for enabling uefi capsule update and capsule authentication features on the platform. CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT=y CONFIG_EFI_CAPSULE_FIRMWARE=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_CAPSULE_AUTHENTICATE=y Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | efi: capsule: Add support for uefi capsule authenticationSughosh Ganu2020-12-313-2/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | Add support for authenticating uefi capsules. Most of the signature verification functionality is shared with the uefi secure boot feature. The root certificate containing the public key used for the signature verification is stored as part of the device tree blob. The root certificate is stored as an efi signature list(esl) file -- this file contains the x509 certificate which is the root certificate. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | efi_loader: Re-factor code to build the signature store from efi signature listSughosh Ganu2020-12-311-42/+61
| | | | | | | | | | | | | | | | | | | | | | The efi_sigstore_parse_sigdb function reads the uefi authenticated variable, stored in the signature database format and builds the signature store structure. Factor out the code for building the signature store. This can then be used by the capsule authentication routine to build the signature store even when the signature database is not stored as an uefi authenticated variable Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | efi_loader: Make the pkcs7 header parsing function an externSughosh Ganu2020-12-312-89/+89
| | | | | | | | | | | | | | | | The pkcs7 header parsing functionality is pretty generic, and can be used by other features like capsule authentication. Make the function an extern, also changing it's name to efi_parse_pkcs7_header Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | efi_loader: Add logic to parse EDKII specific fmp payload headerSughosh Ganu2020-12-311-0/+41
| | | | | | | | | | | | | | | | | | | | When building the capsule using scripts in edk2, a fmp header is added on top of the binary payload. Add logic to detect presence of the header. When present, the pointer to the image needs to be adjusted as per the size of the header to point to the actual binary payload. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | crypto: Fix the logic to calculate hash with authattributes setSughosh Ganu2020-12-311-11/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC 2315 Section 9.3 describes the message digesting process. The digest calculated depends on whether the authenticated attributes are present. In case of a scenario where the authenticated attributes are present, the message digest that gets signed and is part of the pkcs7 message is computed from the auth attributes rather than the contents field. Check if the auth attributes are present, and if set, use the auth attributes to compute the hash that would be compared with the encrypted hash on the pkcs7 message. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* | efi_loader: event queueingHeinrich Schuchardt2020-12-311-1/+1
| | | | | | | | | | | | | | | | When a new event is queued we have to process the event queue by calling efi_process_event_queue(). But there is not reason to call the function when the event is not queueable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: Add size checks to efi_create_indexed_name()Ilias Apalodimas2020-12-312-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | Although the function description states the caller must provide a sufficient buffer, it's better to have in function checks that the destination buffer can hold the intended value. So let's add an extra argument with the buffer size and check that before doing any copying. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: Remove unconditional installation of file2 protocol for initrdIlias Apalodimas2020-12-311-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up to now we install the EFI_LOAD_FILE2_PROTOCOL to load an initrd unconditionally. Although we correctly return various EFI exit codes depending on the file status (i.e EFI_NO_MEDIA, EFI_NOT_FOUND etc), the kernel loader only falls back to the cmdline interpreted initrd if the protocol is not installed. This creates a problem for EFI installers, since they won't be able to load their own initrd and start the installation. A following patch introduces a different logic where we search for an initrd path defined in an EFI variable named 'Initrd####'. If the bootmgr is used to launch the EFI payload, we'll will try to match the BootCurrent value and find the corresponding initrd (i.e Boot0000 -> Initrd0000 etc). If the file is found, we'll install the required protocol which the kernel's efi-stub can use and load our initrd. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: Remove unused headers from efi_load_initrd.cIlias Apalodimas2020-12-311-5/+3
| | | | | | | | | | | | | | | | dm.h and env.h serve no purpose here. Remove them and sort the remaining in alphabetical order. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: use after free in efi_exit()Heinrich Schuchardt2020-12-311-5/+12
| | | | | | | | | | | | | | Do not use data from the loaded image object after deleting it. Fixes: 126a43f15b36 ("efi_loader: unload applications upon Exit()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: efi_signal_event() fix comment typosHeinrich Schuchardt2020-12-311-2/+2
| | | | | | | | | | | | Add missing commas. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: avoid invalid freeHeinrich Schuchardt2020-12-311-1/+1
| | | | | | | | | | | | | | | | load_options passed from do_efibootmgr() to do_bootefi_exec() may contain invalid data from the stack which will lead to an invalid free(). Fixes: 0ad64007feb9 ("efi_loader: set load options in boot manager") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: escape key handlingHeinrich Schuchardt2020-12-311-0/+12
| | | | | | | | | | | | | | | | | | | | Up to now the escape key was not correctly detected in UEFI applications. We had to hit it twice for a single escape to be recognized. Use a 10 ms delay to detect if we are dealing with the escape key or an escape sequence. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: missing parentheses after ifHeinrich Schuchardt2020-12-311-1/+1
| | | | | | | | | | | | | | IS_ENABLED() contains parentheses. But we should still put extra parentheses around it in an if statement for readability. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: Extra checks while opening an OPTEE sessionIlias Apalodimas2020-12-311-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | When opening an OP-TEE session we need to check the internal return value of OP-TEE call arguments as well the return code of the function itself. The code was also ignoring to close the OP-TEE session in case the shared memory registration failed. Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | efi_loader: make variable store size customizableHeinrich Schuchardt2020-12-311-0/+14
| | | | | | | | | | | | | | | | | | | | | | Currently the size of the buffer to keep UEFI variables in memory is fixed at 16384 bytes. This size has proven to be too small for some use cases. Make the size of the memory buffer for UEFI variables customizable. Reported-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | fdt: Use phandle to distinguish DT nodes with same nameAswath Govindraju2020-12-222-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While assigning the sequence number to subsystem instances by reading the aliases property, only DT nodes names are compared and not the complete path. This causes a problem when there are two DT nodes with same name but have different paths. In arch/arm/dts/k3-am65-main.dtsi there are two USB controllers with the same device tree node name but different path. When aliases are defined for these USB controllers then fdtdec_get_alias_seq() fails to pick the correct instance for a given index. fdt_path_offset() function is slow and this would effect the U-Boot startup. To avert the time penalty on all boards, apply this extra check only when required by using a config option. Fix it by comparing the phandles of DT nodes after the node names match, under a config option. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Fix whitespace error in Kconfig: Signed-off-by: Simon Glass <sjg@chromium.org>
* | sandbox: implement runtime system resetHeinrich Schuchardt2020-12-221-1/+2
| | | | | | | | | | | | | | | | Implement a reset function that we can call after ExitBootServices(), when all driver model devices are gone. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* | x86: Simplify acpi_device_infer_name()Simon Glass2020-12-181-24/+3
| | | | | | | | | | | | | | There is no-longer any need to check if sequence numbers are valid, since this is ensured by driver model. Drop the unwanted logic. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: Avoid accessing seq directlySimon Glass2020-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | At present various drivers etc. access the device's 'seq' member directly. This makes it harder to change the meaning of that member. Change access to go through a function instead. The drivers/i2c/lpc32xx_i2c.c file is left unchanged for now. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass2020-12-133-7/+7
| | | | | | | | | | | | | | Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <sjg@chromium.org>
* | dm: treewide: Rename dev_get_platdata() to dev_get_plat()Simon Glass2020-12-131-3/+3
| | | | | | | | | | | | Rename this to be consistent with the change from 'platdata'. Signed-off-by: Simon Glass <sjg@chromium.org>