From bdd36cdc1a1fb411bc8edc5f8ec81115be99ab48 Mon Sep 17 00:00:00 2001 From: Kun Qin Date: Thu, 23 Jul 2026 17:12:02 -0700 Subject: [PATCH] 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 --- SecurityPkg/Tcg/Tcg2StandaloneMmArm/Tcg2StandaloneMmArm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2StandaloneMmArm/Tcg2StandaloneMmArm.c b/SecurityPkg/Tcg/Tcg2StandaloneMmArm/Tcg2StandaloneMmArm.c index aed3f6a7eb..7651edb70b 100644 --- a/SecurityPkg/Tcg/Tcg2StandaloneMmArm/Tcg2StandaloneMmArm.c +++ b/SecurityPkg/Tcg/Tcg2StandaloneMmArm/Tcg2StandaloneMmArm.c @@ -18,12 +18,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include #include #include +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 (