Hi Michal,
[...]
>
> config EFI_RT_VOLATILE_STORE
> bool "Allow variable runtime services in volatile storage (e.g RAM)"
> - depends on EFI_VARIABLE_FILE_STORE
> + depends on EFI_VARIABLE_FILE_STORE || EFI_VARIABLE_SF_STORE
Will this work on nands as well? They got a much shrter lifetime that
spi flashes.
> help
> When EFI variables are stored on file we don't allow SetVariableRT,
> since the OS doesn't know how to write that file. At the same time
I am not sure we need to allow this for now. At least not until we've
talked to the efitool maintainers and make sure they will accept
another 'special' case.
The problem with allowing this is that if people enable it, boot a
linux and do a setvariable, it will return a success. But none of the
variables will be preserved after a reboot unless someone manually
updates the serial flash contents. In theory, we can preserve the
driver model and the spi drivers in EFI runtime services and allow
'proper' setvariable at runtime.
However, I think this is not very useful. Having an unprotected to
store authenticated EFI variables, is dangerous. Someone can erase the
SPI flash and efectively disable secure boot. Due to that, I prefer
the current file based approach for EFI variables -- which doesn't
store/restore authenticated EFI variables (and which this patch
implements). The obvious downside is that enable setvariable at
runtime is tricky once again....
[...]
> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
> index be670a8e7c25..feab212b245b 100644
> --- a/lib/efi_loader/efi_variable.c
> +++ b/lib/efi_loader/efi_variable.c
> @@ -397,11 +397,11 @@ efi_status_t efi_set_variable_int(const u16
> *variable_name,
> ret = EFI_SUCCESS;
>
> /*
> - * Write non-volatile EFI variables to file
> + * Write non-volatile EFI variables to file or SPI Flash
> * TODO: check if a value change has occured to avoid superfluous
> writes
> */
> if (attributes & EFI_VARIABLE_NON_VOLATILE) {
> -#if CONFIG_IS_ENABLED(EFI_VARIABLE_FILE_STORE)
> +#if CONFIG_IS_ENABLED(EFI_VARIABLE_FILE_STORE) ||
> CONFIG_IS_ENABLED(EFI_VARIABLE_SF_STORE)
Do we need the ifdefery here? efi_variable.o is basically compiled
whenever we have the variables managed by the non-secure world and
this function will exist either with a file back storage or a SPI
flash
> efi_var_write();
> #else
> return EFI_NOT_READY;
> @@ -599,7 +599,7 @@ efi_status_t efi_init_variables(void)
> if (ret != EFI_SUCCESS)
> return ret;
>
> -#if CONFIG_IS_ENABLED(EFI_VARIABLE_FILE_STORE)
> +#if CONFIG_IS_ENABLED(EFI_VARIABLE_FILE_STORE) ||
> CONFIG_IS_ENABLED(EFI_VARIABLE_SF_STORE)
ditto
> ret = efi_var_read();
> if (ret != EFI_SUCCESS)
> return ret;
> --
> 2.43.0
>
Cheers
/Ilias