efi_loader: UEFI variable persistence

Persist non-volatile UEFI variables in a file on the EFI system partition.

The file is written whenever a non-volatile UEFI variable is changed after
initialization of the UEFI sub-system.

The file is read during the UEFI sub-system initialization to restore
non-volatile UEFI variables.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
Heinrich Schuchardt
2020-07-11 23:14:17 +02:00
parent 198bf6418e
commit 5f7dcf079d
5 changed files with 319 additions and 1 deletions
+9 -1
View File
@@ -988,6 +988,11 @@ out:
ret = EFI_SUCCESS;
}
/* Write non-volatile EFI variables to file */
if (attributes & EFI_VARIABLE_NON_VOLATILE &&
ret == EFI_SUCCESS && efi_obj_list_initialized == EFI_SUCCESS)
efi_var_to_file();
err:
free(native_name);
free(old_data);
@@ -1083,6 +1088,7 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
*/
void efi_variables_boot_exit_notify(void)
{
/* Switch variable services functions to runtime version */
efi_runtime_services.get_variable = efi_get_variable_runtime;
efi_runtime_services.get_next_variable_name =
efi_get_next_variable_name_runtime;
@@ -1102,6 +1108,8 @@ efi_status_t efi_init_variables(void)
efi_status_t ret;
ret = efi_init_secure_state();
if (ret != EFI_SUCCESS)
return ret;
return ret;
return efi_var_from_file();
}