X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FSecCore%2FSecMain.c;h=c241d3704af72b9702b15fbcc277358aa195d678;hp=ec252cf719f5f72998c0ca8af74085b2ff6859aa;hb=147fd35c3e389ecd025dbfd243312bf5b22da7c9;hpb=1921695e6461e699ebe12c91254a779ed221b96f diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c index ec252cf719..c241d3704a 100644 --- a/UefiCpuPkg/SecCore/SecMain.c +++ b/UefiCpuPkg/SecCore/SecMain.c @@ -1,7 +1,7 @@ /** @file C functions in SEC - Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -21,6 +21,14 @@ EFI_PEI_TEMPORARY_RAM_DONE_PPI gSecTemporaryRamDonePpi = { EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformationPpi = { SecPlatformInformation }; EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformationPpi[] = { + { + // + // SecPerformance PPI notify descriptor. + // + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, + &gPeiSecPerformancePpiGuid, + (VOID *) (UINTN) SecPerformancePpiCallBack + }, { EFI_PEI_PPI_DESCRIPTOR_PPI, &gEfiTemporaryRamDonePpiGuid, @@ -49,11 +57,50 @@ UINT64 mIdtEntryTemplate = 0xffff8e000010ffe4ULL; **/ VOID +NORETURN EFIAPI SecStartupPhase2( IN VOID *Context ); +/** + Entry point of the notification callback function itself within the PEIM. + It is to get SEC performance data and build HOB to convey the SEC performance + data to DXE phase. + + @param PeiServices Indirect reference to the PEI Services Table. + @param NotifyDescriptor Address of the notification descriptor data structure. + @param Ppi Address of the PPI that was installed. + + @return Status of the notification. + The status code returned from this function is ignored. +**/ +EFI_STATUS +EFIAPI +SecPerformancePpiCallBack ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + EFI_STATUS Status; + PEI_SEC_PERFORMANCE_PPI *SecPerf; + FIRMWARE_SEC_PERFORMANCE Performance; + + SecPerf = (PEI_SEC_PERFORMANCE_PPI *) Ppi; + Status = SecPerf->GetPerformance ((CONST EFI_PEI_SERVICES **) PeiServices, SecPerf, &Performance); + if (!EFI_ERROR (Status)) { + BuildGuidDataHob ( + &gEfiFirmwarePerformanceGuid, + &Performance, + sizeof (FIRMWARE_SEC_PERFORMANCE) + ); + DEBUG ((DEBUG_INFO, "FPDT: SEC Performance Hob ResetEnd = %ld\n", Performance.ResetEnd)); + } + + return Status; +} + /** Entry point to the C language phase of SEC. After the SEC assembly @@ -142,7 +189,7 @@ SecStartup ( // SecCoreData.DataSize = (UINT16) sizeof (EFI_SEC_PEI_HAND_OFF); SecCoreData.BootFirmwareVolumeBase = BootFirmwareVolume; - SecCoreData.BootFirmwareVolumeSize = (UINTN)(0x100000000ULL - (UINTN) BootFirmwareVolume); + SecCoreData.BootFirmwareVolumeSize = (UINTN)((EFI_FIRMWARE_VOLUME_HEADER *) BootFirmwareVolume)->FvLength; SecCoreData.TemporaryRamBase = (VOID*)(UINTN) TempRamBase; SecCoreData.TemporaryRamSize = SizeOfRam; SecCoreData.PeiTemporaryRamBase = SecCoreData.TemporaryRamBase; @@ -167,6 +214,7 @@ SecStartup ( **/ VOID +NORETURN EFIAPI SecStartupPhase2( IN VOID *Context @@ -228,6 +276,12 @@ SecStartupPhase2( ASSERT (SecCoreData->PeiTemporaryRamSize > Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); SecCoreData->PeiTemporaryRamBase = (VOID *)((UINTN) SecCoreData->PeiTemporaryRamBase + Index * sizeof (EFI_PEI_PPI_DESCRIPTOR)); SecCoreData->PeiTemporaryRamSize = SecCoreData->PeiTemporaryRamSize - Index * sizeof (EFI_PEI_PPI_DESCRIPTOR); + // + // Adjust the Base and Size to be 8-byte aligned as HOB which has 8byte aligned requirement + // will be built based on them in PEI phase. + // + SecCoreData->PeiTemporaryRamBase = (VOID *)(((UINTN)SecCoreData->PeiTemporaryRamBase + 7) & ~0x07); + SecCoreData->PeiTemporaryRamSize &= ~(UINTN)0x07; } else { // // No addition PPI, PpiList directly point to the common PPI list. @@ -235,6 +289,14 @@ SecStartupPhase2( PpiList = &mPeiSecPlatformInformationPpi[0]; } + DEBUG (( + DEBUG_INFO, + "%a() Stack Base: 0x%p, Stack Size: 0x%x\n", + __FUNCTION__, + SecCoreData->StackBase, + (UINT32) SecCoreData->StackSize + )); + // // Report Status Code to indicate transferring to PEI core // @@ -252,7 +314,7 @@ SecStartupPhase2( // // Should not come here. // - return; + UNREACHABLE (); } /** @@ -271,6 +333,11 @@ SecTemporaryRamDone ( { BOOLEAN State; + // + // Republish Sec Platform Information(2) PPI + // + RepublishSecPlatformInformationPpi (); + // // Migrate DebugAgentContext. //