From a8a0fc4628ba7a3443f4e90f47809fdac7aa492e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 14 Nov 2022 10:25:04 +0100 Subject: doc: fix documentation of enum gd_flags Correct GD_FLG_CYCLIC_RUNNING documentation to match Sphinx style. Fixes: d7de5ef62935 ("cyclic: use a flag in gd->flags for recursion protection") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- include/asm-generic/global_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 02ad8ca..8882912 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -651,7 +651,7 @@ enum gd_flags { */ GD_FLG_FDT_CHANGED = 0x100000, /** - * GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress + * @GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress */ GD_FLG_CYCLIC_RUNNING = 0x200000, }; -- cgit v1.1 From dd706c83beb1f65f00aed432376cc507ff255fcb Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 14 Nov 2022 10:16:02 +0100 Subject: sandbox: fix documentation of struct host_ops The documentation of struct host_ops should be Sphinx compliant. Fixes: 9bd1aa8af2ed ("dm: sandbox: Create a new HOST uclass") Signed-off-by: Heinrich Schuchardt --- include/sandbox_host.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/include/sandbox_host.h b/include/sandbox_host.h index 2e37ede..ebd7d99 100644 --- a/include/sandbox_host.h +++ b/include/sandbox_host.h @@ -23,26 +23,23 @@ struct host_sb_plat { /** * struct host_ops - operations supported by UCLASS_HOST - * - * @attach_file: Attach a new file to a device - * @detach_file: Detach a file from a device */ struct host_ops { - /* - * attach_file() - Attach a new file to the device + /** + * @attach_file: - Attach a new file to the device * - * @dev: Device to update - * @filename: Name of the file, e.g. "/path/to/disk.img" - * Returns: 0 if OK, -EEXIST if a file is already attached, other -ve on + * @attach_file.dev: Device to update + * @attach_file.filename: Name of the file, e.g. "/path/to/disk.img" + * @attach_file.Returns: 0 if OK, -EEXIST if a file is already attached, other -ve on * other error */ int (*attach_file)(struct udevice *dev, const char *filename); /** - * detach_file() - Detach a file from the device + * @detach_file: - Detach a file from the device * - * @dev: Device to detach from - * Returns: 0 if OK, -ENOENT if no file is attached, other -ve on other + * @detach_file.dev: Device to detach from + * @detach_file.Returns: 0 if OK, -ENOENT if no file is attached, other -ve on other * error */ int (*detach_file)(struct udevice *dev); -- cgit v1.1 From 5727f922ca26b94db38c498935b0b3b75e3cbc4c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 14 Nov 2022 10:30:58 +0100 Subject: Documentation: man-page for command bootd Provide a man-page for the bootd command. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- doc/usage/cmd/bootd.rst | 38 ++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 2 files changed, 39 insertions(+) create mode 100644 doc/usage/cmd/bootd.rst diff --git a/doc/usage/cmd/bootd.rst b/doc/usage/cmd/bootd.rst new file mode 100644 index 0000000..380ef15 --- /dev/null +++ b/doc/usage/cmd/bootd.rst @@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +bootd command +============= + +Synopsis +-------- + +:: + + bootd + +Description +----------- + +The bootd command executes the command stored in the environment variable +*bootcmd*, i.e. it does the same thing as *run bootcmd*. + +Example +------- + +:: + + => setenv bootcmd 'echo Hello World' + => bootd + Hello World + => setenv bootcmd true + => bootd; echo $? + 0 + => setenv bootcmd false + => bootd; echo $? + 1 + +Return value +------------ + +The return value $? of the bootd command is the return value of the command in +the environment variable *bootcmd*. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index f7f03ae..815b032 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -23,6 +23,7 @@ Shell commands cmd/addrmap cmd/askenv cmd/base + cmd/bootd cmd/bootdev cmd/bootefi cmd/bootflow -- cgit v1.1 From 030c2d187ed2495fdb37e58fb5bf6997ef4039ef Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 13 Nov 2022 13:27:32 +0100 Subject: doc: add man-page for cmp command Provide a man-page for the cmp command. Signed-off-by: Heinrich Schuchardt --- doc/usage/cmd/cmp.rst | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 2 files changed, 106 insertions(+) create mode 100644 doc/usage/cmd/cmp.rst diff --git a/doc/usage/cmd/cmp.rst b/doc/usage/cmd/cmp.rst new file mode 100644 index 0000000..241320d --- /dev/null +++ b/doc/usage/cmd/cmp.rst @@ -0,0 +1,105 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +cmp command +=========== + +Synopsis +-------- + +:: + + cmp [.b, .w, .l, .q] addr1 addr2 count + +Description +----------- + +The cmp command is used to compare two memory areas. By default it works on +four byte tuples. By appending .b, .w, .l, .q the size of the tuples is +controlled: + +cmp.b + compare 1 byte tuples + +cmp.w + compare 2 byte tuples + +cmp.l + compare 4 byte tuples + +cmp.q + compare 8 byte tuples + +The parameters are used as follows: + +addr1 + Address of the first memory area. + +addr2 + Address of the second memory area. + +count + Number of bytes to compare (as hexadecimal number). + +Example +------- + +In the example below the strings "Hello world\n" and "Hello World\n" are written +to memory and then compared. + +:: + + => mm.b 0x1000000 + 01000000: 00 ? 48 + 01000001: 00 ? 65 + 01000002: 00 ? 6c + 01000003: 00 ? 6c + 01000004: 00 ? 6f + 01000005: 00 ? 20 + 01000006: 00 ? 77 + 01000007: 00 ? 6f + 01000008: 00 ? 72 + 01000009: 00 ? 6c + 0100000a: 00 ? 64 + 0100000b: 00 ? 0d + 0100000c: 00 ? => + => mm.b 0x101000 + 00101000: 00 ? 48 + 00101001: 00 ? 65 + 00101002: 00 ? 6c + 00101003: 00 ? 6c + 00101004: 00 ? 6f + 00101005: 00 ? 20 + 00101006: 00 ? 57 + 00101007: 00 ? 6f + 00101008: 00 ? 72 + 00101009: 00 ? 6c + 0010100a: 00 ? 64 + 0010100b: 00 ? 0d + 0010100c: 00 ? => + => cmp 0x1000000 0x101000 0xc + word at 0x01000004 (0x6f77206f) != word at 0x00101004 (0x6f57206f) + Total of 1 word(s) were the same + => cmp.b 0x1000000 0x101000 0xc + byte at 0x01000006 (0x77) != byte at 0x00101006 (0x57) + Total of 6 byte(s) were the same + => cmp.w 0x1000000 0x101000 0xc + halfword at 0x01000006 (0x6f77) != halfword at 0x00101006 (0x6f57) + Total of 3 halfword(s) were the same + => cmp.l 0x1000000 0x101000 0xc + word at 0x01000004 (0x6f77206f) != word at 0x00101004 (0x6f57206f) + Total of 1 word(s) were the same + => cmp.q 0x1000000 0x101000 0xc + double word at 0x01000000 (0x6f77206f6c6c6548) != double word at 0x00101000 (0x6f57206f6c6c6548) + Total of 0 double word(s) were the same + +Configuration +------------- + +The cmp command is only available if CONFIG_CMD_MEMORY=y. The cmp.q command is +only available if additionally CONFIG_MEM_SUPPORT_64BIT_DATA=y. + +Return value +------------ + +The return value $? is true (0) if the compared memory areas are equal. +The reutrn value is false (1) if the compared memory areas differ. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 815b032..d6283fa 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -35,6 +35,7 @@ Shell commands cmd/cat cmd/cbsysinfo cmd/cls + cmd/cmp cmd/conitrace cmd/cyclic cmd/dm -- cgit v1.1 From 2b94359e9c489061b66cc7dcefddbb6adb5ba9f8 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Mon, 7 Nov 2022 14:49:31 +0100 Subject: doc: fix build with sphinx 5.0 and later. Sphinx 5.0 and later fails to build when language is set to None: Warning, treated as error: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English) Let's set the language to English since it is the language used for the documentation. Cc: Quentin Schulz Signed-off-by: Quentin Schulz Reviewed-by: Heinrich Schuchardt --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index eac3acc..62c8d31 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -178,7 +178,7 @@ finally: # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -- cgit v1.1 From 9fb3269ab39d3b3b1db43296b5d2619238eaa8b0 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 10 Nov 2022 10:21:24 +0200 Subject: efi_loader: initialize return values in efi_uninstall_multiple_protocol_interfaces_int() If the va_list we got handed over contains no protocols we must return EFI_SUCCESS. However in that case the current code just returns an unintialized value. Fix that by setting the return value in the variable definition Addresses-Coverity: CID 376195: ("Uninitialized variables (UNINIT)") Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a560215..253f9f7 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2754,7 +2754,7 @@ efi_uninstall_multiple_protocol_interfaces_int(efi_handle_t handle, { const efi_guid_t *protocol; void *protocol_interface; - efi_status_t ret; + efi_status_t ret = EFI_SUCCESS; size_t i = 0; efi_va_list argptr_copy; -- cgit v1.1 From 00ec77f2b030aa9982363b0d6a6cc6b56a64a0af Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 10 Nov 2022 12:23:35 +0100 Subject: MAINTAINERS: add UEFI commands to EFI PAYLOAD Add the following files to EFI PAYLOAD: - cmd/bootefi.c - cmd/efidebug.c - cmd/eficonfig.c - cmd/nvedit_efi.c Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index a377afb..97b2f69 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -889,6 +889,10 @@ M: Ilias Apalodimas S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-efi.git F: arch/arm/lib/*_efi.* +F: cmd/bootefi.c +F: cmd/eficonfig.c +F: cmd/efidebug.c +F: cmd/nvedit_efi.c F: doc/api/efi.rst F: doc/develop/uefi/* F: doc/mkeficapsule.1 -- cgit v1.1 From 3d595ac5f5cbcf4db793caee035ab28304f41457 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 10 Nov 2022 12:19:30 +0100 Subject: cmd: remove superfluous if in eficonfig_edit_boot_option Goto for an immediately succeeding label is superfluous. Fixes: 87d791423ac6 ("eficonfig: menu-driven addition of UEFI boot option") Addresses-Coverity: 376202 ("Identical code for different branches") Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- cmd/eficonfig.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 2595dd9..0dc6e7b 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -1527,8 +1527,6 @@ static efi_status_t eficonfig_edit_boot_option(u16 *varname, struct eficonfig_bo } ret = eficonfig_set_boot_option(varname, final_dp, final_dp_size, bo->description, tmp); - if (ret != EFI_SUCCESS) - goto out; out: free(tmp); free(bo->optional_data); -- cgit v1.1 From 95d18c5ed0ca952947214c619140e68b33005a4c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 10 Nov 2022 14:14:06 +0100 Subject: efi_loader: improve description of efi_file_from_path() Provide a description of the function's logic. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index c96a7f7..8b9fa588 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1098,6 +1098,15 @@ static const struct efi_file_handle efi_file_handle_protocol = { /** * efi_file_from_path() - open file via device path * + * The device path @fp consists of the device path of the handle with the + * simple file system protocol and one or more file path device path nodes. + * The concatenation of all file path names provides the total file path. + * + * The code starts at the first file path node and tries to open that file or + * directory. If there is a succeding file path node, the code opens it relative + * to this directory and continues iterating until reaching the last file path + * node. + * * @fp: device path * Return: EFI_FILE_PROTOCOL for the file or NULL */ -- cgit v1.1 From 1167e88ab876febdc1c567e877a6d81996a566a1 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Mon, 14 Nov 2022 19:00:47 +0900 Subject: eficonfig: fix missing variable initialization The 'ret' variable must be initialized before use in eficonfig_delete_invalid_boot_option(). Fixes: c416f1c0bc ("bootmenu: add removable media entries") Addresses-Coverity: 376207 ("Uninitialized variables") Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- cmd/eficonfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 0dc6e7b..2b14389 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -2278,10 +2278,10 @@ efi_status_t eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op { u32 i, j; efi_uintn_t size; - efi_status_t ret; void *load_option; struct efi_load_option lo; u16 varname[] = u"Boot####"; + efi_status_t ret = EFI_SUCCESS; for (i = 0; i <= 0xFFFF; i++) { efi_uintn_t tmp; -- cgit v1.1 From 94a574d8f6116a12def77fbf9a92f02a430a1d12 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 10 Nov 2022 15:31:30 +0200 Subject: efi_loader: add comments on efi_file_from_path() regarding alignment UEFI specification requires pointers that are passed to protocol member functions to be aligned. There's a u16_strdup in that function which doesn't make sense otherwise Add a comment so no one removes it accidentally Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index 8b9fa588..b1495e5 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1144,6 +1144,11 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp) return NULL; } + /* + * UEFI specification requires pointers that are passed to + * protocol member functions to be aligned. So memcpy it + * unconditionally + */ filename = u16_strdup(fdp->str); if (!filename) return NULL; -- cgit v1.1 From 64012e0c52eefa6fbfedbad772133a478bd741ea Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Fri, 11 Nov 2022 18:20:37 +0200 Subject: efi_loader: add missing EFI_CALL when closing a file Closing the files uses the EFI protocol and specifically it's .close callback. This needs to be wrapped on an EFI_CALL() Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index b1495e5..d6dc823 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1140,7 +1140,7 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp) if (!EFI_DP_TYPE(fp, MEDIA_DEVICE, FILE_PATH)) { printf("bad file path!\n"); - f->close(f); + EFI_CALL(f->close(f)); return NULL; } -- cgit v1.1 From a930d69baa958d5f308b3910187c5f3c083fe171 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Fri, 11 Nov 2022 20:04:31 +0200 Subject: efi_loader: replace a u16_strdup with alloc + memcpy Heinrich reports that on RISC-V unaligned access is emulated by OpenSBI which is very slow. Performance wise it's better if we skip the calls to u16_strdup() -- which in turn calls u16_strsize() and just allocate/copy the memory directly. The access to dp.length may still be unaligned, but that's way less than what u16_strsize() would do Signed-off-by: Ilias Apalodimas Use malloc() instead of calloc(). Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index d6dc823..520c730 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1137,6 +1137,7 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp) container_of(fp, struct efi_device_path_file_path, dp); struct efi_file_handle *f2; u16 *filename; + size_t filename_sz; if (!EFI_DP_TYPE(fp, MEDIA_DEVICE, FILE_PATH)) { printf("bad file path!\n"); @@ -1149,9 +1150,14 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp) * protocol member functions to be aligned. So memcpy it * unconditionally */ - filename = u16_strdup(fdp->str); + if (fdp->dp.length <= offsetof(struct efi_device_path_file_path, str)) + return NULL; + filename_sz = fdp->dp.length - + offsetof(struct efi_device_path_file_path, str); + filename = malloc(filename_sz); if (!filename) return NULL; + memcpy(filename, fdp->str, filename_sz); EFI_CALL(ret = f->open(f, &f2, filename, EFI_FILE_MODE_READ, 0)); free(filename); -- cgit v1.1