summaryrefslogtreecommitdiff
path: root/cmd/efidebug.c
AgeCommit message (Collapse)Author
2023-01-06efi_loader: carve out efi_get_memory_map_alloc()Heinrich Schuchardt
Carve out code from efidebug command used to read the memory map. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-02efi_loader: utility function to check the variable name is "Boot####"Masahisa Kojima
Some commands need to enumerate the existing UEFI load option variable("Boot####"). This commit transfers some code from cmd/efidebug.c to lib/efi_loder/, then exposes efi_varname_is_load_option() function to check whether the UEFI variable name is "Boot####". Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-02efi_loader: don't use EFI_LOADER_DATA internallyHeinrich Schuchardt
EFI_LOADER_DATA/CODE is reserved for EFI applications. Memory allocated by U-Boot for internal usage should be EFI_BOOT_SERVICES_DATA or _CODE or EFI_RUNTIME_SERVICES_DATA or _CODE. Reported-by: François-Frédéric Ozog <ff@ozog.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: François-Frédéric Ozog <ff@ozog.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-10-16cmd: simplify efidebugHeinrich Schuchardt
* don't use EFI_CALL() for variable services * don't use runtime pointer to access exported function Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-10-06cmd: simplify command efidebugHeinrich Schuchardt
Currently we have subcommands 'efidebug dh' which shows protocols per handle and 'efidebug devices' which shows the device path. None shows which U-Boot device matches the handle. Change 'efidebug dh' to show the device path and the U-Boot device if any is associated with the handle. Remove 'efidebug devices'. Old output of 'efidebug dh': Handle Protocols ================ ==================== 000000001b22e690 Device Path, Block IO 000000001b22e800 Device Path, Block IO, system, Simple File System New output of 'efidebug dh': 000000001b22e690 (host0) /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00) Block IO 000000001b22e800 (host0:1) /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00)/HD(1,GPT,7e5c17c5-3f5f-49d0-ae96-511b21d7f273,0x800,0x3f7df) Block IO system Simple File System Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-10-06cmd: simplify do_efi_boot_add()Heinrich Schuchardt
Use efi_convert_string() to convert a UTF-8 to a UTF-16 string. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-08-13cmd: efidebug: Add missing \n at the end of messageMichal Simek
Currently message is not intended that prompt end up at the end of debug line. For example like this: DFU alt info setting: done DFU entities configuration failed! (partition table does not match dfu_alt_info?) Firmware update failed: <NULL> Cannot handle a capsule at 10000000Zynq> Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-04-09cmd: efidebug: Disable 'capsule disk-update' when CONFIG_EFI_CAPSULE_ON_DISK=nMasami Hiramatsu
Disable 'capsule disk-update' option for the efidebug command when CONFIC_EFI_CAPSULE_ON_DISK is disabled, because this option is available only when the EFI capsule update on disk is enabled. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-03-26cmd: efidebug: simplify do_efi_boot_add()Heinrich Schuchardt
When calling efi_dp_from_name() we are not interested in the device part. Just pass NULL as an argument. Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-03-20efi_loader: use short-form DP for load optionsHeinrich Schuchardt
The GUID of partitions is sufficient for identification and will stay constant in the lifetime of a boot option. The preceding path of the device-path may change due to changes in the enumeration of devices. Therefore it is preferable to use the short-form of device-paths in load options. Adjust the 'efidebug boot add' command accordingly. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-03efi: Use 16-bit unicode stringsSimon Glass
At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-01-19cmd: efidebug: simplify printing GUIDsHeinrich Schuchardt
Use "%pS" to print text representations of GUIDs. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-10-21efi_loader: avoid multiple local copies of lf2_initrd_guidHeinrich Schuchardt
Create the GUID as a global variable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-10-21efi_loader: efi_dp_from_lo() unused parameter sizeHeinrich Schuchardt
Parameter size is never used in function efi_dp_from_lo(). Remove it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-10-21efi_loader: simplify show_efi_boot_opt_data()Heinrich Schuchardt
Use printf code %pD for printing device paths. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-10-21efi_loader: efi_dp_from_lo() don't copy GUIDHeinrich Schuchardt
Instead of copying a GUID and then using a pointer to the copy for calling guidcmp(), just pass the pointer to the orginal GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-08-02global: Convert simple_strtoul() with hex to hextoul()Simon Glass
It is a pain to have to specify the value 16 in each call. Add a new hextoul() function and update the code to use it. Add a proper comment to simple_strtoul() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-28efidebug: correct display of BootOrderHeinrich Schuchardt
Display the number of the boot option and not its index. Fixes: 2ecee31017bf ("efi_loader: use efi_create_indexed_name()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-05-25efi_loader: simplify accessing variablesHeinrich Schuchardt
Use efi_get_variable_int() instead of EFI_CALL(RT->get_variable()). Use efi_set_variable_int() instead of EFI_CALL(efi_set_variable()). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: use efi_create_indexed_name()Heinrich Schuchardt
Simplify the creation of indexed variable names like 'Boot0000' by using function efi_create_indexed_name(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: simplify show_efi_boot_order()Heinrich Schuchardt
To print a UTF-16 string use %ls instead of converting string to UTF-8. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-05-25efi_loader: simplify show_efi_boot_opt_data()Heinrich Schuchardt
To print a UTF-16 string use %ls instead of converting string to UTF-8. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-04-10efi_loader: simplify efi_get_device_path_text()Heinrich Schuchardt
Replace static function efi_get_device_handle_info() by a simplified function efi_get_device_path_text() avoiding EFI_CALL(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25cmd: efi: ESRT table debug printJose Marinho
This commit enables the ESRT printing from the u-boot shell by invoking: - efidebug capsule esrt CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Ilias Apalodimas <ilias.apalodimas@linaro.org> CC: Andre Przywara <andre.przywara@arm.com> CC: Alexander Graf <agraf@csgraf.de> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efi: Add ESRT to the EFI system tableJose Marinho
The ESRT is initialised during efi_init_objlist after efi_initialize_system_table(). The ESRT is recreated from scratch at the following events: - successful UpdateCapsule; - FMP instance install. The code ensures that every ESRT entry has a unique fw_class value. Limitations: - The ESRT is not updated if an FMP instance is uninstalled; - the fields image_type and flags are in the current implementation left undefined. Setting these values will require a per-platform function that returns the image_type/flags as a function of the image fw_class. CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Ilias Apalodimas <ilias.apalodimas@linaro.org> CC: Andre Przywara <andre.przywara@arm.com> CC: Alexander Graf <agraf@csgraf.de> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Remove two EFI_CALL() indirections. Move ESRT GUID in efidebug's list of GUIDs. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efidebug: add multiple device path instances on Boot####Ilias Apalodimas
The UEFI spec allows a packed array of UEFI device paths in the FilePathList[] of an EFI_LOAD_OPTION. The first file path must describe the loaded image but the rest are OS specific. Previous patches parse the device path and try to use the second member of the array as an initrd. So let's modify efidebug slightly and install the second file described in the command line as the initrd device path. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-03-25efi: Fix compiler warningsSimon Glass
This occur when building on Raspberry Pi 400 (32-bit ARM). Fix them. Examples: cmd/efidebug.c: In function ‘do_efi_capsule_update’: cmd/efidebug.c:75:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL)); ^ include/efi_loader.h:104:9: note: in definition of macro ‘EFI_CALL’ typeof(exp) _r = exp; \ ^~~ cmd/efidebug.c:75:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL)); ^ include/efi_loader.h:104:19: note: in definition of macro ‘EFI_CALL’ typeof(exp) _r = exp; \ ^~~ In file included from include/common.h:20, from lib/efi_loader/efi_capsule.c:9: lib/efi_loader/efi_capsule.c: In function ‘efi_update_capsule’: include/efi_loader.h:83:8: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 10 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \ ^~~~~~~~~~~~~~~~~~ include/linux/printk.h:37:21: note: in definition of macro ‘pr_fmt’ #define pr_fmt(fmt) fmt ^~~ include/log.h:229:2: note: in expansion of macro ‘log’ log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \ ^~~ include/log.h:249:2: note: in expansion of macro ‘debug_cond’ debug_cond(_DEBUG, fmt, ##args) ^~~~~~~~~~ include/efi_loader.h:83:2: note: in expansion of macro ‘debug’ debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \ ^~~~~ lib/efi_loader/efi_capsule.c:444:2: note: in expansion of macro ‘EFI_ENTRY’ EFI_ENTRY("%p, %lu, %llu\n", capsule_header_array, capsule_count, ^~~~~~~~~ lib/efi_loader/efi_capsule.c:444:19: note: format string is defined here EFI_ENTRY("%p, %lu, %llu\n", capsule_header_array, capsule_count, ~~^ %u Signed-off-by: Simon Glass <sjg@chromium.org> Replace (uintptr_t)NULL by 0. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-26cmd/efidebug: add firmware management protocol GUIDHeinrich Schuchardt
Add missing GUID short text used in the efidebug tables and efidebug dh sub-commands. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-04efi_loader: install UEFI System Partition GUIDHeinrich Schuchardt
On the handle for the UEFI System Partition we must install the System Partition GUID (with a NULL interface). Let the efidebug command display the GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-23cmd: efidebug: always check return code from get_variable()AKASHI Takahiro
CID 316364 says: > Null pointer dereferences (FORWARD_NULL) > printf("Result total size: 0x%x\n", result->variable_total_size); at do_efi_capsule_res(). The code is basically safe because a buffer for "result" is allocated by malloc() and filled up by the second get_variable(), which fails any way if the allocation has failed. But the first (and second) get_variable() possibly returns an error other than EFI_SUCCESS. We always need to check the return code from get_variable() before accessing the data in "result". While this change won't suppress CID 316364, the resulting code is much safer. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-20efi_loader: make the UEFI boot manager configurableHeinrich Schuchardt
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>
2021-01-13efi_loader: implement EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt
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>
2020-12-31efidebug: capsule: Add a command to update capsule on diskSughosh Ganu
Add a efidebug subcommand to initiate a firmware update using the efi firmware management protocol(fmp) set_image routine. The firmware update can be initiated through 'efidebug capsule disk-update' This would locate the efi capsule file on the efi system partition, and call the platform's set_image fmp routine to initiate the firmware update. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2020-12-03cmd: add "efidebug capsule" commandAKASHI Takahiro
"efidebug capsule" is more or less a debugging utility. efidebug capsule update: invoke UpdateCapsule against data on memory efidebug capsule show: show a capsule header efidebug capsule result: dump a capsule result variable Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2020-12-03cmd: efidebug: Add support for TCG2 final events tableIlias Apalodimas
A previous commit is adding EFI_TCG2_PROTOCOL, which in it's eventlog support registers an EFI configuration table. Let's add the necessary GUID so 'efidebug table' command can display table names properly. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-09-27efi_loader: efidebug display RNG protocolHeinrich Schuchardt
Add the Random Number Generator (RNG) protocol to the GUIDs that the 'efidebug dh' protocol can replace by a text. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-13cmd/efidebug: missing initialization of load_optionsHeinrich Schuchardt
Variable load_options must be initialized to NULL to avoid a segmentation fault when freeing the memory this variable points to. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-08efi_loader: set load options in boot managerHeinrich Schuchardt
Up to now we used the value of the bootargs environment variable as load options in the boot manager. This is not correct. The data has to be taken from the Boot#### variable. Let the boot manager copy the optional data of the EFI_LOAD_OPTION as load options to the loaded image protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-06-03efi_loader: validate load optionHeinrich Schuchardt
For passing the optional data of the load option to the loaded imaged protocol we need its size. efi_deserialize_load_option() is changed to return the size of the optional data. As a by-product we get a partial validation of the load option. Checking the length of the device path remains to be implemented. Some Coverity defects identified the load options as user input because get_unaligned_le32() and get_unaligned_le16() is called. But non of these Coverity defects can be resolved without marking functions with Coverity specific tags. Reported-by: Coverity (CID 303760) Reported-by: Coverity (CID 303768) Reported-by: Coverity (CID 303776) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-21efi_loader: add EFI_MEMORY_SP to memory attributesHeinrich Schuchardt
The UEFI 2.8 specification has introduced the EFI_MEMORY_SP memory attribute. Add it to the 'efidebug memmap' and 'efi mem' commands. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-18common: Drop log.h from common headerSimon Glass
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass
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-17cmd: efidebug: Add support for querying UEFI variable storageIlias Apalodimas
With the previous patches that use OP-TEE and StandAloneMM for UEFI variable storage we've added functionality for efi_query_variable_info. So let's add the relevant command to efidebug and retrieve information about the container used to store UEFI variables Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-05-10cmd: efidebug: fix -Werror=type-limits warningHeinrich Schuchardt
Compiling with -Wtype-limits yields: cmd/efidebug.c:968:32: error: comparison is always false due to limited range of data type [-Werror=type-limits] 968 | if (*endp != '\0' || bootnext > 0xffff) { | Remove the superfluous check. Fixes: 59df7e7e77e7 ("cmd: add efidebug command") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-09cmd: efidebug: add a comment against Coverity check (300329)AKASHI Takahiro
The check here, "Null pointer dereferences," is a false positive. So leave a comment. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reported-by: Coverity (CID 300329)
2020-05-09cmd: efidebug: fix a wrong handling of argumentsAKASHI Takahiro
Coverity detected a dead code, but actually there is a bug in a check against a number of arguments. So simply fix it. Reported-by: Coverity (CID 300330) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-04cmd: efidebug: simplify UEFI protocol callsHeinrich Schuchardt
We should not to refer to a function via the run-time or boot services tables if the function is exported. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-30efi_loader: fix 'efidebug bootorder'Heinrich Schuchardt
* don't copy GUIDs for no reason * shorten print format strings by using variable names * don't use the run-time table to access exported functions * check the result of malloc() (fixes Coverity CID 300331) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-30efi_loader: efidebug, avoid illegal memory accessHeinrich Schuchardt
For EFI_PERSISTENT_MEMORY_TYPE the 'efidebug memmap' command produces an illegal memory access. * Add the missing descriptive string for EFI_PERSISTENT_MEMORY_TYPE. * Replace the check for EFI_MAX_MEMORY_TYPE by the ARRAY_SIZE() macro. Reported-by: Coverity (CID 300336) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-04-30efi_loader: fix 'efidebug boot dump'Heinrich Schuchardt
* Do not recreate a variable name that we already have as u16 string. * Check the return value of malloc() * EFI_NOT_FOUND cannot occur for a variable name returned by GetNextVariableName(). Remove a print statement. * Don't copy a GUID for no reason. * Don't use the run-time service table to call exported functions. * Don't pass NULL to show_efi_boot_opt_data() (fixes Coverity CID 300338). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>