[edk2-devel] [PATCH] UefiPayloadPkg: Fix Coverity report defect

2022-08-11 Thread GregX Yeh
From: Gregx Yeh 

https://bugzilla.tianocore.org/show_bug.cgi?id=4018
Coverity report FORWARD_NULL and OVERFLOW_BEFORE_WIDEN potential defect
in UefiPayloadPkg.

Signed-off-by: Gregx Yeh 
Cc: Guo Dong 
Cc: Ray Ni 
---
 UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 4 ++--
 UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c   | 2 +-
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c| 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c 
b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 9847063d3d..790e6109c0 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -232,11 +232,11 @@ PciHostBridgeFreeRootBridges (
   UINTNCount
   )
 {
-  if ((Bridges == NULL) && (Count == 0)) {
+  if ((Bridges == NULL) || (Count == 0)) {
 return;
   }
 
-  ASSERT (Bridges != NULL && Count > 0);
+  ASSERT (Bridges != NULL || Count > 0);
 
   do {
 --Count;
diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c 
b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
index 2a6305c67b..a9bf6f3223 100644
--- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
+++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
@@ -149,7 +149,7 @@ CalculateElfFileSize (
 FileSize2 = Elf32Hdr->e_shoff + Elf32Hdr->e_shentsize * Elf32Hdr->e_shnum;
   } else if (ElfCt->EiClass == ELFCLASS64) {
 Elf64Hdr  = (Elf64_Ehdr *)ElfCt->FileBase;
-FileSize2 = (UINTN)(Elf64Hdr->e_shoff + Elf64Hdr->e_shentsize * 
Elf64Hdr->e_shnum);
+FileSize2 = ((UINTN)Elf64Hdr->e_shoff + (UINTN)(Elf64Hdr->e_shentsize * 
Elf64Hdr->e_shnum));
   }
 
   *FileSize = MAX (FileSize1, FileSize2);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index 74b667a62a..8d8a9d0ca8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -783,9 +783,9 @@ CreateIdentityMappingPageTables (
   // Pre-allocate big pages to avoid later allocations.
   //
   if (!Page1GSupport) {
-TotalPagesNum = ((NumberOfPdpEntriesNeeded + 1) * 
NumberOfPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;
+TotalPagesNum = (UINTN)((NumberOfPdpEntriesNeeded + 1) * 
NumberOfPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;
   } else {
-TotalPagesNum = (NumberOfPml4EntriesNeeded + 1) * 
NumberOfPml5EntriesNeeded + 1;
+TotalPagesNum = (UINTN)(NumberOfPml4EntriesNeeded + 1) * 
NumberOfPml5EntriesNeeded + 1;
   }
 
   //
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92343): https://edk2.groups.io/g/devel/message/92343
Mute This Topic: https://groups.io/mt/92953360/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] UefiPayloadPkg: Fix Coverity report defect

2022-08-11 Thread GregX Yeh
From: Gregx Yeh 

https://bugzilla.tianocore.org/show_bug.cgi?id=4018
Coverity report FORWARD_NULL and OVERFLOW_BEFORE_WIDEN potential defect
in UefiPayloadPkg.

Signed-off-by: Gregx Yeh 
---
 UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 4 ++--
 UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c   | 2 +-
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c| 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c 
b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 9847063d3d..790e6109c0 100644
--- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -232,11 +232,11 @@ PciHostBridgeFreeRootBridges (
   UINTNCount
   )
 {
-  if ((Bridges == NULL) && (Count == 0)) {
+  if ((Bridges == NULL) || (Count == 0)) {
 return;
   }
 
-  ASSERT (Bridges != NULL && Count > 0);
+  ASSERT (Bridges != NULL || Count > 0);
 
   do {
 --Count;
diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c 
b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
index 2a6305c67b..a9bf6f3223 100644
--- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
+++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c
@@ -149,7 +149,7 @@ CalculateElfFileSize (
 FileSize2 = Elf32Hdr->e_shoff + Elf32Hdr->e_shentsize * Elf32Hdr->e_shnum;
   } else if (ElfCt->EiClass == ELFCLASS64) {
 Elf64Hdr  = (Elf64_Ehdr *)ElfCt->FileBase;
-FileSize2 = (UINTN)(Elf64Hdr->e_shoff + Elf64Hdr->e_shentsize * 
Elf64Hdr->e_shnum);
+FileSize2 = ((UINTN)Elf64Hdr->e_shoff + (UINTN)(Elf64Hdr->e_shentsize * 
Elf64Hdr->e_shnum));
   }
 
   *FileSize = MAX (FileSize1, FileSize2);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index 74b667a62a..8d8a9d0ca8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -783,9 +783,9 @@ CreateIdentityMappingPageTables (
   // Pre-allocate big pages to avoid later allocations.
   //
   if (!Page1GSupport) {
-TotalPagesNum = ((NumberOfPdpEntriesNeeded + 1) * 
NumberOfPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;
+TotalPagesNum = (UINTN)((NumberOfPdpEntriesNeeded + 1) * 
NumberOfPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;
   } else {
-TotalPagesNum = (NumberOfPml4EntriesNeeded + 1) * 
NumberOfPml5EntriesNeeded + 1;
+TotalPagesNum = (UINTN)(NumberOfPml4EntriesNeeded + 1) * 
NumberOfPml5EntriesNeeded + 1;
   }
 
   //
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92341): https://edk2.groups.io/g/devel/message/92341
Mute This Topic: https://groups.io/mt/92953360/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] MdeModulePkg PCD: Reinstall PCD service PPIS when memory available

2021-08-12 Thread GregX Yeh
https://bugzilla.tianocore.org/show_bug.cgi?id=3525

After PciSegmentLib using Dynamic PCD for Pcie base address such
long delay found in FSP. The root cause is some of the PCD service
PPIs not shadowed to memory and flash cache may have been disabled
in NotifyPhase stage. Solution is to shadow all PCD service PPIs
to memory.

Signed-off-by: GregX Yeh 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Reviewed-by: Dandan Bi 
---
 MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71 +++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c 
b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 9c6346924f..f31e0be35f 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
 /** @file
   All Pcd Ppi services are implemented here.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -339,6 +339,75 @@ PcdPeimInit (
 {
   EFI_STATUS Status;
 
+  Status = PeiServicesRegisterForShadow (FileHandle);
+  if (Status == EFI_ALREADY_STARTED) {
+//
+// This is now starting in memory, the second time starting.
+//
+EFI_PEI_PPI_DESCRIPTOR *OldPpiList;
+EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;
+VOID *Ppi;
+VOID *Ppi2;
+
+OldPpiList = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList, [0]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList2 = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList2 != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList2, [0]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList, [1]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList2 = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList2 != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList2, [1]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+return Status;
+  }
+
   BuildPcdDatabase (FileHandle);
 
   //
-- 
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79152): https://edk2.groups.io/g/devel/message/79152
Mute This Topic: https://groups.io/mt/84835142/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg PCD: FSP NotifyPhase APIs caused 100ms delay

2021-08-12 Thread GregX Yeh
Hi Dandan,

So I need create new patch file with new subject then send-email again?

Thanks,
Greg

-Original Message-
From: Bi, Dandan  
Sent: Thursday, August 12, 2021 11:47 AM
To: Yeh, GregX ; devel@edk2.groups.io
Cc: Wang, Jian J ; Wu, Hao A ; 
Liming Gao 
Subject: RE: [PATCH] MdeModulePkg PCD: FSP NotifyPhase APIs caused 100ms delay

Hi Greg,

One minor comment, could we update the subject to reflect what have done in 
this patch for PCD module before submitting the patch? 
With that addressed Reviewed-by: Dandan Bi 



Thanks,
Dandan

> -Original Message-
> From: Yeh, GregX 
> Sent: Monday, August 9, 2021 10:28 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Wu, Hao A 
> ; Bi, Dandan ; Liming Gao 
> 
> Subject: [PATCH] MdeModulePkg PCD: FSP NotifyPhase APIs caused 100ms 
> delay
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=3525
> 
> After PciSegmentLib using Dynamic PCD for Pcie base address such long 
> delay found in FSP. The root cause is some of the PCD service PPIs not 
> shadowed to memory and flash cache may have been disabled in NotifyPhase 
> stage.
> Solution is to shadow all PCD service PPIs to memory.
> 
> Signed-off-by: GregX Yeh 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Dandan Bi 
> Cc: Liming Gao 
> ---
>  MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71
> +++-
>  1 file changed, 70 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
> b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
> index 9c6346924f..f31e0be35f 100644
> --- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
> +++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
> @@ -1,7 +1,7 @@
>  /** @file   All Pcd Ppi services are implemented here. -Copyright (c) 2006 -
> 2018, Intel Corporation. All rights reserved.+Copyright (c) 2006 - 
> 2021, Intel Corporation. All rights reserved. (C) Copyright 2016 
> Hewlett Packard Enterprise Development LP SPDX-License-Identifier: 
> BSD-2- Clause-Patent @@ -339,6 +339,75 @@ PcdPeimInit (
>  {   EFI_STATUS Status; +  Status = PeiServicesRegisterForShadow
> (FileHandle);+  if (Status == EFI_ALREADY_STARTED) {+//+// This is now
> starting in memory, the second time starting.+//+
> EFI_PEI_PPI_DESCRIPTOR *OldPpiList;+EFI_PEI_PPI_DESCRIPTOR
> *OldPpiList2;+VOID *Ppi;+VOID *Ppi2;++OldPpiList = NULL;+
> Status =
> PeiServicesLocatePpi (+   ,+   0,+
> ,+   +   );+ASSERT_EFI_ERROR 
> (Status);++if
> (OldPpiList != NULL) {+  Status = PeiServicesReInstallPpi (OldPpiList,
> [0]);+  ASSERT_EFI_ERROR (Status);+}++OldPpiList2 = 
> NULL;+
> Status = PeiServicesLocatePpi (+   ,+  
>  0,+
> ,+   +   );+ASSERT_EFI_ERROR 
> (Status);++if
> (OldPpiList2 != NULL) {+  Status = PeiServicesReInstallPpi (OldPpiList2,
> [0]);+  ASSERT_EFI_ERROR (Status);+}++OldPpiList = 
> NULL;+
> Status = PeiServicesLocatePpi (+   ,+   
> 0,+
> ,+   +   );+ASSERT_EFI_ERROR 
> (Status);++if
> (OldPpiList != NULL) {+  Status = PeiServicesReInstallPpi (OldPpiList,
> [1]);+  ASSERT_EFI_ERROR (Status);+}++OldPpiList2 = 
> NULL;+
> Status = PeiServicesLocatePpi (+   ,+   
> 0,+
> ,+   +   );+ASSERT_EFI_ERROR 
> (Status);++if
> (OldPpiList2 != NULL) {+  Status = PeiServicesReInstallPpi (OldPpiList2,
> [1]);+  ASSERT_EFI_ERROR (Status);+}++return Status;+  
> }+
> BuildPcdDatabase (FileHandle);//--
> 2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79148): https://edk2.groups.io/g/devel/message/79148
Mute This Topic: https://groups.io/mt/84760812/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] MdeModulePkg PCD: FSP NotifyPhase APIs caused 100ms delay

2021-08-08 Thread GregX Yeh
https://bugzilla.tianocore.org/show_bug.cgi?id=3525

After PciSegmentLib using Dynamic PCD for Pcie base address such
long delay found in FSP. The root cause is some of the PCD service
PPIs not shadowed to memory and flash cache may have been disabled
in NotifyPhase stage. Solution is to shadow all PCD service PPIs
to memory.

Signed-off-by: GregX Yeh 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
---
 MdeModulePkg/Universal/PCD/Pei/Pcd.c | 71 +++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/PCD/Pei/Pcd.c 
b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
index 9c6346924f..f31e0be35f 100644
--- a/MdeModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/MdeModulePkg/Universal/PCD/Pei/Pcd.c
@@ -1,7 +1,7 @@
 /** @file
   All Pcd Ppi services are implemented here.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -339,6 +339,75 @@ PcdPeimInit (
 {
   EFI_STATUS Status;
 
+  Status = PeiServicesRegisterForShadow (FileHandle);
+  if (Status == EFI_ALREADY_STARTED) {
+//
+// This is now starting in memory, the second time starting.
+//
+EFI_PEI_PPI_DESCRIPTOR *OldPpiList;
+EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;
+VOID *Ppi;
+VOID *Ppi2;
+
+OldPpiList = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList, [0]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList2 = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList2 != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList2, [0]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList, [1]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+OldPpiList2 = NULL;
+Status = PeiServicesLocatePpi (
+   ,
+   0,
+   ,
+   
+   );
+ASSERT_EFI_ERROR (Status);
+
+if (OldPpiList2 != NULL) {
+  Status = PeiServicesReInstallPpi (OldPpiList2, [1]);
+  ASSERT_EFI_ERROR (Status);
+}
+
+return Status;
+  }
+
   BuildPcdDatabase (FileHandle);
 
   //
-- 
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78913): https://edk2.groups.io/g/devel/message/78913
Mute This Topic: https://groups.io/mt/84760812/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] [edk2-staging] BaseTools/Fmmt: Fix rebuild FFS lost dependency section.

2021-03-25 Thread GregX Yeh
https://bugzilla.tianocore.org/show_bug.cgi?id=3261

Dependency section data lost when rebuild FFS.
Add pei dxe smm dependency section to FFS and Encap_INFO_DATA structure.
Restore dependency section when build FFS.

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: GregX Yeh 
---
 BaseTools/Source/C/FMMT/FirmwareModuleManagement.h |  28 +-
 BaseTools/Source/C/FMMT/FmmtLib.c  | 443 +++--
 2 files changed, 334 insertions(+), 137 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h 
b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
index 9d09c9160a..84ccfaed1d 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
@@ -2,7 +2,7 @@
 
  Structures and functions declaration.
 
- Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -195,7 +195,7 @@ typedef struct {
   // UI Name for this FFS file, if has.
   //
   CHAR16   UiName[_MAX_PATH];
-   UINT32   UiNameSize;
+  UINT32   UiNameSize;
   //
   // Total section number in this FFS.
   //
@@ -223,8 +223,12 @@ typedef struct {
   UINT32  Offset;
   UINT8   FvLevel;
   EFI_GUIDGuidName;
-  UINT8   *Depex;
-  UINT32  DepexLen;
+  UINT8   *PeiDepex;
+  UINT32  PeiDepexLen;
+  UINT8   *DxeDepex;
+  UINT32  DxeDepexLen;
+  UINT8   *SmmDepex;
+  UINT32  SmmDepexLen;
   BOOLEAN IsHandle;
   BOOLEAN IsFvStart;
   BOOLEAN IsFvEnd;
@@ -259,8 +263,12 @@ typedef struct __ENCAP_INFO_DATA{
 
   CHAR16   UiName[_MAX_PATH];
   UINT32   UiNameSize;
-  UINT8*Depex;
-  UINT32   DepexLen;
+  UINT8*PeiDepex;
+  UINT32   PeiDepexLen;
+  UINT8*DxeDepex;
+  UINT32   DxeDepexLen;
+  UINT8*SmmDepex;
+  UINT32   SmmDepexLen;
 
   //
   // Next node.
@@ -281,8 +289,12 @@ typedef struct _FFS_INFOMATION{
   BOOLEANIsFFS;
   CHAR16 UiName[_MAX_PATH];
   UINT32 UiNameSize;
-  UINT8  *Depex;
-  UINT32 DepexLen;
+  UINT8  *PeiDepex;
+  UINT32 PeiDepexLen;
+  UINT8  *DxeDepex;
+  UINT32 DxeDepexLen;
+  UINT8  *SmmDepex;
+  UINT32 SmmDepexLen;
   BOOLEANFfsFoundFlag;
   struct _FFS_INFOMATION *Next;
 } FFS_INFORMATION;
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c 
b/BaseTools/Source/C/FMMT/FmmtLib.c
index 9a9ba8b56f..fa77ed7317 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -164,8 +164,12 @@ LibInitializeFvStruct (
 Fv->FfsAttuibutes[Index].IsLeaf   = TRUE;
 Fv->FfsAttuibutes[Index].Level= 0xFF;
 Fv->FfsAttuibutes[Index].TotalSectionNum  = 0;
-Fv->FfsAttuibutes[Index].Depex= NULL;
-Fv->FfsAttuibutes[Index].DepexLen = 0;
+Fv->FfsAttuibutes[Index].PeiDepex= NULL;
+Fv->FfsAttuibutes[Index].PeiDepexLen = 0;
+Fv->FfsAttuibutes[Index].DxeDepex= NULL;
+Fv->FfsAttuibutes[Index].DxeDepexLen = 0;
+Fv->FfsAttuibutes[Index].SmmDepex= NULL;
+Fv->FfsAttuibutes[Index].SmmDepexLen = 0;
 Fv->FfsAttuibutes[Index].IsHandle = FALSE;
 Fv->FfsAttuibutes[Index].IsFvStart= FALSE;
 Fv->FfsAttuibutes[Index].IsFvEnd  = FALSE;
@@ -835,6 +839,7 @@ LibParseSection (
   CHAR8   *ToolOutputFileName;
   BOOLEAN  HasUiSection;
   BOOLEAN  FirstInFlag;
+  UINT32   KeepFfsCount;
 
   DataOffset = 0;
   GuidAttr   = 0;
@@ -871,6 +876,7 @@ LibParseSection (
   LargeHeaderOffset  = 0;
   HasUiSection   = FALSE;
   FirstInFlag= TRUE;
+  KeepFfsCount   = *FfsCount;
 
 
   while (ParsedLength < BufferLength) {
@@ -945,9 +951,13 @@ LibParseSection (
 LocalEncapData->Data= NULL;
 LocalEncapData->FvExtHeader = NULL;
 LocalEncapData->NextNode= NULL;
-LocalEncapData->RightNode = NULL;
-LocalEncapData->Depex = NULL;
-LocalEncapData->DepexLen = 0;
+LocalEncapData->RightNode = NULL;
+LocalEncapData->PeiDepex = NULL;
+LocalEncapData->PeiDepexLen = 0;
+LocalEncapData->DxeDepex = NULL;
+LocalEncapData->DxeDepexLen = 0;
+LocalEncapData->S

Re: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-15 Thread GregX Yeh
Hi Bob,

I have created new patch file. PatchCheck is pass.
Using Git send-email  send to edk2.group.io 

Thanks,
Greg

-Original Message-
From: Feng, Bob C  
Sent: Monday, March 15, 2021 12:35 PM
To: Yeh, GregX ; devel@edk2.groups.io; Yunhua Feng 

Cc: Liming Gao 
Subject: RE: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when 
FV level over 2

Hi Greg,

Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are some 
lines code format invalid.
The logic looks good to me.

Yunhua, could you please double check, I remember you have concerns about the 
previous version of this patch.

Thanks,
Bob

-Original Message-
From: Yeh, GregX 
Sent: Wednesday, March 10, 2021 10:05 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Liming Gao 
Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV 
level over 2

Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh 
Cc: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/C/FMMT/FmmtLib.c | 56 ++-
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c 
b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..26df0181c7 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -494,7 +494,7 @@ LibReadFvHeader (
 if ((FvLevel -1) == 0) {
   printf ("\n%s :\n", FvName);
 } else {
-  printf ("%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName);
+  printf ("\n%sChild FV named FV%d of %s\n", BlankSpace, FvCount, 
+ FvName);
 }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-printf ("\n%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
+printf ("%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
 printf ("%sTotal Volume Size: 0x%08X\n", BlankSpace, (unsigned) 
VolumeHeader->FvLength);
 printf ("%sFree Volume Size:  0x%08X\n", BlankSpace, (unsigned) 
(VolumeHeader->FvLength - GetFreeOffset(InputFv)));
   }
@@ -789,7 +789,8 @@ LibParseSection (
   UINT8  *FvCount,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   UINT32  ParsedLength;
@@ -997,8 +998,12 @@ LibParseSection (
   break;
 
 case EFI_SECTION_COMPRESSION:
-  if (FirstInFlag) {
-Level ++;
+   if (IsFfs){
+ Level ++;
+   } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated);
+  IsFfsGenerated,
+  FALSE
+  );
 
   if (CompressionType == EFI_STANDARD_COMPRESSION) {
 //
@@ -1181,8 +1188,12 @@ LibParseSection (
   // looks up the appropriate tool to use for extracting
   // a GUID defined FV section.
   //
-  if (FirstInFlag) {
+  if (IsFfs) {
 Level ++;
+  } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections++;
   EncapDataNeedUpdata = TRUE;
@@ -1216,7 +1227,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
 if (EFI_ERROR(Status)) {
   Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", 
NULL); @@ -1471,7 +1483,8 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated
+  IsFfsGenerated,
+  FALSE
   );
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", 
NULL); @@ -1491,7 +1504,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
   if (ExtractionTool != NULL) {
 free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
   LocalEncapData->Level = Level;
   LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-LocalEncapData->FvExtHeader = NULL;
+  LocalEncapData->FvExtHeader = NULL;
   LocalEncapData->Depex = NULL;
   LocalEncapData->DepexLen = 0;
   Loca

[edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Build FV failure when FV level over 2

2021-03-15 Thread GregX Yeh
Fix replace file failure when FFS in multiple level FV and FV level over 2

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: GregX Yeh 
---
 BaseTools/Source/C/FMMT/FmmtLib.c | 56 ++-
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c 
b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..9a9ba8b56f 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -2,7 +2,7 @@
 
  Library to parse and generate FV image.
 
- Copyright (c)  2019 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c)  2019 - 2021, Intel Corporation. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -494,7 +494,7 @@ LibReadFvHeader (
 if ((FvLevel -1) == 0) {
   printf ("\n%s :\n", FvName);
 } else {
-  printf ("%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName);
+  printf ("\n%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName);
 }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-printf ("\n%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
+printf ("%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
 printf ("%sTotal Volume Size: 0x%08X\n", BlankSpace, (unsigned) 
VolumeHeader->FvLength);
 printf ("%sFree Volume Size:  0x%08X\n", BlankSpace, (unsigned) 
(VolumeHeader->FvLength - GetFreeOffset(InputFv)));
   }
@@ -789,7 +789,8 @@ LibParseSection (
   UINT8  *FvCount,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   UINT32  ParsedLength;
@@ -997,8 +998,12 @@ LibParseSection (
   break;
 
 case EFI_SECTION_COMPRESSION:
-  if (FirstInFlag) {
+  if (IsFfs){
 Level ++;
+  } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated);
+  IsFfsGenerated,
+  FALSE
+  );
 
   if (CompressionType == EFI_STANDARD_COMPRESSION) {
 //
@@ -1181,8 +1188,12 @@ LibParseSection (
   // looks up the appropriate tool to use for extracting
   // a GUID defined FV section.
   //
-  if (FirstInFlag) {
+  if (IsFfs) {
 Level ++;
+  } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections++;
   EncapDataNeedUpdata = TRUE;
@@ -1216,7 +1227,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
 if (EFI_ERROR(Status)) {
   Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", NULL);
@@ -1471,7 +1483,8 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated
+  IsFfsGenerated,
+  FALSE
   );
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", 
NULL);
@@ -1491,7 +1504,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
   if (ExtractionTool != NULL) {
 free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
   LocalEncapData->Level = Level;
   LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-LocalEncapData->FvExtHeader = NULL;
+  LocalEncapData->FvExtHeader = NULL;
   LocalEncapData->Depex = NULL;
   LocalEncapData->DepexLen = 0;
   LocalEncapData->UiNameSize = 0;
@@ -2099,7 +2113,8 @@ LibGetFileInfo (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  
+  ,
+  TRUE
   );
 }
 if (EFI_ERROR (Status)) {
@@ -4198,10 +4213,13 @@ LibEncapNewFvFile(
   UINT32  header;
   UINT8   AlignN;
   UINT8   AlignV[1] = {0xFF};
+  UINT32  EntryFvId;
+
   AlignN  = 0;
   Id  = 0;
   InputFileSize   = 0;
   TmpFileSize = 0;
+  AlignmentFileSize   = 0;
   EncapFvIndex= 0;
   Index

[edk2-devel] [PATCH] [edk2-staging] BaseTools/Fmmt: Fix rebuild FFS will lost dependency section.

2021-03-11 Thread GregX Yeh
Dependency section data will lost when rebuild FFS.
Add pei dxe smm dependency section to  FFS and Encap_INFO_DATA structure.
Restore dependency section when build FFS.

Cc: Bob Feng 
Cc: Liming Gao 

Signed-off-by: GregX Yeh 
---
 BaseTools/Source/C/FMMT/FirmwareModuleManagement.h |  28 +-
 BaseTools/Source/C/FMMT/FmmtLib.c  | 330 -
 2 files changed, 271 insertions(+), 87 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h 
b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
index 9d09c9160a..84ccfaed1d 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.h
@@ -2,7 +2,7 @@
 
  Structures and functions declaration.
 
- Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -195,7 +195,7 @@ typedef struct {
   // UI Name for this FFS file, if has.
   //
   CHAR16   UiName[_MAX_PATH];
-   UINT32   UiNameSize;
+  UINT32   UiNameSize;
   //
   // Total section number in this FFS.
   //
@@ -223,8 +223,12 @@ typedef struct {
   UINT32  Offset;
   UINT8   FvLevel;
   EFI_GUIDGuidName;
-  UINT8   *Depex;
-  UINT32  DepexLen;
+  UINT8   *PeiDepex;
+  UINT32  PeiDepexLen;
+  UINT8   *DxeDepex;
+  UINT32  DxeDepexLen;
+  UINT8   *SmmDepex;
+  UINT32  SmmDepexLen;
   BOOLEAN IsHandle;
   BOOLEAN IsFvStart;
   BOOLEAN IsFvEnd;
@@ -259,8 +263,12 @@ typedef struct __ENCAP_INFO_DATA{
 
   CHAR16   UiName[_MAX_PATH];
   UINT32   UiNameSize;
-  UINT8*Depex;
-  UINT32   DepexLen;
+  UINT8*PeiDepex;
+  UINT32   PeiDepexLen;
+  UINT8*DxeDepex;
+  UINT32   DxeDepexLen;
+  UINT8*SmmDepex;
+  UINT32   SmmDepexLen;
 
   //
   // Next node.
@@ -281,8 +289,12 @@ typedef struct _FFS_INFOMATION{
   BOOLEANIsFFS;
   CHAR16 UiName[_MAX_PATH];
   UINT32 UiNameSize;
-  UINT8  *Depex;
-  UINT32 DepexLen;
+  UINT8  *PeiDepex;
+  UINT32 PeiDepexLen;
+  UINT8  *DxeDepex;
+  UINT32 DxeDepexLen;
+  UINT8  *SmmDepex;
+  UINT32 SmmDepexLen;
   BOOLEANFfsFoundFlag;
   struct _FFS_INFOMATION *Next;
 } FFS_INFORMATION;
diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c 
b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..23eafa3892 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -2,7 +2,7 @@
 
  Library to parse and generate FV image.
 
- Copyright (c)  2019 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c)  2019 - 2021, Intel Corporation. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -164,8 +164,12 @@ LibInitializeFvStruct (
 Fv->FfsAttuibutes[Index].IsLeaf   = TRUE;
 Fv->FfsAttuibutes[Index].Level= 0xFF;
 Fv->FfsAttuibutes[Index].TotalSectionNum  = 0;
-Fv->FfsAttuibutes[Index].Depex= NULL;
-Fv->FfsAttuibutes[Index].DepexLen = 0;
+Fv->FfsAttuibutes[Index].PeiDepex= NULL;
+Fv->FfsAttuibutes[Index].PeiDepexLen = 0;
+Fv->FfsAttuibutes[Index].DxeDepex= NULL;
+Fv->FfsAttuibutes[Index].DxeDepexLen = 0;
+Fv->FfsAttuibutes[Index].SmmDepex= NULL;
+Fv->FfsAttuibutes[Index].SmmDepexLen = 0;
 Fv->FfsAttuibutes[Index].IsHandle = FALSE;
 Fv->FfsAttuibutes[Index].IsFvStart= FALSE;
 Fv->FfsAttuibutes[Index].IsFvEnd  = FALSE;
@@ -944,9 +948,13 @@ LibParseSection (
 LocalEncapData->Data= NULL;
 LocalEncapData->FvExtHeader = NULL;
 LocalEncapData->NextNode= NULL;
-LocalEncapData->RightNode = NULL;
-LocalEncapData->Depex = NULL;
-LocalEncapData->DepexLen = 0;
+LocalEncapData->RightNode = NULL;
+LocalEncapData->PeiDepex = NULL;
+LocalEncapData->PeiDepexLen = 0;
+LocalEncapData->DxeDepex = NULL;
+LocalEncapData->DxeDepexLen = 0;
+LocalEncapData->SmmDepex = NULL;
+LocalEncapData->SmmDepexLen = 0;
 LocalEncapData->UiNameSize = 0;
 LocalEncapData->FvId  = *FvCount;
   }
@@ -971,13 +979,19 @@ LibParseSection (
 if ((memcmp(>FfsAttuibutes[*FfsCount - 
1].GuidName, &(LocalEn

[edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2

2021-03-09 Thread GregX Yeh
Fixed replace file failure when FFS in multiple level FV and FV level over 2

Signed-off-by: GregX Yeh 
Cc: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/C/FMMT/FmmtLib.c | 56 ++-
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c 
b/BaseTools/Source/C/FMMT/FmmtLib.c
index b945e9b63d..26df0181c7 100644
--- a/BaseTools/Source/C/FMMT/FmmtLib.c
+++ b/BaseTools/Source/C/FMMT/FmmtLib.c
@@ -494,7 +494,7 @@ LibReadFvHeader (
 if ((FvLevel -1) == 0) {
   printf ("\n%s :\n", FvName);
 } else {
-  printf ("%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName);
+  printf ("\n%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName);
 }
   }
 
@@ -502,7 +502,7 @@ LibReadFvHeader (
   // Print FV header information
   //
   if (ViewFlag) {
-printf ("\n%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
+printf ("%sAttributes:%X\n", BlankSpace, (unsigned) 
VolumeHeader->Attributes);
 printf ("%sTotal Volume Size: 0x%08X\n", BlankSpace, (unsigned) 
VolumeHeader->FvLength);
 printf ("%sFree Volume Size:  0x%08X\n", BlankSpace, (unsigned) 
(VolumeHeader->FvLength - GetFreeOffset(InputFv)));
   }
@@ -789,7 +789,8 @@ LibParseSection (
   UINT8  *FvCount,
   BOOLEANViewFlag,
   BOOLEANErasePolarity,
-  BOOLEAN*IsFfsGenerated
+  BOOLEAN*IsFfsGenerated,
+  BOOLEANIsFfs
   )
 {
   UINT32  ParsedLength;
@@ -997,8 +998,12 @@ LibParseSection (
   break;
 
 case EFI_SECTION_COMPRESSION:
-  if (FirstInFlag) {
-Level ++;
+   if (IsFfs){
+ Level ++;
+   } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections ++;
 
@@ -1159,7 +1164,9 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated);
+  IsFfsGenerated,
+  FALSE
+  );
 
   if (CompressionType == EFI_STANDARD_COMPRESSION) {
 //
@@ -1181,8 +1188,12 @@ LibParseSection (
   // looks up the appropriate tool to use for extracting
   // a GUID defined FV section.
   //
-  if (FirstInFlag) {
+  if (IsFfs) {
 Level ++;
+  } else {
+if (FirstInFlag) {
+  Level ++;
+}
   }
   NumberOfSections++;
   EncapDataNeedUpdata = TRUE;
@@ -1216,7 +1227,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
 if (EFI_ERROR(Status)) {
   Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", NULL);
@@ -1471,7 +1483,8 @@ LibParseSection (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  IsFfsGenerated
+  IsFfsGenerated,
+  FALSE
   );
 if (EFI_ERROR (Status)) {
   Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", 
NULL);
@@ -1491,7 +1504,8 @@ LibParseSection (
 FvCount,
 ViewFlag,
 ErasePolarity,
-IsFfsGenerated
+IsFfsGenerated,
+FALSE
 );
   if (ExtractionTool != NULL) {
 free (ExtractionTool);
@@ -2016,7 +2030,7 @@ LibGetFileInfo (
 
   LocalEncapData->Level = Level;
   LocalEncapData->Type  = FMMT_ENCAP_TREE_FFS;
-LocalEncapData->FvExtHeader = NULL;
+  LocalEncapData->FvExtHeader = NULL;
   LocalEncapData->Depex = NULL;
   LocalEncapData->DepexLen = 0;
   LocalEncapData->UiNameSize = 0;
@@ -2099,7 +2113,8 @@ LibGetFileInfo (
   FvCount,
   ViewFlag,
   ErasePolarity,
-  
+  ,
+  TRUE
   );
 }
 if (EFI_ERROR (Status)) {
@@ -4198,10 +4213,13 @@ LibEncapNewFvFile(
   UINT32  header;
   UINT8   AlignN;
   UINT8   AlignV[1] = {0xFF};
+  UINT32  EntryFvId;
+
   AlignN  = 0;
   Id  = 0;
   InputFileSize   = 0;
   TmpFileSize = 0;
+  AlignmentFileSize   = 0;
   EncapFvIndex= 0;
   Index   = 0;
   OuterIndex  = 0;
@@ -4224,7 +4242,7 @@ LibEncapNewFvFile(
   IsLargeFile = FALSE;
   OutputFileSize  = 0;
   LargeFileSize   = 0x100;
-
+  EntryFvId

[edk2-devel] [PATCH] MdeModulePkg/Setup: Check ConfigAccess protocol in case it's destroyed

2019-07-08 Thread GregX Yeh
https://bugzilla.tianocore.org/show_bug.cgi?id=1920
Check ConfigAccess protocol is available before process user input.

Signed-off-by: GregX Yeh 
Cc: Dandan Bi 
Cc: Ray Ni 
Cc: Ted Kuo 
---
 .../Universal/SetupBrowserDxe/Presentation.c   | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index d7927725b2..7c36a6f2b7 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -20,6 +20,38 @@ UINT16 mCurFakeQestId;
 FORM_DISPLAY_ENGINE_FORM gDisplayFormData;
 BOOLEANmFinishRetrieveCall = FALSE;
 
+/**
+  Check whether the ConfigAccess protocol is available
+
+  @parm FormSet   FormSet of which the ConfigAcces protocol need to be 
checked.
+
+  @retval EFI_SUCCESS The function executed successfully.
+
+**/
+EFI_STATUS
+CheckConfigAccess(
+  IN FORM_BROWSER_FORMSET  *FormSet
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->HandleProtocol (
+  FormSet->DriverHandle,
+  ,
+  (VOID **) >ConfigAccess
+  );
+  if (EFI_ERROR (Status)) {
+//
+// Configuration Driver don't attach ConfigAccess protocol to its HII 
package
+// list, then there will be no configuration action required.
+// Or the ConfigAccess protocol has been uninstalled.
+//
+FormSet->ConfigAccess = NULL;
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
   Evaluate all expressions in a Form.
 
@@ -1686,6 +1718,8 @@ DisplayForm (
 return Status;
   }
 
+  CheckConfigAccess(gCurrentSelection->FormSet);
+
   Status = ProcessUserInput ();
   FreeDisplayFormData();
   return Status;
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43417): https://edk2.groups.io/g/devel/message/43417
Mute This Topic: https://groups.io/mt/32402217/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH] MdeModulePkg:Platform exception when callback function was destroyed by unconnected controller in setup browser

2019-06-18 Thread GregX Yeh
https://bugzilla.tianocore.org/show_bug.cgi?id=1920
Check ConfigAccess available before call callback function.

Signed-off-by: GregX Yeh 
Cc: Dandan Bi 
Cc: Ray Ni 
Cc: Ted Kuo 
---
 MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
index d7927725b2..a613ab350c 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
@@ -1958,6 +1958,23 @@ ProcessCallBackFunction (
   if (ConfigAccess == NULL) {
 return EFI_SUCCESS;
   }
+//
+// Check ConfigAccess available.
+//
+  Status = gBS->HandleProtocol (
+  FormSet->DriverHandle,
+  ,
+  (VOID **) >ConfigAccess
+  );
+  if (EFI_ERROR (Status)) {
+//
+// Configuration Driver don't attach ConfigAccess protocol to its HII 
package
+// list, then there will be no configuration action required.
+// Or the ConfigAccess protocol has been uninstalled.
+//
+FormSet->ConfigAccess = NULL;
+return EFI_SUCCESS;
+  }
 
   Link = GetFirstNode (>StatementListHead);
   while (!IsNull (>StatementListHead, Link)) {
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#42555): https://edk2.groups.io/g/devel/message/42555
Mute This Topic: https://groups.io/mt/32110310/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-