43 IN OUT VOID *CommBuffer,
51 BOOLEAN RequestConfirmed;
57 Status = mSmmVariable->SmmGetVariable (
58 PHYSICAL_PRESENCE_VARIABLE,
59 &gEfiPhysicalPresenceGuid,
65 DEBUG ((DEBUG_INFO,
"[TPM] PP callback, Parameter = %x\n", mTcgNvs->PhysicalPresence.Parameter));
66 if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {
67 if (EFI_ERROR (Status)) {
68 mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE;
69 mTcgNvs->PhysicalPresence.LastRequest = 0;
70 mTcgNvs->PhysicalPresence.Response = 0;
71 DEBUG ((DEBUG_ERROR,
"[TPM] Get PP variable failure! Status = %r\n", Status));
75 mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS;
76 mTcgNvs->PhysicalPresence.LastRequest = PpData.LastPPRequest;
77 mTcgNvs->PhysicalPresence.Response = PpData.PPResponse;
78 }
else if ( (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS)
79 || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2))
81 if (EFI_ERROR (Status)) {
82 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
83 DEBUG ((DEBUG_ERROR,
"[TPM] Get PP variable failure! Status = %r\n", Status));
87 if (mTcgNvs->PhysicalPresence.Request == PHYSICAL_PRESENCE_SET_OPERATOR_AUTH) {
91 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED;
95 if (PpData.
PPRequest != mTcgNvs->PhysicalPresence.Request) {
96 PpData.
PPRequest = (UINT8)mTcgNvs->PhysicalPresence.Request;
98 Status = mSmmVariable->SmmSetVariable (
99 PHYSICAL_PRESENCE_VARIABLE,
100 &gEfiPhysicalPresenceGuid,
107 if (EFI_ERROR (Status)) {
108 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
112 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;
114 if (mTcgNvs->PhysicalPresence.Request >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
116 Status = mSmmVariable->SmmGetVariable (
117 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
118 &gEfiPhysicalPresenceGuid,
123 if (EFI_ERROR (Status)) {
124 Flags.PPFlags = TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;
129 }
else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) {
130 if (EFI_ERROR (Status)) {
131 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;
132 DEBUG ((DEBUG_ERROR,
"[TPM] Get PP variable failure! Status = %r\n", Status));
140 Status = mSmmVariable->SmmGetVariable (
141 PHYSICAL_PRESENCE_FLAGS_VARIABLE,
142 &gEfiPhysicalPresenceGuid,
147 if (EFI_ERROR (Status)) {
148 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION;
149 DEBUG ((DEBUG_ERROR,
"[TPM] Get PP flags failure! Status = %r\n", Status));
153 RequestConfirmed =
FALSE;
155 switch (mTcgNvs->PPRequestUserConfirm) {
156 case PHYSICAL_PRESENCE_ENABLE:
157 case PHYSICAL_PRESENCE_DISABLE:
158 case PHYSICAL_PRESENCE_ACTIVATE:
159 case PHYSICAL_PRESENCE_DEACTIVATE:
160 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:
161 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:
162 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:
163 case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:
164 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:
165 case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:
166 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) {
167 RequestConfirmed =
TRUE;
172 case PHYSICAL_PRESENCE_CLEAR:
173 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:
174 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) {
175 RequestConfirmed =
TRUE;
180 case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:
181 if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE) != 0) {
182 RequestConfirmed =
TRUE;
187 case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
188 case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:
189 if (((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) && ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0)) {
190 RequestConfirmed =
TRUE;
195 case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:
196 case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:
197 case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:
198 case PHYSICAL_PRESENCE_NO_ACTION:
199 RequestConfirmed =
TRUE;
202 case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:
206 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED;
212 if (RequestConfirmed) {
213 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_NOT_REQUIRED;
215 mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_ALLOWED_AND_PPUSER_REQUIRED;
218 if (mTcgNvs->PhysicalPresence.Request >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
248 IN OUT VOID *CommBuffer,
256 mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_SUCCESS;
257 if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE) {
258 MorControl = (UINT8)mTcgNvs->MemoryClear.Request;
259 }
else if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_PTS_CLEAR_MOR_BIT) {
260 DataSize =
sizeof (UINT8);
261 Status = mSmmVariable->SmmGetVariable (
263 &gEfiMemoryOverwriteControlDataGuid,
268 if (EFI_ERROR (Status)) {
269 mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;
270 DEBUG ((DEBUG_ERROR,
"[TPM] Get MOR variable failure! Status = %r\n", Status));
278 MorControl &= ~MOR_CLEAR_MEMORY_BIT_MASK;
280 mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;
281 DEBUG ((DEBUG_ERROR,
"[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter));
285 DataSize =
sizeof (UINT8);
286 Status = mSmmVariable->SmmSetVariable (
288 &gEfiMemoryOverwriteControlDataGuid,
293 if (EFI_ERROR (Status)) {
294 mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE;
295 DEBUG ((DEBUG_ERROR,
"[TPM] Set MOR variable failure! Status = %r\n", Status));
323 MemoryAddress = SIZE_4GB - 1;
332 if ((OpRegion->OpRegionOp == AML_EXT_REGION_OP) &&
333 (OpRegion->NameString == Name) &&
334 (OpRegion->DWordPrefix == AML_DWORD_PREFIX) &&
335 (OpRegion->BytePrefix == AML_BYTE_PREFIX))
340 OpRegion->RegionOffset = (UINT32)(
UINTN)MemoryAddress;
341 OpRegion->RegionLen = (UINT8)Size;
346 return (VOID *)(
UINTN)MemoryAddress;
382 EV_POSTCODE_INFO_ACPI_DATA,
388 ASSERT (Table->OemTableId ==
SIGNATURE_64 (
'T',
'c',
'g',
'T',
'a',
'b',
'l',
'e'));
389 CopyMem (Table->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (Table->OemId));
391 ASSERT (mTcgNvs !=
NULL);
396 Status =
gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid,
NULL, (VOID **)&AcpiTable);
400 Status = AcpiTable->InstallAcpiTable (
437 DEBUG ((DEBUG_ERROR,
"No TPM12 instance required!\n"));
438 return EFI_UNSUPPORTED;
447 Status =
gSmst->SmmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid,
NULL, (VOID **)&SwDispatch);
449 SwContext.SwSmiInputValue = (
UINTN)-1;
452 if (EFI_ERROR (Status)) {
456 mTcgNvs->PhysicalPresence.SoftwareSmi = (UINT8)SwContext.SwSmiInputValue;
458 SwContext.SwSmiInputValue = (
UINTN)-1;
461 if (EFI_ERROR (Status)) {
465 mTcgNvs->MemoryClear.SoftwareSmi = (UINT8)SwContext.SwSmiInputValue;
470 Status =
gSmst->SmmLocateProtocol (&gEfiSmmVariableProtocolGuid,
NULL, (VOID **)&mSmmVariable);
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI GetSectionFromFv(IN CONST EFI_GUID *NameGuid, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **Buffer, OUT UINTN *Size)
#define SIGNATURE_64(A, B, C, D, E, F, G, H)
#define SIGNATURE_32(A, B, C, D)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define MOR_CLEAR_MEMORY_VALUE(mor)
#define MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME
#define PcdGetPtr(TokenName)
EFI_SMM_SYSTEM_TABLE2 * gSmst
UINT32 EFIAPI TcgPpVendorLibGetUserConfirmationStatusFunction(IN UINT32 OperationRequest, IN UINT32 ManagementFlags)
UINT32 EFIAPI TcgPpVendorLibSubmitRequestToPreOSFunction(IN UINT32 OperationRequest, IN UINT32 ManagementFlags)
EFI_STATUS EFIAPI MemoryClearCallback(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
VOID * AssignOpRegion(EFI_ACPI_DESCRIPTION_HEADER *Table, UINT32 Name, UINT16 Size)
EFI_STATUS PublishAcpiTable(VOID)
EFI_STATUS EFIAPI PhysicalPresenceCallback(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context, IN OUT VOID *CommBuffer, IN OUT UINTN *CommBufferSize)
EFI_STATUS EFIAPI InitializeTcgSmm(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI TpmMeasureAndLogData(IN UINT32 PcrIndex, IN UINT32 EventType, IN VOID *EventLog, IN UINT32 LogLen, IN VOID *HashData, IN UINT64 HashDataLen)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
#define EFI_VARIABLE_NON_VOLATILE
UINT8 PPRequest
Physical Presence request command.