Add TPM Physical Presence >=128 operation value support.
authorYao, Jiewen <jiewen.yao@intel.com>
Mon, 12 Jan 2015 03:16:49 +0000 (03:16 +0000)
committerjyao1 <jyao1@Edk2>
Mon, 12 Jan 2015 03:16:49 +0000 (03:16 +0000)
The Tcg/TrEE PhysicalPresence library will depend on Tcg/TrEE PpVendor library.
The default NULL library instance is provided in this package.
OEM can create OemPpVendorLib as override to handle >=128 operation value.

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@16597 6f19259b-4bc3-4df7-8a09-765794883524

22 files changed:
SecurityPkg/Include/Guid/PhysicalPresenceData.h
SecurityPkg/Include/Guid/TrEEPhysicalPresenceData.h
SecurityPkg/Include/Library/TcgPpVendorLib.h [new file with mode: 0644]
SecurityPkg/Include/Library/TrEEPpVendorLib.h [new file with mode: 0644]
SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.inf
SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.c
SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf
SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.c [new file with mode: 0644]
SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.inf [new file with mode: 0644]
SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.uni [new file with mode: 0644]
SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.c [new file with mode: 0644]
SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.inf [new file with mode: 0644]
SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.uni [new file with mode: 0644]
SecurityPkg/SecurityPkg.dec
SecurityPkg/SecurityPkg.dsc
SecurityPkg/Tcg/TcgSmm/TcgSmm.c
SecurityPkg/Tcg/TcgSmm/TcgSmm.h
SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
SecurityPkg/Tcg/TrEESmm/TrEESmm.c
SecurityPkg/Tcg/TrEESmm/TrEESmm.h
SecurityPkg/Tcg/TrEESmm/TrEESmm.inf

