Date   

Re: [PATCH v2] BaseTools/EfiRom: supply missing machine type lookup strings

Laszlo Ersek
 

On 09/09/16 09:25, Gao, Liming wrote:
Reviewed-by: Liming Gao <liming.gao@...>
Thanks.

Ard, are you OK with this patch? (You were OK with "ARM" in advance, but
the AARCH64 string also changed in this version.)

Thanks
Laszlo

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@...]
Sent: Friday, September 09, 2016 3:24 PM
To: edk2-devel-01 <edk2-devel@...>
Cc: Ard Biesheuvel <ard.biesheuvel@...>; Gao, Liming
<liming.gao@...>; Zhu, Yonghong <yonghong.zhu@...>
Subject: [PATCH v2] BaseTools/EfiRom: supply missing machine type lookup
strings

"EfiRom --dump" does not recognize the 0x8664 machine type:

EFI ROM header contents
EFI Signature 0x0EF1
Compression Type 0x0001 (compressed)
Machine type 0x8664 (unknown)
Subsystem 0x000B (EFI boot service driver)
EFI image offset 0x0050 (@0xF650)
Add lookup strings for the remaining EFI_IMAGE_MACHINE_* numeric
macros
that can be found in
"BaseTools/Source/C/Include/IndustryStandard/PeImage.h". The strings
follow Table 12. "UEFI Image Types" from the UEFI v2.6 spec.

Cc: Ard Biesheuvel <ard.biesheuvel@...>
Cc: Liming Gao <liming.gao@...>
Cc: Yonghong Zhu <yonghong.zhu@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@...>
---

Notes:
v2:
- use ARM for ARM [Ard, Liming]
- use AA64 for AARCH64 [Liming]
- reference Table 12 in the commit message [Liming]

BaseTools/Source/C/EfiRom/EfiRom.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h
b/BaseTools/Source/C/EfiRom/EfiRom.h
index 1214700826de..6763d6b1ec28 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -117,6 +117,9 @@ static STRING_LOOKUP mMachineTypes[] = {
{ EFI_IMAGE_MACHINE_IA32, "IA32" },
{ EFI_IMAGE_MACHINE_IA64, "IA64" },
{ EFI_IMAGE_MACHINE_EBC, "EBC" },
+ { EFI_IMAGE_MACHINE_X64, "X64" },
+ { EFI_IMAGE_MACHINE_ARMT, "ARM" },
+ { EFI_IMAGE_MACHINE_AARCH64, "AA64" },
{ 0, NULL }
};

--
2.9.2


[PATCH 2/2] Platforms/ARM/FVP: limit VA range to 36 bits

Ard Biesheuvel
 

The FVP model has up to 8 GB of memory (on the Base model), where the
top 6GB starts at 0x8_8000_0000, and all other memory regions of interest
live below that. This means we can cover the whole VA space with 36-bits
worth of VA.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...>
---
Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
index 3d8e0cfbb57e..60df45dca276 100644
--- a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
+++ b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
@@ -175,6 +175,9 @@
# Set tick frequency value to 100Mhz
gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|100000000

+ # the entire FVP address space can be covered by 36 bit VAs
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|36
+
[PcdsDynamicDefault.common]
#
# The size of a dynamic PCD of the (VOID*) type can not be increased at run
--
2.7.4


[PATCH 1/2] Platforms/AMD/Styx: limit VA space to 40 bits

Ard Biesheuvel
 

We can cover the entire MMIO range and 512 GB of memory starting at
0x80_0000_0000 using 40 bits of VA space, both in the page tables and
in the GCD memory map.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...>
---
Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc | 5 +++++
Platforms/AMD/Styx/OverdriveBoard/OverdriveBoard.dsc | 5 +++++
2 files changed, 10 insertions(+)

diff --git a/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc b/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
index 8a100e0d9a3c..0a987cc3b118 100644
--- a/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
+++ b/Platforms/AMD/Styx/CelloBoard/CelloBoard.dsc
@@ -375,6 +375,11 @@ DEFINE DO_KCS = 0
# Size of the region used by UEFI in permanent memory (Reserved 64MB)
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000

