From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 15/16] efi_loader: enable UEFI variables at runtime
Date: Wed, 1 Apr 2020 10:41:24 +0900 [thread overview]
Message-ID: <20200401014123.GS11504@linaro.org> (raw)
In-Reply-To: <20200331060541.4212-1-xypron.glpk@gmx.de>
On Tue, Mar 31, 2020 at 08:05:40AM +0200, Heinrich Schuchardt wrote:
> Enable UEFI variables at runtime.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> lib/efi_loader/efi_runtime.c | 6 +++++-
> lib/efi_loader/efi_variable.c | 23 +++++++++++++++++------
> 2 files changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 664a0422e2..acd644202d 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -120,8 +120,12 @@ efi_status_t efi_init_runtime_supported(void)
> rt_table->version = EFI_RT_PROPERTIES_TABLE_VERSION;
> rt_table->length = sizeof(struct efi_rt_properties_table);
> rt_table->runtime_services_supported =
> + EFI_RT_SUPPORTED_GET_VARIABLE |
> + EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME |
> + EFI_RT_SUPPORTED_SET_VARIABLE |
> EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP |
> - EFI_RT_SUPPORTED_CONVERT_POINTER;
> + EFI_RT_SUPPORTED_CONVERT_POINTER |
> + EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO;
>
> /*
> * This value must be synced with efi_runtime_detach_list
> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
> index 7c39542968..cf8b44c535 100644
> --- a/lib/efi_loader/efi_variable.c
> +++ b/lib/efi_loader/efi_variable.c
> @@ -326,15 +326,13 @@ efi_status_t __efi_runtime EFIAPI efi_query_variable_info(
> u64 *remaining_variable_storage_size,
> u64 *maximum_variable_size)
> {
> - /*
> *maximum_variable_storage_size = EFI_VAR_BUF_SIZE -
> sizeof(struct efi_var_file);
> *remaining_variable_storage_size = efi_var_mem_free();
> *maximum_variable_size = EFI_VAR_BUF_SIZE -
> sizeof(struct efi_var_file) -
> sizeof(struct efi_var_entry);
> - */
> - return EFI_UNSUPPORTED;
> + return EFI_SUCCESS;
> }
>
> /**
> @@ -351,7 +349,8 @@ static efi_status_t __efi_runtime EFIAPI
> efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
> u32 *attributes, efi_uintn_t *data_size, void *data)
> {
> - return EFI_UNSUPPORTED;
> + return efi_get_variable_int(variable_name, vendor, attributes,
> + data_size, data);
> }
>
> /**
> @@ -367,7 +366,8 @@ static efi_status_t __efi_runtime EFIAPI
> efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
> u16 *variable_name, efi_guid_t *vendor)
> {
> - return EFI_UNSUPPORTED;
> + return efi_get_next_variable_name_int(variable_name_size, variable_name,
> + vendor);
> }
>
> /**
> @@ -385,7 +385,18 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
> u32 attributes, efi_uintn_t data_size,
> const void *data)
> {
> - return EFI_UNSUPPORTED;
> + const u32 required_attributes = EFI_VARIABLE_NON_VOLATILE |
> + EFI_VARIABLE_BOOTSERVICE_ACCESS |
> + EFI_VARIABLE_RUNTIME_ACCESS;
> +
Why not support APPEND_WRITE?
> + if (attributes &&
> + (attributes & required_attributes) != required_attributes)
> + return EFI_INVALID_PARAMETER;
UEFI specification says,
===8<====
Variables that have runtime access but that are not nonvolatile are read-
only data variables once ExitBootServices() is performed.
[snip]
EFI_WRITE_PROTECTED The variable in question is read-only.
===>8===
So in this case, we should return WRITE_PROTECTED instead of
INVALID_PARAMETER.
> + if ((attributes & ~(u32)EFI_VARIABLE_MASK))
> + return EFI_INVALID_PARAMETER;
> +
> + return efi_set_variable_rt_int(variable_name, vendor, attributes,
> + data_size, data);
I didn't follow detailed logic of this function, but
does it really return UNSUPPORTED if !FAT_WRITE?
-Takahiro Akashi
> }
>
> /**
> --
> 2.25.1
>
next prev parent reply other threads:[~2020-04-01 1:41 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 5:27 [PATCH 00/16] efi_loader: non-volatile and runtime variables Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 01/16] cmd: efidebug: fix int to pointer cast Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 02/16] efi_loader: only reserve memory if fdt node enabled Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 03/16] efi_loader: eliminate EFI_CALL() for variable access Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 04/16] part: detect EFI system partition Heinrich Schuchardt
2020-03-27 6:35 ` Punit Agrawal
2020-03-27 7:21 ` Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 05/16] efi_loader: identify " Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 06/16] efi_loader: keep attributes in efi_set_variable_int() Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 07/16] efi_loader: export initialization state Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 08/16] efi_loader: change setup sequence Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 09/16] efi_loader: imply FAT, FAT_WRITE Heinrich Schuchardt
2020-03-31 5:28 ` AKASHI Takahiro
2020-03-31 6:44 ` Heinrich Schuchardt
2020-03-31 7:44 ` AKASHI Takahiro
2020-03-31 8:20 ` Mark Kettenis
2020-04-01 0:31 ` AKASHI Takahiro
2020-04-01 6:43 ` Heinrich Schuchardt
2020-04-01 17:56 ` Mark Kettenis
2020-04-02 1:34 ` AKASHI Takahiro
2020-03-31 13:08 ` Heinrich Schuchardt
2020-03-31 23:57 ` AKASHI Takahiro
2020-04-01 1:14 ` AKASHI Takahiro
2020-04-01 6:31 ` Heinrich Schuchardt
2020-04-01 7:04 ` AKASHI Takahiro
2020-04-02 12:33 ` Ilias Apalodimas
2020-03-27 5:27 ` [PATCH 10/16] efi_loader: UEFI variable persistence Heinrich Schuchardt
2020-03-27 8:07 ` Punit Agrawal
2020-03-27 10:30 ` Heinrich Schuchardt
2020-03-30 10:03 ` Punit Agrawal
2020-04-06 16:06 ` Ilias Apalodimas
2021-01-02 22:15 ` Peter Robinson
2020-03-27 5:27 ` [PATCH 11/16] efi_loader: export efi_convert_pointer() Heinrich Schuchardt
2020-03-27 5:27 ` [PATCH 12/16] efi_loader: optional pointer for ConvertPointer Heinrich Schuchardt
2020-03-31 5:23 ` AKASHI Takahiro
2020-03-31 6:52 ` Heinrich Schuchardt
2020-03-31 7:51 ` AKASHI Takahiro
2020-03-27 5:27 ` [PATCH 13/16] efi_loader: memory buffer for variables Heinrich Schuchardt
2020-03-27 8:09 ` Punit Agrawal
2020-03-27 10:45 ` Heinrich Schuchardt
2020-03-30 10:50 ` Punit Agrawal
2020-03-27 5:27 ` [PATCH 14/16] efi_loader: use memory based variable storage Heinrich Schuchardt
2020-03-27 19:44 ` [PATCH 00/16] efi_loader: non-volatile and runtime variables Simon Glass
2020-03-28 6:42 ` Heinrich Schuchardt
2020-03-31 6:05 ` [PATCH 15/16] efi_loader: enable UEFI variables at runtime Heinrich Schuchardt
2020-03-31 6:05 ` [PATCH 15/16] efi_selftest: adjust runtime test for variables Heinrich Schuchardt
2020-04-01 1:41 ` AKASHI Takahiro [this message]
2020-04-01 6:26 ` [PATCH 15/16] efi_loader: enable UEFI variables at runtime Heinrich Schuchardt
2020-04-01 6:51 ` AKASHI Takahiro
2020-03-31 6:07 ` [PATCH 16/16] efi_selftest: adjust runtime test for variables Heinrich Schuchardt
2020-04-01 1:05 ` AKASHI Takahiro
2020-04-01 6:37 ` Heinrich Schuchardt
2020-04-01 7:27 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200401014123.GS11504@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox