Message ID | 20200511181403.19448-4-ilias.apalodimas@linaro.org |
---|---|
State | New |
Headers | show |
Series | EFI variable support via OP-TEE | expand |
On 5/11/20 8:14 PM, Ilias Apalodimas wrote: > With the previous patches that use OP-TEE and StandAloneMM for UEFI > variable storage we've added functionality for efi_query_variable_info. > So let's add the relevant command to efidebug and retrieve information > about the container used to store UEFI variables > > Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org> For now attributes (e.g. EFI_VARIABLE_NON_VOLATILE) cannot be passed to the 'efidebug query' sub-command instead a fixed value is used. We can add attributes on the command line later. > --- > cmd/efidebug.c | 44 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 43 insertions(+), 1 deletion(-) > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > index d8a76d78a388..a3980772c934 100644 > --- a/cmd/efidebug.c > +++ b/cmd/efidebug.c > @@ -1160,6 +1160,44 @@ static int do_efi_test(cmd_tbl_t *cmdtp, int flag, > return cp->cmd(cmdtp, flag, argc, argv); > } > > +/** > + * do_efi_query_info() - QueryVariableInfo EFI service > + * > + * @cmdtp: Command table > + * @flag: Command flag > + * @argc: Number of arguments > + * @argv: Argument array > + * Return: CMD_RET_SUCCESS on success, > + * CMD_RET_USAGE or CMD_RET_FAILURE on failure > + * > + * Implement efidebug "test" sub-command. > + */ > + > +static int do_efi_query_info(cmd_tbl_t *cmdtp, int flag, > + int argc, char * const argv[]) > +{ > + efi_status_t ret; > + u32 attr = EFI_VARIABLE_BOOTSERVICE_ACCESS | > + EFI_VARIABLE_RUNTIME_ACCESS | > + EFI_VARIABLE_NON_VOLATILE; As we do not support variables at runtime currently shouldn't we remove EFI_VARIABLE_RUNTIME_ACCESS from the default value? I could do that when merging. Otherwise: Reviewed-by: Heinrich Schuchardt <xypron.glpk at gmx.de> > + u64 max_variable_storage_size; > + u64 remain_variable_storage_size; > + u64 max_variable_size; > + > + ret = EFI_CALL(efi_query_variable_info(attr, > + &max_variable_storage_size, > + &remain_variable_storage_size, > + &max_variable_size)); > + if (ret != EFI_SUCCESS) > + return CMD_RET_FAILURE; > + > + printf("Max storage size %llu\n", max_variable_storage_size); > + printf("Remaining storage size %llu\n", remain_variable_storage_size); > + printf("Max variable size %llu\n", max_variable_size); > + > + return CMD_RET_SUCCESS; > +} > + > static cmd_tbl_t cmd_efidebug_sub[] = { > U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""), > U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, > @@ -1176,6 +1214,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { > "", ""), > U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test, > "", ""), > + U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info, > + "", ""), > }; > > /** > @@ -1247,7 +1287,9 @@ static char efidebug_help_text[] = > "efidebug tables\n" > " - show UEFI configuration tables\n" > "efidebug test bootmgr\n" > - " - run simple bootmgr for test\n"; > + " - run simple bootmgr for test\n" > + "efidebug query\n" > + " - show size of UEFI variables store\n"; > #endif > > U_BOOT_CMD( >
On Mon, May 11, 2020 at 08:54:04PM +0200, Heinrich Schuchardt wrote: > On 5/11/20 8:14 PM, Ilias Apalodimas wrote: > > With the previous patches that use OP-TEE and StandAloneMM for UEFI > > variable storage we've added functionality for efi_query_variable_info. > > So let's add the relevant command to efidebug and retrieve information > > about the container used to store UEFI variables > > > > Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org> > > For now attributes (e.g. EFI_VARIABLE_NON_VOLATILE) cannot be passed to > the 'efidebug query' sub-command instead a fixed value is used. We can > add attributes on the command line later. Good point, I'll add it on the commit message for v3 > > > --- > > cmd/efidebug.c | 44 +++++++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 43 insertions(+), 1 deletion(-) > > > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > > index d8a76d78a388..a3980772c934 100644 > > --- a/cmd/efidebug.c > > +++ b/cmd/efidebug.c > > @@ -1160,6 +1160,44 @@ static int do_efi_test(cmd_tbl_t *cmdtp, int flag, > > return cp->cmd(cmdtp, flag, argc, argv); > > } > > > > +/** > > + * do_efi_query_info() - QueryVariableInfo EFI service > > + * > > + * @cmdtp: Command table > > + * @flag: Command flag > > + * @argc: Number of arguments > > + * @argv: Argument array > > + * Return: CMD_RET_SUCCESS on success, > > + * CMD_RET_USAGE or CMD_RET_FAILURE on failure > > + * > > + * Implement efidebug "test" sub-command. > > + */ > > + > > +static int do_efi_query_info(cmd_tbl_t *cmdtp, int flag, > > + int argc, char * const argv[]) > > +{ > > + efi_status_t ret; > > + u32 attr = EFI_VARIABLE_BOOTSERVICE_ACCESS | > > + EFI_VARIABLE_RUNTIME_ACCESS | > > + EFI_VARIABLE_NON_VOLATILE; > > As we do not support variables at runtime currently shouldn't we remove > EFI_VARIABLE_RUNTIME_ACCESS from the default value? I could do that when > merging. We can still add variables marked as runtime in U-Boot's cmd line although we don't support those in Linux. So I'd keep that flag on the defaults. > > Otherwise: > > Reviewed-by: Heinrich Schuchardt <xypron.glpk at gmx.de> > Regards /Ilias
diff --git a/cmd/efidebug.c b/cmd/efidebug.c index d8a76d78a388..a3980772c934 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1160,6 +1160,44 @@ static int do_efi_test(cmd_tbl_t *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } +/** + * do_efi_query_info() - QueryVariableInfo EFI service + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_FAILURE on failure + * + * Implement efidebug "test" sub-command. + */ + +static int do_efi_query_info(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_status_t ret; + u32 attr = EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS | + EFI_VARIABLE_NON_VOLATILE; + u64 max_variable_storage_size; + u64 remain_variable_storage_size; + u64 max_variable_size; + + ret = EFI_CALL(efi_query_variable_info(attr, + &max_variable_storage_size, + &remain_variable_storage_size, + &max_variable_size)); + if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + + printf("Max storage size %llu\n", max_variable_storage_size); + printf("Remaining storage size %llu\n", remain_variable_storage_size); + printf("Max variable size %llu\n", max_variable_size); + + return CMD_RET_SUCCESS; +} + static cmd_tbl_t cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""), U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, @@ -1176,6 +1214,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { "", ""), U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test, "", ""), + U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info, + "", ""), }; /** @@ -1247,7 +1287,9 @@ static char efidebug_help_text[] = "efidebug tables\n" " - show UEFI configuration tables\n" "efidebug test bootmgr\n" - " - run simple bootmgr for test\n"; + " - run simple bootmgr for test\n" + "efidebug query\n" + " - show size of UEFI variables store\n"; #endif U_BOOT_CMD(
With the previous patches that use OP-TEE and StandAloneMM for UEFI variable storage we've added functionality for efi_query_variable_info. So let's add the relevant command to efidebug and retrieve information about the container used to store UEFI variables Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org> --- cmd/efidebug.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-)