From add3ca4e0060cbf134f3c8559d5569bda24a5c9b Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Fri, 24 May 2024 17:41:40 +0800 Subject: SecurityPkg:Consume gEdkiiTcgPhysicalPresenceInterfaceVerHobGuid Consume gEdkiiTcgPhysicalPresenceInterfaceVerHobGuid in StandaloneMmTcg2PhysicalPresenceLib. This is to avoid using the dynamic PcdTcgPhysicalPresenceInterfaceVer in StandaloneMm module. Signed-off-by: Dun Tan --- .../MmTcg2PhysicalPresenceLibCommon.c | 20 +++------------- .../MmTcg2PhysicalPresenceLibCommon.h | 25 +++++++++++++++++++- .../SmmTcg2PhysicalPresenceLib.c | 16 ++++++++++++- .../StandaloneMmTcg2PhysicalPresenceLib.c | 27 +++++++++++++++++++++- .../StandaloneMmTcg2PhysicalPresenceLib.inf | 5 ++-- 5 files changed, 71 insertions(+), 22 deletions(-) (limited to 'SecurityPkg') diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.c b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.c index f2ab4f1..e8f3a7a 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.c +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.c @@ -10,24 +10,12 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction() will receive untrusted input and do validation. -Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#define PP_INF_VERSION_1_2 "1.2" +#include "MmTcg2PhysicalPresenceLibCommon.h" EFI_SMM_VARIABLE_PROTOCOL *mTcg2PpSmmVariable; BOOLEAN mIsTcg2PPVerLowerThan_1_3 = FALSE; @@ -392,9 +380,7 @@ Tcg2PhysicalPresenceLibCommonConstructor ( { EFI_STATUS Status; - if (AsciiStrnCmp (PP_INF_VERSION_1_2, (CHAR8 *)PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer), sizeof (PP_INF_VERSION_1_2) - 1) >= 0) { - mIsTcg2PPVerLowerThan_1_3 = TRUE; - } + mIsTcg2PPVerLowerThan_1_3 = IsTcg2PPVerLowerThan_1_3 (); // // Locate SmmVariableProtocol. diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.h b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.h index a018273..4409c4d 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.h +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/MmTcg2PhysicalPresenceLibCommon.h @@ -10,7 +10,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction() will receive untrusted input and do validation. -Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -18,6 +18,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _MM_TCG2_PHYSICAL_PRESENCE_LIB_COMMON_H_ #define _MM_TCG2_PHYSICAL_PRESENCE_LIB_COMMON_H_ +#include + +#include + +#include +#include +#include +#include +#include + +#define PP_INF_VERSION_1_2 "1.2" + /** The constructor function locates MmVariable protocol. @@ -31,4 +43,15 @@ Tcg2PhysicalPresenceLibCommonConstructor ( VOID ); +/** + Check if Tcg2 PP version is lower than PP_INF_VERSION_1_3. + + @retval TRUE Tcg2 PP version is lower than PP_INF_VERSION_1_3. + @retval Other Tcg2 PP version is not lower than PP_INF_VERSION_1_3. +**/ +BOOLEAN +IsTcg2PPVerLowerThan_1_3 ( + VOID + ); + #endif diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c index 36d8b89..da89be3 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c @@ -10,7 +10,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction() will receive untrusted input and do validation. -Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -39,3 +39,17 @@ Tcg2PhysicalPresenceLibTraditionalConstructor ( { return Tcg2PhysicalPresenceLibCommonConstructor (); } + +/** + Check if Tcg2 PP version is lower than PP_INF_VERSION_1_3. + + @retval TRUE Tcg2 PP version is lower than PP_INF_VERSION_1_3. + @retval Other Tcg2 PP version is not lower than PP_INF_VERSION_1_3. +**/ +BOOLEAN +IsTcg2PPVerLowerThan_1_3 ( + VOID + ) +{ + return (BOOLEAN)(AsciiStrnCmp (PP_INF_VERSION_1_2, (CHAR8 *)PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer), sizeof (PP_INF_VERSION_1_2) - 1) >= 0); +} diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.c index 5c298a8..d1646d0 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.c +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.c @@ -10,7 +10,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction() and Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction() will receive untrusted input and do validation. -Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -18,6 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include +#include + #include "MmTcg2PhysicalPresenceLibCommon.h" /** @@ -40,3 +42,26 @@ Tcg2PhysicalPresenceLibStandaloneMmConstructor ( { return Tcg2PhysicalPresenceLibCommonConstructor (); } + +/** + Check if Tcg2 PP version is lower than PP_INF_VERSION_1_3. + + @retval TRUE Tcg2 PP version is lower than PP_INF_VERSION_1_3. + @retval Other Tcg2 PP version is not lower than PP_INF_VERSION_1_3. +**/ +BOOLEAN +IsTcg2PPVerLowerThan_1_3 ( + VOID + ) +{ + VOID *GuidHob; + + GuidHob = GetFirstGuidHob (&gEdkiiTcgPhysicalPresenceInterfaceVerHobGuid); + ASSERT (GuidHob != NULL); + + if (AsciiStrnCmp (PP_INF_VERSION_1_2, (CHAR8 *)GET_GUID_HOB_DATA (GuidHob), sizeof (PP_INF_VERSION_1_2) - 1) >= 0) { + return TRUE; + } + + return FALSE; +} diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf index 6d11b6b..0d8d111 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf @@ -7,7 +7,7 @@ # This driver will have external input - variable. # This external input must be validated carefully to avoid security issue. # -# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -44,18 +44,19 @@ Tcg2PpVendorLib MmServicesTableLib BaseMemoryLib + HobLib [Guids] ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence" ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence" ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresenceFlags" gEfiTcg2PhysicalPresenceGuid + gEdkiiTcgPhysicalPresenceInterfaceVerHobGuid [Protocols] gEfiSmmVariableProtocolGuid ## CONSUMES [Pcd] - gEfiSecurityPkgTokenSpaceGuid.PcdTcgPhysicalPresenceInterfaceVer ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdTcg2PhysicalPresenceFlags ## SOMETIMES_CONSUMES [Depex] -- cgit v1.1