From 6a329eb853d177a8ba608d3503f394b906e9e6a8 Mon Sep 17 00:00:00 2001 From: Prachotan Bathi Date: Tue, 1 Jul 2025 11:28:58 -0500 Subject: [PATCH] ArmPlatformPkg: Capture TransferList Information for SEC Capture TransferList address from register x3 Refer to section 3 of the FW Handoff Specification https://firmwarehandoff.github.io/firmware_handoff The TransferList header is present at the base address captured by this variable. For platforms with no TransferList support, boot continues without any errors. Signed-off-by: Prachotan Bathi --- ArmPlatformPkg/Sec/AArch64/ModuleEntryPoint.S | 16 ++++++++++- ArmPlatformPkg/Sec/Sec.c | 27 ++++++++++++++++--- ArmPlatformPkg/Sec/Sec.h | 1 + ArmPlatformPkg/Sec/Sec.inf | 1 + 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ArmPlatformPkg/Sec/AArch64/ModuleEntryPoint.S b/ArmPlatformPkg/Sec/AArch64/ModuleEntryPoint.S index 154be1111d..28cd015772 100644 --- a/ArmPlatformPkg/Sec/AArch64/ModuleEntryPoint.S +++ b/ArmPlatformPkg/Sec/AArch64/ModuleEntryPoint.S @@ -8,6 +8,19 @@ #include ASM_FUNC(_ModuleEntryPoint) + // Check if register assignment at handoff matches spec + MOV64 (x4, 0x14a0fb10b) + // Check if x1 holds TransferList signature + cmp x1, x4 + b.ne _SkipTransferList + + // Skip TransferList init if x2 is not equal to 0 + cbnz x2, _SkipTransferList + + // Set the TransferList Base Address from register x3 + mov x10, x3 + +_SkipTransferList: // Do early platform specific actions bl ASM_PFX(ArmPlatformPeiBootAction) @@ -47,7 +60,8 @@ ASM_PFX(MainEntryPoint): // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector MOV64 (x2, FixedPcdGet64(PcdFvBaseAddress)) ldr x0, [x2, #8] - + // Pass the TransferList Base Address + mov x1, x10 // Move sec startup address into a data register // Ensure we're jumping to FV version of the code (not boot remapped alias) ldr x3, =ASM_PFX(CEntryPoint) diff --git a/ArmPlatformPkg/Sec/Sec.c b/ArmPlatformPkg/Sec/Sec.c index 4535ae7e78..0e9d1c82fe 100644 --- a/ArmPlatformPkg/Sec/Sec.c +++ b/ArmPlatformPkg/Sec/Sec.c @@ -151,12 +151,15 @@ PrintFirmwareVersion ( @param[in] PeiCoreEntryPoint Address in ram of the entrypoint of the PEI core + @param[in] TransferListBaseAddr Address of the Transfer List base address + **/ STATIC VOID EFIAPI SecMain ( - IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint + IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint, + IN UINTN TransferListBaseAddr ) { EFI_SEC_PEI_HAND_OFF SecCoreData; @@ -164,6 +167,21 @@ SecMain ( EFI_PEI_PPI_DESCRIPTOR *PpiList; UINTN TemporaryRamBase; UINTN TemporaryRamSize; + VOID *TransferListBase; + + // Dump the Transfer List + TransferListBase = (VOID *)TransferListBaseAddr; + if (TransferListBase != NULL) { + if (TransferListCheckHeader (TransferListBase) != TRANSFER_LIST_OPS_INVALID) { + DEBUG_CODE_BEGIN (); + TransferListDump (TransferListBase); + DEBUG_CODE_END (); + } else { + DEBUG ((DEBUG_ERROR, "%a: No valid operations possible on TransferList found @ 0x%p\n", __func__, TransferListBase)); + } + } else { + DEBUG ((DEBUG_INFO, "%a: No TransferList found, continuing boot\n", __func__)); + } CreatePpiList (&PpiListSize, &PpiList); @@ -197,10 +215,13 @@ SecMain ( @param[in] PeiCoreEntryPoint Address in ram of the entrypoint of the PEI core + @param[in] TransferListBaseAddr Address of the Transfer List base address + **/ VOID CEntryPoint ( - IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint + IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint, + IN UINTN TransferListBaseAddr ) { if (!ArmMmuEnabled ()) { @@ -237,7 +258,7 @@ CEntryPoint ( ArmPlatformInitialize (ArmReadMpidr ()); // Goto primary Main. - SecMain (PeiCoreEntryPoint); + SecMain (PeiCoreEntryPoint, TransferListBaseAddr); // PEI Core should always load and never return ASSERT (FALSE); diff --git a/ArmPlatformPkg/Sec/Sec.h b/ArmPlatformPkg/Sec/Sec.h index 56d9f352bd..c1cd10d909 100644 --- a/ArmPlatformPkg/Sec/Sec.h +++ b/ArmPlatformPkg/Sec/Sec.h @@ -23,6 +23,7 @@ #include #include +#include /** Helper function to switch to a different stack. Implemented in assembler as diff --git a/ArmPlatformPkg/Sec/Sec.inf b/ArmPlatformPkg/Sec/Sec.inf index a75ce8d5ec..2d1622cf52 100644 --- a/ArmPlatformPkg/Sec/Sec.inf +++ b/ArmPlatformPkg/Sec/Sec.inf @@ -48,6 +48,7 @@ PrintLib SerialPortLib StackCheckLib + ArmTransferListLib [Ppis] gEfiTemporaryRamSupportPpiGuid