* [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
@ 2021-08-18 7:38 Grzegorz Bernacki
2021-08-18 19:42 ` Samer El-Haj-Mahmoud
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Grzegorz Bernacki @ 2021-08-18 7:38 UTC (permalink / raw)
To: devel
Cc: leif, ardb+tianocore, Samer.El-Haj-Mahmoud, sunny.Wang, mw,
upstream, pete, Grzegorz Bernacki
This patch adds checks if Boot Discovery Policy has been
changed. Only in that case EfiBootManagerRefreshAllBootOption()
should be called.
Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
---
Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 24 +++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index c8305ce4f5..378ba0ebf4 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -617,6 +617,7 @@ BootDiscoveryPolicyHandler (
{
EFI_STATUS Status;
UINT32 DiscoveryPolicy;
+ UINT32 DiscoveryPolicyOld;
UINTN Size;
EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
EFI_GUID *Class;
@@ -678,7 +679,28 @@ BootDiscoveryPolicyHandler (
return Status;
}
- EfiBootManagerRefreshAllBootOption();
+ //
+ // Refresh Boot Options if Boot Discovery Policy has been changed
+ //
+ Size = sizeof (DiscoveryPolicyOld);
+ Status = gRT->GetVariable (
+ BOOT_DISCOVERY_POLICY_OLD_VAR,
+ &gBootDiscoveryPolicyMgrFormsetGuid,
+ NULL,
+ &Size,
+ &DiscoveryPolicyOld
+ );
+ if ((Status == EFI_NOT_FOUND) || (DiscoveryPolicyOld != DiscoveryPolicy)) {
+ EfiBootManagerRefreshAllBootOption();
+
+ Status = gRT->SetVariable (
+ BOOT_DISCOVERY_POLICY_OLD_VAR,
+ &gBootDiscoveryPolicyMgrFormsetGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (DiscoveryPolicyOld),
+ &DiscoveryPolicy
+ );
+ }
return EFI_SUCCESS;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
2021-08-18 7:38 [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change Grzegorz Bernacki
@ 2021-08-18 19:42 ` Samer El-Haj-Mahmoud
2021-08-22 21:23 ` [edk2-devel] " Mario Bălănică
2021-08-31 12:11 ` Ard Biesheuvel
2 siblings, 0 replies; 6+ messages in thread
From: Samer El-Haj-Mahmoud @ 2021-08-18 19:42 UTC (permalink / raw)
To: Grzegorz Bernacki, devel@edk2.groups.io
Cc: leif@nuviainc.com, ardb+tianocore@kernel.org, Sunny Wang,
mw@semihalf.com, upstream@semihalf.com, pete@akeo.ie,
Samer El-Haj-Mahmoud
Thanks for the patch!
Reviewed-By: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
> -----Original Message-----
> From: Grzegorz Bernacki <gjb@semihalf.com>
> Sent: Wednesday, August 18, 2021 3:38 AM
> To: devel@edk2.groups.io
> Cc: leif@nuviainc.com; ardb+tianocore@kernel.org; Samer El-Haj-Mahmoud
> <Samer.El-Haj-Mahmoud@arm.com>; Sunny Wang
> <Sunny.Wang@arm.com>; mw@semihalf.com; upstream@semihalf.com;
> pete@akeo.ie; Grzegorz Bernacki <gjb@semihalf.com>
> Subject: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot
> Discovery Policy change.
>
> This patch adds checks if Boot Discovery Policy has been
> changed. Only in that case EfiBootManagerRefreshAllBootOption()
> should be called.
>
> Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
> ---
> Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 24
> +++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git
> a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> index c8305ce4f5..378ba0ebf4 100644
> --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -617,6 +617,7 @@ BootDiscoveryPolicyHandler (
> {
> EFI_STATUS Status;
> UINT32 DiscoveryPolicy;
> + UINT32 DiscoveryPolicyOld;
> UINTN Size;
> EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
> EFI_GUID *Class;
> @@ -678,7 +679,28 @@ BootDiscoveryPolicyHandler (
> return Status;
> }
>
> - EfiBootManagerRefreshAllBootOption();
> + //
> + // Refresh Boot Options if Boot Discovery Policy has been changed
> + //
> + Size = sizeof (DiscoveryPolicyOld);
> + Status = gRT->GetVariable (
> + BOOT_DISCOVERY_POLICY_OLD_VAR,
> + &gBootDiscoveryPolicyMgrFormsetGuid,
> + NULL,
> + &Size,
> + &DiscoveryPolicyOld
> + );
> + if ((Status == EFI_NOT_FOUND) || (DiscoveryPolicyOld != DiscoveryPolicy))
> {
> + EfiBootManagerRefreshAllBootOption();
> +
> + Status = gRT->SetVariable (
> + BOOT_DISCOVERY_POLICY_OLD_VAR,
> + &gBootDiscoveryPolicyMgrFormsetGuid,
> + EFI_VARIABLE_NON_VOLATILE |
> EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (DiscoveryPolicyOld),
> + &DiscoveryPolicy
> + );
> + }
>
> return EFI_SUCCESS;
> }
> --
> 2.25.1
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-devel] [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
2021-08-18 7:38 [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change Grzegorz Bernacki
2021-08-18 19:42 ` Samer El-Haj-Mahmoud
@ 2021-08-22 21:23 ` Mario Bălănică
2021-08-31 12:11 ` Ard Biesheuvel
2 siblings, 0 replies; 6+ messages in thread
From: Mario Bălănică @ 2021-08-22 21:23 UTC (permalink / raw)
To: Grzegorz Bernacki, devel
[-- Attachment #1: Type: text/plain, Size: 58 bytes --]
Tested-by: Mario Bălănică <mariobalanica02@gmail.com>
[-- Attachment #2: Type: text/html, Size: 64 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
2021-08-18 7:38 [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change Grzegorz Bernacki
2021-08-18 19:42 ` Samer El-Haj-Mahmoud
2021-08-22 21:23 ` [edk2-devel] " Mario Bălănică
@ 2021-08-31 12:11 ` Ard Biesheuvel
2021-09-01 8:45 ` Grzegorz Bernacki
2 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2021-08-31 12:11 UTC (permalink / raw)
To: Grzegorz Bernacki
Cc: devel, leif, ardb+tianocore, Samer.El-Haj-Mahmoud, sunny.Wang, mw,
upstream, pete
On Wed, 18 Aug 2021 at 09:38, Grzegorz Bernacki <gjb@semihalf.com> wrote:
>
> This patch adds checks if Boot Discovery Policy has been
> changed. Only in that case EfiBootManagerRefreshAllBootOption()
> should be called.
>
> Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
To be honest, I'm not a fan of this bodge. Can you explain why we need
two separate EFI variables to keep track of this state?
> ---
> Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 24 +++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> index c8305ce4f5..378ba0ebf4 100644
> --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -617,6 +617,7 @@ BootDiscoveryPolicyHandler (
> {
> EFI_STATUS Status;
> UINT32 DiscoveryPolicy;
> + UINT32 DiscoveryPolicyOld;
> UINTN Size;
> EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
> EFI_GUID *Class;
> @@ -678,7 +679,28 @@ BootDiscoveryPolicyHandler (
> return Status;
> }
>
> - EfiBootManagerRefreshAllBootOption();
> + //
> + // Refresh Boot Options if Boot Discovery Policy has been changed
> + //
> + Size = sizeof (DiscoveryPolicyOld);
> + Status = gRT->GetVariable (
> + BOOT_DISCOVERY_POLICY_OLD_VAR,
> + &gBootDiscoveryPolicyMgrFormsetGuid,
> + NULL,
> + &Size,
> + &DiscoveryPolicyOld
> + );
> + if ((Status == EFI_NOT_FOUND) || (DiscoveryPolicyOld != DiscoveryPolicy)) {
> + EfiBootManagerRefreshAllBootOption();
> +
> + Status = gRT->SetVariable (
> + BOOT_DISCOVERY_POLICY_OLD_VAR,
> + &gBootDiscoveryPolicyMgrFormsetGuid,
> + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> + sizeof (DiscoveryPolicyOld),
> + &DiscoveryPolicy
> + );
> + }
>
> return EFI_SUCCESS;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
2021-08-31 12:11 ` Ard Biesheuvel
@ 2021-09-01 8:45 ` Grzegorz Bernacki
2021-09-01 8:48 ` Ard Biesheuvel
0 siblings, 1 reply; 6+ messages in thread
From: Grzegorz Bernacki @ 2021-09-01 8:45 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel-groups-io, Leif Lindholm, Ard Biesheuvel,
Samer El-Haj-Mahmoud, Sunny Wang, Marcin Wojtas, upstream,
Pete Batard
Hi Ard,
The problem is that for some reason EfiBootManagerRefreshAllBootOption
() overwrites BootOrder. For example, if USB bootable device is
removed from the top and added at the bottom of the list.
I will debug the problem further, however this patch is needed to
retain correct boot order unless I find the root cause of the problem.
thanks,
greg
wt., 31 sie 2021 o 14:11 Ard Biesheuvel <ardb@kernel.org> napisał(a):
>
> On Wed, 18 Aug 2021 at 09:38, Grzegorz Bernacki <gjb@semihalf.com> wrote:
> >
> > This patch adds checks if Boot Discovery Policy has been
> > changed. Only in that case EfiBootManagerRefreshAllBootOption()
> > should be called.
> >
> > Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
>
> To be honest, I'm not a fan of this bodge. Can you explain why we need
> two separate EFI variables to keep track of this state?
>
>
> > ---
> > Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 24 +++++++++++++++++++-
> > 1 file changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > index c8305ce4f5..378ba0ebf4 100644
> > --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > @@ -617,6 +617,7 @@ BootDiscoveryPolicyHandler (
> > {
> > EFI_STATUS Status;
> > UINT32 DiscoveryPolicy;
> > + UINT32 DiscoveryPolicyOld;
> > UINTN Size;
> > EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
> > EFI_GUID *Class;
> > @@ -678,7 +679,28 @@ BootDiscoveryPolicyHandler (
> > return Status;
> > }
> >
> > - EfiBootManagerRefreshAllBootOption();
> > + //
> > + // Refresh Boot Options if Boot Discovery Policy has been changed
> > + //
> > + Size = sizeof (DiscoveryPolicyOld);
> > + Status = gRT->GetVariable (
> > + BOOT_DISCOVERY_POLICY_OLD_VAR,
> > + &gBootDiscoveryPolicyMgrFormsetGuid,
> > + NULL,
> > + &Size,
> > + &DiscoveryPolicyOld
> > + );
> > + if ((Status == EFI_NOT_FOUND) || (DiscoveryPolicyOld != DiscoveryPolicy)) {
> > + EfiBootManagerRefreshAllBootOption();
> > +
> > + Status = gRT->SetVariable (
> > + BOOT_DISCOVERY_POLICY_OLD_VAR,
> > + &gBootDiscoveryPolicyMgrFormsetGuid,
> > + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > + sizeof (DiscoveryPolicyOld),
> > + &DiscoveryPolicy
> > + );
> > + }
> >
> > return EFI_SUCCESS;
> > }
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change.
2021-09-01 8:45 ` Grzegorz Bernacki
@ 2021-09-01 8:48 ` Ard Biesheuvel
0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2021-09-01 8:48 UTC (permalink / raw)
To: Grzegorz Bernacki
Cc: edk2-devel-groups-io, Leif Lindholm, Ard Biesheuvel,
Samer El-Haj-Mahmoud, Sunny Wang, Marcin Wojtas, upstream,
Pete Batard
On Wed, 1 Sept 2021 at 10:45, Grzegorz Bernacki <gjb@semihalf.com> wrote:
>
> Hi Ard,
>
> The problem is that for some reason EfiBootManagerRefreshAllBootOption
> () overwrites BootOrder. For example, if USB bootable device is
> removed from the top and added at the bottom of the list.
> I will debug the problem further, however this patch is needed to
> retain correct boot order unless I find the root cause of the problem.
Thanks for the explanation.
I would prefer to find the root cause first. Pasting this workaround
all over the place is really not the right way to deal with this.
>
> wt., 31 sie 2021 o 14:11 Ard Biesheuvel <ardb@kernel.org> napisał(a):
> >
> > On Wed, 18 Aug 2021 at 09:38, Grzegorz Bernacki <gjb@semihalf.com> wrote:
> > >
> > > This patch adds checks if Boot Discovery Policy has been
> > > changed. Only in that case EfiBootManagerRefreshAllBootOption()
> > > should be called.
> > >
> > > Signed-off-by: Grzegorz Bernacki <gjb@semihalf.com>
> >
> > To be honest, I'm not a fan of this bodge. Can you explain why we need
> > two separate EFI variables to keep track of this state?
> >
> >
> > > ---
> > > Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c | 24 +++++++++++++++++++-
> > > 1 file changed, 23 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > > index c8305ce4f5..378ba0ebf4 100644
> > > --- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > > +++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
> > > @@ -617,6 +617,7 @@ BootDiscoveryPolicyHandler (
> > > {
> > > EFI_STATUS Status;
> > > UINT32 DiscoveryPolicy;
> > > + UINT32 DiscoveryPolicyOld;
> > > UINTN Size;
> > > EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
> > > EFI_GUID *Class;
> > > @@ -678,7 +679,28 @@ BootDiscoveryPolicyHandler (
> > > return Status;
> > > }
> > >
> > > - EfiBootManagerRefreshAllBootOption();
> > > + //
> > > + // Refresh Boot Options if Boot Discovery Policy has been changed
> > > + //
> > > + Size = sizeof (DiscoveryPolicyOld);
> > > + Status = gRT->GetVariable (
> > > + BOOT_DISCOVERY_POLICY_OLD_VAR,
> > > + &gBootDiscoveryPolicyMgrFormsetGuid,
> > > + NULL,
> > > + &Size,
> > > + &DiscoveryPolicyOld
> > > + );
> > > + if ((Status == EFI_NOT_FOUND) || (DiscoveryPolicyOld != DiscoveryPolicy)) {
> > > + EfiBootManagerRefreshAllBootOption();
> > > +
> > > + Status = gRT->SetVariable (
> > > + BOOT_DISCOVERY_POLICY_OLD_VAR,
> > > + &gBootDiscoveryPolicyMgrFormsetGuid,
> > > + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
> > > + sizeof (DiscoveryPolicyOld),
> > > + &DiscoveryPolicy
> > > + );
> > > + }
> > >
> > > return EFI_SUCCESS;
> > > }
> > > --
> > > 2.25.1
> > >
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-01 8:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-18 7:38 [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change Grzegorz Bernacki
2021-08-18 19:42 ` Samer El-Haj-Mahmoud
2021-08-22 21:23 ` [edk2-devel] " Mario Bălănică
2021-08-31 12:11 ` Ard Biesheuvel
2021-09-01 8:45 ` Grzegorz Bernacki
2021-09-01 8:48 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox