mbox series

[00/16] efi_loader: non-volatile and runtime variables

Message ID 20200327052800.11022-1-xypron.glpk@gmx.de
Headers show
Series efi_loader: non-volatile and runtime variables | expand

Message

Heinrich Schuchardt March 27, 2020, 5:27 a.m. UTC
Up to UEFI variable where stored in U-Boot environment variables. Saving
UEFI variables was not possible without saving the U-Boot environment
variables.

With this patch series file ubootefi.var in the EFI system partition is
used for saving UEFI variables.

Furthermore the UEFI variables are exposed at runtime and are writable at
runtime.

The missing piece is transferring the variable changed at runtime back to
the firmware. I will evaluate the following options:

* using a fixed memory address: we could read the memory area after a
  reboot
* using a systemd service which is called before the system goes down

Many of the CCs are due to the changes in disk/part_efi.c. Here the logic
to detect the EFI system partition is introduced (patch 04/16).

Heinrich Schuchardt (16):
  cmd: efidebug: fix int to pointer cast
  efi_loader: only reserve memory if fdt node enabled
  efi_loader: eliminate EFI_CALL() for variable access
  part: detect EFI system partition
  efi_loader: identify EFI system partition
  efi_loader: keep attributes in efi_set_variable_int()
  efi_loader: export initialization state
  efi_loader: change setup sequence
  efi_loader: imply FAT, FAT_WRITE
  efi_loader: UEFI variable persistence
  efi_loader: export efi_convert_pointer()
  efi_loader: optional pointer for ConvertPointer
  efi_loader: memory buffer for variables
  efi_loader: use memory based variable storage
  efi_loader: enable UEFI variables at runtime
  efi_selftest: adjust runtime test for variables

 cmd/bootefi.c                                 |   3 +-
 cmd/efidebug.c                                |  71 +-
 cmd/nvedit_efi.c                              |  18 +-
 disk/part_dos.c                               |  10 +-
 disk/part_efi.c                               |  12 +-
 include/efi_api.h                             |   2 +
 include/efi_loader.h                          |  22 +
 include/efi_variable.h                        |  52 ++
 include/part.h                                |  11 +-
 lib/efi_loader/Kconfig                        |  10 +
 lib/efi_loader/Makefile                       |   2 +
 lib/efi_loader/efi_bootmgr.c                  |  20 +-
 lib/efi_loader/efi_disk.c                     |  20 +
 lib/efi_loader/efi_runtime.c                  |  20 +-
 lib/efi_loader/efi_setup.c                    |  54 +-
 lib/efi_loader/efi_variable.c                 | 635 ++++++------------
 lib/efi_loader/efi_variables_file.c           | 235 +++++++
 lib/efi_loader/efi_variables_mem.c            | 324 +++++++++
 .../efi_selftest_variables_runtime.c          |  47 +-
 19 files changed, 1037 insertions(+), 531 deletions(-)
 create mode 100644 include/efi_variable.h
 create mode 100644 lib/efi_loader/efi_variables_file.c
 create mode 100644 lib/efi_loader/efi_variables_mem.c

--
2.25.1

Comments

Simon Glass March 27, 2020, 7:44 p.m. UTC | #1
Hi Heinrich,

On Thu, 26 Mar 2020 at 23:28, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Up to UEFI variable where stored in U-Boot environment variables. Saving

That doesn't read right to me.

> UEFI variables was not possible without saving the U-Boot environment
> variables.
>
> With this patch series file ubootefi.var in the EFI system partition is
> used for saving UEFI variables.
>
> Furthermore the UEFI variables are exposed at runtime and are writable at
> runtime.
>
> The missing piece is transferring the variable changed at runtime back to
> the firmware. I will evaluate the following options:
>
> * using a fixed memory address: we could read the memory area after a
>   reboot
> * using a systemd service which is called before the system goes down
>
> Many of the CCs are due to the changes in disk/part_efi.c. Here the logic
> to detect the EFI system partition is introduced (patch 04/16).
>
> Heinrich Schuchardt (16):
>   cmd: efidebug: fix int to pointer cast
>   efi_loader: only reserve memory if fdt node enabled
>   efi_loader: eliminate EFI_CALL() for variable access
>   part: detect EFI system partition
>   efi_loader: identify EFI system partition
>   efi_loader: keep attributes in efi_set_variable_int()
>   efi_loader: export initialization state
>   efi_loader: change setup sequence
>   efi_loader: imply FAT, FAT_WRITE
>   efi_loader: UEFI variable persistence
>   efi_loader: export efi_convert_pointer()
>   efi_loader: optional pointer for ConvertPointer
>   efi_loader: memory buffer for variables
>   efi_loader: use memory based variable storage
>   efi_loader: enable UEFI variables at runtime
>   efi_selftest: adjust runtime test for variables
>
>  cmd/bootefi.c                                 |   3 +-
>  cmd/efidebug.c                                |  71 +-
>  cmd/nvedit_efi.c                              |  18 +-
>  disk/part_dos.c                               |  10 +-
>  disk/part_efi.c                               |  12 +-
>  include/efi_api.h                             |   2 +
>  include/efi_loader.h                          |  22 +
>  include/efi_variable.h                        |  52 ++
>  include/part.h                                |  11 +-
>  lib/efi_loader/Kconfig                        |  10 +
>  lib/efi_loader/Makefile                       |   2 +
>  lib/efi_loader/efi_bootmgr.c                  |  20 +-
>  lib/efi_loader/efi_disk.c                     |  20 +
>  lib/efi_loader/efi_runtime.c                  |  20 +-
>  lib/efi_loader/efi_setup.c                    |  54 +-
>  lib/efi_loader/efi_variable.c                 | 635 ++++++------------
>  lib/efi_loader/efi_variables_file.c           | 235 +++++++
>  lib/efi_loader/efi_variables_mem.c            | 324 +++++++++
>  .../efi_selftest_variables_runtime.c          |  47 +-
>  19 files changed, 1037 insertions(+), 531 deletions(-)
>  create mode 100644 include/efi_variable.h
>  create mode 100644 lib/efi_loader/efi_variables_file.c
>  create mode 100644 lib/efi_loader/efi_variables_mem.c

