summaryrefslogtreecommitdiffstats
path: root/cmd/efidebug.c
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: validate load optionHeinrich Schuchardt2020-06-031-6/+15
| | | | | | | | | | | | | | | | | | | | | 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>
* efi_loader: add EFI_MEMORY_SP to memory attributesHeinrich Schuchardt2020-05-211-0/+1
| | | | | | | 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>
* common: Drop log.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* command: Remove the cmd_tbl_t typedefSimon Glass2020-05-181-35/+35
| | | | | | | | | | | | | 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>
* cmd: efidebug: Add support for querying UEFI variable storageIlias Apalodimas2020-05-171-1/+57
| | | | | | | | | 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>
* cmd: efidebug: fix -Werror=type-limits warningHeinrich Schuchardt2020-05-101-1/+1
| | | | | | | | | | | | | | 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>
* cmd: efidebug: add a comment against Coverity check (300329)AKASHI Takahiro2020-05-091-0/+5
| | | | | | | | 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)
* cmd: efidebug: fix a wrong handling of argumentsAKASHI Takahiro2020-05-091-1/+1
| | | | | | | | | 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>
* cmd: efidebug: simplify UEFI protocol callsHeinrich Schuchardt2020-05-041-21/+19
| | | | | | | 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>
* efi_loader: fix 'efidebug bootorder'Heinrich Schuchardt2020-04-301-21/+26
| | | | | | | | | * 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>
* efi_loader: efidebug, avoid illegal memory accessHeinrich Schuchardt2020-04-301-1/+2
| | | | | | | | | | | 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>
* efi_loader: fix 'efidebug boot dump'Heinrich Schuchardt2020-04-301-25/+20
| | | | | | | | | | | | * 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>
* cmd: efidebug: add "test bootmgr" sub-commandAKASHI Takahiro2020-04-161-1/+77
| | | | | | | | | | | This sub-command will be used to test image authentication, in particular, a case where efi_load_image() failed with EFI_SECURITY_VIOLATION but we still want to try efi_start_image(). We won't run such a case under normal bootmgr because it simply refuses to call efi_start_image() if anything but EFI_SUCCESS is returned when loading an image. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
* cmd: efidebug: fix int to pointer castHeinrich Schuchardt2020-03-281-3/+5
| | | | | | | | | On 32 bit systems fix warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Fixes: a415d61eac26 ("cmd: map addresses to sysmem in efidebug memmap") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: map addresses to sysmem in efidebug memmapHeinrich Schuchardt2020-03-171-2/+4
| | | | | | | | | | | Addresses in the sandbox's device tree are in the sandbox's virtual address space. If we want to compare memory reservations in the device-tree with the output of 'efidebug memmap', we need to convert back to this address space. Adjust the output of the 'efidebug memmap' command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: correct error messageHeinrich Schuchardt2020-03-111-1/+1
| | | | | | | | | | Add the missing line feed at the error message if the variable referred to by 'efidebug boot rm' does not exist. Shorten the format string by using the variable name instead of the number of the boot variable. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: fix a failure of "boot rm" sub-commandAKASHI Takahiro2020-03-111-2/+3
| | | | | | | | | There is a wrong usage of utf8_utf16_strncpy() in "boot rm" command, and then it will end up with a failure of this command due to a wrong value of an interim variable ("var_name16"). Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: Implement FileLoad2 for initramfs loadingIlias Apalodimas2020-02-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Following kernel's proposal for an arch-agnostic initrd loading mechanism [1] let's implement the U-boot counterpart. This new approach has a number of advantages compared to what we did up to now. The file is loaded into memory only when requested limiting the area of TOCTOU attacks. Users will be allowed to place the initramfs file on any u-boot accessible partition instead of just the ESP one. Finally this is an attempt of a generic interface across architectures in the linux kernel so it makes sense to support that. The file location is intentionally only supported as a config option argument(CONFIG_EFI_INITRD_FILESPEC), in an effort to enhance security. Although U-boot is not responsible for verifying the integrity of the initramfs, we can enhance the offered security by only accepting a built-in option, which will be naturally verified by UEFI Secure Boot. This can easily change in the future if needed and configure that via ENV or UEFI variable. [1] https://lore.kernel.org/linux-efi/20200207202637.GA3464906@rani.riverdale.lan/T/#m4a25eb33112fab7a22faa0fd65d4d663209af32f Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: implement EFI_RT_PROPERTIES_TABLEHeinrich Schuchardt2020-02-261-0/+4
| | | | | | | | | | UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable defined in UEFI spec 2.8 by the configuration table EFI_RT_PROPERTIES_TABLE. So let's follow suit. Cc: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Tested-by: Ard Biesheuvel <ardb@kernel.org>
* cmd: efidebug: capitalize UEFIHeinrich Schuchardt2020-01-071-4/+4
| | | | | | %s/uefi/UEFI/g Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: new sub-command tablesHeinrich Schuchardt2020-01-071-1/+46
| | | | | | Provide sub-command for efidebug to list configuration tables. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: simplify get_guid_text()Heinrich Schuchardt2020-01-071-11/+14
| | | | | | | | | | | When we hit a matching GUID we can directly return the text. There is no need for a check after the loop. efi_guid_t is defined as 8 byte aligned but GUIDs in packed structures do not follow this alignment. Do not require the argument of get_guid_text() to be correctly aligned. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: fix a build error in show_efi_boot_opt()AKASHI Takahiro2019-12-031-2/+2
| | | | | | | | | | | | | | I detected the following error in sandbox with Clang on Travis CI: +cmd/efidebug.c:703:15: error: result of comparison of constant 9223372036854775822 with expression of type 'int' is always false [-Werror,-Wtautological-constant-out-of-range-compare] + else if (ret == EFI_NOT_FOUND) + ~~~ ^ ~~~~~~~~~~~~~ Simply changing a type of 'ret' to efi_status_t will fix this error. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* 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>
* efi_loader: efidebug.c function documentationHeinrich Schuchardt2019-07-301-3/+2
| | | | | | | | | | | make htmldocs produces a warning: ./cmd/efidebug.c:733: WARNING: Unexpected indentation. Correct the indentation. Remove 'See above for details of sub-commands.' which is not helpful in the Sphinx generated documentation. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: function comments cmd/efi_debug.cHeinrich Schuchardt2019-07-161-6/+10
| | | | | | Adjust comments for Sphinx. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: consistent error handling in efidebug.cHeinrich Schuchardt2019-06-201-7/+16
| | | | | | If a variable cannot be set, always show an information message. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: consistent types in efidebug.cHeinrich Schuchardt2019-06-201-11/+14
| | | | | | | efi_status_t and int are of different size. Use separate variables for return codes of different type. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: make some boot variables non-volatileAKASHI Takahiro2019-06-041-0/+3
| | | | | | | Boot####, BootOrder and BootNext should be non-volatile. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: optional data in load options are binaryHeinrich Schuchardt2019-05-021-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The field boot OptionalData in structure _EFI_LOAD_OPTIONS is for binary data. When we use `efidebug boot add` we should convert the 5th argument from UTF-8 to UTF-16 before putting it into the BootXXXX variable. When printing boot variables with `efidebug boot dump` we should support the OptionalData being arbitrary binary data. So let's dump the data as hexadecimal values. Here is an example session protocol: => efidebug boot add 00a1 label1 scsi 0:1 doit1 'my option' => efidebug boot add 00a2 label2 scsi 0:1 doit2 => efidebug boot dump Boot00A0: attributes: A-- (0x00000001) label: label1 file_path: .../HD(1,MBR,0xeac4e18b,0x800,0x3fffe)/doit1 data: 00000000: 6d 00 79 00 20 00 6f 00 70 00 74 00 69 00 6f 00 m.y. .o.p.t.i.o. 00000010: 6e 00 00 00 n... Boot00A1: attributes: A-- (0x00000001) label: label2 file_path: .../HD(1,MBR,0xeac4e18b,0x800,0x3fffe)/doit2 data: Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: rework "boot dump" sub-command using GetNextVariableName()AKASHI Takahiro2019-05-021-24/+55
| | | | | | | | | Currently in do_efi_boot_dump(), we directly read EFI variables from related environment variables. To accommodate alternative storage backends, we should switch to using the UEFI API instead. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: more short texts for protocols in efidebugHeinrich Schuchardt2019-04-231-0/+20
| | | | | | | | | | | The `efidebug dh` command shows handles and the installed protocols. For most of the protocols implemented by U-Boot a short text was shown. But for some only the GUID was displayed. Provide the missing short texts for the following protocols: HII String, HII Database, HII Config Routing, Simple Network, PXE Base Code. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: consistent naming of protocol GUIDsHeinrich Schuchardt2019-04-231-5/+5
| | | | | | | | | | | | | We should consistently use the same name for protocol GUIDs as defined in the UEFI specification. Not adhering to this rule has led to duplicate definitions for the EFI_LOADED_IMAGE_PROTOCOL_GUID. Adjust misnamed protocol GUIDs. Adjust the text for the graphics output protocol in the output of the `efidebug dh` command. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_loader: error handling for `efidebug boot add`Heinrich Schuchardt2019-03-021-1/+1
| | | | | | | | | In `efidebug boot add iPXE scsi 0:1 snp-arm64.efi --foo` a parameter is missing. Hence the command should not silently return as if everything were ok but should display the usage info. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@csgraf.de>
* cmd: efidebug: add memmap commandAKASHI Takahiro2019-02-251-1/+126
| | | | | | | | | | | | | | | | | | | "memmap" command prints uefi-specific memory map information. => efi memmap Type Start End Attributes ================ ================ ================ ========== CONVENTIONAL 0000000040000000-000000007de27000 WB RUNTIME DATA 000000007de27000-000000007de28000 WB|RT RESERVED 000000007de28000-000000007de2a000 WB RUNTIME DATA 000000007de2a000-000000007de2b000 WB|RT RESERVED 000000007de2b000-000000007de2c000 WB RUNTIME DATA 000000007de2c000-000000007de2d000 WB|RT LOADER DATA 000000007de2d000-000000007ff37000 WB RUNTIME CODE 000000007ff37000-000000007ff38000 WB|RT LOADER DATA 000000007ff38000-0000000080000000 WB Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: add images commandAKASHI Takahiro2019-02-251-1/+25
| | | | | | | "images" command prints loaded images-related information. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: add dh commandAKASHI Takahiro2019-02-251-1/+141
| | | | | | | | | | | | | | | | | | "dh" command prints all the uefi handles used in the system. => efi dh 7ef3bfa0: Device Path, Device Path To Text, Device Path Utilities, Unicode Collation 2 7ef31d30: Driver Binding 7ef31da0: Simple Text Output 7ef31e10: Simple Text Input, Simple Text Input Ex 7ef3cca0: Block IO, Device Path 7ef3d070: Block IO, Device Path 7ef3d1b0: Block IO, Device Path, Simple File System 7ef3d3e0: Block IO, Device Path, Simple File System Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: add drivers commandAKASHI Takahiro2019-02-251-1/+94
| | | | | | | | | | | | "drivers" command prints all the uefi drivers on the system. => efi drivers Driver Name Image Path ================ ==================== ==================== 000000007ef003d0 <NULL> <built-in> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: efidebug: add devices commandAKASHI Takahiro2019-02-251-1/+78
| | | | | | | | | | | | | | | | | | | "devices" command prints all the uefi variables on the system. => efi devices Scanning disk ahci_scsi.id0lun0... Scanning disk ahci_scsi.id1lun0... Found 4 disks Device Device Path ================ ==================== 000000007ef07ea0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b) 000000007ef00c10 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0) 000000007ef00dd0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0) 000000007ef07be0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(1,MBR,0x086246ba,0x800,0x40000) 000000007ef07510 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(2,MBR,0x086246ba,0x40800,0x3f800) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* cmd: add efidebug commandAKASHI Takahiro2019-02-251-0/+587
Currently, there is no easy way to add or modify UEFI variables. In particular, bootmgr supports BootOrder/BootXXXX variables, it is quite hard to define them as u-boot variables because they are represented in a complicated and encoded format. The new command, efidebug, helps address these issues and give us more friendly interfaces: * efidebug boot add: add BootXXXX variable * efidebug boot rm: remove BootXXXX variable * efidebug boot dump: display all BootXXXX variables * efidebug boot next: set BootNext variable * efidebug boot order: set/display a boot order (BootOrder) Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>