+/** @file\r
+ Tcg PP storage library instance that does support any storage specific PPI.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiDxe.h>\r
+\r
+#include <Guid/Tcg2PhysicalPresenceData.h>\r
+#include <Guid/TcgPhysicalPresenceStorageData.h>\r
+\r
+#include <IndustryStandard/TcgPhysicalPresence.h>\r
+\r
+#include <Protocol/VariableLock.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/Tcg2PhysicalPresenceLib.h>\r
+#include <Library/TcgPhysicalPresenceStorageLib.h>\r
+\r
+#include "DxeTcgPhysicalPresenceStorageLibInternal.h"\r
+\r
+/**\r
+ Display the confirm text and get user confirmation.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] ManagementFlags BIOS TPM Management Flags.\r
+\r
+\r
+ @retval TRUE The user need to confirme the changes.\r
+ @retval FALSE The user doesn't need to confirme the changes.\r
+**/\r
+BOOLEAN\r
+Tcg2PpNeedUserConfirm (\r
+ IN UINT8 OperationRequest,\r
+ IN UINT32 ManagementFlags\r
+ )\r
+{\r
+ BOOLEAN NeedUserConfirm;\r
+\r
+ NeedUserConfirm = FALSE;\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ if ((ManagementFlags & TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID) != 0) {\r
+ NeedUserConfirm = TRUE;\r
+ }\r
+ break;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ NeedUserConfirm = TRUE;\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return NeedUserConfirm;\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in] RequestParameter TPM physical presence operation request parameter.\r
+\r
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and\r
+ Submit TPM Operation Request to Pre-OS Environment 2.\r
+**/\r
+UINT32\r
+EFIAPI\r
+Tcg2SubmitStorageRequest (\r
+ IN UINT32 OperationRequest,\r
+ IN UINT32 RequestParameter\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter));\r
+\r
+ //\r
+ // Get the Physical Presence storage variable\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ if ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
+ }\r
+\r
+ if ((PpData.PPRequest != OperationRequest) ||\r
+ (PpData.PPRequestParameter != RequestParameter)) {\r
+ PpData.PPRequest = (UINT8)OperationRequest;\r
+ PpData.PPRequestParameter = RequestParameter;\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &PpData\r
+ );\r
+ }\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+ }\r
+\r
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check if the pending TPM request needs user input to confirm.\r
+\r
+ The TPM request may come from OS. This API will check if TPM request exists and need user\r
+ input to confirmation.\r
+\r
+ @retval TRUE TPM needs input to confirm user physical presence.\r
+ @retval FALSE TPM doesn't need input to confirm user physical presence.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Tcg2NeedUserConfirm(\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_TCG2_PHYSICAL_PRESENCE TcgPpData;\r
+ UINTN DataSize;\r
+ EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS PpiFlags;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return FALSE;\r
+ }\r
+\r
+ //\r
+ // Check Tpm requests\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return FALSE;\r
+ }\r
+\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG2_BIOS_TPM_MANAGEMENT_FLAG_DEFAULT;\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) &&\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN)) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ return Tcg2PpNeedUserConfirm(TcgPpData.PPRequest, PpiFlags.PPFlags);\r
+}\r
+\r
+/**\r
+ The handler for TPM physical presence function:\r
+ Return TPM Operation Response to OS Environment.\r
+\r
+ @param[out] MostRecentRequest Most recent operation request.\r
+ @param[out] Response Response to the most recent operation request.\r
+\r
+ @return Return Code for Return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+EFIAPI\r
+Tcg2ReturnOperationResponseToOsFunction (\r
+ OUT UINT32 *MostRecentRequest,\r
+ OUT UINT32 *Response\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE PpData;\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] ReturnOperationResponseToOsFunction\n"));\r
+\r
+ //\r
+ // Get the Physical Presence variable\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ *MostRecentRequest = 0;\r
+ *Response = 0;\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Get PP variable failure! Status = %r\n", Status));\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
+ }\r
+\r
+ *MostRecentRequest = PpData.LastPPRequest;\r
+ *Response = PpData.PPResponse;\r
+\r
+ return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
+}\r
+\r
+/**\r
+ Check and execute the requested physical presence command.\r
+\r
+ This API should be invoked in BIOS boot phase to process pending request.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ If OperationRequest < 128, then ASSERT().\r
+\r
+ @param[in] OperationRequest TPM physical presence operation request.\r
+ @param[in, out] ManagementFlags BIOS TPM Management Flags.\r
+ @param[out] ResetRequired If reset is required to vendor settings in effect.\r
+ True, it indicates the reset is required.\r
+ False, it indicates the reset is not required.\r
+\r
+ @return TPM Operation Response to OS Environment.\r
+**/\r
+UINT32\r
+Tcg2ExecutePendingRequest (\r
+ IN UINT8 OperationRequest,\r
+ IN OUT UINT32 *ManagementFlags,\r
+ OUT BOOLEAN *ResetRequired\r
+ )\r
+{\r
+ ASSERT ((OperationRequest >= TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) &&\r
+ (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION));\r
+\r
+ if (Tcg2PpNeedUserConfirm(OperationRequest, *ManagementFlags)) {\r
+ if (!TcgPpUserConfirm (OperationRequest)) {\r
+ return TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+ }\r
+ }\r
+\r
+ switch (OperationRequest) {\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags|= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_TRUE:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_PP_REQUIRED_FOR_DISABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID:\r
+ *ManagementFlags |= TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ case TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID:\r
+ *ManagementFlags &= ~TCG_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID;\r
+ return TCG_PP_OPERATION_RESPONSE_SUCCESS;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
+}\r
+\r
+/**\r
+ Check and execute the pending TPM request.\r
+\r
+ The TPM request may come from OS or BIOS. This API will display request information and wait\r
+ for user confirmation if TPM request exists. The TPM request will be sent to TPM device after\r
+ the TPM request is confirmed, and one or more reset may be required to make TPM request to\r
+ take effect.\r
+\r
+ This API should be invoked after console in and console out are all ready as they are required\r
+ to display request information and get user input to confirm the request.\r
+\r
+ @param[in] PlatformAuth platform auth value. NULL means no platform auth change.\r
+**/\r
+VOID\r
+EFIAPI\r
+Tcg2ProcessStorageRequest (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_TCG2_PHYSICAL_PRESENCE TcgPpData;\r
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;\r
+ EFI_TCG2_PHYSICAL_PRESENCE_FLAGS PpiFlags;\r
+ EFI_TCG2_PHYSICAL_PRESENCE_FLAGS NewPpiFlags;\r
+ BOOLEAN ResetRequired;\r
+\r
+ //\r
+ // Check S4 resume\r
+ //\r
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {\r
+ DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n"));\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence variable.\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->GetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence variable failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+\r
+ if ((TcgPpData.PPRequest >= TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) ||\r
+ (TcgPpData.PPRequest < TCG2_PHYSICAL_PRESENCE_STORAGE_MANAGEMENT_BEGIN) ) {\r
+ //\r
+ // This library only support storage related actions.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Only support TCG storage related PP actions, not support PPRequest=%x\n", TcgPpData.PPRequest));\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Initialize physical presence flags.\r
+ //\r
+ DataSize = sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS);\r
+ Status = gRT->GetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ NULL,\r
+ &DataSize,\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ PpiFlags.PPFlags = TCG_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &PpiFlags\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Set physical presence flag failed, Status = %r\n", Status));\r
+ return ;\r
+ }\r
+ }\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PpiFlags = %x\n", PpiFlags.PPFlags));\r
+\r
+ //\r
+ // This flags variable controls whether physical presence is required for TPM command.\r
+ // It should be protected from malicious software. We set it as read-only variable here.\r
+ //\r
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = VariableLockProtocol->RequestToLock (\r
+ VariableLockProtocol,\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR, "[TPM Storage] Error when lock variable %s, Status = %r\n", TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE, Status));\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ }\r
+\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
+\r
+ NewPpiFlags.PPFlags = PpiFlags.PPFlags;\r
+ ResetRequired = FALSE;\r
+ TcgPpData.PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+\r
+ TcgPpData.PPResponse = Tcg2ExecutePendingRequest (TcgPpData.PPRequest, &NewPpiFlags.PPFlags, &ResetRequired);\r
+ DEBUG ((EFI_D_INFO, "[TPM Storage] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags));\r
+\r
+ if (TcgPpData.PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {\r
+ return;\r
+ }\r
+\r
+ //\r
+ // Save the flags if it is updated.\r
+ //\r
+ if (CompareMem (&PpiFlags, &NewPpiFlags, sizeof(EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS)) != 0) {\r
+ Status = gRT->SetVariable (\r
+ TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE,\r
+ &gEfiTcgPhysicalPresenceStorageGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS),\r
+ &NewPpiFlags\r
+ );\r
+ }\r
+\r
+ //\r
+ // Clear request\r
+ //\r
+ TcgPpData.LastPPRequest = TcgPpData.PPRequest;\r
+ TcgPpData.PPRequest = TCG2_PHYSICAL_PRESENCE_NO_ACTION;\r
+ TcgPpData.PPRequestParameter = 0;\r
+\r
+ //\r
+ // Save changes\r
+ //\r
+ DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE);\r
+ Status = gRT->SetVariable (\r
+ TCG2_PHYSICAL_PRESENCE_VARIABLE,\r
+ &gEfiTcg2PhysicalPresenceGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ DataSize,\r
+ &TcgPpData\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return;\r
+ }\r
+\r
+ if (!ResetRequired) {\r
+ return;\r
+ }\r
+\r
+ Print (L"Rebooting system to make TPM2 settings in effect\n");\r
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+ ASSERT (FALSE);\r
+}\r
+\r