UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI

In SecTemporaryRamDone(), we will build one privated GUIDed-HOB to save CPU BIST
Data and re-install SEC platform information(2) PPI. Then other PEI drivers
could get CPU BIST data from the private GUIDed-HOB by new installed PPI.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@Intel.com>
This commit is contained in:
Jeff Fan 2016-09-09 15:14:32 +08:00
parent d157de8b56
commit 8a5b8cef67
4 changed files with 146 additions and 1 deletions

View File

@ -14,6 +14,26 @@
#include "SecMain.h"
EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatformInformation = {
SecPlatformInformationBist
};
EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiSecPlatformInformationPpiGuid,
&mSecPlatformInformation
};
EFI_SEC_PLATFORM_INFORMATION2_PPI mSecPlatformInformation2 = {
SecPlatformInformation2Bist
};
EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformInformation2 = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiSecPlatformInformation2PpiGuid,
&mSecPlatformInformation2
};
/**
Worker function to parse CPU BIST information from Guided HOB.
@ -179,3 +199,70 @@ GetBistInfoFromPpi (
return EFI_DEVICE_ERROR;
}
/**
Get CPUs' BIST by calling SecPlatformInformationPpi/SecPlatformInformation2Ppi.
**/
VOID
RepublishSecPlatformInformationPpi (
VOID
)
{
EFI_STATUS Status;
CONST EFI_PEI_SERVICES **PeiServices;
UINT64 BistInformationSize;
VOID *BistInformationData;
EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor;
PeiServices = GetPeiServicesTablePointer ();
Status = GetBistInfoFromPpi (
PeiServices,
&gEfiSecPlatformInformation2PpiGuid,
&SecInformationDescriptor,
&BistInformationData,
&BistInformationSize
);
if (Status == EFI_SUCCESS) {
BuildGuidDataHob (
&gEfiCallerIdGuid,
BistInformationData,
(UINTN) BistInformationSize
);
//
// The old SecPlatformInformation data is on CAR.
// After memory discovered, we should never get it from CAR, or the data will be crashed.
// So, we reinstall SecPlatformInformation PPI here.
//
Status = PeiServicesReInstallPpi (
SecInformationDescriptor,
&mPeiSecPlatformInformation2
);
} if (Status == EFI_NOT_FOUND) {
Status = GetBistInfoFromPpi (
PeiServices,
&gEfiSecPlatformInformationPpiGuid,
&SecInformationDescriptor,
&BistInformationData,
&BistInformationSize
);
if (Status == EFI_SUCCESS) {
BuildGuidDataHob (
&gEfiCallerIdGuid,
BistInformationData,
(UINTN) BistInformationSize
);
//
// The old SecPlatformInformation2 data is on CAR.
// After memory discovered, we should never get it from CAR, or the data will be crashed.
// So, we reinstall SecPlatformInformation2 PPI here.
//
Status = PeiServicesReInstallPpi (
SecInformationDescriptor,
&mPeiSecPlatformInformation
);
}
}
ASSERT_EFI_ERROR(Status);
}

View File

@ -64,7 +64,12 @@
HobLib
[Ppis]
gEfiSecPlatformInformationPpiGuid ## PRODUCES
## SOMETIMES_CONSUMES
## PRODUCES
gEfiSecPlatformInformationPpiGuid
## SOMETIMES_CONSUMES
## SOMETIMES_PRODUCES
gEfiSecPlatformInformation2PpiGuid
gEfiTemporaryRamDonePpiGuid ## PRODUCES
[Pcd]

View File

@ -273,6 +273,11 @@ SecTemporaryRamDone (
{
BOOLEAN State;
//
// Republish Sec Platform Information(2) PPI
//
RepublishSecPlatformInformationPpi ();
//
// Migrate DebugAgentContext.
//

View File

@ -109,4 +109,52 @@ ProcessLibraryConstructorList (
VOID
);
/**
Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI.
@param PeiServices Pointer to the PEI Services Table.
@param StructureSize Pointer to the variable describing size of the input buffer.
@param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
@retval EFI_SUCCESS The data was successfully returned.
@retval EFI_BUFFER_TOO_SMALL The buffer was too small.
**/
EFI_STATUS
EFIAPI
SecPlatformInformationBist (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN OUT UINT64 *StructureSize,
OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
);
/**
Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
@param PeiServices The pointer to the PEI Services Table.
@param StructureSize The pointer to the variable describing size of the input buffer.
@param PlatformInformationRecord2 The pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD2.
@retval EFI_SUCCESS The data was successfully returned.
@retval EFI_BUFFER_TOO_SMALL The buffer was too small. The current buffer size needed to
hold the record is returned in StructureSize.
**/
EFI_STATUS
EFIAPI
SecPlatformInformation2Bist (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN OUT UINT64 *StructureSize,
OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
);
/**
Republish SecPlatformInformationPpi/SecPlatformInformation2Ppi.
**/
VOID
RepublishSecPlatformInformationPpi (
VOID
);
#endif