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 <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
This commit is contained in:
Wei6 Xu 2024-10-21 00:07:22 +08:00 committed by mergify[bot]
parent 334f574886
commit 8d74a37944

View File

@ -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);