summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: do not call efi_runtime_detach twiceHeinrich Schuchardt2019-08-151-9/+4
| | | | | | | | | | | | | Commit 7f95104d91cc ("efi_loader: detach runtime in ExitBootServices()") added a call to efi_runtime_detach() to ExitBootServices() but did not remove the call in SetVirtualAddressMap(). Remove the superfluous function call. Correct a comment referring to efi_runtime_detach(). Fixes: 7f95104d91cc ("efi_loader: detach runtime in ExitBootServices()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: parameter check in SetVirtualAddressMapHeinrich Schuchardt2019-08-151-3/+10
| | | | | | | Check the parameters DescriptorSize and DescriptiorVersion of SetVirtualAddressMap() as prescribed by the UEFI specification. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: EFI_PXE_BASE_CODE_PROTOCOL stubHeinrich Schuchardt2019-08-151-3/+129
| | | | | | | | | | | | U-Boot implements the EFI_PXE_BASE_CODE_PROTOCOL because GRUB uses the mode information for booting via PXE. All function pointers in the protocol were NULL up to now which will cause immediate crashes when the services of the protocol are called. Create function stubs for all services of the protocol returning EFI_UNSUPPORTED. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* env: Rename environment.h to env_internal.hSimon Glass2019-08-111-1/+1
| | | | | | | | | | | | | | This file contains lots of internal details about the environment. Most code can include env.h instead, calling the functions there as needed. Rename this file and add a comment at the top to indicate its internal nature. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> [trini: Fixup apalis-tk1.c] Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Drop environment.h header file where not neededSimon Glass2019-08-111-1/+0
| | | | | | | | This header file is now only used by files that access internal environment features. Drop it from various places where it is not needed. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop the ACTION typedefSimon Glass2019-08-111-9/+9
| | | | | | | | | | | | Avoid using a typedef here which is unnecessary. Add an 'env_' prefix to both the enum and its members to make it clear that these are related to the environment. Add an ENV prefix to these two flags so that it is clear what they relate to. Also move them to env.h since they are part of the public API. Use an enum rather than a #define to tie them together. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop _ENTRYSimon Glass2019-08-111-3/+4
| | | | | | | | This typedef does not need to be defined in the search.h header since it is only used in one file (hashtable.c). Remove it from the header and change it to a struct. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Drop the ENTRY typedefSimon Glass2019-08-111-22/+23
| | | | | | | | | | | U-Boot is not supposed to use typedef for structs anymore. Also this name is the same as the ENTRY() macro used in assembler files, and 'entry' itself is widely used in U-Boot (>8k matches). Drop the typedef and rename the struct to env_entry to reduce confusion. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Move env_get() to env.hSimon Glass2019-08-112-0/+2
| | | | | | | Move env_get() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_set() to env.hSimon Glass2019-08-112-0/+2
| | | | | | | Move env_set() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Move env_get_ulong() to env.hSimon Glass2019-08-111-0/+1
| | | | | | | Move env_get_ulong() over to the new header file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* common: Move gzip functions into a new gzip headerSimon Glass2019-08-113-2/+5
| | | | | | | | | As part of the effort to remove things from common.h, create a new header for the gzip functions. Move the function declarations to it and add missing documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
* efi_selftest: sharpen ConvertPointer() testHeinrich Schuchardt2019-07-301-8/+22
| | | | | | | Now that ConvertPointer() is implemented throw an error if the result is incorrect. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement ConvertPointer()Heinrich Schuchardt2019-07-301-4/+71
| | | | | | | Implement the ConvertPointer() runtime service. Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: definition of efi_virtual_address_map()Heinrich Schuchardt2019-07-301-7/+7
| | | | | | | Use efi_uintn_t where the UEFI spec uses UINTN. Use efi_uintn_t also for the result of the division of two efi_uintn_t. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: fix SetVirtualAddressMap unit testHeinrich Schuchardt2019-07-301-0/+1
| | | | | | | | | | | | We read the address map before assigning the memory for the pages that will be mapped to virtual addresses. So these pages will overlap with the entry for EFI_CONVENTIONAL_MEMORY. We have to ensure that every page is described at most once in the map. Remove EFI_CONVENTIONAL_MEMORY from the map that we pass to SetVirtualAddressMap(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: re-enable GRUB workaround on 32bit ARMHeinrich Schuchardt2019-07-302-15/+21
| | | | | | | | | | | | | GRUB on ARM 32bit prior to version 2.04 lacks proper handling of caches. In U-Boot v2019.04 a workaround for this was inadvertently removed. The workaround is currently also needed for booting on systems with caches that cannot be managed via CP15 (e.g. with an i.MX6 CPU). Re-enable the workaround and make it customizable. Fixes: f69d63fae281 ("efi_loader: use efi_start_image() for bootefi") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* lib: uuid: alignment error in gen_rand_uuid()Heinrich Schuchardt2019-07-291-7/+7
| | | | | | | | | | | | | | | | | | | | Packed structures like struct uuid are not aligned. GCC 9.1 therefore throws an error when trying to compile gen_rand_uuid(). lib/uuid.c: In function ‘gen_rand_uuid’: lib/uuid.c:244:2: error: converting a packed ‘struct uuid’ pointer (alignment 1) to a ‘unsigned int’ pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member] 244 | unsigned int *ptr = (unsigned int *)&uuid; | ^~~~~~~~ Generate the uuid in a properly aligned buffer. The byte order of a random number should not matter. Do not call cpu_to_be32() to change the byte order. Reported-by: Ramon Fried <rfried.dev@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge tag 'u-boot-imx-20190719' of ↵Tom Rini2019-07-271-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-imx u-boot-imx-20190719 - CCF for i.MX6 - nandbcb command to write SPL into NAND - Switch to DM (i.MX28) - Boards: Toradex, engicam, DH - Fixes for i.MX8 - Fixes for i.MX7ULP Travis: https://travis-ci.org/sbabic/u-boot-imx/builds/561147504
| * optee: Make TZDRAM config options contingent on CONFIG_OPTEEBryan O'Donoghue2019-07-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit c7b3a7ee5351 ("optee: adjust dependencies and default values for dram") makes the TZDRAM defines for OPTEE show up for all configs as a side-effect. While not harmful its not what we really want. This patch makes the following defines contingent on CONFIG_OPTEE=y CONFIG_OPTEE_TZDRAM_BASE CONFIG_OPTEE_TZDRAM_SIZE Rightly, if you don't have CONFIG_OPTEE=y you don't care about the above two defines. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Cc: Rui Miguel Silva <rui.silva@linaro.org> Acked-by: Rui Miguel Silva <rui.silva@linaro.org>
* | Merge tag 'efi-2019-10-rc1-2' of ↵WIP/23Jul2019Tom Rini2019-07-2312-107/+398
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for v2019.10-rc1 (2) * Implement the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. * Address errors of type -Werror=address-of-packed-member when building with GCC9.1 * Fix an error when adding memory add addres 0x00000000. * Rework some code comments for Sphinx compliance.
| * efi_loader: unaligned access in efi_file_from_path()Heinrich Schuchardt2019-07-161-1/+6
| | | | | | | | | | | | | | | | The device path structure is packed. So no assumption on the alignment is possible. Copy the file name in efi_file_from_path() to assure there is no unaligned access. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: efi_dp_from_file() expect UTF-8 pathHeinrich Schuchardt2019-07-161-9/+31
| | | | | | | | | | | | Properly convert UTF-8 file names to UTF-16. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: support unaligned u16 stringsHeinrich Schuchardt2019-07-161-9/+14
| | | | | | | | | | | | Allow unaligned u16 strings as arguments to u16_strdup() and u16_strlen(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: function comments efi_bootmgr.cHeinrich Schuchardt2019-07-161-7/+40
| | | | | | | | | | | | Convert function descriptions to Sphinx style. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fix comment for struct efi_pool_allocationHeinrich Schuchardt2019-07-161-5/+9
| | | | | | | | | | | | | | Change comment for struct efi_pool_allocation to match Sphinx style. Describe all structure fields. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fix comments for variable servicesHeinrich Schuchardt2019-07-161-4/+23
| | | | | | | | | | | | | | | | Add missing parameter descriptions. Remove an invalid link. Correct the formatting of a function comment. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_driver: use Sphinx style commentsHeinrich Schuchardt2019-07-161-19/+20
| | | | | | | | | | | | Use Sphinx style comments for describing function parameters. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fix comments for efi_update_exit_data()Heinrich Schuchardt2019-07-161-3/+3
| | | | | | | | | | | | Add missing colons after parameter descriptions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: fix function comments in efi_boottime.cHeinrich Schuchardt2019-07-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | scripts/kernel-doc pointed out some errors in the function comments in efi_boottime.c. Add missing and remove superfluous parameter descriptions. Escape * in a function description. Add empty lines for readability. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: Change return type of efi_add_memory_map()Bryan O'Donoghue2019-07-162-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have some inconsistent use of efi_add_memory_map() throughout the code. In particular the return value of efi_add_memory_map() is not interpreted the same way by various users in the codebase. This patch does the following: - Changes efi_add_memory_map() to return efi_status_t. - Adds a method description to efi_add_memory_map(). - Changes efi_add_memory_map() to return EFI_SUCCESS - Returns non-zero for error in efi_add_memory_map() - Updates efi_allocate_pages() to new efi_add_memory_map() - Updates efi_free_pages() to new efi_add_memory_map() - Updates efi_carve_out_dt_rsv() to new efi_add_memory_map() - Updates efi_add_runtime_mmio() to new efi_add_memory_map() Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes") Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Alexander Graf <agraf@csgraf.de> Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_selftest: EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGEHeinrich Schuchardt2019-07-162-0/+193
| | | | | | | | | | | | | | | | Provide a unit test for SetVirtualAddressMap() and ConvertPointer(). As ConvertPointer() is not implemented yet this will spit out some warnings. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGEHeinrich Schuchardt2019-07-162-8/+31
| | | | | | | | | | | | | | | | Implement the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. This requires allocating the event and the event list from runtime data. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_loader: efi_set_virtual_address_map_runtime()Heinrich Schuchardt2019-07-161-1/+1
| | | | | | | | | | | | | | efi_set_virtual_address_map_runtime() must be of type __efi_runtime. Fixes: ee8ebaaaaedc ("efi_loader: split off detaching SetVirtualAddress()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
| * efi_selftest: do not call CloseEvent() after ExitBootServices()Heinrich Schuchardt2019-07-161-23/+0
| | | | | | | | | | | | | | | | Boot services are not available after calling ExitBootServices(). So we should not try to close an event here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
* | lib: rsa: add support to other openssl engine types than pkcs11Vesa Jääskeläinen2019-07-181-0/+18
|/ | | | | | | | | | | There are multiple other openssl engines used by HSMs that can be used to sign FIT images instead of forcing users to use pkcs11 type of service. Relax engine selection so that other openssl engines can be specified and use generic key id definition formula. Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> Cc: Tom Rini <trini@konsulko.com>
* configs: Make USE_TINY_PRINTF depend on SPL||TPL and be defaultTom Rini2019-07-131-0/+2
| | | | | | | | | | | | | | The USE_TINY_PRINTF symbol only changes things within SPL and TPL builds, so make it depend on that support. Next, make it default as within these cases we should rarely have need of more advanced print formats outside of the debug context. To do this, in a few cases we need to correct our Kconfig dependencies as we had cases of non-SPL targets select'ing this symbol. Finally, in the case of a few boards we really do need the full printf functionality. Signed-off-by: Tom Rini <trini@konsulko.com>
* trace: do not limit trace buffer to 2GiBHeinrich Schuchardt2019-07-101-7/+7
| | | | | | | | There is no good reason to limit the trace buffer to 2GiB on a 64bit system. Adjust the types of the relevant parameters. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* trace: make call depth limit customizableHeinrich Schuchardt2019-07-102-2/+17
| | | | | | | | | | | | Up to now we had hard coded values for the call depth up to which trace records are created: 200 for early tracing, 15 thereafter. UEFI applications reach a call depth of 80 or above. Provide customizing settings for the call trace depth limit and the early call trace depth limit. Use the old values as defaults. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* trace: conserve gd registerHeinrich Schuchardt2019-07-101-0/+49
| | | | | | | | | | | An UEFI application may change the value of the register that gd lives in. But some of our functions like get_ticks() access this register. So we have to set the gd register to the U-Boot value when entering a trace point and set it back to the application value when exiting the trace point. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* fdtdec: test: Fix memory leakThierry Reding2019-07-101-0/+2
| | | | | | | | | | | | Free the memory allocated to store the test FDT upon test completion to avoid leaking the memory. We don't bother cleaning up on test failure since the code is broken in that case and should be fixed, in which case the leak would also go away. Reported-by: Tom Rini <tom.rini@gmail.com> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* sandbox: Quit when hang() is calledSimon Glass2019-07-101-0/+3
| | | | | | | | | | | | It doesn't make a lot of sense to hang on sandbox when hang() is called, since the only way out is Ctrl-C. In fact, Ctrl-C does not work if the terminal is in raw mode, which it will be if the command-line has not been reached yet. In that case, Ctrl-Z / kill -9 must be used, which is not very friendly. Avoid all of this by quiting when hang() is called. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: detach runtime in ExitBootServices()Heinrich Schuchardt2019-07-062-1/+4
| | | | | | | | | | | | | | | | Linux can be called with a command line parameter efi=novamap, cf. commit 4e46c2a95621 ("efi/arm/arm64: Allow SetVirtualAddressMap() to be omitted"). In this case SetVirtualAddressMap() is not called after ExitBootServices(). OpenBSD 32bit does not call SetVirtualAddressMap() either. Runtime services must be set to an implementation supported at runtime in ExitBootServices(). Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Suggested-by: Alexander Graf <agraf@csgraf.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: simplify detachingHeinrich Schuchardt2019-07-061-32/+8
| | | | | | | We do not need any array typed detach list. Let's simply update the pointers directly. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: decision on EFI_RT_SUPPORTED_RESET_SYSTEMHeinrich Schuchardt2019-07-062-4/+7
| | | | | | Move the logic determining which board supports reset at runtime to Kconfig. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: split off detaching SetVirtualAddress()Heinrich Schuchardt2019-07-061-11/+58
| | | | | | | | | | | | | The runtime services SetVirtualAddress() and ConvertPointer() become unavailable after SetVirtualAddress(). Other runtime services become unavailable after ExitBootServices. Move the update of SetVirtualAddress() and ConvertPointer() to efi_relocate_runtime_table(). Use functions with the correct signature when detaching. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: test variable services at runtimeHeinrich Schuchardt2019-07-062-0/+95
| | | | | | | | | Provide a unit test for the variable services at runtime. Currently we expect EFI_UNSUPPORTED to be returned as the runtime implementation is still missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: unimplemented runtime servicesHeinrich Schuchardt2019-07-061-32/+2
| | | | | | | Unimplemented runtime services should always return EFI_UNSUPPORTED as described in the UEFI 2.8 spec. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: let the variable driver patch out the runtimeHeinrich Schuchardt2019-07-063-10/+46
| | | | | | | | | Our variable services are only provided at boottime. Therefore when leaving boottime the variable function are replaced by dummy functions returning EFI_UNSUPPORTED. Move this patching of the runtime table to the variable services implementation. Executed it in ExitBootServices(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: clean up runtime detachingHeinrich Schuchardt2019-07-061-23/+55
| | | | | | | | | | | The detaching of the runtime will have to move to ExitBootServices() to encompass operating system that do not call SetVirtualAddressMap(). This patch changes the logic for the relocation of the pointers in the runtime table such that the relocation becomes independent of the entries in the detach list. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>