summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Tcg/TcgPei
diff options
context:
space:
mode:
authorYao, Jiewen <jiewen.yao@intel.com>2015-01-12 03:21:00 +0000
committerjyao1 <jyao1@Edk2>2015-01-12 03:21:00 +0000
commit6f785cfcc304c48ec04e542ee429df95e7b51bc5 (patch)
tree5fc40fc8b8be583bf58179a4e3d245cad6c5e1ad /SecurityPkg/Tcg/TcgPei
parent4610b23ab10942d140eb51c4bdbefc5f896979ad (diff)
downloadedk2-6f785cfcc304c48ec04e542ee429df95e7b51bc5.tar.gz
edk2-6f785cfcc304c48ec04e542ee429df95e7b51bc5.tar.bz2
edk2-6f785cfcc304c48ec04e542ee429df95e7b51bc5.zip
Handle TPM device error and avoid deadloop in BDS.
If TPM error happens, set TPM flag to NOT present, so that trusted boot patch is disabled. Also report status code for failure, so that platform may register handler to apply policy like force system reset, or disable TPM permanently. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: "Dong, Guo" <guo.dong@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16598 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg/Tcg/TcgPei')
-rw-r--r--SecurityPkg/Tcg/TcgPei/TcgPei.c33
-rw-r--r--SecurityPkg/Tcg/TcgPei/TcgPei.inf5
-rw-r--r--SecurityPkg/Tcg/TcgPei/TpmComm.c6
3 files changed, 34 insertions, 10 deletions
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index 0c00e286ce..dcf4b0bbbd 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -1,7 +1,7 @@
/** @file
Initialize TPM device and measure FVs before handing off control to DXE.
-Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -38,6 +38,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/BaseLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/ReportStatusCodeLib.h>
#include "TpmComm.h"
@@ -221,6 +222,10 @@ HashLogExtendEvent (
{
EFI_STATUS Status;
VOID *HobData;
+
+ if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) {
+ return EFI_DEVICE_ERROR;
+ }
HobData = NULL;
if (HashDataLen != 0) {
@@ -229,7 +234,9 @@ HashLogExtendEvent (
HashDataLen,
&NewEventHdr->Digest
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
}
Status = TpmCommExtend (
@@ -239,20 +246,34 @@ HashLogExtendEvent (
NewEventHdr->PCRIndex,
NULL
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
HobData = BuildGuidHob (
&gTcgEventEntryHobGuid,
sizeof (*NewEventHdr) + NewEventHdr->EventSize
);
if (HobData == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
}
CopyMem (HobData, NewEventHdr, sizeof (*NewEventHdr));
HobData = (VOID *) ((UINT8*)HobData + sizeof (*NewEventHdr));
CopyMem (HobData, NewEventData, NewEventHdr->EventSize);
- return EFI_SUCCESS;
+
+Done:
+ if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_TIMEOUT)) {
+ DEBUG ((EFI_D_ERROR, "HashLogExtendEvent - %r. Disable TPM.\n", Status));
+ BuildGuidHob (&gTpmErrorHobGuid,0);
+ REPORT_STATUS_CODE (
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,
+ (PcdGet32 (PcdStatusCodeSubClassTpmDevice) | EFI_P_EC_INTERFACE_ERROR)
+ );
+ Status = EFI_DEVICE_ERROR;
+ }
+ return Status;
}
/**
@@ -365,7 +386,6 @@ MeasureFvImage (
&TcgEventHdr,
(UINT8*) &FvBlob
);
- ASSERT_EFI_ERROR (Status);
//
// Add new FV into the measured FV list.
@@ -682,7 +702,6 @@ PeimEntryMP (
if (IsTpmUsable (PeiServices, TpmHandle)) {
if (PcdGet8 (PcdTpmScrtmPolicy) == 1) {
Status = MeasureCRTMVersion (PeiServices, TpmHandle);
- ASSERT_EFI_ERROR (Status);
}
Status = MeasureMainBios (PeiServices, TpmHandle);
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index c68c9056cf..6a76cf1c2e 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -4,7 +4,7 @@
# This module will initialize TPM device, measure reported FVs and BIOS version.
# This module may also lock TPM physical presence and physicalPresenceLifetimeLock.
#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -56,9 +56,11 @@
BaseLib
PcdLib
MemoryAllocationLib
+ ReportStatusCodeLib
[Guids]
gTcgEventEntryHobGuid ## PRODUCES ## HOB
+ gTpmErrorHobGuid ## SOMETIMES_PRODUCES ## HOB
gMeasuredFvHobGuid ## PRODUCES ## HOB
gEfiTpmDeviceInstanceTpm12Guid ## PRODUCES ## GUID # TPM device identifier
@@ -79,6 +81,7 @@
gEfiSecurityPkgTokenSpaceGuid.PcdTpmInitializationPolicy ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpmScrtmPolicy ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES
+ gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeSubClassTpmDevice ## SOMETIMES_CONSUMES
[Depex]
gEfiPeiMasterBootModePpiGuid AND
diff --git a/SecurityPkg/Tcg/TcgPei/TpmComm.c b/SecurityPkg/Tcg/TcgPei/TpmComm.c
index fb5011ee9d..899c8e3e0b 100644
--- a/SecurityPkg/Tcg/TcgPei/TpmComm.c
+++ b/SecurityPkg/Tcg/TcgPei/TpmComm.c
@@ -1,7 +1,7 @@
/** @file
Utility functions used by TPM PEI driver.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -222,7 +222,9 @@ TpmCommExtend (
SendBuffer.PcrIndex = SwapBytes32 (PcrIndex);
CopyMem (&SendBuffer.TpmDigest, (UINT8 *)DigestToExtend, sizeof (TPM_DIGEST));
Status = TisTpmCommand (PeiServices, TpmHandle, (UINT8 *)&SendBuffer, TpmSendSize, RecvBuffer, &TpmRecvSize);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
if(NewPcrValue != NULL) {
CopyMem ((UINT8*)NewPcrValue, &RecvBuffer[10], sizeof (TPM_DIGEST));