FmpDevicePkg/FmpDxe: Use new Variable Lock interface

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3655
The code in FmpDevicePkg call the deprecated interface
VariableLockRequestToLockc. So I changed the code in
FmpDevicePkg using RegisterBasicVariablePolicy, instead
of the deprecated interface.

Signed-off-by: Yang Jie <jie.yang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Wei6 Xu <wei6.xu@intel.com>
This commit is contained in:
Yang Jie 2021-10-19 11:11:04 +08:00 committed by mergify[bot]
parent b80c17b62d
commit 2f6f3329ad
4 changed files with 38 additions and 39 deletions

View File

@ -53,6 +53,7 @@
DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
!ifdef CONTINUOUS_INTEGRATION !ifdef CONTINUOUS_INTEGRATION
BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
!else !else

View File

@ -4,7 +4,7 @@
information provided through PCDs and libraries. information provided through PCDs and libraries.
Copyright (c) Microsoft Corporation.<BR> Copyright (c) Microsoft Corporation.<BR>
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR> Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -33,11 +33,11 @@
#include <Library/FmpDependencyDeviceLib.h> #include <Library/FmpDependencyDeviceLib.h>
#include <Protocol/FirmwareManagement.h> #include <Protocol/FirmwareManagement.h>
#include <Protocol/FirmwareManagementProgress.h> #include <Protocol/FirmwareManagementProgress.h>
#include <Protocol/VariableLock.h>
#include <Guid/SystemResourceTable.h> #include <Guid/SystemResourceTable.h>
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>
#include <LastAttemptStatus.h> #include <LastAttemptStatus.h>
#include <FmpLastAttemptStatus.h> #include <FmpLastAttemptStatus.h>
#include <Library/VariablePolicyHelperLib.h>
#define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED" #define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED"
#define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE" #define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE"

View File

@ -4,7 +4,7 @@
# information provided through PCDs and libraries. # information provided through PCDs and libraries.
# #
# Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR> # Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
# #
# SPDX-License-Identifier: BSD-2-Clause-Patent # SPDX-License-Identifier: BSD-2-Clause-Patent
## ##
@ -55,14 +55,15 @@
FmpDependencyLib FmpDependencyLib
FmpDependencyCheckLib FmpDependencyCheckLib
FmpDependencyDeviceLib FmpDependencyDeviceLib
VariablePolicyHelperLib
[Guids] [Guids]
gEfiEndOfDxeEventGroupGuid gEfiEndOfDxeEventGroupGuid
[Protocols] [Protocols]
gEdkiiVariableLockProtocolGuid ## CONSUMES
gEfiFirmwareManagementProtocolGuid ## PRODUCES gEfiFirmwareManagementProtocolGuid ## PRODUCES
gEdkiiFirmwareManagementProgressProtocolGuid ## PRODUCES gEdkiiFirmwareManagementProgressProtocolGuid ## PRODUCES
gEdkiiVariablePolicyProtocolGuid ## CONSUMES
[Pcd] [Pcd]
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceStorageAccessEnable ## CONSUMES gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceStorageAccessEnable ## CONSUMES

View File

@ -3,7 +3,7 @@
firmware updates. firmware updates.
Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR> Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR> Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@ -729,29 +729,30 @@ SetLastAttemptVersionInVariable (
static static
EFI_STATUS EFI_STATUS
LockFmpVariable ( LockFmpVariable (
IN EFI_STATUS PreviousStatus, IN EFI_STATUS PreviousStatus,
IN EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock, IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy,
IN CHAR16 *VariableName IN CHAR16 *VariableName
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = VariableLock->RequestToLock ( // If success, go ahead and set the policies to protect the target variables.
VariableLock, Status = RegisterBasicVariablePolicy (VariablePolicy,
VariableName, &gEfiCallerIdGuid,
&gEfiCallerIdGuid VariableName,
); VARIABLE_POLICY_NO_MIN_SIZE,
if (!EFI_ERROR (Status)) { VARIABLE_POLICY_NO_MAX_SIZE,
return PreviousStatus; VARIABLE_POLICY_NO_MUST_ATTR,
VARIABLE_POLICY_NO_CANT_ATTR,
VARIABLE_POLICY_TYPE_LOCK_NOW);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Status = %r\n",
mImageIdName,
&gEfiCallerIdGuid,
VariableName,
Status
));
} }
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Status = %r\n",
mImageIdName,
&gEfiCallerIdGuid,
VariableName,
Status
));
if (EFI_ERROR (PreviousStatus)) { if (EFI_ERROR (PreviousStatus)) {
return PreviousStatus; return PreviousStatus;
} }
@ -773,26 +774,22 @@ LockAllFmpVariables (
FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
VariableLock = NULL; // Locate the VariablePolicy protocol.
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID**)&VariablePolicy );
&gEdkiiVariableLockProtocolGuid, if (EFI_ERROR (Status)) {
NULL, DEBUG ((DEBUG_ERROR, "FmpDxe %a - Could not locate VariablePolicy protocol! %r\n", __FUNCTION__, Status));
(VOID **)&VariableLock return Status;
);
if (EFI_ERROR (Status) || VariableLock == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to locate Variable Lock Protocol (%r).\n", mImageIdName, Status));
return EFI_UNSUPPORTED;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Status = LockFmpVariable (Status, VariableLock, Private->VersionVariableName); Status = LockFmpVariable (Status, VariablePolicy, Private->VersionVariableName);
Status = LockFmpVariable (Status, VariableLock, Private->LsvVariableName); Status = LockFmpVariable (Status, VariablePolicy, Private->LsvVariableName);
Status = LockFmpVariable (Status, VariableLock, Private->LastAttemptStatusVariableName); Status = LockFmpVariable (Status, VariablePolicy, Private->LastAttemptStatusVariableName);
Status = LockFmpVariable (Status, VariableLock, Private->LastAttemptVersionVariableName); Status = LockFmpVariable (Status, VariablePolicy, Private->LastAttemptVersionVariableName);
Status = LockFmpVariable (Status, VariableLock, Private->FmpStateVariableName); Status = LockFmpVariable (Status, VariablePolicy, Private->FmpStateVariableName);
return Status; return Status;
} }