mbox series

[0/4] efi_loader: non-volatile variables support

Message ID 20181128060059.5508-1-takahiro.akashi@linaro.org
Headers show
Series efi_loader: non-volatile variables support | expand

Message

AKASHI Takahiro Nov. 28, 2018, 6 a.m. UTC
As the subject suggested, this patch set allows any efi variable to be
volatile or non-volatile as UEFI specification describes.

With my efishell patch[1] with patch #2, you can try as follows:
  => efi setvar PlatformLang en
  => efi setvar -nv BootNext =H0200
  => env save

BootNext will be preserved across reboot, while PlatformLang not.

Please note that, currently, setvar command does not automatically
append NON_VOLATILE attribute, while UEFI specification expects that
PlatformLang be non-volatile, you'd better also specify -nv for
this variable here.

Patch #2/#3 depend on my efishell patch[1].
Patch #4 depends on my BootNext patch[2].

Patch[1] and [2] have not been merged yet, so patch#1 can be applied 
on its own.

[1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html
[2] https://lists.denx.de/pipermail/u-boot/2018-November/349281.html

AKASHI Takahiro (4):
  efi_loader: support non-volatile variable behavior
  cmd: efishell: support -nv option to setvar sub-command
  cmd: efishell: make Boot####/BootOrder variable non-volatile
  efi_loader: bootmgr: make BootNext non-volatile

 cmd/efishell.c                | 20 ++++++++---
 env/env.c                     |  4 +++
 include/efi_loader.h          |  1 +
 lib/efi_loader/efi_bootmgr.c  |  3 +-
 lib/efi_loader/efi_variable.c | 64 +++++++++++++++++++++++++++++++++--
 5 files changed, 84 insertions(+), 8 deletions(-)

Comments

Sumit Garg Dec. 5, 2018, 6:23 a.m. UTC | #1
Hi Akashi,

On Wed, 28 Nov 2018 at 11:28, AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>
> As the subject suggested, this patch set allows any efi variable to be
> volatile or non-volatile as UEFI specification describes.
>
> With my efishell patch[1] with patch #2, you can try as follows:
>   => efi setvar PlatformLang en
>   => efi setvar -nv BootNext =H0200
>   => env save
>

How do you expect usage of "EFI_VARIABLE_NON_VOLATILE" attribute to
work during boot-time services as we don't have "env save" command
option as a boot-time service?

Take example scenario with EDK2 shell launched from u-boot and tries
to set non-volatile efi variable.

IMHO, support should be added to "efi_set_variable" to save variable
with "EFI_VARIABLE_NON_VOLATILE" attribute to non volatile storage.

-Sumit

> BootNext will be preserved across reboot, while PlatformLang not.
>
> Please note that, currently, setvar command does not automatically
> append NON_VOLATILE attribute, while UEFI specification expects that
> PlatformLang be non-volatile, you'd better also specify -nv for
> this variable here.
>
> Patch #2/#3 depend on my efishell patch[1].
> Patch #4 depends on my BootNext patch[2].
>
> Patch[1] and [2] have not been merged yet, so patch#1 can be applied
> on its own.
>
> [1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html
> [2] https://lists.denx.de/pipermail/u-boot/2018-November/349281.html
>
> AKASHI Takahiro (4):
>   efi_loader: support non-volatile variable behavior
>   cmd: efishell: support -nv option to setvar sub-command
>   cmd: efishell: make Boot####/BootOrder variable non-volatile
>   efi_loader: bootmgr: make BootNext non-volatile
>
>  cmd/efishell.c                | 20 ++++++++---
>  env/env.c                     |  4 +++
>  include/efi_loader.h          |  1 +
>  lib/efi_loader/efi_bootmgr.c  |  3 +-
>  lib/efi_loader/efi_variable.c | 64 +++++++++++++++++++++++++++++++++--
>  5 files changed, 84 insertions(+), 8 deletions(-)
>
> --
> 2.19.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
AKASHI Takahiro Dec. 7, 2018, 2:29 a.m. UTC | #2
# My patch is more or less a RFC to raise attention.

On Wed, Dec 05, 2018 at 11:53:42AM +0530, Sumit Garg wrote:
> Hi Akashi,
> 
> On Wed, 28 Nov 2018 at 11:28, AKASHI Takahiro
> <takahiro.akashi@linaro.org> wrote:
> >
> > As the subject suggested, this patch set allows any efi variable to be
> > volatile or non-volatile as UEFI specification describes.
> >
> > With my efishell patch[1] with patch #2, you can try as follows:
> >   => efi setvar PlatformLang en
> >   => efi setvar -nv BootNext =H0200
> >   => env save
> >
> 
> How do you expect usage of "EFI_VARIABLE_NON_VOLATILE" attribute to
> work during boot-time services as we don't have "env save" command
> option as a boot-time service?
> 
> Take example scenario with EDK2 shell launched from u-boot and tries
> to set non-volatile efi variable.

I know the issue, but

> IMHO, support should be added to "efi_set_variable" to save variable
> with "EFI_VARIABLE_NON_VOLATILE" attribute to non volatile storage.

I also hesitate to implement such a behavior to efi_set_variable
as it ends up writing to flash every time. Please note that data on
storage is a sorted list in plain text and so updating it can be painful.

-Takahiro Akashi


> -Sumit
> 
> > BootNext will be preserved across reboot, while PlatformLang not.
> >
> > Please note that, currently, setvar command does not automatically
> > append NON_VOLATILE attribute, while UEFI specification expects that
> > PlatformLang be non-volatile, you'd better also specify -nv for
> > this variable here.
> >
> > Patch #2/#3 depend on my efishell patch[1].
> > Patch #4 depends on my BootNext patch[2].
> >
> > Patch[1] and [2] have not been merged yet, so patch#1 can be applied
> > on its own.
> >
> > [1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html
> > [2] https://lists.denx.de/pipermail/u-boot/2018-November/349281.html
> >
> > AKASHI Takahiro (4):
> >   efi_loader: support non-volatile variable behavior
> >   cmd: efishell: support -nv option to setvar sub-command
> >   cmd: efishell: make Boot####/BootOrder variable non-volatile
> >   efi_loader: bootmgr: make BootNext non-volatile
> >
> >  cmd/efishell.c                | 20 ++++++++---
> >  env/env.c                     |  4 +++
> >  include/efi_loader.h          |  1 +
> >  lib/efi_loader/efi_bootmgr.c  |  3 +-
> >  lib/efi_loader/efi_variable.c | 64 +++++++++++++++++++++++++++++++++--
> >  5 files changed, 84 insertions(+), 8 deletions(-)
> >
> > --
> > 2.19.1
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
Sumit Garg Dec. 7, 2018, 12:40 p.m. UTC | #3
On Fri, 7 Dec 2018 at 07:56, Takahiro Akashi <takahiro.akashi@linaro.org> wrote:
>
> # My patch is more or less a RFC to raise attention.
>
> On Wed, Dec 05, 2018 at 11:53:42AM +0530, Sumit Garg wrote:
> > Hi Akashi,
> >
> > On Wed, 28 Nov 2018 at 11:28, AKASHI Takahiro
> > <takahiro.akashi@linaro.org> wrote:
> > >
> > > As the subject suggested, this patch set allows any efi variable to be
> > > volatile or non-volatile as UEFI specification describes.
> > >
> > > With my efishell patch[1] with patch #2, you can try as follows:
> > >   => efi setvar PlatformLang en
> > >   => efi setvar -nv BootNext =H0200
> > >   => env save
> > >
> >
> > How do you expect usage of "EFI_VARIABLE_NON_VOLATILE" attribute to
> > work during boot-time services as we don't have "env save" command
> > option as a boot-time service?
> >
> > Take example scenario with EDK2 shell launched from u-boot and tries
> > to set non-volatile efi variable.
>
> I know the issue, but
>
> > IMHO, support should be added to "efi_set_variable" to save variable
> > with "EFI_VARIABLE_NON_VOLATILE" attribute to non volatile storage.
>
> I also hesitate to implement such a behavior to efi_set_variable
> as it ends up writing to flash every time. Please note that data on
> storage is a sorted list in plain text and so updating it can be painful.
>

AFAIK, flash should be updated every time in case efi_set_variable is
called with non-volatile attribute. Do you foresee any issues with
call to "env_save" during this call? I think it would be similar to
what you are doing currently from prompt with your
purge_volatile_variables() api in place.

-Sumit

> -Takahiro Akashi
>
>
> > -Sumit
> >
> > > BootNext will be preserved across reboot, while PlatformLang not.
> > >
> > > Please note that, currently, setvar command does not automatically
> > > append NON_VOLATILE attribute, while UEFI specification expects that
> > > PlatformLang be non-volatile, you'd better also specify -nv for
> > > this variable here.
> > >
> > > Patch #2/#3 depend on my efishell patch[1].
> > > Patch #4 depends on my BootNext patch[2].
> > >
> > > Patch[1] and [2] have not been merged yet, so patch#1 can be applied
> > > on its own.
> > >
> > > [1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html
> > > [2] https://lists.denx.de/pipermail/u-boot/2018-November/349281.html
> > >
> > > AKASHI Takahiro (4):
> > >   efi_loader: support non-volatile variable behavior
> > >   cmd: efishell: support -nv option to setvar sub-command
> > >   cmd: efishell: make Boot####/BootOrder variable non-volatile
> > >   efi_loader: bootmgr: make BootNext non-volatile
> > >
> > >  cmd/efishell.c                | 20 ++++++++---
> > >  env/env.c                     |  4 +++
> > >  include/efi_loader.h          |  1 +
> > >  lib/efi_loader/efi_bootmgr.c  |  3 +-
> > >  lib/efi_loader/efi_variable.c | 64 +++++++++++++++++++++++++++++++++--
> > >  5 files changed, 84 insertions(+), 8 deletions(-)
> > >
> > > --
> > > 2.19.1
> > >
> > > _______________________________________________
> > > U-Boot mailing list
> > > U-Boot@lists.denx.de
> > > https://lists.denx.de/listinfo/u-boot