aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-11-16 11:08:51 -0500
committerTom Rini <trini@konsulko.com>2022-11-16 11:08:51 -0500
commitbebb393b340295edb9ba50a996fc0510cd1b6ac0 (patch)
tree3eda675d84dbfedc19aed9b6da8fd1c7a5574930
parentd78cccb1acd683083560d71753c116c6e38e2491 (diff)
parenta930d69baa958d5f308b3910187c5f3c083fe171 (diff)
downloadu-boot-WIP/16Nov2022.zip
u-boot-WIP/16Nov2022.tar.gz
u-boot-WIP/16Nov2022.tar.bz2
Merge tag 'efi-2023-01-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efiWIP/16Nov2022
Pull request for efi-2023-01-rc2 Documentation: * fix building with Sphinx 5.0+ * man-pages for cmp and bootd commands UEFI: * Avoid unaligned access in efi_file_from_path() * More bug fixes
-rw-r--r--MAINTAINERS4
-rw-r--r--cmd/eficonfig.c4
-rw-r--r--doc/conf.py2
-rw-r--r--doc/usage/cmd/bootd.rst38
-rw-r--r--doc/usage/cmd/cmp.rst105
-rw-r--r--doc/usage/index.rst2
-rw-r--r--include/asm-generic/global_data.h2
-rw-r--r--include/sandbox_host.h19
-rw-r--r--lib/efi_loader/efi_boottime.c2
-rw-r--r--lib/efi_loader/efi_file.c24
10 files changed, 183 insertions, 19 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index a377afb..97b2f69 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -889,6 +889,10 @@ M: Ilias Apalodimas <ilias.apalodimas@linaro.org>
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
diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
index 2595dd9..2b14389 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);
@@ -2280,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;
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:
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/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 ? => <INTERRUPT>
+ => 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 ? => <INTERRUPT>
+ => 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 f7f03ae..d6283fa 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
@@ -34,6 +35,7 @@ Shell commands
cmd/cat
cmd/cbsysinfo
cmd/cls
+ cmd/cmp
cmd/conitrace
cmd/cyclic
cmd/dm
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,
};
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);
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;
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index c96a7f7..520c730 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
*/
@@ -1128,16 +1137,27 @@ 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");
- f->close(f);
+ EFI_CALL(f->close(f));
return NULL;
}
- filename = u16_strdup(fdp->str);
+ /*
+ * UEFI specification requires pointers that are passed to
+ * protocol member functions to be aligned. So memcpy it
+ * unconditionally
+ */
+ 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);