+ # 40 bits of VA space is sufficient to support up to 512 GB of RAM in the
+ # range 0x80_0000_0000 - 0xFF_FFFF_FFFF (all platform and PCI MMIO is below
+ # that)
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
+
#
# ARM PrimeCell
#
diff --git a/Platforms/AMD/Styx/OverdriveBoard/OverdriveBoard.dsc b/Platforms/AMD/Styx/OverdriveBoard/OverdriveBoard.dsc
index 38c3309dcff1..72ceb8b6994e 100644
--- a/Platforms/AMD/Styx/OverdriveBoard/OverdriveBoard.dsc
+++ b/Platforms/AMD/Styx/OverdriveBoard/OverdriveBoard.dsc
@@ -382,6 +382,11 @@ DEFINE DO_KCS = 1
# Size of the region used by UEFI in permanent memory (Reserved 64MB)
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000

+ # 40 bits of VA space is sufficient to support up to 512 GB of RAM in the
+ # range 0x80_0000_0000 - 0xFF_FFFF_FFFF (all platform and PCI MMIO is below
+ # that)
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
+
#
# ARM PrimeCell
#
--
2.7.4


[PATCH] ArmPkg/ArmMmuLib: base page table VA size on GCD memory map size

Ard Biesheuvel
 

As reported by Eugene, the practice of sizing the address space in the
virtual memory system based on the maximum address in the table passed
to ArmConfigureMmu() is problematic, since it fails to take into account
the fact that the GCD memory space may be extended at a later time, both
for memory and for MMIO. So instead, choose the VA size identical to the
GCD memory map size, which is based on PcdPrePiCpuMemorySize on ARM
systems.

Reported-by: Eugene Cohen <eugene@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...>
---
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 14 ++------------
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 4 ++++
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 4 ++++
3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 6e05e6085011..b5900a761f80 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -582,9 +582,7 @@ ArmConfigureMmu (
VOID* TranslationTable;
UINTN TranslationTablePageCount;
UINT32 TranslationTableAttribute;
- ARM_MEMORY_REGION_DESCRIPTOR *MemoryTableEntry;
UINT64 MaxAddress;
- UINT64 TopAddress;
UINTN T0SZ;
UINTN RootTableEntryCount;
UINT64 TCR;
@@ -595,16 +593,8 @@ ArmConfigureMmu (
return RETURN_INVALID_PARAMETER;
}

- // Identify the highest address of the memory table
- MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1;
- MemoryTableEntry = MemoryTable;
- while (MemoryTableEntry->Length != 0) {
- TopAddress = MemoryTableEntry->PhysicalBase + MemoryTableEntry->Length - 1;
- if (TopAddress > MaxAddress) {
- MaxAddress = TopAddress;
- }
- MemoryTableEntry++;
- }
+ // Cover the entire GCD memory space
+ MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1;

// Lookup the Table Level to get the information
LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
index 1533c2944e8e..b9f264de8d26 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -32,6 +32,7 @@ [Sources.ARM]

[Packages]
ArmPkg/ArmPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec

[LibraryClasses]
@@ -39,5 +40,8 @@ [LibraryClasses]
CacheMaintenanceLib
MemoryAllocationLib

+[Pcd.AARCH64]
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
+
[Pcd.ARM]
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
index 14ebf8de673d..ecf13f790734 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
@@ -28,9 +28,13 @@ [Sources.AARCH64]

[Packages]
ArmPkg/ArmPkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec

[LibraryClasses]
ArmLib
CacheMaintenanceLib
MemoryAllocationLib
+
+[Pcd.AARCH64]
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
--
2.7.4


[Patch 7/7] UefiCpuPkg/SecCore: Re-install SEC platform information(2) PPI

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 6/7] UefiCpuPkg/SecCore: Abstract worker function GetBistFromHob()

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 5/7] UefiCpuPkg/SecCore: Add SecBist.c

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 4/7] UefiCpuPkg/CpuMpPei: Build GUIDed-HOB to store all CPU BIST Data

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 3/7] UefiCpuPkg/CpuMpPei: Fix BistData ouput error

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 2/7] UefiCpuPkg/CpuMpPei: Add parameter BistInformationSize

Jeff Fan <jeff.fan@...>
 

Add one OPTIONAL parameter BistInformationSize for GetBistInfoFromPpi().

Cc: Michael Kinney <michael.d.kinney@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 1/7] UefiCpuPkg/CpuDxe: Fix duplicated status code report

Jeff Fan <jeff.fan@...>
 

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@...>
Cc: Feng Tian <feng.tian@...>
Cc: Giri P Mudusuru <giri.p.mudusuru@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@...>
---
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


