efi_selftest: simplify efi_st_query_variable_common

Use global st_runtime.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Heinrich Schuchardt
2025-11-14 10:32:44 +01:00
parent 178900ab9a
commit 98838b56cd
4 changed files with 28 additions and 38 deletions

View File

@@ -151,13 +151,11 @@ u16 efi_st_get_key(void);
/**
* efi_st_query_variable_common - Common variable tests for boottime/runtime
*
* @runtime: Pointer to services table
* @attributes: Attributes used
*
* Return: EFI_ST_SUCCESS/FAILURE
*/
int efi_st_query_variable_common(struct efi_runtime_services *runtime,
u32 attributes);
int efi_st_query_variable_common(u32 attributes);
/**
* struct efi_unit_test - EFI unit test

View File

@@ -53,8 +53,7 @@ static int execute(void)
efi_guid_t guid;
int test_ret;
test_ret = efi_st_query_variable_common(runtime,
EFI_VARIABLE_BOOTSERVICE_ACCESS);
test_ret = efi_st_query_variable_common(EFI_VARIABLE_BOOTSERVICE_ACCESS);
if (test_ret != EFI_ST_SUCCESS) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;

View File

@@ -11,15 +11,13 @@
#define EFI_INVALID_ATTR BIT(30)
int efi_st_query_variable_common(struct efi_runtime_services *runtime,
u32 attributes)
int efi_st_query_variable_common(u32 attributes)
{
efi_status_t ret;
u64 max_storage, rem_storage, max_size;
ret = runtime->query_variable_info(attributes,
&max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(attributes, &max_storage,
&rem_storage, &max_size);
if (ret != EFI_SUCCESS) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
@@ -28,58 +26,54 @@ int efi_st_query_variable_common(struct efi_runtime_services *runtime,
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(EFI_VARIABLE_RUNTIME_ACCESS,
&max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(EFI_VARIABLE_RUNTIME_ACCESS,
&max_storage, &rem_storage,
&max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(attributes,
NULL, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(attributes, NULL, &rem_storage,
&max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(attributes,
&max_storage, NULL,
&max_size);
ret = st_runtime->query_variable_info(attributes, &max_storage, NULL,
&max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(attributes,
&max_storage, &rem_storage,
NULL);
ret = st_runtime->query_variable_info(attributes, &max_storage,
&rem_storage, NULL);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(0, &max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(0, &max_storage, &rem_storage,
&max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(attributes |
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(
attributes | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage, &max_size);
if (ret != EFI_UNSUPPORTED) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
}
ret = runtime->query_variable_info(EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage,
&max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;
@@ -89,10 +83,9 @@ int efi_st_query_variable_common(struct efi_runtime_services *runtime,
* Use a mix existing/non-existing attribute bits from the
* UEFI spec
*/
ret = runtime->query_variable_info(attributes | EFI_INVALID_ATTR |
EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage,
&max_size);
ret = st_runtime->query_variable_info(
attributes | EFI_INVALID_ATTR | EFI_VARIABLE_NON_VOLATILE,
&max_storage, &rem_storage, &max_size);
if (ret != EFI_INVALID_PARAMETER) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;

View File

@@ -60,8 +60,8 @@ static int execute(void)
memset(v2, 0x1, sizeof(v2));
if (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) {
test_ret = efi_st_query_variable_common(runtime, EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS);
test_ret = efi_st_query_variable_common(EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS);
if (test_ret != EFI_ST_SUCCESS) {
efi_st_error("QueryVariableInfo failed\n");
return EFI_ST_FAILURE;