From nobody Fri May 17 11:28:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86723+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86723+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1645078880; cv=none; d=zohomail.com; s=zohoarc; b=C3e+tTE5JdXiWQHzZKFAlG0lQ1Sm1f2aBXAONWalkRXYAvDHJjB3pfYAOfw80IRaLHtvr1AK1l+xgXMuYLI6taWtLgevzCP7lA2zNWpZAgFm7UevzlVtbnrU6zQ/Mgsi5Ny9MR5GleVkiuRHJq5U8H6NCzzrcqKIpUCmU9lrymI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645078880; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=U6jCpK5zWeIm1x1tBydVijFQhaVGx4W7gYtvWcsBrxQ=; b=dS90qiLL5nf9O52mcuhJ3LYAEhVWsbLZVnLJ3wBlHsnpuoliozXxkRU3xQPzjH0+nuZOUaXe8wYhuagF/EFt+xNiecJcScVCScRYKS7wFt3Pz5gO1IGk/nkMtg3V4F1RVhYkSEZE9PWnciHIB2n+eac15xjvboAlvyAt9ZuL71I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86723+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16450788803311013.5353908584242; Wed, 16 Feb 2022 22:21:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZW3FYY1788612xmdgNZ6MXPt; Wed, 16 Feb 2022 22:21:19 -0800 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.4472.1645078877722717930 for ; Wed, 16 Feb 2022 22:21:18 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="311548082" X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="311548082" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 22:21:16 -0800 X-IronPort-AV: E=Sophos;i="5.88,375,1635231600"; d="scan'208";a="529977252" X-Received: from cchiu4-mobl.gar.corp.intel.com ([10.252.189.176]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 22:21:15 -0800 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: "Chiu, Chasel" , Nate DeSimone , Liming Gao , Eric Dong , Isaac Oram Subject: [edk2-devel] [edk2-platforms: PATCH v4] MinPlatformPkg/SaveMemoryConfig: Variable may not be locked. Date: Thu, 17 Feb 2022 14:21:08 +0800 Message-Id: <20220217062108.1857-1-chasel.chiu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,chasel.chiu@intel.com X-Gm-Message-State: MlazfuuUmpu1mL7tEiKerijrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1645078879; bh=0tESiwIXOVGUW8ZYx09bQcdmNQO6/fqr1RAHbv1rg5U=; h=Cc:Date:From:Reply-To:Subject:To; b=B3bRTRj75uVm1w/7+Z8nVsp4g6kPPvct/6M0L+Hv5t3kTEz4DjXKSh8CYbS1fV4UO1b k5HkSfjArPuZGpC+V9tUOfohath+deg98CIQknheMTjhQzktNb4Fl51kyxD2dwpJsO33Z FWq8YXdvCWQ6JRZovgtmYtWtW6KUzf9S6Xs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1645078881896100001 Content-Type: text/plain; charset="utf-8" From: "Chiu, Chasel" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3829 Fixed the bug that existing variable will not be locked when it is identical with hob data by creating LockLargeVariable function, also switched to VariablePolicyProtocol for locking variables. Failing to lock variable could be security vulnerability, so the LargeVariableWriteLib functions will return EFI_ABORTED if locking was failed and SaveMemoryConfig driver will delete variable to prevent from using unlocked variable. This patch also modified SaveMemoryConfig driver to be unloaded after execution because it does not produce any service protocol. To achieve this goal the DxeRuntimeVariableWriteLib should close registered ExitBootService events in its DESTRUCTOR. Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Chasel Chiu Reviewed-by: Isaac Oram Reviewed-by: Nate DeSimone ---Patch V4: 1.Removed CpuDeadLoop and delete variable if Lock failed in Sa= veMemoryConfig. 2. LargeVariableWrite will not delete variable if Lock fail= ed, let caller to do it. Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .c | 37 ++++++++++++++++++++++++++++++++++--- Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWr= iteLib.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++---- Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntim= eVariableWriteLib.c | 61 +++++++++++++++++++++++++++++++++++++++++++++--= -------------- Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .inf | 3 ++- Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h = | 26 ++++++++++++++++++++++++-- Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntim= eVariableWriteLib.inf | 8 +++++--- 6 files changed, 248 insertions(+), 29 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/= SaveMemoryConfig.c index 820585f676..fb51edd5cb 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.c @@ -2,13 +2,14 @@ This is the driver that locates the MemoryConfigurationData HOB, if it exists, and saves the data to nvRAM. =20 -Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include #include +#include #include #include #include @@ -18,6 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include =20 /** @@ -86,6 +88,23 @@ SaveMemoryConfigEntryPoint ( Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa= riableGuid, &BufferSize, VariableData); if (!EFI_ERROR (Status) && (BufferSize =3D=3D DataSize) && (0 = =3D=3D CompareMem (HobData, VariableData, DataSize))) { DataIsIdentical =3D TRUE; + // + // No need to update Variable, only lock it. + // + Status =3D LockLargeVariable (L"FspNvsBuffer", &gFspNvsBuff= erVariableGuid); + if (EFI_ERROR (Status)) { + // + // Fail to lock variable is security vulnerability and sho= uld not happen. + // + ASSERT_EFI_ERROR (Status); + // + // When building without ASSERT_EFI_ERROR hang, delete the= varialbe so it will not be consumed. + // + DEBUG ((DEBUG_ERROR, "Delete variable!\n")); + DataSize =3D 0; + Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBuff= erVariableGuid, FALSE, DataSize, HobData); + ASSERT_EFI_ERROR (Status); + } } FreePool (VariableData); } @@ -95,6 +114,18 @@ SaveMemoryConfigEntryPoint ( =20 if (!DataIsIdentical) { Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab= leGuid, TRUE, DataSize, HobData); + if (Status =3D=3D EFI_ABORTED) { + // + // Fail to lock variable! This should not happen. + // + ASSERT_EFI_ERROR (Status); + // + // When building without ASSERT_EFI_ERROR hang, delete the varia= lbe so it will not be consumed. + // + DEBUG ((DEBUG_ERROR, "Delete variable!\n")); + DataSize =3D 0; + Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVari= ableGuid, FALSE, DataSize, HobData); + } ASSERT_EFI_ERROR (Status); DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n= ", DataSize)); } else { @@ -106,7 +137,7 @@ SaveMemoryConfigEntryPoint ( } =20 // - // This driver cannot be unloaded because DxeRuntimeVariableWriteLib con= structor will register ExitBootServices callback. + // This driver does not produce any protocol services, so always unload = it. // - return EFI_SUCCESS; + return EFI_REQUEST_UNLOAD_IMAGE; } diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/Lar= geVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVaria= bleLib/LargeVariableWriteLib.c index e4b97ef1df..cb8e2e7f0a 100644 --- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c @@ -10,7 +10,7 @@ integer number will be added to the end of the variable name. This number will be incremented for each variable as needed to store the entire data= set. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -245,7 +245,7 @@ Done: @retval EFI_DEVICE_ERROR The variable could not be retrieved due t= o a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be delete= d. - + @retval EFI_ABORTED LockVariable was requested but failed. @retval EFI_NOT_FOUND The variable trying to be updated or dele= ted was not found. =20 **/ @@ -323,6 +323,13 @@ SetLargeVariable ( } if (LockVariable) { Status =3D VarLibVariableRequestToLock (VariableName, VendorGuid); + if (EFI_ERROR (Status)) { + // + // Do not delete Variable when failed to lock. Caller is responsib= le to do this. + // + DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error locking variable: St= atus =3D %r\n", Status)); + Status =3D EFI_ABORTED; + } } } else { // @@ -402,7 +409,7 @@ SetLargeVariable ( DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error writting variable: S= tatus =3D %r\n", Status)); goto Done; } - VariablesSaved =3D Index; + VariablesSaved ++; BytesRemaining -=3D SizeToSave; OffsetPtr +=3D SizeToSave; } // End of for loop @@ -420,6 +427,10 @@ SetLargeVariable ( Status =3D VarLibVariableRequestToLock (TempVariableName, VendorGu= id); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error locking variable: = Status =3D %r\n", Status)); + // + // Do not delete Variable when failed to lock. Caller is respons= ible to do this. + // + Status =3D EFI_ABORTED; VariablesSaved =3D 0; goto Done; } @@ -442,9 +453,132 @@ Done: 0, NULL ); - DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error deleting variable: Statu= s =3D %r\n", Status2)); + if (EFI_ERROR (Status2)) { + DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error deleting variable: S= tatus =3D %r\n", Status2)); + } } } DEBUG ((DEBUG_ERROR, "SetLargeVariable: Status =3D %r\n", Status)); return Status; } + +/** + Locks the existing large variable. + + @param[in] VariableName A Null-terminated string that is the name= of the vendor's variable. + Each VariableName is unique for each Vend= orGuid. VariableName must + contain 1 or more characters. If Variable= Name is an empty string, + then EFI_INVALID_PARAMETER is returned. + @param[in] VendorGuid A unique identifier for the vendor. + @retval EFI_SUCCESS The firmware has successfully locked the = variable. + @retval EFI_INVALID_PARAMETER An invalid combination of variable name a= nd GUID was supplied + @retval EFI_OUT_OF_RESOURCES The VariableName is longer than 1018 char= acters + @retval EFI_UNSUPPORTED The service for locking variable is not r= eady. + @retval EFI_NOT_FOUND The targeting variable for locking is not= present. + @retval EFI_ABORTED Fail to lock variable. +**/ +EFI_STATUS +EFIAPI +LockLargeVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid + ) +{ + CHAR16 TempVariableName[MAX_VARIABLE_NAME_SIZE]; + UINT64 VariableSize; + EFI_STATUS Status; + UINTN Index; + + // + // Check input parameters. + // + if (VariableName =3D=3D NULL || VariableName[0] =3D=3D 0 || VendorGuid = =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Check the length of the variable name is short enough to allow an int= eger + // to be appended. + // + if (StrLen (VariableName) >=3D (MAX_VARIABLE_NAME_SIZE - MAX_VARIABLE_SP= LIT_DIGITS)) { + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Variable name too long\n")); + return EFI_OUT_OF_RESOURCES; + } + + if (!VarLibIsVariableRequestToLockSupported ()) { + return EFI_UNSUPPORTED; + } + + // + // Check if it is single variable scenario. + // + VariableSize =3D 0; + Status =3D VarLibGetVariable (VariableName, VendorGuid, NULL, &VariableS= ize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // Lock single variable. + // + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", VariableName, VendorG= uid)); + Status =3D VarLibVariableRequestToLock (VariableName, VendorGuid); + if (EFI_ERROR (Status)) { + // + // Do not delete Variable when failed to lock. Caller is responsible= to do this. + // + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\n", St= atus)); + return EFI_ABORTED; + } + return EFI_SUCCESS; + } else { + // + // Check if it is multiple variables scenario. + // + Index =3D 0; + ZeroMem (TempVariableName, MAX_VARIABLE_NAME_SIZE); + UnicodeSPrint (TempVariableName, MAX_VARIABLE_NAME_SIZE, L"%s%d", Vari= ableName, Index); + VariableSize =3D 0; + Status =3D VarLibGetVariable (TempVariableName, VendorGuid, NULL, &Var= iableSize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // Lock first variable and continue to rest of the variables. + // + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", TempVariableName, V= endorGuid)); + Status =3D VarLibVariableRequestToLock (TempVariableName, VendorGuid= ); + if (EFI_ERROR (Status)) { + // + // Do not delete Variable when failed to lock. Caller is responsib= le to do this. + // + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\n", = Status)); + return EFI_ABORTED; + } + for (Index =3D 1; Index < MAX_VARIABLE_SPLIT; Index++) { + ZeroMem (TempVariableName, MAX_VARIABLE_NAME_SIZE); + UnicodeSPrint (TempVariableName, MAX_VARIABLE_NAME_SIZE, L"%s%d", = VariableName, Index); + + VariableSize =3D 0; + Status =3D VarLibGetVariable (TempVariableName, VendorGuid, NULL, = &VariableSize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", TempVariableNam= e, VendorGuid)); + Status =3D VarLibVariableRequestToLock (TempVariableName, Vendor= Guid); + if (EFI_ERROR (Status)) { + // + // Do not delete Variable when failed to lock. Caller is respo= nsible to do this. + // + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\= n", Status)); + return EFI_ABORTED; + } + } else if (Status =3D=3D EFI_NOT_FOUND) { + // + // No more variables need to lock. + // + return EFI_SUCCESS; + } + } // End of for loop + } + } + + // + // Here probably means variable not present. + // + return Status; + +} diff --git a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteL= ib/DxeRuntimeVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/Dxe= RuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c index 9ed59f8827..28730f858b 100644 --- a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.c @@ -10,7 +10,7 @@ Using this library allows code to be written in a generic manner that ca= n be used in DXE or SMM without modification. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -18,14 +18,16 @@ #include =20 #include -#include +#include =20 #include #include #include #include =20 -STATIC EDKII_VARIABLE_LOCK_PROTOCOL *mVariableWriteLibVariableLock =3D NU= LL; +STATIC EDKII_VARIABLE_POLICY_PROTOCOL *mVariableWriteLibVariablePolicy = =3D NULL; +EFI_EVENT mExitBootServiceEvent; +EFI_EVENT mLegacyBootEvent; =20 /** Sets the value of a variable. @@ -144,7 +146,7 @@ VarLibIsVariableRequestToLockSupported ( VOID ) { - if (mVariableWriteLibVariableLock !=3D NULL) { + if (mVariableWriteLibVariablePolicy !=3D NULL) { return TRUE; } else { return FALSE; @@ -178,16 +180,45 @@ VarLibVariableRequestToLock ( { EFI_STATUS Status =3D EFI_UNSUPPORTED; =20 - if (mVariableWriteLibVariableLock !=3D NULL) { - Status =3D mVariableWriteLibVariableLock->RequestToLock ( - mVariableWriteLibVariableLoc= k, - VariableName, - VendorGuid - ); + if (mVariableWriteLibVariablePolicy !=3D NULL) { + Status =3D RegisterBasicVariablePolicy ( + mVariableWriteLibVariablePolicy, + (CONST EFI_GUID*) VendorGuid, + (CONST CHAR16 *) VariableName, + 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 + ); } return Status; } =20 +/** + Close events when driver unloaded. + + @param[in] ImageHandle A handle for the image that is initializing this= driver + @param[in] SystemTable A pointer to the EFI system table + + @retval EFI_SUCCESS The initialization finished successfully. +**/ +EFI_STATUS +EFIAPI +DxeRuntimeVariableWriteLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (mExitBootServiceEvent !=3D 0) { + gBS->CloseEvent (mExitBootServiceEvent); + } + if (mLegacyBootEvent !=3D 0) { + gBS->CloseEvent (mLegacyBootEvent); + } + return EFI_SUCCESS; +} + /** Exit Boot Services Event notification handler. =20 @@ -202,7 +233,7 @@ DxeRuntimeVariableWriteLibOnExitBootServices ( IN VOID *Context ) { - mVariableWriteLibVariableLock =3D NULL; + mVariableWriteLibVariablePolicy =3D NULL; } =20 /** @@ -227,13 +258,11 @@ DxeRuntimeVariableWriteLibConstructor ( ) { EFI_STATUS Status; - EFI_EVENT ExitBootServiceEvent; - EFI_EVENT LegacyBootEvent; =20 // // Locate VariableLockProtocol. // - Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **)&mVariableWriteLibVariableLock); + Status =3D gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL,= (VOID **)&mVariableWriteLibVariablePolicy); ASSERT_EFI_ERROR (Status); =20 // @@ -245,7 +274,7 @@ DxeRuntimeVariableWriteLibConstructor ( DxeRuntimeVariableWriteLibOnExitBootServices, NULL, &gEfiEventExitBootServicesGuid, - &ExitBootServiceEvent + &mExitBootServiceEvent ); ASSERT_EFI_ERROR (Status); =20 @@ -257,7 +286,7 @@ DxeRuntimeVariableWriteLibConstructor ( TPL_NOTIFY, DxeRuntimeVariableWriteLibOnExitBootServices, NULL, - &LegacyBootEvent + &mLegacyBootEvent ); ASSERT_EFI_ERROR (Status); =20 diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfi= g/SaveMemoryConfig.inf index e2dbd2fb49..61e85a6586 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.inf @@ -1,7 +1,7 @@ ### @file # Component information file for SaveMemoryConfig module # -# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -25,6 +25,7 @@ BaseMemoryLib LargeVariableReadLib LargeVariableWriteLib + BaseLib =20 [Packages] MdePkg/MdePkg.dec diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWri= teLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteL= ib.h index c847d7f152..1b9370685a 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h +++ b/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h @@ -16,7 +16,7 @@ is possible, adjusting the value of PcdMaxVariableSize may provide a sim= pler solution to this problem. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -52,7 +52,7 @@ @retval EFI_DEVICE_ERROR The variable could not be retrieved due t= o a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be delete= d. - + @retval EFI_ABORTED LockVariable was requested but failed. @retval EFI_NOT_FOUND The variable trying to be updated or dele= ted was not found. =20 **/ @@ -66,4 +66,26 @@ SetLargeVariable ( IN VOID *Data ); =20 +/** + Locks the existing large variable. + + @param[in] VariableName A Null-terminated string that is the name= of the vendor's variable. + Each VariableName is unique for each Vend= orGuid. VariableName must + contain 1 or more characters. If Variable= Name is an empty string, + then EFI_INVALID_PARAMETER is returned. + @param[in] VendorGuid A unique identifier for the vendor. + @retval EFI_SUCCESS The firmware has successfully locked the = variable. + @retval EFI_INVALID_PARAMETER An invalid combination of variable name a= nd GUID was supplied + @retval EFI_OUT_OF_RESOURCES The VariableName is longer than 1018 char= acters + @retval EFI_UNSUPPORTED The service for locking variable is not r= eady. + @retval EFI_NOT_FOUND The targeting variable for locking is not= present. + @retval EFI_ABORTED Fail to lock variable. +**/ +EFI_STATUS +EFIAPI +LockLargeVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid + ); + #endif // _LARGE_VARIABLE_WRITE_LIB_H_ diff --git a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteL= ib/DxeRuntimeVariableWriteLib.inf b/Platform/Intel/MinPlatformPkg/Library/D= xeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.inf index 704a8ac7cc..f83090c847 100644 --- a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.inf +++ b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.inf @@ -10,7 +10,7 @@ # Using this library allows code to be written in a generic manner that ca= n be # used in DXE or SMM without modification. # -# Copyright (c) 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -24,6 +24,7 @@ MODULE_TYPE =3D DXE_RUNTIME_DRIVER LIBRARY_CLASS =3D VariableWriteLib|DXE_CORE DXE_DRIVER = DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER CONSTRUCTOR =3D DxeRuntimeVariableWriteLibConstructor + DESTRUCTOR =3D DxeRuntimeVariableWriteLibDestructor =20 [Packages] MdePkg/MdePkg.dec @@ -37,13 +38,14 @@ UefiLib UefiBootServicesTableLib UefiRuntimeServicesTableLib + VariablePolicyHelperLib =20 [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event =20 [Protocols] gEfiVariableWriteArchProtocolGuid ## CONSUMES - gEdkiiVariableLockProtocolGuid ## CONSUMES + gEdkiiVariablePolicyProtocolGuid ## CONSUMES =20 [Depex] - gEfiVariableWriteArchProtocolGuid AND gEdkiiVariableLockProtocolGuid + gEfiVariableWriteArchProtocolGuid AND gEdkiiVariablePolicyProtocolGuid --=20 2.28.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86723): https://edk2.groups.io/g/devel/message/86723 Mute This Topic: https://groups.io/mt/89204326/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-