From nobody Sat Apr 27 14:57:16 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+82246+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+82246+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634587673; cv=none; d=zohomail.com; s=zohoarc; b=gNGPWKPxFdqOMskIDte02BqFsjLBLNvIf6uI/0tSFLNf9AFoS+relLNx3gxEe808CTWg3yyJPiFwbx3azlnbwhv/pUYoaVTmJyIIMlxzL+6nFVOCvrhVqRivnCEl/YNHw49U+k4ghx1loEobPn4tLW/2ePI6lA5WMfoghYRMHHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634587673; 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=jvYXUWHDWJBTulAUFR9SrYK2JUPk+0Aehg7OoiuIy98=; b=JPJraA8bEV21nmg9Aac7Ur7bWGUYae0TJYFFREKB6woS8uGayLslNlWFPqrteiW8mCxk03UnFHyHxXa1w8jqF+xI1EcvGKWk1w48BfOe/PobWiv2fRsQxjXDIkv95rWTX6pWfag/YogdRBkNqMGUR6Gfr3F8L57j0FnwL84oChk= 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+82246+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 163458767306533.09427229889832; Mon, 18 Oct 2021 13:07:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6kNFYY1788612xaOqXkg09Uj; Mon, 18 Oct 2021 13:07:52 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.32166.1634534055701844445 for ; Sun, 17 Oct 2021 22:14:15 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="228444914" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="228444914" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 22:14:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="482578866" X-Received: from desktop-yang.ccr.corp.intel.com ([10.239.158.52]) by orsmga007.jf.intel.com with ESMTP; 17 Oct 2021 22:14:03 -0700 From: "Yang Jie" To: devel@edk2.groups.io Cc: gaoliming@byosoft.com.cn, michael.d.kinney@intel.com, guomin.jiang@intel.com, wei6.xu@intel.com, yangjie Subject: [edk2-devel][PATCH] FmpDevicePkg/FmpDxe: Use new Variable Lock interface Date: Mon, 18 Oct 2021 13:14:00 +0800 Message-Id: <20211018051400.3097-1-jie.yang@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,jie.yang@intel.com X-Gm-Message-State: pCNwuSrriUf1v3phQKHLcRftx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634587672; bh=wfA7GL+MMBMtNNI2PW20L5XwinKJhnzAD03FdPkU5JY=; h=Cc:Date:From:Reply-To:Subject:To; b=CeTxhArUhi90xXmH+WMjtEGmlIuCmDqqebybyWA65w2GHviCMf7QDN07xe6jVLnbR9o xzZKxBNs4A7smgnsZbNr2TASXnZ3W2ZryCxa6uH/5+Sr+UBa6uFCaIXPZc40Y/NCYzCvN Nn3FiFYY9FtfgJYZiwKN2TIKetppEZPshv0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634587675146100011 Content-Type: text/plain; charset="utf-8" From: yangjie REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3655 The code in FmpDevicePkg called the deprecated interface=20 VariableLockRequestToLock. So I changed the code in=20 FmpDevicePkg using RegisterBasicVariablePolicy,=20 instead of the deprecated interface. Signed-off-by: Yang Jie Cc: Liming Gao Cc: Michael D Kinney Cc: Guomin Jiang Cc: Wei6 Xu Reviewed-by: Liming Gao Reviewed-by: Wei6 Xu --- FmpDevicePkg/FmpDevicePkg.dsc | 1 + FmpDevicePkg/FmpDxe/FmpDxe.h | 4 +- FmpDevicePkg/FmpDxe/FmpDxe.inf | 5 ++- FmpDevicePkg/FmpDxe/VariableSupport.c | 65 +++++++++++++-------------- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc index b420f52a08..7b1af285dd 100644 --- a/FmpDevicePkg/FmpDevicePkg.dsc +++ b/FmpDevicePkg/FmpDevicePkg.dsc @@ -53,6 +53,7 @@ DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf !ifdef CONTINUOUS_INTEGRATION BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf !else diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.h b/FmpDevicePkg/FmpDxe/FmpDxe.h index 1177b1828e..4d94a925b6 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.h +++ b/FmpDevicePkg/FmpDxe/FmpDxe.h @@ -4,7 +4,7 @@ information provided through PCDs and libraries. =20 Copyright (c) Microsoft Corporation.
- Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -33,11 +33,11 @@ #include #include #include -#include #include #include #include #include +#include =20 #define VERSION_STRING_NOT_SUPPORTED L"VERSION STRING NOT SUPPORTED" #define VERSION_STRING_NOT_AVAILABLE L"VERSION STRING NOT AVAILABLE" diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf index eeb904a091..1c296388b0 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.inf +++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf @@ -4,7 +4,7 @@ # information provided through PCDs and libraries. # # Copyright (c) 2016, Microsoft Corporation. All rights reserved.
-# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -55,14 +55,15 @@ FmpDependencyLib FmpDependencyCheckLib FmpDependencyDeviceLib + VariablePolicyHelperLib =20 [Guids] gEfiEndOfDxeEventGroupGuid =20 [Protocols] - gEdkiiVariableLockProtocolGuid ## CONSUMES gEfiFirmwareManagementProtocolGuid ## PRODUCES gEdkiiFirmwareManagementProgressProtocolGuid ## PRODUCES + gEdkiiVariablePolicyProtocolGuid ## CONSUMES =20 [Pcd] gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceStorageAccessEnable = ## CONSUMES diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/Va= riableSupport.c index 86dd5b203b..a1bd949b09 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.c +++ b/FmpDevicePkg/FmpDxe/VariableSupport.c @@ -3,7 +3,7 @@ firmware updates. =20 Copyright (c) 2016, Microsoft Corporation. All rights reserved.
- Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2018 - 2021, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -730,28 +730,29 @@ static EFI_STATUS LockFmpVariable ( IN EFI_STATUS PreviousStatus, - IN EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock, + EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy, IN CHAR16 *VariableName ) { EFI_STATUS Status; =20 - Status =3D VariableLock->RequestToLock ( - VariableLock, - VariableName, - &gEfiCallerIdGuid - ); - if (!EFI_ERROR (Status)) { - return PreviousStatus; + // If success, go ahead and set the policies to protect the target varia= bles. + Status =3D RegisterBasicVariablePolicy (VariablePolicy, + &gEfiCallerIdGuid, + 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); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Stat= us =3D %r\n", + mImageIdName, + &gEfiCallerIdGuid, + VariableName, + Status + )); } - - DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Status= =3D %r\n", - mImageIdName, - &gEfiCallerIdGuid, - VariableName, - Status - )); - if (EFI_ERROR (PreviousStatus)) { return PreviousStatus; } @@ -773,26 +774,22 @@ LockAllFmpVariables ( FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private ) { - EFI_STATUS Status; - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; - - VariableLock =3D NULL; - Status =3D gBS->LocateProtocol ( - &gEdkiiVariableLockProtocolGuid, - NULL, - (VOID **)&VariableLock - ); - if (EFI_ERROR (Status) || VariableLock =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to locate Variable Lock Proto= col (%r).\n", mImageIdName, Status)); - return EFI_UNSUPPORTED; + EFI_STATUS Status; + EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy; + + // Locate the VariablePolicy protocol. + Status =3D gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL,= (VOID**)&VariablePolicy ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpDxe %a - Could not locate VariablePolicy prot= ocol! %r\n", __FUNCTION__, Status)); + return Status; } =20 Status =3D EFI_SUCCESS; - Status =3D LockFmpVariable (Status, VariableLock, Private->VersionVariab= leName); - Status =3D LockFmpVariable (Status, VariableLock, Private->LsvVariableNa= me); - Status =3D LockFmpVariable (Status, VariableLock, Private->LastAttemptSt= atusVariableName); - Status =3D LockFmpVariable (Status, VariableLock, Private->LastAttemptVe= rsionVariableName); - Status =3D LockFmpVariable (Status, VariableLock, Private->FmpStateVaria= bleName); + Status =3D LockFmpVariable (Status, VariablePolicy, Private->VersionVari= ableName); + Status =3D LockFmpVariable (Status, VariablePolicy, Private->LsvVariable= Name); + Status =3D LockFmpVariable (Status, VariablePolicy, Private->LastAttempt= StatusVariableName); + Status =3D LockFmpVariable (Status, VariablePolicy, Private->LastAttempt= VersionVariableName); + Status =3D LockFmpVariable (Status, VariablePolicy, Private->FmpStateVar= iableName); =20 return Status; } --=20 2.26.2.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 (#82246): https://edk2.groups.io/g/devel/message/82246 Mute This Topic: https://groups.io/mt/86407503/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-