return str;
}
-static efi_status_t efi_set_variable_internal(u16 *variable_name,
- const efi_guid_t *vendor,
- u32 attributes,
- efi_uintn_t data_size,
- const void *data,
- bool ro_check);
+static efi_status_t efi_set_variable_common(u16 *variable_name,
+ const efi_guid_t *vendor,
+ u32 attributes,
+ efi_uintn_t data_size,
+ const void *data,
+ bool ro_check);
/**
* efi_set_secure_state - modify secure boot state variables
attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
READ_ONLY;
- ret = efi_set_variable_internal(L"SecureBoot",
- &efi_global_variable_guid,
- attributes,
- sizeof(sec_boot), &sec_boot,
- false);
+ ret = efi_set_variable_common(L"SecureBoot", &efi_global_variable_guid,
+ attributes, sizeof(sec_boot), &sec_boot,
+ false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_internal(L"SetupMode",
- &efi_global_variable_guid,
- attributes,
- sizeof(setup_mode), &setup_mode,
- false);
+ ret = efi_set_variable_common(L"SetupMode", &efi_global_variable_guid,
+ attributes, sizeof(setup_mode),
+ &setup_mode, false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_internal(L"AuditMode",
- &efi_global_variable_guid,
- attributes,
- sizeof(audit_mode), &audit_mode,
- false);
+ ret = efi_set_variable_common(L"AuditMode", &efi_global_variable_guid,
+ attributes, sizeof(audit_mode),
+ &audit_mode, false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_internal(L"DeployedMode",
- &efi_global_variable_guid,
- attributes,
- sizeof(deployed_mode), &deployed_mode,
- false);
+ ret = efi_set_variable_common(L"DeployedMode",
+ &efi_global_variable_guid, attributes,
+ sizeof(deployed_mode), &deployed_mode,
+ false);
err:
return ret;
}
* @mode: new state
*
* Depending on @mode, secure boot related variables are updated.
- * Those variables are *read-only* for users, efi_set_variable_internal()
+ * Those variables are *read-only* for users, efi_set_variable_common()
* is called here.
*
* Return: EFI_SUCCESS on success, status code (negative) on error
efi_secure_boot = true;
} else if (mode == EFI_MODE_AUDIT) {
- ret = efi_set_variable_internal(
- L"PK", &efi_global_variable_guid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS |
- EFI_VARIABLE_RUNTIME_ACCESS,
- 0, NULL, false);
+ ret = efi_set_variable_common(L"PK", &efi_global_variable_guid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ 0, NULL, false);
if (ret != EFI_SUCCESS)
goto err;
ret = efi_transfer_secure_state(mode);
if (ret == EFI_SUCCESS)
- ret = efi_set_variable_internal(L"VendorKeys",
- &efi_global_variable_guid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS
- | EFI_VARIABLE_RUNTIME_ACCESS
- | READ_ONLY,
- sizeof(efi_vendor_keys),
- &efi_vendor_keys,
- false);
+ ret = efi_set_variable_common(L"VendorKeys",
+ &efi_global_variable_guid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS |
+ READ_ONLY,
+ sizeof(efi_vendor_keys),
+ &efi_vendor_keys, false);
err:
return ret;
return EFI_EXIT(ret);
}
-static
-efi_status_t EFIAPI efi_set_variable_common(u16 *variable_name,
+static efi_status_t efi_set_variable_common(u16 *variable_name,
const efi_guid_t *vendor,
u32 attributes,
efi_uintn_t data_size,
const void *data,
- bool ro_check,
- bool is_non_volatile)
+ bool ro_check)
{
char *native_name = NULL, *old_data = NULL, *val = NULL, *s;
efi_uintn_t old_size;
attr = 0;
ret = EFI_CALL(efi_get_variable(variable_name, vendor, &attr,
&old_size, NULL));
- if (ret == EFI_BUFFER_TOO_SMALL) {
- if ((is_non_volatile && !(attr & EFI_VARIABLE_NON_VOLATILE)) ||
- (!is_non_volatile && (attr & EFI_VARIABLE_NON_VOLATILE))) {
- ret = EFI_INVALID_PARAMETER;
- goto err;
- }
- }
-
append = !!(attributes & EFI_VARIABLE_APPEND_WRITE);
attributes &= ~(u32)EFI_VARIABLE_APPEND_WRITE;
delete = !append && (!data_size || !attributes);
/* update VendorKeys */
if (vendor_keys_modified & efi_vendor_keys) {
efi_vendor_keys = 0;
- ret = efi_set_variable_internal(
+ ret = efi_set_variable_common(
L"VendorKeys",
&efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS
return ret;
}
-static
-efi_status_t EFIAPI efi_set_volatile_variable(u16 *variable_name,
- const efi_guid_t *vendor,
- u32 attributes,
- efi_uintn_t data_size,
- const void *data,
- bool ro_check)
-{
- return efi_set_variable_common(variable_name, vendor, attributes,
- data_size, data, ro_check, false);
-}
-
-efi_status_t EFIAPI efi_set_nonvolatile_variable(u16 *variable_name,
- const efi_guid_t *vendor,
- u32 attributes,
- efi_uintn_t data_size,
- const void *data,
- bool ro_check)
-{
- efi_status_t ret;
-
- ret = efi_set_variable_common(variable_name, vendor, attributes,
- data_size, data, ro_check, true);
-
- return ret;
-}
-
-static efi_status_t efi_set_variable_internal(u16 *variable_name,
- const efi_guid_t *vendor,
- u32 attributes,
- efi_uintn_t data_size,
- const void *data,
- bool ro_check)
-{
- efi_status_t ret;
-
- if (attributes & EFI_VARIABLE_NON_VOLATILE)
- ret = efi_set_nonvolatile_variable(variable_name, vendor,
- attributes,
- data_size, data, ro_check);
- else
- ret = efi_set_volatile_variable(variable_name, vendor,
- attributes, data_size, data,
- ro_check);
-
- return ret;
-}
-
/**
* efi_set_variable() - set value of a UEFI variable
*
/* READ_ONLY bit is not part of API */
attributes &= ~(u32)READ_ONLY;
- return EFI_EXIT(efi_set_variable_internal(variable_name, vendor,
- attributes, data_size, data,
- true));
+ return EFI_EXIT(efi_set_variable_common(variable_name, vendor,
+ attributes, data_size, data,
+ true));
}
/**