* [Patch 1/7] UefiCpuPkg/CpuDxe: Fix duplicated status code report
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 2/7] UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize Jeff Fan
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
If CPU Bist data is not zero, we will report Status code. But there is one bug
that will report each processor's status code duplicated with NumberOfData
times. This fix is to exchange the loop order on NumberOfData and
mNumberOfProcessors. It could make sure the report status code only once for
each processor.
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>
---
UefiCpuPkg/CpuDxe/CpuMp.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index a619a2b..3e4f83f 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -539,6 +539,7 @@ CollectBistDataFromHob (
UINTN ProcessorNumber;
EFI_PROCESSOR_INFORMATION ProcessorInfo;
EFI_HEALTH_FLAGS BistData;
+ UINTN CpuInstanceNumber;
SecPlatformInformation2 = NULL;
SecPlatformInformation = NULL;
@@ -578,25 +579,25 @@ CollectBistDataFromHob (
}
}
- while ((NumberOfData--) > 0) {
- for (ProcessorNumber = 0; ProcessorNumber < mNumberOfProcessors; ProcessorNumber++) {
- MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData);
- if (ProcessorInfo.ProcessorId == CpuInstance[NumberOfData].CpuLocation) {
+ for (ProcessorNumber = 0; ProcessorNumber < mNumberOfProcessors; ProcessorNumber++) {
+ MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData);
+ for (CpuInstanceNumber = 0; CpuInstanceNumber < NumberOfData; CpuInstanceNumber++) {
+ if (ProcessorInfo.ProcessorId == CpuInstance[CpuInstanceNumber].CpuLocation) {
//
// Update CPU health status for MP Services Protocol according to BIST data.
//
- BistData = CpuInstance[NumberOfData].InfoRecord.IA32HealthFlags;
- }
- if (BistData.Uint32 != 0) {
- //
- // Report Status Code that self test is failed
- //
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MAJOR,
- (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST)
- );
+ BistData = CpuInstance[CpuInstanceNumber].InfoRecord.IA32HealthFlags;
}
}
+ if (BistData.Uint32 != 0) {
+ //
+ // Report Status Code that self test is failed
+ //
+ REPORT_STATUS_CODE (
+ EFI_ERROR_CODE | EFI_ERROR_MAJOR,
+ (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST)
+ );
+ }
}
}
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 2/7] UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
2016-09-09 7:59 ` [Patch 1/7] UefiCpuPkg/CpuDxe: Fix duplicated status code report Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 3/7] UefiCpuPkg/CpuMpPei: Fix BistData ouput error Jeff Fan
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
Add one OPTIONAL parameter BistInformationSize for GetBistInfoFromPpi().
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>
---
UefiCpuPkg/CpuMpPei/CpuBist.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c
index 641eb10..dae7d78 100644
--- a/UefiCpuPkg/CpuMpPei/CpuBist.c
+++ b/UefiCpuPkg/CpuMpPei/CpuBist.c
@@ -84,6 +84,7 @@ SecPlatformInformation2 (
@param PpiDescriptor Return a pointer to instance of the
EFI_PEI_PPI_DESCRIPTOR
@param BistInformationData Pointer to BIST information data
+ @param BistInformationSize Return the size in bytes of BIST information
@retval EFI_SUCCESS Retrieve of the BIST data successfully
@retval EFI_NOT_FOUND No sec platform information(2) ppi export
@@ -95,7 +96,8 @@ GetBistInfoFromPpi (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_GUID *Guid,
OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
- OUT VOID **BistInformationData
+ OUT VOID **BistInformationData,
+ OUT UINT64 *BistInformationSize OPTIONAL
)
{
EFI_STATUS Status;
@@ -140,6 +142,9 @@ GetBistInfoFromPpi (
);
if (Status == EFI_SUCCESS) {
*BistInformationData = SecPlatformInformation2;
+ if (BistInformationSize != NULL) {
+ *BistInformationSize = InformationSize;
+ }
return EFI_SUCCESS;
}
}
@@ -191,7 +196,8 @@ CollectBistDataFromPpi (
PeiServices,
&gEfiSecPlatformInformation2PpiGuid,
&SecInformationDescriptor,
- (VOID *) &SecPlatformInformation2
+ (VOID *) &SecPlatformInformation2,
+ NULL
);
if (Status == EFI_SUCCESS) {
//
@@ -207,7 +213,8 @@ CollectBistDataFromPpi (
PeiServices,
&gEfiSecPlatformInformationPpiGuid,
&SecInformationDescriptor,
- (VOID *) &SecPlatformInformation
+ (VOID *) &SecPlatformInformation,
+ NULL
);
if (Status == EFI_SUCCESS) {
NumberOfData = 1;
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 3/7] UefiCpuPkg/CpuMpPei: Fix BistData ouput error
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
2016-09-09 7:59 ` [Patch 1/7] UefiCpuPkg/CpuDxe: Fix duplicated status code report Jeff Fan
2016-09-09 7:59 ` [Patch 2/7] UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 4/7] UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data Jeff Fan
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
ProcessorInfo.ProcessorId is UINT64 type even it's valid value is UINT32. Use %x
only output the low 4 bytes and keep the high 4 bytes in stack that will be
output as the second parameter BistData. Typecast ProcessorInfo.ProcessorId to
UINT32 could make BistData output correctly.
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>
---
UefiCpuPkg/CpuMpPei/CpuBist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c
index dae7d78..f596237 100644
--- a/UefiCpuPkg/CpuMpPei/CpuBist.c
+++ b/UefiCpuPkg/CpuMpPei/CpuBist.c
@@ -250,7 +250,7 @@ CollectBistDataFromPpi (
);
}
DEBUG ((EFI_D_INFO, " APICID - 0x%08x, BIST - 0x%08x\n",
- ProcessorInfo.ProcessorId,
+ (UINT32) ProcessorInfo.ProcessorId,
BistData
));
}
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 4/7] UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
` (2 preceding siblings ...)
2016-09-09 7:59 ` [Patch 3/7] UefiCpuPkg/CpuMpPei: Fix BistData ouput error Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 5/7] UefiCpuPkg/SecCore: Add SecBist.c Jeff Fan
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
Build gEfiSecPlatformInformation2PpiGuid GUIDed-HOB to store all CPU BIST data
that could be used not only by SecPlatformInformation2(), but also by CPU MP Dxe
driver to get CPU BIST data.
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>
---
UefiCpuPkg/CpuMpPei/CpuBist.c | 64 ++++++++++++++++++++++++++--------------
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 1 +
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 4 ++-
3 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c
index f596237..bf18ca4 100644
--- a/UefiCpuPkg/CpuMpPei/CpuBist.c
+++ b/UefiCpuPkg/CpuMpPei/CpuBist.c
@@ -44,34 +44,29 @@ SecPlatformInformation2 (
OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
)
{
- UINTN BistInformationSize;
- UINTN CpuIndex;
- EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance;
- EFI_PROCESSOR_INFORMATION ProcessorInfo;
- EFI_HEALTH_FLAGS BistData;
- UINTN NumberOfProcessors;
- UINTN NumberOfEnabledProcessors;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *DataInHob;
+ UINTN DataSize;
- MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);
+ GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);
+ if (GuidHob == NULL) {
+ *StructureSize = 0;
+ return EFI_SUCCESS;
+ }
+
+ DataInHob = GET_GUID_HOB_DATA (GuidHob);
+ DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
- BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +
- sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;
//
- // return the information size if input buffer size is too small
+ // return the information from BistHob
//
- if ((*StructureSize) < (UINT64) BistInformationSize) {
- *StructureSize = (UINT64) BistInformationSize;
+ if ((*StructureSize) < (UINT64) DataSize) {
+ *StructureSize = (UINT64) DataSize;
return EFI_BUFFER_TOO_SMALL;
}
- PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;
- CpuInstance = PlatformInformationRecord2->CpuInstance;
- for (CpuIndex = 0; CpuIndex < NumberOfProcessors; CpuIndex ++) {
- MpInitLibGetProcessorInfo (CpuIndex, &ProcessorInfo, &BistData);
- CpuInstance[CpuIndex].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;
- CpuInstance[CpuIndex].InfoRecord.IA32HealthFlags = BistData;
- }
-
+ *StructureSize = (UINT64) DataSize;
+ CopyMem (PlatformInformationRecord2, DataInHob, DataSize);
return EFI_SUCCESS;
}
@@ -181,14 +176,26 @@ CollectBistDataFromPpi (
EFI_HEALTH_FLAGS BistData;
UINTN NumberOfProcessors;
UINTN NumberOfEnabledProcessors;
+ UINTN BistInformationSize;
+ EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2;
+ EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob;
+
MpInitLibGetNumberOfProcessors(&NumberOfProcessors, &NumberOfEnabledProcessors);
+ BistInformationSize = sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) +
+ sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * NumberOfProcessors;
+ Status = PeiServicesAllocatePool (
+ (UINTN) BistInformationSize,
+ (VOID **) &PlatformInformationRecord2
+ );
+ ASSERT_EFI_ERROR (Status);
+ PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;
+
SecPlatformInformation2 = NULL;
SecPlatformInformation = NULL;
NumberOfData = 0;
CpuInstance = NULL;
-
//
// Get BIST information from Sec Platform Information2 Ppi firstly
//
@@ -253,7 +260,20 @@ CollectBistDataFromPpi (
(UINT32) ProcessorInfo.ProcessorId,
BistData
));
+ CpuInstanceInHob = PlatformInformationRecord2->CpuInstance;
+ CpuInstanceInHob[ProcessorNumber].CpuLocation = (UINT32) ProcessorInfo.ProcessorId;
+ CpuInstanceInHob[ProcessorNumber].InfoRecord.IA32HealthFlags = BistData;
}
+
+ //
+ // Build SecPlatformInformation2 PPI GUIDed HOB that also could be consumed
+ // by CPU MP driver to get CPU BIST data
+ //
+ BuildGuidDataHob (
+ &gEfiSecPlatformInformation2PpiGuid,
+ PlatformInformationRecord2,
+ (UINTN) BistInformationSize
+ );
if (SecPlatformInformation2 != NULL && NumberOfData < NumberOfProcessors) {
//
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 24931c9..0836593 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -31,6 +31,7 @@
#include <Library/ReportStatusCodeLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/MpInitLib.h>
+#include <Library/BaseMemoryLib.h>
extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index c8461a2..3b40d88 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -47,12 +47,14 @@ [LibraryClasses]
ReportStatusCodeLib
CpuExceptionHandlerLib
MpInitLib
+ BaseMemoryLib
[Ppis]
gEfiPeiMpServicesPpiGuid ## PRODUCES
gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES
## SOMETIMES_CONSUMES
- ## SOMETIMES_PRODUCES
+ ## PRODUCES
+ ## UNDEFINED # HOB
gEfiSecPlatformInformation2PpiGuid
gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 5/7] UefiCpuPkg/SecCore: Add SecBist.c
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
` (3 preceding siblings ...)
2016-09-09 7:59 ` [Patch 4/7] UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 6/7] UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob() Jeff Fan
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
Add SecBist.c and copy GetBistInfoFromPpi() and SecPlatformInformation2() from
UefiCpuPkg/CpuMpPei/CpuBist.c. And update SecMain.c, SecMain.inf and
UefiCpuPkg.dsc accordinlgy to pass build.
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>
---
UefiCpuPkg/SecCore/SecBist.c | 140 +++++++++++++++++++++++++++++++++++++++++
UefiCpuPkg/SecCore/SecCore.inf | 4 ++
UefiCpuPkg/SecCore/SecMain.h | 7 ++-
UefiCpuPkg/UefiCpuPkg.dsc | 3 +
4 files changed, 152 insertions(+), 2 deletions(-)
create mode 100644 UefiCpuPkg/SecCore/SecBist.c
diff --git a/UefiCpuPkg/SecCore/SecBist.c b/UefiCpuPkg/SecCore/SecBist.c
new file mode 100644
index 0000000..cba445d
--- /dev/null
+++ b/UefiCpuPkg/SecCore/SecBist.c
@@ -0,0 +1,140 @@
+/** @file
+ Get SEC platform information(2) PPI and reinstall it.
+
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+ 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
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "SecMain.h"
+
+/**
+ 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
+SecPlatformInformation2 (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN OUT UINT64 *StructureSize,
+ OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *DataInHob;
+ UINTN DataSize;
+
+ GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);
+ if (GuidHob == NULL) {
+ *StructureSize = 0;
+ return EFI_SUCCESS;
+ }
+
+ DataInHob = GET_GUID_HOB_DATA (GuidHob);
+ DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+
+ //
+ // return the information from BistHob
+ //
+ if ((*StructureSize) < (UINT64) DataSize) {
+ *StructureSize = (UINT64) DataSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StructureSize = (UINT64) DataSize;
+ CopyMem (PlatformInformationRecord2, DataInHob, DataSize);
+ return EFI_SUCCESS;
+}
+
+/**
+ Worker function to get CPUs' BIST by calling SecPlatformInformationPpi
+ or SecPlatformInformation2Ppi.
+
+ @param PeiServices Pointer to PEI Services Table
+ @param Guid PPI Guid
+ @param PpiDescriptor Return a pointer to instance of the
+ EFI_PEI_PPI_DESCRIPTOR
+ @param BistInformationData Pointer to BIST information data
+ @param BistInformationSize Return the size in bytes of BIST information
+
+ @retval EFI_SUCCESS Retrieve of the BIST data successfully
+ @retval EFI_NOT_FOUND No sec platform information(2) ppi export
+ @retval EFI_DEVICE_ERROR Failed to get CPU Information
+
+**/
+EFI_STATUS
+GetBistInfoFromPpi (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_GUID *Guid,
+ OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ OUT VOID **BistInformationData,
+ OUT UINT64 *BistInformationSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi;
+ EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;
+ UINT64 InformationSize;
+
+ Status = PeiServicesLocatePpi (
+ Guid, // GUID
+ 0, // INSTANCE
+ PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
+ (VOID **)&SecPlatformInformation2Ppi // PPI
+ );
+ if (Status == EFI_NOT_FOUND) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // Get the size of the sec platform information2(BSP/APs' BIST data)
+ //
+ InformationSize = 0;
+ SecPlatformInformation2 = NULL;
+ Status = SecPlatformInformation2Ppi->PlatformInformation2 (
+ PeiServices,
+ &InformationSize,
+ SecPlatformInformation2
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Status = PeiServicesAllocatePool (
+ (UINTN) InformationSize,
+ (VOID **) &SecPlatformInformation2
+ );
+ if (Status == EFI_SUCCESS) {
+ //
+ // Retrieve BIST data
+ //
+ Status = SecPlatformInformation2Ppi->PlatformInformation2 (
+ PeiServices,
+ &InformationSize,
+ SecPlatformInformation2
+ );
+ if (Status == EFI_SUCCESS) {
+ *BistInformationData = SecPlatformInformation2;
+ if (BistInformationSize != NULL) {
+ *BistInformationSize = InformationSize;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+
+ return EFI_DEVICE_ERROR;
+}
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index 4e598cb..e875cff 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -37,6 +37,7 @@ [Sources]
SecMain.c
SecMain.h
FindPeiCore.c
+ SecBist.c
[Sources.IA32]
Ia32/ResetVec.nasmb
@@ -58,6 +59,9 @@ [LibraryClasses]
PeCoffExtraActionLib
CpuExceptionHandlerLib
ReportStatusCodeLib
+ PeiServicesLib
+ PeiServicesTablePointerLib
+ HobLib
[Ppis]
gEfiSecPlatformInformationPpiGuid ## PRODUCES
diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h
index 05175d2..2484a0f 100644
--- a/UefiCpuPkg/SecCore/SecMain.h
+++ b/UefiCpuPkg/SecCore/SecMain.h
@@ -1,7 +1,7 @@
/** @file
Master header file for SecCore.
- Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>
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
@@ -18,6 +18,7 @@
#include <PiPei.h>
#include <Ppi/SecPlatformInformation.h>
+#include <Ppi/SecPlatformInformation2.h>
#include <Ppi/TemporaryRamDone.h>
#include <Library/BaseLib.h>
@@ -31,7 +32,9 @@
#include <Library/DebugAgentLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/ReportStatusCodeLib.h>
-
+#include <Library/PeiServicesTablePointerLib.h>
+#include <Library/HobLib.h>
+#include <Library/PeiServicesLib.h>
#define SEC_IDT_ENTRY_COUNT 34
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index d4a6673..bfe0fbd 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -65,6 +65,9 @@ [LibraryClasses]
[LibraryClasses.common.SEC]
PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
[LibraryClasses.common.PEIM]
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 6/7] UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob()
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
` (4 preceding siblings ...)
2016-09-09 7:59 ` [Patch 5/7] UefiCpuPkg/SecCore: Add SecBist.c Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-09 7:59 ` [Patch 7/7] UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI Jeff Fan
2016-09-13 7:41 ` [Patch 0/7] Re-install SEC Platform Information PPI Tian, Feng
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
Abstract one worker function to get CPU BIST from the GUIDed-HOB. Add
SecPlatformInformationBist() and SecPlatformInformation2Bist() to invoke
GetBistFromHob(). Add in/out for parameter in function header.
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>
---
UefiCpuPkg/SecCore/SecBist.c | 81 +++++++++++++++++++++++++++++++++-----------
1 file changed, 61 insertions(+), 20 deletions(-)
diff --git a/UefiCpuPkg/SecCore/SecBist.c b/UefiCpuPkg/SecCore/SecBist.c
index cba445d..10bebbc 100644
--- a/UefiCpuPkg/SecCore/SecBist.c
+++ b/UefiCpuPkg/SecCore/SecBist.c
@@ -15,30 +15,26 @@
#include "SecMain.h"
/**
- Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
+ Worker function to parse CPU BIST information from Guided HOB.
- @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.
+ @param[out] StructureSize Pointer to the variable describing size of the input buffer.
+ @param[out] StructureBuffer Pointer to the buffer save CPU BIST information.
- @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.
+ @retval EFI_SUCCESS The data was successfully returned.
+ @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
**/
EFI_STATUS
-EFIAPI
-SecPlatformInformation2 (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN OUT UINT64 *StructureSize,
- OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
+GetBistFromHob (
+ IN OUT UINT64 *StructureSize,
+ IN OUT VOID *StructureBuffer
)
{
EFI_HOB_GUID_TYPE *GuidHob;
VOID *DataInHob;
UINTN DataSize;
- GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid);
+ GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);
if (GuidHob == NULL) {
*StructureSize = 0;
return EFI_SUCCESS;
@@ -56,20 +52,65 @@ SecPlatformInformation2 (
}
*StructureSize = (UINT64) DataSize;
- CopyMem (PlatformInformationRecord2, DataInHob, DataSize);
+ CopyMem (StructureBuffer, DataInHob, DataSize);
return EFI_SUCCESS;
}
/**
+ Implementation of the PlatformInformation service in EFI_SEC_PLATFORM_INFORMATION_PPI.
+
+ @param[in] PeiServices Pointer to the PEI Services Table.
+ @param[out] StructureSize Pointer to the variable describing size of the input buffer.
+ @param[out 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
+ )
+{
+ return GetBistFromHob (StructureSize, PlatformInformationRecord);
+}
+
+/**
+ Implementation of the PlatformInformation2 service in EFI_SEC_PLATFORM_INFORMATION2_PPI.
+
+ @param[in] PeiServices The pointer to the PEI Services Table.
+ @param[out] StructureSize The pointer to the variable describing size of the input buffer.
+ @param[out] 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
+ )
+{
+ return GetBistFromHob (StructureSize, PlatformInformationRecord2);
+}
+
+/**
Worker function to get CPUs' BIST by calling SecPlatformInformationPpi
or SecPlatformInformation2Ppi.
- @param PeiServices Pointer to PEI Services Table
- @param Guid PPI Guid
- @param PpiDescriptor Return a pointer to instance of the
- EFI_PEI_PPI_DESCRIPTOR
- @param BistInformationData Pointer to BIST information data
- @param BistInformationSize Return the size in bytes of BIST information
+ @param[in] PeiServices Pointer to PEI Services Table
+ @param[in] Guid PPI Guid
+ @param[out] PpiDescriptor Return a pointer to instance of the
+ EFI_PEI_PPI_DESCRIPTOR
+ @param[out] BistInformationData Pointer to BIST information data
+ @param[out] BistInformationSize Return the size in bytes of BIST information
@retval EFI_SUCCESS Retrieve of the BIST data successfully
@retval EFI_NOT_FOUND No sec platform information(2) ppi export
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Patch 7/7] UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
` (5 preceding siblings ...)
2016-09-09 7:59 ` [Patch 6/7] UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob() Jeff Fan
@ 2016-09-09 7:59 ` Jeff Fan
2016-09-13 7:41 ` [Patch 0/7] Re-install SEC Platform Information PPI Tian, Feng
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Fan @ 2016-09-09 7:59 UTC (permalink / raw)
To: edk2-devel; +Cc: Michael Kinney, Feng Tian, Giri P Mudusuru
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>
---
UefiCpuPkg/SecCore/SecBist.c | 87 ++++++++++++++++++++++++++++++++++++++++++
UefiCpuPkg/SecCore/SecCore.inf | 7 +++-
UefiCpuPkg/SecCore/SecMain.c | 5 +++
UefiCpuPkg/SecCore/SecMain.h | 48 +++++++++++++++++++++++
4 files changed, 146 insertions(+), 1 deletion(-)
diff --git a/UefiCpuPkg/SecCore/SecBist.c b/UefiCpuPkg/SecCore/SecBist.c
index 10bebbc..dd5c5e5 100644
--- a/UefiCpuPkg/SecCore/SecBist.c
+++ b/UefiCpuPkg/SecCore/SecBist.c
@@ -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);
+}
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index e875cff..0d135e6 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -64,7 +64,12 @@ [LibraryClasses]
HobLib
[Ppis]
- gEfiSecPlatformInformationPpiGuid ## PRODUCES
+ ## SOMETIMES_CONSUMES
+ ## PRODUCES
+ gEfiSecPlatformInformationPpiGuid
+ ## SOMETIMES_CONSUMES
+ ## SOMETIMES_PRODUCES
+ gEfiSecPlatformInformation2PpiGuid
gEfiTemporaryRamDonePpiGuid ## PRODUCES
[Pcd]
diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c
index 5e5d543..af1e661 100644
--- a/UefiCpuPkg/SecCore/SecMain.c
+++ b/UefiCpuPkg/SecCore/SecMain.c
@@ -274,6 +274,11 @@ SecTemporaryRamDone (
BOOLEAN State;
//
+ // Republish Sec Platform Information(2) PPI
+ //
+ RepublishSecPlatformInformationPpi ();
+
+ //
// Migrate DebugAgentContext.
//
InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);
diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h
index 2484a0f..6e31a95 100644
--- a/UefiCpuPkg/SecCore/SecMain.h
+++ b/UefiCpuPkg/SecCore/SecMain.h
@@ -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
--
2.9.3.windows.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Patch 0/7] Re-install SEC Platform Information PPI
2016-09-09 7:59 [Patch 0/7] Re-install SEC Platform Information PPI Jeff Fan
` (6 preceding siblings ...)
2016-09-09 7:59 ` [Patch 7/7] UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI Jeff Fan
@ 2016-09-13 7:41 ` Tian, Feng
7 siblings, 0 replies; 9+ messages in thread
From: Tian, Feng @ 2016-09-13 7:41 UTC (permalink / raw)
To: Fan, Jeff, edk2-devel@lists.01.org; +Cc: Tian, Feng
Looks good to me
Reviewed-by: Feng Tian <feng.tian@Intel.com>
Thanks
Feng
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jeff Fan
Sent: Friday, September 9, 2016 3:59 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch 0/7] Re-install SEC Platform Information PPI
Platform SEC Lib will save CPU BIST into CAR and install SEC Platform
information(2) PPI. But after memory is ready, all data in CAR will be cleared.
We update UefiCpuPkg/SecCore to re-install SEC platform information(2) PPI before CAR is cleared.
We also update CpuMpPei driver to build Sec Platform Information2 PPI GUIDed-HOB to pass all CPU BIST date to DXE phase.
Jeff Fan (7):
UefiCpuPkg/CpuDxe: Fix duplicated status code report
UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize
UefiCpuPkg/CpuMpPei: Fix BistData ouput error
UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data
UefiCpuPkg/SecCore: Add SecBist.c
UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob()
UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI
UefiCpuPkg/CpuDxe/CpuMp.c | 29 +++--
UefiCpuPkg/CpuMpPei/CpuBist.c | 79 ++++++++----
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 1 +
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 4 +-
UefiCpuPkg/SecCore/SecBist.c | 268 +++++++++++++++++++++++++++++++++++++++
UefiCpuPkg/SecCore/SecCore.inf | 11 +-
UefiCpuPkg/SecCore/SecMain.c | 5 +
UefiCpuPkg/SecCore/SecMain.h | 55 +++++++-
UefiCpuPkg/UefiCpuPkg.dsc | 3 +
9 files changed, 411 insertions(+), 44 deletions(-) create mode 100644 UefiCpuPkg/SecCore/SecBist.c
--
2.9.3.windows.2
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 9+ messages in thread