From 4610b23ab10942d140eb51c4bdbefc5f896979ad Mon Sep 17 00:00:00 2001 From: "Yao, Jiewen" Date: Mon, 12 Jan 2015 03:16:49 +0000 Subject: Add TPM Physical Presence >=128 operation value support. 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" Reviewed-by: "Dong, Guo" git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16597 6f19259b-4bc3-4df7-8a09-765794883524 --- SecurityPkg/Tcg/TrEESmm/TrEESmm.c | 82 ++++++++++++++++++++++++++----------- SecurityPkg/Tcg/TrEESmm/TrEESmm.h | 22 +++------- SecurityPkg/Tcg/TrEESmm/TrEESmm.inf | 3 +- 3 files changed, 65 insertions(+), 42 deletions(-) (limited to 'SecurityPkg/Tcg/TrEESmm') diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.c b/SecurityPkg/Tcg/TrEESmm/TrEESmm.c index 14303d5458..a522cd97c6 100644 --- a/SecurityPkg/Tcg/TrEESmm/TrEESmm.c +++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.c @@ -9,7 +9,7 @@ PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check. -Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
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 @@ -66,11 +66,11 @@ PhysicalPresenceCallback ( IN OUT UINTN *CommBufferSize ) { - EFI_STATUS Status; - UINTN DataSize; - EFI_TREE_PHYSICAL_PRESENCE PpData; - UINT8 Flags; - BOOLEAN RequestConfirmed; + EFI_STATUS Status; + UINTN DataSize; + EFI_TREE_PHYSICAL_PRESENCE PpData; + EFI_TREE_PHYSICAL_PRESENCE_FLAGS Flags; + BOOLEAN RequestConfirmed; // // Get the Physical Presence variable @@ -83,24 +83,33 @@ PhysicalPresenceCallback ( &DataSize, &PpData ); - if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE; - DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } DEBUG ((EFI_D_INFO, "[TPM2] PP callback, Parameter = %x, Request = %x\n", mTcgNvs->PhysicalPresence.Parameter, mTcgNvs->PhysicalPresence.Request)); if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) { + if (EFI_ERROR (Status)) { + mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE; + mTcgNvs->PhysicalPresence.LastRequest = 0; + mTcgNvs->PhysicalPresence.Response = 0; + DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); + return EFI_SUCCESS; + } + mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS; mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest; mTcgNvs->PhysicalPresence.Response = PpData.PPResponse; } 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 > TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) { + if (EFI_ERROR (Status)) { + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE; + DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); + return EFI_SUCCESS; + } + if ((mTcgNvs->PhysicalPresence.Request > TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) && + (mTcgNvs->PhysicalPresence.Request < TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) ) { // // This command requires UI to prompt user for Auth data. // - mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_NOT_IMPLEMENTED; + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED; return EFI_SUCCESS; } @@ -117,16 +126,36 @@ PhysicalPresenceCallback ( } if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE; - DEBUG ((EFI_D_ERROR, "[TPM] Set PP variable failure! Status = %r\n", Status)); + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE; + DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status)); return EFI_SUCCESS; } - mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_SUCCESS; + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS; + + if (mTcgNvs->PhysicalPresence.Request >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { + DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS); + Status = mSmmVariable->SmmGetVariable ( + TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE, + &gEfiTrEEPhysicalPresenceGuid, + NULL, + &DataSize, + &Flags + ); + if (EFI_ERROR (Status)) { + Flags.PPFlags = 0; + } + mTcgNvs->PhysicalPresence.ReturnCode = TrEEPpVendorLibSubmitRequestToPreOSFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags); + } } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) { + if (EFI_ERROR (Status)) { + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION; + DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); + return EFI_SUCCESS; + } // // Get the Physical Presence flags // - DataSize = sizeof (UINT8); + DataSize = sizeof (EFI_TREE_PHYSICAL_PRESENCE_FLAGS); Status = mSmmVariable->SmmGetVariable ( TREE_PHYSICAL_PRESENCE_FLAGS_VARIABLE, &gEfiTrEEPhysicalPresenceGuid, @@ -135,8 +164,8 @@ PhysicalPresenceCallback ( &Flags ); if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = PP_SUBMIT_REQUEST_GENERAL_FAILURE; - DEBUG ((EFI_D_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status)); + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION; + DEBUG ((EFI_D_ERROR, "[TPM2] Get PP flags failure! Status = %r\n", Status)); return EFI_SUCCESS; } @@ -148,7 +177,7 @@ PhysicalPresenceCallback ( case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_2: case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_3: case TREE_PHYSICAL_PRESENCE_CLEAR_CONTROL_CLEAR_4: - if ((Flags & TREE_FLAG_NO_PPI_CLEAR) != 0) { + if ((Flags.PPFlags & TREE_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) { RequestConfirmed = TRUE; } break; @@ -164,17 +193,22 @@ PhysicalPresenceCallback ( if (mTcgNvs->PhysicalPresence.Request <= TREE_PHYSICAL_PRESENCE_NO_ACTION_MAX) { RequestConfirmed = TRUE; } else { - mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_NOT_IMPLEMENTED; - return EFI_SUCCESS; + if (mTcgNvs->PhysicalPresence.Request < TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; + return EFI_SUCCESS; + } } break; } if (RequestConfirmed) { - mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_NOT_REQUIRED; + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED; } else { - mTcgNvs->PhysicalPresence.ReturnCode = PP_REQUEST_ALLOWED_AND_PPUSER_REQUIRED; + mTcgNvs->PhysicalPresence.ReturnCode = TREE_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED; } + if (mTcgNvs->PhysicalPresence.Request >= TREE_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { + mTcgNvs->PhysicalPresence.ReturnCode = TrEEPpVendorLibGetUserConfirmationStatusFunction (mTcgNvs->PhysicalPresence.Request, Flags.PPFlags); + } } return EFI_SUCCESS; diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.h b/SecurityPkg/Tcg/TrEESmm/TrEESmm.h index 8f4117e1e4..a0e1182248 100644 --- a/SecurityPkg/Tcg/TrEESmm/TrEESmm.h +++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.h @@ -1,7 +1,7 @@ /** @file The header file for TrEE SMM driver. -Copyright (c) 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
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 @@ -37,6 +37,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #pragma pack(1) typedef struct { @@ -84,23 +85,10 @@ typedef struct { #define ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST 8 // -// The return code for Get User Confirmation Status for Operation +// The return code for Return TPM Operation Response to OS Environment // -#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 - +#define PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS 0 +#define PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE 1 // // The definition for TCG MOR diff --git a/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf b/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf index 0436ba5c51..de71ffdc1b 100644 --- a/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf +++ b/SecurityPkg/Tcg/TrEESmm/TrEESmm.inf @@ -9,7 +9,7 @@ # This driver will have external input - variable and ACPINvs data in SMM mode. # This external input must be validated carefully to avoid security issue. # -# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
# 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 @@ -49,6 +49,7 @@ DxeServicesLib TpmMeasurementLib Tpm2DeviceLib + TrEEPpVendorLib [Guids] ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence" -- cgit v1.2.3