From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by mx.groups.io with SMTP id smtpd.web10.21476.1643239405305210531 for ; Wed, 26 Jan 2022 15:23:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=QjFJFigd; spf=pass (domain: quicinc.com, ip: 199.106.114.39, mailfrom: quic_rcran@quicinc.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643239405; x=1674775405; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KQhAhh72WUHOcxS0RFDZ1VifKDibWV3Vgsd7W3ZcQzI=; b=QjFJFigdnWYp+bGgjfN6ZarZXX1aAX8aefS3NOdqd5s+eBD8fHh/DK26 IW4nHWGtRLR3kpL7SOwMvaA15dp4lemshI63dJerGy/vtX8bBcPlG4AjR U+qddBB9Jzbs6qisKDFcXTxxXZy/5U3T/oSUlUpzlWVft2Aoy/sLJ3hsv 0=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 26 Jan 2022 15:23:24 -0800 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2022 15:23:24 -0800 Received: from [10.110.89.50] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Wed, 26 Jan 2022 15:23:24 -0800 Message-ID: <522e1720-5f37-44c2-8d0a-d4a5e37827e2@quicinc.com> Date: Wed, 26 Jan 2022 16:23:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/UefiBootManagerLib: Convert BmLoadOption to Variable Policy To: CC: Jian J Wang , Liming Gao , Zhichao Gao , Ray Ni References: <16CBC7B9F156E53A.7993@groups.io> From: "Rebecca Cran" In-Reply-To: <16CBC7B9F156E53A.7993@groups.io> Return-Path: quic_rcran@quicinc.com X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) Content-Language: en-US Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit It's been a week since I sent this out: could someone review it please? Thanks. Rebecca Cran On 1/19/22 14:01, Rebecca Cran wrote: > Since the Variable Lock protocol is deprecated, convert locking of > PlatformRecovery#### in EfiBootManagerLoadOptionToVariable to use the > Variable Policy protocol. > > Cc: Jian J Wang > Cc: Liming Gao > Cc: Zhichao Gao > Cc: Ray Ni > > Signed-off-by: Rebecca Cran > --- > MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c | 33 +++++++++++++------- > MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h | 1 - > MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf | 3 +- > 3 files changed, 24 insertions(+), 13 deletions(-) > > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c > index 32a9cbb425fa..2087f0b91df7 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c > @@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #include "InternalBm.h" > > +#include > + > GLOBAL_REMOVE_IF_UNREFERENCED > CHAR16 *mBmLoadOptionName[] = { > L"Driver", > @@ -169,15 +171,15 @@ EfiBootManagerLoadOptionToVariable ( > IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Option > ) > { > - EFI_STATUS Status; > - UINTN VariableSize; > - UINT8 *Variable; > - UINT8 *Ptr; > - CHAR16 OptionName[BM_OPTION_NAME_LEN]; > - CHAR16 *Description; > - CHAR16 NullChar; > - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; > - UINT32 VariableAttributes; > + EFI_STATUS Status; > + UINTN VariableSize; > + UINT8 *Variable; > + UINT8 *Ptr; > + CHAR16 OptionName[BM_OPTION_NAME_LEN]; > + CHAR16 *Description; > + CHAR16 NullChar; > + EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy; > + UINT32 VariableAttributes; > > if ((Option->OptionNumber == LoadOptionNumberUnassigned) || > (Option->FilePath == NULL) || > @@ -242,9 +244,18 @@ structure. > // > // Lock the PlatformRecovery#### > // > - Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock); > + Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID **)&VariablePolicy); > if (!EFI_ERROR (Status)) { > - Status = VariableLock->RequestToLock (VariableLock, OptionName, &gEfiGlobalVariableGuid); > + Status = RegisterBasicVariablePolicy ( > + VariablePolicy, > + &gEfiGlobalVariableGuid, > + OptionName, > + VARIABLE_POLICY_NO_MIN_SIZE, > + VARIABLE_POLICY_NO_MAX_SIZE, > + VARIABLE_POLICY_NO_MUST_ATTR, > + VARIABLE_POLICY_NO_CANT_ATTR, > + VARIABLE_POLICY_TYPE_LOCK_NOW > + ); > ASSERT_EFI_ERROR (Status); > } > > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > index a9b0d485cace..b7dfe2a7e0bd 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h > @@ -39,7 +39,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > #include > #include > #include > -#include > #include > #include > #include > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf > index cf5908692fa7..fe05d5f1cc9d 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf > +++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf > @@ -62,6 +62,7 @@ > PerformanceLib > HiiLib > SortLib > + VariablePolicyHelperLib > > [Guids] > ## SOMETIMES_CONSUMES ## SystemTable (The identifier of memory type information type in system table) > @@ -99,7 +100,7 @@ > gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES > gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES > gEfiSimpleTextInputExProtocolGuid ## SOMETIMES_CONSUMES > - gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES > + gEdkiiVariablePolicyProtocolGuid ## SOMETIMES_CONSUMES > gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES > gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES > gEfiNvmExpressPassThruProtocolGuid ## SOMETIMES_CONSUMES