From 5a06afa7dd8ba8e99178fec9525be9e3fd2a4d3a Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Wed, 21 Aug 2024 10:05:34 +0800 Subject: SecurityPkg: Allocate EfiACPIMemoryNVS buffer for TCG2 Allocate EfiACPIMemoryNVS buffer for TCG2 related usage in Tcg2ConfigPeim. The buffer will be used in Tcg2Acpi driver to retrive information from SMM environment. Previously, the buffer used in Tcg2Acpi driver is AcpiNvs type. But I mistakenly thought the Runtime Data type buffer should also work. So I used API AllocateRuntimePages() to allocate buffer in 9a76c7945b7 and consume the buffer in e939ecf6c1. Recently we found that if the buffer type is Runtime Data instead of AcpiNvs, BSOD issue happened after boot into OS. So this commit is to Allocate EfiACPIMemoryNVS buffer for TCG2 usage in SMM to align with the initial code logic. Signed-off-by: Dun Tan --- SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'SecurityPkg') diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c index 0e4dd3e7fd..92243ec894 100644 --- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c +++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c @@ -75,21 +75,25 @@ BuildTcg2AcpiCommunicateBufferHob ( { TCG2_ACPI_COMMUNICATE_BUFFER *Tcg2AcpiCommunicateBufferHob; EFI_STATUS Status; - VOID *Buffer; + EFI_PHYSICAL_ADDRESS Buffer; UINTN Pages; Pages = EFI_SIZE_TO_PAGES (sizeof (TCG_NVS)); - Buffer = AllocateRuntimePages (Pages); - ASSERT (Buffer != NULL); + Status = PeiServicesAllocatePages ( + EfiACPIMemoryNVS, + Pages, + &Buffer + ); + ASSERT_EFI_ERROR (Status); - Status = MmUnblockMemoryRequest ((UINTN)Buffer, Pages); + Status = MmUnblockMemoryRequest (Buffer, Pages); if ((Status != EFI_UNSUPPORTED) && EFI_ERROR (Status)) { return Status; } Tcg2AcpiCommunicateBufferHob = BuildGuidHob (&gEdkiiTcg2AcpiCommunicateBufferHobGuid, sizeof (TCG2_ACPI_COMMUNICATE_BUFFER)); ASSERT (Tcg2AcpiCommunicateBufferHob != NULL); - Tcg2AcpiCommunicateBufferHob->Tcg2AcpiCommunicateBuffer = (UINTN)Buffer; + Tcg2AcpiCommunicateBufferHob->Tcg2AcpiCommunicateBuffer = Buffer; Tcg2AcpiCommunicateBufferHob->Pages = Pages; return EFI_SUCCESS; -- cgit