summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Library
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/Library
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/Library')
-rw-r--r--SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c4
-rw-r--r--SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c4
-rw-r--r--SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c17
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c29
4 files changed, 22 insertions, 32 deletions
diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
index 6b6a377b2d..ed53b7e003 100644
--- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
@@ -15,7 +15,7 @@
TrEEMeasureGptTable() function will receive untrusted GPT partition table, and parse
partition data carefully.
-Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 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
@@ -456,7 +456,7 @@ DxeTpm2MeasureBootHandler (
TreeProtocol,
&ProtocolCapability
);
- if (EFI_ERROR (Status) || !ProtocolCapability.TrEEPresentFlag) {
+ if (EFI_ERROR (Status) || (!ProtocolCapability.TrEEPresentFlag)) {
//
// TPM device doesn't work or activate.
//
diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
index 5bfa282bc5..466a74ef09 100644
--- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c
@@ -15,7 +15,7 @@
TcgMeasureGptTable() function will receive untrusted GPT partition table, and parse
partition data carefully.
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 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
@@ -768,7 +768,7 @@ DxeTpmMeasureBootHandler (
&EventLogLocation,
&EventLogLastEntry
);
- if (EFI_ERROR (Status) || ProtocolCapability.TPMDeactivatedFlag) {
+ if (EFI_ERROR (Status) || ProtocolCapability.TPMDeactivatedFlag || (!ProtocolCapability.TPMPresentFlag)) {
//
// TPM device doesn't work or activate.
//
diff --git a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
index 2ad5345927..2fb360fa12 100644
--- a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
+++ b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c
@@ -1,7 +1,7 @@
/** @file
TIS (TPM Interface Specification) functions used by TPM1.2.
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 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
@@ -217,7 +217,6 @@ Tpm12TisPcPresenceCheck (
@retval EFI_TIMEOUT The register can't run into the expected status in time.
**/
EFI_STATUS
-EFIAPI
Tpm12TisPcWaitRegisterBits (
IN UINT8 *Register,
IN UINT8 BitSet,
@@ -249,7 +248,6 @@ Tpm12TisPcWaitRegisterBits (
@retval EFI_TIMEOUT BurstCount can't be got in time.
**/
EFI_STATUS
-EFIAPI
Tpm12TisPcReadBurstCount (
IN TIS_PC_REGISTERS_PTR TisReg,
OUT UINT16 *BurstCount
@@ -293,7 +291,6 @@ Tpm12TisPcReadBurstCount (
@retval EFI_TIMEOUT TPM chip can't be set to ready state in time.
**/
EFI_STATUS
-EFIAPI
Tpm12TisPcPrepareCommand (
IN TIS_PC_REGISTERS_PTR TisReg
)
@@ -326,7 +323,6 @@ Tpm12TisPcPrepareCommand (
@retval EFI_TIMEOUT Can't get the TPM control in time.
**/
EFI_STATUS
-EFIAPI
Tpm12TisPcRequestUseTpm (
IN TIS_PC_REGISTERS_PTR TisReg
)
@@ -361,7 +357,6 @@ Tpm12TisPcRequestUseTpm (
@param[in, out] SizeOut Size of response data.
@retval EFI_SUCCESS Operation completed successfully.
- @retval EFI_TIMEOUT The register can't run into the expected status in time.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
@retval EFI_UNSUPPORTED Unsupported TPM version
@@ -408,7 +403,7 @@ Tpm12TisTpmCommand (
Status = Tpm12TisPcPrepareCommand (TisReg);
if (EFI_ERROR (Status)){
DEBUG ((DEBUG_ERROR, "Tpm12 is not ready for command!\n"));
- return Status;
+ return EFI_DEVICE_ERROR;
}
//
// Send the command data to Tpm
@@ -417,7 +412,7 @@ Tpm12TisTpmCommand (
while (Index < SizeIn) {
Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {
@@ -451,7 +446,7 @@ Tpm12TisTpmCommand (
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Wait for Tpm12 response data time out!!\n"));
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
//
@@ -462,7 +457,7 @@ Tpm12TisTpmCommand (
while (Index < sizeof (TPM_RSP_COMMAND_HDR)) {
Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
for (; BurstCount > 0; BurstCount--) {
@@ -509,7 +504,7 @@ Tpm12TisTpmCommand (
}
Status = Tpm12TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
}
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
index cf85d4c7ee..a1862796a5 100644
--- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c
@@ -1,7 +1,7 @@
/** @file
TIS (TPM Interface Specification) functions used by dTPM2.0 library.
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 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
@@ -223,7 +223,6 @@ TisPcPresenceCheck (
@retval EFI_TIMEOUT The register can't run into the expected status in time.
**/
EFI_STATUS
-EFIAPI
TisPcWaitRegisterBits (
IN UINT8 *Register,
IN UINT8 BitSet,
@@ -255,7 +254,6 @@ TisPcWaitRegisterBits (
@retval EFI_TIMEOUT BurstCount can't be got in time.
**/
EFI_STATUS
-EFIAPI
TisPcReadBurstCount (
IN TIS_PC_REGISTERS_PTR TisReg,
OUT UINT16 *BurstCount
@@ -299,7 +297,6 @@ TisPcReadBurstCount (
@retval EFI_TIMEOUT TPM chip can't be set to ready state in time.
**/
EFI_STATUS
-EFIAPI
TisPcPrepareCommand (
IN TIS_PC_REGISTERS_PTR TisReg
)
@@ -332,7 +329,6 @@ TisPcPrepareCommand (
@retval EFI_TIMEOUT Can't get the TPM control in time.
**/
EFI_STATUS
-EFIAPI
TisPcRequestUseTpm (
IN TIS_PC_REGISTERS_PTR TisReg
)
@@ -367,7 +363,6 @@ TisPcRequestUseTpm (
@param[in, out] SizeOut Size of response data.
@retval EFI_SUCCESS Operation completed successfully.
- @retval EFI_TIMEOUT The register can't run into the expected status in time.
@retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
@retval EFI_DEVICE_ERROR Unexpected device behavior.
@retval EFI_UNSUPPORTED Unsupported TPM version
@@ -392,7 +387,7 @@ TisTpmCommand (
DEBUG_CODE (
UINTN DebugSize;
- DEBUG ((EFI_D_INFO, "TisTpmCommand Send - "));
+ DEBUG ((EFI_D_INFO, "Tpm2TisTpmCommand Send - "));
if (SizeIn > 0x100) {
DebugSize = 0x40;
} else {
@@ -413,8 +408,8 @@ TisTpmCommand (
Status = TisPcPrepareCommand (TisReg);
if (EFI_ERROR (Status)){
- DEBUG ((DEBUG_ERROR, "Tpm is not ready for command!\n"));
- return Status;
+ DEBUG ((DEBUG_ERROR, "Tpm2 is not ready for command!\n"));
+ return EFI_DEVICE_ERROR;
}
//
// Send the command data to Tpm
@@ -423,7 +418,7 @@ TisTpmCommand (
while (Index < SizeIn) {
Status = TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
for (; BurstCount > 0 && Index < SizeIn; BurstCount--) {
@@ -441,7 +436,7 @@ TisTpmCommand (
TIS_TIMEOUT_C
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "The send buffer too small!\n"));
+ DEBUG ((DEBUG_ERROR, "Tpm2 The send buffer too small!\n"));
Status = EFI_BUFFER_TOO_SMALL;
goto Exit;
}
@@ -460,8 +455,8 @@ TisTpmCommand (
TIS_TIMEOUT_MAX
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Wait for Tpm response data time out!!\n"));
- Status = EFI_TIMEOUT;
+ DEBUG ((DEBUG_ERROR, "Wait for Tpm2 response data time out!!\n"));
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
//
@@ -472,7 +467,7 @@ TisTpmCommand (
while (Index < sizeof (TPM2_RESPONSE_HEADER)) {
Status = TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
for (; BurstCount > 0; BurstCount--) {
@@ -494,7 +489,7 @@ TisTpmCommand (
CopyMem (&Data16, BufferOut, sizeof (UINT16));
// TPM2 should not use this RSP_COMMAND
if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) {
- DEBUG ((EFI_D_ERROR, "TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));
+ DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND));
Status = EFI_UNSUPPORTED;
goto Exit;
}
@@ -520,13 +515,13 @@ TisTpmCommand (
}
Status = TisPcReadBurstCount (TisReg, &BurstCount);
if (EFI_ERROR (Status)) {
- Status = EFI_TIMEOUT;
+ Status = EFI_DEVICE_ERROR;
goto Exit;
}
}
Exit:
DEBUG_CODE (
- DEBUG ((EFI_D_INFO, "TisTpmCommand Receive - "));
+ DEBUG ((EFI_D_INFO, "Tpm2TisTpmCommand Receive - "));
for (Index = 0; Index < TpmOutSize; Index++) {
DEBUG ((EFI_D_INFO, "%02x ", BufferOut[Index]));
}