index 9428657..165b464 100644 (file)
@@ -4,7 +4,7 @@
   cleared after it is processed in the next boot cycle. The TPM response \r
   is saved to variable.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -63,6 +63,9 @@ typedef struct {
 // It should be protected from malicious software (e.g. Set it as read-only variable). \r
 //\r
 #define PHYSICAL_PRESENCE_FLAGS_VARIABLE  L"PhysicalPresenceFlags"\r
+typedef struct {\r
+  UINT8   PPFlags;\r
+} EFI_PHYSICAL_PRESENCE_FLAGS;\r
 \r
 //\r
 // The definition bit of the TPM Management Flags\r
index 65750cd..0e2f8d1 100644 (file)
@@ -4,7 +4,7 @@
   cleared after it is processed in the next boot cycle. The TPM2 response \r
   is saved to variable.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -34,7 +34,9 @@ typedef struct {
 //\r
 // The definition bit of the flags\r
 //\r
+// BIT0 is reserved\r
 #define TREE_FLAG_NO_PPI_CLEAR                        BIT1\r
+// BIT2 is reserved\r
 #define TREE_FLAG_RESET_TRACK                         BIT3\r
 \r
 //\r
@@ -42,6 +44,9 @@ typedef struct {
 // It should be protected from malicious software (e.g. Set it as read-only variable). \r
 //\r
 #define TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE  L"TrEEPhysicalPresenceFlags"\r
+typedef struct {\r
+  UINT8   PPFlags;\r
+} EFI_TREE_PHYSICAL_PRESENCE_FLAGS;\r
 \r
 //\r
 // The definition of physical presence operation actions\r
diff --git a/SecurityPkg/Include/Library/TcgPpVendorLib.h b/SecurityPkg/Include/Library/TcgPpVendorLib.h
new file mode 100644 (file)
index 0000000..fd8c2e7
--- /dev/null
@@ -0,0 +1,159 @@
+/** @file\r
+  Ihis library is to support TCG Physical Presence Interface (PPI) specification\r
+  >= 128 Vendor Specific PPI Operation.\r
+\r
+  The Vendor Specific PPI operation may change TPM state, BIOS TPM management\r
+  flags, and may need additional boot cycle.\r
+  \r
+  Caution: This function may receive untrusted input.\r
+\r
+Copyright (c) 2015, 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
+\r
+#ifndef _TCG_PP_VENDOR_LIB_H_\r
+#define _TCG_PP_VENDOR_LIB_H_\r
+\r
+//\r
+// The definition of physical presence operation actions\r
+//\r
+#define TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION                         128\r
+\r
+//\r
+// The definition bit of the BIOS TPM Management Flags\r
+//\r
+#define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION                    BIT0\r
+#define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR                        BIT1\r
+#define TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE                  BIT2\r
+#define TCG_VENDOR_LIB_FLAG_RESET_TRACK                                  BIT3\r
+\r
+//\r
+// The definition for TPM Operation Response to OS Environment\r
+//\r
+#define TCG_PP_OPERATION_RESPONSE_SUCCESS              0x0\r
+#define TCG_PP_OPERATION_RESPONSE_USER_ABORT           0xFFFFFFF0\r
+#define TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE         0xFFFFFFF1\r
+\r
+//\r
+// The return code for Sumbit TPM Request to Pre-OS Environment\r
+// and Sumbit TPM Request to Pre-OS Environment 2\r
+//\r
+#define TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS                                  0\r
+#define TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED                          1\r
+#define TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE                          2\r
+#define TCG_PP_SUBMIT_REQUEST_TO_PREOS_BLOCKED_BY_BIOS_SETTINGS                 3\r
+\r
+//\r
+// The return code for Get User Confirmation Status for Operation\r
+//\r
+#define TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED                                 0\r
+#define TCG_PP_GET_USER_CONFIRMATION_BIOS_ONLY                                       1\r
+#define TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION                   2\r
+#define TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED                     3\r
+#define TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED                 4\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
+EFIAPI\r
+TcgPpVendorLibExecutePendingRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN OUT UINT32             *ManagementFlags,\r
+  OUT BOOLEAN               *ResetRequired\r
+  );\r
+\r
+/**\r
+  Check if there is a valid physical presence command request.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+  @param[out]     RequestConfirmed If the physical presence operation command required user confirm from UI.\r
+                                   True, it indicates the command doesn't require user confirm.\r
+                                   False, it indicates the command need user confirm from UI.\r
+\r
+  @retval  TRUE        Physical Presence operation command is valid.\r
+  @retval  FALSE       Physical Presence operation command is invalid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgPpVendorLibHasValidRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags,\r
+  OUT BOOLEAN               *RequestConfirmed\r
+  );\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Submit TPM Operation Request to Pre-OS Environment and\r
+  Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\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
+TcgPpVendorLibSubmitRequestToPreOSFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  );\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Get User Confirmation Status for Operation.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+\r
+  @return Return Code for Get User Confirmation Status for Operation.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgPpVendorLibGetUserConfirmationStatusFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  );\r
+\r
+#endif\r
diff --git a/SecurityPkg/Include/Library/TrEEPpVendorLib.h b/SecurityPkg/Include/Library/TrEEPpVendorLib.h
new file mode 100644 (file)
index 0000000..80c1bab
--- /dev/null
@@ -0,0 +1,164 @@
+/** @file\r
+  Ihis library is to support Trusted Execution Environment (TrEE) ACPI Profile\r
+  >= 128 Vendor Specific PPI Operation.\r
+\r
+  The Vendor Specific PPI operation may change TPM state, BIOS TPM management\r
+  flags, and may need additional boot cycle.\r
+  \r
+  Caution: This function may receive untrusted input.\r
+\r
+Copyright (c) 2015, 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
+\r
+#ifndef _TREE_PP_VENDOR_LIB_H_\r
+#define _TREE_PP_VENDOR_LIB_H_\r
+\r
+#include <IndustryStandard/Tpm20.h>\r
+#include <Protocol/TrEEProtocol.h>\r
+\r
+//\r
+// The definition of physical presence operation actions\r
+//\r
+#define TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION                         128\r
+\r
+//\r
+// The definition bit of the BIOS TPM Management Flags\r
+//\r
+// BIT0 is reserved\r
+#define TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR                        BIT1\r
+// BIT2 is reserved\r
+#define TREE_VENDOR_LIB_FLAG_RESET_TRACK                                  BIT3\r
+\r
+//\r
+// The definition for TPM Operation Response to OS Environment\r
+//\r
+#define TREE_PP_OPERATION_RESPONSE_SUCCESS              0x0\r
+#define TREE_PP_OPERATION_RESPONSE_USER_ABORT           0xFFFFFFF0\r
+#define TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE         0xFFFFFFF1\r
+\r
+//\r
+// The return code for Sumbit TPM Request to Pre-OS Environment\r
+// and Sumbit TPM Request to Pre-OS Environment 2\r
+//\r
+#define TREE_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS                                  0\r
+#define TREE_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED                          1\r
+#define TREE_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE                          2\r
+#define TREE_PP_SUBMIT_REQUEST_TO_PREOS_BLOCKED_BY_BIOS_SETTINGS                 3\r
+\r
+//\r
+// The return code for Get User Confirmation Status for Operation\r
+//\r
+#define TREE_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED                                 0\r
+#define TREE_PP_GET_USER_CONFIRMATION_BIOS_ONLY                                       1\r
+#define TREE_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION                   2\r
+#define TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED                     3\r
+#define TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED                 4\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]      PlatformAuth     platform auth value. NULL means no platform auth change.\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
+EFIAPI\r
+TrEEPpVendorLibExecutePendingRequest (\r
+  IN TPM2B_AUTH             *PlatformAuth,  OPTIONAL\r
+  IN UINT32                 OperationRequest,\r
+  IN OUT UINT32             *ManagementFlags,\r
+  OUT BOOLEAN               *ResetRequired\r
+  );\r
+\r
+/**\r
+  Check if there is a valid physical presence command request.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+  @param[out]     RequestConfirmed If the physical presence operation command required user confirm from UI.\r
+                                   True, it indicates the command doesn't require user confirm.\r
+                                   False, it indicates the command need user confirm from UI.\r
+\r
+  @retval  TRUE        Physical Presence operation command is valid.\r
+  @retval  FALSE       Physical Presence operation command is invalid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TrEEPpVendorLibHasValidRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags,\r
+  OUT BOOLEAN               *RequestConfirmed\r
+  );\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Submit TPM Operation Request to Pre-OS Environment and\r
+  Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\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
+TrEEPpVendorLibSubmitRequestToPreOSFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  );\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Get User Confirmation Status for Operation.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+\r
+  @return Return Code for Get User Confirmation Status for Operation.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TrEEPpVendorLibGetUserConfirmationStatusFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  );\r
+\r
+#endif\r
index 74a124c..7fbeb0a 100644 (file)
@@ -8,7 +8,7 @@
 \r
   ExecutePendingTpmRequest() will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -34,9 +34,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/HiiLib.h>\r
 #include <Guid/EventGroup.h>\r
 #include <Guid/PhysicalPresenceData.h>\r
+#include <Library/TcgPpVendorLib.h>\r
 \r
-#define TPM_PP_USER_ABORT           ((TPM_RESULT)(-0x10))\r
-#define TPM_PP_BIOS_FAILURE         ((TPM_RESULT)(-0x0f))\r
 #define CONFIRM_BUFFER_SIZE         4096\r
 \r
 EFI_HII_HANDLE mPpStringPackHandle;\r
@@ -184,12 +183,12 @@ TpmPhysicalPresence (
   @param[in] AdditionalParameterSize  Additional parameter size.  \r
   @param[in] AdditionalParameters     Pointer to the Additional paramaters.  \r
   \r
-  @retval TPM_PP_BIOS_FAILURE         Error occurred during sending command to TPM or \r
-                                      receiving response from TPM.\r
-  @retval Others                      Return code from the TPM device after command execution.\r
+  @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE  Error occurred during sending command to TPM or \r
+                                                  receiving response from TPM.\r
+  @retval Others                                  Return code from the TPM device after command execution.\r
 \r
 **/\r
-TPM_RESULT\r
+UINT32\r
 TpmCommandNoReturnData (\r
   IN      EFI_TCG_PROTOCOL          *TcgProtocol,\r
   IN      TPM_COMMAND_CODE          Ordinal,\r
@@ -204,7 +203,7 @@ TpmCommandNoReturnData (
 \r
   TpmRqu = (TPM_RQU_COMMAND_HDR*) AllocatePool (sizeof (*TpmRqu) + AdditionalParameterSize);\r
   if (TpmRqu == NULL) {\r
-    return TPM_PP_BIOS_FAILURE;\r
+    return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
   }\r
 \r
   TpmRqu->tag       = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
@@ -222,7 +221,7 @@ TpmCommandNoReturnData (
                           );\r
   FreePool (TpmRqu);\r
   if (EFI_ERROR (Status) || (TpmRsp.tag != SwapBytes16 (TPM_TAG_RSP_COMMAND))) {\r
-    return TPM_PP_BIOS_FAILURE;\r
+    return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
   }\r
   return SwapBytes32 (TpmRsp.returnCode);\r
 }\r
@@ -234,21 +233,21 @@ TpmCommandNoReturnData (
   @param[in]      CommandCode         Physical presence operation value.\r
   @param[in, out] PpiFlags            The physical presence interface flags.\r
   \r
-  @retval TPM_PP_BIOS_FAILURE         Unknown physical presence operation.\r
-  @retval TPM_PP_BIOS_FAILURE         Error occurred during sending command to TPM or \r
-                                      receiving response from TPM.\r
-  @retval Others                      Return code from the TPM device after command execution.\r
+  @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE  Unknown physical presence operation.\r
+  @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE  Error occurred during sending command to TPM or \r
+                                                  receiving response from TPM.\r
+  @retval Others                                  Return code from the TPM device after command execution.\r
 \r
 **/\r
-TPM_RESULT\r
+UINT32\r
 ExecutePhysicalPresence (\r
-  IN      EFI_TCG_PROTOCOL          *TcgProtocol,\r
-  IN      UINT8                     CommandCode,\r
-  IN OUT  UINT8                     *PpiFlags\r
+  IN      EFI_TCG_PROTOCOL            *TcgProtocol,\r
+  IN      UINT32                      CommandCode,\r
+  IN OUT  EFI_PHYSICAL_PRESENCE_FLAGS *PpiFlags\r
   )\r
 {\r
   BOOLEAN                           BoolVal;\r
-  TPM_RESULT                        TpmResponse;\r
+  UINT32                            TpmResponse;\r
   UINT32                            InData[5];\r
 \r
   switch (CommandCode) {\r
@@ -331,12 +330,12 @@ ExecutePhysicalPresence (
       // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE\r
       // PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE will be executed after reboot\r
       //\r
-      if ((*PpiFlags & FLAG_RESET_TRACK) == 0) {\r
+      if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
-        *PpiFlags |= FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       } else {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE, PpiFlags);\r
-        *PpiFlags &= ~FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       }\r
       return TpmResponse;\r
 \r
@@ -366,7 +365,7 @@ ExecutePhysicalPresence (
       // This command requires UI to prompt user for Auth data\r
       // Here it is NOT implemented\r
       //\r
-      return TPM_PP_BIOS_FAILURE;\r
+      return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
 \r
     case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:\r
       TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_CLEAR, PpiFlags);\r
@@ -376,27 +375,27 @@ ExecutePhysicalPresence (
       return TpmResponse;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:\r
-      *PpiFlags &= ~FLAG_NO_PPI_PROVISION;\r
+      PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;\r
       return 0;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:\r
-      *PpiFlags |= FLAG_NO_PPI_PROVISION;\r
+      PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;\r
       return 0;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:\r
-      *PpiFlags &= ~FLAG_NO_PPI_CLEAR;\r
+      PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;\r
       return 0;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:\r
-      *PpiFlags |= FLAG_NO_PPI_CLEAR;\r
+      PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;\r
       return 0;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:\r
-      *PpiFlags &= ~FLAG_NO_PPI_MAINTENANCE;\r
+      PpiFlags->PPFlags &= ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE;\r
       return 0;\r
 \r
     case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:\r
-      *PpiFlags |= FLAG_NO_PPI_MAINTENANCE;\r
+      PpiFlags->PPFlags |= TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE;\r
       return 0;\r
   \r
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:\r
@@ -404,12 +403,12 @@ ExecutePhysicalPresence (
       // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR\r
       // PHYSICAL_PRESENCE_CLEAR will be executed after reboot.\r
       //\r
-      if ((*PpiFlags & FLAG_RESET_TRACK) == 0) {\r
+      if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
-        *PpiFlags |= FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       } else {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_CLEAR, PpiFlags);\r
-        *PpiFlags &= ~FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       }\r
       return TpmResponse;\r
 \r
@@ -418,19 +417,19 @@ ExecutePhysicalPresence (
       // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE\r
       // PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE will be executed after reboot.\r
       //\r
-      if ((*PpiFlags & FLAG_RESET_TRACK) == 0) {\r
+      if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_ENABLE_ACTIVATE, PpiFlags);\r
-        *PpiFlags |= FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags |= TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       } else {\r
         TpmResponse = ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE, PpiFlags);\r
-        *PpiFlags &= ~FLAG_RESET_TRACK;\r
+        PpiFlags->PPFlags &= ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;\r
       } \r
       return TpmResponse;\r
 \r
     default:\r
       ;\r
   }\r
-  return TPM_PP_BIOS_FAILURE;\r
+  return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
 }\r
 \r
 \r
@@ -519,7 +518,7 @@ TcgPhysicalPresenceLibConstructor (
 **/\r
 BOOLEAN\r
 UserConfirm (\r
-  IN      UINT                    TpmPpCommand\r
+  IN      UINT32                    TpmPpCommand\r
   )\r
 {\r
   CHAR16                            *ConfirmText;\r
@@ -910,11 +909,12 @@ UserConfirm (
 **/\r
 BOOLEAN\r
 HaveValidTpmRequest  (\r
-  IN      EFI_PHYSICAL_PRESENCE     *TcgPpData,\r
-  IN      UINT8                     Flags,\r
-  OUT     BOOLEAN                   *RequestConfirmed\r
+  IN      EFI_PHYSICAL_PRESENCE       *TcgPpData,\r
+  IN      EFI_PHYSICAL_PRESENCE_FLAGS Flags,\r
+  OUT     BOOLEAN                     *RequestConfirmed\r
   )\r
 {\r
+  BOOLEAN  IsRequestValid;\r
 \r
   *RequestConfirmed = FALSE;\r
 \r
@@ -933,27 +933,27 @@ HaveValidTpmRequest  (
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:\r
     case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:\r
     case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:\r
-      if ((Flags & FLAG_NO_PPI_PROVISION) != 0) {\r
+      if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {\r
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
 \r
     case PHYSICAL_PRESENCE_CLEAR:\r
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:\r
-      if ((Flags & FLAG_NO_PPI_CLEAR) != 0) {\r
+      if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {\r
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
 \r
     case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:\r
-      if ((Flags & FLAG_NO_PPI_MAINTENANCE) != 0) {\r
+      if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE) != 0) {\r
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
 \r
     case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:\r
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:\r
-      if ((Flags & FLAG_NO_PPI_CLEAR) != 0 && (Flags & FLAG_NO_PPI_PROVISION) != 0) {\r
+      if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0 && (Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {\r
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
@@ -970,13 +970,22 @@ HaveValidTpmRequest  (
       break;\r
 \r
     default:\r
-      //\r
-      // Wrong Physical Presence command\r
-      //\r
-      return FALSE;\r
+      if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+        IsRequestValid = TcgPpVendorLibHasValidRequest (TcgPpData->PPRequest, Flags.PPFlags, RequestConfirmed);\r
+        if (!IsRequestValid) {\r
+          return FALSE;\r
+        } else {\r
+          break;\r
+        }\r
+      } else {\r
+        //\r
+        // Wrong Physical Presence command\r
+        //\r
+        return FALSE;\r
+      }\r
   }\r
 \r
-  if ((Flags & FLAG_RESET_TRACK) != 0) {\r
+  if ((Flags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) != 0) {\r
     //\r
     // It had been confirmed in last boot, it doesn't need confirm again.\r
     //\r
@@ -1004,21 +1013,23 @@ HaveValidTpmRequest  (
 **/\r
 VOID\r
 ExecutePendingTpmRequest (\r
-  IN      EFI_TCG_PROTOCOL          *TcgProtocol,\r
-  IN      EFI_PHYSICAL_PRESENCE     *TcgPpData,\r
-  IN      UINT8                     Flags\r
+  IN      EFI_TCG_PROTOCOL            *TcgProtocol,\r
+  IN      EFI_PHYSICAL_PRESENCE       *TcgPpData,\r
+  IN      EFI_PHYSICAL_PRESENCE_FLAGS Flags\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
   UINTN                             DataSize;\r
   BOOLEAN                           RequestConfirmed;\r
-  UINT8                             NewFlags;\r
+  EFI_PHYSICAL_PRESENCE_FLAGS       NewFlags;\r
+  BOOLEAN                           ResetRequired;\r
+  UINT32                            NewPPFlags;\r
 \r
   if (!HaveValidTpmRequest(TcgPpData, Flags, &RequestConfirmed)) {\r
     //\r
     // Invalid operation request.\r
     //\r
-    TcgPpData->PPResponse = TPM_PP_BIOS_FAILURE;\r
+    TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
     TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;\r
     DataSize = sizeof (EFI_PHYSICAL_PRESENCE);\r
@@ -1032,43 +1043,50 @@ ExecutePendingTpmRequest (
     return;\r
   }\r
 \r
-  if (!RequestConfirmed) {\r
+  ResetRequired = FALSE;\r
+  if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+    NewFlags = Flags;\r
+    NewPPFlags = NewFlags.PPFlags;\r
+    TcgPpData->PPResponse = TcgPpVendorLibExecutePendingRequest (TcgPpData->PPRequest, &NewPPFlags, &ResetRequired);\r
+    NewFlags.PPFlags = (UINT8)NewPPFlags;\r
+  } else {\r
+    if (!RequestConfirmed) {\r
+      //\r
+      // Print confirm text and wait for approval. \r
+      //\r
+      RequestConfirmed = UserConfirm (TcgPpData->PPRequest);\r
+    }\r
+\r
     //\r
-    // Print confirm text and wait for approval. \r
+    // Execute requested physical presence command\r
     //\r
-    RequestConfirmed = UserConfirm (TcgPpData->PPRequest);\r
-  }\r
-\r
-  //\r
-  // Execute requested physical presence command\r
-  //\r
-  TcgPpData->PPResponse = TPM_PP_USER_ABORT;\r
-  NewFlags = Flags;\r
-  if (RequestConfirmed) {\r
-    TcgPpData->PPResponse = ExecutePhysicalPresence (TcgProtocol, TcgPpData->PPRequest, &NewFlags);\r
+    TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;\r
+    NewFlags = Flags;\r
+    if (RequestConfirmed) {\r
+      TcgPpData->PPResponse = ExecutePhysicalPresence (TcgProtocol, TcgPpData->PPRequest, &NewFlags);\r
+    }\r
   }\r
 \r
   //\r
   // Save the flags if it is updated.\r
   //\r
-  if (Flags != NewFlags) {\r
+  if (CompareMem (&Flags, &NewFlags, sizeof(EFI_PHYSICAL_PRESENCE_FLAGS)) != 0) {\r
     Status   = gRT->SetVariable (\r
                       PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                       &gEfiPhysicalPresenceGuid,\r
                       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      sizeof (UINT8),\r
+                      sizeof (EFI_PHYSICAL_PRESENCE_FLAGS),\r
                       &NewFlags\r
                       ); \r
     if (EFI_ERROR (Status)) {\r
       return;\r
     }\r
   }\r
-\r
-\r
+  \r
   //\r
   // Clear request\r
   //\r
-  if ((NewFlags & FLAG_RESET_TRACK) == 0) {\r
+  if ((NewFlags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
     TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;    \r
   }\r
@@ -1088,7 +1106,7 @@ ExecutePendingTpmRequest (
     return;\r
   }\r
 \r
-  if (TcgPpData->PPResponse == TPM_PP_USER_ABORT) {\r
+  if (TcgPpData->PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {\r
     return;\r
   }\r
 \r
@@ -1109,6 +1127,13 @@ ExecutePendingTpmRequest (
     case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:      \r
       break;\r
     default:\r
+      if (TcgPpData->LastPPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+        if (ResetRequired) {\r
+          break;\r
+        } else {\r
+          return ;\r
+        }\r
+      }\r
       if (TcgPpData->PPRequest != PHYSICAL_PRESENCE_NO_ACTION) {\r
         break;\r
       }\r
@@ -1146,7 +1171,7 @@ TcgPhysicalPresenceLibProcessRequest (
   EFI_PHYSICAL_PRESENCE             TcgPpData;\r
   EFI_TCG_PROTOCOL                  *TcgProtocol;\r
   EDKII_VARIABLE_LOCK_PROTOCOL      *VariableLockProtocol;\r
-  UINT8                             PpiFlags;\r
+  EFI_PHYSICAL_PRESENCE_FLAGS       PpiFlags;\r
   \r
   Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);\r
   if (EFI_ERROR (Status)) {\r
@@ -1156,7 +1181,7 @@ TcgPhysicalPresenceLibProcessRequest (
   //\r
   // Initialize physical presence flags.\r
   //\r
-  DataSize = sizeof (UINT8);\r
+  DataSize = sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);\r
   Status = gRT->GetVariable (\r
                   PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                   &gEfiPhysicalPresenceGuid,\r
@@ -1165,12 +1190,12 @@ TcgPhysicalPresenceLibProcessRequest (
                   &PpiFlags\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    PpiFlags = FLAG_NO_PPI_PROVISION;\r
+    PpiFlags.PPFlags = TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;\r
     Status   = gRT->SetVariable (\r
                       PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                       &gEfiPhysicalPresenceGuid,\r
                       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      sizeof (UINT8),\r
+                      sizeof (EFI_PHYSICAL_PRESENCE_FLAGS),\r
                       &PpiFlags\r
                       );\r
     if (EFI_ERROR (Status)) {\r
@@ -1178,7 +1203,7 @@ TcgPhysicalPresenceLibProcessRequest (
       return ;\r
     }\r
   }\r
-  DEBUG ((EFI_D_INFO, "[TPM] PpiFlags = %x\n", PpiFlags));\r
+  DEBUG ((EFI_D_INFO, "[TPM] PpiFlags = %x\n", PpiFlags.PPFlags));\r
 \r
   //\r
   // This flags variable controls whether physical presence is required for TPM command. \r
@@ -1224,7 +1249,7 @@ TcgPhysicalPresenceLibProcessRequest (
     }\r
   }\r
 \r
-  DEBUG ((EFI_D_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags, TcgPpData.PPRequest));\r
+  DEBUG ((EFI_D_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, TcgPpData.PPRequest));\r
 \r
   if (TcgPpData.PPRequest == PHYSICAL_PRESENCE_NO_ACTION) {\r
     //\r
@@ -1284,14 +1309,14 @@ TcgPhysicalPresenceLibNeedUserConfirm(
   VOID\r
   )\r
 {\r
-  EFI_STATUS              Status;\r
-  EFI_PHYSICAL_PRESENCE   TcgPpData;\r
-  UINTN                   DataSize;\r
-  BOOLEAN                 RequestConfirmed;\r
-  BOOLEAN                 LifetimeLock;\r
-  BOOLEAN                 CmdEnable;\r
-  EFI_TCG_PROTOCOL        *TcgProtocol;\r
-  UINT8                   PpiFlags;\r
+  EFI_STATUS                   Status;\r
+  EFI_PHYSICAL_PRESENCE        TcgPpData;\r
+  UINTN                        DataSize;\r
+  BOOLEAN                      RequestConfirmed;\r
+  BOOLEAN                      LifetimeLock;\r
+  BOOLEAN                      CmdEnable;\r
+  EFI_TCG_PROTOCOL             *TcgProtocol;\r
+  EFI_PHYSICAL_PRESENCE_FLAGS  PpiFlags;\r
   \r
   Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);\r
   if (EFI_ERROR (Status)) {\r
@@ -1313,7 +1338,7 @@ TcgPhysicalPresenceLibNeedUserConfirm(
     return FALSE;\r
   }\r
 \r
-  DataSize = sizeof (UINT8);\r
+  DataSize = sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);\r
   Status = gRT->GetVariable (\r
                   PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                   &gEfiPhysicalPresenceGuid,\r
index ed6b03f..b48b887 100644 (file)
@@ -9,7 +9,7 @@
 #  This driver will have external input - variable.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2015, 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
@@ -54,6 +54,7 @@
   DebugLib\r
   PrintLib\r
   HiiLib\r
+  TcgPpVendorLib\r
 \r
 [Protocols]\r
   gEfiTcgProtocolGuid                   ## CONSUMES\r
index 89ce436..9ff9d88 100644 (file)
@@ -7,7 +7,7 @@
 \r
   TrEEExecutePendingTpmRequest() will receive untrusted input and do validation.\r
 \r
-Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -34,10 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/EventGroup.h>\r
 #include <Guid/TrEEPhysicalPresenceData.h>\r
 #include <Library/Tpm2CommandLib.h>\r
-\r
-#define TPM_PP_SUCCESS              0\r
-#define TPM_PP_USER_ABORT           ((TPM_RESULT)(-0x10))\r
-#define TPM_PP_BIOS_FAILURE         ((TPM_RESULT)(-0x0f))\r
+#include <Library/TrEEPpVendorLib.h>\r
 \r
 #define CONFIRM_BUFFER_SIZE         4096\r
 \r
@@ -113,16 +110,16 @@ Done:
   @param[in]      CommandCode         Physical presence operation value.\r
   @param[in, out] PpiFlags            The physical presence interface flags.\r
   \r
-  @retval TPM_PP_BIOS_FAILURE         Unknown physical presence operation.\r
-  @retval TPM_PP_BIOS_FAILURE         Error occurred during sending command to TPM or \r
-                                      receiving response from TPM.\r
-  @retval Others                      Return code from the TPM device after command execution.\r
+  @retval TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE  Unknown physical presence operation.\r
+  @retval TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE  Error occurred during sending command to TPM or \r
+                                                   receiving response from TPM.\r
+  @retval Others                                   Return code from the TPM device after command execution.\r
 **/\r
-TPM_RESULT\r
+UINT32\r
 TrEEExecutePhysicalPresence (\r
-  IN      TPM2B_AUTH                *PlatformAuth,  OPTIONAL\r
-  IN      UINT8                     CommandCode,\r
-  IN OUT  UINT8                     *PpiFlags\r
+  IN      TPM2B_AUTH                       *PlatformAuth,  OPTIONAL\r
+  IN      UINT32                           CommandCode,\r
+  IN OUT  EFI_TREE_PHYSICAL_PRESENCE_FLAGS *PpiFlags\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -134,24 +131,24 @@ TrEEExecutePhysicalPresence (
     case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:\r
       Status = TpmCommandClear (PlatformAuth);\r
       if (EFI_ERROR (Status)) {\r
-        return TPM_PP_BIOS_FAILURE;\r
+        return TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
       } else {\r
-        return TPM_PP_SUCCESS;\r
+        return TREE_PP_OPERATION_RESPONSE_SUCCESS;\r
       }\r
 \r
     case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:\r
-      *PpiFlags &= ~TREE_FLAG_NO_PPI_CLEAR;\r
-      return TPM_PP_SUCCESS;\r
+      PpiFlags->PPFlags &= ~TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;\r
+      return TREE_PP_OPERATION_RESPONSE_SUCCESS;\r
 \r
     case TREE_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:\r
-      *PpiFlags |= TREE_FLAG_NO_PPI_CLEAR;\r
-      return TPM_PP_SUCCESS;\r
+      PpiFlags->PPFlags |= TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;\r
+      return TREE_PP_OPERATION_RESPONSE_SUCCESS;\r
 \r
     default:\r
       if (CommandCode <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
-        return TPM_PP_SUCCESS;\r
+        return TREE_PP_OPERATION_RESPONSE_SUCCESS;\r
       } else {\r
-        return TPM_PP_BIOS_FAILURE;\r
+        return TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
       }\r
   }\r
 }\r
@@ -233,7 +230,7 @@ TrEEPhysicalPresenceLibConstructor (
 **/\r
 BOOLEAN\r
 TrEEUserConfirm (\r
-  IN      UINT                    TpmPpCommand\r
+  IN      UINT32                    TpmPpCommand\r
   )\r
 {\r
   CHAR16                            *ConfirmText;\r
@@ -346,11 +343,13 @@ TrEEUserConfirm (
 **/\r
 BOOLEAN\r
 TrEEHaveValidTpmRequest  (\r
-  IN      EFI_TREE_PHYSICAL_PRESENCE     *TcgPpData,\r
-  IN      UINT8                          Flags,\r
-  OUT     BOOLEAN                        *RequestConfirmed\r
+  IN      EFI_TREE_PHYSICAL_PRESENCE       *TcgPpData,\r
+  IN      EFI_TREE_PHYSICAL_PRESENCE_FLAGS Flags,\r
+  OUT     BOOLEAN                          *RequestConfirmed\r
   )\r
 {\r
+  BOOLEAN  IsRequestValid;\r
+\r
   *RequestConfirmed = FALSE;\r
 \r
   switch (TcgPpData->PPRequest) {\r
@@ -361,7 +360,7 @@ TrEEHaveValidTpmRequest  (
     case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:\r
     case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:\r
     case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:\r
-      if ((Flags & TREE_FLAG_NO_PPI_CLEAR) != 0) {\r
+      if ((Flags.PPFlags & TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {\r
         *RequestConfirmed = TRUE;\r
       }\r
       break;\r
@@ -374,13 +373,22 @@ TrEEHaveValidTpmRequest  (
       break;\r
 \r
     default:\r
-      //\r
-      // Wrong Physical Presence command\r
-      //\r
-      return FALSE;\r
+      if (TcgPpData->PPRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+        IsRequestValid = TrEEPpVendorLibHasValidRequest (TcgPpData->PPRequest, Flags.PPFlags, RequestConfirmed);\r
+        if (!IsRequestValid) {\r
+          return FALSE;\r
+        } else {\r
+          break;\r
+        }\r
+      } else {\r
+        //\r
+        // Wrong Physical Presence command\r
+        //\r
+        return FALSE;\r
+      }\r
   }\r
 \r
-  if ((Flags & TREE_FLAG_RESET_TRACK) != 0) {\r
+  if ((Flags.PPFlags & TREE_VENDOR_LIB_FLAG_RESET_TRACK) != 0) {\r
     //\r
     // It had been confirmed in last boot, it doesn't need confirm again.\r
     //\r
@@ -407,15 +415,17 @@ TrEEHaveValidTpmRequest  (
 **/\r
 VOID\r
 TrEEExecutePendingTpmRequest (\r
-  IN      TPM2B_AUTH                     *PlatformAuth,  OPTIONAL\r
-  IN      EFI_TREE_PHYSICAL_PRESENCE     *TcgPpData,\r
-  IN      UINT8                          Flags\r
+  IN      TPM2B_AUTH                       *PlatformAuth,  OPTIONAL\r
+  IN      EFI_TREE_PHYSICAL_PRESENCE       *TcgPpData,\r
+  IN      EFI_TREE_PHYSICAL_PRESENCE_FLAGS Flags\r
   )\r
 {\r
   EFI_STATUS                        Status;\r
   UINTN                             DataSize;\r
   BOOLEAN                           RequestConfirmed;\r
-  UINT8                             NewFlags;\r
+  EFI_TREE_PHYSICAL_PRESENCE_FLAGS  NewFlags;\r
+  BOOLEAN                           ResetRequired;\r
+  UINT32                            NewPPFlags;\r
 \r
   if (TcgPpData->PPRequest == TREE_PHYSICAL_PRESENCE_NO_ACTION) {\r
     //\r
@@ -429,9 +439,9 @@ TrEEExecutePendingTpmRequest (
     // Invalid operation request.\r
     //\r
     if (TcgPpData->PPRequest <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
-      TcgPpData->PPResponse = TPM_PP_SUCCESS;\r
+      TcgPpData->PPResponse = TREE_PP_OPERATION_RESPONSE_SUCCESS;\r
     } else {\r
-      TcgPpData->PPResponse = TPM_PP_BIOS_FAILURE;\r
+      TcgPpData->PPResponse = TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
     }\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
     TcgPpData->PPRequest = TREE_PHYSICAL_PRESENCE_NO_ACTION;\r
@@ -446,33 +456,41 @@ TrEEExecutePendingTpmRequest (
     return;\r
   }\r
 \r
-  if (!RequestConfirmed) {\r
+  ResetRequired = FALSE;\r
+  if (TcgPpData->PPRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+    NewFlags = Flags;\r
+    NewPPFlags = NewFlags.PPFlags;\r
+    TcgPpData->PPResponse = TrEEPpVendorLibExecutePendingRequest (PlatformAuth, TcgPpData->PPRequest, &NewPPFlags, &ResetRequired);\r
+    NewFlags.PPFlags = (UINT8)NewPPFlags;\r
+  } else {\r
+    if (!RequestConfirmed) {\r
+      //\r
+      // Print confirm text and wait for approval. \r
+      //\r
+      RequestConfirmed = TrEEUserConfirm (TcgPpData->PPRequest\r
+                                          );\r
+    }\r
+\r
     //\r
-    // Print confirm text and wait for approval. \r
+    // Execute requested physical presence command\r
     //\r
-    RequestConfirmed = TrEEUserConfirm (TcgPpData->PPRequest\r
-                                        );\r
-  }\r
-\r
-  //\r
-  // Execute requested physical presence command\r
-  //\r
-  TcgPpData->PPResponse = TPM_PP_USER_ABORT;\r
-  NewFlags = Flags;\r
-  if (RequestConfirmed) {\r
-    TcgPpData->PPResponse = TrEEExecutePhysicalPresence (PlatformAuth, TcgPpData->PPRequest, \r
-                                                         &NewFlags);\r
+    TcgPpData->PPResponse = TREE_PP_OPERATION_RESPONSE_USER_ABORT;\r
+    NewFlags = Flags;\r
+    if (RequestConfirmed) {\r
+      TcgPpData->PPResponse = TrEEExecutePhysicalPresence (PlatformAuth, TcgPpData->PPRequest, \r
+                                                           &NewFlags);\r
+    }\r
   }\r
 \r
   //\r
   // Save the flags if it is updated.\r
   //\r
-  if (Flags != NewFlags) {\r
+  if (CompareMem (&Flags, &NewFlags, sizeof(EFI_TREE_PHYSICAL_PRESENCE_FLAGS)) != 0) {\r
     Status   = gRT->SetVariable (\r
                       TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                       &gEfiTrEEPhysicalPresenceGuid,\r
                       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      sizeof (UINT8),\r
+                      sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS),\r
                       &NewFlags\r
                       ); \r
   }\r
@@ -480,7 +498,7 @@ TrEEExecutePendingTpmRequest (
   //\r
   // Clear request\r
   //\r
-  if ((NewFlags & TREE_FLAG_RESET_TRACK) == 0) {\r
+  if ((NewFlags.PPFlags & TREE_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {\r
     TcgPpData->LastPPRequest = TcgPpData->PPRequest;\r
     TcgPpData->PPRequest = TREE_PHYSICAL_PRESENCE_NO_ACTION;    \r
   }\r
@@ -500,7 +518,7 @@ TrEEExecutePendingTpmRequest (
     return;\r
   }\r
 \r
-  if (TcgPpData->PPResponse == TPM_PP_USER_ABORT) {\r
+  if (TcgPpData->PPResponse == TREE_PP_OPERATION_RESPONSE_USER_ABORT) {\r
     return;\r
   }\r
 \r
@@ -514,6 +532,13 @@ TrEEExecutePendingTpmRequest (
     case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:\r
       break;\r
     default:\r
+      if (TcgPpData->LastPPRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+        if (ResetRequired) {\r
+          break;\r
+        } else {\r
+          return ;\r
+        }\r
+      }\r
       if (TcgPpData->PPRequest != TREE_PHYSICAL_PRESENCE_NO_ACTION) {\r
         break;\r
       }\r
@@ -549,7 +574,7 @@ TrEEPhysicalPresenceLibProcessRequest (
   EFI_TREE_PHYSICAL_PRESENCE        TcgPpData;\r
   EFI_TREE_PROTOCOL                 *TreeProtocol;\r
   EDKII_VARIABLE_LOCK_PROTOCOL      *VariableLockProtocol;\r
-  UINT8                             PpiFlags;\r
+  EFI_TREE_PHYSICAL_PRESENCE_FLAGS  PpiFlags;\r
 \r
   Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);\r
   if (EFI_ERROR (Status)) {\r
@@ -559,7 +584,7 @@ TrEEPhysicalPresenceLibProcessRequest (
   //\r
   // Initialize physical presence flags.\r
   //\r
-  DataSize = sizeof (UINT8);\r
+  DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS);\r
   Status = gRT->GetVariable (\r
                   TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                   &gEfiTrEEPhysicalPresenceGuid,\r
@@ -568,12 +593,12 @@ TrEEPhysicalPresenceLibProcessRequest (
                   &PpiFlags\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    PpiFlags = 0;\r
+    PpiFlags.PPFlags = 0;\r
     Status   = gRT->SetVariable (\r
                       TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                       &gEfiTrEEPhysicalPresenceGuid,\r
                       EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                      sizeof (UINT8),\r
+                      sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS),\r
                       &PpiFlags\r
                       );\r
     if (EFI_ERROR (Status)) {\r
@@ -581,7 +606,7 @@ TrEEPhysicalPresenceLibProcessRequest (
       return ;\r
     }\r
   }\r
-  DEBUG ((EFI_D_INFO, "[TPM2] PpiFlags = %x\n", PpiFlags));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] PpiFlags = %x\n", PpiFlags.PPFlags));\r
 \r
   //\r
   // This flags variable controls whether physical presence is required for TPM command. \r
@@ -627,13 +652,13 @@ TrEEPhysicalPresenceLibProcessRequest (
     }\r
   }\r
 \r
-  DEBUG ((EFI_D_INFO, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest));\r
 \r
   //\r
   // Execute pending TPM request.\r
   //  \r
   TrEEExecutePendingTpmRequest (PlatformAuth, &TcgPpData, PpiFlags);\r
-  DEBUG ((EFI_D_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags));\r
+  DEBUG ((EFI_D_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags));\r
 \r
 }\r
 \r
@@ -658,7 +683,7 @@ TrEEPhysicalPresenceLibNeedUserConfirm(
   UINTN                             DataSize;\r
   BOOLEAN                           RequestConfirmed;\r
   EFI_TREE_PROTOCOL                 *TreeProtocol;\r
-  UINT8                             PpiFlags;\r
+  EFI_TREE_PHYSICAL_PRESENCE_FLAGS  PpiFlags;\r
 \r
   Status = gBS->LocateProtocol (&gEfiTrEEProtocolGuid, NULL, (VOID **) &TreeProtocol);\r
   if (EFI_ERROR (Status)) {\r
@@ -680,7 +705,7 @@ TrEEPhysicalPresenceLibNeedUserConfirm(
     return FALSE;\r
   }\r
 \r
-  DataSize = sizeof (UINT8);\r
+  DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS);\r
   Status = gRT->GetVariable (\r
                   TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                   &gEfiTrEEPhysicalPresenceGuid,\r
index 5d062ae..0612226 100644 (file)
@@ -8,7 +8,7 @@
 #  This driver will have external input - variable.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2015, 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
@@ -54,6 +54,7 @@
   PrintLib\r
   HiiLib\r
   Tpm2CommandLib\r
+  TrEEPpVendorLib\r
 \r
 [Protocols]\r
   gEfiTrEEProtocolGuid                 ## CONSUMES\r
diff --git a/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.c b/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.c
new file mode 100644 (file)
index 0000000..ddd6d72
--- /dev/null
@@ -0,0 +1,129 @@
+/** @file\r
+  NULL TCG PP Vendor library instance that does not support any vendor specific PPI.\r
+\r
+Copyright (c) 2015, 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
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/TcgPpVendorLib.h>\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
+EFIAPI\r
+TcgPpVendorLibExecutePendingRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN OUT UINT32             *ManagementFlags,\r
+  OUT BOOLEAN               *ResetRequired\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
+}\r
+\r
+/**\r
+  Check if there is a valid physical presence command request.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+  @param[out]     RequestConfirmed If the physical presence operation command required user confirm from UI.\r
+                                   True, it indicates the command doesn't require user confirm.\r
+                                   False, it indicates the command need user confirm from UI.\r
+\r
+  @retval  TRUE        Physical Presence operation command is valid.\r
+  @retval  FALSE       Physical Presence operation command is invalid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgPpVendorLibHasValidRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags,\r
+  OUT BOOLEAN               *RequestConfirmed\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Submit TPM Operation Request to Pre-OS Environment and\r
+  Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\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
+TcgPpVendorLibSubmitRequestToPreOSFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
+}\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Get User Confirmation Status for Operation.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+\r
+  @return Return Code for Get User Confirmation Status for Operation.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TcgPpVendorLibGetUserConfirmationStatusFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+}\r
diff --git a/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.inf b/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.inf
new file mode 100644 (file)
index 0000000..9674386
--- /dev/null
@@ -0,0 +1,37 @@
+## @file\r
+#  NULL TCG PP Vendor library instance that does not support any vendor specific PPI\r
+#\r
+# Copyright (c) 2015, 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
+# 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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = TcgPpVendorLibNull\r
+  MODULE_UNI_FILE                = TcgPpVendorLibNull.uni\r
+  FILE_GUID                      = 8489334D-4219-4CA1-9B42-1D46B0B75861\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TcgPpVendorLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_DRIVER\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  TcgPpVendorLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  SecurityPkg/SecurityPkg.dec\r
+  \r
+[LibraryClasses]\r
+  DebugLib
\ No newline at end of file
diff --git a/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.uni b/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.uni
new file mode 100644 (file)
index 0000000..e840a3d
Binary files /dev/null and b/SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.uni differ
diff --git a/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.c b/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.c
new file mode 100644 (file)
index 0000000..efd477a
--- /dev/null
@@ -0,0 +1,131 @@
+/** @file\r
+  NULL TrEE PP Vendor library instance that does not support any vendor specific PPI.\r
+\r
+Copyright (c) 2015, 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
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/TrEEPpVendorLib.h>\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]      PlatformAuth     platform auth value. NULL means no platform auth change.\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
+EFIAPI\r
+TrEEPpVendorLibExecutePendingRequest (\r
+  IN TPM2B_AUTH             *PlatformAuth,  OPTIONAL\r
+  IN UINT32                 OperationRequest,\r
+  IN OUT UINT32             *ManagementFlags,\r
+  OUT BOOLEAN               *ResetRequired\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TREE_PP_OPERATION_RESPONSE_BIOS_FAILURE;\r
+}\r
+\r
+/**\r
+  Check if there is a valid physical presence command request.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+  @param[out]     RequestConfirmed If the physical presence operation command required user confirm from UI.\r
+                                   True, it indicates the command doesn't require user confirm.\r
+                                   False, it indicates the command need user confirm from UI.\r
+\r
+  @retval  TRUE        Physical Presence operation command is valid.\r
+  @retval  FALSE       Physical Presence operation command is invalid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TrEEPpVendorLibHasValidRequest (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags,\r
+  OUT BOOLEAN               *RequestConfirmed\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Submit TPM Operation Request to Pre-OS Environment and\r
+  Submit TPM Operation Request to Pre-OS Environment 2.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\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
+TrEEPpVendorLibSubmitRequestToPreOSFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TREE_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
+}\r
+\r
+/**\r
+  The callback for TPM vendor specific physical presence which is called for\r
+  Get User Confirmation Status for Operation.\r
+\r
+  This API should be invoked in OS runtime phase to interface with ACPI method.\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]      ManagementFlags  BIOS TPM Management Flags.\r
+\r
+  @return Return Code for Get User Confirmation Status for Operation.\r
+**/\r
+UINT32\r
+EFIAPI\r
+TrEEPpVendorLibGetUserConfirmationStatusFunction (\r
+  IN UINT32                 OperationRequest,\r
+  IN UINT32                 ManagementFlags\r
+  )\r
+{\r
+  ASSERT (OperationRequest >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION);\r
+  return TREE_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;\r
+}\r
diff --git a/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.inf b/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.inf
new file mode 100644 (file)
index 0000000..81144e9
--- /dev/null
@@ -0,0 +1,37 @@
+## @file\r
+#  NULL TrEE PP Vendor library instance that does not support any vendor specific PPI\r
+#\r
+# Copyright (c) 2015, 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
+# 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
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = TrEEPpVendorLibNull\r
+  MODULE_UNI_FILE                = TrEEPpVendorLibNull.uni\r
+  FILE_GUID                      = FB76E42B-EA77-48F3-A61D-208FF0535F92\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TrEEPpVendorLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_DRIVER\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  TrEEPpVendorLibNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  SecurityPkg/SecurityPkg.dec\r
+  \r
+[LibraryClasses]\r
+  DebugLib
\ No newline at end of file
diff --git a/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.uni b/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.uni
new file mode 100644 (file)
index 0000000..7e6ef74
Binary files /dev/null and b/SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.uni differ
index 670df13..7bbc1e6 100644 (file)
@@ -5,7 +5,7 @@
 #  It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library classes)\r
 #  and libraries instances, which are used for those features.\r
 #\r
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under\r
 # the terms and conditions of the BSD License which accompanies this distribution.\r
 # The full text of the license may be found at\r
   #\r
   TcgPhysicalPresenceLib|Include/Library/TcgPhysicalPresenceLib.h\r
   \r
+  ##  @libraryclass  Provides support for TCG PP >= 128 Vendor Specific PPI Operation.\r
+  #\r
+  TcgPpVendorLib|Include/Library/TcgPpVendorLib.h\r
+  \r
   ##  @libraryclass  Provides interfaces for other modules to send TPM 2.0 command.\r
   #\r
   Tpm2CommandLib|Include/Library/Tpm2CommandLib.h\r
   ##  @libraryclass  Provides interfaces to handle TPM 2.0 request.\r
   #\r
   TrEEPhysicalPresenceLib|Include/Library/TrEEPhysicalPresenceLib.h\r
+  \r
+  ##  @libraryclass  Provides support for TrEE PP >= 128 Vendor Specific PPI Operation.\r
+  #\r
+  TrEEPpVendorLib|Include/Library/TrEEPpVendorLib.h\r
 \r
 [Guids]\r
   ## Security package token space guid.\r
index d0b44cf..a8b0a29 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Security Module Package for All Architectures.\r
 #\r
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2015, 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
@@ -55,6 +55,8 @@
   Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf\r
   Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf\r
   TrEEPhysicalPresenceLib|SecurityPkg/Library/DxeTrEEPhysicalPresenceLib/DxeTrEEPhysicalPresenceLib.inf\r
+  TcgPpVendorLib|SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.inf\r
+  TrEEPpVendorLib|SecurityPkg/Library/TrEEPpVendorLibNull/TrEEPpVendorLibNull.inf\r
 \r
 [LibraryClasses.common.PEIM]\r
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
index 6080eff..96fb456 100644 (file)
@@ -8,7 +8,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2015, 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
@@ -53,7 +53,7 @@ PhysicalPresenceCallback (
   EFI_STATUS                     Status;\r
   UINTN                          DataSize;\r
   EFI_PHYSICAL_PRESENCE          PpData;\r
-  UINT8                          Flags;\r
+  EFI_PHYSICAL_PRESENCE_FLAGS    Flags;\r
   BOOLEAN                        RequestConfirmed;\r
 \r
   //\r
@@ -67,23 +67,31 @@ PhysicalPresenceCallback (
                            &DataSize,\r
                            &PpData\r
                            );\r
-  if (EFI_ERROR (Status)) {\r
-    mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
-    DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
-    return EFI_SUCCESS;\r
-  }\r
 \r
   DEBUG ((EFI_D_INFO, "[TPM] PP callback, Parameter = %x\n", mTcgNvs->PhysicalPresence.Parameter));\r
   if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode  = PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
+      mTcgNvs->PhysicalPresence.LastRequest = 0;\r
+      mTcgNvs->PhysicalPresence.Response    = 0;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
+    mTcgNvs->PhysicalPresence.ReturnCode  = PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
     mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest;\r
     mTcgNvs->PhysicalPresence.Response    = PpData.PPResponse;\r
   } else if ((mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS) \r
           || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2)) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
     if (mTcgNvs->PhysicalPresence.Request == PHYSICAL_PRESENCE_SET_OPERATOR_AUTH) {\r
       //\r
       // This command requires UI to prompt user for Auth data.\r
       //\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_NOT_IMPLEMENTED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -100,15 +108,35 @@ PhysicalPresenceCallback (
     }\r
 \r
     if (EFI_ERROR (Status)) { \r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
       return EFI_SUCCESS;\r
     }\r
-    mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;\r
+    mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r
+\r
+    if (mTcgNvs->PhysicalPresence.Request >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+      DataSize = sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);\r
+      Status = mSmmVariable->SmmGetVariable (\r
+                               PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                               &gEfiPhysicalPresenceGuid,\r
+                               NULL,\r
+                               &DataSize,\r
+                               &Flags\r
+                               );\r
+      if (EFI_ERROR (Status)) {\r
+        Flags.PPFlags = TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;\r
+      }\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TcgPpVendorLibSubmitRequestToPreOSFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags);\r
+    }\r
   } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
+      DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
     //\r
     // Get the Physical Presence flags\r
     //\r
-    DataSize = sizeof (UINT8);\r
+    DataSize = sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);\r
     Status = mSmmVariable->SmmGetVariable (\r
                              PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                              &gEfiPhysicalPresenceGuid,\r
@@ -117,7 +145,7 @@ PhysicalPresenceCallback (
                              &Flags\r
                              );\r
     if (EFI_ERROR (Status)) {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
       DEBUG ((EFI_D_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status));\r
       return EFI_SUCCESS;\r
     }\r
@@ -135,27 +163,27 @@ PhysicalPresenceCallback (
       case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:\r
       case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:\r
       case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:\r
-        if ((Flags & FLAG_NO_PPI_PROVISION) != 0) {\r
+        if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {\r
           RequestConfirmed = TRUE;\r
         }\r
         break;\r
 \r
       case PHYSICAL_PRESENCE_CLEAR:\r
       case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:\r
-        if ((Flags & FLAG_NO_PPI_CLEAR) != 0) {\r
+        if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {\r
           RequestConfirmed = TRUE;\r
         }\r
         break;\r
 \r
       case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:\r
-        if ((Flags & FLAG_NO_PPI_MAINTENANCE) != 0) {\r
+        if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE) != 0) {\r
           RequestConfirmed = TRUE;\r
         }\r
         break;\r
 \r
       case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:\r
       case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:\r
-        if ((Flags & FLAG_NO_PPI_CLEAR) != 0 && (Flags & FLAG_NO_PPI_PROVISION) != 0) {\r
+        if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0 && (Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {\r
           RequestConfirmed = TRUE;\r
         }\r
         break;  \r
@@ -171,15 +199,20 @@ PhysicalPresenceCallback (
         //\r
         // This command requires UI to prompt user for Auth data\r
         //\r
-        mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_NOT_IMPLEMENTED; \r
+        mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; \r
         return EFI_SUCCESS;\r
+      default:\r
+        break;\r
     }\r
 \r
     if (RequestConfirmed) {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED;\r
     } else {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED;\r
     }    \r
+    if (mTcgNvs->PhysicalPresence.Request >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TcgPpVendorLibGetUserConfirmationStatusFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags);\r
+    }\r
   } \r
 \r
   return EFI_SUCCESS;\r
index eee8bc3..d8eb82f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header file for TCG SMM driver.\r
   \r
-Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2015, 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
@@ -36,6 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DxeServicesLib.h>\r
 #include <Library/TpmMeasurementLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/TcgPpVendorLib.h>\r
 \r
 #pragma pack(1)\r
 typedef struct {\r
@@ -83,23 +84,10 @@ typedef struct {
 #define ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST     8\r
 \r
 //\r
-// The return code for Get User Confirmation Status for Operation\r
+// The return code for Return TPM Operation Response to OS Environment\r
 //\r
-#define PP_REQUEST_NOT_IMPLEMENTED                                 0\r
-#define PP_REQUEST_BIOS_ONLY                                       1\r
-#define PP_REQUEST_BLOCKED                                         2\r
-#define PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED                     3\r
-#define PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED                 4\r
-\r
-//\r
-// The return code for Sumbit TPM Request to Pre-OS Environment\r
-// and Sumbit TPM Request to Pre-OS Environment 2\r
-//\r
-#define PP_SUBMIT_REQUEST_SUCCESS                                  0\r
-#define PP_SUBMIT_REQUEST_NOT_IMPLEMENTED                          1\r
-#define PP_SUBMIT_REQUEST_GENERAL_FAILURE                          2\r
-#define PP_SUBMIT_REQUEST_BLOCKED_BY_BIOS_SETTINGS                 3\r
-\r
+#define PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS                   0\r
+#define PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE                   1\r
 \r
 //\r
 // The definition for TCG MOR\r
index f39e089..be7a96b 100644 (file)
@@ -9,7 +9,7 @@
 #  This driver will have external input - variable and ACPINvs data in SMM mode.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2015, 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
@@ -49,6 +49,7 @@
   DxeServicesLib\r
   TpmMeasurementLib\r
   PcdLib\r
+  TcgPpVendorLib\r
 \r
 [Guids]\r
   ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence"\r
index 14303d5..a522cd9 100644 (file)
@@ -9,7 +9,7 @@
 \r
   PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.\r
 \r
-Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -66,11 +66,11 @@ PhysicalPresenceCallback (
   IN OUT UINTN                   *CommBufferSize\r
   )\r
 {\r
-  EFI_STATUS                     Status;\r
-  UINTN                          DataSize;\r
-  EFI_TREE_PHYSICAL_PRESENCE     PpData;\r
-  UINT8                          Flags;\r
-  BOOLEAN                        RequestConfirmed;\r
+  EFI_STATUS                        Status;\r
+  UINTN                             DataSize;\r
+  EFI_TREE_PHYSICAL_PRESENCE        PpData;\r
+  EFI_TREE_PHYSICAL_PRESENCE_FLAGS  Flags;\r
+  BOOLEAN                           RequestConfirmed;\r
 \r
   //\r
   // Get the Physical Presence variable\r
@@ -83,24 +83,33 @@ PhysicalPresenceCallback (
                            &DataSize,\r
                            &PpData\r
                            );\r
-  if (EFI_ERROR (Status)) {\r
-    mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
-    DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));\r
-    return EFI_SUCCESS;\r
-  }\r
 \r
   DEBUG ((EFI_D_INFO, "[TPM2] PP callback, Parameter = %x, Request = %x\n", mTcgNvs->PhysicalPresence.Parameter, mTcgNvs->PhysicalPresence.Request));\r
 \r
   if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode  = PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;\r
+      mTcgNvs->PhysicalPresence.LastRequest = 0;\r
+      mTcgNvs->PhysicalPresence.Response    = 0;\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
+    mTcgNvs->PhysicalPresence.ReturnCode  = PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;\r
     mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest;\r
     mTcgNvs->PhysicalPresence.Response    = PpData.PPResponse;\r
   } else if ((mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS) \r
           || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2)) {\r
-    if (mTcgNvs->PhysicalPresence.Request > TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
+    if ((mTcgNvs->PhysicalPresence.Request > TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) &&\r
+        (mTcgNvs->PhysicalPresence.Request < TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) ) {\r
       //\r
       // This command requires UI to prompt user for Auth data.\r
       //\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_NOT_IMPLEMENTED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -117,16 +126,36 @@ PhysicalPresenceCallback (
     }\r
 \r
     if (EFI_ERROR (Status)) { \r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
-      DEBUG ((EFI_D_ERROR, "[TPM] Set PP variable failure! Status = %r\n", Status));\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status));\r
       return EFI_SUCCESS;\r
     }\r
-    mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS;\r
+    mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;\r
+\r
+    if (mTcgNvs->PhysicalPresence.Request >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+      DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS);\r
+      Status = mSmmVariable->SmmGetVariable (\r
+                               TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
+                               &gEfiTrEEPhysicalPresenceGuid,\r
+                               NULL,\r
+                               &DataSize,\r
+                               &Flags\r
+                               );\r
+      if (EFI_ERROR (Status)) {\r
+        Flags.PPFlags = 0;\r
+      }\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TrEEPpVendorLibSubmitRequestToPreOSFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags);\r
+    }\r
   } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {\r
+    if (EFI_ERROR (Status)) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status));\r
+      return EFI_SUCCESS;\r
+    }\r
     //\r
     // Get the Physical Presence flags\r
     //\r
-    DataSize = sizeof (UINT8);\r
+    DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS);\r
     Status = mSmmVariable->SmmGetVariable (\r
                              TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE,\r
                              &gEfiTrEEPhysicalPresenceGuid,\r
@@ -135,8 +164,8 @@ PhysicalPresenceCallback (
                              &Flags\r
                              );\r
     if (EFI_ERROR (Status)) {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE;\r
-      DEBUG ((EFI_D_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status));\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;\r
+      DEBUG ((EFI_D_ERROR, "[TPM2] Get PP flags failure! Status = %r\n", Status));\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -148,7 +177,7 @@ PhysicalPresenceCallback (
       case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2:\r
       case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3:\r
       case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4:\r
-        if ((Flags & TREE_FLAG_NO_PPI_CLEAR) != 0) {\r
+        if ((Flags.PPFlags & TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {\r
           RequestConfirmed = TRUE;\r
         }\r
         break;\r
@@ -164,17 +193,22 @@ PhysicalPresenceCallback (
         if (mTcgNvs->PhysicalPresence.Request <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) {\r
           RequestConfirmed = TRUE;\r
         } else {\r
-          mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_NOT_IMPLEMENTED; \r
-          return EFI_SUCCESS;\r
+          if (mTcgNvs->PhysicalPresence.Request < TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+            mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; \r
+            return EFI_SUCCESS;\r
+          }\r
         }\r
         break;\r
     }\r
 \r
     if (RequestConfirmed) {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED;\r
     } else {\r
-      mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED;\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED;\r
     }    \r
+    if (mTcgNvs->PhysicalPresence.Request >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {\r
+      mTcgNvs->PhysicalPresence.ReturnCode = TrEEPpVendorLibGetUserConfirmationStatusFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags);\r
+    }\r
   } \r
 \r
   return EFI_SUCCESS;\r
index 8f4117e..a0e1182 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header file for TrEE SMM driver.\r
   \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -37,6 +37,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DxeServicesLib.h>\r
 #include <Library/TpmMeasurementLib.h>\r
 #include <Library/Tpm2DeviceLib.h>\r
+#include <Library/TrEEPpVendorLib.h>\r
 \r
 #pragma pack(1)\r
 typedef struct {\r
@@ -84,23 +85,10 @@ typedef struct {
 #define ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST     8\r
 \r
 //\r
-// The return code for Get User Confirmation Status for Operation\r
+// The return code for Return TPM Operation Response to OS Environment\r
 //\r
-#define PP_REQUEST_NOT_IMPLEMENTED                                 0\r
-#define PP_REQUEST_BIOS_ONLY                                       1\r
-#define PP_REQUEST_BLOCKED                                         2\r
-#define PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED                     3\r
-#define PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED                 4\r
-\r
-//\r
-// The return code for Sumbit TPM Request to Pre-OS Environment\r
-// and Sumbit TPM Request to Pre-OS Environment 2\r
-//\r
-#define PP_SUBMIT_REQUEST_SUCCESS                                  0\r
-#define PP_SUBMIT_REQUEST_NOT_IMPLEMENTED                          1\r
-#define PP_SUBMIT_REQUEST_GENERAL_FAILURE                          2\r
-#define PP_SUBMIT_REQUEST_BLOCKED_BY_BIOS_SETTINGS                 3\r
-\r
+#define PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS                   0\r
+#define PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE                   1\r
 \r
 //\r
 // The definition for TCG MOR\r
index 0436ba5..de71ffd 100644 (file)
@@ -9,7 +9,7 @@
 #  This driver will have external input - variable and ACPINvs data in SMM mode.\r
 #  This external input must be validated carefully to avoid security issue.\r
 #\r
-# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2015, 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
@@ -49,6 +49,7 @@
   DxeServicesLib\r
   TpmMeasurementLib\r
   Tpm2DeviceLib\r
+  TrEEPpVendorLib\r
 \r
 [Guids]\r
   ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence"\r