From 8d74a37944f9c4b53d83372c4078dde40e01e6b3 Mon Sep 17 00:00:00 2001 From: Wei6 Xu Date: Mon, 21 Oct 2024 00:07:22 +0800 Subject: [PATCH] StandaloneMmPkg/Core: Reset IsCommBufferValid to FALSE before MMI exits In current implementation of MmCommunication, caller (StandaloneMmIplPei or MmCommunicationDxe) sets the IsCommBufferValid to TRUE and triggers synchronous MMI, then caller resets IsCommBufferValid to FLASE after MMI exits. If asynchronous MMI happens before caller resets the IsCommBufferValid to FALSE, StandaloneMmCore will mistakenly thought there is still a synchronous MMI and then update incorrect values into ReturnStatus and ReturnBufferSize. To fix the above issue, StandaloneMmCore should reset IsCommBufferValid to FALSE before MMI exits. Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Ray Ni Cc: Jiaxin Wu Signed-off-by: Wei6 Xu --- StandaloneMmPkg/Core/StandaloneMmCore.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index f38d7d7483..970a06045b 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -574,11 +574,12 @@ MmEntryPoint ( } // - // Update CommunicationBuffer, BufferSize and ReturnStatus - // Communicate service finished, reset the pointer to CommBuffer to NULL + // Update ReturnBufferSize and ReturnStatus + // Communicate service finished, reset IsCommBufferValid to FALSE // - CommunicationStatus->ReturnBufferSize = BufferSize; - CommunicationStatus->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND; + CommunicationStatus->IsCommBufferValid = FALSE; + CommunicationStatus->ReturnBufferSize = BufferSize; + CommunicationStatus->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND; } else { DEBUG ((DEBUG_ERROR, "Input buffer size is larger than the size of MM Communication Buffer\n")); ASSERT (FALSE);