[Patch 0/7] Re-install SEC Platform Information PPI

Jeff Fan <jeff.fan@...>
 

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


[PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output

Ard Biesheuvel
 

As reported by Vishal, the new backtrace output would be more useful if
it did not contain the full absolute path of each module in the list.
So strip off everything up to the last forward slash or backslash in the
string.

Example output:

IRQ Exception at 0x000000005EF110E0
DxeCore.dll loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EF121F0) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EF1289C) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEFB6B4) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEFAA44) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEFB450) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEF938C) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEF8D04) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEFA8E8) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEF3C14) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEF3E48) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EF0C838) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEEF70C) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEEE93C) loaded at 0x000000005EEED000
called from DxeCore.dll (0x000000005EEEE024) loaded at 0x000000005EEED000

Suggested-by: "Oliyil Kunnil, Vishal" <vishalo@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...>
---
ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 24 +++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index 84b442f2b6f4..177231dbdb97 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -119,6 +119,24 @@ DescribeExceptionSyndrome (
DEBUG ((EFI_D_ERROR, "\n %a \n", Message));
}

+STATIC
+CONST CHAR8 *
+BaseName (
+ IN CONST CHAR8 *FullName
+ )
+{
+ CONST CHAR8 *Str;
+
+ Str = FullName + AsciiStrLen (FullName);
+
+ while (--Str > FullName) {
+ if (*Str == '/' || *Str == '\\') {
+ return Str + 1;
+ }
+ }
+ return Str;
+}
+
/**
This is the default action to take on an unexpected exception

@@ -156,13 +174,13 @@ DefaultExceptionHandler (

Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
- DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", Pdb, ImageBase));
+ DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", BaseName (Pdb), ImageBase));

Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase,
&PeCoffSizeOfHeader);
if (Pdb != NULL) {
DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
- Pdb, SystemContext.SystemContextAArch64->LR, ImageBase));
+ BaseName (Pdb), SystemContext.SystemContextAArch64->LR, ImageBase));
}
for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP;
*Fp != 0;
@@ -173,7 +191,7 @@ DefaultExceptionHandler (
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) {
DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
- Pdb, Fp[1], ImageBase));
+ BaseName (Pdb), Fp[1], ImageBase));
}
}
}
--
2.7.4


Re: [PATCH v2] BaseTools/EfiRom: supply missing machine type lookup strings

Liming Gao
 

Reviewed-by: Liming Gao <liming.gao@...>

-----Original Message-----
From: Laszlo Ersek [mailto:lersek@...]
Sent: Friday, September 09, 2016 3:24 PM
To: edk2-devel-01 <edk2-devel@...>
Cc: Ard Biesheuvel <ard.biesheuvel@...>; Gao, Liming
<liming.gao@...>; Zhu, Yonghong <yonghong.zhu@...>
Subject: [PATCH v2] BaseTools/EfiRom: supply missing machine type lookup
strings

"EfiRom --dump" does not recognize the 0x8664 machine type:

EFI ROM header contents
EFI Signature 0x0EF1
Compression Type 0x0001 (compressed)
Machine type 0x8664 (unknown)
Subsystem 0x000B (EFI boot service driver)
EFI image offset 0x0050 (@0xF650)
Add lookup strings for the remaining EFI_IMAGE_MACHINE_* numeric
macros
that can be found in
"BaseTools/Source/C/Include/IndustryStandard/PeImage.h". The strings
follow Table 12. "UEFI Image Types" from the UEFI v2.6 spec.

Cc: Ard Biesheuvel <ard.biesheuvel@...>
Cc: Liming Gao <liming.gao@...>
Cc: Yonghong Zhu <yonghong.zhu@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@...>
---

Notes:
v2:
- use ARM for ARM [Ard, Liming]
- use AA64 for AARCH64 [Liming]
- reference Table 12 in the commit message [Liming]

BaseTools/Source/C/EfiRom/EfiRom.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h
b/BaseTools/Source/C/EfiRom/EfiRom.h
index 1214700826de..6763d6b1ec28 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -117,6 +117,9 @@ static STRING_LOOKUP mMachineTypes[] = {
{ EFI_IMAGE_MACHINE_IA32, "IA32" },
{ EFI_IMAGE_MACHINE_IA64, "IA64" },
{ EFI_IMAGE_MACHINE_EBC, "EBC" },
+ { EFI_IMAGE_MACHINE_X64, "X64" },
+ { EFI_IMAGE_MACHINE_ARMT, "ARM" },
+ { EFI_IMAGE_MACHINE_AARCH64, "AA64" },
{ 0, NULL }
};

--
2.9.2


[PATCH v2] BaseTools/EfiRom: supply missing machine type lookup strings

Laszlo Ersek
 

"EfiRom --dump" does not recognize the 0x8664 machine type:

EFI ROM header contents
EFI Signature 0x0EF1
Compression Type 0x0001 (compressed)
Machine type 0x8664 (unknown)
Subsystem 0x000B (EFI boot service driver)
EFI image offset 0x0050 (@0xF650)
Add lookup strings for the remaining EFI_IMAGE_MACHINE_* numeric macros
that can be found in
"BaseTools/Source/C/Include/IndustryStandard/PeImage.h". The strings
follow Table 12. "UEFI Image Types" from the UEFI v2.6 spec.

Cc: Ard Biesheuvel <ard.biesheuvel@...>
Cc: Liming Gao <liming.gao@...>
Cc: Yonghong Zhu <yonghong.zhu@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@...>
---

Notes:
v2:
- use ARM for ARM [Ard, Liming]
- use AA64 for AARCH64 [Liming]
- reference Table 12 in the commit message [Liming]

BaseTools/Source/C/EfiRom/EfiRom.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h b/BaseTools/Source/C/EfiRom/EfiRom.h
index 1214700826de..6763d6b1ec28 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -117,6 +117,9 @@ static STRING_LOOKUP mMachineTypes[] = {
{ EFI_IMAGE_MACHINE_IA32, "IA32" },
{ EFI_IMAGE_MACHINE_IA64, "IA64" },
{ EFI_IMAGE_MACHINE_EBC, "EBC" },
+ { EFI_IMAGE_MACHINE_X64, "X64" },
+ { EFI_IMAGE_MACHINE_ARMT, "ARM" },
+ { EFI_IMAGE_MACHINE_AARCH64, "AA64" },
{ 0, NULL }
};

--
2.9.2


[PATCH] MdePkg/BaseLib AARCH64: terminate stack frame list on stack switch

Ard Biesheuvel
 

When switching to the DXE phase stack, set the frame pointer to zero so
that code walking the stack frame will not try to access stack frames\
belonging to the old stack.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...>
---
MdePkg/Library/BaseLib/AArch64/SwitchStack.S | 1 +
1 file changed, 1 insertion(+)

diff --git a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S b/MdePkg/Library/BaseLib/AArch64/SwitchStack.S
index 2bce9c998f4f..c3ac8d7e4dfe 100644
--- a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S
+++ b/MdePkg/Library/BaseLib/AArch64/SwitchStack.S
@@ -40,6 +40,7 @@ InternalSwitchStackAsm (
);
**/
ASM_PFX(InternalSwitchStackAsm):
+ mov x29, #0
mov x30, x0
mov sp, x3
mov x0, x1
--
2.7.4


