summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
authorgdong1 <gdong1@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-11 05:10:57 +0000
committergdong1 <gdong1@6f19259b-4bc3-4df7-8a09-765794883524>2012-05-11 05:10:57 +0000
commit82a1e09c83d53819c46b1d7fcb7a50905f411b7f (patch)
tree9bcd4e82584bcb3e8f13a6dc34e0a740f7f02287 /SecurityPkg
parente6063a9595b0aeda9086c85a1aeac162af289952 (diff)
downloadedk2-82a1e09c83d53819c46b1d7fcb7a50905f411b7f.tar.gz
Enhance TcgSmm driver to handle potential SetVariable failure case.
Signed-off-by: Dong Guo <guo.dong@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Yao Jiewen <jiewen.yao@intel.com> Reviewed-by: Ouyang Qian <qian.ouyang@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13309 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.c111
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.h110
-rw-r--r--SecurityPkg/Tcg/TcgSmm/TcgSmm.inf3
-rw-r--r--SecurityPkg/Tcg/TcgSmm/Tpm.asl11
4 files changed, 138 insertions, 97 deletions
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
index 0e18357b1..dd6d89f69 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c
@@ -2,7 +2,7 @@
It updates TPM items in ACPI table and registers SMI callback
functions for physical presence and ClearMemory.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2012, 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
@@ -13,54 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-
-#include <PiDxe.h>
-#include <IndustryStandard/Acpi.h>
-#include <Guid/PhysicalPresenceData.h>
-#include <Guid/MemoryOverwriteControl.h>
-#include <Protocol/SmmSwDispatch2.h>
-#include <Protocol/AcpiTable.h>
-#include <Protocol/SmmVariable.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/SmmServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DxeServicesLib.h>
-
-#pragma pack(1)
-typedef struct {
- UINT8 SoftwareSmi;
- UINT32 Parameter;
- UINT32 Response;
- UINT32 Request;
- UINT32 LastRequest;
- UINT32 ReturnCode;
-} PHYSICAL_PRESENCE_NVS;
-
-typedef struct {
- UINT8 SoftwareSmi;
- UINT32 Parameter;
- UINT32 Request;
-} MEMORY_CLEAR_NVS;
-
-typedef struct {
- PHYSICAL_PRESENCE_NVS PhysicalPresence;
- MEMORY_CLEAR_NVS MemoryClear;
-} TCG_NVS;
-
-typedef struct {
- UINT8 OpRegionOp;
- UINT32 NameString;
- UINT8 RegionSpace;
- UINT8 DWordPrefix;
- UINT32 RegionOffset;
- UINT8 BytePrefix;
- UINT8 RegionLen;
-} AML_OP_REGION_32_8;
-#pragma pack()
+#include "TcgSmm.h"
EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable;
TCG_NVS *mTcgNvs;
@@ -109,23 +62,16 @@ PhysicalPresenceCallback (
}
DEBUG ((EFI_D_INFO, "[TPM] PP callback, Parameter = %x\n", mTcgNvs->PhysicalPresence.Parameter));
- if (mTcgNvs->PhysicalPresence.Parameter == 5) {
- //
- // Return TPM Operation Response to OS Environment
- //
+ if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {
mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest;
mTcgNvs->PhysicalPresence.Response = PpData.PPResponse;
-
- } else if ((mTcgNvs->PhysicalPresence.Parameter == 2) || (mTcgNvs->PhysicalPresence.Parameter == 7)) {
- //
- // Submit TPM Operation Request to Pre-OS Environment
- //
-
+ } else if ((mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS)
+ || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2)) {
if (mTcgNvs->PhysicalPresence.Request == PHYSICAL_PRESENCE_SET_OPERATOR_AUTH) {
//
- // This command requires UI to prompt user for Auth data, NOT implemented.
+ // This command requires UI to prompt user for Auth data.
//
- mTcgNvs->PhysicalPresence.ReturnCode = 1;
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_NOT_IMPLEMENTED;
return EFI_SUCCESS;
}
@@ -142,17 +88,11 @@ PhysicalPresenceCallback (
}
if (EFI_ERROR (Status)) {
- //
- // General failure.
- //
- mTcgNvs->PhysicalPresence.ReturnCode = 2;
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;
return EFI_SUCCESS;
}
- mTcgNvs->PhysicalPresence.ReturnCode = 0;
- } else if (mTcgNvs->PhysicalPresence.Parameter == 8) {
- //
- // Get User Confirmation Status for Operation
- //
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;
+ } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {
Flags = PpData.Flags;
RequestConfirmed = FALSE;
@@ -202,22 +142,15 @@ PhysicalPresenceCallback (
case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:
//
// This command requires UI to prompt user for Auth data
- // Here it is NOT implemented
//
- mTcgNvs->PhysicalPresence.ReturnCode = 0;
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_NOT_IMPLEMENTED;
return EFI_SUCCESS;
}
if (RequestConfirmed) {
- //
- // Allowed and physically present user not required
- //
- mTcgNvs->PhysicalPresence.ReturnCode = 4;
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED;
} else {
- //
- // Allowed and physically present user required
- //
- mTcgNvs->PhysicalPresence.ReturnCode = 3;
+ mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED;
}
}
@@ -251,15 +184,10 @@ MemoryClearCallback (
UINTN DataSize;
UINT8 MorControl;
- if (mTcgNvs->MemoryClear.Parameter == 1) {
- //
- // Called from ACPI _DSM method, save the MOR data to variable.
- //
+ mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_SUCCESS;
+ if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE) {
MorControl = (UINT8) mTcgNvs->MemoryClear.Request;
- } else if (mTcgNvs->MemoryClear.Parameter == 2) {
- //
- // Called from ACPI _PTS method, setup ClearMemory flags if needed.
- //
+ } else if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_PTS_CLEAR_MOR_BIT) {
DataSize = sizeof (UINT8);
Status = mSmmVariable->SmmGetVariable (
MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
@@ -269,7 +197,6 @@ MemoryClearCallback (
&MorControl
);
if (EFI_ERROR (Status)) {
- ASSERT (Status == EFI_NOT_FOUND);
return EFI_SUCCESS;
}
@@ -287,7 +214,9 @@ MemoryClearCallback (
DataSize,
&MorControl
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;
+ }
return EFI_SUCCESS;
}
@@ -324,7 +253,6 @@ AssignOpRegion (
OpRegion = (AML_OP_REGION_32_8 *) ((UINT8 *) OpRegion + 1)) {
if ((OpRegion->OpRegionOp == AML_EXT_REGION_OP) &&
(OpRegion->NameString == Name) &&
- (OpRegion->RegionLen == Size) &&
(OpRegion->DWordPrefix == AML_DWORD_PREFIX) &&
(OpRegion->BytePrefix == AML_BYTE_PREFIX)) {
@@ -332,6 +260,7 @@ AssignOpRegion (
ASSERT_EFI_ERROR (Status);
ZeroMem ((VOID *)(UINTN)MemoryAddress, Size);
OpRegion->RegionOffset = (UINT32) (UINTN) MemoryAddress;
+ OpRegion->RegionLen = (UINT8) Size;
break;
}
}
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.h b/SecurityPkg/Tcg/TcgSmm/TcgSmm.h
new file mode 100644
index 000000000..1706132d3
--- /dev/null
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.h
@@ -0,0 +1,110 @@
+/** @file
+ The header file for TCG SMM driver.
+
+Copyright (c) 2012, 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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __TCG_SMM_H__
+#define __TCG_SMM_H__
+
+#include <PiDxe.h>
+#include <IndustryStandard/Acpi.h>
+#include <Guid/PhysicalPresenceData.h>
+#include <Guid/MemoryOverwriteControl.h>
+#include <Protocol/SmmSwDispatch2.h>
+#include <Protocol/AcpiTable.h>
+#include <Protocol/SmmVariable.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DxeServicesLib.h>
+
+#pragma pack(1)
+typedef struct {
+ UINT8 SoftwareSmi;
+ UINT32 Parameter;
+ UINT32 Response;
+ UINT32 Request;
+ UINT32 LastRequest;
+ UINT32 ReturnCode;
+} PHYSICAL_PRESENCE_NVS;
+
+typedef struct {
+ UINT8 SoftwareSmi;
+ UINT32 Parameter;
+ UINT32 Request;
+ UINT32 ReturnCode;
+} MEMORY_CLEAR_NVS;
+
+typedef struct {
+ PHYSICAL_PRESENCE_NVS PhysicalPresence;
+ MEMORY_CLEAR_NVS MemoryClear;
+} TCG_NVS;
+
+typedef struct {
+ UINT8 OpRegionOp;
+ UINT32 NameString;
+ UINT8 RegionSpace;
+ UINT8 DWordPrefix;
+ UINT32 RegionOffset;
+ UINT8 BytePrefix;
+ UINT8 RegionLen;
+} AML_OP_REGION_32_8;
+#pragma pack()
+
+//
+// The definition for TCG physical presence ACPI function
+//
+#define ACPI_FUNCTION_GET_PHYSICAL_PRESENCE_INTERFACE_VERSION 1
+#define ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS 2
+#define ACPI_FUNCTION_GET_PENDING_REQUEST_BY_OS 3
+#define ACPI_FUNCTION_GET_PLATFORM_ACTION_TO_TRANSITION_TO_BIOS 4
+#define ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS 5
+#define ACPI_FUNCTION_SUBMIT_PREFERRED_USER_LANGUAGE 6
+#define ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2 7
+#define ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST 8
+
+//
+// The return code for Get User Confirmation Status for Operation
+//
+#define PP_REQUEST_NOT_IMPLEMENTED 0
+#define PP_REQUEST_BIOS_ONLY 1
+#define PP_REQUEST_BLOCKED 2
+#define PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED 3
+#define PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED 4
+
+//
+// The return code for Sumbit TPM Request to Pre-OS Environment
+// and Sumbit TPM Request to Pre-OS Environment 2
+//
+#define PP_SUBMIT_REQUEST_SUCCESS 0
+#define PP_SUBMIT_REQUEST_NOT_IMPLEMENTED 1
+#define PP_SUBMIT_REQUEST_GENERAL_FAILURE 2
+#define PP_SUBMIT_REQUEST_BLOCKED_BY_BIOS_SETTINGS 3
+
+
+//
+// The definition for TCG MOR
+//
+#define ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE 1
+#define ACPI_FUNCTION_PTS_CLEAR_MOR_BIT 2
+
+//
+// The return code for Memory Clear Interface Functions
+//
+#define MOR_REQUEST_SUCCESS 0
+#define MOR_REQUEST_GENERAL_FAILURE 1
+
+#endif // __TCG_SMM_H__
diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf b/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
index c8e7092e7..9e5751a43 100644
--- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
@@ -3,7 +3,7 @@
# registers SMI callback functions for physical presence and
# MemoryClear to handle the requests from ACPI method.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, 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
@@ -24,6 +24,7 @@
[Sources]
TcgSmm.c
+ TcgSmm.h
Tpm.asl
[Packages]
diff --git a/SecurityPkg/Tcg/TcgSmm/Tpm.asl b/SecurityPkg/Tcg/TcgSmm/Tpm.asl
index 47a68ca61..6dafa0277 100644
--- a/SecurityPkg/Tcg/TcgSmm/Tpm.asl
+++ b/SecurityPkg/Tcg/TcgSmm/Tpm.asl
@@ -2,7 +2,7 @@
The TPM definition block in ACPI table for physical presence
and MemoryClear.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2012, 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
@@ -64,9 +64,9 @@ DefinitionBlock (
//
// Operational region for TPM support, TPM Physical Presence and TPM Memory Clear
- // Region Offset to be fixed at runtime
+ // Region Offset 0xFFFF0000 and Length 0xF0 will be fixed in C code.
//
- OperationRegion (TNVS, SystemMemory, 0xFFFF0000, 0x1E)
+ OperationRegion (TNVS, SystemMemory, 0xFFFF0000, 0xF0)
Field (TNVS, AnyAcc, NoLock, Preserve)
{
PPIN, 8, // Software SMI for Physical Presence Interface
@@ -77,7 +77,8 @@ DefinitionBlock (
FRET, 32, // Physical Presence function return code
MCIN, 8, // Software SMI for Memory Clear Interface
MCIP, 32, // Used for save the Mor paramter
- MORD, 32 // Memory Overwrite Request Data
+ MORD, 32, // Memory Overwrite Request Data
+ MRET, 32 // Memory Overwrite function return code
}
Method (PTS, 1, Serialized)
@@ -313,7 +314,7 @@ DefinitionBlock (
// Triggle the SMI interrupt
//
Store (MCIN, IOB2)
- Return (0)
+ Return (MRET)
}
Default {BreakPoint}
}