summaryrefslogtreecommitdiff
path: root/cmd/bootefi.c
AgeCommit message (Collapse)AuthorFilesLines
2020-06-30efi_loader: incorrect check against FDT_ADDR_T_NONEHeinrich Schuchardt1-1/+1
With commit 0d7c2913fdf7 ("cmd: bootefi: Honor the address & size cells properties correctly") addr was replaced by fdt_addr. But not in the check against FDT_ADDR_T_NONE. Fixes: 0d7c2913fdf7 ("cmd: bootefi: Honor the address & size cells properties correctly") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-24cmd: bootefi: Fix fdt_size variable type in efi_carve_out_dt_rsv()Bin Meng1-1/+2
Variable fdt_size should be of type 'fdt_size_t', not 'fdt_addr_t'. Fixes 0d7c2913fdf7: ("cmd: bootefi: Honor the address & size cells properties correctly") Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-19cmd: bootefi: Honor the address & size cells properties correctlyAtish Patra1-3/+6
fdtdec_get_addr_size reads the uses a fixed value for address & size cell properties which may not be correct always. Use the auto variant of the function which automatically reads #address-cells & #size-cells from parent and uses to read the "reg" property. Signed-off-by: Atish Patra <atish.patra@wdc.com> On 32 bit systems fdt_addr_t may be 4 bytes long but size is defined as u64. Avoid filling the upper 4 bytes of the sizep parameter of fdtdec_get_addr_size_auto_parent() with random bytes from the stack by defining a separate variable fdt_size. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-19command: Remove the cmd_tbl_t typedefSimon Glass1-1/+2
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-19common: Drop image.h from common headerSimon Glass1-0/+1
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-17efi_loader: round the memory area in efi_add_memory_map()Michael Walle1-6/+2
Virtually all callers of this function do the rounding on their own. Some do it right, some don't. Instead of doing this in each caller, do the rounding in efi_add_memory_map(). Change the size parameter to bytes instead of pages and remove aligning and size calculation in all callers. There is no more need to make the original efi_add_memory_map() (which takes pages as size) available outside the module. Thus rename it to efi_add_memory_map_pg() and make it static to prevent further misuse outside the module. Signed-off-by: Michael Walle <michael@walle.cc> Add missing comma in sunxi_display.c. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-07efi_loader: put device tree into EfiACPIReclaimMemoryHeinrich Schuchardt1-2/+2
According to the UEFI spec ACPI tables should be placed in EfiACPIReclaimMemory. Let's do the same with the device tree. Suggested-by: Ard Biesheuvel <ardb@kernel.org> Cc: Grant Likely <grant.likely@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-30efi_loader: remove superfluous NULL check in bootefi.cHeinrich Schuchardt1-4/+2
efi_free_pool() and efi_delete_handle() both check if their argument is NULL. The caller should not duplicate this check. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-28efi_loader: only reserve memory if fdt node enabledHeinrich Schuchardt1-1/+2
Sub-nodes of /reserved-memory may be disabled. In this case we should not reserve memory in the memory map. Reported-by: Patrick DELAUNAY <patrick.delaunay@st.com> Fixes: fef907b2e440 ("efi_loader: create reservations after ft_board_setup") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-17cmd: bootefi: Parse reserved-memory node from DTAtish Patra1-9/+34
Currently, bootefi only parses memory reservation block to setup EFI reserved memory mappings. However, it doesn't parse the reserved-memory[1] device tree node that also can contain the reserved memory regions. Add capability to parse reserved-memory node and update the EFI memory mappings accordingly. 1. <U-Boot source>/doc/device-tree-bindings/reserved-memory/reserved-memory.txt] Signed-off-by: Atish Patra <atish.patra@wdc.com> Fix an endless loop. The /reserved-memory node may have children without reg property. Remove a superfluous debug statement. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-17efi_loader: create reservations after ft_board_setupHeinrich Schuchardt1-3/+3
Some memory reservations are made in ft_board_setup(). Ensure that we create reserved memory map entries after ft_board_setup(). The downside of this patch is that if bootefi is called multiple times with an devicetree argument superfluous reservations for the old copies of the device tree will exist. But that is still better than missing a reservation. Deleting the superfluous reservations is not possible because reservations in the memory map are rounded to page size and may be coallesced. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-19efi_loader: fix efi_install_fdt() descriptionHeinrich Schuchardt1-5/+5
In the function description use the correct parameter name. Mention EFI_FDT_USE_INTERNAL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-06dm: core: Create a new header file for 'compat' featuresSimon Glass1-0/+1
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-01-07efi_loader: free load options after executionHeinrich Schuchardt1-12/+14
When be launch a binary via bootefi the bootargs environment variable is used to set the load options in the loaded image protocol. Free memory allocated for load options when the UEFI binary exits. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: export efi_install_fdt()Heinrich Schuchardt1-10/+14
Use a pointer to addressable memory instead of a "physical" address in the virtual address space of the sandbox to efi_install_fdt(). Export the efi_install_fdt() function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: carve out efi_run_image()Heinrich Schuchardt1-19/+32
Provide public function efi_run_imager() which can be used to run an UEFI image from memory. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: use hardware device tree by defaultHeinrich Schuchardt1-8/+14
If the bootefi command is called without passing the address of a device tree, the internal device tree is used. For devices with a hardware device tree it is preferable to used the hardware device tree in this case. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_loader: pass address to efi_install_fdt()Heinrich Schuchardt1-14/+18
As part of moving the parsing of command line arguments to do_bootefi() call efi_install_fdt() with the address of the device tree instead of a string. If the address is EFI_FDT_USE_INTERNAL (= 0), the internal device tree is used. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-11env: Move env_get() to env.hSimon Glass1-0/+1
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>
2019-07-17efi_loader: fix function comments in cmd/bootefi.cHeinrich Schuchardt1-3/+13
Describe efi_set_bootdev(). Change function descriptions to Sphinx style. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-17efi_loader: Change return type of efi_add_memory_map()Bryan O'Donoghue1-2/+2
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>
2019-05-12efi_loader: comments for efi_install_fdt()Heinrich Schuchardt1-3/+8
Describe that efi_install_fdt() defaults to using the device tree indicated by environment variable fdtcontroladdr. ACPI tables and device trees are mutually exclusive. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-12efi_loader: deduplicate code in cmd/bootefi.cHeinrich Schuchardt1-62/+37
Move duplicate initialization code to single instance. Adjust comments of concerned functions. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-07efi_loader: clean up UEFI sub-system initializationHeinrich Schuchardt1-27/+0
allow_unaligned(), switch_to_non_secure_mode(), and efi_init_obj_list() are called in sequence in multiple places. Move calls to allow_unaligned() and switch_to_non_secure_mode() to efi_init_obj_list(). Remove unused includes. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-02efi_loader: implement support of exit dataHeinrich Schuchardt1-3/+8
In case of a failure exit data may be passed to Exit() which in turn is returned by StartImage(). Let the `bootefi` command print the exit data string in case of an error. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-05-02efi_loader: set OsIndicationsSupported at initAKASHI Takahiro1-4/+0
UEFI variables should be installed using well-defined API. Currently we don't support much, but the value of OsIndicationsSupported will be updated once some features are added in the future. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Add comments. Rename a variable. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23efi_loader: need either ACPI table or device treeHeinrich Schuchardt1-26/+72
The EBBR specification prescribes that we should have either an ACPI table or a device tree but not both. Let us enforce this condition in the `bootefi` command. If the bootefi command is called without a device tree parameter use a previously device tree or fall back to the internal device tree. The fdt unit test should not be run on boards with an ACPI table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23efi_loader: rework bootmgr/bootefi using load_image APIAKASHI Takahiro1-86/+94
In the current implementation, bootefi command and EFI boot manager don't use load_image API, instead, use more primitive and internal functions. This will introduce duplicated code and potentially unknown bugs as well as inconsistent behaviours. With this patch, do_efibootmgr() and do_boot_efi() are completely overhauled and re-implemented using load_image API. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Use efi_root as parent handle for the loaded image. LoadImage() should be called with BootPolicy = true by the boot manager. Avoid duplicate free_pool(). Eliminate variable memdp which is not needed after anymore due to "efi_loader: correctly split device path of loaded image". Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: carve out do_bootefi_image() from do_bootefi()AKASHI Takahiro1-55/+67
This is a preparatory patch for reworking do_bootefi() in later patch. All the non-boot-manager-based (that is, bootefi <addr>) code is put into one function, do_bootefi_image(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: carve out bootmgr code from do_bootefi()AKASHI Takahiro1-8/+36
This is a preparatory patch for reworking do_bootefi() in later patch. do_bootmgr_exec() is renamed to do_efibootmgr() as we put all the necessary code into this function. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: move do_bootefi_bootmgr_exec() forwardAKASHI Takahiro1-21/+21
This is a preparatory patch for reworking do_bootefi() in later patch. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: carve out efi_selftest code from do_bootefi()AKASHI Takahiro1-53/+92
This is a preparatory patch for reworking do_bootefi() in later patch. Efi_selftest code is unusual in terms of execution path in do_bootefi(), which make that function complicated and hard to understand. With this patch, all efi_selftest related code will be put in a separate function. The change also includes expanding efi_run_prepare() and efi_run_finish() in do_bootefi_exec(). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: merge efi_install_fdt() and efi_process_fdt()AKASHI Takahiro1-38/+27
This is a preparatory patch for reworking do_bootefi() in later patch. For simplicity, merge two functions. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Return error code of efi_install_configuration_table() when aborting from efi_install_fdt(). Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: carve out fdt handling from do_bootefi()AKASHI Takahiro1-16/+38
This is a preparatory patch for reworking do_bootefi() in later patch. Carve out a function to handle the installation of the device tree as a configuration table in system table. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-23cmd: bootefi: rework set_load_options()AKASHI Takahiro1-9/+27
set_load_options() can fail, so it should return error code to stop invoking an image. In addition, set_load_options() now takes a handle, instead of loaded_image_info, to utilize efi_load_image() in a later patch. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-04-12Change FDT memory type from runtime data to boot services dataIlias Apalodimas1-2/+2
Following Ard's suggestion: Runtime data sections are intended for data that is used by the runtime services implementation. Let's change the type to EFI_BOOT_SERVICES_DATA. This also fixes booting of armv7 using efi and fdtcontroladdr. Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: clean up bootefi_test_prepare()Heinrich Schuchardt1-25/+33
Free resources upon failure. Correct the function description. As there is no need for any special address in the dummy memory device path passed via the EFI_LOADED_IMAGE_PROTOCOL simply use 0 as address. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: fix EFI entry countingHeinrich Schuchardt1-1/+1
`bootefi selftest` fails on qemu-x86_defconfig if efi_selftest() is not invoked using EFI_CALL(). Likewise we call the entry point of EFI payloads with EFI_CALL(efi_start_image()). entry_count indicates if we are in U-Boot (1) or in EFI payload code (0). As we start in U-Boot code the initial value has to be 1. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: use efi_start_image() for bootefiHeinrich Schuchardt1-21/+1
Remove the duplicate code in efi_do_enter() and use efi_start_image() to start the image invoked by the bootefi command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-16efi_loader: set entry point in efi_load_pe()Heinrich Schuchardt1-9/+4
Up to now efi_load_pe() returns the entry point or NULL in case of an error. This does not allow to return correct error codes from LoadImage(). Let efi_load_pe() return a status code and fill in the entry point in the corresponding field of the image object. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-02-13efi_loader: refactor switch to non-secure modeHeinrich Schuchardt1-67/+4
Refactor the switch from supervisor to hypervisor to a new function called at the beginning of do_bootefi(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: move efi_init_obj_list() to a new efi_setup.cAKASHI Takahiro1-77/+0
The function, efi_init_obj_list(), can be shared in different pseudo efi applications, like bootefi/bootmgr as well as my efishell. Moreover, it will be utilized to extend efi initialization, for example, my "removable disk support" patch and "capsule-on-disk support" patch in the future. So with this patch, it will be moved to a new file, efi_setup.c, under lib/efi_loader and exported, making no changes in functionality. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Remove lines deactivated by #if 1 #else Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: avoid unnecessary pointer to long conversionHeinrich Schuchardt1-1/+1
debug() support supports %p to print pointers. The debug message is unique. So there is not need to write a possibly distracting line number. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2019-02-13efi_loader: use named constant for efi_dp_from_mem()Heinrich Schuchardt1-1/+1
When calling efi_dp_from_mem() use a named constant for the memory type. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: create fdt reservation before copyHeinrich Schuchardt1-9/+3
When copying the device we must ensure that the copy does not fall into a memory area reserved by the same. So let's change the sequence: first create memory reservations and then copy the device tree. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: fix memory mapping for sandboxHeinrich Schuchardt1-12/+17
The sandbox is using a virtual address space which is neither the physical address space of the operating system nor the virtual address space in which Linux aplications live. The addresses used insided the flattened device tree use this sandbox virtual address space. The EFI subsystem uses the virtual address space of the operating system and this is where the fdt is stored. Fix all incorrect addresses for the fdt in cmd/bootefi.cmd. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi_loader: macro efi_size_in_pages()Heinrich Schuchardt1-9/+6
When allocating EFI memory pages the size in bytes has to be converted to pages. Provide a macro efi_size_in_pages() for this conversion. Use it in the EFI subsystem and correct related comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi: Rename bootefi_test_finish() to bootefi_run_finish()Simon Glass1-22/+24
This function can be used from do_bootefi_exec() so that we use mostly the same code for a normal EFI application and an EFI test. Rename the function and use it in both places. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi: Create a function to set up for running EFI codeSimon Glass1-21/+31
There is still duplicated code in efi_loader for tests and normal operation. Add a new bootefi_run_prepare() function which holds common code used to set up U-Boot to run EFI code. Make use of this from the existing bootefi_test_prepare() function, as well as do_bootefi_exec(). Also shorten a few variable names. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-12-02efi: Split out test init/uninit into functionsSimon Glass1-21/+64
The functions in bootefi are very long because they mix high-level code and control with the low-level implementation. To help with this, create functions which handle preparing for running the test and cleaning up afterwards. Also shorten the awfully long variable names here. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>