Re: [PATCH] BaseTools/EfiRom: supply missing machine type lookup strings

Liming Gao
 

Laszlo:
UEFI spec defines machine type short-name for each machine type in Table 12 UEFI Image Types of 3.5.1.1 Removable Media Boot Behavior. I suggest we follow the name in UEFI spec. In this table, AArch32 architecture BOOTARM.EFI, AArch64 architecture BOOTAA64.EFI. So, AArch32 name is ARM, AArch64 name is AA64.

Thanks
Liming
From: Laszlo Ersek [mailto:lersek@...]
Sent: Friday, September 09, 2016 5:30 AM
To: Ard Biesheuvel <ard.biesheuvel@...>
Cc: edk2-devel@... <edk2-devel@...>; Gao, Liming <liming.gao@...>
Subject: Re: [edk2] [PATCH] BaseTools/EfiRom: supply missing machine type lookup strings

On 09/08/16 22:39, Ard Biesheuvel wrote:
On 8 September 2016 at 20:55, Laszlo Ersek wrote:
"EfiRom --dump" does not recognize the 0x8664 machine type:

EFI ROM header contents
EFI Signature 0x0EF1
Compression Type 0x0001 (compressed)
Machine type 0x8664 (unknown)
Subsystem 0x000B (EFI boot service driver)
EFI image offset 0x0050 (@0xF650)
Add lookup strings for the remaining EFI_IMAGE_MACHINE_* numeric macros
that can be found in
"BaseTools/Source/C/Include/IndustryStandard/PeImage.h".

