Skip to content

Commit

Permalink
SecurityPkg: Allocate EfiACPIMemoryNVS buffer for TCG2
Browse files Browse the repository at this point in the history
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 9a76c79 and consume the buffer in
e939ecf. 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 <[email protected]>
  • Loading branch information
td36 committed Aug 21, 2024
1 parent dc2dc89 commit 6da7400
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6da7400

Please sign in to comment.