From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web12.5316.1630486143697115748 for ; Wed, 01 Sep 2021 01:49:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jzgXnOBU; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id C192160C3E for ; Wed, 1 Sep 2021 08:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630486142; bh=JGtvq2urxZKCzFMsPcqnoa20I1zscZDIW4SRwH/fyPw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jzgXnOBUj5tvNwBUd4EdwYDQ6ZprBg/5Q0cYeL29wfMtawCS4eBQaAA3tdxY8vWaG ZLfJg6CR9I6sLz+mDFolmeRYHlamDgyj9QOXb0j8/jzHTH/rCbby3/j934tDrYGvdB /v+olYKGJGNqN3fpI2GubpSXOKrE0F4+T3RpSkM57Y1MBmQlFVbC2VdAECd4ofmJPg ou9QOf06KPAEZdxeW2noKYOhfsFmdUCWeGqEvkTAmHwk0KxW3ln2cLJvKX/A0ZGvFx wgTEPY0IGYPgwgFbZIMORsdZriXy0k8Ljkp3AxVtAstbyTCbrcsIN0gl9A9YnP7b3I 2Fo3k6owH6uXQ== Received: by mail-ot1-f49.google.com with SMTP id m7-20020a9d4c87000000b0051875f56b95so2567276otf.6 for ; Wed, 01 Sep 2021 01:49:02 -0700 (PDT) X-Gm-Message-State: AOAM530OMyt/AY8hm4rw6zfVHl/hfzddJ5IX4iSras8nhzBFys9YlF6f aNnI53G66gwoftN6WrmQZm4JUJxFBYp/0p0/8vs= X-Google-Smtp-Source: ABdhPJxmCoQ/t3/zDKkwTJ2Mgt50c+qHmfBTJUIcYjWyGC2LKMZAwrkqo89raXzsrhfC/3Avz9mvPvt5RKzMeaMyMho= X-Received: by 2002:a05:6830:719:: with SMTP id y25mr21343348ots.77.1630486142158; Wed, 01 Sep 2021 01:49:02 -0700 (PDT) MIME-Version: 1.0 References: <20210818073811.3571796-1-gjb@semihalf.com> In-Reply-To: From: "Ard Biesheuvel" Date: Wed, 1 Sep 2021 10:48:50 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-platforms PATCH] Platform/RaspberryPi: Check for Boot Discovery Policy change. To: Grzegorz Bernacki Cc: edk2-devel-groups-io , Leif Lindholm , Ard Biesheuvel , Samer El-Haj-Mahmoud , Sunny Wang , Marcin Wojtas , upstream@semihalf.com, Pete Batard Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 1 Sept 2021 at 10:45, Grzegorz Bernacki 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 napisa=C5=82(a)= : > > > > On Wed, 18 Aug 2021 at 09:38, Grzegorz Bernacki wrot= e: > > > > > > This patch adds checks if Boot Discovery Policy has been > > > changed. Only in that case EfiBootManagerRefreshAllBootOption() > > > should be called. > > > > > > Signed-off-by: Grzegorz Bernacki > > > > 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 | 2= 4 +++++++++++++++++++- > > > 1 file changed, 23 insertions(+), 1 deletion(-) > > > > > > diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/Plat= formBm.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 =3D sizeof (DiscoveryPolicyOld); > > > + Status =3D gRT->GetVariable ( > > > + BOOT_DISCOVERY_POLICY_OLD_VAR, > > > + &gBootDiscoveryPolicyMgrFormsetGuid, > > > + NULL, > > > + &Size, > > > + &DiscoveryPolicyOld > > > + ); > > > + if ((Status =3D=3D EFI_NOT_FOUND) || (DiscoveryPolicyOld !=3D Disc= overyPolicy)) { > > > + EfiBootManagerRefreshAllBootOption(); > > > + > > > + Status =3D gRT->SetVariable ( > > > + BOOT_DISCOVERY_POLICY_OLD_VAR, > > > + &gBootDiscoveryPolicyMgrFormsetGuid, > > > + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSER= VICE_ACCESS, > > > + sizeof (DiscoveryPolicyOld), > > > + &DiscoveryPolicy > > > + ); > > > + } > > > > > > return EFI_SUCCESS; > > > } > > > -- > > > 2.25.1 > > >