SecurityPkg: Tcg2StandaloneMmArm: Align PP buffer with ARM_FFA_ARGS

The misc MM communicate buffer now stores the FF-A direct message
registers in an ARM_FFA_ARGS layout that preserves the native register
indices. The TCG physical presence callback must therefore locate the
TCG_NVS payload at the correct register offset instead of the start of
the communication buffer.

Point LocalTcgNvs at CommBuffer + OFFSET_OF (ARM_FFA_ARGS, Arg4) and
validate the buffer size against sizeof (ARM_FFA_ARGS). Add a
STATIC_ASSERT to guarantee TCG_NVS fits within the register space
available for the direct message payload, and include ArmFfaLib.h for
the ARM_FFA_ARGS definition.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
This commit is contained in:
Kun Qin 2026-07-23 17:12:02 -07:00 committed by mergify[bot]
parent 93ee300675
commit bdd36cdc1a

View file

@ -18,12 +18,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiMm.h>
#include <IndustryStandard/TcgPhysicalPresence.h>
#include <Guid/TpmNvsMm.h>
#include <Library/ArmFfaLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MmServicesTableLib.h>
#include <Library/StandaloneMmMemLib.h>
#include <Library/Tcg2PhysicalPresenceLib.h>
STATIC_ASSERT (sizeof (TCG_NVS) <= (sizeof (ARM_FFA_ARGS) - OFFSET_OF (ARM_FFA_ARGS, Arg4)), "TCG_NVS size is larger than direct message buffer size");
/**
This function checks if the required instance is a supported TPM 2.0 instance.
It currently supports two instances: dTPM and FFA.
@ -97,7 +100,7 @@ PhysicalPresenceCallback (
return EFI_INVALID_PARAMETER;
}
if (*CommBufferSize < sizeof (TCG_NVS)) {
if (*CommBufferSize < sizeof (ARM_FFA_ARGS)) {
return EFI_INVALID_PARAMETER;
}
@ -107,7 +110,7 @@ PhysicalPresenceCallback (
}
// Enough complaints, now get to work...
LocalTcgNvs = (TCG_NVS *)CommBuffer;
LocalTcgNvs = (TCG_NVS *)((UINT8 *)CommBuffer + OFFSET_OF (ARM_FFA_ARGS, Arg4));
if (LocalTcgNvs->PhysicalPresence.Parameter == TCG_ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) {
LocalTcgNvs->PhysicalPresence.ReturnCode = Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (