[edk2] [PATCH] UefiCpuPkg/CpuDxe: Fix assert issue on IA32 platform

2017-09-28 Thread Jian J Wang
This patch is to fix an assert issue during booting IA32 platforms
such as OvmfIa32 or Quark. This issue is caused by trying to access
page table on a platform without page table. A check is added to
avoid the assert.

Bug tracker: https://bugzilla.tianocore.org/show_bug.cgi?id=724

c: Star Zeng 
Cc: Jiewen Yao 
Cc: Michael Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 48 --
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 4e8fa100e0..85a520079f 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -683,7 +683,7 @@ SetGcdMemorySpaceAttributes (
 
 **/
 VOID
-RefreshGcdMemoryAttributes (
+RefreshMemoryAttributesFromMtrr (
   VOID
   )
 {
@@ -704,14 +704,9 @@ RefreshGcdMemoryAttributes (
   UINT32  FirmwareVariableMtrrCount;
   UINT8   DefaultMemoryType;
 
-  if (!IsMtrrSupported ()) {
-return;
-  }
-
   FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
   ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
 
-  mIsFlushingGCD = TRUE;
   MemorySpaceMap = NULL;
 
   //
@@ -862,11 +857,44 @@ RefreshGcdMemoryAttributes (
   if (MemorySpaceMap != NULL) {
 FreePool (MemorySpaceMap);
   }
+}
 
-  //
-  // Update page attributes
-  //
-  RefreshGcdMemoryAttributesFromPaging();
+/**
+ Check if paging is enabled or not.
+**/
+BOOLEAN
+IsPagingSupported (
+  VOID
+  )
+{
+  return (
+  (AsmReadCr0 () & BIT31) != 0
+  &&
+  (AsmReadCr4 () & BIT5) != 0
+ );
+}
+
+/**
+  Refreshes the GCD Memory Space attributes according to MTRRs and Paging.
+
+  This function refreshes the GCD Memory Space attributes according to MTRRs
+  and page tables.
+
+**/
+VOID
+RefreshGcdMemoryAttributes (
+  VOID
+  )
+{
+  mIsFlushingGCD = TRUE;
+
+  if (IsMtrrSupported ()) {
+RefreshMemoryAttributesFromMtrr ();
+  }
+
+  if (IsPagingSupported ()) {
+RefreshGcdMemoryAttributesFromPaging ();
+  }
 
   mIsFlushingGCD = FALSE;
 }
-- 
2.14.1.windows.1

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


[edk2] [Patch V2] BaseTools: PI 1.6 to support FV extended header contain FV used size

2017-09-28 Thread Yonghong Zhu
From: Yunhua Feng 

Per PI 1.6 we added an FV Extended Header entry that would contain the
size of the FV that was in use.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c  | 19 ---
 BaseTools/Source/C/Include/Common/PiFirmwareVolume.h |  6 ++
 BaseTools/Source/Python/GenFds/FdfParser.py  |  2 +-
 BaseTools/Source/Python/GenFds/Fv.py | 17 -
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 01c862e..6a91858 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -42,10 +42,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION   0xEB00
 #define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION  0x1400
 
 BOOLEAN mArm = FALSE;
 STATIC UINT32   MaxFfsAlignment = 0;
+BOOLEAN VtfFileFlag = FALSE;
 
 EFI_GUID  mEfiFirmwareVolumeTopFileGuid   = EFI_FFS_VOLUME_TOP_FILE_GUID;
 EFI_GUID  mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV];
 EFI_GUID  mZeroGuid   = {0x0, 0x0, 0x0, {0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
 EFI_GUID  mDefaultCapsuleGuid = {0x3B6686BD, 0x0D76, 0x4030, { 
0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 }};
@@ -598,11 +599,13 @@ Returns:
 {
   EFI_FFS_FILE_HEADER *PadFile;
   UINTN   PadFileSize;
   UINT32  NextFfsHeaderSize;
   UINT32  CurFfsHeaderSize;
-
+  UINT32  Index;
+
+  Index = 0;
   CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
   //
   // Verify input parameters.
   //
   if (FvImage == NULL) {
@@ -703,10 +706,22 @@ Returns:
 
   if (ExtHeader != NULL) {
 //
 // Copy Fv Extension Header and Set Fv Extension header offset
 //
+if (ExtHeader->ExtHeaderSize > sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER)) {
+ for (Index = 1; Index <= ExtHeader->ExtHeaderSize - 
sizeof(EFI_FIRMWARE_VOLUME_EXT_HEADER);) {
+if (((EFI_FIRMWARE_VOLUME_EXT_ENTRY *)(ExtHeader + Index)) -> 
ExtEntryType == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {
+   if (VtfFileFlag) {
+  ((EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *)(ExtHeader + 
Index))->UsedSize = mFvTotalSize;
+} else {
+  ((EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *)(ExtHeader + 
Index))->UsedSize = mFvTakenSize;
+}
+ Index += ((EFI_FIRMWARE_VOLUME_EXT_ENTRY *)(ExtHeader + Index)) -> 
ExtEntrySize;
+}
+ }
+}
 memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, 
ExtHeader->ExtHeaderSize);
 ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = 
(UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize) - (UINTN) 
FvImage->FileImage);
  //
  // Make next file start at QWord Boundry
  //
@@ -3057,16 +3072,14 @@ Returns:
   UINTN   FfsFileSize;
   UINTN   FvExtendHeaderSize;
   UINT32  FfsAlignment;
   UINT32  FfsHeaderSize;
   EFI_FFS_FILE_HEADER FfsHeader;
-  BOOLEAN VtfFileFlag;
   UINTN   VtfFileSize;
   
   FvExtendHeaderSize = 0;
   VtfFileSize = 0;
-  VtfFileFlag = FALSE;
   fpin  = NULL;
   Index = 0;
 
   //
   // Compute size for easy access later
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h 
b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h
index b5c2b03..c3089e8 100644
--- a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h
+++ b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h
@@ -152,6 +152,12 @@ typedef struct {
   //
   // UINT8 Data[1];
   //
 } EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
 
+#define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
+typedef struct {
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
+  UINT32 UsedSize;
+} EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;
+
 #endif
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 499d0a6..b95afc7 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -2309,11 +2309,11 @@ class FdfParser:
 if name not in ("ERASE_POLARITY", "MEMORY_MAPPED", \
"STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", 
"WRITE_ENABLED_CAP", \
"WRITE_DISABLED_CAP", "WRITE_STATUS", 
"READ_ENABLED_CAP", \
"READ_DISABLED_CAP", "READ_STATUS", 
"READ_LOCK_CAP", \
"READ_LOCK_STATUS", "WRITE_LOCK_CAP", 
"WRITE_LOCK_STATUS", \
-   "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"):
+   

[edk2] [PATCH edk2-platforms fix bug] Hisilicon/D03/D05: Add AddressTranslationOffset support

2017-09-28 Thread Heyi Guo
From: Yan Zhang 

Assign valid value to AddressTranslationOffset to support
address translation between domains of CPU and PCIe, which
is need by GOP to enable frame buffer.

This patch fix the bug:
Kernel (4.12, without the vga driver) boot hang with kernel panic
while kernel accesses UEFI GOP frame buffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yan Zhang 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c 
b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
index b57bd51..55b80aa 100644
--- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
+++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
@@ -2316,6 +2316,7 @@ RootBridgeIoConfiguration (
   }
   Configuration.SpaceDesp[Index].AddrRangeMax = 
Configuration.SpaceDesp[Index].AddrRangeMin + 
PrivateData->ResAllocNode[Index].Length - 1;
   Configuration.SpaceDesp[Index].AddrLen  = 
PrivateData->ResAllocNode[Index].Length;
+  Configuration.SpaceDesp[Index].AddrTranslationOffset = 
PrivateData->MemBase - PrivateData->PciRegionBase;
 }
   }
 
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 11/11] Hisilicon D03/D05: Enlarge iATU for RP with ARI capable device.

2017-09-28 Thread Heyi Guo
From: Jason zhang 

1. Because Hi161x chip doesn't support "ARI Forwarding Enable"
   function, BIOS will enumerate 32 same devices (Device Number 0~31)
   when a Non-ARI capable device attached in the RP. Hi161x chip will
   not fix it, need BIOS patch.
2. Just enlarge iatu for those root port with ARI capable device
   attached, Non-ARI capable device's RP, keep iatu limitation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jason zhang 
Signed-off-by: Heyi Guo 
---
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c   |  1 +
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h   |  7 ++
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 79 

 3 files changed, 87 insertions(+)

diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c 
b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
index e3d3988..9fa3f84 100644
--- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
+++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
@@ -839,6 +839,7 @@ NotifyPhase(
 
   case EfiPciHostBridgeEndEnumeration:
 PCIE_DEBUG("Case EfiPciHostBridgeEndEnumeration\n");
+EnlargeAtuConfig0 (This);
 break;
 
   case EfiPciHostBridgeBeginBusAllocation:
diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h 
b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h
index cddda6b..c04361f 100644
--- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h
+++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h
@@ -401,6 +401,9 @@ PreprocessController (
 #define EFI_RESOURCE_NONEXISTENT   0xULL
 #define EFI_RESOURCE_LESS  0xFFFEULL
 
+#defineINVALID_CAPABILITY_00   0x00
+#defineINVALID_CAPABILITY_FF   0xFF
+#definePCI_CAPABILITY_POINTER_MASK 0xFC
 
 //
 // Driver Instance Data Prototypes
@@ -518,4 +521,8 @@ RootBridgeConstructor (
   IN UINT32 Seg
   );
 
+VOID
+EnlargeAtuConfig0 (
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This
+  );
 #endif
diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c 
b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
index 10d766a..b57bd51 100644
--- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
+++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c
@@ -14,6 +14,7 @@
  **/
 
 #include "PciHostBridge.h"
+#include 
 #include 
 #include 
 #include 
@@ -2322,3 +2323,81 @@ RootBridgeIoConfiguration (
   return EFI_SUCCESS;
 }
 
+BOOLEAN
+PcieCheckAriFwdEn (
+  UINTN  PciBaseAddr
+  )
+{
+  UINT8   PciPrimaryStatus;
+  UINT8   CapabilityOffset;
+  UINT8   CapId;
+  UINT8   TempData;
+
+  PciPrimaryStatus = MmioRead16 (PciBaseAddr + PCI_PRIMARY_STATUS_OFFSET);
+
+  if (PciPrimaryStatus & EFI_PCI_STATUS_CAPABILITY) {
+CapabilityOffset = MmioRead8 (PciBaseAddr + PCI_CAPBILITY_POINTER_OFFSET);
+CapabilityOffset &= PCI_CAPABILITY_POINTER_MASK;
+
+while ((CapabilityOffset != INVALID_CAPABILITY_00) && (CapabilityOffset != 
INVALID_CAPABILITY_FF)) {
+  CapId = MmioRead8 (PciBaseAddr + CapabilityOffset);
+  if (CapId == EFI_PCI_CAPABILITY_ID_PCIEXP) {
+break;
+  }
+  CapabilityOffset = MmioRead8 (PciBaseAddr + CapabilityOffset + 1);
+  CapabilityOffset &= PCI_CAPABILITY_POINTER_MASK;
+}
+  } else {
+PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__);
+return FALSE;
+  }
+
+  if ((CapabilityOffset == INVALID_CAPABILITY_FF) || (CapabilityOffset == 
INVALID_CAPABILITY_00)) {
+PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__);
+return FALSE;
+  }
+
+  TempData = MmioRead16 (PciBaseAddr + CapabilityOffset +
+  EFI_PCIE_CAPABILITY_DEVICE_CONTROL_2_OFFSET);
+  TempData &= EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWARDING;
+
+  if (TempData == EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWARDING) {
+return TRUE;
+  } else {
+return FALSE;
+  }
+}
+
+VOID
+EnlargeAtuConfig0 (
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This
+  )
+{
+  UINTN   RbPciBase;
+  UINT64  MemLimit;
+  LIST_ENTRY  *List;
+  PCI_HOST_BRIDGE_INSTANCE*HostBridgeInstance;
+  PCI_ROOT_BRIDGE_INSTANCE*RootBridgeInstance;
+
+  PCIE_DEBUG ("In Enlarge RP iatu Config 0.\n");
+
+  HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This);
+  List = HostBridgeInstance->Head.ForwardLink;
+
+  while (List != >Head) {
+PCIE_DEBUG ("HostBridge has data.\n");
+RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List);
+
+RbPciBase = RootBridgeInstance->RbPciBar;
+
+// Those ARI FWD Enable Root Bridge, need enlarge iatu window.
+if (PcieCheckAriFwdEn (RbPciBase)) {
+  MemLimit = GetPcieCfgAddress 

[edk2] [PATCH edk2-platforms v5 04/11] Hisilicon D03/D05: get firmware version from FIRMWARE_VER

2017-09-28 Thread Heyi Guo
From: Ming Huang 

Value of the environment variable FIRMWARE_VER is GIT SHA by default,
and you can add the environment variable FIRMWARE_VER to EXTRA_OPTIONS
at build time to specify something else, eg. "16.12-".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D03/D03.dsc | 6 +-
 Platform/Hisilicon/D05/D05.dsc | 6 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 7e25ffb..fca6781 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -170,7 +170,11 @@
   gHisiTokenSpaceGuid.PcdAlgSmmuBaseAddress|0xd004
 
 
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Hisilicon D03 UEFI 
16.12 Release"
+  !ifdef $(FIRMWARE_VER)
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
+  !else
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build base on Hisilicon D03 UEFI 17.10 Release"
+  !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
 
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 7cd5758..aa61c0e 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -188,7 +188,11 @@
 
   gHisiTokenSpaceGuid.PcdIsMPBoot|1
   gHisiTokenSpaceGuid.PcdSocketMask|0x3
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Hisilicon D05 UEFI 
16.12 Release"
+  !ifdef $(FIRMWARE_VER)
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
+  !else
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build base on Hisilicon D05 UEFI 17.10 Release"
+  !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
 
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 07/11] D05/PCIe: Modify PcieRegionBase of secondary chip

2017-09-28 Thread Heyi Guo
From: Ming Huang 

On D05 PCIe now, 2p NA PCIe2 and 2p NB PCIe0's pci domain addresses are
0x2000 and 0x3000 based. These addresses overlap with the DDR
memory range 0-1G. In this situation, on the inbound direction, our pcie
will drop the DDR address access that are located in the pci range window
and lead to a dataflow error.

Modify 2p NA PCIe2 and 2p NB PCIe0's pci domain addresses to 0x4000
and decrease PciRegion Size accordingly.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D05/D05.dsc | 12 ++--
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl |  8 
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 01defe0..64101a7 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -329,12 +329,12 @@
   gHisiTokenSpaceGuid.PcdHb1Rb0PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb1Rb1PciRegionBaseAddress|0x400a940
   gHisiTokenSpaceGuid.PcdHb1Rb1PciRegionSize|0xbf
-  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionBaseAddress|0x2000
-  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionSize|0xd000
+  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionBaseAddress|0x4000
+  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionSize|0xb000
   gHisiTokenSpaceGuid.PcdHb1Rb3PciRegionBaseAddress|0x400ab40
   gHisiTokenSpaceGuid.PcdHb1Rb3PciRegionSize|0xbf
-  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionBaseAddress|0x3000
-  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionSize|0xc000
+  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionBaseAddress|0x4000
+  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionSize|0xb000
   gHisiTokenSpaceGuid.PcdHb1Rb5PciRegionBaseAddress|0x4000
   gHisiTokenSpaceGuid.PcdHb1Rb5PciRegionSize|0xb000
   gHisiTokenSpaceGuid.PcdHb1Rb6PciRegionBaseAddress|0x408aa40
@@ -352,9 +352,9 @@
   gHisiTokenSpaceGuid.PcdHb0Rb7CpuMemRegionBase|0x8B980
   gHisiTokenSpaceGuid.PcdHb1Rb0CpuMemRegionBase|0x400A840
   gHisiTokenSpaceGuid.PcdHb1Rb1CpuMemRegionBase|0x400A940
-  gHisiTokenSpaceGuid.PcdHb1Rb2CpuMemRegionBase|0x6502000
+  gHisiTokenSpaceGuid.PcdHb1Rb2CpuMemRegionBase|0x6504000
   gHisiTokenSpaceGuid.PcdHb1Rb3CpuMemRegionBase|0x400AB40
-  gHisiTokenSpaceGuid.PcdHb1Rb4CpuMemRegionBase|0x7503000
+  gHisiTokenSpaceGuid.PcdHb1Rb4CpuMemRegionBase|0x7504000
   gHisiTokenSpaceGuid.PcdHb1Rb5CpuMemRegionBase|0x7904000
   gHisiTokenSpaceGuid.PcdHb1Rb6CpuMemRegionBase|0x408AA40
   gHisiTokenSpaceGuid.PcdHb1Rb7CpuMemRegionBase|0x408AB40
diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
index 79267e5..55c7f50 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
@@ -646,10 +646,10 @@ Scope(_SB)
   Cacheable,
   ReadWrite,
   0x0, // Granularity
-  0x2000, // Min Base Address
+  0x4000, // Min Base Address
   0xefff, // Max Base Address
   0x650, // Translate
-  0xd000 // Length
+  0xb000 // Length
 )
 QWordIO (
   ResourceProducer,
@@ -766,10 +766,10 @@ Scope(_SB)
   Cacheable,
   ReadWrite,
   0x0, // Granularity
-  0x3000, // Min Base Address
+  0x4000, // Min Base Address
   0xefff, // Max Base Address
   0x750, // Translate
-  0xc000 // Length
+  0xb000 // Length
 )
 QWordIO (
   ResourceProducer,
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 05/11] Hisilicon/PciHostBridgeDxe: Assign BAR resource from PciRegionBase

2017-09-28 Thread Heyi Guo
Io BAR should be based IoBase and Mem BAR should be based PciRegionBase.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c   | 37 

 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 15 ++--
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c 
b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
index a970da6..e3d3988 100644
--- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
+++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c
@@ -1410,9 +1410,8 @@ SetResource(
 Ptr->ResType = 1;
 Ptr->GenFlag = 0;
 Ptr->SpecificFlag = 0;
-/* This is PCIE Device Bus which start address is the low 32bit of mem 
base*/
-Ptr->AddrRangeMin = (RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase) +
-(RootBridgeInstance->MemBase & 0x);
+/* PCIE Device Iobar address should be based on IoBase */
+Ptr->AddrRangeMin = RootBridgeInstance->IoBase;
 Ptr->AddrRangeMax = 0;
 Ptr->AddrTranslationOffset = \
  (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : 
EFI_RESOURCE_LESS;
@@ -1429,9 +1428,13 @@ SetResource(
 Ptr->GenFlag = 0;
 Ptr->SpecificFlag = 0;
 Ptr->AddrSpaceGranularity = 32;
-/* This is PCIE Device Bus which start address is the low 32bit of mem 
base*/
-Ptr->AddrRangeMin = (RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase) +
- (RootBridgeInstance->MemBase & 0x);
+/* PCIE device Bar should be based on PciRegionBase */
+if (RootBridgeInstance->PciRegionBase > MAX_UINT32) {
+  DEBUG((DEBUG_ERROR, "PCIE Res(TypeMem32) unsupported.\n"));
+  return EFI_UNSUPPORTED;
+}
+Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase +
+RootBridgeInstance->PciRegionBase;
 Ptr->AddrRangeMax = 0;
 Ptr->AddrTranslationOffset = \
  (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : 
EFI_RESOURCE_LESS;
@@ -1448,9 +1451,13 @@ SetResource(
 Ptr->GenFlag = 0;
 Ptr->SpecificFlag = 6;
 Ptr->AddrSpaceGranularity = 32;
-/* This is PCIE Device Bus which start address is the low 32bit of mem 
base*/
-Ptr->AddrRangeMin = (RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase) +
- (RootBridgeInstance->MemBase & 0x);
+/* PCIE device Bar should be based on PciRegionBase */
+if (RootBridgeInstance->PciRegionBase > MAX_UINT32) {
+  DEBUG((DEBUG_ERROR, "PCIE Res(TypePMem32) unsupported.\n"));
+  return EFI_UNSUPPORTED;
+}
+Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase +
+RootBridgeInstance->PciRegionBase;
 Ptr->AddrRangeMax = 0;
 Ptr->AddrTranslationOffset = \
  (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : 
EFI_RESOURCE_LESS;
@@ -1467,9 +1474,9 @@ SetResource(
 Ptr->GenFlag = 0;
 Ptr->SpecificFlag = 0;
 Ptr->AddrSpaceGranularity = 64;
-/* This is PCIE Device Bus which start address is the low 32bit of mem 
base*/
-Ptr->AddrRangeMin = (RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase) +
- (RootBridgeInstance->MemBase & 
0x);
+/* PCIE device Bar should be based on PciRegionBase */
+Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase +
+RootBridgeInstance->PciRegionBase;
 Ptr->AddrRangeMax = 0;
 Ptr->AddrTranslationOffset = \
  (ResStatus == ResAllocated) ? EFI_RESOURCE_SATISFIED : 
EFI_RESOURCE_LESS;
@@ -1486,9 +1493,9 @@ SetResource(
 Ptr->GenFlag = 0;
 Ptr->SpecificFlag = 6;
 Ptr->AddrSpaceGranularity = 64;
-/* This is PCIE Device Bus which start address is the low 32bit of mem 
base*/
-Ptr->AddrRangeMin = (RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase) +
- (RootBridgeInstance->MemBase & 
0x);
+/* PCIE device Bar should be based on PciRegionBase */
+Ptr->AddrRangeMin = RootBridgeInstance->ResAllocNode[Index].Base - 
RootBridgeInstance->MemBase +
+RootBridgeInstance->PciRegionBase;
 Ptr->AddrRangeMax = 0;
 Ptr->AddrTranslationOffset = \
  (ResStatus 

[edk2] [PATCH edk2-platforms v5 10/11] D05/ACPI: Modify I2C device

2017-09-28 Thread Heyi Guo
From: Ming Huang 

1. Disable I2C0 device avoiding access conflict in OS, for it is used
   by UEFI to access DS3231 RTC chip and provide time services;
2. Modify _HID of I2C2 for matching the string in OS driver;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl | 20 
+---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl
index eb906ef..3cc60d1 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl
@@ -18,26 +18,8 @@
 
 Scope(_SB)
 {
-  Device(I2C0) {
-Name(_HID, "APMC0D0F")
-Name(_CID, "APMC0D0F")
-Name(_CRS, ResourceTemplate() {
-  Memory32Fixed(ReadWrite, 0xd00e, 0x1)
-  Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive, 0, 
"\\_SB.MBI6") { 705 }
-})
-Name (_DSD, Package () {
-  ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
-  Package () {
-Package () {"clock-frequency", 10},
-Package () {"i2c-sda-falling-time-ns", 913},
-Package () {"i2c-scl-falling-time-ns", 303},
-Package () {"i2c-sda-hold-time-ns", 0x9c2},
-  }
-})
-  }
-
   Device(I2C2) {
-Name(_HID, "APMC0D0F")
+Name(_HID, "HISI02A1")
 Name(_CID, "APMC0D0F")
 Name(_CRS, ResourceTemplate() {
   Memory32Fixed(ReadWrite, 0xd010, 0x1)
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 06/11] Hisilicon/D05/Pcie: fix bug of size definition

2017-09-28 Thread Heyi Guo
From: Ming Huang 

Fix bug of PcieRegion size definition and IO size definition.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D05/D05.dsc | 64 ++--
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index aa61c0e..01defe0 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -310,37 +310,37 @@
   gHisiTokenSpaceGuid.PciHb1Rb7Base|0x700a00b
 
   gHisiTokenSpaceGuid.PcdHb0Rb0PciRegionBaseAddress|0xa840
-  gHisiTokenSpaceGuid.PcdHb0Rb0PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb0Rb0PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb0Rb1PciRegionBaseAddress|0xa940
-  gHisiTokenSpaceGuid.PcdHb0Rb1PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb0Rb1PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb0Rb2PciRegionBaseAddress|0xa880
-  gHisiTokenSpaceGuid.PcdHb0Rb2PciRegionSize|0x77e
+  gHisiTokenSpaceGuid.PcdHb0Rb2PciRegionSize|0x77f
   gHisiTokenSpaceGuid.PcdHb0Rb3PciRegionBaseAddress|0xab40
-  gHisiTokenSpaceGuid.PcdHb0Rb3PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb0Rb3PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb0Rb4PciRegionBaseAddress|0xa900
-  gHisiTokenSpaceGuid.PcdHb0Rb4PciRegionSize|0x2fe
+  gHisiTokenSpaceGuid.PcdHb0Rb4PciRegionSize|0x2ff
   gHisiTokenSpaceGuid.PcdHb0Rb5PciRegionBaseAddress|0xb080
-  gHisiTokenSpaceGuid.PcdHb0Rb5PciRegionSize|0x77e
+  gHisiTokenSpaceGuid.PcdHb0Rb5PciRegionSize|0x77f
   gHisiTokenSpaceGuid.PcdHb0Rb6PciRegionBaseAddress|0xac90
-  gHisiTokenSpaceGuid.PcdHb0Rb6PciRegionSize|0x36e
+  gHisiTokenSpaceGuid.PcdHb0Rb6PciRegionSize|0x36f
   gHisiTokenSpaceGuid.PcdHb0Rb7PciRegionBaseAddress|0xb980
-  gHisiTokenSpaceGuid.PcdHb0Rb7PciRegionSize|0x67e
+  gHisiTokenSpaceGuid.PcdHb0Rb7PciRegionSize|0x67f
   gHisiTokenSpaceGuid.PcdHb1Rb0PciRegionBaseAddress|0x400a840
-  gHisiTokenSpaceGuid.PcdHb1Rb0PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb1Rb0PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb1Rb1PciRegionBaseAddress|0x400a940
-  gHisiTokenSpaceGuid.PcdHb1Rb1PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb1Rb1PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionBaseAddress|0x2000
-  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionSize|0xcfff
+  gHisiTokenSpaceGuid.PcdHb1Rb2PciRegionSize|0xd000
   gHisiTokenSpaceGuid.PcdHb1Rb3PciRegionBaseAddress|0x400ab40
-  gHisiTokenSpaceGuid.PcdHb1Rb3PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb1Rb3PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionBaseAddress|0x3000
-  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionSize|0xbfff
+  gHisiTokenSpaceGuid.PcdHb1Rb4PciRegionSize|0xc000
   gHisiTokenSpaceGuid.PcdHb1Rb5PciRegionBaseAddress|0x4000
-  gHisiTokenSpaceGuid.PcdHb1Rb5PciRegionSize|0xafff
+  gHisiTokenSpaceGuid.PcdHb1Rb5PciRegionSize|0xb000
   gHisiTokenSpaceGuid.PcdHb1Rb6PciRegionBaseAddress|0x408aa40
-  gHisiTokenSpaceGuid.PcdHb1Rb6PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb1Rb6PciRegionSize|0xbf
   gHisiTokenSpaceGuid.PcdHb1Rb7PciRegionBaseAddress|0x408ab40
-  gHisiTokenSpaceGuid.PcdHb1Rb7PciRegionSize|0xbe
+  gHisiTokenSpaceGuid.PcdHb1Rb7PciRegionSize|0xbf
 
   gHisiTokenSpaceGuid.PcdHb0Rb0CpuMemRegionBase|0xA840
   gHisiTokenSpaceGuid.PcdHb0Rb1CpuMemRegionBase|0xA940
@@ -377,52 +377,52 @@
   gHisiTokenSpaceGuid.PcdHb1Rb7CpuIoRegionBase|0x408abff
 
   gHisiTokenSpaceGuid.PcdHb0Rb0IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb0IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb0IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb1IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb1IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb1IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb2IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb2IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb2IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb3IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb3IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb3IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb4IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb4IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb4IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb5IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb5IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb5IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb6IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb6IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb6IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb0Rb7IoBase|0
-  gHisiTokenSpaceGuid.PcdHb0Rb7IoSize|0x #64K
+  gHisiTokenSpaceGuid.PcdHb0Rb7IoSize|0x1 #64K
 
   gHisiTokenSpaceGuid.PcdHb1Rb0IoBase|0
-  gHisiTokenSpaceGuid.PcdHb1Rb0IoSize|0x #64K
+  

[edk2] [PATCH edk2-platforms v5 09/11] D05/ACPI: Disable D05 SAS0 and SAS2

2017-09-28 Thread Heyi Guo
From: Ming Huang 

There is no interface from SAS0 or SAS2 controller on D05,
so SAS0 and SAS2 can't be used.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
index 93beb95..6455130 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
@@ -88,6 +88,11 @@ Scope(_SB)
   Store(0x7, CLK)
   Sleep(1)
 }
+
+   Method (_STA, 0, NotSerialized)
+   {
+ Return (0x0)
+   }
   }
 
   Device(SAS1) {
@@ -239,6 +244,11 @@ Scope(_SB)
   Store(0x7, CLK)
   Sleep(1)
 }
+
+   Method (_STA, 0, NotSerialized)
+   {
+ Return (0x0)
+   }
   }
 
 }
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 08/11] Hisilicon/D03: Disable the function of PerfTuning

2017-09-28 Thread Heyi Guo
From: Chenhui Sun 

The PerTuning function is not stable, it will cause the
LSI SAS 3008/3108 crash, disable this function first.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chenhui Sun 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/D03.dsc|  1 -
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf |  1 -
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c   | 50 

 Silicon/Hisilicon/HisiPkg.dec |  1 -
 4 files changed, 53 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index fca6781..f2a120e 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -112,7 +112,6 @@
   #  It could be set FALSE to save size.
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gHisiTokenSpaceGuid.PcdIsItsSupported|TRUE
-  gHisiTokenSpaceGuid.PcdIsPciPerfTuningEnable|TRUE
 
 [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdEmbeddedPrompt|"D03"
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf 
b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
index ee9dbed..61b091f 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
@@ -55,7 +55,6 @@
 
 [FeaturePcd]
   gHisiTokenSpaceGuid.PcdIsItsSupported
-  gHisiTokenSpaceGuid.PcdIsPciPerfTuningEnable
 
 [depex]
   TRUE
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c 
b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
index 8ab7fa3..f420c91 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
@@ -315,50 +315,6 @@ PcieEnableItssm (
 
 }
 
-STATIC EFI_STATUS PciPerfTuning(UINT32 soctype, UINT32 HostBridgeNum, UINT32 
Port)
-{
-UINT32 Value;
-UINTN  RegSegmentOffset;
-
-if (Port >= PCIE_MAX_ROOTBRIDGE) {
-  DEBUG((DEBUG_ERROR, "Invalid port number: %d\n", Port));
-  return EFI_INVALID_PARAMETER;
-}
-
-RegSegmentOffset = PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_SYS_REG_OFFSET;
-
-//Enable SMMU bypass for translation
-RegRead(RegSegmentOffset + PCIE_SYS_CTRL13_REG, Value);
-//BIT13: controller master read SMMU bypass
-//BIT12: controller master write SMMU bypass
-//BIT10: SMMU bypass enable
-Value |= (BIT13 | BIT12 | BIT10);
-RegWrite(RegSegmentOffset + PCIE_SYS_CTRL13_REG, Value);
-
-//Switch strongly order (SO) to relaxed order (RO) for write transaction
-RegRead(RegSegmentOffset + PCIE_CTRL_6_REG, Value);
-//BIT13 | BIT12: Enable write merge and SMMU streaming ordered write 
acknowledge
-Value |= (BIT13 | BIT12);
-//BIT29 | BIT27 | BIT25 | BIT23 | BIT21 | BIT19 | BIT17: Enable RO for all 
types of write transaction
-Value |= (BIT29 | BIT27 | BIT25 | BIT23 | BIT21 | BIT19 | BIT17);
-RegWrite(RegSegmentOffset + PCIE_CTRL_6_REG, Value);
-
-//Force streamID for controller read operation
-RegRead(RegSegmentOffset + PCIE_SYS_CTRL54_REG, Value);
-//Force using streamID in PCIE_SYS_CTRL54_REG
-Value &= ~(BIT30);
-//Set streamID to 0, bit[0:15] is for request ID and should be kept
-Value &= ~(0xff << 16);
-RegWrite(RegSegmentOffset + PCIE_SYS_CTRL54_REG, Value);
-
-//Enable read and write snoopy
-RegRead(RegSegmentOffset + PCIE_SYS_CTRL19_REG, Value);
-Value |= (BIT30 | BIT28);
-RegWrite(RegSegmentOffset + PCIE_SYS_CTRL19_REG, Value);
-
-return EFI_SUCCESS;
-}
-
 EFI_STATUS PcieDisableItssm(UINT32 soctype, UINT32 HostBridgeNum, UINT32 Port)
 {
 PCIE_CTRL_7_U pcie_ctrl7;
@@ -1141,12 +1097,6 @@ PciePortInit (
  DisableRcOptionRom (soctype, HostBridgeNum, PortIndex, 
PcieCfg->PortInfo.PortType);
  /* assert LTSSM enable */
  (VOID)PcieEnableItssm (soctype, HostBridgeNum, PortIndex, PcieCfg);
- if (FeaturePcdGet(PcdIsPciPerfTuningEnable)) {
-   //PCIe will still work even if performance tuning fails,
-   //and there is warning message inside the function to print
-   //detailed error if there is.
-   (VOID)PciPerfTuning(soctype, HostBridgeNum, PortIndex);
- }
 
  PcieConfigContextHi1610(soctype, HostBridgeNum, PortIndex);
  /*
diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec
index 2c02e14..81ba3be 100644
--- a/Silicon/Hisilicon/HisiPkg.dec
+++ b/Silicon/Hisilicon/HisiPkg.dec
@@ -274,7 +274,6 @@
 
 [PcdsFeatureFlag]
   gHisiTokenSpaceGuid.PcdIsItsSupported|FALSE|BOOLEAN|0x0065
-  gHisiTokenSpaceGuid.PcdIsPciPerfTuningEnable|FALSE|BOOLEAN|0x0066
 
 
 
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 02/11] Hisilicon/D03: Modify dsc and fdf file

2017-09-28 Thread Heyi Guo
1. Add Drivers/SasPlatform;
2. Add Drivers/Net/SnpPlatform;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/D03.dsc | 5 -
 Platform/Hisilicon/D03/D03.fdf | 4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index afea162..7e25ffb 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -418,11 +418,6 @@
 
   Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.inf
 
-  #
-  #network
-  #
-  Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
-
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index b62b908..37a7e28 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -242,7 +242,8 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
+  INF Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
@@ -271,6 +272,7 @@ READ_LOCK_STATUS   = TRUE
   #
   INF Platform/Hisilicon/D03/Drivers/Sm750Dxe/UefiSmi.inf
 
+  INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf
   INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf
 
   #
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 03/11] Hisilicon: Fix the drivers use the same GUID issue

2017-09-28 Thread Heyi Guo
The drivers build from separate sources, their GUID should
be different.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf  | 
2 +-
 Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf | 
2 +-
 Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf| 
2 +-
 Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf  | 
2 +-
 Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf| 
2 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf   | 
2 +-
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf  | 
2 +-
 Platform/Hisilicon/D05/Library/PlatformPciLib/PlatformPciLib.inf| 
2 +-
 Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.inf| 
2 +-
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf   | 
2 +-
 Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf | 
2 +-
 Silicon/Hisilicon/Library/Dw8250SerialPortLib/Dw8250SerialPortLib.inf   | 
2 +-
 Silicon/Hisilicon/Library/I2CLib/I2CLib.inf | 
2 +-
 Silicon/Hisilicon/Library/I2CLib/I2CLibRuntime.inf  | 
2 +-
 14 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf 
b/Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf
index 5506a58..3f3f81c 100644
--- a/Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf
+++ b/Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = EarlyConfigPeim
-  FILE_GUID  = A181AD33-E64A-4084-A54A-A69DF1FB0ABF
+  FILE_GUID  = ECAE8400-9CCE-4BA5-9B44-74CAABE4DA79
   MODULE_TYPE= PEIM
   VERSION_STRING = 1.0
   ENTRY_POINT= EarlyConfigEntry
diff --git a/Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf 
b/Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf
index c952414..e881899 100644
--- a/Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf
+++ b/Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = FdtUpdateLib
-  FILE_GUID  = 02CF1727-E697-47fc-8CC2-5DCB81B26DD9
+  FILE_GUID  = 0F9ADE24-46B4-4506-8802-60C519B56133
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = FdtUpdateLib
diff --git a/Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf 
b/Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf
index 4d2dbba..ab3b62b 100644
--- a/Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf
+++ b/Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = PlatformPciLib
-  FILE_GUID  = 61b7276a-fc67-11e5-82fd-47ea9896dd5d
+  FILE_GUID  = 128F1E1E-A921-4277-A796-A4A47B96B7D2
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
 
diff --git a/Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf 
b/Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf
index df5adf1..4c5955f 100644
--- a/Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf
+++ b/Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = OemNicConfig
-  FILE_GUID  = 3A23A929-1F38-4d04-8A01-38AD993EB2CE
+  FILE_GUID  = BF422A22-CA90-4C34-95B9-3D147AF09E70
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
   ENTRY_POINT= OemNicConfigEntry
diff --git a/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf 
b/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf
index 9569b91..2d9d53d 100755
--- a/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf
+++ b/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = FdtUpdateLib
-  FILE_GUID  = 02CF1727-E697-47fc-8CC2-5DCB81B26DD9
+  FILE_GUID  = B80B9FF1-FAB9-4BE5-B602-5ABAA6B7A3D4
   MODULE_TYPE= BASE
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = FdtUpdateLib
diff --git 

[edk2] [PATCH edk2-platforms v5 00/11] Improve D0x platforms and bug fix

2017-09-28 Thread Heyi Guo
Code can also be found in github:
https://github.com/hisilicon/OpenPlatformPkg.git
branch: rp-1710-platforms-v5

Note:
1. There may be some minor issue (or even in SoC IP) that causes D05/3 into 
exception, 
which was just found when we updated edk2 and edk2-platforms. We will continue 
to investigate the issue.
It boot successfully by switch the VirtualEhciPciIo with old one.

2. The separate patch (Add AddressTranslationOffset support) is a prerequisite 
for this series
   and it's source can also be found in above branch(rp-1710-platforms-v5).

Chenhui Sun (1):
  Hisilicon/D03: Disable the function of PerfTuning

Heyi Guo (4):
  Hisilicon/D05: Modify dsc and fdf file
  Hisilicon/D03: Modify dsc and fdf file
  Hisilicon: Fix the drivers use the same GUID issue
  Hisilicon/PciHostBridgeDxe: Assign BAR resource from PciRegionBase

Jason zhang (1):
  Hisilicon D03/D05: Enlarge iATU for RP with ARI capable device.

Ming Huang (5):
  Hisilicon D03/D05: get firmware version from FIRMWARE_VER
  Hisilicon/D05/Pcie: fix bug of size definition
  D05/PCIe: Modify PcieRegionBase of secondary chip
  D05/ACPI: Disable D05 SAS0 and SAS2
  D05/ACPI: Modify I2C device

 Platform/Hisilicon/D02/EarlyConfigPeim/EarlyConfigPeim.inf  |  
2 +-
 Platform/Hisilicon/D02/FdtUpdateLibD02/FdtUpdateLib.inf |  
2 +-
 Platform/Hisilicon/D02/Library/PlatformPciLib/PlatformPciLib.inf|  
2 +-
 Platform/Hisilicon/D02/OemNicConfigD02/OemNicConfigD02.inf  |  
2 +-
 Platform/Hisilicon/D03/D03.dsc  | 
12 ++-
 Platform/Hisilicon/D03/D03.fdf  |  
4 +-
 Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.inf|  
2 +-
 Platform/Hisilicon/D05/D05.dsc  | 
83 +
 Platform/Hisilicon/D05/D05.fdf  |  
4 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf   |  
2 +-
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf  |  
2 +-
 Platform/Hisilicon/D05/Library/PlatformPciLib/PlatformPciLib.inf|  
2 +-
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c  | 
38 
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h  |  
7 ++
 Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c| 
94 +++-
 Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.inf|  
2 +-
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf   |  
3 +-
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c | 
50 ---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05I2c.asl  | 
20 +
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl  |  
8 +-
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl  | 
10 +++
 Silicon/Hisilicon/HisiPkg.dec   |  
1 -
 Silicon/Hisilicon/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.inf |  
2 +-
 Silicon/Hisilicon/Library/Dw8250SerialPortLib/Dw8250SerialPortLib.inf   |  
2 +-
 Silicon/Hisilicon/Library/I2CLib/I2CLib.inf |  
2 +-
 Silicon/Hisilicon/Library/I2CLib/I2CLibRuntime.inf  |  
2 +-
 26 files changed, 203 insertions(+), 157 deletions(-)

-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v5 01/11] Hisilicon/D05: Modify dsc and fdf file

2017-09-28 Thread Heyi Guo
1. Add Drivers/SasPlatform;
2. Add Drivers/Net/SnpPlatform;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D05/D05.dsc | 5 -
 Platform/Hisilicon/D05/D05.fdf | 4 +++-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 3cdb1b1..7cd5758 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -538,11 +538,6 @@
 
   Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.inf
 
-  #
-  #network
-  #
-  Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
-
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index b6d0e42..a5e6546 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -247,7 +247,8 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
+  INF Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
@@ -292,6 +293,7 @@ READ_LOCK_STATUS   = TRUE
   #
   INF Platform/Hisilicon/D05/Drivers/Sm750Dxe/UefiSmi.inf
   INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+  INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf
   INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf
 
   #
-- 
1.9.1

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


[edk2] [PATCH edk2-non-osi v5 09/10] Hisilicon/D05: Fix occasional system hang bug

2017-09-28 Thread Heyi Guo
From: Ming Huang 

Fix bug 3061(https://bugs.linaro.org/show_bug.cgi?id=3061):
D05(before EC) boot hangs at "Need Reset";

If the D05 is before EC, then speed of i2c reduce to 100k.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D05/Sec/FVMAIN_SEC.Fv | Bin 262144 -> 262144 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D05/Sec/FVMAIN_SEC.Fv 
b/Platform/Hisilicon/D05/Sec/FVMAIN_SEC.Fv
index 16500b7..ab6ea83 100644
Binary files a/Platform/Hisilicon/D05/Sec/FVMAIN_SEC.Fv and 
b/Platform/Hisilicon/D05/Sec/FVMAIN_SEC.Fv differ
-- 
1.9.1

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


[edk2] [PATCH edk2-non-osi v5 08/10] Hisilicon/D05: Update Trusted Firmware binary

2017-09-28 Thread Heyi Guo
From: Ming Huang 

The Trusted Firmware binary was produced from the commit hash:
"14c7bdf"

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D05/bl1.bin | Bin 12296 -> 14344 bytes
 Platform/Hisilicon/D05/fip.bin | Bin 41493 -> 41493 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D05/bl1.bin b/Platform/Hisilicon/D05/bl1.bin
index f207cd9..7341476 100644
Binary files a/Platform/Hisilicon/D05/bl1.bin and 
b/Platform/Hisilicon/D05/bl1.bin differ
diff --git a/Platform/Hisilicon/D05/fip.bin b/Platform/Hisilicon/D05/fip.bin
index 0952662..496a9b8 100644
Binary files a/Platform/Hisilicon/D05/fip.bin and 
b/Platform/Hisilicon/D05/fip.bin differ
-- 
1.9.1

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


[edk2] [PATCH edk2-non-osi v5 10/10] Hisilicon: Fix the drivers use the same GUID issue

2017-09-28 Thread Heyi Guo
The drivers build from separate sources, their GUID should
be different.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
| 2 +-
 Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf
| 2 +-
 Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf
| 2 +-
 Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf   
| 2 +-
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.inf  
| 2 +-
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.inf  
| 2 +-
 Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOpDxe.inf 
| 2 +-
 Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.inf 
| 2 +-
 Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
| 2 +-
 Platform/Hisilicon/D05/Drivers/OhciDxe/OhciDxe.inf 
| 2 +-
 
Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.inf
 | 2 +-
 Platform/Hisilicon/D05/Drivers/SFC/SfcDxeDriver.inf
| 2 +-
 Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf
| 2 +-
 Platform/Hisilicon/D05/Drivers/Sm750Dxe/UefiSmi.inf
| 2 +-
 Platform/Hisilicon/D05/Drivers/TransferSmbiosInfo/TransSmbiosInfo.inf  
| 2 +-
 Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.inf   
| 2 +-
 Platform/Hisilicon/D05/MemoryInitPei/MemoryInitPeim.inf
| 2 +-
 Silicon/Hisilicon/Hi1610/Library/Hi1610Serdes/Hi1610SerdesLib.inf  
| 2 +-
 Silicon/Hisilicon/Hi1610/Library/LpcLib/LpcLib.inf 
| 2 +-
 
Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf
 | 2 +-
 Silicon/Hisilicon/Hi1616/Library/Hi1616Serdes/Hi1616SerdesLib.inf  
| 2 +-
 
Silicon/Hisilicon/Pv660/Library/PlatformSysCtrlLibPv660/PlatformSysCtrlLibPv660.inf
| 2 +-
 Silicon/Hisilicon/Pv660/Library/Pv660Serdes/Pv660SerdesLib.inf 
| 2 +-
 23 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
b/Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
index 8376bbd..8b9ee1d 100644
--- a/Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
+++ b/Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
@@ -17,7 +17,7 @@
 [Defines]
   INF_VERSION= 0x00010019
   BASE_NAME  = SnpPV600Dxe
-  FILE_GUID  = 3246F154-3612-4803-BD4E-4104D7EF944A
+  FILE_GUID  = 1AB373EB-2CD7-4D5C-9C39-D31845B67F5E
   MODULE_TYPE= UEFI_DRIVER
   VERSION_STRING = 1.0
 
diff --git a/Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf 
b/Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf
index e10275a..02a4d7f 100644
--- a/Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf
+++ b/Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = SFCDriver
-  FILE_GUID  = FC5651CA-55D8-4fd2-B6D3-A284D993ABA2
+  FILE_GUID  = 02C6BAAE-6E43-4910-8084-60D5045729A0
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
   ENTRY_POINT= SFCInitialize
diff --git a/Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf 
b/Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf
index c221de9..0095c82 100644
--- a/Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf
+++ b/Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf
@@ -18,7 +18,7 @@
 [Defines]
   INF_VERSION= 0x00010005
   BASE_NAME  = MemoryInit
-  FILE_GUID  = c61ef796-b50d-4f98-9f78-4f6f79d800d5
+  FILE_GUID  = A311058D-0993-4C05-A3EC-16CC0801C1A0
   MODULE_TYPE= PEIM
   VERSION_STRING = 1.0
 
diff --git a/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf 
b/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf
index 20e2f05..1a2bd01 100644
--- a/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf
+++ b/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf
@@ -16,7 +16,7 @@
 [Defines]
   INF_VERSION= 0x00010019
   BASE_NAME  = GetInfoFromBmc
-  FILE_GUID  = 43B59C81-9C5F-4021-B0F2-947DB839B781
+  

[edk2] [PATCH edk2-non-osi v5 02/10] Hisilicon/D03/Sas: Add SasPlatform

2017-09-28 Thread Heyi Guo
Install protocol to enable sas port which is using and
transmit base address info of sas port to SasDriverDxe.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi | Bin 0 -> 3040 
bytes
 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf |  24 

 2 files changed, 24 insertions(+)

diff --git a/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi 
b/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi
new file mode 100644
index 000..4255641
Binary files /dev/null and 
b/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi differ
diff --git a/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf 
b/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf
new file mode 100644
index 000..0d747a1
--- /dev/null
+++ b/Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = SasPlatform
+  FILE_GUID  = 102D8FC9-20a4-42EB-aC14-1C98BA5b26A4
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+
+[Binaries.AARCH64]
+  PE32|SasPlatform.efi|*
-- 
1.9.1

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


[edk2] [PATCH edk2-non-osi v5 07/10] Hisilicon/D05: Update binary file

2017-09-28 Thread Heyi Guo
From: Ming Huang 

Update binary file for edk2 upgrade.
1. Replace UncachedMemoryAllocationLib with DmaLib;
2. Remove ArmCpuLib dependenc;
3. Remove ConvertToPhysicalAddress;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi   
| Bin 19552 -> 5024 bytes
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi  
| Bin 25696 -> 7680 bytes
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi  
| Bin 22528 -> 5344 bytes
 Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
| Bin 23136 -> 5280 bytes
 Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
| Bin 15968 -> 2592 bytes
 Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi  
| Bin 48000 -> 23328 bytes
 
Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 | Bin 21536 -> 4032 bytes
 Platform/Hisilicon/D05/Drivers/SFC/SFCDriver.efi   
| Bin 262144 -> 262144 bytes
 Platform/Hisilicon/D05/Drivers/Sas/SasDriverDxe.efi
| Bin 230912 -> 116288 bytes
 Platform/Hisilicon/D05/Drivers/Sm750Dxe/SmiGraphicsOutput.efi  
| Bin 35904 -> 18592 bytes
 Platform/Hisilicon/D05/Drivers/TransferSmbiosInfo/TransSmbiosInfo.efi  
| Bin 16576 -> 4288 bytes
 Platform/Hisilicon/D05/Library/OemAddressMapD05/OemAddressMapD05.lib   
| Bin 42136 -> 52968 bytes
 Platform/Hisilicon/D05/MemoryInitPei/MemoryInit.efi
| Bin 273312 -> 152576 bytes
 Silicon/Hisilicon/Hi1616/Library/Hi1616Serdes/Hi1616SerdesLib.lib  
| Bin 707246 -> 726884 bytes
 
Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 | Bin 358602 -> 344310 bytes
 15 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi 
b/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi
index 6f117e2..a0fa8c8 100644
Binary files a/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi 
and b/Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi differ
diff --git 
a/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi 
b/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi
index 139658c..9b4e23e 100644
Binary files 
a/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi and 
b/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi 
differ
diff --git 
a/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi 
b/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi
index c3d28ec..5bf6ded 100644
Binary files 
a/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi and 
b/Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi 
differ
diff --git a/Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi 
b/Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
index 96d1680..3092139 100644
Binary files a/Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi and 
b/Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
b/Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi
index 029ce97..ece5615 100644
Binary files 
a/Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi and 
b/Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi 
b/Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi
index dcabce2..9e7dd0e 100644
Binary files a/Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi and 
b/Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi differ
diff --git 
a/Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 
b/Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
index da85b0b..2be627f 100644
Binary files 
a/Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 and 
b/Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 differ
diff --git a/Platform/Hisilicon/D05/Drivers/SFC/SFCDriver.efi 
b/Platform/Hisilicon/D05/Drivers/SFC/SFCDriver.efi
index 02ea2b1..52d6107 100644
Binary files a/Platform/Hisilicon/D05/Drivers/SFC/SFCDriver.efi and 
b/Platform/Hisilicon/D05/Drivers/SFC/SFCDriver.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/Sas/SasDriverDxe.efi 

[edk2] [PATCH edk2-non-osi v5 01/10] Hisilicon/D03/Net: Update Snp driver

2017-09-28 Thread Heyi Guo
1. Replace SnpPV660Dxe with SnpPV600Dxe;
2. Add SnpPlatform:
 Install protocol to enable nic port which are using.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi | Bin 0 -> 
26688 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf |  24 
+
 Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi | Bin 56832 -> 
0 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf |  27 

 Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi | Bin 0 -> 3040 
bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf |  24 
+
 6 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi
new file mode 100644
index 000..8ce6a6d
Binary files /dev/null and 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi differ
diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
new file mode 100644
index 000..90e478d
--- /dev/null
+++ b/Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = SnpPV600Dxe
+  FILE_GUID  = 3247F15F-3612-4803-BD4E-4104D7EF944A
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+
+[Binaries.AARCH64]
+  PE32|SnpPV600Dxe.efi|*
diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi
deleted file mode 100644
index eb69403..000
Binary files a/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
and /dev/null differ
diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
deleted file mode 100644
index 204ef17..000
--- a/Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
+++ /dev/null
@@ -1,27 +0,0 @@
-#/** @file
-#
-#Copyright (c) 2016, Hisilicon Limited. All rights reserved.
-#Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
-#
-#This program and the accompanying materials
-#are licensed and made available under the terms and conditions of the BSD 
License
-#which accompanies this distribution. The full text of the license may be 
found at
-#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.
-#
-#**/
-
-[Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = SnpPV600Dxe
-  FILE_GUID  = 92D37768-571C-48d9-BEF5-9744AE2FDAF4
-  MODULE_TYPE= UEFI_DRIVER
-  VERSION_STRING = 1.0
-
-  ENTRY_POINT= InitializeSnpPV600Driver
-  UNLOAD_IMAGE   = SnpPV600Unload
-
-[Binaries]
-  PE32|SnpPV600Dxe.efi|*
diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi
new file mode 100644
index 000..5e7d8bd
Binary files /dev/null and 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi differ
diff --git a/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf 
b/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
new file mode 100644
index 000..10b2003
--- /dev/null
+++ b/Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#http://opensource.org/licenses/bsd-license.php
+#
+#THE PROGRAM IS DISTRIBUTED 

[edk2] [PATCH edk2-non-osi v5 00/10] Update D03/D05 binary for edk2 update and bug fix

2017-09-28 Thread Heyi Guo
Code can also be found in github:
https://github.com/hisilicon/OpenPlatformPkg.git
branch: rp-1710-osi-v5

Heyi Guo (5):
  Hisilicon/D03/Net: Update Snp driver
  Hisilicon/D03/Sas: Add SasPlatform
  Hisilicon/D05/Net: Update Snp driver
  Hisilicon/D05/Sas: Add SasPlatform
  Hisilicon: Fix the drivers use the same GUID issue

Ming Huang (5):
  Hisilicon/D03: Update binary file
  Hisilicon/D03: Update Trusted Firmware binary
  Hisilicon/D05: Update binary file
  Hisilicon/D05: Update Trusted Firmware binary
  Hisilicon/D05: Fix occasional system hang bug

 Platform/Hisilicon/D02/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
|   2 +-
 Platform/Hisilicon/D02/Drivers/SFC/SfcDxeDriver.inf
|   2 +-
 Platform/Hisilicon/D02/MemoryInitPei/MemoryInitPeim.inf
|   2 +-
 Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi   
| Bin 21696 -> 4768 bytes
 Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi  
| Bin 22208 -> 4672 bytes
 Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi  
| Bin 25440 -> 6784 bytes
 Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
| Bin 23712 -> 4896 bytes
 Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
| Bin 18080 -> 2304 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi 
| Bin 0 -> 26688 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
|  24 +
 Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
| Bin 56832 -> 0 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf 
|  27 
 Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi 
| Bin 0 -> 3040 bytes
 Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf 
|  24 +
 Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi  
| Bin 48352 -> 21664 bytes
 
Platform/Hisilicon/D03/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 | Bin 22112 -> 3712 bytes
 Platform/Hisilicon/D03/Drivers/SFC/SFCDriver.efi   
| Bin 262144 -> 262144 bytes
 Platform/Hisilicon/D03/Drivers/Sas/SasDriverDxe.efi
| Bin 208288 -> 98144 bytes
 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi 
| Bin 0 -> 3040 bytes
 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf 
|  24 +
 Platform/Hisilicon/D03/Drivers/Sm750Dxe/SmiGraphicsOutput.efi  
| Bin 36480 -> 17728 bytes
 Platform/Hisilicon/D03/Drivers/TransferSmbiosInfo/TransSmbiosInfo.efi  
| Bin 21408 -> 4000 bytes
 Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2P.lib 
| Bin 19486 -> 20550 bytes
 Platform/Hisilicon/D03/MemoryInitPei/MemoryInit.efi
| Bin 161280 -> 90272 bytes
 Platform/Hisilicon/D03/Sec/FVMAIN_SEC.Fv   
| Bin 262144 -> 262144 bytes
 Platform/Hisilicon/D03/bl1.bin 
| Bin 14336 -> 14336 bytes
 Platform/Hisilicon/D03/fip.bin 
| Bin 45601 -> 62513 bytes
 Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi   
| Bin 19552 -> 5024 bytes
 Platform/Hisilicon/D05/Drivers/GetInfoFromBmc/GetInfoFromBmc.inf   
|   2 +-
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.efi  
| Bin 25696 -> 7680 bytes
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.inf  
|   2 +-
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi  
| Bin 22528 -> 5344 bytes
 Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.inf  
|   2 +-
 Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
| Bin 23136 -> 5280 bytes
 Platform/Hisilicon/D05/Drivers/IpmiMiscOpDxe/IpmiMiscOpDxe.inf 
|   2 +-
 Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
| Bin 15968 -> 2592 bytes
 Platform/Hisilicon/D05/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.inf 
|   2 +-
 Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi 
| Bin 0 -> 28544 bytes
 Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
|  24 +
 Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
| Bin 

[edk2] [PATCH edk2-non-osi v5 04/10] Hisilicon/D03: Update Trusted Firmware binary

2017-09-28 Thread Heyi Guo
From: Ming Huang 

The Trusted Firmware binary was produced from the commit hash:
"14c7bdf"

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/bl1.bin | Bin 14336 -> 14336 bytes
 Platform/Hisilicon/D03/fip.bin | Bin 45601 -> 62513 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D03/bl1.bin b/Platform/Hisilicon/D03/bl1.bin
index 7bf0698..cdaa743 100644
Binary files a/Platform/Hisilicon/D03/bl1.bin and 
b/Platform/Hisilicon/D03/bl1.bin differ
diff --git a/Platform/Hisilicon/D03/fip.bin b/Platform/Hisilicon/D03/fip.bin
index 913d40d..ae4ed1a 100644
Binary files a/Platform/Hisilicon/D03/fip.bin and 
b/Platform/Hisilicon/D03/fip.bin differ
-- 
1.9.1

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


[edk2] [PATCH edk2-non-osi v5 05/10] Hisilicon/D05/Net: Update Snp driver

2017-09-28 Thread Heyi Guo
1. Replace SnpPV660Dxe with SnpPV600Dxe;
2. Add SnpPlatform:
 Install protocol to enable nic port which are using.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi | Bin 0 -> 
28544 bytes
 Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf |  24 
+
 Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi | Bin 56512 -> 
0 bytes
 Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf |  27 

 Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi | Bin 0 -> 3392 
bytes
 Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf |  24 
+
 6 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi
new file mode 100644
index 000..bc7942a
Binary files /dev/null and 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
new file mode 100644
index 000..90e478d
--- /dev/null
+++ b/Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = SnpPV600Dxe
+  FILE_GUID  = 3247F15F-3612-4803-BD4E-4104D7EF944A
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+
+[Binaries.AARCH64]
+  PE32|SnpPV600Dxe.efi|*
diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi
deleted file mode 100644
index c54538f..000
Binary files a/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.efi 
and /dev/null differ
diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
deleted file mode 100644
index 98cc3b8..000
--- a/Platform/Hisilicon/D05/Drivers/Net/SnpPV660Dxe/SnpPV600Dxe.inf
+++ /dev/null
@@ -1,27 +0,0 @@
-#/** @file
-#
-#Copyright (c) 2016, Hisilicon Limited. All rights reserved.
-#Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
-#
-#This program and the accompanying materials
-#are licensed and made available under the terms and conditions of the BSD 
License
-#which accompanies this distribution. The full text of the license may be 
found at
-#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.
-#
-#**/
-
-[Defines]
-  INF_VERSION= 0x00010019
-  BASE_NAME  = SnpPV600Dxe
-  FILE_GUID  = 85F85FDE-FDA1-465A-B22E-488F1A6F966C
-  MODULE_TYPE= UEFI_DRIVER
-  VERSION_STRING = 1.0
-
-  ENTRY_POINT= InitializeSnpPV600Driver
-  UNLOAD_IMAGE   = SnpPV600Unload
-
-[Binaries]
-  PE32|SnpPV600Dxe.efi|*
diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi
new file mode 100644
index 000..42c26de
Binary files /dev/null and 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf 
b/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
new file mode 100644
index 000..10b2003
--- /dev/null
+++ b/Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#http://opensource.org/licenses/bsd-license.php
+#
+#THE PROGRAM IS DISTRIBUTED 

[edk2] [PATCH edk2-non-osi v5 03/10] Hisilicon/D03: Update binary file

2017-09-28 Thread Heyi Guo
From: Ming Huang 

Update binary file for edk2 upgrade.
1. Replace UncachedMemoryAllocationLib with DmaLib;
2. Remove ArmCpuLib dependenc;
3. Remove ConvertToPhysicalAddress;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi   
| Bin 21696 -> 4768 bytes
 Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi  
| Bin 22208 -> 4672 bytes
 Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi  
| Bin 25440 -> 6784 bytes
 Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
| Bin 23712 -> 4896 bytes
 Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
| Bin 18080 -> 2304 bytes
 Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi  
| Bin 48352 -> 21664 bytes
 
Platform/Hisilicon/D03/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 | Bin 22112 -> 3712 bytes
 Platform/Hisilicon/D03/Drivers/SFC/SFCDriver.efi   
| Bin 262144 -> 262144 bytes
 Platform/Hisilicon/D03/Drivers/Sas/SasDriverDxe.efi
| Bin 208288 -> 98144 bytes
 Platform/Hisilicon/D03/Drivers/Sm750Dxe/SmiGraphicsOutput.efi  
| Bin 36480 -> 17728 bytes
 Platform/Hisilicon/D03/Drivers/TransferSmbiosInfo/TransSmbiosInfo.efi  
| Bin 21408 -> 4000 bytes
 Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2P.lib 
| Bin 19486 -> 20550 bytes
 Platform/Hisilicon/D03/MemoryInitPei/MemoryInit.efi
| Bin 161280 -> 90272 bytes
 Platform/Hisilicon/D03/Sec/FVMAIN_SEC.Fv   
| Bin 262144 -> 262144 bytes
 Silicon/Hisilicon/Hi1610/Library/Hi1610Serdes/Hi1610SerdesLib.lib  
| Bin 603524 -> 587188 bytes
 Silicon/Hisilicon/Hi1610/Library/IpmiCmdLib/IpmiCmdLib.lib 
| Bin 247176 -> 210280 bytes
 Silicon/Hisilicon/Hi1610/Library/LpcLib/LpcLib.lib 
| Bin 13998 -> 13958 bytes
 
Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 | Bin 305230 -> 297590 bytes
 Silicon/Hisilicon/Hi1610/Library/Uart/LpcSerialPortLib/LpcSerialPortLib.lib
| Bin 17022 -> 16942 bytes
 19 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi 
b/Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi
index 269243a..12640f2 100644
Binary files a/Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi 
and b/Platform/Hisilicon/D03/Drivers/GetInfoFromBmc/GetInfoFromBmc.efi differ
diff --git 
a/Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi 
b/Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi
index c197895..d2565c8 100644
Binary files 
a/Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi and 
b/Platform/Hisilicon/D03/Drivers/Ipmi/IpmiInterfacePei/IpmiInterfacePei.efi 
differ
diff --git 
a/Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi 
b/Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi
index 6201971..0d8ff52 100644
Binary files 
a/Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi and 
b/Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.efi 
differ
diff --git a/Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi 
b/Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi
index 7409fcb..b85c19b 100644
Binary files a/Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi and 
b/Platform/Hisilicon/D03/Drivers/IpmiMiscOpDxe/IpmiMiscOp.efi differ
diff --git a/Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi 
b/Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi
index a9238b1..89c4b5b 100644
Binary files 
a/Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi and 
b/Platform/Hisilicon/D03/Drivers/IpmiWatchdogDxe/IpmiWatchdogDxe.efi differ
diff --git a/Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi 
b/Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi
index 0a0d9d5..e1970fd 100644
Binary files a/Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi and 
b/Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi differ
diff --git 
a/Platform/Hisilicon/D03/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 
b/Platform/Hisilicon/D03/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
index 12b2af7..0572a71 100644
Binary files 
a/Platform/Hisilicon/D03/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.efi
 and 

[edk2] [PATCH edk2-non-osi v5 06/10] Hisilicon/D05/Sas: Add SasPlatform

2017-09-28 Thread Heyi Guo
Install protocol to enable sas port which is using and
transmit base address info of sas port to SasDriverDxe.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
---
 Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi | Bin 0 -> 3424 
bytes
 Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf |  24 

 2 files changed, 24 insertions(+)

diff --git a/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi 
b/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi
new file mode 100644
index 000..d2685ab
Binary files /dev/null and 
b/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi differ
diff --git a/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf 
b/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf
new file mode 100644
index 000..0d747a1
--- /dev/null
+++ b/Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf
@@ -0,0 +1,24 @@
+#/** @file
+#
+#Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#Copyright (c) 2017, Linaro Limited. All rights reserved.
+#
+#This program and the accompanying materials
+#are licensed and made available under the terms and conditions of the BSD 
License
+#which accompanies this distribution. The full text of the license may be 
found at
+#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.
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = SasPlatform
+  FILE_GUID  = 102D8FC9-20a4-42EB-aC14-1C98BA5b26A4
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+
+[Binaries.AARCH64]
+  PE32|SasPlatform.efi|*
-- 
1.9.1

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


Re: [edk2] [PATCH] UefiCpuPkg/SmmCpuFeaturesLib: replace hard-coded machine code

2017-09-28 Thread Dong, Eric
Hi Chris,

Thanks to provide this change. I have confirmed no binary change after this 
patch. 

Pushed this patch:
SHA-1: 4c34a8ea191155f438901e635bd87810072b19a4

* UefiCpuPkg/SmmCpuFeaturesLib: replace hard-coded machine code

Replace hard-coded machine code with equivalent assembly source code.
Changes tested by checking for machine code equivalence by disassembling
the original and changed code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Reviewed-by: Eric Dong 


Thanks,
Eric
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Chris 
Ruffin
Sent: Thursday, September 28, 2017 9:52 AM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Yao, Jiewen 

Subject: [edk2] [PATCH] UefiCpuPkg/SmmCpuFeaturesLib: replace hard-coded 
machine code

Replace hard-coded machine code with equivalent assembly source code.
Changes tested by checking for machine code equivalence by disassembling the 
original and changed code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Ruffin 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
---
 .../Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm   | 24 ++
 .../SmmCpuFeaturesLib/Ia32/SmiException.nasm   |  5 ++--
 .../Library/SmmCpuFeaturesLib/X64/SmiEntry.nasm| 29 --
 .../SmmCpuFeaturesLib/X64/SmiException.nasm|  5 ++--
 4 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
index b1c84a494f..00c0f0672c 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiEntry.nasm
@@ -1,5 +1,5 @@
 
;-- 
; -; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2017, Intel Corporation. All rights 
+reserved.
 ; This program and the accompanying materials  ; are licensed and made 
available under the terms and conditions of the BSD License  ; which 
accompanies this distribution.  The full text of the license may be found at @@ 
-51,6 +51,11 @@ global ASM_PFX(gStmSmbase)  global ASM_PFX(gStmXdSupported)  
extern ASM_PFX(gStmSmiHandlerIdtr)
 
+ASM_PFX(gStmSmiCr3)  EQU StmSmiCr3Patch - 4
+ASM_PFX(gStmSmiStack)EQU StmSmiStackPatch - 4
+ASM_PFX(gStmSmbase)  EQU StmSmbasePatch - 4
+ASM_PFX(gStmXdSupported) EQU StmXdSupportedPatch - 1
+
 SECTION .text
 
 BITS 16
@@ -66,8 +71,8 @@ _StmSmiEntryPoint:
 o32 lgdt[cs:bx]   ; lgdt fword ptr cs:[bx]
 mov ax, PROTECT_MODE_CS
 mov [cs:bx-0x2],ax
-DB  0x66, 0xbf   ; mov edi, SMBASE
-ASM_PFX(gStmSmbase): DD 0
+o32 mov edi, strict dword 0
+StmSmbasePatch:
 lea eax, [edi + (@32bit - _StmSmiEntryPoint) + 0x8000]
 mov [cs:bx-0x6],eax
 mov ebx, cr0
@@ -87,15 +92,15 @@ o16 mov es, ax
 o16 mov fs, ax
 o16 mov gs, ax
 o16 mov ss, ax
-DB  0xbc   ; mov esp, imm32
-ASM_PFX(gStmSmiStack): DD 0
+mov esp, strict dword 0
+StmSmiStackPatch:
 mov eax, ASM_PFX(gStmSmiHandlerIdtr)
 lidt[eax]
 jmp ProtFlatMode
 
 ProtFlatMode:
-DB  0xb8; mov eax, imm32
-ASM_PFX(gStmSmiCr3): DD 0
+mov eax, strict dword 0
+StmSmiCr3Patch:
 mov cr3, eax
 ;
 ; Need to test for CR4 specific bit support @@ -134,8 +139,8 @@ 
ASM_PFX(gStmSmiCr3): DD 0
 .6:
 
 ; enable NXE if supported
-DB  0b0h; mov al, imm8
-ASM_PFX(gStmXdSupported): DB  1
+mov al, strict byte 1
+StmXdSupportedPatch:
 cmp al, 0
 jz  @SkipXd
 ;
@@ -268,4 +273,3 @@ _StmSmiHandler:
 
 ASM_PFX(gcStmSmiHandlerSize)   : DW$ - _StmSmiEntryPoint
 ASM_PFX(gcStmSmiHandlerOffset) : DW_StmSmiHandler - _StmSmiEntryPoint
-
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm
index 0ce8501ba9..93dc3005b7 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmiException.nasm
@@ -1,5 +1,5 @@
 
;-- 
; -; Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2009 - 2017, Intel Corporation. All rights 
+reserved.
 ; This program and the accompanying materials  ; are licensed and made 
available under the terms and conditions of the BSD License  ; which 
accompanies this distribution.  The full text of the license 

Re: [edk2] multiple levels of support for MOR / MORLock

2017-09-28 Thread Yao, Jiewen
Thanks Laszlo.

Yes, I agree it is bug. Would you please help to file a bugzilar in EDKII?

For the fix, I think we have a way to resolve it without PCD. (I do not want to 
bother a platform developer to set a new PCD.)

The only invalid case we need handle is: MOR is absent, but MORL is present.

My thought is to let Variable driver check if MOR is present. Variable driver 
can defer the MORL setting at EndOfDxe event based upon the presence of MOR. If 
MOR driver is present, it sets MOR at entrypoint. EndOfDxe is good enough to 
know the state.

Also, because EndOfDxe is PI event, the UEFI OS is not aware of that.

Thank you
Yao Jiewen


> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Thursday, September 28, 2017 8:55 PM
> To: Yao, Jiewen 
> Cc: Ladi Prosek ; edk2-devel-01 
> Subject: multiple levels of support for MOR / MORLock
> 
> Hi Jiewen,
> 
> my colleague Ladi (CC'd) reported an issue about MORLock in OVMF (and
> also analyzed it in great depth):
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1496170
> 
> Here's my understanding of the "MemoryOverwriteRequestControl" and
> "MemoryOverwriteRequestControlLock" variables:
> 
> (1) The "MemoryOverwriteRequestControl" variable comes from the "TCG
> Platform Reset Attack Mitigation Specification" at
> 
>  -Attack-Mitigation-Specification.pdf>.
> 
> (2) The "MemoryOverwriteRequestControlLock" variable is a Microsoft-only
> addition, called "Secure MOR implementation", from
> 
>  guard-requirements>.
> 
> (3) "winload.efi" accepts the following cases as "valid":
> 
> (3a) Both MORC and MORCL are present. In this case MORC is set and MORCL
>  is used to lock both MORC and MORCL.
> 
> (3b) MORC is present, MORCL is absent. In this case "winload.efi" thinks
>  that the platform follows the TCG spec from (1), and does not
>  support the Microsoft spec from (2). MORC is set, but it is not
>  locked.
> 
> (3c) Both MORC and MORCL are missing. "winload.efi" thinks that the
>  platform does not know about either spec, and "winload.efi" accepts
>  that as OK.
> 
> However "winload.efi"rejects the following case as "invalid":
> 
> (3d) MORCL is present, but MORC is missing. In my opinion, "winload.efi"
>  is right to reject this, because it implies that the platform
>  supports the *dependent* spec (2), but does not support the
>  *prerequisite* spec (1).
> 
> 
> In edk2, MORC is implemented by the
> "SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf" driver. A platform
> is allowed *not* to include this driver, even if it supports SMM.
> 
> OVMF is such a platform; it does not include "TcgMor.inf".
> 
> However, MORCL is initialized in the variable driver, independently of
> platform support for MORC:
> 
> * If the platform includes the SMM driver backend, then we have:
> 
>   VariableWriteServiceInitialize()
> [MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c]
> MorLockInit()
> [MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c]
>   SetMorLockVariable()
> [MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c]
> //
> // create or set variable
> // with contents 0
> //
> 
> * If the platform includes no SMM backend for the variable services,
>   then we have:
> 
>   VariableWriteServiceInitialize()
> [MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c]
> MorLockInit()
> [MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockDxe.c]
>   //
>   // delete the variable and
>   // also lock it so that
>   // nothing else can
>   // create it
>   //
> 
> In my opinion, if the platform includes the SMM backend, but does not
> support "MORC", then the "TcgMorLockSmm.c" code is incorrect; instead we
> should do what we see in "TcgMorLockDxe.c".
> 
> In other words, SMM support in itself is no indication for claiming
> support for MORCL.
> 
> 
> I suggest that we introduce a new PCD for this
> ("PcdSupportMemoryOverwriteRequest"), in "SecurityPkg.dec", with type
> UINT8. It should be a bitmap:
> 
> - BIT0 -- If clear, then MORC is not supported, and BIT1 is ignored.
>   Otherwise, MORC is supported, and BIT1 is meaningful.
> 
> - BIT1 -- If clear, then MORCL is unsupported. If set, then MORCL is
>   supported.
> 
> - BIT2 through BIT7 are reserved.
> 
> 
> In turn, here's how the new PCD should be handled, in my opinion:
> 
> - MorLockInit() in "TcgMorLockDxe.c" should do what it does now, but it
>   should also assert that BIT1 is clear.
> 
> - MorLockInit() in "TcgMorLockSmm.c" should do what it does now *only*
>   if BIT1 is set. Otherwise (i.e., BIT1 is clear), it should do what
>   "TcgMorLockDxe.c" does now.
> 
> - If BIT0 is clear (MORC is not supported), then both 

Re: [edk2] [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Wu, Hao A
> Sent: Friday, September 29, 2017 9:28 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Zeng, Star ; Kinney,
> Michael D ; Yao, Jiewen 
> Subject: [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to
> check NULL ptr
> 
> Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
> checking NULL pointer dereference.
> 
> The ASSERT added here is for addressing a false positive NULL pointer
> dereference issue raised from static analysis.
> 
> This commit adds comments to clarify the reason for using ASSERT as the
> check.
> 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Core/Dxe/Hand/Handle.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> index 2db441725c..86a4065733 100644
> --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> @@ -1175,10 +1175,18 @@ Done:
>  //
>  if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
>//
> +  // According to above logic, if 'Prot' is NULL, then the 'Status' must 
> be
> +  // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so
> 'Prot'
> +  // must be not NULL.
> +  //
> +  // The ASSERT here is for addressing a false positive NULL pointer
> +  // dereference issue raised from static analysis.
> +  //
> +  ASSERT (Prot != NULL);
> +  //
>// EFI_ALREADY_STARTED is not an error for bus driver.
>// Return the corresponding protocol interface.
>//
> -  ASSERT (Prot != NULL);
>*Interface = Prot->Interface;
>  } else if (Status == EFI_UNSUPPORTED) {
>//
> --
> 2.12.0.windows.1

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


[edk2] [PATCH v2] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Hao Wu
Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
checking NULL pointer dereference.

The ASSERT added here is for addressing a false positive NULL pointer
dereference issue raised from static analysis.

This commit adds comments to clarify the reason for using ASSERT as the
check.

Cc: Star Zeng 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Core/Dxe/Hand/Handle.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c 
b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index 2db441725c..86a4065733 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -1175,10 +1175,18 @@ Done:
 //
 if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
   //
+  // According to above logic, if 'Prot' is NULL, then the 'Status' must be
+  // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
+  // must be not NULL.
+  //
+  // The ASSERT here is for addressing a false positive NULL pointer
+  // dereference issue raised from static analysis.
+  //
+  ASSERT (Prot != NULL);
+  //
   // EFI_ALREADY_STARTED is not an error for bus driver.
   // Return the corresponding protocol interface.
   //
-  ASSERT (Prot != NULL);
   *Interface = Prot->Interface;
 } else if (Status == EFI_UNSUPPORTED) {
   //
-- 
2.12.0.windows.1

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


[edk2] [Patch 3/3] BaseTools: Update Makefile to support FFS file generation

2017-09-28 Thread Yonghong Zhu
Update Makefile to support FFS file generation.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py |  16 +-
 BaseTools/Source/Python/AutoGen/GenMake.py |  84 +
 BaseTools/Source/Python/GenFds/AprioriSection.py   |  16 +-
 BaseTools/Source/Python/GenFds/CompressSection.py  |  10 +-
 BaseTools/Source/Python/GenFds/DataSection.py  |  37 ++--
 BaseTools/Source/Python/GenFds/DepexSection.py |   6 +-
 BaseTools/Source/Python/GenFds/EfiSection.py   |  78 
 BaseTools/Source/Python/GenFds/Fd.py   |  24 ++-
 BaseTools/Source/Python/GenFds/FfsFileStatement.py |   4 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  | 198 -
 BaseTools/Source/Python/GenFds/Fv.py   | 187 ++-
 BaseTools/Source/Python/GenFds/FvImageSection.py   |   8 +-
 BaseTools/Source/Python/GenFds/GenFds.py   |  17 ++
 .../Source/Python/GenFds/GenFdsGlobalVariable.py   | 168 +
 BaseTools/Source/Python/GenFds/GuidSection.py  |  59 +-
 .../Source/Python/GenFds/OptRomFileStatement.py|   4 +-
 .../Source/Python/GenFds/OptRomInfStatement.py |  12 +-
 BaseTools/Source/Python/GenFds/OptionRom.py|  25 +--
 BaseTools/Source/Python/GenFds/Region.py   |  49 +++--
 BaseTools/Source/Python/GenFds/Section.py  |   4 +-
 BaseTools/Source/Python/GenFds/UiSection.py|   5 +-
 BaseTools/Source/Python/GenFds/VerSection.py   |   9 +-
 BaseTools/Source/Python/build/build.py |  18 +-
 23 files changed, 656 insertions(+), 382 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 14eb138..981f0a6 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2757,10 +2757,11 @@ class ModuleAutoGen(AutoGen):
 self._CustomMakefile  = None
 self._Macro   = None
 
 self._BuildDir= None
 self._OutputDir   = None
+self._FfsOutputDir= None
 self._DebugDir= None
 self._MakeFileDir = None
 
 self._IncludePathList = None
 self._IncludePathLength = 0
@@ -2873,10 +2874,11 @@ class ModuleAutoGen(AutoGen):
 self._Macro["PLATFORM_GUID" ] = self.PlatformInfo.Guid
 self._Macro["PLATFORM_VERSION"  ] = self.PlatformInfo.Version
 self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir
 self._Macro["PLATFORM_DIR"  ] = 
mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)
 self._Macro["PLATFORM_OUTPUT_DIR"   ] = self.PlatformInfo.OutputDir
+self._Macro["FFS_OUTPUT_DIR"] = self.FfsOutputDir
 return self._Macro
 
 ## Return the module build data object
 def _GetModule(self):
 if self._Module == None:
@@ -2963,10 +2965,19 @@ class ModuleAutoGen(AutoGen):
 if self._OutputDir == None:
 self._OutputDir = path.join(self.BuildDir, "OUTPUT")
 CreateDirectory(self._OutputDir)
 return self._OutputDir
 
+## Return the directory to store ffs file
+def _GetFfsOutputDir(self):
+if self._FfsOutputDir == None:
+if GlobalData.gFdfParser != None:
+self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, 
"FV", "Ffs", self.Guid + self.Name)
+else:
+self._FfsOutputDir = ''
+return self._FfsOutputDir
+
 ## Return the directory to store auto-gened source files of the mdoule
 def _GetDebugDir(self):
 if self._DebugDir == None:
 self._DebugDir = path.join(self.BuildDir, "DEBUG")
 CreateDirectory(self._DebugDir)
@@ -4219,20 +4230,20 @@ class ModuleAutoGen(AutoGen):
 ## Create makefile for the module and its dependent libraries
 #
 #   @param  CreateLibraryMakeFile   Flag indicating if or not the 
makefiles of
 #   dependent libraries will be created
 #
-def CreateMakeFile(self, CreateLibraryMakeFile=True):
+def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):
 # Ignore generating makefile when it is a binary module
 if self.IsBinaryModule:
 return
 
 if self.IsMakeFileCreated:
 return
 if self.CanSkip():
 return
-
+self.GenFfsList = GenFfsList
 if not self.IsLibrary and CreateLibraryMakeFile:
 for LibraryAutoGen in self.LibraryAutoGenList:
 LibraryAutoGen.CreateMakeFile()
 
 if len(self.CustomMakefile) == 0:
@@ -4452,10 +4463,11 @@ class ModuleAutoGen(AutoGen):
 
 IsLibrary   = property(_IsLibrary)
 

[edk2] [Patch 2/3] BaseTools: Update Trim to generate VfrBinOffset Binary

2017-09-28 Thread Yonghong Zhu
Its usage is
"Trim --Vfr-Uni-Offset -o $(OUTPUT_DIR)(+)$(MODULE_NAME)VfrOffset.sec
--ModuleName=$(MODULE_NAME) --DebugDir=$(DEBUG_DIR)"

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/Trim/Trim.py | 81 ++--
 1 file changed, 78 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/Trim/Trim.py 
b/BaseTools/Source/Python/Trim/Trim.py
index 9ccc027..47d72a9 100644
--- a/BaseTools/Source/Python/Trim/Trim.py
+++ b/BaseTools/Source/Python/Trim/Trim.py
@@ -1,9 +1,9 @@
 ## @file
 # Trim files preprocessed by compiler
 #
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
 # which accompanies this distribution.  The full text of the license may be 
found at
 # http://opensource.org/licenses/bsd-license.php
 #
@@ -15,10 +15,11 @@
 # Import Modules
 #
 import Common.LongFilePathOs as os
 import sys
 import re
+import StringIO
 
 from optparse import OptionParser
 from optparse import make_option
 from Common.BuildToolError import *
 from Common.Misc import *
@@ -27,11 +28,11 @@ import Common.EdkLogger as EdkLogger
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
 # Version and Copyright
 __version_number__ = ("0.10" + " " + gBUILD_VERSION)
 __version__ = "%prog Version " + __version_number__
-__copyright__ = "Copyright (c) 2007-2016, Intel Corporation. All rights 
reserved."
+__copyright__ = "Copyright (c) 2007-2017, Intel Corporation. All rights 
reserved."
 
 ## Regular expression for matching Line Control directive like "#line xxx"
 gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
 ## Regular expression for matching "typedef struct"
 gTypedefPattern = re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", 
re.MULTILINE)
@@ -428,10 +429,72 @@ def TrimAslFile(Source, Target, IncludePathFile):
 EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=Target)
 
 f.writelines(Lines)
 f.close()
 
+def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
+VfrNameList = []
+if os.path.isdir(DebugDir):
+for CurrentDir, Dirs, Files in os.walk(DebugDir):
+for FileName in Files:
+Name, Ext = os.path.splitext(FileName)
+if Ext == '.lst':
+VfrNameList.append (Name + 'Bin')
+
+VfrNameList.append (ModuleName + 'Strings')
+
+EfiFileName = os.path.join(DebugDir, ModuleName + '.efi')
+MapFileName = os.path.join(DebugDir, ModuleName + '.map')
+VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrNameList)
+
+if not VfrUniOffsetList:
+return
+
+try:
+fInputfile = open(OutputFile, "wb+", 0)
+except:
+EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %s" 
%OutputFile, None)
+
+# Use a instance of StringIO to cache data
+fStringIO = StringIO.StringIO('')
+
+for Item in VfrUniOffsetList:
+if (Item[0].find("Strings") != -1):
+#
+# UNI offset in image.
+# GUID + Offset
+# { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 
0xfc, 0x6, 0x66 } }
+#
+UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 
0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]
+UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]
+fStringIO.write(''.join(UniGuid))
+UniValue = pack ('Q', int (Item[1], 16))
+fStringIO.write (UniValue)
+else:
+#
+# VFR binary offset in image.
+# GUID + Offset
+# { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 
0xda, 0x6, 0xa2 } };
+#
+VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 
0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]
+VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]
+fStringIO.write(''.join(VfrGuid))
+type (Item[1])
+VfrValue = pack ('Q', int (Item[1], 16))
+fStringIO.write (VfrValue)
+
+#
+# write data into file.
+#
+try :
+fInputfile.write (fStringIO.getvalue())
+except:
+EdkLogger.error("Trim", FILE_WRITE_FAILURE, "Write data to file %s 
failed, please check whether the file been locked or using by other 
applications." %OutputFile, None)
+
+fStringIO.close ()
+fInputfile.close ()
+
 ## Trim EDK source code file(s)
 #
 #
 # @param  SourceFile or directory to be trimmed
 # @param  TargetFile or directory to store the trimmed content
@@ -533,10 +596,12 @@ def Options():
 OptionList = [
 make_option("-s", "--source-code", dest="FileType", 

[edk2] [Patch 1/3] BaseTools: GenFfs support to get alignment value from SectionFile

2017-09-28 Thread Yonghong Zhu
Update GenFfs tool to get alignment value from SectionFile when use
the new option -n 0.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/C/GenFfs/GenFfs.c | 127 -
 1 file changed, 125 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c 
b/BaseTools/Source/C/GenFfs/GenFfs.c
index cb16f38..26a3c88 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -10,10 +10,17 @@ 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.  
   
 
 **/
 
+#ifndef __GNUC__
+#include 
+#include 
+#include 
+#include 
+#endif
+
 #include 
 #include 
 #include 
 
 #include 
@@ -22,10 +29,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include 
 
 #include "CommonLib.h"
 #include "ParseInf.h"
 #include "EfiUtilityMsgs.h"
+#include "FvLib.h"
+#include "PeCoffLib.h"
 
 #define UTILITY_NAME"GenFfs"
 #define UTILITY_MAJOR_VERSION   0
 #define UTILITY_MINOR_VERSION   1
 
@@ -151,11 +160,12 @@ Returns:
 128K,256K,512K,1M,2M,4M,8M,16M\n");
   fprintf (stdout, "  -i SectionFile, --sectionfile SectionFile\n\
 Section file will be contained in this FFS file.\n");
   fprintf (stdout, "  -n SectionAlign, --sectionalign SectionAlign\n\
 SectionAlign points to section alignment, which 
support\n\
-the alignment scope 1~16M. It is specified together\n\
+the alignment scope 0~16M. If SectionAlign is 
specified as 0, tool\n\
+get alignment value from SectionFile. It is specified 
together\n\
 with sectionfile to point its alignment in FFS 
file.\n");
   fprintf (stdout, "  -v, --verbose Turn on verbose output with 
informational messages.\n");
   fprintf (stdout, "  -q, --quiet   Disable all messages except key 
message and fatal error\n");
   fprintf (stdout, "  -d, --debug level Enable debug messages, at input 
debug level.\n");
   fprintf (stdout, "  --version Show program's version number and 
exit.\n");
@@ -455,10 +465,101 @@ Returns:
 *BufferLength = Size;
 return EFI_SUCCESS;
   }
 }
 
+EFI_STATUS
+FfsRebaseImageRead (
+IN  VOID*FileHandle,
+IN  UINTN   FileOffset,
+IN OUT  UINT32  *ReadSize,
+OUT VOID*Buffer
+)
+  /*++
+
+Routine Description:
+
+Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF 
file
+
+Arguments:
+
+   FileHandle - The handle to the PE/COFF file
+
+   FileOffset - The offset, in bytes, into the file to read
+
+   ReadSize   - The number of bytes to read from the file starting at 
FileOffset
+
+   Buffer - A pointer to the buffer to read the data into.
+
+   Returns:
+
+   EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF 
file starting at FileOffset
+
+   --*/
+{
+  CHAR8   *Destination8;
+  CHAR8   *Source8;
+  UINT32  Length;
+
+  Destination8  = Buffer;
+  Source8   = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
+  Length= *ReadSize;
+  while (Length--) {
+*(Destination8++) = *(Source8++);
+  }
+
+  return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
+  /*++
+InFile is input file for getting alignment
+return the alignment
+--*/
+{
+  FILE   *InFileHandle;
+  UINT8  *PeFileBuffer;
+  UINTN  PeFileSize;
+  UINT32 CurSecHdrSize;
+  PE_COFF_LOADER_IMAGE_CONTEXT   ImageContext;
+  EFI_COMMON_SECTION_HEADER  *CommonHeader;
+  EFI_STATUS Status;
+
+  InFileHandle= NULL;
+  PeFileBuffer= NULL;
+
+  memset (, 0, sizeof (ImageContext));
+
+  InFileHandle = fopen(LongFilePath(InFile), "rb");
+  if (InFileHandle == NULL){
+Error (NULL, 0, 0001, "Error opening file", InFile);
+return EFI_ABORTED;
+  }
+  PeFileSize = _filelength (fileno(InFileHandle));
+  PeFileBuffer = (UINT8 *) malloc (PeFileSize);
+  if (PeFileBuffer == NULL) {
+fclose (InFileHandle);
+Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", 
InFileHandle);
+return EFI_OUT_OF_RESOURCES;
+  }
+  fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+  fclose (InFileHandle);
+  CommonHeader = (EFI_COMMON_SECTION_HEADER *) PeFileBuffer;
+  CurSecHdrSize = GetSectionHeaderLength(CommonHeader);
+  ImageContext.Handle = (VOID *) ((UINTN)PeFileBuffer + CurSecHdrSize);
+  ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE)FfsRebaseImageRead;
+  Status   = 

[edk2] [Patch 0/3] BaseTools: Enable multiple thread to generate FFS file

2017-09-28 Thread Yonghong Zhu
These patches enable multiple thread to generate ffs file by merge FFS file's
generation into Make phase.

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 

Yonghong Zhu (3):
  BaseTools: GenFfs support to get alignment value from SectionFile
  BaseTools: Update Trim to generate VfrBinOffset Binary
  BaseTools: Update Makefile to support FFS file generation

 BaseTools/Source/C/GenFfs/GenFfs.c | 127 -
 BaseTools/Source/Python/AutoGen/AutoGen.py |  16 +-
 BaseTools/Source/Python/AutoGen/GenMake.py |  84 +
 BaseTools/Source/Python/GenFds/AprioriSection.py   |  16 +-
 BaseTools/Source/Python/GenFds/CompressSection.py  |  10 +-
 BaseTools/Source/Python/GenFds/DataSection.py  |  37 ++--
 BaseTools/Source/Python/GenFds/DepexSection.py |   6 +-
 BaseTools/Source/Python/GenFds/EfiSection.py   |  78 
 BaseTools/Source/Python/GenFds/Fd.py   |  24 ++-
 BaseTools/Source/Python/GenFds/FfsFileStatement.py |   4 +-
 BaseTools/Source/Python/GenFds/FfsInfStatement.py  | 198 -
 BaseTools/Source/Python/GenFds/Fv.py   | 187 ++-
 BaseTools/Source/Python/GenFds/FvImageSection.py   |   8 +-
 BaseTools/Source/Python/GenFds/GenFds.py   |  17 ++
 .../Source/Python/GenFds/GenFdsGlobalVariable.py   | 168 +
 BaseTools/Source/Python/GenFds/GuidSection.py  |  59 +-
 .../Source/Python/GenFds/OptRomFileStatement.py|   4 +-
 .../Source/Python/GenFds/OptRomInfStatement.py |  12 +-
 BaseTools/Source/Python/GenFds/OptionRom.py|  25 +--
 BaseTools/Source/Python/GenFds/Region.py   |  49 +++--
 BaseTools/Source/Python/GenFds/Section.py  |   4 +-
 BaseTools/Source/Python/GenFds/UiSection.py|   5 +-
 BaseTools/Source/Python/GenFds/VerSection.py   |   9 +-
 BaseTools/Source/Python/Trim/Trim.py   |  81 -
 BaseTools/Source/Python/build/build.py |  18 +-
 25 files changed, 859 insertions(+), 387 deletions(-)

-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Wu, Hao A
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Udit
> Kumar
> Sent: Thursday, September 28, 2017 5:28 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Kinney, Michael D; Yao, Jiewen; Zeng, Star
> Subject: Re: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the
> ASSERT to check NULL ptr
> 
> 
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Hao
> > Wu
> > Sent: Thursday, September 28, 2017 12:31 PM
> > To: edk2-devel@lists.01.org
> > Cc: Hao Wu ; Michael D Kinney
> > ; Jiewen Yao ; Star
> Zeng
> > 
> > Subject: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the
> > ASSERT to check NULL ptr
> >
> > Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
> > checking NULL pointer dereference.
> >
> > This commit adds comments to clarify the reason for using ASSERT as the
> check.
> >
> > Cc: Star Zeng 
> > Cc: Michael D Kinney 
> > Cc: Jiewen Yao 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > index 2db441725c..344ff1fe02 100644
> > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > @@ -1175,10 +1175,15 @@ Done:
> >  //
> >  if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
> >//
> > +  // According to above logic, if 'Prot' is NULL, then the 'Status' 
> > must be
> > +  // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so
> 'Prot'
> > +  // must be not NULL.
> > +  //
> > +  ASSERT (Prot != NULL);
> > +  //
> 
> I think , we should take care of no debug environment here
> If MDEPKG_NDEBUG is not defined and Prot is NULL then
> shouldn't we return error ?

Hi Udit Kumar,

As mentioned in another feedback for this patch from Mike, the ASSERT here
is added duet to a false positive report from static analysis.

The code logic actually ensures that 'Prot' will not be NULL within the
'if' statement:

"if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {"

I will refine the patch to add more comments for the ASSERT used here so
that later if there's improvement for the static analysis, we can locate
and remove this ASSERT by searching keywords in the comments.


Best Regards,
Hao Wu

> 
> >// EFI_ALREADY_STARTED is not an error for bus driver.
> >// Return the corresponding protocol interface.
> >//
> > -  ASSERT (Prot != NULL);
> >*Interface = Prot->Interface;
> >  } else if (Status == EFI_UNSUPPORTED) {
> >//
> > --
> > 2.12.0.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.

2017-09-28 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

-Original Message-
From: Dong, Eric 
Sent: Friday, September 29, 2017 8:27 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Ni, Ruiyu 
Subject: [Patch v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.

In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI, this is 
not necessary. This change combine these 2 INIT-SIPI-SIPI to 1 and add CpuPause 
between them.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 51 ---
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 9404501..ae4b516 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -39,6 +39,11 @@ typedef struct {
 //
 SPIN_LOCK*mMemoryMappedLock = NULL;
 
+//
+// Signal that SMM BASE relocation is complete.
+//
+volatile BOOLEAN mInitApsAfterSmmBaseReloc;
+
 /**
   Get starting address and size of the rendezvous entry for APs.
   Information for fixing a jump instruction in the code is also returned.
@@ -342,17 +347,21 @@ SetProcessorRegister (
   }
 }
 
+
+
 /**
-  AP initialization before SMBASE relocation in the S3 boot path.
+  AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
-EarlyMPRendezvousProcedure (
+MPRendezvousProcedure (
   VOID
   )
 {
   CPU_REGISTER_TABLE *RegisterTableList;
   UINT32 InitApicId;
   UINTN  Index;
+  UINTN  TopOfStack;
+  UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
@@ -368,25 +377,18 @@ EarlyMPRendezvousProcedure (
 }
   }
 
+
   //
   // Count down the number with lock mechanism.
   //
   InterlockedDecrement (); -}
 
-/**
-  AP initialization after SMBASE relocation in the S3 boot path.
-**/
-VOID
-MPRendezvousProcedure (
-  VOID
-  )
-{
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-  UINTN  TopOfStack;
-  UINT8  Stack[128];
+  //
+  // Wait for BSP to signal SMM Base relocation done.
+  //
+  while (!mInitApsAfterSmmBaseReloc) {
+CpuPause ();
+  }
 
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
@@ -500,7 +502,12 @@ EarlyInitializeCpu (
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) EarlyMPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+
+  //
+  // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
+  //
+  mInitApsAfterSmmBaseReloc = FALSE;
 
   //
   // Send INIT IPI - SIPI to all APs
@@ -538,17 +545,11 @@ InitializeCpu (
   }
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  //
-  // StackStart was updated when APs were waken up in EarlyInitializeCpu.
-  // Re-initialize StackAddress to original beginning address.
-  //
-  mExchangeInfo->StackStart  = (VOID *) (UINTN) mAcpiCpuData.StackAddress;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
 
   //
-  // Send INIT IPI - SIPI to all APs
+  // Signal that SMM base relocation is complete and to continue 
initialization.
   //
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+  mInitApsAfterSmmBaseReloc = TRUE;
 
   while (mNumberToFinish > 0) {
 CpuPause ();
--
2.7.0.windows.1

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


Re: [edk2] [Patch v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

-Original Message-
From: Dong, Eric 
Sent: Friday, September 29, 2017 8:27 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Ni, Ruiyu 
Subject: [Patch v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid 
duplicated code.

V2:
  Change function parameter to avoid touch global info in function.
  Enhance function name, make it more user friendly

V1:
  Refine code to avoid duplicate code to set processor register.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 84 +++
 1 file changed, 24 insertions(+), 60 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index ae4b516..ef72b9b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -208,18 +208,30 @@ Returns:
 
   This function programs registers for the calling processor.
 
-  @param  RegisterTable Pointer to register table of the running processor.
+  @param  RegisterTablesPointer to register table of the running 
processor.
+  @param  RegisterTableCountRegister table count.
 
 **/
 VOID
 SetProcessorRegister (
-  IN CPU_REGISTER_TABLE*RegisterTable
+  IN CPU_REGISTER_TABLE*RegisterTables,
+  IN UINTN RegisterTableCount
   )
 {
   CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
   UINTN Index;
   UINTN Value;
   SPIN_LOCK *MsrSpinLock;
+  UINT32InitApicId;
+  CPU_REGISTER_TABLE*RegisterTable;
+
+  InitApicId = GetInitialApicId ();
+  for (Index = 0; Index < RegisterTableCount; Index++) {
+if (RegisterTables[Index].InitialApicId == InitApicId) {
+  RegisterTable =  [Index];
+  break;
+}
+  }
 
   //
   // Traverse Register Table of this logical processor @@ -347,36 +359,20 @@ 
SetProcessorRegister (
   }
 }
 
-
-
 /**
   AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
-MPRendezvousProcedure (
+InitializeAp (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
   UINTN  TopOfStack;
   UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
-
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.PreSmmInitRegisterTable, mAcpiCpuData.NumberOfCpus);
 
   //
   // Count down the number with lock mechanism.
@@ -393,14 +389,7 @@ MPRendezvousProcedure (
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
 
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.RegisterTable, mAcpiCpuData.NumberOfCpus);
 
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
@@ -475,34 +464,20 @@ PrepareApStartupVector (
 
 **/
 VOID
-EarlyInitializeCpu (
+InitializeCpuBeforeRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.PreSmmInitRegisterTable, mAcpiCpuData.NumberOfCpus);
 
   ProgramVirtualWireMode ();
 
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) InitializeAp;
 
   //
   // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
@@ -527,22 +502,11 @@ EarlyInitializeCpu (
 
 **/
 VOID
-InitializeCpu (

Re: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Wu, Hao A
Mike,

Thanks for the feedbacks. I will refine the commit message and code
comments according to your suggestions.


Best Regards,
Hao Wu

> -Original Message-
> From: Kinney, Michael D
> Sent: Friday, September 29, 2017 12:49 AM
> To: Wu, Hao A; edk2-devel@lists.01.org; Kinney, Michael D
> Cc: Zeng, Star; Yao, Jiewen
> Subject: RE: [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT
> to check NULL ptr
> 
> Hao Wu,
> 
> The comment block clearly describes that the condition is not
> possible, so we would never expect this ASSERT() condition to
> ever be triggered.  Looking at the comment in this patch and
> the ASSERT() statement, a developer in the future may be tempted
> to remove this comment and ASSERT() thinking there is no impact.
> 
> The real reason the ASSERT() is added is because of a false
> positive report from static analysis.
> 
> Please add to the commit message and the comment block that
> this ASSERT() is added to address a false positive from
> static analysis, so it is clear that this ASSERT() should
> not be removed.
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: Wu, Hao A
> > Sent: Thursday, September 28, 2017 12:01 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Zeng, Star
> > ; Kinney, Michael D
> > ; Yao, Jiewen
> > 
> > Subject: [PATCH] MdeModulePkg/DxeCore: Add comments for the
> > ASSERT to check NULL ptr
> >
> > Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT
> > for
> > checking NULL pointer dereference.
> >
> > This commit adds comments to clarify the reason for using
> > ASSERT as the
> > check.
> >
> > Cc: Star Zeng 
> > Cc: Michael D Kinney 
> > Cc: Jiewen Yao 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > index 2db441725c..344ff1fe02 100644
> > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > @@ -1175,10 +1175,15 @@ Done:
> >  //
> >  if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED)
> > {
> >//
> > +  // According to above logic, if 'Prot' is NULL, then the
> > 'Status' must be
> > +  // EFI_UNSUPPORTED. Here the 'Status' is not
> > EFI_UNSUPPORTED, so 'Prot'
> > +  // must be not NULL.
> > +  //
> > +  ASSERT (Prot != NULL);
> > +  //
> >// EFI_ALREADY_STARTED is not an error for bus driver.
> >// Return the corresponding protocol interface.
> >//
> > -  ASSERT (Prot != NULL);
> >*Interface = Prot->Interface;
> >  } else if (Status == EFI_UNSUPPORTED) {
> >//
> > --
> > 2.12.0.windows.1

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


[edk2] [Patch v2 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Enhance S3 code.

2017-09-28 Thread Eric Dong
Combine INIT-SIPI-SIPI code and remove the duplicate code.

V2: Change patch 2 to includes:
  Change function parameter to avoid touch global info in function.
  Enhance function name, make it more user friendly

Eric Dong (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.
  UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 123 +-
 1 file changed, 43 insertions(+), 80 deletions(-)

-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH 1/2] ShellPkg/dh: Correct typo in help

2017-09-28 Thread Ni, Ruiyu
Yes I think so.

Thanks/Ray

> -Original Message-
> From: Carsey, Jaben
> Sent: Friday, September 29, 2017 2:30 AM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Subject: RE: [PATCH 1/2] ShellPkg/dh: Correct typo in help
> 
> Ray,
> 
> This text is taken directly from the shell spec.  Do we need to fix that also?
> 
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Thursday, September 28, 2017 10:21 AM
> > To: edk2-devel@lists.01.org
> > Cc: Carsey, Jaben 
> > Subject: [PATCH 1/2] ShellPkg/dh: Correct typo in help
> > Importance: High
> >
> > Help message of "dh" gives an example to display all handles with
> > "Image" protocol but actually "LoadedImage" protocol should be used.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Ruiyu Ni 
> > Cc: Jaben Carsey 
> > ---
> >  .../UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni   | 4
> > ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> > a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> > sLib.uni
> > b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> > dsLib.uni
> > index e4bff68838..3804fa7d28 100644
> > ---
> > a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> > sLib.uni
> > +++
> > b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> > dsLib.uni
> > @@ -401,9 +401,9 @@
> >  "  * To display all handles with 'diskio' protocol:\r\n"
> >  "Shell> dh -p diskio\r\n"
> >  " \r\n"
> > -"  * To display all handles with 'Image' protocol and break when the
> > screen is\r\n"
> > +"  * To display all handles with 'LoadedImage' protocol and break
> > +when the
> > screen is\r\n"
> >  "full:\r\n"
> > -"Shell> dh -p Image -b\r\n"
> > +"Shell> dh -p LoadedImage -b\r\n"
> >  ".SH RETURNVALUES\r\n"
> >  " \r\n"
> >  "RETURN VALUES:\r\n"
> > --
> > 2.12.2.windows.2

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


[edk2] [Patch v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Eric Dong
V2:
  Change function parameter to avoid touch global info in function.
  Enhance function name, make it more user friendly

V1:
  Refine code to avoid duplicate code to set processor register.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 84 +++
 1 file changed, 24 insertions(+), 60 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index ae4b516..ef72b9b 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -208,18 +208,30 @@ Returns:
 
   This function programs registers for the calling processor.
 
-  @param  RegisterTable Pointer to register table of the running processor.
+  @param  RegisterTablesPointer to register table of the running 
processor.
+  @param  RegisterTableCountRegister table count.
 
 **/
 VOID
 SetProcessorRegister (
-  IN CPU_REGISTER_TABLE*RegisterTable
+  IN CPU_REGISTER_TABLE*RegisterTables,
+  IN UINTN RegisterTableCount
   )
 {
   CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
   UINTN Index;
   UINTN Value;
   SPIN_LOCK *MsrSpinLock;
+  UINT32InitApicId;
+  CPU_REGISTER_TABLE*RegisterTable;
+
+  InitApicId = GetInitialApicId ();
+  for (Index = 0; Index < RegisterTableCount; Index++) {
+if (RegisterTables[Index].InitialApicId == InitApicId) {
+  RegisterTable =  [Index];
+  break;
+}
+  }
 
   //
   // Traverse Register Table of this logical processor
@@ -347,36 +359,20 @@ SetProcessorRegister (
   }
 }
 
-
-
 /**
   AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
-MPRendezvousProcedure (
+InitializeAp (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
   UINTN  TopOfStack;
   UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
-
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable, mAcpiCpuData.NumberOfCpus);
 
   //
   // Count down the number with lock mechanism.
@@ -393,14 +389,7 @@ MPRendezvousProcedure (
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
 
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable, mAcpiCpuData.NumberOfCpus);
 
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
@@ -475,34 +464,20 @@ PrepareApStartupVector (
 
 **/
 VOID
-EarlyInitializeCpu (
+InitializeCpuBeforeRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable, mAcpiCpuData.NumberOfCpus);
 
   ProgramVirtualWireMode ();
 
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) InitializeAp;
 
   //
   // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
@@ -527,22 +502,11 @@ EarlyInitializeCpu (
 
 **/
 VOID
-InitializeCpu (
+InitializeCpuAfterRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < 

[edk2] [Patch v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.

2017-09-28 Thread Eric Dong
In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI,
this is not necessary. This change combine these 2 INIT-SIPI-SIPI to 1
and add CpuPause between them.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 51 ---
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 9404501..ae4b516 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -39,6 +39,11 @@ typedef struct {
 //
 SPIN_LOCK*mMemoryMappedLock = NULL;
 
+//
+// Signal that SMM BASE relocation is complete.
+//
+volatile BOOLEAN mInitApsAfterSmmBaseReloc;
+
 /**
   Get starting address and size of the rendezvous entry for APs.
   Information for fixing a jump instruction in the code is also returned.
@@ -342,17 +347,21 @@ SetProcessorRegister (
   }
 }
 
+
+
 /**
-  AP initialization before SMBASE relocation in the S3 boot path.
+  AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
-EarlyMPRendezvousProcedure (
+MPRendezvousProcedure (
   VOID
   )
 {
   CPU_REGISTER_TABLE *RegisterTableList;
   UINT32 InitApicId;
   UINTN  Index;
+  UINTN  TopOfStack;
+  UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
@@ -368,25 +377,18 @@ EarlyMPRendezvousProcedure (
 }
   }
 
+
   //
   // Count down the number with lock mechanism.
   //
   InterlockedDecrement ();
-}
 
-/**
-  AP initialization after SMBASE relocation in the S3 boot path.
-**/
-VOID
-MPRendezvousProcedure (
-  VOID
-  )
-{
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-  UINTN  TopOfStack;
-  UINT8  Stack[128];
+  //
+  // Wait for BSP to signal SMM Base relocation done.
+  //
+  while (!mInitApsAfterSmmBaseReloc) {
+CpuPause ();
+  }
 
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
@@ -500,7 +502,12 @@ EarlyInitializeCpu (
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) EarlyMPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+
+  //
+  // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
+  //
+  mInitApsAfterSmmBaseReloc = FALSE;
 
   //
   // Send INIT IPI - SIPI to all APs
@@ -538,17 +545,11 @@ InitializeCpu (
   }
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  //
-  // StackStart was updated when APs were waken up in EarlyInitializeCpu.
-  // Re-initialize StackAddress to original beginning address.
-  //
-  mExchangeInfo->StackStart  = (VOID *) (UINTN) mAcpiCpuData.StackAddress;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
 
   //
-  // Send INIT IPI - SIPI to all APs
+  // Signal that SMM base relocation is complete and to continue 
initialization.
   //
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+  mInitApsAfterSmmBaseReloc = TRUE;
 
   while (mNumberToFinish > 0) {
 CpuPause ();
-- 
2.7.0.windows.1

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


[edk2] Enabling DEBUG() output in CorebootPayloadPkg

2017-09-28 Thread Mason M
Hi, I've been trying to enable output from DebugLib in CorebootPayloadPkg
to the serial port at I/O address 0x3F8, but can't seem to get any results.

I know the prints are being included in the build since I can see them in
the binary, and the hardware is also good since coreboot uses it just
fine.  I've made sure all of the DebugLib instances are pointed to
BaseDebugLibSerialPort under MdePkg, and SerialPortLib is pointed to
BaseSerialPortLib16550 under MdeModulePkg.  Is there something else I'm
missing?

Thanks,
Mason
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 1/2] ShellPkg/dh: Correct typo in help

2017-09-28 Thread Carsey, Jaben
Ray,

This text is taken directly from the shell spec.  Do we need to fix that also?

> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 10:21 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben 
> Subject: [PATCH 1/2] ShellPkg/dh: Correct typo in help
> Importance: High
> 
> Help message of "dh" gives an example to display all handles
> with "Image" protocol but actually "LoadedImage" protocol should
> be used.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Jaben Carsey 
> ---
>  .../UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni   | 4
> ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> index e4bff68838..3804fa7d28 100644
> ---
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> +++
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> @@ -401,9 +401,9 @@
>  "  * To display all handles with 'diskio' protocol:\r\n"
>  "Shell> dh -p diskio\r\n"
>  " \r\n"
> -"  * To display all handles with 'Image' protocol and break when the screen
> is\r\n"
> +"  * To display all handles with 'LoadedImage' protocol and break when the
> screen is\r\n"
>  "full:\r\n"
> -"Shell> dh -p Image -b\r\n"
> +"Shell> dh -p LoadedImage -b\r\n"
>  ".SH RETURNVALUES\r\n"
>  " \r\n"
>  "RETURN VALUES:\r\n"
> --
> 2.12.2.windows.2

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


Re: [edk2] [PATCH 0/2] Correct typo in command help

2017-09-28 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Thursday, September 28, 2017 10:21 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH 0/2] Correct typo in command help
> Importance: High
> 
> Ruiyu Ni (2):
>   ShellPkg/dh: Correct typo in help
>   ShellPkg/disconnect: '-r' is not optional when disconnecting all
> 
>  .../UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni | 6
> +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> --
> 2.12.2.windows.2
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [ipxe-devel] Tips on how to debug EFI code (iPXE) from within KVM after ipxe.efi has crashed with #GP?

2017-09-28 Thread Laszlo Ersek
On 09/28/17 20:04, Michael Brown wrote:
> On 28/09/17 18:37, Konrad Rzeszutek Wilk wrote:
>> !!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID -
>>  
>> ExceptionData - 
>> RIP  - BEC2949C, CS  - 0038, RFLAGS -
>> 00210216
>> 
>>  Find image 808610ed.efidrv (ImageBase=BEC27000,
>> EntryPoint=BEC2E089) 
>>
>> And now I am trying to figure out how to troubleshoot this.
>> (and yes I am thinking it was related to the Tivoli work-around, but
>> disabling that didn't help).
> 
> The Tivoli workaround is for legacy BIOS only; it doesn't apply to the
> UEFI build of iPXE.
> 
> You have the RIP and ImageBase, so you know that the exception happens
> at offset +0x249c within your iPXE binary.  You can use this in
> conjunction with the corresponding map file from the iPXE build (which
> will probably be named bin-x86_64-efi/808610d3.efidrv.tmp.map, but see
> below) to figure out exactly where the crash is occurring.

Or run "objdump -S 808610d3.efidrv.tmp", and look up the offset in the
output. (First, check if (EntryPoint - ImageBase), i.e., 0x7089, equals
"start address" in the "objdump -x" output.)

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


Re: [edk2] [ipxe-devel] Tips on how to debug EFI code (iPXE) from within KVM after ipxe.efi has crashed with #GP?

2017-09-28 Thread Michael Brown

On 28/09/17 18:37, Konrad Rzeszutek Wilk wrote:

!!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID -
 
ExceptionData - 
RIP  - BEC2949C, CS  - 0038, RFLAGS - 00210216

> 

 Find image 808610ed.efidrv (ImageBase=BEC27000,
EntryPoint=BEC2E089) 

And now I am trying to figure out how to troubleshoot this.
(and yes I am thinking it was related to the Tivoli work-around, but
disabling that didn't help).


The Tivoli workaround is for legacy BIOS only; it doesn't apply to the 
UEFI build of iPXE.


You have the RIP and ImageBase, so you know that the exception happens 
at offset +0x249c within your iPXE binary.  You can use this in 
conjunction with the corresponding map file from the iPXE build (which 
will probably be named bin-x86_64-efi/808610d3.efidrv.tmp.map, but see 
below) to figure out exactly where the crash is occurring.



#crash ipxe/src/bin/ipxe.lkrn.tmp ./guest-memory


That's a completely different iPXE binary from the one you are using.


- The 80810ed.efidrv is built using:

(cd ipxe/src;make bin-x86_64-efi/808610d3.efi  CONFIG=qemu
DEBUG=iscsi:4,scsi:4 EMBED=/ipxe.config -j8)
if [ $? -ne 0 ]; then exit 1; fi
(cd ipxe/src;EfiRom -f 0x8086 -i 0x1528 --pci23 -ec
bin-x86_64-efi/808610d3.efidrv -o ../../808610d3.rom)
if [ $? -ne 0 ]; then exit 1; fi


You can build this much more simply in a single command:

  make bin-x86_64-efi/808610d3.efirom EMBED=/ipxe.config

Also note that:

- debug levels in iPXE are bitmasks, so DEBUG=:4 generally doesn't 
make much sense.  You probably want DEBUG=iscsi,scsi for minimal debug 
(i.e. detailed error messages for any problems), or DEBUG=iscsi:3,scsi:3 
for much more verbose logging.  That said, you don't seem to be using 
iSCSI anyway, so .?


- In your build chain (using EfiRom) I think you have a typo: you build 
the EFI _application_ bin-x86_64-efi/808610d3.efi but then use the EFI 
_driver_ bin-x86_64-efi/808610d3.efidrv, which you have not explicitly 
built.  Your final binary may therefore not match what you think you 
have just built.  You should probably not worry about any of this, and 
just use the single-command build given above instead.


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


[edk2] Tips on how to debug EFI code (iPXE) from within KVM after ipxe.efi has crashed with #GP?

2017-09-28 Thread Konrad Rzeszutek Wilk
Hey,

I am hitting an interesting issue with the latest versions of iPXE,
edk2, and GRUB wherein I am trying to boot GRUB (via iPXE), and then
load Xen, I get this:

!!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID -
 
ExceptionData - 
RIP  - BEC2949C, CS  - 0038, RFLAGS - 00210216
RAX  - , RCX - BFA2DC18, RDX - 
RBX  - BFA2DC60, RSP - BFEDDFD8, RBP - 0008
RSI  - , RDI - 0001
R8   - 0001, R9  - 0030, R10 - 0009E000
R11  - BFF1A000, R12 - BFEF7260, R13 - BFA2DC18
R14  - BF40BD18, R15 - BEB4E8A4
DS   - 0030, ES  - 0030, FS  - 0030
GS   - 0030, SS  - 0030
CR0  - 80010033, CR2 - , CR3 - BFE7D000
CR4  - 0668, CR8 - 
DR0  - , DR1 - , DR2 - 
DR3  - , DR6 - 0FF0, DR7 - 0400
GDTR - BFE6B698 0047, LDTR - 
IDTR - BF620018 0FFF,   TR - 
FXSAVE_STATE - BFEDDC30
 Find image 808610ed.efidrv (ImageBase=BEC27000,
EntryPoint=BEC2E089) 


And now I am trying to figure out how to troubleshoot this.
(and yes I am thinking it was related to the Tivoli work-around, but
disabling that didn't help).

I was somehow hoping I could use 'crash' tool and run it with with the guest
memory and the iPXE code:

#crash ipxe/src/bin/ipxe.lkrn.tmp ./guest-memory
..

WARNING: machine type mismatch:
 crash utility: X86_64
 ipxe/src/bin/ipxe.lkrn.tmp: X86

crash: ipxe/src/bin/ipxe.lkrn.tmp: not a supported file format
..



So how do folks troubleshoot things like this?




A bit background information:

- The /guest-memory I got by having an -qmp argument and telneting in
it and doing:

{"execute":"dump-guest-memory","arguments":{"paging":
false,"protocol":"file:/guest-memory"}}

- The 80810ed.efidrv is built using:

(cd ipxe/src;make bin-x86_64-efi/808610d3.efi  CONFIG=qemu
DEBUG=iscsi:4,scsi:4 EMBED=/ipxe.config -j8)
if [ $? -ne 0 ]; then exit 1; fi
(cd ipxe/src;EfiRom -f 0x8086 -i 0x1528 --pci23 -ec
bin-x86_64-efi/808610d3.efidrv -o ../../808610d3.rom)
if [ $? -ne 0 ]; then exit 1; fi

The ipxe script is simple:

!ipxe

dhcp && echo * DHCP worked || goto dhcp_retry
echo * IP address: ${net0/ip} ; echo * Subnet mask: ${net0/netmask}
ifstat
set url http://10.0.1.2/
echo ${url}
imgfetch ${url}/grub.efi
imgstat
boot grub.efi


- And grub.efi was created with this:

GRUB_MODULES="boot chain configfile echo efinet eval ext2 fat font
gettext gfxterm gzio help linux loadenv lsefi normal part_gpt par
t_msdos read regexp search search_fs_file search_fs_uuid search_label
terminal terminfo test tftp time multiboot multiboot2 net slee
p efifwsetup  lsefisystab lspci lsefi lsacpi lsefimmap acpi fat eval
elf file linux linux16 pcidump http serial efi_gop"

grub-install/usr/bin/grub-mkimage \
--config ${GRUB_CFG} \
--directory=`pwd`/grub-install/usr/lib64/grub/x86_64-efi \
--output=grub.efi \
--format=x86_64-efi \
--prefix "(http)/" \
$GRUB_MODULES

# more grub.config
set timeout=5

net_bootp
net_ls_addr
net_ls_cards
net_ls_routes
lspci
set net_default_server=10.0.1.2
serial --speed=115200 --unit=0 --word=8
terminal_output  serial console
terminal_input  serial console
multiboot2 (http,10.0.1.2)/xen.gz dom0_mem=max:1G loglvl=all
guest_loglvl=all console=com1 com1=115200,8n1
module2 (http,10.0.1.2)/vmlinuz console=hvc0 debug initcall_debug
module2 (http,10.0.1.2)/initrd.img
boot
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH 2/2] ShellPkg/disconnect: '-r' is not optional when disconnecting all

2017-09-28 Thread Ruiyu Ni
Correct the help message to match that defined in Shell spec.
In 'DISCONNECT -r [-nc]' case, '-r' is not optional.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 .../Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni 
b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index 3804fa7d28..0120e4e065 100644
--- 
a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
@@ -308,7 +308,7 @@
 ".SH SYNOPSIS\r\n"
 " \r\n"
 "DISCONNECT DeviceHandle [DriverHandle [ChildHandle]] \r\n"
-"DISCONNECT [-r] [-nc] \r\n"
+"DISCONNECT -r [-nc] \r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
 "NOTES:\r\n"
-- 
2.12.2.windows.2

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


[edk2] [PATCH 1/2] ShellPkg/dh: Correct typo in help

2017-09-28 Thread Ruiyu Ni
Help message of "dh" gives an example to display all handles
with "Image" protocol but actually "LoadedImage" protocol should
be used.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 .../UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni 
b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index e4bff68838..3804fa7d28 100644
--- 
a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ 
b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
@@ -401,9 +401,9 @@
 "  * To display all handles with 'diskio' protocol:\r\n"
 "Shell> dh -p diskio\r\n"
 " \r\n"
-"  * To display all handles with 'Image' protocol and break when the screen 
is\r\n"
+"  * To display all handles with 'LoadedImage' protocol and break when the 
screen is\r\n"
 "full:\r\n"
-"Shell> dh -p Image -b\r\n"
+"Shell> dh -p LoadedImage -b\r\n"
 ".SH RETURNVALUES\r\n"
 " \r\n"
 "RETURN VALUES:\r\n"
-- 
2.12.2.windows.2

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


[edk2] [PATCH 0/2] Correct typo in command help

2017-09-28 Thread Ruiyu Ni
Ruiyu Ni (2):
  ShellPkg/dh: Correct typo in help
  ShellPkg/disconnect: '-r' is not optional when disconnecting all

 .../UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.12.2.windows.2

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


Re: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Kinney, Michael D
Hao Wu,

The comment block clearly describes that the condition is not
possible, so we would never expect this ASSERT() condition to
ever be triggered.  Looking at the comment in this patch and
the ASSERT() statement, a developer in the future may be tempted
to remove this comment and ASSERT() thinking there is no impact.

The real reason the ASSERT() is added is because of a false
positive report from static analysis.

Please add to the commit message and the comment block that
this ASSERT() is added to address a false positive from
static analysis, so it is clear that this ASSERT() should
not be removed.

Thanks,

Mike

> -Original Message-
> From: Wu, Hao A
> Sent: Thursday, September 28, 2017 12:01 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Zeng, Star
> ; Kinney, Michael D
> ; Yao, Jiewen
> 
> Subject: [PATCH] MdeModulePkg/DxeCore: Add comments for the
> ASSERT to check NULL ptr
> 
> Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT
> for
> checking NULL pointer dereference.
> 
> This commit adds comments to clarify the reason for using
> ASSERT as the
> check.
> 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> index 2db441725c..344ff1fe02 100644
> --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> @@ -1175,10 +1175,15 @@ Done:
>  //
>  if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED)
> {
>//
> +  // According to above logic, if 'Prot' is NULL, then the
> 'Status' must be
> +  // EFI_UNSUPPORTED. Here the 'Status' is not
> EFI_UNSUPPORTED, so 'Prot'
> +  // must be not NULL.
> +  //
> +  ASSERT (Prot != NULL);
> +  //
>// EFI_ALREADY_STARTED is not an error for bus driver.
>// Return the corresponding protocol interface.
>//
> -  ASSERT (Prot != NULL);
>*Interface = Prot->Interface;
>  } else if (Status == EFI_UNSUPPORTED) {
>//
> --
> 2.12.0.windows.1

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


Re: [edk2] [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol

2017-09-28 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 1:50 AM
> To: Wu, Hao A ; edk2-devel@lists.01.org
> Cc: Carsey, Jaben 
> Subject: RE: [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition
> Info protocol
> Importance: High
> 
> Reviewed-by: Ruiyu Ni 
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: Wu, Hao A
> > Sent: Thursday, September 28, 2017 4:33 PM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A ; Ni, Ruiyu ;
> Carsey,
> > Jaben 
> > Subject: [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition
> Info
> > protocol
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655
> >
> > V2 change:
> > Put some strings into the UNI file for localization.
> >
> > The dump information will include:
> > a. The type of the partition (Mbr, Gpt or Other); b. Whether the partition 
> > is
> an
> > EFI System Partition.
> >
> > Cc: Ruiyu Ni 
> > Cc: Jaben Carsey 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Hao Wu 
> > ---
> >  .../UefiHandleParsingLib/UefiHandleParsingLib.c| 86
> > ++
> >  .../UefiHandleParsingLib/UefiHandleParsingLib.h|  1 +
> >  .../UefiHandleParsingLib/UefiHandleParsingLib.inf  |  1
> > +  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |  9 +++
> >  4 files changed, 97 insertions(+)
> >
> > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> > b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> > index d12466c7b0..a228226623 100644
> > --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> > +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> > @@ -1933,6 +1933,87 @@ ERROR_EXIT:
> >return NULL;
> >  }
> >
> > +/**
> > +  Function to dump information about Partition Information protocol.
> > +
> > +  This will allocate the return buffer from boot services pool.
> > +
> > +  @param[in] TheHandle  The handle that has the protocol installed.
> > +  @param[in] VerboseTRUE for additional information, FALSE
> otherwise.
> > +
> > +  @retval A pointer to a string containing the information.
> > +**/
> > +CHAR16*
> > +EFIAPI
> > +PartitionInfoProtocolDumpInformation (
> > +  IN CONST EFI_HANDLE TheHandle,
> > +  IN CONST BOOLEANVerbose
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  EFI_PARTITION_INFO_PROTOCOL *PartitionInfo;
> > +  CHAR16  *PartitionType;
> > +  CHAR16  *EfiSystemPartition;
> > +  CHAR16  *RetVal;
> > +
> > +  if (!Verbose) {
> > +return NULL;
> > +  }
> > +
> > +  Status = gBS->OpenProtocol (
> > +TheHandle,
> > +,
> > +(VOID**),
> > +gImageHandle,
> > +NULL,
> > +EFI_OPEN_PROTOCOL_GET_PROTOCOL
> > +);
> > +  if (EFI_ERROR (Status)) {
> > +return NULL;
> > +  }
> > +
> > +  HandleParsingHiiInit ();
> > +
> > +  switch (PartitionInfo->Type) {
> > +  case PARTITION_TYPE_OTHER:
> > +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> > STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);
> > +break;
> > +  case PARTITION_TYPE_MBR:
> > +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> > STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);
> > +break;
> > +  case PARTITION_TYPE_GPT:
> > +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> > STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);
> > +break;
> > +  default:
> > +PartitionType = NULL;
> > +break;
> > +  }
> > +  if (PartitionType == NULL) {
> > +return NULL;
> > +  }
> > +
> > +  if (PartitionInfo->System == 1) {
> > +EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle,
> > + STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);  } else {
> > +EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle,
> > + STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);  }
> if
> > + (EfiSystemPartition == NULL) {
> > +SHELL_FREE_NON_NULL (PartitionType);
> > +return NULL;
> > +  }
> > +
> > +  RetVal = CatSPrint (
> > + NULL,
> > + L"%s\r\n%s",
> > + PartitionType,
> > + EfiSystemPartition
> > + );
> > +
> > +  SHELL_FREE_NON_NULL (EfiSystemPartition);
> > +  SHELL_FREE_NON_NULL (PartitionType);
> > +  return RetVal;
> > +}
> > +
> >  //
> >  // Put the information on the NT32 protocol GUIDs here so we are not
> > dependant on the Nt32Pkg  // @@ -2147,6 +2228,11 @@ STATIC CONST
> > GUID_INFO_BLOCK mGuidStringList[] = {
> >{STRING_TOKEN(STR_ADAPTER_INFO),
> > ,
> > AdapterInformationDumpInformation},
> >
> >  //
> > +// UEFI 2.7

Re: [edk2] Clarification about InitializeCpuExceptionHandlers() and TGE bit in hcr_el2

2017-09-28 Thread Andrew Fish

> On Sep 28, 2017, at 4:23 AM, Vabhav Sharma  wrote:
> 
> Hi All,
> 
> I see that InitializeCpuExceptionHandlers() is called from DxeMain to take 
> over exception handlers and later from ArmCpuDxe.
> Is there any specific purpose to call it from two places during dxe phase?
> 

Vabhav,

DxeMain is the DXE Core and that is like (micro) kernel and it is platform 
agnostic code. InitializeCpuExceptionHandlers() exists in that location to 
catch unhandled exceptions, especially in the case when no debugger stub is 
linked in. The CPU Dxe driver abstracts CPU specifics from the DXE Core and it 
adds supports for interrupts, cachability, etc. and the DXE Core uses services 
from this driver to abstract CPU implementation.

To make things even more complex on some platforms PEI and DXE run in entirely 
different modes. For example on x86 is is common for PEI to be 32-bit and and 
DXE to be 64-bit. This is mostly due to how complex it is to turn on memory, 
and the fact that there is no good place to put the page tables prior to memory 
init. 

I'll let the ARM folks comment on hcr_el2 usage. 

Thanks,

Andrew Fish 

> Additionally we are setting TGE bit three times in hcr_el2 during PrePei 
> phase(ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c)
> and Twice in Dxe phase: dxemain(),ArmCpuDxe
> 
> Please help to clarify or required to be fixed?
> 
> Regards,
> Vabhav
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

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


Re: [edk2] [PATCH 2/2] ShellPkg/UefiHandleParsingLib.c: Map SmmPciRootBridgeIo correctly

2017-09-28 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Ni, Ruiyu
> Sent: Wednesday, September 27, 2017 11:37 PM
> To: edk2-devel@lists.01.org
> Cc: Li, Huajing ; Carsey, Jaben
> 
> Subject: [PATCH 2/2] ShellPkg/UefiHandleParsingLib.c: Map
> SmmPciRootBridgeIo correctly
> Importance: High
> 
> From: Huajing Li 
> 
> The current implementation has a typo that maps SmmPciRootBridgeIo
> to "PciRootBridgeIo".
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Huajing Li 
> Reviewed-by: Ruiyu Ni 
> Cc: Jaben Carsey 
> ---
>  ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> index 06f9d26e5f..489decfaf8 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> @@ -2229,7 +2229,7 @@ STATIC CONST GUID_INFO_BLOCK
> mGuidStringList[] = {
>{STRING_TOKEN(STR_S_COMM),
> ,NULL},
>{STRING_TOKEN(STR_S_STAT),,
> NULL},
>{STRING_TOKEN(STR_S_CPU), ,
> NULL},
> -  {STRING_TOKEN(STR_S_PCIRBIO),
> , NULL},
> +  {STRING_TOKEN(STR_S_PCIRBIO),
> ,  NULL},
>{STRING_TOKEN(STR_S_SWD),
> ,  NULL},
>{STRING_TOKEN(STR_S_SXD), ,
> NULL},
>{STRING_TOKEN(STR_S_PTD2),
> ,   NULL},
> --
> 2.12.2.windows.2

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


Re: [edk2] [PATCH 1/2] ShellPkg/dh: Add mapping of new UEFI/PI protocols

2017-09-28 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Ni, Ruiyu
> Sent: Wednesday, September 27, 2017 11:37 PM
> To: edk2-devel@lists.01.org
> Cc: Li, Huajing ; Carsey, Jaben
> 
> Subject: [PATCH 1/2] ShellPkg/dh: Add mapping of new UEFI/PI protocols
> Importance: High
> 
> From: Huajing Li 
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Huajing Li 
> Reviewed-by: Ruiyu Ni 
> Cc: Jaben Carsey 
> ---
>  .../UefiHandleParsingLib/UefiHandleParsingLib.c| 56
> ++
>  .../UefiHandleParsingLib/UefiHandleParsingLib.inf  | 40 
>  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  | 44
> +
>  3 files changed, 140 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> index d12466c7b0..06f9d26e5f 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> @@ -2147,6 +2147,37 @@ STATIC CONST GUID_INFO_BLOCK
> mGuidStringList[] = {
>{STRING_TOKEN(STR_ADAPTER_INFO),
> ,
> AdapterInformationDumpInformation},
> 
>  //
> +// UEFI2.5
> +//
> +  {STRING_TOKEN(STR_TLS_SB),
> ,  NULL},
> +  {STRING_TOKEN(STR_TLS),   ,
> NULL},
> +  {STRING_TOKEN(STR_TLS_CONFIG),
> ,   NULL},
> +  {STRING_TOKEN(STR_SUPPLICANT_SB),
> ,   NULL},
> +  {STRING_TOKEN(STR_SUPPLICANT),,
> NULL},
> +
> +//
> +// UEFI2.6
> +//
> +  {STRING_TOKEN(STR_WIFI2), ,
> NULL},
> +  {STRING_TOKEN(STR_RAMDISK),   ,
> NULL},
> +  {STRING_TOKEN(STR_HII_ID),,
> NULL},
> +  {STRING_TOKEN(STR_HII_IE),,
> NULL},
> +  {STRING_TOKEN(STR_SD_MPT),
> ,  NULL},
> +  {STRING_TOKEN(STR_ERASE_BLOCK),   ,
> NULL},
> +
> +//
> +// UEFI2.7
> +//
> +  {STRING_TOKEN(STR_BLUETOOTH_ATTR),
> ,   NULL},
> +  {STRING_TOKEN(STR_BLUETOOTH_ATTR_SB),
> , NULL},
> +  {STRING_TOKEN(STR_BLUETOOTH_LE_CONFIG),
> ,NULL},
> +  {STRING_TOKEN(STR_UFS_DEV_CONFIG),
> ,  NULL},
> +  {STRING_TOKEN(STR_HTTP_BOOT_CALL),
> , NULL},
> +  {STRING_TOKEN(STR_RESET_NOTI),
> ,NULL},
> +  {STRING_TOKEN(STR_PARTITION_INFO),
> ,NULL},
> +  {STRING_TOKEN(STR_HII_POPUP), ,
> NULL},
> +
> +//
>  // PI Spec ones
>  //
>{STRING_TOKEN(STR_IDE_CONT_INIT),
> ,   NULL},
> @@ -2271,6 +2302,31 @@ STATIC CONST GUID_INFO_BLOCK
> mGuidStringList[] = {
>{STRING_TOKEN(STR_REST),  ,
> NULL},
> 
>  //
> +// PI 1.5
> +//
> +  {STRING_TOKEN(STR_MM_EOD),,
> NULL},
> +  {STRING_TOKEN(STR_MM_ITD),
> ,NULL},
> +  {STRING_TOKEN(STR_MM_PBD),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_SBD),
> , NULL},
> +  {STRING_TOKEN(STR_MM_GD),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_UD),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_PTD),
> , NULL},
> +  {STRING_TOKEN(STR_MM_SXD),
> ,NULL},
> +  {STRING_TOKEN(STR_MM_SWD),
> ,NULL},
> +  {STRING_TOKEN(STR_MM_PRBI),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_CPU),,
> NULL},
> +  {STRING_TOKEN(STR_MM_STACODE),
> ,NULL},
> +  {STRING_TOKEN(STR_DXEMM_RTL),
> ,NULL},
> +  {STRING_TOKEN(STR_MM_CONFIG),
> , NULL},
> +  {STRING_TOKEN(STR_MM_RTL),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_CONTROL),
> ,   NULL},
> +  {STRING_TOKEN(STR_MM_ACCESS), ,
> NULL},
> +  {STRING_TOKEN(STR_MM_BASE),   ,
> NULL},
> +  {STRING_TOKEN(STR_MM_CPUIO),  ,
> NULL},
> +  {STRING_TOKEN(STR_MM_RH), ,
> NULL},
> +  {STRING_TOKEN(STR_MM_COM),
> , NULL},
> +
> +//
>  // UEFI Shell Spec 2.0
>  //
>{STRING_TOKEN(STR_SHELL_PARAMETERS),
> , NULL},
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> index 4c1c3d3846..1ab208e328 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
> @@ -292,6 +292,46 @@ [Protocols]
>gEfiHttpProtocolGuid## UNDEFINED
>gEfiHttpUtilitiesProtocolGuid   ## UNDEFINED
>gEfiRestProtocolGuid## UNDEFINED
> +  gEfiMmEndOfDxeProtocolGuid  ## UNDEFINED
> +  gEfiMmIoTrapDispatchProtocolGuid## UNDEFINED
> +  gEfiMmPowerButtonDispatchProtocolGuid   

Re: [edk2] [patch] ShellPkg/Dh: Refine variable naming style

2017-09-28 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Ni, Ruiyu
> Sent: Wednesday, September 27, 2017 10:57 PM
> To: Bi, Dandan ; edk2-devel@lists.01.org
> Cc: Carsey, Jaben 
> Subject: RE: [patch] ShellPkg/Dh: Refine variable naming style
> Importance: High
> 
> Reviewed-by: Ruiyu Ni 
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: Bi, Dandan
> > Sent: Thursday, September 28, 2017 10:45 AM
> > To: edk2-devel@lists.01.org
> > Cc: Ni, Ruiyu ; Carsey, Jaben
> 
> > Subject: [patch] ShellPkg/Dh: Refine variable naming style
> >
> > Avoid using only lower-case characters for variable name.
> >
> > Cc: Ruiyu Ni 
> > Cc: Jaben Carsey 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Dandan Bi 
> > ---
> >  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > index 7d06163..a7bd251 100644
> > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > @@ -284,11 +284,11 @@ GetProtocolInfoString(
> >EFI_STATUSStatus;
> >CHAR16*RetVal;
> >UINTN Size;
> >CHAR16*Temp;
> >CHAR16GuidStr[40];
> > -  VOID  *instance;
> > +  VOID  *Instance;
> >CHAR16InstanceStr[17];
> >
> >ProtocolGuidArray = NULL;
> >RetVal= NULL;
> >Size  = 0;
> > @@ -314,14 +314,14 @@ GetProtocolInfoString(
> >  FreePool(Temp);
> >}
> >StrnCatGrow(, , L"%N", 0);
> >
> >if(Verbose) {
> > -Status = gBS->HandleProtocol (TheHandle,
> > ProtocolGuidArray[ProtocolIndex], );
> > +Status = gBS->HandleProtocol (TheHandle,
> > ProtocolGuidArray[ProtocolIndex], );
> >  if (!EFI_ERROR (Status)) {
> >StrnCatGrow (, , L"(%H", 0);
> > -  UnicodeSPrint (InstanceStr, sizeof (InstanceStr), L"%x", 
> > instance);
> > +  UnicodeSPrint (InstanceStr, sizeof (InstanceStr), L"%x", 
> > Instance);
> >StrnCatGrow (, , InstanceStr, 0);
> >StrnCatGrow (, , L"%N)", 0);
> >  }
> >}
> >
> > --
> > 1.9.5.msysgit.1

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


[edk2] multiple levels of support for MOR / MORLock

2017-09-28 Thread Laszlo Ersek
Hi Jiewen,

my colleague Ladi (CC'd) reported an issue about MORLock in OVMF (and
also analyzed it in great depth):

  https://bugzilla.redhat.com/show_bug.cgi?id=1496170

Here's my understanding of the "MemoryOverwriteRequestControl" and
"MemoryOverwriteRequestControlLock" variables:

(1) The "MemoryOverwriteRequestControl" variable comes from the "TCG
Platform Reset Attack Mitigation Specification" at

.

(2) The "MemoryOverwriteRequestControlLock" variable is a Microsoft-only
addition, called "Secure MOR implementation", from

.

(3) "winload.efi" accepts the following cases as "valid":

(3a) Both MORC and MORCL are present. In this case MORC is set and MORCL
 is used to lock both MORC and MORCL.

(3b) MORC is present, MORCL is absent. In this case "winload.efi" thinks
 that the platform follows the TCG spec from (1), and does not
 support the Microsoft spec from (2). MORC is set, but it is not
 locked.

(3c) Both MORC and MORCL are missing. "winload.efi" thinks that the
 platform does not know about either spec, and "winload.efi" accepts
 that as OK.

However "winload.efi"rejects the following case as "invalid":

(3d) MORCL is present, but MORC is missing. In my opinion, "winload.efi"
 is right to reject this, because it implies that the platform
 supports the *dependent* spec (2), but does not support the
 *prerequisite* spec (1).


In edk2, MORC is implemented by the
"SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf" driver. A platform
is allowed *not* to include this driver, even if it supports SMM.

OVMF is such a platform; it does not include "TcgMor.inf".

However, MORCL is initialized in the variable driver, independently of
platform support for MORC:

* If the platform includes the SMM driver backend, then we have:

  VariableWriteServiceInitialize() 
[MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c]
MorLockInit()  
[MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c]
  SetMorLockVariable() 
[MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c]
//
// create or set variable
// with contents 0
//

* If the platform includes no SMM backend for the variable services,
  then we have:

  VariableWriteServiceInitialize() 
[MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c]
MorLockInit()  
[MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockDxe.c]
  //
  // delete the variable and
  // also lock it so that
  // nothing else can
  // create it
  //

In my opinion, if the platform includes the SMM backend, but does not
support "MORC", then the "TcgMorLockSmm.c" code is incorrect; instead we
should do what we see in "TcgMorLockDxe.c".

In other words, SMM support in itself is no indication for claiming
support for MORCL.


I suggest that we introduce a new PCD for this
("PcdSupportMemoryOverwriteRequest"), in "SecurityPkg.dec", with type
UINT8. It should be a bitmap:

- BIT0 -- If clear, then MORC is not supported, and BIT1 is ignored.
  Otherwise, MORC is supported, and BIT1 is meaningful.

- BIT1 -- If clear, then MORCL is unsupported. If set, then MORCL is
  supported.

- BIT2 through BIT7 are reserved.


In turn, here's how the new PCD should be handled, in my opinion:

- MorLockInit() in "TcgMorLockDxe.c" should do what it does now, but it
  should also assert that BIT1 is clear.

- MorLockInit() in "TcgMorLockSmm.c" should do what it does now *only*
  if BIT1 is set. Otherwise (i.e., BIT1 is clear), it should do what
  "TcgMorLockDxe.c" does now.

- If BIT0 is clear (MORC is not supported), then both MorLockInit()
  functions should delete, and lock, the MORC variable too, so that
  nothing else can create it.

What do you think?

Thank you!
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Laszlo Ersek
On 09/28/17 14:06, Laszlo Ersek wrote:

> So, how can I invalidate all the cached values? Is it enough to delete
> the *.hash files?

... I'm asking because I tried the --binary-destination option as well,
and in the bin cache directory, *.depex and *.inf files were stored as
well, not just *.hash values.

So I figure, whatever gets stored in the binary cache directory, should
be deleted when I'd like to invalidate the cache.

Now, removing this separate cache directory altogether would solve my
question; but that would require me to use "--binary-destination" and
"--binary-source" together. The idea is that "--hash" would fetch the
hash values from that separate directory, and it would also write the
new hash values back to that directory. In addition this directory would
be very easy to remove, so "--hash" would know whenever the hash was empty.

However, it looks like "--binary-destination" and "--binary-source"
cannot be used together. Why is that?

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Laszlo Ersek
On 09/19/17 08:48, Yonghong Zhu wrote:
> V2:
> change the option name to --binary-destination and --binary-source.
> 
> fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=689
> Cc: Liming Gao 
> Cc: Michael Kinney 
> Cc: Kevin W Shaw 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu 
> ---
>  .../82_auto-generation_process.md| 20 
> 
>  README.md|  1 +
>  appendix_d_buildexe_command/d4_usage.md  | 19 +++
>  3 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md 
> b/8_pre-build_autogen_stage/82_auto-generation_process.md
> index 671a7d5..f2ddf32 100644
> --- a/8_pre-build_autogen_stage/82_auto-generation_process.md
> +++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
> @@ -1031,10 +1031,30 @@ maximum command line length.  The default value is 
> 4096.
>  **Note:** The following `FLAGS` options are included in the response file:
>  `PP_FLAGS`, `CC_FLAGS`, `VFRPP_FLAGS`, `APP_FLAGS`, `ASLPP_FLAGS`, 
> `ASLCC_FLAGS`,
>  and `ASM_FLAGS`.
>  **
>  
> + 8.2.4.15 Build with Binary Cache
> +
> +**build** tool provides three new options for binary cache feature.
> +--hash enables hash-based caching during build process. when --hash is 
> enabled,
> +build tool will base on the module hash value to do the incremental build, 
> without
> +--hash, build tool will base on the timestamp to do the incremental build. 
> --hash
> +option use md5 method to get every hash value, DSC/FDF, tools_def.txt, 
> build_rule.txt
> +and build command are calculated as global hash value, Package DEC and its 
> include
> +header files are calculated as package hash value, Module source files and 
> its INF
> +file are calculated as module hash value. Library hash value will combine 
> the global
> +hash value and its dependent package hash value. Driver hash value will 
> combine the
> +global hash value, its dependent package hash value and its linked library 
> hash value.
> +When --hash and --binary-destination are specified, build tool will copy the 
> generated
> +binary files for each module into the directory specified by 
> binary-destination at the
> +build phase. Binary-destination directory caches all the generated binary 
> files.
> +When --hash and --binary-source are specified, build tool will try to get 
> the binary
> +files from the binary source directory at the build phase. If the cached 
> binary has
> +the same hash value, it will be directly used. Otherwise, build tool will 
> compile the
> +source files and generate the binary files.
> +

I have another question about this feature: how can I invalidate the
binary cache, so that the next invocation with "--hash" fall back to the
timestamp-based incremental build?

Is it enough if I remove all "*.hash" files from the Build tree?

This question is relevant for bisection. Assume that we are bisecting a
commit range that straddles the introduction of "--hash" to BaseTools,
and that we use a build script that uses "--hash" whenever it is available.

Consider the following build order:

(1) Build the tree with "--hash" (because "--hash" is available at the
commit that we're testing). Assume this build displays the symptom we
are bisecting, so we enter "git bisect bad", and git checks out an
earlier commit.

(2) Assume BaseTools lacks "--hash" at this earlier commit, so we build
the tree without "--hash". Using the timestamp checks, the modules
changed or affected by the checkout done by git-bisect in step (1) will
be rebuilt correctly. We test this build and find that it works okay, so
we enter "git bisect good". Git checks out a later commit (such that it
is earlier than the one tested in (1)).

(3) Assume that at this commit, "--hash" is again available, so we build
the tree with "--hash". This is incorrect however, because the cached
values come from step (1), not step (2).


This means that every time the build script notices that "--hash" is
unavailable, it must invalidate (delete) all the cached values, so that
*next time* it returns to using "--hash", all the hash values are
recalculated from scratch, and only the timestamp based checks are used
for that build.

So, how can I invalidate all the cached values? Is it enough to delete
the *.hash files?

Thanks,
Laszlo
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] FW: MTFTP file transfer timeout error

2017-09-28 Thread Vabhav Sharma
Hello Fu Siyuan,
I see that blocksize option with tftp command is introduced with commit 
2be45bfe2779043bc3566e879e7ec279412012dc.
Could you please help me clarify with the timeout error behavior observed in 
previous mail

Please note the behavior varies for different file type(Attached sheet).

Regards, 
Vabhav

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Vabhav 
Sharma
Sent: Saturday, September 23, 2017 4:21 PM
To: edk2-devel@lists.01.org; edk2-devel 
Subject: [edk2] MTFTP file transfer timeout error

[This sender failed our fraud detection checks and may not be who they appear 
to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]

Hi All,
I am facing timeout error with file transfer using tftp on UEFI shell with ARM 
based SoCs Command used: tftp -s  -i   


File transfer with file size greater 50 or 60 MB is returning timeout(Also 
depends on type of file like data file, ASCII file, boot sector)

I verified by playing around with blocksize from 32K to 42K for different file 
size(100MB,200MB,500MB) and identify that increasing the block size for large 
file size helps with successful transfer.
File transfer is always successful with 1K blocksize but file transfer time is 
increased.

Please suggest if there is any link between block size with file size or anyone 
faced such issue? I assume expectation is to use any blocksize from 
512(default) to 64K.

Regards,
Vabhav
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] Recall: MTFTP file transfer timeout error

2017-09-28 Thread Vabhav Sharma
Vabhav Sharma would like to recall the message, "MTFTP file transfer timeout 
error".
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] MTFTP file transfer timeout error

2017-09-28 Thread Vabhav Sharma
Hello Fu Siyuan,
I see that blocksize option with tftp command is introduced with commit 
2be45bfe2779043bc3566e879e7ec279412012dc.
Could you please help me clarify with the timeout error behavior observed in 
previous mail

Please note the behavior varies for different file type(Attached sheet)
Regards,
Vabhav

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Vabhav 
Sharma
Sent: Saturday, September 23, 2017 4:21 PM
To: edk2-devel@lists.01.org; edk2-devel 
Subject: [edk2] MTFTP file transfer timeout error

[This sender failed our fraud detection checks and may not be who they appear 
to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]

Hi All,
I am facing timeout error with file transfer using tftp on UEFI shell with ARM 
based SoCs Command used: tftp -s  -i   


File transfer with file size greater 50 or 60 MB is returning timeout(Also 
depends on type of file like data file, ASCII file, boot sector)

I verified by playing around with blocksize from 32K to 42K for different file 
size(100MB,200MB,500MB) and identify that increasing the block size for large 
file size helps with successful transfer.
File transfer is always successful with 1K blocksize but file transfer time is 
increased.

Please suggest if there is any link between block size with file size or anyone 
faced such issue? I assume expectation is to use any blocksize from 
512(default) to 64K.

Regards,
Vabhav
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Gao, Liming
Laszlo:
   I would like more people use it. Thank you! If you find any issue, please 
let me know. 

  When hash is enabled, AutoGen phase calculates hash value of every source 
files, INF, DSC and FDF, but has no AutoGen header and source file generation. 
So, AutoGen still takes some time. 

Thanks
Liming
>-Original Message-
>From: Laszlo Ersek [mailto:ler...@redhat.com]
>Sent: Thursday, September 28, 2017 7:15 PM
>To: Gao, Liming ; Zhu, Yonghong
>; edk2-devel@lists.01.org
>Cc: Kinney, Michael D ; Shaw, Kevin W
>
>Subject: Re: [edk2] [Patch V2] Build spec: add description for build with 
>binary
>cache
>
>On 09/28/17 11:02, Gao, Liming wrote:
>> Laszlo:
>>   Hash way may improve the incremental build performance. If hash value is
>not changed, module AutoGen and Make will be skipped.
>>   Time stamp way bases on Makefile. This way will run AutoGen every time.
>If no change, Makefile will not be updated.
>
>I did some tests, with ArmVirtQemu (AARCH64) and OVMF (Ia32 / Ia32X64 /
>X64).
>
>First I built all these platforms twice in a row, *without* --hash:
>- build ArmVirtQemu (AARCH64)
>- build OVMF (Ia32)
>- build OVMF (Ia32X64)
>- build OVMF (X64)
>- repeat all four builds in the same order, and now capture times in the
>report
>
>Then I built them twice in a row, *with* --hash:
>- build ArmVirtQemu (AARCH64)
>- build OVMF (Ia32)
>- build OVMF (Ia32X64)
>- build OVMF (X64)
>- repeat all four builds in the same order, and now capture times in the
>report
>
>The idea was that in the "repeat" builds, there was nothing to actually
>rebuild.
>
>Then we can compare how much time "--hash" saved, between the "repeat"
>builds:
>
>* without --hash:
>
>build.aa64virt.report:Build Duration:   00:00:15
>build.aa64virt.report:AutoGen Duration: 00:00:04
>build.aa64virt.report:Make Duration:00:00:04
>build.aa64virt.report:GenFds Duration:  00:00:06
>
>build.ovmf.32.report:Build Duration:   00:00:16
>build.ovmf.32.report:AutoGen Duration: 00:00:04
>build.ovmf.32.report:Make Duration:00:00:06
>build.ovmf.32.report:GenFds Duration:  00:00:06
>
>build.ovmf.3264.report:Build Duration:   00:00:20
>build.ovmf.3264.report:AutoGen Duration: 00:00:06
>build.ovmf.3264.report:Make Duration:00:00:07
>build.ovmf.3264.report:GenFds Duration:  00:00:07
>
>build.ovmf.report:Build Duration:   00:00:18
>build.ovmf.report:AutoGen Duration: 00:00:04
>build.ovmf.report:Make Duration:00:00:06
>build.ovmf.report:GenFds Duration:  00:00:06
>
>* With --hash:
>
>build.aa64virt.report:Build Duration:   00:00:11
>build.aa64virt.report:AutoGen Duration: 00:00:04
>build.aa64virt.report:GenFds Duration:  00:00:06
>
>build.ovmf.32.report:Build Duration:   00:00:11
>build.ovmf.32.report:AutoGen Duration: 00:00:04
>build.ovmf.32.report:GenFds Duration:  00:00:06
>
>build.ovmf.3264.report:Build Duration:   00:00:14
>build.ovmf.3264.report:AutoGen Duration: 00:00:06
>build.ovmf.3264.report:GenFds Duration:  00:00:07
>
>build.ovmf.report:Build Duration:   00:00:12
>build.ovmf.report:AutoGen Duration: 00:00:05
>build.ovmf.report:GenFds Duration:  00:00:06
>
>With "--hash", the "Make" step disappeared entirely (which is very
>welcome, and I'll start using --hash today).
>
>However, the "AutoGen" step took just as long. Can you think of a reason
>why? (Above you mention that AutoGen should be skipped too.)
>
>Thanks!
>Laszlo
>
>
>>> -Original Message-
>>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>>> Sent: Thursday, September 28, 2017 4:19 PM
>>> To: Zhu, Yonghong ; edk2-devel@lists.01.org
>>> Cc: Kinney, Michael D ; Shaw, Kevin W
>>> ; Gao, Liming 
>>> Subject: Re: [edk2] [Patch V2] Build spec: add description for build with
>binary
>>> cache
>>>
>>> On 09/19/17 08:48, Yonghong Zhu wrote:
 V2:
 change the option name to --binary-destination and --binary-source.

 fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=689
>>>
>>> What are the benefits of a hash-based incremental build over a
>>> timestamp-based incremental build?
>>>
>>> Thank you,
>>> Laszlo
>>>
 Cc: Liming Gao 
 Cc: Michael Kinney 
 Cc: Kevin W Shaw 
 Contributed-under: TianoCore Contribution Agreement 1.1
 Signed-off-by: Yonghong Zhu 
 ---
  .../82_auto-generation_process.md| 20
>>> 
  README.md|  1 +
  appendix_d_buildexe_command/d4_usage.md  | 19
>>> +++
  3 files changed, 36 insertions(+), 4 deletions(-)

 diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md
>>> 

[edk2] Clarification about InitializeCpuExceptionHandlers() and TGE bit in hcr_el2

2017-09-28 Thread Vabhav Sharma
Hi All,

I see that InitializeCpuExceptionHandlers() is called from DxeMain to take over 
exception handlers and later from ArmCpuDxe.
Is there any specific purpose to call it from two places during dxe phase?

Additionally we are setting TGE bit three times in hcr_el2 during PrePei 
phase(ArmPlatformPkg/PrePi/AArch64/ArchPrePi.c)
and Twice in Dxe phase: dxemain(),ArmCpuDxe

Please help to clarify or required to be fixed?

Regards,
Vabhav
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Laszlo Ersek
On 09/28/17 11:02, Gao, Liming wrote:
> Laszlo:
>   Hash way may improve the incremental build performance. If hash value is 
> not changed, module AutoGen and Make will be skipped. 
>   Time stamp way bases on Makefile. This way will run AutoGen every time. If 
> no change, Makefile will not be updated.  

I did some tests, with ArmVirtQemu (AARCH64) and OVMF (Ia32 / Ia32X64 /
X64).

First I built all these platforms twice in a row, *without* --hash:
- build ArmVirtQemu (AARCH64)
- build OVMF (Ia32)
- build OVMF (Ia32X64)
- build OVMF (X64)
- repeat all four builds in the same order, and now capture times in the
report

Then I built them twice in a row, *with* --hash:
- build ArmVirtQemu (AARCH64)
- build OVMF (Ia32)
- build OVMF (Ia32X64)
- build OVMF (X64)
- repeat all four builds in the same order, and now capture times in the
report

The idea was that in the "repeat" builds, there was nothing to actually
rebuild.

Then we can compare how much time "--hash" saved, between the "repeat"
builds:

* without --hash:

build.aa64virt.report:Build Duration:   00:00:15
build.aa64virt.report:AutoGen Duration: 00:00:04
build.aa64virt.report:Make Duration:00:00:04
build.aa64virt.report:GenFds Duration:  00:00:06

build.ovmf.32.report:Build Duration:   00:00:16
build.ovmf.32.report:AutoGen Duration: 00:00:04
build.ovmf.32.report:Make Duration:00:00:06
build.ovmf.32.report:GenFds Duration:  00:00:06

build.ovmf.3264.report:Build Duration:   00:00:20
build.ovmf.3264.report:AutoGen Duration: 00:00:06
build.ovmf.3264.report:Make Duration:00:00:07
build.ovmf.3264.report:GenFds Duration:  00:00:07

build.ovmf.report:Build Duration:   00:00:18
build.ovmf.report:AutoGen Duration: 00:00:04
build.ovmf.report:Make Duration:00:00:06
build.ovmf.report:GenFds Duration:  00:00:06

* With --hash:

build.aa64virt.report:Build Duration:   00:00:11
build.aa64virt.report:AutoGen Duration: 00:00:04
build.aa64virt.report:GenFds Duration:  00:00:06

build.ovmf.32.report:Build Duration:   00:00:11
build.ovmf.32.report:AutoGen Duration: 00:00:04
build.ovmf.32.report:GenFds Duration:  00:00:06

build.ovmf.3264.report:Build Duration:   00:00:14
build.ovmf.3264.report:AutoGen Duration: 00:00:06
build.ovmf.3264.report:GenFds Duration:  00:00:07

build.ovmf.report:Build Duration:   00:00:12
build.ovmf.report:AutoGen Duration: 00:00:05
build.ovmf.report:GenFds Duration:  00:00:06

With "--hash", the "Make" step disappeared entirely (which is very
welcome, and I'll start using --hash today).

However, the "AutoGen" step took just as long. Can you think of a reason
why? (Above you mention that AutoGen should be skipped too.)

Thanks!
Laszlo


>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Thursday, September 28, 2017 4:19 PM
>> To: Zhu, Yonghong ; edk2-devel@lists.01.org
>> Cc: Kinney, Michael D ; Shaw, Kevin W
>> ; Gao, Liming 
>> Subject: Re: [edk2] [Patch V2] Build spec: add description for build with 
>> binary
>> cache
>>
>> On 09/19/17 08:48, Yonghong Zhu wrote:
>>> V2:
>>> change the option name to --binary-destination and --binary-source.
>>>
>>> fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=689
>>
>> What are the benefits of a hash-based incremental build over a
>> timestamp-based incremental build?
>>
>> Thank you,
>> Laszlo
>>
>>> Cc: Liming Gao 
>>> Cc: Michael Kinney 
>>> Cc: Kevin W Shaw 
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Yonghong Zhu 
>>> ---
>>>  .../82_auto-generation_process.md| 20
>> 
>>>  README.md|  1 +
>>>  appendix_d_buildexe_command/d4_usage.md  | 19
>> +++
>>>  3 files changed, 36 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md
>> b/8_pre-build_autogen_stage/82_auto-generation_process.md
>>> index 671a7d5..f2ddf32 100644
>>> --- a/8_pre-build_autogen_stage/82_auto-generation_process.md
>>> +++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
>>> @@ -1031,10 +1031,30 @@ maximum command line length.  The default
>> value is 4096.
>>>  **Note:** The following `FLAGS` options are included in the response file:
>>>  `PP_FLAGS`, `CC_FLAGS`, `VFRPP_FLAGS`, `APP_FLAGS`, `ASLPP_FLAGS`,
>> `ASLCC_FLAGS`,
>>>  and `ASM_FLAGS`.
>>>  **
>>>
>>> + 8.2.4.15 Build with Binary Cache
>>> +
>>> +**build** tool provides three new options for binary cache feature.
>>> +--hash enables hash-based caching during build process. when --hash is
>> enabled,
>>> +build tool will base on the module hash value to do the incremental build,
>> without
>>> 

Re: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Yao, Jiewen
yes, i like the idea to use table as parameter.

thank you!
Yao, Jiewen


> 在 2017年9月28日,下午6:04,Ni, Ruiyu  写道:
> 
> 1. We could either use BOOLEAN flag to tell SetProcessorRegister() which 
> register table to use.
> Or, pass both RegisterTableList and CpuNum into SetProcessorRegister().
> I prefer the latter one.
> VOID
> SetProcessorRegister (
>  IN CPU_REGISTER_TABLE*RegisterTables,
>  IN UINTN RegisterTableCount
>  );
> 
> 
> 2. How about change MPRendezvousProcedure to InitializeAp?
> 
> Thanks/Ray
> 
>> -Original Message-
>> From: Zeng, Star
>> Sent: Thursday, September 28, 2017 5:31 PM
>> To: Dong, Eric ; edk2-devel@lists.01.org
>> Cc: Ni, Ruiyu ; Yao, Jiewen ; Zeng,
>> Star 
>> Subject: RE: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to
>> avoid duplicated code.
>> 
>> Just FYI, another idea is to declare SetProcessorRegister() like below, then 
>> the
>> caller of SetProcessorRegister() has no need to touch mAcpiCpuData.
>> 
>> VOID
>> SetProcessorRegister (
>>  IN BOOLEAN PreSmmFlag
>>  )
>> {
>>  CPU_REGISTER_TABLE*RegisterTableList;
>> ...
>>  if (PreSmmFlag) {
>>RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
>> mAcpiCpuData.PreSmmInitRegisterTable;
>>  } else {
>>RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
>> mAcpiCpuData.RegisterTable;
>>  }
>> ...
>> 
>> Thanks,
>> Star
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric
>> Dong
>> Sent: Thursday, September 28, 2017 5:15 PM
>> To: edk2-devel@lists.01.org
>> Cc: Ni, Ruiyu ; Yao, Jiewen 
>> Subject: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to
>> avoid duplicated code.
>> 
>> Refine code to avoid duplicate code to set processor register.
>> 
>> Cc: Jiewen Yao 
>> Cc: Ruiyu Ni 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Eric Dong 
>> ---
>> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 78 ++--
>> ---
>> 1 file changed, 20 insertions(+), 58 deletions(-)
>> 
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
>> index ae4b516..500a0e2 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
>> @@ -208,18 +208,28 @@ Returns:
>> 
>>   This function programs registers for the calling processor.
>> 
>> -  @param  RegisterTable Pointer to register table of the running processor.
>> +  @param  RegisterTableList Pointer to register table of the running
>> processor.
>> 
>> **/
>> VOID
>> SetProcessorRegister (
>> -  IN CPU_REGISTER_TABLE*RegisterTable
>> +  IN CPU_REGISTER_TABLE*RegisterTableList
>>   )
>> {
>>   CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
>>   UINTN Index;
>>   UINTN Value;
>>   SPIN_LOCK *MsrSpinLock;
>> +  UINT32InitApicId;
>> +  CPU_REGISTER_TABLE*RegisterTable;
>> +
>> +  InitApicId = GetInitialApicId ();
>> +  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
>> +if (RegisterTableList[Index].InitialApicId == InitApicId) {
>> +  RegisterTable =  [Index];
>> +  break;
>> +}
>> +  }
>> 
>>   //
>>   // Traverse Register Table of this logical processor @@ -347,8 +357,6 @@
>> SetProcessorRegister (
>>   }
>> }
>> 
>> -
>> -
>> /**
>>   AP initialization before then after SMBASE relocation in the S3 boot path.
>> **/
>> @@ -357,26 +365,12 @@ MPRendezvousProcedure (
>>   VOID
>>   )
>> {
>> -  CPU_REGISTER_TABLE *RegisterTableList;
>> -  UINT32 InitApicId;
>> -  UINTN  Index;
>>   UINTN  TopOfStack;
>>   UINT8  Stack[128];
>> 
>>   LoadMtrrData (mAcpiCpuData.MtrrTable);
>> 
>> -  //
>> -  // Find processor number for this CPU.
>> -  //
>> -  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
>> mAcpiCpuData.PreSmmInitRegisterTable;
>> -  InitApicId = GetInitialApicId ();
>> -  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
>> -if (RegisterTableList[Index].InitialApicId == InitApicId) {
>> -  SetProcessorRegister ([Index]);
>> -  break;
>> -}
>> -  }
>> -
>> +  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN)
>> + mAcpiCpuData.PreSmmInitRegisterTable);
>> 
>>   //
>>   // Count down the number with lock mechanism.
>> @@ -393,14 +387,7 @@ MPRendezvousProcedure (
>>   ProgramVirtualWireMode ();
>>   DisableLvtInterrupts ();
>> 
>> -  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
>> mAcpiCpuData.RegisterTable;
>> -  InitApicId = GetInitialApicId ();
>> -  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
>> -if (RegisterTableList[Index].InitialApicId == InitApicId) 

Re: [edk2] [Patch] BaseTools: PI 1.6 to support FV extended header contain FV used size

2017-09-28 Thread Gao, Liming
I have two comments here.

1) GenFv: ExtHeader UsedSize can directly be updated. You don't need to 
allocate new buffer for it. Besides, VtfFileFlag is not required to be listed 
in GenFvInternalLib.h. 
   
2) Genfds: self.ExtEntrySize), self.ExtEntryType and self.UsedSize are hard 
value. You can directly use value instead of the local variable.

>-Original Message-
>From: Zhu, Yonghong
>Sent: Thursday, September 28, 2017 4:22 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, YunhuaX ; Gao, Liming
>
>Subject: [Patch] BaseTools: PI 1.6 to support FV extended header contain FV
>used size
>
>From: Yunhua Feng 
>
>Per PI 1.6 we added an FV Extended Header entry that would contain the
>size of the FV that was in use.
>
>Cc: Liming Gao 
>Cc: Yonghong Zhu 
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yunhua Feng 
>---
> BaseTools/Source/C/GenFv/GenFvInternalLib.c  | 19
>+--
> BaseTools/Source/C/GenFv/GenFvInternalLib.h  |  3 ++-
> BaseTools/Source/C/Include/Common/PiFirmwareVolume.h |  6 ++
> BaseTools/Source/Python/GenFds/FdfParser.py  |  2 +-
> BaseTools/Source/Python/GenFds/Fv.py | 20
>+++-
> 5 files changed, 45 insertions(+), 5 deletions(-)
>
>diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>index 01c862e..5b219b3 100644
>--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
>@@ -42,10 +42,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
>KIND, EITHER EXPRESS OR IMPLIED.
> #define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION   0xEB00
> #define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION  0x1400
>
> BOOLEAN mArm = FALSE;
> STATIC UINT32   MaxFfsAlignment = 0;
>+BOOLEAN VtfFileFlag = FALSE;
>
> EFI_GUID  mEfiFirmwareVolumeTopFileGuid   =
>EFI_FFS_VOLUME_TOP_FILE_GUID;
> EFI_GUID  mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV];
> EFI_GUID  mZeroGuid   = {0x0, 0x0, 0x0, {0x0, 0x0, 
> 0x0, 0x0, 0x0,
>0x0, 0x0, 0x0}};
> EFI_GUID  mDefaultCapsuleGuid = {0x3B6686BD, 0x0D76, 0x4030,
>{ 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 }};
>@@ -598,10 +599,11 @@ Returns:
> {
>   EFI_FFS_FILE_HEADER *PadFile;
>   UINTN   PadFileSize;
>   UINT32  NextFfsHeaderSize;
>   UINT32  CurFfsHeaderSize;
>+  EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *FvUsedSize;
>
>   CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
>   //
>   // Verify input parameters.
>   //
>@@ -703,10 +705,25 @@ Returns:
>
>   if (ExtHeader != NULL) {
> //
> // Copy Fv Extension Header and Set Fv Extension header offset
> //
>+if (ExtHeader->ExtHeaderSize > sizeof
>(EFI_FIRMWARE_VOLUME_EXT_HEADER)) {
>+  FvUsedSize =
>malloc(sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
>+  if (FvUsedSize == NULL) {
>+return EFI_OUT_OF_RESOURCES;
>+  }
>+  memcpy(FvUsedSize, ExtHeader + 1,
>sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
>+  if (FvUsedSize->Hdr.ExtEntryType == EFI_FV_EXT_TYPE_USED_SIZE_TYPE)
>{
>+if (VtfFileFlag) {
>+  FvUsedSize->UsedSize = mFvTotalSize;
>+} else {
>+  FvUsedSize->UsedSize = mFvTakenSize;
>+}
>+memcpy(ExtHeader + 1, FvUsedSize,
>sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
>+  }
>+ }
> memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, ExtHeader-
>>ExtHeaderSize);
> ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)-
>>ExtHeaderOffset = (UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize)
>- (UINTN) FvImage->FileImage);
> //
> // Make next file start at QWord Boundry
> //
>@@ -3057,16 +3074,14 @@ Returns:
>   UINTN   FfsFileSize;
>   UINTN   FvExtendHeaderSize;
>   UINT32  FfsAlignment;
>   UINT32  FfsHeaderSize;
>   EFI_FFS_FILE_HEADER FfsHeader;
>-  BOOLEAN VtfFileFlag;
>   UINTN   VtfFileSize;
>
>   FvExtendHeaderSize = 0;
>   VtfFileSize = 0;
>-  VtfFileFlag = FALSE;
>   fpin  = NULL;
>   Index = 0;
>
>   //
>   // Compute size for easy access later
>diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h
>b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
>index f039fa4..9b1abe7 100644
>--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h
>+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
>@@ -1,10 +1,10 @@
> /** @file
> This file contains describes the public interfaces to the GenFvImage Library.
> The basic purpose of the library is to create Firmware Volume images.
>
>-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
>+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials
> are licensed and made available under 

Re: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Ni, Ruiyu
1. We could either use BOOLEAN flag to tell SetProcessorRegister() which 
register table to use.
Or, pass both RegisterTableList and CpuNum into SetProcessorRegister().
I prefer the latter one.
VOID
SetProcessorRegister (
  IN CPU_REGISTER_TABLE*RegisterTables,
  IN UINTN RegisterTableCount
  );


2. How about change MPRendezvousProcedure to InitializeAp?

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, September 28, 2017 5:31 PM
> To: Dong, Eric ; edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Yao, Jiewen ; Zeng,
> Star 
> Subject: RE: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to
> avoid duplicated code.
> 
> Just FYI, another idea is to declare SetProcessorRegister() like below, then 
> the
> caller of SetProcessorRegister() has no need to touch mAcpiCpuData.
> 
> VOID
> SetProcessorRegister (
>   IN BOOLEAN PreSmmFlag
>   )
> {
>   CPU_REGISTER_TABLE*RegisterTableList;
> ...
>   if (PreSmmFlag) {
> RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
> mAcpiCpuData.PreSmmInitRegisterTable;
>   } else {
> RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
> mAcpiCpuData.RegisterTable;
>   }
> ...
> 
> Thanks,
> Star
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric
> Dong
> Sent: Thursday, September 28, 2017 5:15 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Yao, Jiewen 
> Subject: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to
> avoid duplicated code.
> 
> Refine code to avoid duplicate code to set processor register.
> 
> Cc: Jiewen Yao 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 78 ++--
> ---
>  1 file changed, 20 insertions(+), 58 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index ae4b516..500a0e2 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -208,18 +208,28 @@ Returns:
> 
>This function programs registers for the calling processor.
> 
> -  @param  RegisterTable Pointer to register table of the running processor.
> +  @param  RegisterTableList Pointer to register table of the running
> processor.
> 
>  **/
>  VOID
>  SetProcessorRegister (
> -  IN CPU_REGISTER_TABLE*RegisterTable
> +  IN CPU_REGISTER_TABLE*RegisterTableList
>)
>  {
>CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
>UINTN Index;
>UINTN Value;
>SPIN_LOCK *MsrSpinLock;
> +  UINT32InitApicId;
> +  CPU_REGISTER_TABLE*RegisterTable;
> +
> +  InitApicId = GetInitialApicId ();
> +  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
> +if (RegisterTableList[Index].InitialApicId == InitApicId) {
> +  RegisterTable =  [Index];
> +  break;
> +}
> +  }
> 
>//
>// Traverse Register Table of this logical processor @@ -347,8 +357,6 @@
> SetProcessorRegister (
>}
>  }
> 
> -
> -
>  /**
>AP initialization before then after SMBASE relocation in the S3 boot path.
>  **/
> @@ -357,26 +365,12 @@ MPRendezvousProcedure (
>VOID
>)
>  {
> -  CPU_REGISTER_TABLE *RegisterTableList;
> -  UINT32 InitApicId;
> -  UINTN  Index;
>UINTN  TopOfStack;
>UINT8  Stack[128];
> 
>LoadMtrrData (mAcpiCpuData.MtrrTable);
> 
> -  //
> -  // Find processor number for this CPU.
> -  //
> -  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
> mAcpiCpuData.PreSmmInitRegisterTable;
> -  InitApicId = GetInitialApicId ();
> -  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
> -if (RegisterTableList[Index].InitialApicId == InitApicId) {
> -  SetProcessorRegister ([Index]);
> -  break;
> -}
> -  }
> -
> +  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN)
> + mAcpiCpuData.PreSmmInitRegisterTable);
> 
>//
>// Count down the number with lock mechanism.
> @@ -393,14 +387,7 @@ MPRendezvousProcedure (
>ProgramVirtualWireMode ();
>DisableLvtInterrupts ();
> 
> -  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN)
> mAcpiCpuData.RegisterTable;
> -  InitApicId = GetInitialApicId ();
> -  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
> -if (RegisterTableList[Index].InitialApicId == InitApicId) {
> -  SetProcessorRegister ([Index]);
> -  break;
> -}
> -  }
> +  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN)
> + mAcpiCpuData.RegisterTable);
> 
>//
>// Place AP into the safe code, count down the number with lock mechanism 
> 

Re: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Zeng, Star
Just FYI, another idea is to declare SetProcessorRegister() like below, then 
the caller of SetProcessorRegister() has no need to touch mAcpiCpuData.

VOID
SetProcessorRegister (
  IN BOOLEAN PreSmmFlag
  )
{
  CPU_REGISTER_TABLE*RegisterTableList;
...
  if (PreSmmFlag) {
RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
  } else {
RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
  }
...

Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Dong
Sent: Thursday, September 28, 2017 5:15 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Yao, Jiewen 
Subject: [edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid 
duplicated code.

Refine code to avoid duplicate code to set processor register.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 78 ++-
 1 file changed, 20 insertions(+), 58 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index ae4b516..500a0e2 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -208,18 +208,28 @@ Returns:
 
   This function programs registers for the calling processor.
 
-  @param  RegisterTable Pointer to register table of the running processor.
+  @param  RegisterTableList Pointer to register table of the running 
processor.
 
 **/
 VOID
 SetProcessorRegister (
-  IN CPU_REGISTER_TABLE*RegisterTable
+  IN CPU_REGISTER_TABLE*RegisterTableList
   )
 {
   CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
   UINTN Index;
   UINTN Value;
   SPIN_LOCK *MsrSpinLock;
+  UINT32InitApicId;
+  CPU_REGISTER_TABLE*RegisterTable;
+
+  InitApicId = GetInitialApicId ();
+  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
+if (RegisterTableList[Index].InitialApicId == InitApicId) {
+  RegisterTable =  [Index];
+  break;
+}
+  }
 
   //
   // Traverse Register Table of this logical processor @@ -347,8 +357,6 @@ 
SetProcessorRegister (
   }
 }
 
-
-
 /**
   AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
@@ -357,26 +365,12 @@ MPRendezvousProcedure (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
   UINTN  TopOfStack;
   UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
-
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.PreSmmInitRegisterTable);
 
   //
   // Count down the number with lock mechanism.
@@ -393,14 +387,7 @@ MPRendezvousProcedure (
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
 
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.RegisterTable);
 
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
@@ -475,27 +462,13 @@ PrepareApStartupVector (
 
 **/
 VOID
-EarlyInitializeCpu (
+InitializeCpuBeforeRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
+ mAcpiCpuData.PreSmmInitRegisterTable);
 
   ProgramVirtualWireMode ();
 
@@ -527,22 +500,11 @@ EarlyInitializeCpu (
 
 **/
 VOID
-InitializeCpu (
+InitializeCpuAfterRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;

Re: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Udit Kumar


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Hao
> Wu
> Sent: Thursday, September 28, 2017 12:31 PM
> To: edk2-devel@lists.01.org
> Cc: Hao Wu ; Michael D Kinney
> ; Jiewen Yao ; Star Zeng
> 
> Subject: [edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the
> ASSERT to check NULL ptr
> 
> Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
> checking NULL pointer dereference.
> 
> This commit adds comments to clarify the reason for using ASSERT as the check.
> 
> Cc: Star Zeng 
> Cc: Michael D Kinney 
> Cc: Jiewen Yao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> index 2db441725c..344ff1fe02 100644
> --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> @@ -1175,10 +1175,15 @@ Done:
>  //
>  if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
>//
> +  // According to above logic, if 'Prot' is NULL, then the 'Status' must 
> be
> +  // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
> +  // must be not NULL.
> +  //
> +  ASSERT (Prot != NULL);
> +  //

I think , we should take care of no debug environment here 
If MDEPKG_NDEBUG is not defined and Prot is NULL then 
shouldn't we return error ?

>// EFI_ALREADY_STARTED is not an error for bus driver.
>// Return the corresponding protocol interface.
>//
> -  ASSERT (Prot != NULL);
>*Interface = Prot->Interface;
>  } else if (Status == EFI_UNSUPPORTED) {
>//
> --
> 2.12.0.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [Patch 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

2017-09-28 Thread Eric Dong
Refine code to avoid duplicate code to set processor register.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 78 ++-
 1 file changed, 20 insertions(+), 58 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index ae4b516..500a0e2 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -208,18 +208,28 @@ Returns:
 
   This function programs registers for the calling processor.
 
-  @param  RegisterTable Pointer to register table of the running processor.
+  @param  RegisterTableList Pointer to register table of the running 
processor.
 
 **/
 VOID
 SetProcessorRegister (
-  IN CPU_REGISTER_TABLE*RegisterTable
+  IN CPU_REGISTER_TABLE*RegisterTableList
   )
 {
   CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
   UINTN Index;
   UINTN Value;
   SPIN_LOCK *MsrSpinLock;
+  UINT32InitApicId;
+  CPU_REGISTER_TABLE*RegisterTable;
+
+  InitApicId = GetInitialApicId ();
+  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
+if (RegisterTableList[Index].InitialApicId == InitApicId) {
+  RegisterTable =  [Index];
+  break;
+}
+  }
 
   //
   // Traverse Register Table of this logical processor
@@ -347,8 +357,6 @@ SetProcessorRegister (
   }
 }
 
-
-
 /**
   AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
@@ -357,26 +365,12 @@ MPRendezvousProcedure (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
   UINTN  TopOfStack;
   UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
-
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable);
 
   //
   // Count down the number with lock mechanism.
@@ -393,14 +387,7 @@ MPRendezvousProcedure (
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
 
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable);
 
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
@@ -475,27 +462,13 @@ PrepareApStartupVector (
 
 **/
 VOID
-EarlyInitializeCpu (
+InitializeCpuBeforeRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable);
 
   ProgramVirtualWireMode ();
 
@@ -527,22 +500,11 @@ EarlyInitializeCpu (
 
 **/
 VOID
-InitializeCpu (
+InitializeCpuAfterRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetProcessorRegister ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
 
@@ -660,7 +622,7 @@ SmmRestoreCpu (
 //
 // First time microcode load and restore MTRRs
 //
-EarlyInitializeCpu ();
+InitializeCpuBeforeRebase ();
   }
 
   //
@@ -675,7 +637,7 @@ SmmRestoreCpu (
 //
 // Restore MSRs for BSP and all APs
 //
-InitializeCpu ();
+InitializeCpuAfterRebase ();
   }
 
   //
-- 

[edk2] [Patch 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Enhance S3 code.

2017-09-28 Thread Eric Dong
Combine INIT-SIPI-SIPI code and remove the duplicate code.

Eric Dong (2):
  UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.
  UefiCpuPkg/PiSmmCpuDxeSmm: Refine code to avoid duplicated code.

 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 123 +-
 1 file changed, 43 insertions(+), 80 deletions(-)

-- 
2.7.0.windows.1

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


[edk2] [Patch 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.

2017-09-28 Thread Eric Dong
In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI,
this is not necessary. This change combine these 2 INIT-SIPI-SIPI to 1
and add CpuPause between them.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 51 ---
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 9404501..ae4b516 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -39,6 +39,11 @@ typedef struct {
 //
 SPIN_LOCK*mMemoryMappedLock = NULL;
 
+//
+// Signal that SMM BASE relocation is complete.
+//
+volatile BOOLEAN mInitApsAfterSmmBaseReloc;
+
 /**
   Get starting address and size of the rendezvous entry for APs.
   Information for fixing a jump instruction in the code is also returned.
@@ -342,17 +347,21 @@ SetProcessorRegister (
   }
 }
 
+
+
 /**
-  AP initialization before SMBASE relocation in the S3 boot path.
+  AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
-EarlyMPRendezvousProcedure (
+MPRendezvousProcedure (
   VOID
   )
 {
   CPU_REGISTER_TABLE *RegisterTableList;
   UINT32 InitApicId;
   UINTN  Index;
+  UINTN  TopOfStack;
+  UINT8  Stack[128];
 
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
@@ -368,25 +377,18 @@ EarlyMPRendezvousProcedure (
 }
   }
 
+
   //
   // Count down the number with lock mechanism.
   //
   InterlockedDecrement ();
-}
 
-/**
-  AP initialization after SMBASE relocation in the S3 boot path.
-**/
-VOID
-MPRendezvousProcedure (
-  VOID
-  )
-{
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-  UINTN  TopOfStack;
-  UINT8  Stack[128];
+  //
+  // Wait for BSP to signal SMM Base relocation done.
+  //
+  while (!mInitApsAfterSmmBaseReloc) {
+CpuPause ();
+  }
 
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
@@ -500,7 +502,12 @@ EarlyInitializeCpu (
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) EarlyMPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+
+  //
+  // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
+  //
+  mInitApsAfterSmmBaseReloc = FALSE;
 
   //
   // Send INIT IPI - SIPI to all APs
@@ -538,17 +545,11 @@ InitializeCpu (
   }
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  //
-  // StackStart was updated when APs were waken up in EarlyInitializeCpu.
-  // Re-initialize StackAddress to original beginning address.
-  //
-  mExchangeInfo->StackStart  = (VOID *) (UINTN) mAcpiCpuData.StackAddress;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
 
   //
-  // Send INIT IPI - SIPI to all APs
+  // Signal that SMM base relocation is complete and to continue 
initialization.
   //
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+  mInitApsAfterSmmBaseReloc = TRUE;
 
   while (mNumberToFinish > 0) {
 CpuPause ();
-- 
2.7.0.windows.1

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


Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Gao, Liming
Laszlo:
  Hash way may improve the incremental build performance. If hash value is not 
changed, module AutoGen and Make will be skipped. 
  Time stamp way bases on Makefile. This way will run AutoGen every time. If no 
change, Makefile will not be updated.  

Thanks
Liming
>-Original Message-
>From: Laszlo Ersek [mailto:ler...@redhat.com]
>Sent: Thursday, September 28, 2017 4:19 PM
>To: Zhu, Yonghong ; edk2-devel@lists.01.org
>Cc: Kinney, Michael D ; Shaw, Kevin W
>; Gao, Liming 
>Subject: Re: [edk2] [Patch V2] Build spec: add description for build with 
>binary
>cache
>
>On 09/19/17 08:48, Yonghong Zhu wrote:
>> V2:
>> change the option name to --binary-destination and --binary-source.
>>
>> fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=689
>
>What are the benefits of a hash-based incremental build over a
>timestamp-based incremental build?
>
>Thank you,
>Laszlo
>
>> Cc: Liming Gao 
>> Cc: Michael Kinney 
>> Cc: Kevin W Shaw 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Yonghong Zhu 
>> ---
>>  .../82_auto-generation_process.md| 20
>
>>  README.md|  1 +
>>  appendix_d_buildexe_command/d4_usage.md  | 19
>+++
>>  3 files changed, 36 insertions(+), 4 deletions(-)
>>
>> diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md
>b/8_pre-build_autogen_stage/82_auto-generation_process.md
>> index 671a7d5..f2ddf32 100644
>> --- a/8_pre-build_autogen_stage/82_auto-generation_process.md
>> +++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
>> @@ -1031,10 +1031,30 @@ maximum command line length.  The default
>value is 4096.
>>  **Note:** The following `FLAGS` options are included in the response file:
>>  `PP_FLAGS`, `CC_FLAGS`, `VFRPP_FLAGS`, `APP_FLAGS`, `ASLPP_FLAGS`,
>`ASLCC_FLAGS`,
>>  and `ASM_FLAGS`.
>>  **
>>
>> + 8.2.4.15 Build with Binary Cache
>> +
>> +**build** tool provides three new options for binary cache feature.
>> +--hash enables hash-based caching during build process. when --hash is
>enabled,
>> +build tool will base on the module hash value to do the incremental build,
>without
>> +--hash, build tool will base on the timestamp to do the incremental build. 
>> --
>hash
>> +option use md5 method to get every hash value, DSC/FDF, tools_def.txt,
>build_rule.txt
>> +and build command are calculated as global hash value, Package DEC and its
>include
>> +header files are calculated as package hash value, Module source files and
>its INF
>> +file are calculated as module hash value. Library hash value will combine
>the global
>> +hash value and its dependent package hash value. Driver hash value will
>combine the
>> +global hash value, its dependent package hash value and its linked library
>hash value.
>> +When --hash and --binary-destination are specified, build tool will copy the
>generated
>> +binary files for each module into the directory specified by binary-
>destination at the
>> +build phase. Binary-destination directory caches all the generated binary
>files.
>> +When --hash and --binary-source are specified, build tool will try to get 
>> the
>binary
>> +files from the binary source directory at the build phase. If the cached
>binary has
>> +the same hash value, it will be directly used. Otherwise, build tool will
>compile the
>> +source files and generate the binary files.
>> +
>>  ### 8.2.5 Post processing
>>
>>  Once all files are parsed, the build tools will do following work for each 
>> EDK
>>  II module:
>>
>> diff --git a/README.md b/README.md
>> index 52abb6a..ca59a35 100644
>> --- a/README.md
>> +++ b/README.md
>> @@ -215,5 +215,6 @@ Copyright (c) 2008-2017, Intel Corporation. All rights
>reserved.
>>  || [#523](https://bugzilla.tianocore.org/show_bug.cgi?id=523) 
>> Build
>spec: add EBNF for the --pcd syntax in the Section D.4
>|   |
>>  || [#517](https://bugzilla.tianocore.org/show_bug.cgi?id=517) 
>> Build
>spec: chapter 5.2.2 Guided Tools add description for Pkcs7Sign tool and
>BrotliCompress tool
>|   |
>>  || [#481](https://bugzilla.tianocore.org/show_bug.cgi?id=481) 
>> Build
>Spec: add clarification for not used Pcd that build tool will not do additional
>checks on its value
>|   |
>>  || [#518](https://bugzilla.tianocore.org/show_bug.cgi?id=518) 
>> Build
>Spec: Update Precedence of PCD Values
>|   |
>>  || [#669](https://bugzilla.tianocore.org/show_bug.cgi?id=669) 
>> Build
>Spec: Add multi-arg support to PREBUILD/POSTBUILD
>|   |
>> +|| [#689](https://bugzilla.tianocore.org/show_bug.cgi?id=689) 
>> Build
>spec: add description for build with binary cache
>|  

Re: [edk2] [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol

2017-09-28 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: Wu, Hao A
> Sent: Thursday, September 28, 2017 4:33 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Ni, Ruiyu ; Carsey,
> Jaben 
> Subject: [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition Info
> protocol
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655
> 
> V2 change:
> Put some strings into the UNI file for localization.
> 
> The dump information will include:
> a. The type of the partition (Mbr, Gpt or Other); b. Whether the partition is 
> an
> EFI System Partition.
> 
> Cc: Ruiyu Ni 
> Cc: Jaben Carsey 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu 
> ---
>  .../UefiHandleParsingLib/UefiHandleParsingLib.c| 86
> ++
>  .../UefiHandleParsingLib/UefiHandleParsingLib.h|  1 +
>  .../UefiHandleParsingLib/UefiHandleParsingLib.inf  |  1
> +  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |  9 +++
>  4 files changed, 97 insertions(+)
> 
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> index d12466c7b0..a228226623 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
> @@ -1933,6 +1933,87 @@ ERROR_EXIT:
>return NULL;
>  }
> 
> +/**
> +  Function to dump information about Partition Information protocol.
> +
> +  This will allocate the return buffer from boot services pool.
> +
> +  @param[in] TheHandle  The handle that has the protocol installed.
> +  @param[in] VerboseTRUE for additional information, FALSE otherwise.
> +
> +  @retval A pointer to a string containing the information.
> +**/
> +CHAR16*
> +EFIAPI
> +PartitionInfoProtocolDumpInformation (
> +  IN CONST EFI_HANDLE TheHandle,
> +  IN CONST BOOLEANVerbose
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_PARTITION_INFO_PROTOCOL *PartitionInfo;
> +  CHAR16  *PartitionType;
> +  CHAR16  *EfiSystemPartition;
> +  CHAR16  *RetVal;
> +
> +  if (!Verbose) {
> +return NULL;
> +  }
> +
> +  Status = gBS->OpenProtocol (
> +TheHandle,
> +,
> +(VOID**),
> +gImageHandle,
> +NULL,
> +EFI_OPEN_PROTOCOL_GET_PROTOCOL
> +);
> +  if (EFI_ERROR (Status)) {
> +return NULL;
> +  }
> +
> +  HandleParsingHiiInit ();
> +
> +  switch (PartitionInfo->Type) {
> +  case PARTITION_TYPE_OTHER:
> +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);
> +break;
> +  case PARTITION_TYPE_MBR:
> +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);
> +break;
> +  case PARTITION_TYPE_GPT:
> +PartitionType = HiiGetString (mHandleParsingHiiHandle,
> STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);
> +break;
> +  default:
> +PartitionType = NULL;
> +break;
> +  }
> +  if (PartitionType == NULL) {
> +return NULL;
> +  }
> +
> +  if (PartitionInfo->System == 1) {
> +EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle,
> + STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);  } else {
> +EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle,
> + STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);  }  if
> + (EfiSystemPartition == NULL) {
> +SHELL_FREE_NON_NULL (PartitionType);
> +return NULL;
> +  }
> +
> +  RetVal = CatSPrint (
> + NULL,
> + L"%s\r\n%s",
> + PartitionType,
> + EfiSystemPartition
> + );
> +
> +  SHELL_FREE_NON_NULL (EfiSystemPartition);
> +  SHELL_FREE_NON_NULL (PartitionType);
> +  return RetVal;
> +}
> +
>  //
>  // Put the information on the NT32 protocol GUIDs here so we are not
> dependant on the Nt32Pkg  // @@ -2147,6 +2228,11 @@ STATIC CONST
> GUID_INFO_BLOCK mGuidStringList[] = {
>{STRING_TOKEN(STR_ADAPTER_INFO),
> ,
> AdapterInformationDumpInformation},
> 
>  //
> +// UEFI 2.7
> +//
> +  {STRING_TOKEN(STR_PARTITION_INFO),,
> PartitionInfoProtocolDumpInformation},
> +
> +//
>  // PI Spec ones
>  //
>{STRING_TOKEN(STR_IDE_CONT_INIT),
> ,   NULL},
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> index cf849658aa..68bb00c620 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
> @@ -138,6 +138,7 @@
>  #include   #include
>   #include 
> +#include 
> 
>  #include 
>  #include 
> diff --git 

[edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.

2017-09-28 Thread Eric Dong
In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI,
this is not necessary. This change combine these 2 INIT-SIPI-SIPI to 1
and add CpuPause between them.

Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 112 +++---
 1 file changed, 44 insertions(+), 68 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 9404501..6dc4886 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -39,6 +39,11 @@ typedef struct {
 //
 SPIN_LOCK*mMemoryMappedLock = NULL;
 
+//
+// Signal that SMM BASE relocation is complete.
+//
+volatile BOOLEAN mInitApsAfterSmmBaseReloc;
+
 /**
   Get starting address and size of the rendezvous entry for APs.
   Information for fixing a jump instruction in the code is also returned.
@@ -343,62 +348,59 @@ SetProcessorRegister (
 }
 
 /**
-  AP initialization before SMBASE relocation in the S3 boot path.
+  Set registers for the current processor.
+
+  @param  RegisterTableListThe input registers list.
+
 **/
 VOID
-EarlyMPRendezvousProcedure (
-  VOID
+SetRegisters (
+  IN CPU_REGISTER_TABLE *RegisterTableList
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
   UINT32 InitApicId;
   UINTN  Index;
 
-  LoadMtrrData (mAcpiCpuData.MtrrTable);
-
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
   InitApicId = GetInitialApicId ();
   for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
 if (RegisterTableList[Index].InitialApicId == InitApicId) {
   SetProcessorRegister ([Index]);
-  break;
+  return;
 }
   }
-
-  //
-  // Count down the number with lock mechanism.
-  //
-  InterlockedDecrement ();
 }
 
 /**
-  AP initialization after SMBASE relocation in the S3 boot path.
+  AP initialization before then after SMBASE relocation in the S3 boot path.
 **/
 VOID
 MPRendezvousProcedure (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
   UINTN  TopOfStack;
   UINT8  Stack[128];
 
+  LoadMtrrData (mAcpiCpuData.MtrrTable);
+
+  SetRegisters ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable);
+
+  //
+  // Count down the number with lock mechanism.
+  //
+  InterlockedDecrement ();
+
+  //
+  // Wait for BSP to signal SMM Base relocation done.
+  //
+  while (!mInitApsAfterSmmBaseReloc) {
+CpuPause ();
+  }
+
   ProgramVirtualWireMode ();
   DisableLvtInterrupts ();
 
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetRegisters ((CPU_REGISTER_TABLE *) (UINTN) mAcpiCpuData.RegisterTable);
 
   //
   // Place AP into the safe code, count down the number with lock mechanism in 
the safe code.
@@ -473,34 +475,25 @@ PrepareApStartupVector (
 
 **/
 VOID
-EarlyInitializeCpu (
+InitializeCpuBeforeRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
-  //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-if (RegisterTableList[Index].InitialApicId == InitApicId) {
-  SetProcessorRegister ([Index]);
-  break;
-}
-  }
+  SetRegisters ((CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable);
 
   ProgramVirtualWireMode ();
 
   PrepareApStartupVector (mAcpiCpuData.StartupVector);
 
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) EarlyMPRendezvousProcedure;
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;
+
+  //
+  // Execute code for before SmmBaseReloc. Note: This flag is maintained 
across S3 boots.
+  //
+  mInitApsAfterSmmBaseReloc = FALSE;
 
   //
   // Send INIT IPI - SIPI to all APs
@@ -520,35 +513,18 @@ EarlyInitializeCpu (
 
 **/
 VOID
-InitializeCpu (
+InitializeCpuAfterRebase (
   VOID
   )
 {
-  CPU_REGISTER_TABLE *RegisterTableList;
-  UINT32 InitApicId;
-  UINTN  Index;
-
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.RegisterTable;
-  InitApicId = GetInitialApicId 

[edk2] [PATCH v2] ShellPkg/dh: Add the 'dh' dump support for Partition Info protocol

2017-09-28 Thread Hao Wu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=655

V2 change:
Put some strings into the UNI file for localization.

The dump information will include:
a. The type of the partition (Mbr, Gpt or Other);
b. Whether the partition is an EFI System Partition.

Cc: Ruiyu Ni 
Cc: Jaben Carsey 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c| 86 ++
 .../UefiHandleParsingLib/UefiHandleParsingLib.h|  1 +
 .../UefiHandleParsingLib/UefiHandleParsingLib.inf  |  1 +
 .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |  9 +++
 4 files changed, 97 insertions(+)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index d12466c7b0..a228226623 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1933,6 +1933,87 @@ ERROR_EXIT:
   return NULL;
 }
 
+/**
+  Function to dump information about Partition Information protocol.
+
+  This will allocate the return buffer from boot services pool.
+
+  @param[in] TheHandle  The handle that has the protocol installed.
+  @param[in] VerboseTRUE for additional information, FALSE otherwise.
+
+  @retval A pointer to a string containing the information.
+**/
+CHAR16*
+EFIAPI
+PartitionInfoProtocolDumpInformation (
+  IN CONST EFI_HANDLE TheHandle,
+  IN CONST BOOLEANVerbose
+  )
+{
+  EFI_STATUS  Status;
+  EFI_PARTITION_INFO_PROTOCOL *PartitionInfo;
+  CHAR16  *PartitionType;
+  CHAR16  *EfiSystemPartition;
+  CHAR16  *RetVal;
+
+  if (!Verbose) {
+return NULL;
+  }
+
+  Status = gBS->OpenProtocol (
+TheHandle,
+,
+(VOID**),
+gImageHandle,
+NULL,
+EFI_OPEN_PROTOCOL_GET_PROTOCOL
+);
+  if (EFI_ERROR (Status)) {
+return NULL;
+  }
+
+  HandleParsingHiiInit ();
+
+  switch (PartitionInfo->Type) {
+  case PARTITION_TYPE_OTHER:
+PartitionType = HiiGetString (mHandleParsingHiiHandle, 
STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_OTHER), NULL);
+break;
+  case PARTITION_TYPE_MBR:
+PartitionType = HiiGetString (mHandleParsingHiiHandle, 
STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_MBR), NULL);
+break;
+  case PARTITION_TYPE_GPT:
+PartitionType = HiiGetString (mHandleParsingHiiHandle, 
STRING_TOKEN(STR_PARTINFO_DUMP_TYPE_GPT), NULL);
+break;
+  default:
+PartitionType = NULL;
+break;
+  }
+  if (PartitionType == NULL) {
+return NULL;
+  }
+
+  if (PartitionInfo->System == 1) {
+EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, 
STRING_TOKEN(STR_PARTINFO_DUMP_EFI_SYS_PART), NULL);
+  } else {
+EfiSystemPartition = HiiGetString (mHandleParsingHiiHandle, 
STRING_TOKEN(STR_PARTINFO_DUMP_NOT_EFI_SYS_PART), NULL);
+  }
+  if (EfiSystemPartition == NULL) {
+SHELL_FREE_NON_NULL (PartitionType);
+return NULL;
+  }
+
+  RetVal = CatSPrint (
+ NULL,
+ L"%s\r\n%s",
+ PartitionType,
+ EfiSystemPartition
+ );
+
+  SHELL_FREE_NON_NULL (EfiSystemPartition);
+  SHELL_FREE_NON_NULL (PartitionType);
+  return RetVal;
+}
+
 //
 // Put the information on the NT32 protocol GUIDs here so we are not dependant 
on the Nt32Pkg
 //
@@ -2147,6 +2228,11 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_ADAPTER_INFO),  
,  
AdapterInformationDumpInformation},
 
 //
+// UEFI 2.7
+//
+  {STRING_TOKEN(STR_PARTITION_INFO),,
   PartitionInfoProtocolDumpInformation},
+
+//
 // PI Spec ones
 //
   {STRING_TOKEN(STR_IDE_CONT_INIT), 
,   NULL},
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
index cf849658aa..68bb00c620 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
@@ -138,6 +138,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 4c1c3d3846..ee1b85552b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -292,6 +292,7 @@
   gEfiHttpProtocolGuid## UNDEFINED
   gEfiHttpUtilitiesProtocolGuid   ## UNDEFINED
   gEfiRestProtocolGuid## UNDEFINED
+  gEfiPartitionInfoProtocolGuid   ## CONSUMES
 
 [Guids]
   

[edk2] [Patch] BaseTools: PI 1.6 to support FV extended header contain FV used size

2017-09-28 Thread Yonghong Zhu
From: Yunhua Feng 

Per PI 1.6 we added an FV Extended Header entry that would contain the
size of the FV that was in use.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c  | 19 +--
 BaseTools/Source/C/GenFv/GenFvInternalLib.h  |  3 ++-
 BaseTools/Source/C/Include/Common/PiFirmwareVolume.h |  6 ++
 BaseTools/Source/Python/GenFds/FdfParser.py  |  2 +-
 BaseTools/Source/Python/GenFds/Fv.py | 20 +++-
 5 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 01c862e..5b219b3 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -42,10 +42,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION   0xEB00
 #define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION  0x1400
 
 BOOLEAN mArm = FALSE;
 STATIC UINT32   MaxFfsAlignment = 0;
+BOOLEAN VtfFileFlag = FALSE;
 
 EFI_GUID  mEfiFirmwareVolumeTopFileGuid   = EFI_FFS_VOLUME_TOP_FILE_GUID;
 EFI_GUID  mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV];
 EFI_GUID  mZeroGuid   = {0x0, 0x0, 0x0, {0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
 EFI_GUID  mDefaultCapsuleGuid = {0x3B6686BD, 0x0D76, 0x4030, { 
0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 }};
@@ -598,10 +599,11 @@ Returns:
 {
   EFI_FFS_FILE_HEADER *PadFile;
   UINTN   PadFileSize;
   UINT32  NextFfsHeaderSize;
   UINT32  CurFfsHeaderSize;
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *FvUsedSize;
 
   CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
   //
   // Verify input parameters.
   //
@@ -703,10 +705,25 @@ Returns:
 
   if (ExtHeader != NULL) {
 //
 // Copy Fv Extension Header and Set Fv Extension header offset
 //
+if (ExtHeader->ExtHeaderSize > sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER)) {
+  FvUsedSize = 
malloc(sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
+  if (FvUsedSize == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+  memcpy(FvUsedSize, ExtHeader + 1, 
sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
+  if (FvUsedSize->Hdr.ExtEntryType == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {
+if (VtfFileFlag) {
+  FvUsedSize->UsedSize = mFvTotalSize;
+} else {
+  FvUsedSize->UsedSize = mFvTakenSize;
+}
+memcpy(ExtHeader + 1, FvUsedSize, 
sizeof(EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE));
+  }
+ }
 memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, 
ExtHeader->ExtHeaderSize);
 ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = 
(UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize) - (UINTN) 
FvImage->FileImage);
  //
  // Make next file start at QWord Boundry
  //
@@ -3057,16 +3074,14 @@ Returns:
   UINTN   FfsFileSize;
   UINTN   FvExtendHeaderSize;
   UINT32  FfsAlignment;
   UINT32  FfsHeaderSize;
   EFI_FFS_FILE_HEADER FfsHeader;
-  BOOLEAN VtfFileFlag;
   UINTN   VtfFileSize;
   
   FvExtendHeaderSize = 0;
   VtfFileSize = 0;
-  VtfFileFlag = FALSE;
   fpin  = NULL;
   Index = 0;
 
   //
   // Compute size for easy access later
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
index f039fa4..9b1abe7 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
@@ -1,10 +1,10 @@
 /** @file
 This file contains describes the public interfaces to the GenFvImage Library.
 The basic purpose of the library is to create Firmware Volume images.
   
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
 This program and the accompanying materials  
 are licensed and made available under the terms and conditions of the BSD 
License 
 which accompanies this distribution.  The full text of the license may be 
found at
 http://opensource.org/licenses/bsd-license.php 
   

   
@@ -256,10 +256,11 @@ extern FV_INFOmFvDataInfo;
 extern CAP_INFO   mCapDataInfo;
 extern EFI_GUID   mEfiFirmwareFileSystem2Guid;
 extern EFI_GUID   mEfiFirmwareFileSystem3Guid;
 extern UINT32 mFvTotalSize;
 extern UINT32 mFvTakenSize;
+extern BOOLEANVtfFileFlag;
 
 extern EFI_PHYSICAL_ADDRESS mFvBaseAddress[];
 extern UINT32   mFvBaseAddressNumber;
 

Re: [edk2] [Patch V2] Build spec: add description for build with binary cache

2017-09-28 Thread Laszlo Ersek
On 09/19/17 08:48, Yonghong Zhu wrote:
> V2:
> change the option name to --binary-destination and --binary-source.
> 
> fixes:https://bugzilla.tianocore.org/show_bug.cgi?id=689

What are the benefits of a hash-based incremental build over a
timestamp-based incremental build?

Thank you,
Laszlo

> Cc: Liming Gao 
> Cc: Michael Kinney 
> Cc: Kevin W Shaw 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu 
> ---
>  .../82_auto-generation_process.md| 20 
> 
>  README.md|  1 +
>  appendix_d_buildexe_command/d4_usage.md  | 19 +++
>  3 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md 
> b/8_pre-build_autogen_stage/82_auto-generation_process.md
> index 671a7d5..f2ddf32 100644
> --- a/8_pre-build_autogen_stage/82_auto-generation_process.md
> +++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
> @@ -1031,10 +1031,30 @@ maximum command line length.  The default value is 
> 4096.
>  **Note:** The following `FLAGS` options are included in the response file:
>  `PP_FLAGS`, `CC_FLAGS`, `VFRPP_FLAGS`, `APP_FLAGS`, `ASLPP_FLAGS`, 
> `ASLCC_FLAGS`,
>  and `ASM_FLAGS`.
>  **
>  
> + 8.2.4.15 Build with Binary Cache
> +
> +**build** tool provides three new options for binary cache feature.
> +--hash enables hash-based caching during build process. when --hash is 
> enabled,
> +build tool will base on the module hash value to do the incremental build, 
> without
> +--hash, build tool will base on the timestamp to do the incremental build. 
> --hash
> +option use md5 method to get every hash value, DSC/FDF, tools_def.txt, 
> build_rule.txt
> +and build command are calculated as global hash value, Package DEC and its 
> include
> +header files are calculated as package hash value, Module source files and 
> its INF
> +file are calculated as module hash value. Library hash value will combine 
> the global
> +hash value and its dependent package hash value. Driver hash value will 
> combine the
> +global hash value, its dependent package hash value and its linked library 
> hash value.
> +When --hash and --binary-destination are specified, build tool will copy the 
> generated
> +binary files for each module into the directory specified by 
> binary-destination at the
> +build phase. Binary-destination directory caches all the generated binary 
> files.
> +When --hash and --binary-source are specified, build tool will try to get 
> the binary
> +files from the binary source directory at the build phase. If the cached 
> binary has
> +the same hash value, it will be directly used. Otherwise, build tool will 
> compile the
> +source files and generate the binary files.
> +
>  ### 8.2.5 Post processing
>  
>  Once all files are parsed, the build tools will do following work for each 
> EDK
>  II module:
>  
> diff --git a/README.md b/README.md
> index 52abb6a..ca59a35 100644
> --- a/README.md
> +++ b/README.md
> @@ -215,5 +215,6 @@ Copyright (c) 2008-2017, Intel Corporation. All rights 
> reserved.
>  || [#523](https://bugzilla.tianocore.org/show_bug.cgi?id=523) 
> Build spec: add EBNF for the --pcd syntax in the Section D.4  
>   
>   
>|  
>  |
>  || [#517](https://bugzilla.tianocore.org/show_bug.cgi?id=517) 
> Build spec: chapter 5.2.2 Guided Tools add description for Pkcs7Sign tool and 
> BrotliCompress tool   
>   
>|  
>  |
>  || [#481](https://bugzilla.tianocore.org/show_bug.cgi?id=481) 
> Build Spec: add clarification for not used Pcd that build tool will not do 
> additional checks on its value
>   
>   |   
> |
>  || [#518](https://bugzilla.tianocore.org/show_bug.cgi?id=518) 
> Build Spec: Update Precedence of PCD Values   
>   
>   
>|  
>  |
>  || [#669](https://bugzilla.tianocore.org/show_bug.cgi?id=669) 
> Build Spec: Add 

Re: [edk2] [PATCH v3 6/6] OvmfPkg/QemuVideoDxe: Bypass NULL pointer detection during VBE SHIM installing

2017-09-28 Thread Laszlo Ersek
On 09/28/17 03:03, Jian J Wang wrote:
> QemuVideoDxe driver will link VBE SHIM into page 0. If NULL pointer
> detection is enabled, this driver will fail to load. NULL pointer detection
> bypassing code is added to prevent such problem during boot.
> 
> Please note that Windows 7 will try to access VBE SHIM during boot if it's
> installed, and then cause boot failure. This can be fixed by setting BIT7
> of PcdNullPointerDetectionPropertyMask to disable NULL pointer detection
> after EndOfDxe. As far as we know, there's no other OSs has such issue.
> 
>> According to Laszlo, remove the code disabling/enabling the NULL pointer
>> detection but just ignore the installing if it's enabled
> 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> Cc: Jiewen Yao 
> Cc: Michael Kinney 
> Cc: Jordan Justen 
> Cc: Ayellet Wolman 
> Suggested-by: Ayellet Wolman 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf |  1 +
>  OvmfPkg/QemuVideoDxe/VbeShim.c| 14 ++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf 
> b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> index 577e07b0a8..ff68c99e96 100644
> --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> @@ -77,3 +77,4 @@
>  [Pcd]
>gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion
>gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.c b/OvmfPkg/QemuVideoDxe/VbeShim.c
> index e45a08e887..8ba5522cde 100644
> --- a/OvmfPkg/QemuVideoDxe/VbeShim.c
> +++ b/OvmfPkg/QemuVideoDxe/VbeShim.c
> @@ -75,6 +75,20 @@ InstallVbeShim (
>UINTNPrinted;
>VBE_MODE_INFO*VbeModeInfo;
>  
> +  if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT0|BIT7)) == BIT0) 
> {
> +DEBUG ((
> +  DEBUG_WARN,
> +  "%a: page 0 protected, not installing VBE shim\n",
> +  __FUNCTION__
> +  ));
> +DEBUG ((
> +  DEBUG_WARN,
> +  "%a: page 0 protection prevents Windows 7 from booting anyway\n",
> +  __FUNCTION__
> +  ));
> +return;
> +  }
> +
>Segment0 = 0x0;
>SegmentC = 0xC;
>SegmentF = 0xF;
> 

Reviewed-by: Laszlo Ersek 

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


Re: [edk2] [Patch 0/2] Clarify the usage of HttpConfigData in HTTP protocol

2017-09-28 Thread Ye, Ting
Series Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Jiaxin 
Sent: Thursday, September 28, 2017 1:42 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [Patch 0/2] Clarify the usage of HttpConfigData in HTTP protocol

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdePkg/Http.h: Clarify the usage of HttpConfigData in HTTP protocol
  NetworkPkg/HttpDxe: Clarify the usage of HttpConfigData in HTTP
protocol

 MdePkg/Include/Protocol/Http.h | 16 +---  
NetworkPkg/HttpDxe/HttpImpl.c  | 20 +++-  
NetworkPkg/HttpDxe/HttpImpl.h  | 18 ++
 3 files changed, 30 insertions(+), 24 deletions(-)

--
1.9.5.msysgit.1

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


Re: [edk2] [Patch] NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check

2017-09-28 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Jiaxin 
Sent: Thursday, September 28, 2017 1:49 PM
To: edk2-devel@lists.01.org
Cc: Santhapur Naveen ; Ye, Ting ; 
Fu, Siyuan ; Wu, Jiaxin 
Subject: [Patch] NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check

Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 568360d..9f5be15 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1,9 +1,9 @@
 /** @file
   Support functions implementation for UefiPxeBc Driver.
 
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -422,11 +422,11 @@ PxeBcIcmp6ErrorDpcHandle (
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
 
   if (Type != ICMP_V6_DEST_UNREACHABLE &&
   Type != ICMP_V6_PACKET_TOO_BIG &&
-  Type != ICMP_V6_PACKET_TOO_BIG &&
+  Type != ICMP_V6_TIME_EXCEEDED &&
   Type != ICMP_V6_PARAMETER_PROBLEM) {
 //
 // The type of the receveid packet should be an ICMP6 error message.
 //
 gBS->SignalEvent (RxData->RecycleSignal);
-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH v3 4/5] MdeModulePkg/DxeNetLib: Fix negative value left shift

2017-09-28 Thread Ye, Ting
Reviewed-by: Ye Ting  

-Original Message-
From: Wu, Hao A 
Sent: Thursday, September 28, 2017 12:32 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Shi, Steven ; Fu, 
Siyuan ; Ye, Ting ; Wu, Jiaxin 
; Long, Qin ; Zeng, Star 
; Dong, Eric ; Paolo Bonzini 

Subject: [PATCH v3 4/5] MdeModulePkg/DxeNetLib: Fix negative value left shift

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=698

Within function NetRandomInitSeed(), left shift a negative value is used
in:
"~Time.Hour << 24"

which involves undefined behavior.

Since Time.Hour is of type UINT8 (range from 0 to 23), hence ~Time.Hour will be 
a negative value (of type int, signed).

According to the C11 spec, Section 6.5.7:
> 4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
>   bits are filled with zeros. If E1 has an unsigned type, the value
>   of the result is E1 * 2^E2 , reduced modulo one more than the
>   maximum value representable in the result type. If E1 has a signed
>   type and nonnegative value, and E1 * 2^E2 is representable in the
>   result type, then that is the resulting value; otherwise, the
>   behavior is undefined.

This commit will remove the '~' operator before 'Time.Hour', since it seems 
like an implementation choice for generating the seed.

Cc: Steven Shi 
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Cc: Qin Long 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 7cd7e3aca0..1ee77fe036 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -872,7 +872,7 @@ NetRandomInitSeed (
   UINT64MonotonicCount;
 
   gRT->GetTime (, NULL);
-  Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
+  Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | 
+ Time.Second);
   Seed ^= Time.Nanosecond;
   Seed ^= Time.Year << 7;
 
--
2.12.0.windows.1

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


Re: [edk2] [Patch] NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check

2017-09-28 Thread Fu, Siyuan


Reviewed-by: Fu Siyuan 



-Original Message-
From: Wu, Jiaxin 
Sent: Thursday, September 28, 2017 1:49 PM
To: edk2-devel@lists.01.org
Cc: Santhapur Naveen ; Ye, Ting ; 
Fu, Siyuan ; Wu, Jiaxin 
Subject: [Patch] NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check

Cc: Santhapur Naveen 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c 
b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
index 568360d..9f5be15 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c
@@ -1,9 +1,9 @@
 /** @file
   Support functions implementation for UefiPxeBc Driver.
 
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
   http://opensource.org/licenses/bsd-license.php.
@@ -422,11 +422,11 @@ PxeBcIcmp6ErrorDpcHandle (
 
   Type = *((UINT8 *) RxData->FragmentTable[0].FragmentBuffer);
 
   if (Type != ICMP_V6_DEST_UNREACHABLE &&
   Type != ICMP_V6_PACKET_TOO_BIG &&
-  Type != ICMP_V6_PACKET_TOO_BIG &&
+  Type != ICMP_V6_TIME_EXCEEDED &&
   Type != ICMP_V6_PARAMETER_PROBLEM) {
 //
 // The type of the receveid packet should be an ICMP6 error message.
 //
 gBS->SignalEvent (RxData->RecycleSignal);
-- 
1.9.5.msysgit.1

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


Re: [edk2] [Patch 0/2] Clarify the usage of HttpConfigData in HTTP protocol

2017-09-28 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 



-Original Message-
From: Wu, Jiaxin 
Sent: Thursday, September 28, 2017 1:42 PM
To: edk2-devel@lists.01.org
Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jiaxin 

Subject: [Patch 0/2] Clarify the usage of HttpConfigData in HTTP protocol

Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 

Jiaxin Wu (2):
  MdePkg/Http.h: Clarify the usage of HttpConfigData in HTTP protocol
  NetworkPkg/HttpDxe: Clarify the usage of HttpConfigData in HTTP
protocol

 MdePkg/Include/Protocol/Http.h | 16 +---
 NetworkPkg/HttpDxe/HttpImpl.c  | 20 +++-
 NetworkPkg/HttpDxe/HttpImpl.h  | 18 ++
 3 files changed, 30 insertions(+), 24 deletions(-)

-- 
1.9.5.msysgit.1

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


Re: [edk2] [PATCH v3 4/5] MdeModulePkg/DxeNetLib: Fix negative value left shift

2017-09-28 Thread Fu, Siyuan
Looks good to me.

Reviewed-by: Fu Siyuan 

-Original Message-
From: Wu, Hao A 
Sent: Thursday, September 28, 2017 12:32 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A ; Shi, Steven ; Fu, 
Siyuan ; Ye, Ting ; Wu, Jiaxin 
; Long, Qin ; Zeng, Star 
; Dong, Eric ; Paolo Bonzini 

Subject: [PATCH v3 4/5] MdeModulePkg/DxeNetLib: Fix negative value left shift

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=698

Within function NetRandomInitSeed(), left shift a negative value is used
in:
"~Time.Hour << 24"

which involves undefined behavior.

Since Time.Hour is of type UINT8 (range from 0 to 23), hence ~Time.Hour
will be a negative value (of type int, signed).

According to the C11 spec, Section 6.5.7:
> 4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
>   bits are filled with zeros. If E1 has an unsigned type, the value
>   of the result is E1 * 2^E2 , reduced modulo one more than the
>   maximum value representable in the result type. If E1 has a signed
>   type and nonnegative value, and E1 * 2^E2 is representable in the
>   result type, then that is the resulting value; otherwise, the
>   behavior is undefined.

This commit will remove the '~' operator before 'Time.Hour', since it
seems like an implementation choice for generating the seed.

Cc: Steven Shi 
Cc: Fu Siyuan 
Cc: Ye Ting 
Cc: Wu Jiaxin 
Cc: Qin Long 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Paolo Bonzini 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c 
b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
index 7cd7e3aca0..1ee77fe036 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
@@ -872,7 +872,7 @@ NetRandomInitSeed (
   UINT64MonotonicCount;
 
   gRT->GetTime (, NULL);
-  Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
+  Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
   Seed ^= Time.Nanosecond;
   Seed ^= Time.Year << 7;
 
-- 
2.12.0.windows.1

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


[edk2] [PATCH] MdeModulePkg/DxeCore: Add comments for the ASSERT to check NULL ptr

2017-09-28 Thread Hao Wu
Commit 8932679df5be046feba30fae80776c5815232a08 adds an ASSERT for
checking NULL pointer dereference.

This commit adds comments to clarify the reason for using ASSERT as the
check.

Cc: Star Zeng 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
---
 MdeModulePkg/Core/Dxe/Hand/Handle.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c 
b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index 2db441725c..344ff1fe02 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -1175,10 +1175,15 @@ Done:
 //
 if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
   //
+  // According to above logic, if 'Prot' is NULL, then the 'Status' must be
+  // EFI_UNSUPPORTED. Here the 'Status' is not EFI_UNSUPPORTED, so 'Prot'
+  // must be not NULL.
+  //
+  ASSERT (Prot != NULL);
+  //
   // EFI_ALREADY_STARTED is not an error for bus driver.
   // Return the corresponding protocol interface.
   //
-  ASSERT (Prot != NULL);
   *Interface = Prot->Interface;
 } else if (Status == EFI_UNSUPPORTED) {
   //
-- 
2.12.0.windows.1

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


Re: [edk2] [PATCH v3] CryptoPkg: Add new API to retrieve commonName of X.509 certificate

2017-09-28 Thread Long, Qin
Yes, they are legacy version with old style alignment.
It's first try to address this return status change in this new API.  We may 
update some APIs depending on requirement and impacts evaluations later. 


Best Regards & Thanks,
LONG, Qin

-Original Message-
From: Zhang, Chao B 
Sent: Thursday, September 28, 2017 2:03 PM
To: Long, Qin ; ler...@redhat.com; Ye, Ting 

Cc: edk2-devel@lists.01.org
Subject: RE: [PATCH v3] CryptoPkg: Add new API to retrieve commonName of X.509 
certificate

Qin:  
   What about other X509 related interface, such as X509GetTBSCert, 
X509GetSubjectName. They all return TRUE/FALSE.
   It looks inconsistent between these interfaces


-Original Message-
From: Long, Qin
Sent: Thursday, September 21, 2017 10:48 AM
To: ler...@redhat.com; Ye, Ting ; Zhang, Chao B 

Cc: edk2-devel@lists.01.org
Subject: [PATCH v3] CryptoPkg: Add new API to retrieve commonName of X.509 
certificate

v3: Add extra CommonNameSize check since OpenSSL didn't check this
input parameter. (One openssl issue was filed to address this risk:
https://github.com/openssl/openssl/issues/4392)
v2: Update function interface to return RETURN_STATUS to represent
different error cases.

Add one new API (X509GetCommonName()) to retrieve the subject commonName string 
from one X.509 certificate.

Cc: Laszlo Ersek 
Cc: Ting Ye 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long 
---
 CryptoPkg/Application/Cryptest/RsaVerify2.c|  32 --
 CryptoPkg/Include/Library/BaseCryptLib.h   |  35 +++
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c  | 109 +
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c  |  32 ++
 .../Pk/CryptX509Null.c |  34 ++-
 5 files changed, 234 insertions(+), 8 deletions(-)

diff --git a/CryptoPkg/Application/Cryptest/RsaVerify2.c 
b/CryptoPkg/Application/Cryptest/RsaVerify2.c
index 98b5aad900..9db43d6eef 100644
--- a/CryptoPkg/Application/Cryptest/RsaVerify2.c
+++ b/CryptoPkg/Application/Cryptest/RsaVerify2.c
@@ -204,13 +204,17 @@ ValidateCryptRsa2 (
   VOID
   )
 {
-  BOOLEAN  Status;
-  VOID *RsaPrivKey;
-  VOID *RsaPubKey;
-  UINT8*Signature;
-  UINTNSigSize;
-  UINT8*Subject;
-  UINTNSubjectSize;
+  BOOLEANStatus;
+  VOID   *RsaPrivKey;
+  VOID   *RsaPubKey;
+  UINT8  *Signature;
+  UINTN  SigSize;
+  UINT8  *Subject;
+  UINTN  SubjectSize;
+  RETURN_STATUS  ReturnStatus;
+  CHAR8  CommonName[64];
+  CHAR16 CommonNameUnicode[64];
+  UINTN  CommonNameSize;
 
   Print (L"\nUEFI-OpenSSL RSA Key Retrieving Testing: ");
 
@@ -286,6 +290,20 @@ ValidateCryptRsa2 (
 Print (L"[Pass]");
   }
 
+  //
+  // Get CommonName from X509 Certificate Subject  //  CommonNameSize = 
+ 64;  ZeroMem (CommonName, CommonNameSize);  ReturnStatus = 
+ X509GetCommonName (TestCert, sizeof (TestCert), CommonName, 
+ );  if (RETURN_ERROR (ReturnStatus)) {
+Print (L"\n  - Retrieving Common Name - [Fail]");
+return EFI_ABORTED;
+  } else {
+AsciiStrToUnicodeStrS (CommonName, CommonNameUnicode, CommonNameSize);
+Print (L"\n  - Retrieving Common Name = \"%s\" (Size = %d)", 
+ CommonNameUnicode, CommonNameSize);  }
+
   //
   // X509 Certificate Verification.
   //
diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
b/CryptoPkg/Include/Library/BaseCryptLib.h
index 9c5ffcd9cf..2366a0218d 100644
--- a/CryptoPkg/Include/Library/BaseCryptLib.h
+++ b/CryptoPkg/Include/Library/BaseCryptLib.h
@@ -2171,6 +2171,41 @@ X509GetSubjectName (
   IN OUT  UINTN*SubjectSize
   );
 
+/**
+  Retrieve the common name (CN) string from one X.509 certificate.
+
+  @param[in]  Cert Pointer to the DER-encoded X509 certificate.
+  @param[in]  CertSize Size of the X509 certificate in bytes.
+  @param[out] CommonName   Buffer to contain the retrieved certificate 
common
+   name string. At most CommonNameSize bytes 
will be
+   written and the string will be null 
terminated. May be
+   NULL in order to determine the size buffer 
needed.
+  @param[in,out]  CommonNameSize   The size in bytes of the CommonName buffer 
on input,
+   and the size of buffer returned CommonName 
on output.
+   If CommonName is NULL then the amount of 
space needed
+   in buffer (including the final null) is 
returned.
+
+  @retval RETURN_SUCCESS   The certificate CommonName retrieved 
successfully.
+  @retval RETURN_INVALID_PARAMETER If Cert is NULL.
+   If CommonNameSize is NULL.
+ 

Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Wang, Sunny (HPS SW)
The change Looks good to me. 
Also, Good to see you adding the comment about why we need to cache BootNext 
before all the platform hook function calls. :)

Reviewed-by: Sunny Wang 

Regards,
Sunny Wang

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, September 28, 2017 1:50 PM
To: edk2-devel@lists.01.org
Cc: Eric Dong ; Star Zeng 
Subject: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until 
booting it

Current implementation deletes the "BootNext" before calling any 
PlatformBootManagerLib APIs, but if system resets in PlatformBootManagerLib 
APIs, "BootNext" is not consumed but lost.

The patch defers the deletion of "BootNext" to before booting it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Eric Dong 
Cc: Star Zeng 
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35 ++--
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index ac5f9088dd..a6fe617b56 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -808,7 +808,8 @@ BdsEntry (
   ASSERT_EFI_ERROR (Status);
 
   //
-  // Cache and remove the "BootNext" NV variable.
+  // Cache the "BootNext" NV variable before calling any 
+ PlatformBootManagerLib APIs  // This could avoid the "BootNext" set by 
PlatformBootManagerLib be consumed in this boot.
   //
   GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) , 
);
   if (DataSize != sizeof (UINT16)) {
@@ -817,17 +818,6 @@ BdsEntry (
 }
 BootNext = NULL;
   }
-  Status = gRT->SetVariable (
-  EFI_BOOT_NEXT_VARIABLE_NAME,
-  ,
-  0,
-  0,
-  NULL
-  );
-  //
-  // Deleting NV variable shouldn't fail unless it doesn't exist.
-  //
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
 
   //
   // Initialize the platform language variables @@ -1052,10 +1042,25 @@ 
BdsEntry (
 
 EfiBootManagerHotkeyBoot ();
 
-//
-// Boot to "BootNext"
-//
 if (BootNext != NULL) {
+  //
+  // Delete "BootNext" NV variable before transferring control to it to 
prevent loops.
+  //
+  Status = gRT->SetVariable (
+  EFI_BOOT_NEXT_VARIABLE_NAME,
+  ,
+  0,
+  0,
+  NULL
+  );
+  //
+  // Deleting NV variable shouldn't fail unless it doesn't exist.
+  //
+  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
+
+  //
+  // Boot to "BootNext"
+  //
   UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), 
L"Boot%04x", *BootNext);
   Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, 
);
   if (!EFI_ERROR (Status)) {
--
2.12.2.windows.2

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


[edk2] [PATCH 1/2] ShellPkg/dh: Add mapping of new UEFI/PI protocols

2017-09-28 Thread Ruiyu Ni
From: Huajing Li 

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Huajing Li 
Reviewed-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c| 56 ++
 .../UefiHandleParsingLib/UefiHandleParsingLib.inf  | 40 
 .../UefiHandleParsingLib/UefiHandleParsingLib.uni  | 44 +
 3 files changed, 140 insertions(+)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index d12466c7b0..06f9d26e5f 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -2147,6 +2147,37 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_ADAPTER_INFO),  
,  
AdapterInformationDumpInformation},
 
 //
+// UEFI2.5
+//
+  {STRING_TOKEN(STR_TLS_SB),
,  NULL},
+  {STRING_TOKEN(STR_TLS),   ,  
  NULL},
+  {STRING_TOKEN(STR_TLS_CONFIG),, 
  NULL},
+  {STRING_TOKEN(STR_SUPPLICANT_SB), 
,   NULL},
+  {STRING_TOKEN(STR_SUPPLICANT),,   
  NULL},
+
+//
+// UEFI2.6
+//
+  {STRING_TOKEN(STR_WIFI2), ,
  NULL},
+  {STRING_TOKEN(STR_RAMDISK),   ,  
  NULL},
+  {STRING_TOKEN(STR_HII_ID),,  
  NULL},
+  {STRING_TOKEN(STR_HII_IE),,   
  NULL},
+  {STRING_TOKEN(STR_SD_MPT),,
  NULL},
+  {STRING_TOKEN(STR_ERASE_BLOCK),   ,   
  NULL},
+
+//
+// UEFI2.7
+//
+  {STRING_TOKEN(STR_BLUETOOTH_ATTR),
,   NULL},
+  {STRING_TOKEN(STR_BLUETOOTH_ATTR_SB), 
, NULL},
+  {STRING_TOKEN(STR_BLUETOOTH_LE_CONFIG),   
,NULL},
+  {STRING_TOKEN(STR_UFS_DEV_CONFIG),,  
NULL},
+  {STRING_TOKEN(STR_HTTP_BOOT_CALL),, 
NULL},
+  {STRING_TOKEN(STR_RESET_NOTI),
,NULL},
+  {STRING_TOKEN(STR_PARTITION_INFO),,
NULL},
+  {STRING_TOKEN(STR_HII_POPUP), , 
NULL},
+
+//
 // PI Spec ones
 //
   {STRING_TOKEN(STR_IDE_CONT_INIT), 
,   NULL},
@@ -2271,6 +2302,31 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_REST),  , 
   NULL},
 
 //
+// PI 1.5
+//
+  {STRING_TOKEN(STR_MM_EOD),,   
   NULL},
+  {STRING_TOKEN(STR_MM_ITD),, 
   NULL},
+  {STRING_TOKEN(STR_MM_PBD),
,   NULL},
+  {STRING_TOKEN(STR_MM_SBD),
, NULL},
+  {STRING_TOKEN(STR_MM_GD), ,
   NULL},
+  {STRING_TOKEN(STR_MM_UD), ,
   NULL},
+  {STRING_TOKEN(STR_MM_PTD),
, NULL},
+  {STRING_TOKEN(STR_MM_SXD),, 
   NULL},
+  {STRING_TOKEN(STR_MM_SWD),, 
   NULL},
+  {STRING_TOKEN(STR_MM_PRBI),   
,   NULL},
+  {STRING_TOKEN(STR_MM_CPU),,
   NULL},
+  {STRING_TOKEN(STR_MM_STACODE),, 
   NULL},
+  {STRING_TOKEN(STR_DXEMM_RTL), , 
   NULL},
+  {STRING_TOKEN(STR_MM_CONFIG), ,  
   NULL},
+  {STRING_TOKEN(STR_MM_RTL),,
   NULL},
+  {STRING_TOKEN(STR_MM_CONTROL),,
   NULL},
+  {STRING_TOKEN(STR_MM_ACCESS), , 
   NULL},
+  {STRING_TOKEN(STR_MM_BASE),   ,   
   NULL},
+  {STRING_TOKEN(STR_MM_CPUIO),  ,  
   NULL},
+  {STRING_TOKEN(STR_MM_RH), , 
   NULL},
+  {STRING_TOKEN(STR_MM_COM),,  
   NULL},
+
+//
 // UEFI Shell Spec 2.0
 //
   {STRING_TOKEN(STR_SHELL_PARAMETERS),  ,  
   NULL},
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 4c1c3d3846..1ab208e328 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -292,6 +292,46 @@ [Protocols]
   gEfiHttpProtocolGuid## UNDEFINED
   gEfiHttpUtilitiesProtocolGuid   ## UNDEFINED
   gEfiRestProtocolGuid## UNDEFINED
+  gEfiMmEndOfDxeProtocolGuid  ## UNDEFINED
+  gEfiMmIoTrapDispatchProtocolGuid 

[edk2] [PATCH 2/2] ShellPkg/UefiHandleParsingLib.c: Map SmmPciRootBridgeIo correctly

2017-09-28 Thread Ruiyu Ni
From: Huajing Li 

The current implementation has a typo that maps SmmPciRootBridgeIo
to "PciRootBridgeIo".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Huajing Li 
Reviewed-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 06f9d26e5f..489decfaf8 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -2229,7 +2229,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
   {STRING_TOKEN(STR_S_COMM),, 
   NULL},
   {STRING_TOKEN(STR_S_STAT),,
   NULL},
   {STRING_TOKEN(STR_S_CPU), ,   
   NULL},
-  {STRING_TOKEN(STR_S_PCIRBIO), ,  
   NULL},
+  {STRING_TOKEN(STR_S_PCIRBIO), 
,  NULL},
   {STRING_TOKEN(STR_S_SWD), ,   
   NULL},
   {STRING_TOKEN(STR_S_SXD), ,   
   NULL},
   {STRING_TOKEN(STR_S_PTD2),
,   NULL},
-- 
2.12.2.windows.2

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


[edk2] [PATCH 0/2] Add mapping of new UEFI/PI protocols

2017-09-28 Thread Ruiyu Ni
Huajing Li (2):
  ShellPkg/dh: Add mapping of new UEFI/PI protocols
  ShellPkg/UefiHandleParsingLib.c: Map SmmPciRootBridgeIo correctly

 .../UefiHandleParsingLib/UefiHandleParsingLib.c| 58 +-
 .../UefiHandleParsingLib/UefiHandleParsingLib.inf  | 40 +++
 .../UefiHandleParsingLib/UefiHandleParsingLib.uni  | 44 
 3 files changed, 141 insertions(+), 1 deletion(-)

-- 
2.12.2.windows.2

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


[edk2] [Patch] FDF Spec: Per PI 1.6 to support FV extended header contain FV used size

2017-09-28 Thread Yonghong Zhu
Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 2_fdf_design_discussion/25_[fv]_sections.md  | 2 +-
 3_edk_ii_fdf_file_format/36_[fv]_sections.md | 2 ++
 README.md| 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/2_fdf_design_discussion/25_[fv]_sections.md 
b/2_fdf_design_discussion/25_[fv]_sections.md
index 82755dd..7b50017 100644
--- a/2_fdf_design_discussion/25_[fv]_sections.md
+++ b/2_fdf_design_discussion/25_[fv]_sections.md
@@ -57,11 +57,11 @@ previously defined sections within another FV section. This 
eliminates the need
 to re-specify components or modules in multiple places. When the `FvNameString`
 entry is present and set to TRUE in an `[FV]` section, the tools will generate
 an `FvNameString` entry in FV EXT header using the `UiFvName`.
 
 This section also specifies how to define content for PI FV Extensions which
-provides a mapping between a GUID and an OEM file type. The size of
+provides a mapping for a GUID, an OEM file type and FV used size. The size of
 `EFI_FIRMWARE_VOLUME_EXT_HEADER` and `EFI_FIRMWARE_VOLUME_EXT_ENTRY` sizes will
 be calculated based on content, while the `EFI_FIRMWARE_VOLUME_EXT_ENTRY` type
 must be defined by the platform integrator based on the PI specification,
 volume 3 The content is limited to the contents of a binary file specified by a
 FILE statement or a data array specified by a `DATA` statement.
diff --git a/3_edk_ii_fdf_file_format/36_[fv]_sections.md 
b/3_edk_ii_fdf_file_format/36_[fv]_sections.md
index f2d34cf..b4f292a 100644
--- a/3_edk_ii_fdf_file_format/36_[fv]_sections.md
+++ b/3_edk_ii_fdf_file_format/36_[fv]_sections.md
@@ -74,10 +74,11 @@ Conditional statements may be used anywhere within this 
section.
   ::= []
 []
 []
 []
 []
+[]
 []
 []
 []
 *
 *
@@ -108,10 +109,11 @@ Conditional statements may be used anywhere within this 
section.
 [ "READ_DISABLED_CAP"   ]
 [ "READ_STATUS"   ]
 [ "ERASE_POLARITY"  {"0"} {"1"} ]
 ::=  "FileSystemGuid"   
 ::=  "FvNameGuid"   
+::=  "FvUsedSizeEnable"   
   ::=  "FvNameString"   
  ::=  "APRIORI"  "PEI" 
 "{" 
 *
 *
diff --git a/README.md b/README.md
index 71c92fc..4e15a73 100644
--- a/README.md
+++ b/README.md
@@ -207,5 +207,6 @@ Copyright (c) 2006-2017, Intel Corporation. All rights 
reserved.
 || [#478](https://bugzilla.tianocore.org/show_bug.cgi?id=478) FDF 
spec: extend the  to support  and  
|   |
 || [#353](https://bugzilla.tianocore.org/show_bug.cgi?id=353) 
Build spec: Allow nested includes in DSC and FDF files  
|   |
 || [#520](https://bugzilla.tianocore.org/show_bug.cgi?id=520) FDF 
spec: Update Precedence of PCD Values   
|   |
 || [#585](https://bugzilla.tianocore.org/show_bug.cgi?id=585) FDF 
Spec: Update the FDF_SPECIFICATION version to 0x0001001B or 1.27
|   |
 || Per PI 1.6 to extend FFS alignment to 16M   

   |   |
+|| Per PI 1.6 to support FV extended header entry contain the used 
size of FV  
   |   |
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Zeng, Star
Ok, got it, tks. The new comment is showing why cache "BootNext" logic is still 
kept there, the commit log is showing the reason of the patch change. Make 
sense. :)

Reviewed-by: Star Zeng 


Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, September 28, 2017 2:18 PM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Dong, Eric 
Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting 
it

I didn't change the position of code to cache "BootNext", because:
This could avoid the "BootNext" (set by PlatformBootManagerLib) be consumed in 
*this* boot.

Maybe this time it's more clear.

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, September 28, 2017 2:13 PM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" 
> until booting it
> 
> The commit log is saying the "BootNext" *DELETED* (before
> PlatformBootManagerLib) may be *LOST* if there is reset during 
> PlatformBootManagerLib. I realized it.
> 
> The comment is saying to avoid the "BootNext" "SET" by 
> PlatformBootManagerLib. Sorry I am not getting the point.
> 
> Thanks,
> Star
> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 2:02 PM
> To: Zeng, Star ; edk2-devel@lists.01.org
> Cc: Dong, Eric 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" 
> until booting it
> 
> This could avoid the "BootNext" set by PlatformBootManagerLib be 
> consumed in *this* boot.
> 
> If I add "*" around "this", is it more clear?
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Thursday, September 28, 2017 2:00 PM
> > To: Ni, Ruiyu ; edk2-devel@lists.01.org
> > Cc: Dong, Eric ; Zeng, Star 
> > 
> > Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext"
> > until booting it
> >
> > I am ok with the code logic change, but a little confused by the new 
> > comment. It seems not match with the commit log.
> >
> > " This could avoid the "BootNext" set by PlatformBootManagerLib be 
> > consumed in this boot. "
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Thursday, September 28, 2017 1:50 PM
> > To: edk2-devel@lists.01.org
> > Cc: Dong, Eric ; Zeng, Star 
> > 
> > Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until 
> > booting it
> >
> > Current implementation deletes the "BootNext" before calling any 
> > PlatformBootManagerLib APIs, but if system resets in 
> > PlatformBootManagerLib APIs, "BootNext" is not consumed but lost.
> >
> > The patch defers the deletion of "BootNext" to before booting it.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Ruiyu Ni 
> > Cc: Eric Dong 
> > Cc: Star Zeng 
> > ---
> >  MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35
> > ++
> > --
> >  1 file changed, 20 insertions(+), 15 deletions(-)
> >
> > diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > index ac5f9088dd..a6fe617b56 100644
> > --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > @@ -808,7 +808,8 @@ BdsEntry (
> >ASSERT_EFI_ERROR (Status);
> >
> >//
> > -  // Cache and remove the "BootNext" NV variable.
> > +  // Cache the "BootNext" NV variable before calling any 
> > + PlatformBootManagerLib APIs  // This could avoid the "BootNext" 
> > + set by
> > PlatformBootManagerLib be consumed in this boot.
> >//
> >GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) 
> > , );
> >if (DataSize != sizeof (UINT16)) { @@ -817,17 +818,6 @@ BdsEntry 
> > (
> >  }
> >  BootNext = NULL;
> >}
> > -  Status = gRT->SetVariable (
> > -  EFI_BOOT_NEXT_VARIABLE_NAME,
> > -  ,
> > -  0,
> > -  0,
> > -  NULL
> > -  );
> > -  //
> > -  // Deleting NV variable shouldn't fail unless it doesn't exist.
> > -  //
> > -  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> >
> >//
> >// Initialize the platform language variables @@ -1052,10 
> > +1042,25 @@ BdsEntry (
> >
> >  EfiBootManagerHotkeyBoot ();
> >
> > -//
> > -// Boot to "BootNext"
> > -//
> >  if (BootNext != NULL) {
> > +  //
> > +  // Delete "BootNext" NV variable before transferring control 
> > + to it to
> > prevent loops.
> > +  //
> > +  Status = gRT->SetVariable (
> > +  EFI_BOOT_NEXT_VARIABLE_NAME,
> > +  ,
> > +  

Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Ni, Ruiyu
I didn't change the position of code to cache "BootNext", because:
This could avoid the "BootNext" (set by PlatformBootManagerLib) be consumed in 
*this* boot.

Maybe this time it's more clear.

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, September 28, 2017 2:13 PM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until
> booting it
> 
> The commit log is saying the "BootNext" *DELETED* (before
> PlatformBootManagerLib) may be *LOST* if there is reset during
> PlatformBootManagerLib. I realized it.
> 
> The comment is saying to avoid the "BootNext" "SET" by
> PlatformBootManagerLib. Sorry I am not getting the point.
> 
> Thanks,
> Star
> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 2:02 PM
> To: Zeng, Star ; edk2-devel@lists.01.org
> Cc: Dong, Eric 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until
> booting it
> 
> This could avoid the "BootNext" set by PlatformBootManagerLib be consumed
> in *this* boot.
> 
> If I add "*" around "this", is it more clear?
> 
> Thanks/Ray
> 
> > -Original Message-
> > From: Zeng, Star
> > Sent: Thursday, September 28, 2017 2:00 PM
> > To: Ni, Ruiyu ; edk2-devel@lists.01.org
> > Cc: Dong, Eric ; Zeng, Star 
> > Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext"
> > until booting it
> >
> > I am ok with the code logic change, but a little confused by the new
> > comment. It seems not match with the commit log.
> >
> > " This could avoid the "BootNext" set by PlatformBootManagerLib be
> > consumed in this boot. "
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: Ni, Ruiyu
> > Sent: Thursday, September 28, 2017 1:50 PM
> > To: edk2-devel@lists.01.org
> > Cc: Dong, Eric ; Zeng, Star 
> > Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until
> > booting it
> >
> > Current implementation deletes the "BootNext" before calling any
> > PlatformBootManagerLib APIs, but if system resets in
> > PlatformBootManagerLib APIs, "BootNext" is not consumed but lost.
> >
> > The patch defers the deletion of "BootNext" to before booting it.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Ruiyu Ni 
> > Cc: Eric Dong 
> > Cc: Star Zeng 
> > ---
> >  MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35
> > ++
> > --
> >  1 file changed, 20 insertions(+), 15 deletions(-)
> >
> > diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > index ac5f9088dd..a6fe617b56 100644
> > --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> > @@ -808,7 +808,8 @@ BdsEntry (
> >ASSERT_EFI_ERROR (Status);
> >
> >//
> > -  // Cache and remove the "BootNext" NV variable.
> > +  // Cache the "BootNext" NV variable before calling any
> > + PlatformBootManagerLib APIs  // This could avoid the "BootNext" set
> > + by
> > PlatformBootManagerLib be consumed in this boot.
> >//
> >GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)
> > , );
> >if (DataSize != sizeof (UINT16)) {
> > @@ -817,17 +818,6 @@ BdsEntry (
> >  }
> >  BootNext = NULL;
> >}
> > -  Status = gRT->SetVariable (
> > -  EFI_BOOT_NEXT_VARIABLE_NAME,
> > -  ,
> > -  0,
> > -  0,
> > -  NULL
> > -  );
> > -  //
> > -  // Deleting NV variable shouldn't fail unless it doesn't exist.
> > -  //
> > -  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> >
> >//
> >// Initialize the platform language variables @@ -1052,10 +1042,25
> > @@ BdsEntry (
> >
> >  EfiBootManagerHotkeyBoot ();
> >
> > -//
> > -// Boot to "BootNext"
> > -//
> >  if (BootNext != NULL) {
> > +  //
> > +  // Delete "BootNext" NV variable before transferring control to
> > + it to
> > prevent loops.
> > +  //
> > +  Status = gRT->SetVariable (
> > +  EFI_BOOT_NEXT_VARIABLE_NAME,
> > +  ,
> > +  0,
> > +  0,
> > +  NULL
> > +  );
> > +  //
> > +  // Deleting NV variable shouldn't fail unless it doesn't exist.
> > +  //
> > +  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> > +
> > +  //
> > +  // Boot to "BootNext"
> > +  //
> >UnicodeSPrint (BootNextVariableName, sizeof
> > (BootNextVariableName), L"Boot%04x", *BootNext);
> >Status = EfiBootManagerVariableToLoadOption
> > 

Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Zeng, Star
The commit log is saying the "BootNext" *DELETED* (before 
PlatformBootManagerLib) may be *LOST* if there is reset during 
PlatformBootManagerLib. I realized it.

The comment is saying to avoid the "BootNext" "SET" by PlatformBootManagerLib. 
Sorry I am not getting the point.

Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, September 28, 2017 2:02 PM
To: Zeng, Star ; edk2-devel@lists.01.org
Cc: Dong, Eric 
Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting 
it

This could avoid the "BootNext" set by PlatformBootManagerLib be consumed in 
*this* boot.

If I add "*" around "this", is it more clear?

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, September 28, 2017 2:00 PM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" 
> until booting it
> 
> I am ok with the code logic change, but a little confused by the new 
> comment. It seems not match with the commit log.
> 
> " This could avoid the "BootNext" set by PlatformBootManagerLib be 
> consumed in this boot. "
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 1:50 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until 
> booting it
> 
> Current implementation deletes the "BootNext" before calling any 
> PlatformBootManagerLib APIs, but if system resets in 
> PlatformBootManagerLib APIs, "BootNext" is not consumed but lost.
> 
> The patch defers the deletion of "BootNext" to before booting it.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Eric Dong 
> Cc: Star Zeng 
> ---
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35 
> ++
> --
>  1 file changed, 20 insertions(+), 15 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> index ac5f9088dd..a6fe617b56 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> @@ -808,7 +808,8 @@ BdsEntry (
>ASSERT_EFI_ERROR (Status);
> 
>//
> -  // Cache and remove the "BootNext" NV variable.
> +  // Cache the "BootNext" NV variable before calling any 
> + PlatformBootManagerLib APIs  // This could avoid the "BootNext" set 
> + by
> PlatformBootManagerLib be consumed in this boot.
>//
>GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) 
> , );
>if (DataSize != sizeof (UINT16)) {
> @@ -817,17 +818,6 @@ BdsEntry (
>  }
>  BootNext = NULL;
>}
> -  Status = gRT->SetVariable (
> -  EFI_BOOT_NEXT_VARIABLE_NAME,
> -  ,
> -  0,
> -  0,
> -  NULL
> -  );
> -  //
> -  // Deleting NV variable shouldn't fail unless it doesn't exist.
> -  //
> -  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> 
>//
>// Initialize the platform language variables @@ -1052,10 +1042,25 
> @@ BdsEntry (
> 
>  EfiBootManagerHotkeyBoot ();
> 
> -//
> -// Boot to "BootNext"
> -//
>  if (BootNext != NULL) {
> +  //
> +  // Delete "BootNext" NV variable before transferring control to 
> + it to
> prevent loops.
> +  //
> +  Status = gRT->SetVariable (
> +  EFI_BOOT_NEXT_VARIABLE_NAME,
> +  ,
> +  0,
> +  0,
> +  NULL
> +  );
> +  //
> +  // Deleting NV variable shouldn't fail unless it doesn't exist.
> +  //
> +  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> +
> +  //
> +  // Boot to "BootNext"
> +  //
>UnicodeSPrint (BootNextVariableName, sizeof 
> (BootNextVariableName), L"Boot%04x", *BootNext);
>Status = EfiBootManagerVariableToLoadOption 
> (BootNextVariableName, );
>if (!EFI_ERROR (Status)) {
> --
> 2.12.2.windows.2

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


Re: [edk2] [PATCH v3] CryptoPkg: Add new API to retrieve commonName of X.509 certificate

2017-09-28 Thread Zhang, Chao B
Qin:  
   What about other X509 related interface, such as X509GetTBSCert, 
X509GetSubjectName. They all return TRUE/FALSE.
   It looks inconsistent between these interfaces


-Original Message-
From: Long, Qin 
Sent: Thursday, September 21, 2017 10:48 AM
To: ler...@redhat.com; Ye, Ting ; Zhang, Chao B 

Cc: edk2-devel@lists.01.org
Subject: [PATCH v3] CryptoPkg: Add new API to retrieve commonName of X.509 
certificate

v3: Add extra CommonNameSize check since OpenSSL didn't check this
input parameter. (One openssl issue was filed to address this risk:
https://github.com/openssl/openssl/issues/4392)
v2: Update function interface to return RETURN_STATUS to represent
different error cases.

Add one new API (X509GetCommonName()) to retrieve the subject commonName string 
from one X.509 certificate.

Cc: Laszlo Ersek 
Cc: Ting Ye 
Cc: Chao Zhang 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long 
---
 CryptoPkg/Application/Cryptest/RsaVerify2.c|  32 --
 CryptoPkg/Include/Library/BaseCryptLib.h   |  35 +++
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c  | 109 +
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c  |  32 ++
 .../Pk/CryptX509Null.c |  34 ++-
 5 files changed, 234 insertions(+), 8 deletions(-)

diff --git a/CryptoPkg/Application/Cryptest/RsaVerify2.c 
b/CryptoPkg/Application/Cryptest/RsaVerify2.c
index 98b5aad900..9db43d6eef 100644
--- a/CryptoPkg/Application/Cryptest/RsaVerify2.c
+++ b/CryptoPkg/Application/Cryptest/RsaVerify2.c
@@ -204,13 +204,17 @@ ValidateCryptRsa2 (
   VOID
   )
 {
-  BOOLEAN  Status;
-  VOID *RsaPrivKey;
-  VOID *RsaPubKey;
-  UINT8*Signature;
-  UINTNSigSize;
-  UINT8*Subject;
-  UINTNSubjectSize;
+  BOOLEANStatus;
+  VOID   *RsaPrivKey;
+  VOID   *RsaPubKey;
+  UINT8  *Signature;
+  UINTN  SigSize;
+  UINT8  *Subject;
+  UINTN  SubjectSize;
+  RETURN_STATUS  ReturnStatus;
+  CHAR8  CommonName[64];
+  CHAR16 CommonNameUnicode[64];
+  UINTN  CommonNameSize;
 
   Print (L"\nUEFI-OpenSSL RSA Key Retrieving Testing: ");
 
@@ -286,6 +290,20 @@ ValidateCryptRsa2 (
 Print (L"[Pass]");
   }
 
+  //
+  // Get CommonName from X509 Certificate Subject  //  CommonNameSize = 
+ 64;  ZeroMem (CommonName, CommonNameSize);  ReturnStatus = 
+ X509GetCommonName (TestCert, sizeof (TestCert), CommonName, 
+ );  if (RETURN_ERROR (ReturnStatus)) {
+Print (L"\n  - Retrieving Common Name - [Fail]");
+return EFI_ABORTED;
+  } else {
+AsciiStrToUnicodeStrS (CommonName, CommonNameUnicode, CommonNameSize);
+Print (L"\n  - Retrieving Common Name = \"%s\" (Size = %d)", 
+ CommonNameUnicode, CommonNameSize);  }
+
   //
   // X509 Certificate Verification.
   //
diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h 
b/CryptoPkg/Include/Library/BaseCryptLib.h
index 9c5ffcd9cf..2366a0218d 100644
--- a/CryptoPkg/Include/Library/BaseCryptLib.h
+++ b/CryptoPkg/Include/Library/BaseCryptLib.h
@@ -2171,6 +2171,41 @@ X509GetSubjectName (
   IN OUT  UINTN*SubjectSize
   );
 
+/**
+  Retrieve the common name (CN) string from one X.509 certificate.
+
+  @param[in]  Cert Pointer to the DER-encoded X509 certificate.
+  @param[in]  CertSize Size of the X509 certificate in bytes.
+  @param[out] CommonName   Buffer to contain the retrieved certificate 
common
+   name string. At most CommonNameSize bytes 
will be
+   written and the string will be null 
terminated. May be
+   NULL in order to determine the size buffer 
needed.
+  @param[in,out]  CommonNameSize   The size in bytes of the CommonName buffer 
on input,
+   and the size of buffer returned CommonName 
on output.
+   If CommonName is NULL then the amount of 
space needed
+   in buffer (including the final null) is 
returned.
+
+  @retval RETURN_SUCCESS   The certificate CommonName retrieved 
successfully.
+  @retval RETURN_INVALID_PARAMETER If Cert is NULL.
+   If CommonNameSize is NULL.
+   If CommonName is not NULL and 
CommonNameSize is 0.
+   If Certificate is invalid.
+  @retval RETURN_NOT_FOUND If no CommonName entry exists.
+  @retval RETURN_BUFFER_TOO_SMALL  If the CommonName is NULL. The required 
buffer size
+   (including the final null) is returned in 
the 
+   CommonNameSize parameter.
+  @retval RETURN_UNSUPPORTED   The operation is not supported.
+
+**/

Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Ni, Ruiyu
This could avoid the "BootNext" set by PlatformBootManagerLib be consumed in 
*this* boot.

If I add "*" around "this", is it more clear?

Thanks/Ray

> -Original Message-
> From: Zeng, Star
> Sent: Thursday, September 28, 2017 2:00 PM
> To: Ni, Ruiyu ; edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: RE: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until
> booting it
> 
> I am ok with the code logic change, but a little confused by the new comment. 
> It
> seems not match with the commit log.
> 
> " This could avoid the "BootNext" set by PlatformBootManagerLib be consumed
> in this boot. "
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Ni, Ruiyu
> Sent: Thursday, September 28, 2017 1:50 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric ; Zeng, Star 
> Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting
> it
> 
> Current implementation deletes the "BootNext" before calling any
> PlatformBootManagerLib APIs, but if system resets in PlatformBootManagerLib
> APIs, "BootNext" is not consumed but lost.
> 
> The patch defers the deletion of "BootNext" to before booting it.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni 
> Cc: Eric Dong 
> Cc: Star Zeng 
> ---
>  MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35 ++
> --
>  1 file changed, 20 insertions(+), 15 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> index ac5f9088dd..a6fe617b56 100644
> --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> @@ -808,7 +808,8 @@ BdsEntry (
>ASSERT_EFI_ERROR (Status);
> 
>//
> -  // Cache and remove the "BootNext" NV variable.
> +  // Cache the "BootNext" NV variable before calling any
> + PlatformBootManagerLib APIs  // This could avoid the "BootNext" set by
> PlatformBootManagerLib be consumed in this boot.
>//
>GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **)
> , );
>if (DataSize != sizeof (UINT16)) {
> @@ -817,17 +818,6 @@ BdsEntry (
>  }
>  BootNext = NULL;
>}
> -  Status = gRT->SetVariable (
> -  EFI_BOOT_NEXT_VARIABLE_NAME,
> -  ,
> -  0,
> -  0,
> -  NULL
> -  );
> -  //
> -  // Deleting NV variable shouldn't fail unless it doesn't exist.
> -  //
> -  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> 
>//
>// Initialize the platform language variables @@ -1052,10 +1042,25 @@
> BdsEntry (
> 
>  EfiBootManagerHotkeyBoot ();
> 
> -//
> -// Boot to "BootNext"
> -//
>  if (BootNext != NULL) {
> +  //
> +  // Delete "BootNext" NV variable before transferring control to it to
> prevent loops.
> +  //
> +  Status = gRT->SetVariable (
> +  EFI_BOOT_NEXT_VARIABLE_NAME,
> +  ,
> +  0,
> +  0,
> +  NULL
> +  );
> +  //
> +  // Deleting NV variable shouldn't fail unless it doesn't exist.
> +  //
> +  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
> +
> +  //
> +  // Boot to "BootNext"
> +  //
>UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName),
> L"Boot%04x", *BootNext);
>Status = EfiBootManagerVariableToLoadOption (BootNextVariableName,
> );
>if (!EFI_ERROR (Status)) {
> --
> 2.12.2.windows.2

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


Re: [edk2] [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

2017-09-28 Thread Zeng, Star
I am ok with the code logic change, but a little confused by the new comment. 
It seems not match with the commit log.

" This could avoid the "BootNext" set by PlatformBootManagerLib be consumed in 
this boot. "


Thanks,
Star
-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, September 28, 2017 1:50 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Zeng, Star 
Subject: [PATCH] MdeModulePkg/BdsDxe: Don't delete "BootNext" until booting it

Current implementation deletes the "BootNext" before calling any 
PlatformBootManagerLib APIs, but if system resets in PlatformBootManagerLib 
APIs, "BootNext" is not consumed but lost.

The patch defers the deletion of "BootNext" to before booting it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni 
Cc: Eric Dong 
Cc: Star Zeng 
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 35 ++--
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index ac5f9088dd..a6fe617b56 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -808,7 +808,8 @@ BdsEntry (
   ASSERT_EFI_ERROR (Status);
 
   //
-  // Cache and remove the "BootNext" NV variable.
+  // Cache the "BootNext" NV variable before calling any 
+ PlatformBootManagerLib APIs  // This could avoid the "BootNext" set by 
PlatformBootManagerLib be consumed in this boot.
   //
   GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) , 
);
   if (DataSize != sizeof (UINT16)) {
@@ -817,17 +818,6 @@ BdsEntry (
 }
 BootNext = NULL;
   }
-  Status = gRT->SetVariable (
-  EFI_BOOT_NEXT_VARIABLE_NAME,
-  ,
-  0,
-  0,
-  NULL
-  );
-  //
-  // Deleting NV variable shouldn't fail unless it doesn't exist.
-  //
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
 
   //
   // Initialize the platform language variables @@ -1052,10 +1042,25 @@ 
BdsEntry (
 
 EfiBootManagerHotkeyBoot ();
 
-//
-// Boot to "BootNext"
-//
 if (BootNext != NULL) {
+  //
+  // Delete "BootNext" NV variable before transferring control to it to 
prevent loops.
+  //
+  Status = gRT->SetVariable (
+  EFI_BOOT_NEXT_VARIABLE_NAME,
+  ,
+  0,
+  0,
+  NULL
+  );
+  //
+  // Deleting NV variable shouldn't fail unless it doesn't exist.
+  //
+  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);
+
+  //
+  // Boot to "BootNext"
+  //
   UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), 
L"Boot%04x", *BootNext);
   Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, 
);
   if (!EFI_ERROR (Status)) {
--
2.12.2.windows.2

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


  1   2   >