From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH 16/16] efi_selftest: adjust runtime test for variables
Date: Wed, 1 Apr 2020 16:27:16 +0900 [thread overview]
Message-ID: <20200401072715.GV11504@linaro.org> (raw)
In-Reply-To: <4db4a544-b7b3-fd4d-edb7-c6226ff79ba1@gmx.de>
On Wed, Apr 01, 2020 at 08:37:38AM +0200, Heinrich Schuchardt wrote:
> On 4/1/20 3:05 AM, AKASHI Takahiro wrote:
> > On Tue, Mar 31, 2020 at 08:07:39AM +0200, Heinrich Schuchardt wrote:
> >> As variable services are available at runtime we have to expect EFI_SUCCESS
> >> when calling the services.
> >
> > Why not run variables test *after* ExitBootServices as well as
> > *before* that event?
>
> We have a separate test for before ExitBootServices
> (lib/efi_selftest/efi_selftest_variables.c).
Ah, I misundersttood the file to be patched.
(EXECUTE_BEFORE_BOOTTIME_EXIT and SETUP_BEFORE_BOOTTIME_EXIT
are quite confusing.)
> >
> > Then we should have more test cases.
>
> Please, feel free to supply some.
?
You re-invented UEFI variable implementation almost from the scratch,
then you should cover as many corner cases as possible in general.
-Takahiro Akashi
> Unfortunately SCT does not provide runtime testing. I have been running
> my code successfully against Ubuntu's firmware test suite
> (https://git.launchpad.net/fwts).
>
> >
> >> Check the SetVariable() only succeeds with EFI_VARIABLE_RUNTIME_ACCESS and
> >> EFI_VARIABLE_NON_VOLATILE set.
> >
> > I'm not sure if this claim(check) is true.
> > At least, you need provide more description about specific test conditions.
>
> At runtime non-volatile variables and variables without runtime access
> cannot be changed according to the UEFI spec.
> Best regards
>
> Heinrich
>
> >
> > -Takahiro Akashi
> >
> >>
> >> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >> ---
> >> .../efi_selftest_variables_runtime.c | 47 +++++++++++++++----
> >> 1 file changed, 39 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/lib/efi_selftest/efi_selftest_variables_runtime.c b/lib/efi_selftest/efi_selftest_variables_runtime.c
> >> index b3b40ad2cf..c6005eeeaf 100644
> >> --- a/lib/efi_selftest/efi_selftest_variables_runtime.c
> >> +++ b/lib/efi_selftest/efi_selftest_variables_runtime.c
> >> @@ -20,8 +20,8 @@ static const efi_guid_t guid_vendor0 =
> >> EFI_GUID(0x67029eb5, 0x0af2, 0xf6b1,
> >> 0xda, 0x53, 0xfc, 0xb5, 0x66, 0xdd, 0x1c, 0xe6);
> >>
> >> -/*
> >> - * Setup unit test.
> >> +/**
> >> + * setup() - set up unit test.
> >> *
> >> * @handle handle of the loaded image
> >> * @systable system table
> >> @@ -38,7 +38,7 @@ static int setup(const efi_handle_t img_handle,
> >> /**
> >> * execute() - execute unit test
> >> *
> >> - * As runtime support is not implmented expect EFI_UNSUPPORTED to be returned.
> >> + * Test variable services at runtime.
> >> */
> >> static int execute(void)
> >> {
> >> @@ -52,37 +52,68 @@ static int execute(void)
> >> efi_guid_t guid;
> >> u64 max_storage, rem_storage, max_size;
> >>
> >> - ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS,
> >> + ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS |
> >> + EFI_VARIABLE_RUNTIME_ACCESS |
> >> + EFI_VARIABLE_NON_VOLATILE,
> >> &max_storage, &rem_storage,
> >> &max_size);
> >> - if (ret != EFI_UNSUPPORTED) {
> >> + if (ret != EFI_SUCCESS) {
> >> efi_st_error("QueryVariableInfo failed\n");
> >> return EFI_ST_FAILURE;
> >> }
> >>
> >> + ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0,
> >> + EFI_VARIABLE_BOOTSERVICE_ACCESS |
> >> + EFI_VARIABLE_NON_VOLATILE,
> >> + 3, v + 4);
> >> + if (ret != EFI_INVALID_PARAMETER) {
> >> + efi_st_error("SetVariable succeeded w/o EFI_VARIABLE_RUNTIME_ACCESS\n");
> >> + return EFI_ST_FAILURE;
> >> + }
> >> +
> >> ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0,
> >> EFI_VARIABLE_BOOTSERVICE_ACCESS |
> >> EFI_VARIABLE_RUNTIME_ACCESS,
> >> 3, v + 4);
> >> - if (ret != EFI_UNSUPPORTED) {
> >> + if (ret != EFI_INVALID_PARAMETER) {
> >> + efi_st_error("SetVariable succeeded w/o EFI_VARIABLE_NON_VOLATILE\n");
> >> + return EFI_ST_FAILURE;
> >> + }
> >> +
> >> + ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0,
> >> + EFI_VARIABLE_BOOTSERVICE_ACCESS |
> >> + EFI_VARIABLE_RUNTIME_ACCESS |
> >> + EFI_VARIABLE_NON_VOLATILE,
> >> + 3, v + 4);
> >> + if (ret != EFI_SUCCESS) {
> >> efi_st_error("SetVariable failed\n");
> >> return EFI_ST_FAILURE;
> >> }
> >> +
> >> len = 3;
> >> ret = runtime->get_variable(L"efi_st_var0", &guid_vendor0,
> >> &attr, &len, data);
> >> - if (ret != EFI_UNSUPPORTED) {
> >> + if (ret != EFI_SUCCESS) {
> >> efi_st_error("GetVariable failed\n");
> >> return EFI_ST_FAILURE;
> >> }
> >> +
> >> memset(&guid, 0, 16);
> >> *varname = 0;
> >> + len = EFI_ST_MAX_VARNAME_SIZE * sizeof(u16);
> >> ret = runtime->get_next_variable_name(&len, varname, &guid);
> >> - if (ret != EFI_UNSUPPORTED) {
> >> + if (ret != EFI_SUCCESS) {
> >> efi_st_error("GetNextVariableName failed\n");
> >> return EFI_ST_FAILURE;
> >> }
> >>
> >> + ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, 0,
> >> + 3, v + 4);
> >> + if (ret != EFI_SUCCESS) {
> >> + efi_st_error("Variable deletion failed\n");
> >> + return EFI_ST_FAILURE;
> >> + }
> >> +
> >> return EFI_ST_SUCCESS;
> >> }
> >>
> >> --
> >> 2.25.1
> >>
>
prev parent reply other threads:[~2020-04-01 7:27 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 ` [PATCH 15/16] efi_loader: enable UEFI variables at runtime AKASHI Takahiro
2020-04-01 6:26 ` 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 [this message]
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=20200401072715.GV11504@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.