[U-Boot] [PATCH v2 6/9] efi_selftest: allow to select a single test for exexution
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Oct 17 10:58:23 UTC 2017
On 10/17/2017 09:48 AM, Alexander Graf wrote:
>
>
> On 13.10.17 19:33, Heinrich Schuchardt wrote:
>> Environment variable efi_selftest is passed as load options
>> to the selftest application. It is used to select a single
>> test to be executed.
>>
>> Special value 'list' displays a list of all available tests.
>>
>> Tests get an on_request property. If this property is set
>> the tests are only executed if explicitly requested.
>>
>> The invocation of efi_selftest is changed to reflect that
>> bootefi selftest with efi_selftest = 'list' will call the
>> Exit bootservice.
>>
>> Environment variable bootargs is used as load options
>> for all other bootefi payloads.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
>> ---
>> v2
>> use an environment variable to choose a test
>> ---
>> cmd/bootefi.c | 46 ++++++++++++++++-
>> include/efi_selftest.h | 18 +++++++
>> lib/efi_selftest/efi_selftest.c | 90 +++++++++++++++++++++++++++++++--
>> lib/efi_selftest/efi_selftest_console.c | 10 ++++
>> lib/efi_selftest/efi_selftest_util.c | 11 +++-
>> 5 files changed, 168 insertions(+), 7 deletions(-)
>>
>> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
>> index 18176a1266..2d70137482 100644
>> --- a/cmd/bootefi.c
>> +++ b/cmd/bootefi.c
>> @@ -6,10 +6,12 @@
>> * SPDX-License-Identifier: GPL-2.0+
>> */
>>
>> +#include <charset.h>
>> #include <common.h>
>> #include <command.h>
>> #include <dm.h>
>> #include <efi_loader.h>
>> +#include <efi_selftest.h>
>> #include <errno.h>
>> #include <libfdt.h>
>> #include <libfdt_env.h>
>> @@ -50,6 +52,32 @@ static void efi_init_obj_list(void)
>> efi_get_time_init();
>> }
>>
>> +/*
>> + * Set the load options of an image from an environment variable.
>> + *
>> + * @loaded_image_info: the image
>> + * @env_var: name of the environment variable
>> + */
>> +static void set_load_options(struct efi_loaded_image *loaded_image_info,
>> + const char *env_var)
>> +{
>> + size_t size;
>> + const char *env = env_get(env_var);
>> +
>> + loaded_image_info->load_options = NULL;
>> + loaded_image_info->load_options_size = 0;
>> + if (!env)
>> + return;
>> + size = strlen(env) + 1;
>> + loaded_image_info->load_options = calloc(size, sizeof(u16));
>> + if (!loaded_image_info->load_options) {
>> + printf("ERROR: Out of memory\n");
>> + return;
>> + }
>> + utf8_to_utf16(loaded_image_info->load_options, (u8 *)env, size);
>> + loaded_image_info->load_options_size = size * 2;
>> +}
>> +
>> static void *copy_fdt(void *fdt)
>> {
>> u64 fdt_size = fdt_totalsize(fdt);
>> @@ -190,6 +218,8 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt,
>> efi_install_configuration_table(&fdt_guid, NULL);
>> }
>>
>> + /* Transfer environment variable bootargs as load options */
>> + set_load_options(&loaded_image_info, "bootargs");
>
> While I really want to see that change, please try not to sneak it in
> with the selftest one :).
>
> Just split that hunk out to a following patch and give it its own patch
> description. In case something goes wrong, we'd only need to revert a
> small patch then.
>
>> /* Load the EFI payload */
>> entry = efi_load_pe(efi, &loaded_image_info);
>> if (!entry) {
>> @@ -237,6 +267,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt,
>>
>> exit:
>> /* image has returned, loaded-image obj goes *poof*: */
>> + free(loaded_image_info.load_options);
>
> This too is a change that doesn't fit the patch description?
>
>> list_del(&loaded_image_info_obj.link);
>>
>> return ret;
>> @@ -301,17 +332,26 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>
>> efi_setup_loaded_image(&loaded_image_info,
>> &loaded_image_info_obj,
>> - bootefi_device_path, bootefi_image_path);
>> + NULL, NULL);
>
> Why?
We have neither a device nor an image path here. We do not want to use
the values that where set by a prior call.
bf19273e81eb efi_loader: Add mem-mapped for fallback
provided a logic for helloworld.
I will add a preceding patch to move that to efi_setup_loaded_image.
Regards
Heinrich
More information about the U-Boot
mailing list