if (!maximum_variable_storage_size ||
!remaining_variable_storage_size ||
- !maximum_variable_size ||
- !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS))
+ !maximum_variable_size)
return EFI_EXIT(EFI_INVALID_PARAMETER);
- if ((attributes & ~(u32)EFI_VARIABLE_MASK) ||
- (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
- (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) ||
- (!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) &&
- (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)))
- return EFI_EXIT(EFI_UNSUPPORTED);
-
ret = efi_query_variable_info_int(attributes,
maximum_variable_storage_size,
remaining_variable_storage_size,
u64 *remaining_variable_storage_size,
u64 *maximum_variable_size)
{
+ if (attributes == 0)
+ return EFI_INVALID_PARAMETER;
+
+ /* EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated */
+ if ((attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) ||
+ ((attributes & EFI_VARIABLE_MASK) == 0))
+ return EFI_UNSUPPORTED;
+
+ if ((attributes & EFI_VARIABLE_MASK) == EFI_VARIABLE_NON_VOLATILE)
+ return EFI_INVALID_PARAMETER;
+
+ /* Make sure if runtime bit is set, boot service bit is set also. */
+ if ((attributes &
+ (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) ==
+ EFI_VARIABLE_RUNTIME_ACCESS)
+ return EFI_INVALID_PARAMETER;
+
+ if (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD)
+ return EFI_UNSUPPORTED;
+
+ if (attributes & ~(u32)EFI_VARIABLE_MASK)
+ return EFI_INVALID_PARAMETER;
+
*maximum_variable_storage_size = EFI_VAR_BUF_SIZE -
sizeof(struct efi_var_file);
*remaining_variable_storage_size = efi_var_mem_free();