From a4245b265de78dd0640004263f0b39da7d5a0506 Mon Sep 17 00:00:00 2001 From: John Strange Date: Thu, 4 Jul 2024 08:49:55 -0700 Subject: SecurityPkg: Tcg2Smm: Remove Memory Clear SMI Handler Remove unused MemoryClear SMI Handler, which is no longer used due to _DSM Memory Clear no longer being used. _DSM Memory Clear was deprecated in 2019 by TCG PC Client Platform Reset Attack Mitigation Spec Version 1.10 revision 17 Family "2.0". Signed-off-by: Oliver Smith-Denny --- SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 85 --------------------------------------- 1 file changed, 85 deletions(-) (limited to 'SecurityPkg/Tcg') diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c index 0c2799b42a..d4a4149ae4 100644 --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c @@ -170,81 +170,6 @@ PhysicalPresenceCallback ( return EFI_SUCCESS; } -/** - Software SMI callback for MemoryClear which is called from ACPI method. - - Caution: This function may receive untrusted input. - Variable and ACPINvs are external input, so this function will validate - its data structure to be valid value. - - @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). - @param[in] Context Points to an optional handler context which was specified when the - handler was registered. - @param[in, out] CommBuffer A pointer to a collection of data in memory that will - be conveyed from a non-SMM environment into an SMM environment. - @param[in, out] CommBufferSize The size of the CommBuffer. - - @retval EFI_SUCCESS The interrupt was handled successfully. - -**/ -EFI_STATUS -EFIAPI -MemoryClearCallback ( - IN EFI_HANDLE DispatchHandle, - IN CONST VOID *Context, - IN OUT VOID *CommBuffer, - IN OUT UINTN *CommBufferSize - ) -{ - EFI_STATUS Status; - UINTN DataSize; - UINT8 MorControl; - - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_SUCCESS; - if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_DSM_MEMORY_CLEAR_INTERFACE) { - MorControl = (UINT8)mTcgNvs->MemoryClear.Request; - } else if (mTcgNvs->MemoryClear.Parameter == ACPI_FUNCTION_PTS_CLEAR_MOR_BIT) { - DataSize = sizeof (UINT8); - Status = mSmmVariable->SmmGetVariable ( - MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, - &gEfiMemoryOverwriteControlDataGuid, - NULL, - &DataSize, - &MorControl - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; - DEBUG ((DEBUG_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - - if (MOR_CLEAR_MEMORY_VALUE (MorControl) == 0x0) { - return EFI_SUCCESS; - } - - MorControl &= ~MOR_CLEAR_MEMORY_BIT_MASK; - } else { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; - DEBUG ((DEBUG_ERROR, "[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter)); - return EFI_SUCCESS; - } - - DataSize = sizeof (UINT8); - Status = mSmmVariable->SmmSetVariable ( - MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, - &gEfiMemoryOverwriteControlDataGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - DataSize, - &MorControl - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; - DEBUG ((DEBUG_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status)); - } - - return EFI_SUCCESS; -} - /** Notification for SMM ReadyToLock protocol. @@ -337,16 +262,6 @@ InitializeTcgCommon ( mPpSoftwareSmi = SwContext.SwSmiInputValue; - SwContext.SwSmiInputValue = (UINTN)-1; - Status = SwDispatch->Register (SwDispatch, MemoryClearCallback, &SwContext, &McSwHandle); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "[%a] Failed to register MC callback as SW MM handler - %r!\n", __func__, Status)); - goto Cleanup; - } - - mMcSoftwareSmi = SwContext.SwSmiInputValue; - // // Locate SmmVariableProtocol. // -- cgit v1.2.3