History log of /u-boot/cmd/nvedit_efi.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 0c0d471e 31-Jul-2023 Dan Carpenter <dan.carpenter@linaro.org>

cmd: improve string matching for hex

Match the "=0x" instead of just "=0".

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Heinrich.Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

# 57b2d300 05-Oct-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: simplify do_env_set_efi()

Use efi_convert_string() to convert a UTF-8 to a UTF-16 string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# a872b18a 19-Jun-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: correct return value for printenv -e

If printenv -e is executed and the specified variable is not found, the
return value $? of the command should be 1 (false).

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 983a5a2e 16-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: printenv: simplify printing GUIDs

Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# f4c1a14f 08-Sep-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: eliminate EFI_CALL() in nvedit_efi.c

Reduce the code size by avoiding using the external UEFI API and using our
internal functions instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 57b2d300 05-Oct-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: simplify do_env_set_efi()

Use efi_convert_string() to convert a UTF-8 to a UTF-16 string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# a872b18a 19-Jun-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: correct return value for printenv -e

If printenv -e is executed and the specified variable is not found, the
return value $? of the command should be 1 (false).

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 983a5a2e 16-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: printenv: simplify printing GUIDs

Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# f4c1a14f 08-Sep-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: eliminate EFI_CALL() in nvedit_efi.c

Reduce the code size by avoiding using the external UEFI API and using our
internal functions instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# a872b18a 19-Jun-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: correct return value for printenv -e

If printenv -e is executed and the specified variable is not found, the
return value $? of the command should be 1 (false).

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 983a5a2e 16-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: printenv: simplify printing GUIDs

Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# f4c1a14f 08-Sep-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: eliminate EFI_CALL() in nvedit_efi.c

Reduce the code size by avoiding using the external UEFI API and using our
internal functions instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 983a5a2e 16-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

cmd: printenv: simplify printing GUIDs

Use "%pS" to print text representations of GUIDs.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# f4c1a14f 08-Sep-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: eliminate EFI_CALL() in nvedit_efi.c

Reduce the code size by avoiding using the external UEFI API and using our
internal functions instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# f4c1a14f 08-Sep-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: eliminate EFI_CALL() in nvedit_efi.c

Reduce the code size by avoiding using the external UEFI API and using our
internal functions instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

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>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# f1eb346e 03-Jul-2021 AKASHI Takahiro <takahiro.akashi@linaro.org>

env: efi: fix a wrong address dereference

Probably, a pointer to a variable in an inner block should not
be exposed to an outer block.

Fixes: c70f44817d46 ("efi_loader: simplify 'printenv -e'")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
[trini: Don't make guid const now]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2b3fbcb5 24-Aug-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use ':' as separator for setenv -i

setenv -e -i <address>,<filesize> can be used to set a UEFI variable
from memory.

For separating an address and a size we use ':' in most commands.
Let's do the same for setenv -e -i.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# c70f4481 15-Jul-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: simplify 'printenv -e'

Currently default output of 'printenv -e' is restricted to variables with
GUID EFI_GLOBAL_VARIABLE. This excludes db and dbx. As the number of
variables is small there is no need for this restriction.

If no GUID is provided, print all matching variables irrespective of GUID.

Always show the numeric value of the GUID.

If the GUID provided to 'setenv -e' is invalid, return CMD_RET_USAGE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2a79c352 24-Jun-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: display RO attribute in printenv -e

Let the 'printenv -e' command display the read only flag.
If the variable is time authenticated write the time stamp.

Avoid EFI_CALL() when calling SetVariable() and GetVariable().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 09140113 10-May-2020 Simon Glass <sjg@chromium.org>

command: Remove the cmd_tbl_t typedef

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>

# ba06b3c5 10-May-2020 Simon Glass <sjg@chromium.org>

common: Drop uuid.h from common header

Move this uncommon header out of the common header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9900e462 05-May-2020 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: use logical and in do_env_print_efi()

If we want to check if two booleans are true, we should use a logical
conjunction (&&) and not a bitwise and-operator (&).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# e50e2878 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-at" option to "env set -e" command

With "-at" option, EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
will be passed to SetVariable() to authenticate the variable.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# f757d045 13-Apr-2020 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: use appropriate guid for authenticated UEFI variable

A signature database variable is associated with a specific guid.
For convenience, if user doesn't supply any guid info, "env set|print -e"
should complement it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 051aa89f 24-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: extend "env [set|print] -e" to manage UEFI variables

With this patch, when setting UEFI variable with "env set -e" command,
we will be able to
- specify vendor guid with "-guid guid",
- specify variable attributes, BOOTSERVICE_ACCESS, RUNTIME_ACCESS,
respectively with "-bs" and "-rt",
- append a value instead of overwriting with "-a",
- use memory as variable's value instead of explicit values given
at the command line with "-i address,size"

If guid is not explicitly given, default value will be used.

Meanwhile, "env print -e," will be modified so that it will NOT dump
a variable's value if '-n' is specified.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 6810caf8 03-Oct-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: fix a typo in a comment of do_env_set_efi()

A wrong function name is referred to in a comment of do_env_set_efi().

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 9fb625ce 01-Aug-2019 Simon Glass <sjg@chromium.org>

env: Move env_set() to env.h

Move env_set() over to the new header file.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 4b27a761 04-Jun-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add -nv option for UEFI non-volatile variable

With this option, -nv, at "setenv -e" command, a variable will be defined
as non-volatile.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 8190b4a3 27-May-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: print a message when setting UEFI variable failed

Error message will alert a user that setting/deleting a variable failed.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 45203e0c 29-Apr-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in append value

When printing an UEFI variable an error may arise while converting an
illegal hexadecimal value. In this case a buffer is leaked.

Close the memory leak. Provide an error message.

Reported-by: Coverity (CID 185830)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 1fd7a476 19-Mar-2019 Heinrich Schuchardt <xypron.glpk@gmx.de>

efi_loader: memory leak in efi_dump_single_var()

A misplaced return statement lead to a memory leak in
efi_dump_single_var().

Reported-by: Coverity (CID 185829)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 49d81fdf 24-Feb-2019 AKASHI Takahiro <takahiro.akashi@linaro.org>

cmd: env: add "-e" option for handling UEFI variables

"env [print|set] -e" allows for handling uefi variables without
knowing details about mapping to corresponding u-boot variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>