Can you use 'vars' instead of variables as these filenames are too long.

Regards,
Simon
Heinrich Schuchardt March 28, 2020, 6:42 a.m. UTC | #2
On 3/27/20 8:44 PM, Simon Glass wrote:
> Hi Heinrich,
>
> On Thu, 26 Mar 2020 at 23:28, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>>
>> Up to UEFI variable where stored in U-Boot environment variables. Saving
>
> That doesn't read right to me.

This should be:

Up to now UEFI variable were stored in U-Boot environment variables

>
>> UEFI variables was not possible without saving the U-Boot environment
>> variables.
>>
>> With this patch series file ubootefi.var in the EFI system partition is
>> used for saving UEFI variables.
>>
>> Furthermore the UEFI variables are exposed at runtime and are writable at
>> runtime.
>>
>> The missing piece is transferring the variable changed at runtime back to
>> the firmware. I will evaluate the following options:
>>
>> * using a fixed memory address: we could read the memory area after a
>>    reboot
>> * using a systemd service which is called before the system goes down
>>
>> Many of the CCs are due to the changes in disk/part_efi.c. Here the logic
>> to detect the EFI system partition is introduced (patch 04/16).
>>
>> Heinrich Schuchardt (16):
>>    cmd: efidebug: fix int to pointer cast
>>    efi_loader: only reserve memory if fdt node enabled
>>    efi_loader: eliminate EFI_CALL() for variable access
>>    part: detect EFI system partition
>>    efi_loader: identify EFI system partition
>>    efi_loader: keep attributes in efi_set_variable_int()
>>    efi_loader: export initialization state
>>    efi_loader: change setup sequence
>>    efi_loader: imply FAT, FAT_WRITE
>>    efi_loader: UEFI variable persistence
>>    efi_loader: export efi_convert_pointer()
>>    efi_loader: optional pointer for ConvertPointer
>>    efi_loader: memory buffer for variables
>>    efi_loader: use memory based variable storage
>>    efi_loader: enable UEFI variables at runtime
>>    efi_selftest: adjust runtime test for variables
>>
>>   cmd/bootefi.c                                 |   3 +-
>>   cmd/efidebug.c                                |  71 +-
>>   cmd/nvedit_efi.c                              |  18 +-
>>   disk/part_dos.c                               |  10 +-
>>   disk/part_efi.c                               |  12 +-
>>   include/efi_api.h                             |   2 +
>>   include/efi_loader.h                          |  22 +
>>   include/efi_variable.h                        |  52 ++
>>   include/part.h                                |  11 +-
>>   lib/efi_loader/Kconfig                        |  10 +
>>   lib/efi_loader/Makefile                       |   2 +
>>   lib/efi_loader/efi_bootmgr.c                  |  20 +-
>>   lib/efi_loader/efi_disk.c                     |  20 +
>>   lib/efi_loader/efi_runtime.c                  |  20 +-
>>   lib/efi_loader/efi_setup.c                    |  54 +-
>>   lib/efi_loader/efi_variable.c                 | 635 ++++++------------
>>   lib/efi_loader/efi_variables_file.c           | 235 +++++++
>>   lib/efi_loader/efi_variables_mem.c            | 324 +++++++++
>>   .../efi_selftest_variables_runtime.c          |  47 +-
>>   19 files changed, 1037 insertions(+), 531 deletions(-)
>>   create mode 100644 include/efi_variable.h
>>   create mode 100644 lib/efi_loader/efi_variables_file.c
>>   create mode 100644 lib/efi_loader/efi_variables_mem.c
>
> Can you use 'vars' instead of variables as these filenames are too long.

Sure

Regards

Heinrich