summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* binman: Allow reading entries from a subnodeSimon Glass2021-01-271-0/+18
| | | | | | | | | Some images may have multiple copies of the same thing, e.g. two versions of the read/write U-Boots. It is necessary to read data from one or other of these under selection of the verified-boot logic. Add a function to select the subnode to use. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move selection of the binman node into a functionSimon Glass2021-01-271-10/+33
| | | | | | | | | | Move this logic out of the main init function so it is available for other purpose. Use a different error when multiple-images is in use but no subnode is available. This makes it easier to determine what is wrong. Signed-off-by: Simon Glass <sjg@chromium.org>
* crc32: Exclude crc32 from TPLSimon Glass2021-01-271-0/+2
| | | | | | | | Unfortunately the toolchain often brings in the crc32 table even if the function is not actually used. For now, exclude it from the TPL build, which is very sensitive to size. Signed-off-by: Simon Glass <sjg@chromium.org>
* display_options: Use USE_TINY_PRINTF for SPL checkSimon Glass2021-01-271-5/+4
| | | | | | | At present this code uses a simple printf() format if running in SPL. But SPL can use the full printf. Use USE_TINY_PRINTF instead. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()Simon Glass2021-01-271-1/+1
| | | | | | | This setting may be different in SPL and TPL. Update the code to check the correct setting. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdtdec: Update the missing-devicetree messageSimon Glass2021-01-271-1/+2
| | | | | | | | | This includes information about sandbox which is not relevant for most boards. Drop it. Also add the address to help figure out the problem. Signed-off-by: Simon Glass <sjg@chromium.org>
* lib: rsa: rsa-verify: don't look for keys in the FIT imagePhilippe Reynes2021-01-271-2/+2
| | | | | | | | | In the function rsa_verify_hash, if the "main" key doesn't work, u-boot try others keys. But it searches those keys in the FIT image instead of the u-boot device tree. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* efi_loader: correct EFI_BLOCK_IO_PROTOCOL.Media.LastBlockHeinrich Schuchardt2021-01-231-9/+21
| | | | | | | | | | | | | The field Media.LastBlock of the EFI_BLOCK_IO_PROTOCOL.Media was filled incorrectly both for block devices as well as for partitions. The field must be filled with the index of the last logical block (LBA): * block devices: device size minus 1 * partitions: partition size minus 1 Reported-by: Alexander von Gluck IV <kallisti5@unixzen.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: notification with TPL_APPLICATION not allowedHeinrich Schuchardt2021-01-231-1/+8
| | | | | | | | | | | | | | The UEFI specification requires event notification levels to be > TPL_APPLICATION and <= TPL_HIGH_LEVEL. With the patch the CreateEvent() and CreatedEventEx() services are changed to check that the notification level is not TPL_APPLICATION. Reference: UEFI Specification 2.8 Errata B, table 27 "TPL Restrictions", "Event Notification Levels" Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: capsule: fix SIZEOF_MISMATCH warningAKASHI Takahiro2021-01-231-1/+1
| | | | | | | | | | | | | | | | | CID 316361 says: > Passing argument "count * 8UL /* sizeof (*files) */" to > function "dlmalloc" and then casting the return value to "u16 **" is > suspicious. In this particular case "sizeof (u16 **)" happens to be equal > to "sizeof (u16 *)", but this is not a portable assumption. > > 767 tmp_files = malloc(count * sizeof(*files)); The change in this patch fixes the ambiguity. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Fixes: CID 316361 For readability use *tmp_files instead of tmp_files[0] Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: fix efi_load_image_from_path()Heinrich Schuchardt2021-01-231-4/+1
| | | | | | | Use the correct GUID when closing the file load protocol. Remove an unnecessary check (Coverity CID 316363). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge tag 'efi-2021-04-rc1-2' of ↵Tom Rini2021-01-2013-248/+784
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2021-04-rc1-2 * Provide a test tool for initial RAM disk provided via load file2 protocol. * Make more items configurable to reduce code size: * Boot manager * EFI_DT_FIXUP_PROTOCOL * EFI_DEVICE_PATH_UTILITIES_PROTOCOL * Bug fixes * avoid EFI runtime symbols in global symbol table
| * efi_loader: Avoid emitting efi_var_buf to .GOTIlias Apalodimas2021-01-202-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Atish reports that on RISC-V, accessing the EFI variables causes a kernel panic. An objdump of the file verifies that, since the global pointer for efi_var_buf ends up in .GOT section which is not mapped in virtual address space for Linux. <snip of efi_var_mem_find> 0000000000000084 <efi_var_mem_find>: 84: 715d addi sp,sp,-80 * objdump -dr 0000000000000086 <.LCFI2>: 86: e0a2 sd s0,64(sp) 88: fc26 sd s1,56(sp) 8a: e486 sd ra,72(sp) 8c: f84a sd s2,48(sp) 8e: f44e sd s3,40(sp) 90: f052 sd s4,32(sp) 92: ec56 sd s5,24(sp) 94: 00000497 auipc s1,0x0 94: R_RISCV_GOT_HI20 efi_var_buf 98: 0004b483 ld s1,0(s1) # 94 <.LCFI2+0xe> 98: R_RISCV_PCREL_LO12_I .L0 98: R_RISCV_RELAX *ABS* * objdump -t 0000000000000084 g F .text.efi_runtime 00000000000000b8 efi_var_mem_find With the patch applied: * objdump -dr 0000000000000086 <.LCFI2>: 86: e0a2 sd s0,64(sp) 88: fc26 sd s1,56(sp) 8a: e486 sd ra,72(sp) 8c: f84a sd s2,48(sp) 8e: f44e sd s3,40(sp) 90: f052 sd s4,32(sp) 92: ec56 sd s5,24(sp) 94: 00000497 auipc s1,0x0 94: R_RISCV_PCREL_HI20 .LANCHOR0 94: R_RISCV_RELAX *ABS* 98: 00048493 mv s1,s1 98: R_RISCV_PCREL_LO12_I .L0 98: R_RISCV_RELAX *ABS* * objdump -t 0000000000000008 l O .data.efi_runtime 0000000000000008 efi_var_buf On arm64 this works, because there's no .GOT entries for this and everything is converted to relative references. * objdump -dr (identical pre-post patch, only the new function shows up) 00000000000000b4 <efi_var_mem_find>: b4: aa0003ee mov x14, x0 b8: 9000000a adrp x10, 0 <efi_var_mem_compare> b8: R_AARCH64_ADR_PREL_PG_HI21 .data.efi_runtime bc: 91000140 add x0, x10, #0x0 bc: R_AARCH64_ADD_ABS_LO12_NC .data.efi_runtime c0: aa0103ed mov x13, x1 c4: 79400021 ldrh w1, [x1] c8: aa0203eb mov x11, x2 cc: f9400400 ldr x0, [x0, #8] d0: b940100c ldr w12, [x0, #16] d4: 8b0c000c add x12, x0, x12 So let's switch efi_var_buf to static and create a helper function for anyone that needs to update it. Fixes: e01aed47d6a0 ("efi_loader: Enable run-time variable support for tee based variables") Reported-by: Atish Patra <atishp@atishpatra.org> Tested-by: Atish Patra <atish.patra@wdc.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_selftest: use CRLF as line endings in dtbdumpHeinrich Schuchardt2021-01-201-42/+52
| | | | | | | | | | | | | | | | EFI applications must use CR LF as line endings. Provide a print() function to reduce code size. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_selftest: provide initrddump test toolHeinrich Schuchardt2021-01-203-2/+456
| | | | | | | | | | | | | | | | Provide an UEFI application to save the initial RAM disk provided by U-Boot via the Load File2 protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * efi_selftest: don't compile dtbdump if GENERATE_ACPI_TABLEHeinrich Schuchardt2021-01-201-2/+3
| | | | | | | | | | | | | | If we are using ACPI tables instead of a device tree, we don't need the dtbdump.efi test tool. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_selftest: ask before overwriting in dtbdump.efiHeinrich Schuchardt2021-01-201-1/+59
| | | | | | | | | | | | Before overwriting an existing file ask the user. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: remove EFI_UNICODE_COLLATION_PROTOCOLHeinrich Schuchardt2021-01-203-50/+6
| | | | | | | | | | | | | | | | | | | | | | | | In EFI 1.10 a version of the Unicode collation protocol using ISO 639-2 language codes existed. This protocol is not part of the UEFI specification any longer. It was however required to run the UEFI Self Certification Test (SCT) II, version 2.6, 2017. So we implemented it for the sole purpose of running the SCT. As the SCT does not need the protocol anymore it is time for removal. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: EFI_DEVICE_PATH_UTILITIES_PROTOCOL configurableHeinrich Schuchardt2021-01-203-1/+10
| | | | | | | | | | | | | | | | | | | | Allow the EFI_DEVICE_PATH_UTILITIES_PROTOCOL to be disabled via configuration. On systems that are very tight on U-Boot image size we may want to disable the protocol. As it is required to run the UEFI Shell enable it by default. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: make EFI_DT_FIXUP_PROTOCOL configurableHeinrich Schuchardt2021-01-203-5/+12
| | | | | | | | | | | | Allow EFI_DT_FIXUP_PROTOCOL to be disabled via configuration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fixup protocol, avoid forward declarationHeinrich Schuchardt2021-01-201-10/+17
| | | | | | | | | | | | | | | | Avoid a forward declaration. Add a missing function description. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: make the UEFI boot manager configurableHeinrich Schuchardt2021-01-202-1/+9
| | | | | | | | | | | | | | | | | | Some boards are very tight on the binary size. Booting via UEFI is possible without using the boot manager. Provide a configuration option to make the boot manager available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: move load options to new moduleHeinrich Schuchardt2021-01-193-135/+150
| | | | | | | | | | | | | | Move all load options related functions to a new module. So that they can be compiled independently. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* | lib: uuid: use RNG device if presentMatthias Brugger2021-01-191-3/+18
|/ | | | | | | | When calculating a random UUID we use a weak seed. Use a RNG device if present to increase entropy. Signed-off-by: Matthias Brugger <mbrugger@suse.com> Reviewed-by: Torsten Duwe <duwe@suse.de>
* Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscvTom Rini2021-01-181-0/+1
|\ | | | | | | | | | | | | | | - Update qemu-riscv.rst build instructions. - Add support for SPI on Kendryte K210. - Add Microchip PolarFire SoC Icicle Kit support. - Add support for an early timer. - Select TIMER_EARLY to avoid infinite recursion for Trace.
| * trace: select TIMER_EARLY to avoid infinite recursionPragnesh Patel2021-01-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When tracing functions is enabled this adds calls to __cyg_profile_func_enter() and __cyg_profile_func_exit() to the traced functions. __cyg_profile_func_enter() and __cyg_profile_func_exit() invoke timer_get_us() to record the entry and exit time. initr_dm() will make gd->dm_root = NULL and gd->timer = NULL, so timer_get_us() -> get_ticks() -> dm_timer_init() will lead to an indefinite recursion. So select TIMER_EARLY when tracing got enabled. Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rick Chen <rick@andestech.com>
* | 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>