Cc: Liming Gao
Cc: Yonghong Zhu
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek
---
BaseTools/Source/C/EfiRom/EfiRom.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h b/BaseTools/Source/C/EfiRom/EfiRom.h
index 1214700826de..461963b4a701 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -117,6 +117,9 @@ static STRING_LOOKUP mMachineTypes[] = {
{ EFI_IMAGE_MACHINE_IA32, "IA32" },
{ EFI_IMAGE_MACHINE_IA64, "IA64" },
{ EFI_IMAGE_MACHINE_EBC, "EBC" },
+ { EFI_IMAGE_MACHINE_X64, "X64" },
+ { EFI_IMAGE_MACHINE_ARMT, "ARMT" },
Just 'ARM', please? PE/COFF has multiple machine types for ARM, but
EFI only uses this one for ARM (0x1c2)

With that change,

Reviewed-by: Ard Biesheuvel
I wasn't sure if we wanted to use the edk2 architecture identifiers
here, or the last _FOO substrings from the macro names verbatim.

One fact that supported just picking _FOO is:

"BaseTools/Source/C/Include/IndustryStandard/PeImage.h" has two mappings
for Itanium (different macro name, same replacement text):

#define EFI_IMAGE_MACHINE_IA64 IMAGE_FILE_MACHINE_IA64
#define EFI_IMAGE_MACHINE_IPF IMAGE_FILE_MACHINE_IA64

The identifier that you can find in the edk2 INF files is IPF, not IA64,
but the above lookup strings include IA64, not IPF. This suggested that
the _FOO suffixes were authoritative, not the arch identifiers that we
use in the DSC / INF etc files.

I'm fine either way, but I would like to hear back from the BaseTools
maintainers too. Because, if we go with ARM, but keep IA64 (rather than
IPF), then that's a (differently) inconsistent situation. And if we
change IA64 to IPF as well, then downstream scripts that presumably
parse the output might break... Fun...

For now I prefer ARMT. Ugly but self-consistent (within the tool). If
Liming / Yonghong agree with you, I'll be happy to repost.

Thanks!
Laszlo


Re: [PATCH v2 0/2][edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib: Version renegotiate

Wu, Jiaxin <jiaxin.wu@...>
 

Series Reviewed-By: Wu Jiaxin <jiaxin.wu@...>

Best Regards!
Jiaxin

-----Original Message-----
From: Thomas Palmer [mailto:thomas.palmer@...]
Sent: Friday, September 9, 2016 3:16 AM
To: edk2-devel@...
Cc: Wu, Jiaxin <jiaxin.wu@...>; joseph.shifflett@...; Thomas
Palmer <thomas.palmer@...>
Subject: [PATCH v2 0/2][edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib:
Version renegotiate

The TLS protocol allows for clients and servers to negotiate which version of
TLS to use. Newer versions are deemed safer, so when they are available the
client and server should opt to use them.

The EDK2 TLS code today only allows TLSv1.0 for TLS communication,
regardless of the target server's capabilities. In order to use the newer
protocols, we'll update the EDK2 TlsLib.c code to allow for TLS version
negotiation when a new TLS object is created. The TLS version specified in
TlsCtxNew will be the minimum version accepted.

Because EDK2 is not yet using OpenSSL 1.1, we use SSL_set_options to
simulate SSL_CTX_set_min_proto_version.

We'll leave the current "EfiTlsVersion" functionality intact, which will restrict
which version of TLS to use and prevent negotiation.

However, to demonstrate the TLS regotiation in this feature branch, we'll
remove the code that calls EfiTlsVersion in the HttpDxe module.

Contributed-under: TianoCore Contribution Agreement 1.0

Thomas Palmer (2):
[edk2-staging/HTTPS-TLS][PATCH]: CryptoPkg/TlsLib: TLS Ver negotiate
[edk2-staging/HTTPS-TLS][PATCH]: NetworkPkg/HttpDxe: Unrestrict TLSv

CryptoPkg/Library/TlsLib/TlsLib.c | 20 ++++++++++++++++----
NetworkPkg/HttpDxe/HttpsSupport.c | 14 +-------------
2 files changed, 17 insertions(+), 17 deletions(-)

--
2.7.4


Re: [patch] MdeModulePkg/UiApp: Fix incorrect question id

Dong, Eric
 

Reviewed-by: Eric Dong <eric.dong@...>

-----Original Message-----
From: Bi, Dandan
Sent: Thursday, September 08, 2016 5:10 PM
To: edk2-devel@...
Cc: Gao, Liming; Dong, Eric
Subject: [patch] MdeModulePkg/UiApp: Fix incorrect question id

For a question, its question id can not be zero.
This patch is to fix the issue that using zero as question id.

Cc: Liming Gao <liming.gao@...>
Cc: Eric Dong <eric.dong@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@...>
---
MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
index 93f6e4e..1505ef9 100644
--- a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
+++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c
@@ -41,10 +41,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define UI_HII_DRIVER_LIST_SIZE 0x8

#define FRONT_PAGE_KEY_CONTINUE 0x1000
#define FRONT_PAGE_KEY_RESET 0x1001
#define FRONT_PAGE_KEY_LANGUAGE 0x1002
+#define FRONT_PAGE_KEY_DRIVER 0x2000

typedef struct {
EFI_STRING_ID PromptId;
EFI_STRING_ID HelpId;
EFI_STRING_ID DevicePathId;
@@ -654,11 +655,11 @@ UiListThirdPartyDrivers (
StartOpCodeHandle,
0,
gHiiDriverList[Index].PromptId,
gHiiDriverList[Index].HelpId,
0,
- 0,
+ (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_DRIVER),
0,
&gHiiDriverList[Index].FormSetGuid,
gHiiDriverList[Index].DevicePathId
);

--
1.9.5.msysgit.1


Re: [patch] MdeModulePkg/HiiDB: Handle the "&READONLY" tag in <KeywordResp> correctly

Dong, Eric
 

Reviewed-by: Eric Dong <eric.dong@...>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@...] On Behalf Of Dandan Bi
Sent: Thursday, September 08, 2016 5:10 PM
To: edk2-devel@...
Cc: Dong, Eric; Gao, Liming
Subject: [edk2] [patch] MdeModulePkg/HiiDB: Handle the "&READONLY" tag in <KeywordResp> correctly

This patch is to fix the incorrect logic when handling the "&READONLY" tag
in <KeywordResp>.
1. In UEFI spec, the "&READONLY" tag is in upper case, but using the lower
case in current codes by mistake.
2. The logic in checking the ReadOnly flag is not correct. Whether having
"&READONLY" tag must be consistent with the result of
"ExtractReadOnlyFromOpCode" function.

Cc: Liming Gao <liming.gao@...>
Cc: Eric Dong <eric.dong@...>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@...>
---
.../Universal/HiiDatabaseDxe/ConfigKeywordHandler.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 6682319..10a901f 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -2905,15 +2905,15 @@ EfiConfigKeywordHandlerSetData (
goto Done;
}
StringPtr = NextStringPtr;

//
- // 5. Find ReadOnly filter.
+ // 5. Find READONLY tag.
//
- if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&ReadOnly", StrLen (L"&ReadOnly")) == 0) {
+ if ((StringPtr != NULL) && StrnCmp (StringPtr, L"&READONLY", StrLen (L"&READONLY")) == 0) {
ReadOnly = TRUE;
- StringPtr += StrLen (L"&ReadOnly");
+ StringPtr += StrLen (L"&READONLY");
} else {
ReadOnly = FALSE;
}

//
@@ -2935,13 +2935,22 @@ EfiConfigKeywordHandlerSetData (

//
// 8. Check the readonly flag.
//
if (ExtractReadOnlyFromOpCode (OpCode) != ReadOnly) {
+ //
+ // Extracting readonly flag form opcode and extracting "READONLY" tag form KeywordString should have the same results.
+ // If not, the input KeywordString must be incorrect, return the error status to caller.
+ //
+ *ProgressErr = KEYWORD_HANDLER_INCOMPATIBLE_VALUE_DETECTED;
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ if (ReadOnly) {
*ProgressErr = KEYWORD_HANDLER_ACCESS_NOT_PERMITTED;
Status = EFI_ACCESS_DENIED;
- goto Done;
+ goto Done;
}

//
// 9. Merge to the MultiKeywordResp string.
//
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@...
https://lists.01.org/mailman/listinfo/edk2-devel