[edk2-devel] [PATCH 1/1] UefiPayloadPkg: Update the Module Info rather than create new Info.

2021-11-29 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3754

1. DxeCore will use ModuleInfo to install LoadedImage protocol for DxeCore.
2. DxeIpl will create the ModuleInfo of UniversalPayload. and
   UniversalPayload will create the ModuleInfo of DxeCore.
3. Only the first ModuleInfo will be used by DxeCore to install
   LoadedImage.
4. So it will create the mismatched ModuleInfo for DxeCore.

Changes:
1. When found the ModuleInfo, update it with DxeCore Info only.
2. Create new ModuleInfo if found no ModuleInfo.

Signed-off-by: Guomin Jiang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
---
 .../Library/PayloadEntryHobLib/Hob.c  | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c 
b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
index 61cd11ba0335..b840e7914f7a 100644
--- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
+++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
@@ -331,6 +331,30 @@ BuildModuleHob (
   ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
   ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
 
+  Hob = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
+  ASSERT (Hob != NULL);
+  while ((Hob = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob)) != NULL) {
+if (CompareGuid (&Hob->MemoryAllocationHeader.Name, 
&gEfiHobMemoryAllocModuleGuid)) {
+  //
+  // Update Dxe Core HOB.
+  //
+  Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+  Hob->MemoryAllocationHeader.MemoryLength  = ModuleLength;
+  Hob->MemoryAllocationHeader.MemoryType= EfiBootServicesCode;
+
+  ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof 
(Hob->MemoryAllocationHeader.Reserved));
+
+  CopyGuid (&Hob->ModuleName, ModuleName);
+  Hob->EntryPoint = EntryPoint;
+
+  //
+  // The Dxe Core HOB should only one. When find it, update and return
+  //
+  return;
+}
+Hob = GET_NEXT_HOB (Hob);
+  }
+
   Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof 
(EFI_HOB_MEMORY_ALLOCATION_MODULE));
 
   CopyGuid (&(Hob->MemoryAllocationHeader.Name), 
&gEfiHobMemoryAllocModuleGuid);
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH v2 1/1] UefiPayloadPkg: Skip ModuleInfo HOB in Payload

2021-12-02 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3754

1. DxeCore will use ModuleInfo to install LoadedImage protocol for DxeCore.
2. DxeIpl will create the ModuleInfo of UniversalPayload. and
   UniversalPayload will create the ModuleInfo of DxeCore.
3. UniversalPayload should skip the ModuleInfo from the DxeIpl to avoid
   the mismatched ModuleInfo for DxeCore.

Changes:
1. Use function IsHobNeed to check if the HOB should be added
2. Add the ModuleInfo check logic in IsHobNeed function

Signed-off-by: Guomin Jiang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
---
 .../UefiPayloadEntry/UniversalPayloadEntry.c  | 32 ++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 4d1096b32321..d743d29abe3f 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -238,6 +238,36 @@ FindAnotherHighestBelow4GResourceDescriptor (
   return ReturnResourceHob;
 }
 
+/**
+  Check the HOB and decide if it is need inside Payload
+
+  Payload maintainer may make decision which HOB is need or needn't
+  Then add the check logic in the function.
+
+  @param[in] Hob The HOB to check
+
+  @retval TRUE  If HOB is need inside Payload
+  @retval FALSE If HOB is needn't inside Payload
+**/
+BOOLEAN
+IsHobNeed (
+  EFI_PEI_HOB_POINTERS Hob
+  )
+{
+  if (Hob.Header->HobType == EFI_HOB_TYPE_HANDOFF) {
+return FALSE;
+  }
+
+  if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
+if (CompareGuid (&Hob.MemoryAllocationModule->MemoryAllocationHeader.Name, 
&gEfiHobMemoryAllocModuleGuid)) {
+  return FALSE;
+}
+  }
+
+  // Arrive here mean the HOB is need
+  return TRUE;
+}
+
 /**
   It will build HOBs based on information from bootloaders.
 
@@ -338,7 +368,7 @@ BuildHobs (
   // Since payload created new Hob, move all hobs except PHIT from boot loader 
hob list.
   //
   while (!END_OF_HOB_LIST (Hob)) {
-if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
+if (IsHobNeed (Hob)) {
   // Add this hob to payload HOB
   AddNewHob (&Hob);
 }
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH v2 0/2] Avoid Emulator Segmentation fault

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

Correct the logic to handle the case that XServer not present to avoid 
Segmentation fault

V2:
Fix typo error. 

Guomin Jiang (2):
  MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
  EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

 EmulatorPkg/EmuGopDxe/GopScreen.c | 11 ++-
 .../Console/GraphicsConsoleDxe/GraphicsConsole.c  |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH v2 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.

If we don't handle it, it will Segmentation fault.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 .../Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 8f0cba9fcde9..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -1,7 +1,7 @@
 /** @file
   This is the main routine for initializing the Graphics Console support 
routines.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
   }
 }
 
-if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+if (EFI_ERROR (Status) || (ModeNumber != 
Private->GraphicsOutput->Mode->Mode)) {
   //
   // Current graphics mode is not set or is not set to the mode which we 
have found,
   // set the new graphic mode.
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH v2 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

WindowOpen will fail in some case. for example, without XServer.

Shouldn't set ModeInfo in this case to avoid the caller use it
incorrectly

Cc: Andrew Fish 
Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 EmulatorPkg/EmuGopDxe/GopScreen.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c 
b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..9249eca1dd03 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -1,6 +1,6 @@
 /*++ @file
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -108,10 +108,6 @@ EmuGopSetMode (
   }
 
   ModeData = 
&Private->ModeData[ModeNumber];
-  This->Mode->Mode = ModeNumber;
-  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
-  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
-  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
 
   if (Private->HardwareNeedsStarting) {
 Status = EmuGopStartWindow (
@@ -128,6 +124,11 @@ EmuGopSetMode (
 Private->HardwareNeedsStarting = FALSE;
   }
 
+  This->Mode->Mode = ModeNumber;
+  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
+  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
+  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
+
   Status = Private->EmuGraphicsWindow->Size (
  Private->EmuGraphicsWindow,
  ModeData->HorizontalResolution,
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH v3 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.

If we don't handle it, it will Segmentation fault.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Reviewed-by: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 .../Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 8f0cba9fcde9..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -1,7 +1,7 @@
 /** @file
   This is the main routine for initializing the Graphics Console support 
routines.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
   }
 }
 
-if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+if (EFI_ERROR (Status) || (ModeNumber != 
Private->GraphicsOutput->Mode->Mode)) {
   //
   // Current graphics mode is not set or is not set to the mode which we 
have found,
   // set the new graphic mode.
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH v3 0/2] Avoid Emulator Segmentation fault

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

Correct the logic to handle the case that XServer not present to avoid 
Segmentation fault

V3:
Fix uncrustify error
V2:
Fix typo error. 

Guomin Jiang (2):
  MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
  EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

 EmulatorPkg/EmuGopDxe/GopScreen.c   | 13 +++--
 .../Console/GraphicsConsoleDxe/GraphicsConsole.c|  4 ++--
 2 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH v3 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

2022-03-01 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

WindowOpen will fail in some case. for example, without XServer.

Shouldn't set ModeInfo in this case to avoid the caller use it
incorrectly

Cc: Andrew Fish 
Reviewed-by: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 EmulatorPkg/EmuGopDxe/GopScreen.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c 
b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..88d95b88e162 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -1,6 +1,6 @@
 /*++ @file
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -107,11 +107,7 @@ EmuGopSetMode (
 return EFI_UNSUPPORTED;
   }
 
-  ModeData = 
&Private->ModeData[ModeNumber];
-  This->Mode->Mode = ModeNumber;
-  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
-  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
-  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
+  ModeData = &Private->ModeData[ModeNumber];
 
   if (Private->HardwareNeedsStarting) {
 Status = EmuGopStartWindow (
@@ -128,6 +124,11 @@ EmuGopSetMode (
 Private->HardwareNeedsStarting = FALSE;
   }
 
+  This->Mode->Mode = ModeNumber;
+  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
+  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
+  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
+
   Status = Private->EmuGraphicsWindow->Size (
  Private->EmuGraphicsWindow,
  ModeData->HorizontalResolution,
-- 
2.35.1.windows.2



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




[edk2-devel] [edk2-platforms Patch 0/3] Remove all UGA support

2022-03-10 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Cc: Nate DeSimone 
Cc: Chasel Chiu 
Cc: Eric Dong 
Cc: Liming Gao 
Cc: Ray Ni 

Guomin Jiang (3):
  PurleyOpenBoardPkg: Remove All UGA support
  BoardModulePkg: Remove all UGA support
  OptionRomPkg: Remove all UGA support

 .../CirrusLogic5430Dxe/CirrusLogic5430.c  | 522 +++---
 .../CirrusLogic5430Dxe/CirrusLogic5430.h  | 136 ++---
 .../CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf |   9 +-
 .../CirrusLogic5430UgaDraw.c  | 412 --
 Drivers/OptionRomPkg/OptionRomPkg.dec |   3 -
 .../Library/BoardBdsHookLib/BoardBdsHook.h|  70 ++-
 .../Library/BoardBdsHookLib/BoardBdsHook.h|  70 ++-
 7 files changed, 337 insertions(+), 885 deletions(-)
 delete mode 100644 
Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430UgaDraw.c

-- 
2.35.1.windows.2



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




[edk2-devel] [edk2-platforms Patch 1/3] PurleyOpenBoardPkg: Remove All UGA support

2022-03-10 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support in PurleyOpenBoardPkg

Cc: Nate DeSimone 
Cc: Chasel Chiu 
Signed-off-by: Guomin Jiang 
---
 .../Library/BoardBdsHookLib/BoardBdsHook.h| 70 +--
 1 file changed, 33 insertions(+), 37 deletions(-)

diff --git 
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
 
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
index fd943b3ca793..05e0a3f8920f 100644
--- 
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
+++ 
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for BDS Hook Library
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -55,13 +54,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 ///
 /// ConnectType
 ///
-#define CONSOLE_OUT 0x0001
-#define STD_ERROR   0x0002
-#define CONSOLE_IN  0x0004
-#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
+#define CONSOLE_OUT  0x0001
+#define STD_ERROR0x0002
+#define CONSOLE_IN   0x0004
+#define CONSOLE_ALL  (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
 
-extern EFI_GUID  gUefiShellFileGuid;
-extern EFI_BOOT_MODE gBootMode;
+extern EFI_GUID   gUefiShellFileGuid;
+extern EFI_BOOT_MODE  gBootMode;
 
 #define gPciRootBridge \
   { \
@@ -83,67 +82,66 @@ extern EFI_BOOT_MODE gBootMode;
   }
 
 typedef struct {
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  UINTN ConnectType;
+  EFI_DEVICE_PATH_PROTOCOL*DevicePath;
+  UINTN   ConnectType;
 } BDS_CONSOLE_CONNECT_ENTRY;
 
 //
 // Platform Root Bridge
 //
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
 
 //
 // Below is the platform console device path
 //
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   IsaBridge;
-  ACPI_HID_DEVICE_PATH  Keyboard;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH IsaBridge;
+  ACPI_HID_DEVICE_PATHKeyboard;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_KEYBOARD_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   PciDevice;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH PciDevice;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   Pci0Device;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH Pci0Device;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   PciBridge;
-  PCI_DEVICE_PATH   PciDevice;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH PciBridge;
+  PCI_DEVICE_PATH PciDevice;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
 
 //
 // Below is the boot option device path
 //
 
-#define CLASS_HID   3
-#define SUBCLASS_BOOT   1
-#define PROTOCOL_KEYBOARD   1
+#define CLASS_HID  3
+#define SUBCLASS_BOOT  1
+#define PROTOCOL_KEYBOARD  1
 
 typedef struct {
-  USB_CLASS_DEVICE_PATH   UsbClass;
-  EFI_DEVICE_PATH_PROTOCOLEnd;
+  USB_CLASS_DEVICE_PATH   UsbClass;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } USB_CLASS_FORMAT_DEVICE_PATH;
 
-extern USB_CLASS_FORMAT_DEVICE_PATH  gUsbClassKeyboardDevicePath;
+extern USB_CLASS_FORMAT_DEVICE_PATH  gUsbClassKeyboardDevicePath;
 
 //
 // Platform BDS Functions
 //
 
-
 /**
   Perform the memory test base on the memory test intensive level,
   and update the memory resource.
@@ -156,7 +154,7 @@ extern USB_CLASS_FORMAT_DEVICE_PATH  
gUsbClassKeyboardDevicePath;
 **/
 EFI_STATUS
 MemoryTest (
-  IN EXTENDMEM_COVERAGE_LEVEL Level
+  IN EXTENDMEM_COVERAGE_LEVEL  Level
   );
 
 /**
@@ -167,10 +165,9 @@ MemoryTest (
 **/
 VOID
 ConnectSequence (
-  IN EFI_BOOT_MODE  BootMode
+  IN EFI_BOOT_MODE  BootMode
   );
 
-
 /**
Compares boot priorities of two boot options
 
@@ -195,7 +192,6

[edk2-devel] [edk2-platforms Patch 2/3] BoardModulePkg: Remove all UGA support

2022-03-10 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Cc: Eric Dong 
Cc: Liming Gao 
Signed-off-by: Guomin Jiang 
---
 .../Library/BoardBdsHookLib/BoardBdsHook.h| 70 +--
 1 file changed, 33 insertions(+), 37 deletions(-)

diff --git 
a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h 
b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
index fd943b3ca793..05e0a3f8920f 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for BDS Hook Library
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -55,13 +54,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 ///
 /// ConnectType
 ///
-#define CONSOLE_OUT 0x0001
-#define STD_ERROR   0x0002
-#define CONSOLE_IN  0x0004
-#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
+#define CONSOLE_OUT  0x0001
+#define STD_ERROR0x0002
+#define CONSOLE_IN   0x0004
+#define CONSOLE_ALL  (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
 
-extern EFI_GUID  gUefiShellFileGuid;
-extern EFI_BOOT_MODE gBootMode;
+extern EFI_GUID   gUefiShellFileGuid;
+extern EFI_BOOT_MODE  gBootMode;
 
 #define gPciRootBridge \
   { \
@@ -83,67 +82,66 @@ extern EFI_BOOT_MODE gBootMode;
   }
 
 typedef struct {
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  UINTN ConnectType;
+  EFI_DEVICE_PATH_PROTOCOL*DevicePath;
+  UINTN   ConnectType;
 } BDS_CONSOLE_CONNECT_ENTRY;
 
 //
 // Platform Root Bridge
 //
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
 
 //
 // Below is the platform console device path
 //
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   IsaBridge;
-  ACPI_HID_DEVICE_PATH  Keyboard;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH IsaBridge;
+  ACPI_HID_DEVICE_PATHKeyboard;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_KEYBOARD_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   PciDevice;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH PciDevice;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   Pci0Device;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH Pci0Device;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
 
 typedef struct {
-  ACPI_HID_DEVICE_PATH  PciRootBridge;
-  PCI_DEVICE_PATH   PciBridge;
-  PCI_DEVICE_PATH   PciDevice;
-  EFI_DEVICE_PATH_PROTOCOL  End;
+  ACPI_HID_DEVICE_PATHPciRootBridge;
+  PCI_DEVICE_PATH PciBridge;
+  PCI_DEVICE_PATH PciDevice;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
 
 //
 // Below is the boot option device path
 //
 
-#define CLASS_HID   3
-#define SUBCLASS_BOOT   1
-#define PROTOCOL_KEYBOARD   1
+#define CLASS_HID  3
+#define SUBCLASS_BOOT  1
+#define PROTOCOL_KEYBOARD  1
 
 typedef struct {
-  USB_CLASS_DEVICE_PATH   UsbClass;
-  EFI_DEVICE_PATH_PROTOCOLEnd;
+  USB_CLASS_DEVICE_PATH   UsbClass;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
 } USB_CLASS_FORMAT_DEVICE_PATH;
 
-extern USB_CLASS_FORMAT_DEVICE_PATH  gUsbClassKeyboardDevicePath;
+extern USB_CLASS_FORMAT_DEVICE_PATH  gUsbClassKeyboardDevicePath;
 
 //
 // Platform BDS Functions
 //
 
-
 /**
   Perform the memory test base on the memory test intensive level,
   and update the memory resource.
@@ -156,7 +154,7 @@ extern USB_CLASS_FORMAT_DEVICE_PATH  
gUsbClassKeyboardDevicePath;
 **/
 EFI_STATUS
 MemoryTest (
-  IN EXTENDMEM_COVERAGE_LEVEL Level
+  IN EXTENDMEM_COVERAGE_LEVEL  Level
   );
 
 /**
@@ -167,10 +165,9 @@ MemoryTest (
 **/
 VOID
 ConnectSequence (
-  IN EFI_BOOT_MODE  BootMode
+  IN EFI_BOOT_MODE  BootMode
   );
 
-
 /**
Compares boot priorities of two boot options
 
@@ -195,7 +192,6 @@ RegisterStaticHotkey (
   VOID
   );
 
-
 /**
   Registers/Unregisters boot option hotkey
 
-- 
2.35.1.windows.2



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

[edk2-devel] [edk2-platforms Patch 3/3] OptionRomPkg: Remove all UGA support

2022-03-10 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 .../CirrusLogic5430Dxe/CirrusLogic5430.c  | 522 +++---
 .../CirrusLogic5430Dxe/CirrusLogic5430.h  | 136 ++---
 .../CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf |   9 +-
 .../CirrusLogic5430UgaDraw.c  | 412 --
 Drivers/OptionRomPkg/OptionRomPkg.dec |   3 -
 5 files changed, 271 insertions(+), 811 deletions(-)
 delete mode 100644 
Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430UgaDraw.c

diff --git a/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c 
b/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
index 4e7830ea94b3..a2f2c2ff60f4 100644
--- a/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
+++ b/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
@@ -11,7 +11,7 @@
   documentation on UGA for details on how to write a UGA driver that is able
   to function both in the EFI pre-boot environment and from the OS runtime.
 
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -21,7 +21,7 @@
 //
 #include "CirrusLogic5430.h"
 
-EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL  gCirrusLogic5430DriverBinding = {
   CirrusLogic5430ControllerDriverSupported,
   CirrusLogic5430ControllerDriverStart,
   CirrusLogic5430ControllerDriverStop,
@@ -42,21 +42,21 @@ UINT8  AttributeController[21] = {
 ///
 /// Generic Graphics Controller Register Settings
 ///
-UINT8 GraphicsController[9] = {
+UINT8  GraphicsController[9] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
 };
 
 //
 // 640 x 480 x 256 color @ 60 Hertz
 //
-UINT8 Crtc_640_480_256_60[28] = {
+UINT8  Crtc_640_480_256_60[28] = {
   0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,
   0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,
   0xff, 0x00, 0x00, 0x22
 };
 
-UINT16 Seq_640_480_256_60[15] = {
+UINT16  Seq_640_480_256_60[15] = {
   0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
   0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
 };
@@ -64,14 +64,14 @@ UINT16 Seq_640_480_256_60[15] = {
 //
 // 800 x 600 x 256 color @ 60 Hertz
 //
-UINT8 Crtc_800_600_256_60[28] = {
+UINT8  Crtc_800_600_256_60[28] = {
   0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,
   0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,
   0xFF, 0x00, 0x00, 0x22
 };
 
-UINT16 Seq_800_600_256_60[15] = {
+UINT16  Seq_800_600_256_60[15] = {
   0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
   0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
 };
@@ -79,14 +79,14 @@ UINT16 Seq_800_600_256_60[15] = {
 //
 // 1024 x 768 x 256 color @ 60 Hertz
 //
-UINT8 Crtc_1024_768_256_60[28] = {
+UINT8  Crtc_1024_768_256_60[28] = {
   0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,
   0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,
   0xFF, 0x4A, 0x00, 0x22
 };
 
-UINT16 Seq_1024_768_256_60[15] = {
+UINT16  Seq_1024_768_256_60[15] = {
   0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
   0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
 };
@@ -95,12 +95,11 @@ UINT16 Seq_1024_768_256_60[15] = {
 /// Table of supported video modes
 ///
 CIRRUS_LOGIC_5430_VIDEO_MODES  CirrusLogic5430VideoModes[] = {
-  {  640, 480, 8, 60, Crtc_640_480_256_60,  Seq_640_480_256_60,  0xe3 },
-  {  800, 600, 8, 60, Crtc_800_600_256_60,  Seq_800_600_256_60,  0xef },
+  { 640,  480, 8, 60, Crtc_640_480_256_60,  Seq_640_480_256_60,  0xe3 },
+  { 800,  600, 8, 60, Crtc_800_600_256_60,  Seq_800_600_256_60,  0xef },
   { 1024, 768, 8, 60, Crtc_1024_768_256_60, Seq_1024_768_256_60, 0xef }
 };
 
-
 /**
   CirrusLogic5430ControllerDriverSupported
 
@@ -111,15 +110,15 @@ CIRRUS_LOGIC_5430_VIDEO_MODES  
CirrusLogic5430VideoModes[] = {
 EFI_STATUS
 EFIAPI
 CirrusLogic5430ControllerDriverSupported (
-  IN EFI_DRIVER_BINDING_PROTOCOL*This,
-  IN EFI_HANDLE Controller,
-  IN EFI_DEVICE_PATH_PROTOCOL   *RemainingDevicePath
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE   Controller,
+  IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
   )
 {
-  EFI_STATUS  Status;
-  EFI_PCI_IO_PROTOCOL *PciIo;
-  PCI_TYPE00  Pci;
-  EFI_DEV_PATH*Node;
+  EFI_STATUS   Status;
+  EFI_PCI_IO_PROTOCOL  *PciIo;
+  PCI_TYPE00   Pci;
+  EFI_DEV_PATH *Node;
 
   //
   // Open the PCI I/O Protocol
@@ -127,7 +126,7 @@ CirrusLogic5430ControllerDriverSupported (
   Status = gBS->OpenProtocol (
   Controller,
   &gEfiPciIoProtocolGuid,
-  (VOID **) &PciIo,
+

[edk2-devel] [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-12 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840

Use DEBUG_FILE_PATH to control ASSERT path

Motivation and Goal:
1. Make replication build more easy and less toolchain dependency
2. Consume the ASSERT string easy for downstream
3. Make code more clear

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Guomin Jiang 
---
 MdePkg/Include/Library/DebugLib.h | 34 +--
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 8d3d08638d73..a76a268a00b6 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL 
implementations.
 
-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -85,6 +85,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define DEBUG_LINE_NUMBER  __LINE__
 #endif
 
+//
+// Source file path.
+// Default is use the __FILE__ macro value provided by compiler. The __FILE__
+// mapping can be overriden by predefining DEBUG_FILE_PATH
+//
+// Defining DEBUG_FILE_PATH to a fixed value is useful when comparing builds
+// across machine or configuration with different slash or path file.
+//
+#ifndef DEBUG_FILE_PATH
+#define DEBUG_FILE_PATH  __FILE__
+#endif
+
+//
+// Use below override to keep CLANG specific behavior
+//
+#if defined (__clang__) && defined (__FILE_NAME__)
+  #undef DEBUG_FILE_PATH
+#define DEBUG_FILE_PATH  __FILE_NAME__
+#endif
+
 /**
   Macro that converts a Boolean expression to a Null-terminated ASCII string.
 
@@ -337,17 +357,9 @@ UnitTestDebugAssert (
   IN CONST CHAR8  *Description
   );
 
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE_PATH, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
 #else
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  DebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE_PATH, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
 #endif
 
 /**
-- 
2.35.1.windows.2



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




Re: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-12 Thread Guomin Jiang
Hi Liming,

Below is the detail why need this change. If you only care usage. Please jump 
to "How to use it" directly.

Why need:
1. Replication build is not new, you can refer https://reproducible-builds.org 
for detail
2. The benefit is that 1) make sure the same commit generate same binary so we 
can sure that it is not modified by anyone 2) store the binary in the repo 
without concern of different binary with same code.

What's barrier in EDK2 implement?
1. Very depend on Toolchain(for example VS, GCC, CLANG). Different toolchain 
have different feature set and different toolchain version have different 
feature set.
2. Deploy new toolchain need big effort, include but not limit deploy it in CI 
CD system, update toolchain, size concern, feature change, etc

What's the change:
1. The change want to address one issue that we encounter in replication build: 
the ASSERT in EDK2 will be different in different environment. For example: 
file path, back slash or forward slash, etc

How to use it:
1. If you want to keep current ASSERT string format. No action is required and 
the change keep back compatible
2. If you want to customize the ASSERT string format. You can use additional 
tool to generate PATH and define macro in BuildOptions or tools_def.

Note:
1. Replication build need many effort: 1) address the pdb path, 2) address the 
timestamp, etc
2. This change is not target for resolving all issue in replication build
3. I think it is a small step toward space even though it haven't fix every 
thing.

Thank
Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> gaoliming
> Sent: Wednesday, April 13, 2022 9:03 AM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: Kinney, Michael D ; Liu, Zhiguang
> 
> Subject: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> DEBUG_FILE_PATH to specify debug file path.
> 
> Guomin:
>   Can you introduce DEBUG_FILE_PATH usage? If the developer wants to
> enable this feature, how configure DEBUG_FILE_PATH?
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: Guomin Jiang 
> > 发送时间: 2022年4月12日 18:25
> > 收件人: devel@edk2.groups.io
> > 抄送: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu 
> > 主题: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify
> > debug file path.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> >
> > Use DEBUG_FILE_PATH to control ASSERT path
> >
> > Motivation and Goal:
> > 1. Make replication build more easy and less toolchain dependency 2.
> > Consume the ASSERT string easy for downstream 3. Make code more clear
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Signed-off-by: Guomin Jiang 
> > ---
> >  MdePkg/Include/Library/DebugLib.h | 34
> > +--
> >  1 file changed, 23 insertions(+), 11 deletions(-)
> >
> > diff --git a/MdePkg/Include/Library/DebugLib.h
> > b/MdePkg/Include/Library/DebugLib.h
> > index 8d3d08638d73..a76a268a00b6 100644
> > --- a/MdePkg/Include/Library/DebugLib.h
> > +++ b/MdePkg/Include/Library/DebugLib.h
> > @@ -8,7 +8,7 @@
> >of size reduction when compiler optimization is disabled. If
> > MDEPKG_NDEBUG is
> >defined, then debug and assert related macros wrapped by it are the
> > NULL implementations.
> >
> > -Copyright (c) 2006 - 2020, Intel Corporation. All rights
> > reserved.
> > +Copyright (c) 2006 - 2022, Intel Corporation. All rights
> > +reserved.
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -85,6 +85,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #define DEBUG_LINE_NUMBER  __LINE__  #endif
> >
> > +//
> > +// Source file path.
> > +// Default is use the __FILE__ macro value provided by compiler. The
> > __FILE__
> > +// mapping can be overriden by predefining DEBUG_FILE_PATH // //
> > +Defining DEBUG_FILE_PATH to a fixed value is useful when comparing
> > builds
> > +// across machine or configuration with different slash or path file.
> > +//
> > +#ifndef DEBUG_FILE_PATH
> > +#define DEBUG_FILE_PATH  __FILE__
> > +#endif
> > +
> > +//
> > +// Use below override to keep CLANG specific behavior // #if defined
> > +(__clang__) && defined (__FILE_NAME__)
> > +  #undef DEBUG_FILE_PATH
> > +#define DEBUG_FILE_PATH  __FILE_NAME__ #endif
> > +
> >  /**
> >Macro that converts a Boolean expression to a Null-terminated ASCII
> > string.
> >
> > @@ -337,17 +357,9 @@ UnitTestDebugAssert (
> >IN CONST CHAR8  *Description
> >);
> >
> > -  #if define

Re: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-20 Thread Guomin Jiang
Hi Liming,

I just add ```-D DEBUG_FILE_PATH=gEfiCallerBaseName``` to BuildOptions

Thanks
Guomin

> -Original Message-
> From: gaoliming 
> Sent: Sunday, April 17, 2022 11:21 AM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: Kinney, Michael D ; Liu, Zhiguang
> 
> Subject: 回复: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> DEBUG_FILE_PATH to specify debug file path.
> 
> Guomin:
>   I understand the purpose. But, I don't see the complete solution to
> configure DEBUG_FILE_PATH for every source file in order to meet with the
> debug image reproducible builds. Have you verified this solution with the real
> DEBUG_FILE_PATH for every source file? Or, you just set DEBUG_FILE_PATH
> to the same value for the different source file?
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: Jiang, Guomin 
> > 发送时间: 2022年4月13日 13:43
> > 收件人: devel@edk2.groups.io; Gao, Liming 
> > 抄送: Kinney, Michael D ; Liu, Zhiguang
> > 
> > 主题: RE: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> > DEBUG_FILE_PATH to specify debug file path.
> >
> > Hi Liming,
> >
> > Below is the detail why need this change. If you only care usage.
> > Please jump to "How to use it" directly.
> >
> > Why need:
> > 1. Replication build is not new, you can refer
> > https://reproducible-builds.org for detail 2. The benefit is that 1)
> > make sure the same commit generate same binary so we can sure that it
> > is not modified by anyone 2) store the binary in the repo without
> > concern of different binary with same code.
> >
> > What's barrier in EDK2 implement?
> > 1. Very depend on Toolchain(for example VS, GCC, CLANG). Different
> > toolchain have different feature set and different toolchain version
> > have different feature set.
> > 2. Deploy new toolchain need big effort, include but not limit deploy
> > it in CI CD system, update toolchain, size concern, feature change,
> > etc
> >
> > What's the change:
> > 1. The change want to address one issue that we encounter in
> > replication
> > build: the ASSERT in EDK2 will be different in different environment.
> > For
> > example: file path, back slash or forward slash, etc
> >
> > How to use it:
> > 1. If you want to keep current ASSERT string format. No action is
> > required and the change keep back compatible 2. If you want to
> > customize the ASSERT string format. You can use additional tool to
> > generate PATH and define macro in BuildOptions or tools_def.
> >
> > Note:
> > 1. Replication build need many effort: 1) address the pdb path, 2)
> > address the timestamp, etc 2. This change is not target for resolving
> > all issue in replication build 3. I think it is a small step toward
> > space even though it haven't fix every thing.
> >
> > Thank
> > Guomin
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> > > gaoliming
> > > Sent: Wednesday, April 13, 2022 9:03 AM
> > > To: Jiang, Guomin ; devel@edk2.groups.io
> > > Cc: Kinney, Michael D ; Liu, Zhiguang
> > > 
> > > Subject: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> > > DEBUG_FILE_PATH to specify debug file path.
> > >
> > > Guomin:
> > >   Can you introduce DEBUG_FILE_PATH usage? If the developer wants to
> > > enable this feature, how configure DEBUG_FILE_PATH?
> > >
> > > Thanks
> > > Liming
> > > > -邮件原件-
> > > > 发件人: Guomin Jiang 
> > > > 发送时间: 2022年4月12日 18:25
> > > > 收件人: devel@edk2.groups.io
> > > > 抄送: Michael D Kinney ; Liming Gao
> > > > ; Zhiguang Liu 
> > > > 主题: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to
> specify
> > > > debug file path.
> > > >
> > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> > > >
> > > > Use DEBUG_FILE_PATH to control ASSERT path
> > > >
> > > > Motivation and Goal:
> > > > 1. Make replication build more easy and less toolchain dependency 2.
> > > > Consume the ASSERT string easy for downstream 3. Make code more
> > clear
> > > >
> > > > Cc: Michael D Kinney 
> > > > Cc: Liming Gao 
> > > > Cc: Zhiguang Liu 
> > > > Signed-off-by: Guomin Jiang 
> > > > ---
> > > >  MdePkg/Include/Library/DebugLib.h | 34
> > > > +--
> > > >  1 file chan

[edk2-devel] [PATCH edk2-platforms 1/1] IntelSiliconPkg/PeiSmmAccessLib: Remove the S3 check

2021-10-11 Thread Guomin Jiang
Always install the SmmAccessPpi without checking S3 boot mode.
The caller can add the S3 check to decide if it is need to install the
Ppi

Signed-off-by: Guomin Jiang 
Cc: Ray Ni 
Cc: Rangasai V Chaganty 
---
 .../PeiSmmAccessLib/PeiSmmAccessLib.inf   | 40 ---
 .../Library/PeiSmmAccessLib/PeiSmmAccessLib.c | 16 +---
 2 files changed, 19 insertions(+), 37 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
index 0c2411ea57c8..8cf6d7923398 100644
--- 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
+++ 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.inf
@@ -1,41 +1,35 @@
 ## @file
 # Library description file for the SmmAccess
 #
-# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
 
-
 [Defines]
-INF_VERSION = 0x00010017
-BASE_NAME = PeiSmmAccessLib
-FILE_GUID = 54020881-B594-442A-8377-A57AFF98C7CF
-VERSION_STRING = 1.0
-MODULE_TYPE = PEIM
-LIBRARY_CLASS = SmmAccessLib
-
+  INF_VERSION= 0x00010017
+  BASE_NAME  = PeiSmmAccessLib
+  FILE_GUID  = 54020881-B594-442A-8377-A57AFF98C7CF
+  VERSION_STRING = 1.0
+  MODULE_TYPE= PEIM
+  LIBRARY_CLASS  = SmmAccessLib
 
 [LibraryClasses]
-BaseLib
-BaseMemoryLib
-HobLib
-PciSegmentLib
-PeiServicesLib
-
+  BaseLib
+  BaseMemoryLib
+  HobLib
+  PciSegmentLib
+  PeiServicesLib
 
 [Packages]
-MdePkg/MdePkg.dec
-IntelSiliconPkg/IntelSiliconPkg.dec
-
+  MdePkg/MdePkg.dec
+  IntelSiliconPkg/IntelSiliconPkg.dec
 
 [Sources]
-PeiSmmAccessLib.c
-
+  PeiSmmAccessLib.c
 
 [Ppis]
-gEfiPeiMmAccessPpiGuid ## PRODUCES
-
+  gEfiPeiMmAccessPpiGuid ## PRODUCES
 
 [Guids]
-gEfiSmmSmramMemoryGuid
+  gEfiSmmSmramMemoryGuid
diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
index d9bf4fba983e..0e3f230e413e 100644
--- 
a/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
+++ 
b/Silicon/Intel/IntelSiliconPkg/Feature/SmmAccess/Library/PeiSmmAccessLib/PeiSmmAccessLib.c
@@ -1,7 +1,7 @@
 /** @file
   This is to publish the SMM Access Ppi instance.
 
-  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
 
 **/
@@ -234,7 +234,7 @@ GetCapabilities (
 /**
   This function is to install an SMM Access PPI
   - Introduction \n
-An API to install an instance of EFI_PEI_MM_ACCESS_PPI. This PPI is 
commonly used to control SMM mode memory access for S3 resume.
+An API to install an instance of EFI_PEI_MM_ACCESS_PPI.
 
 @retval EFI_SUCCESS   - Ppi successfully started and installed.
 @retval EFI_NOT_FOUND - Ppi can't be found.
@@ -252,19 +252,7 @@ PeiInstallSmmAccessPpi (
   EFI_SMRAM_HOB_DESCRIPTOR_BLOCK  *DescriptorBlock;
   SMM_ACCESS_PRIVATE_DATA *SmmAccessPrivate;
   VOID*HobList;
-  EFI_BOOT_MODE   BootMode;
 
-  Status = PeiServicesGetBootMode (&BootMode);
-  if (EFI_ERROR (Status)) {
-//
-// If not in S3 boot path. do nothing
-//
-return EFI_SUCCESS;
-  }
-
-  if (BootMode != BOOT_ON_S3_RESUME) {
-return EFI_SUCCESS;
-  }
   //
   // Initialize private data
   //
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 1/1] SecurityPkg/FvReportPei: Remove the ASSERT to allow neither M nor V

2021-10-14 Thread Guomin Jiang
REF: https://bugzilla.tiancore.org/show_bug.cgi?id=2673

M mean that Measured Boot, V mean that Verified Boot.

The FvReport do below:
1. Do nothing if neither M nor V
2. Allocate pages to save the firmware volume and use it to install
   firmware info Ppi
3. Install PreHashFv Ppi if the FV need measurement.
4. Verify the Hash if the FV need verification

Notes:
1. The component is used to verify the FV or measure the FV
2. Copy action is just for security purpose but not main purpose.
3. If you use this component, Doesn't need to copy in other compoent
   which result time consumption.

Signed-off-by: Guomin Jiang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
---
 SecurityPkg/FvReportPei/FvReportPei.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/FvReportPei/FvReportPei.c 
b/SecurityPkg/FvReportPei/FvReportPei.c
index 9f3ebd8ed174..6dce3298e3a2 100644
--- a/SecurityPkg/FvReportPei/FvReportPei.c
+++ b/SecurityPkg/FvReportPei/FvReportPei.c
@@ -150,10 +150,12 @@ VerifyHashedFv (
   FvHashValue = HashValue;
   for (FvIndex = 0; FvIndex < FvNumber; ++FvIndex) {
 //
-// FV must be meant for verified boot and/or measured boot.
+// Not meant for verified boot and/or measured boot?
 //
-ASSERT ((FvInfo[FvIndex].Flag & HASHED_FV_FLAG_VERIFIED_BOOT) != 0 ||
-(FvInfo[FvIndex].Flag & HASHED_FV_FLAG_MEASURED_BOOT) != 0);
+if ((FvInfo[FvIndex].Flag & HASHED_FV_FLAG_VERIFIED_BOOT) == 0 &&
+  (FvInfo[FvIndex].Flag & HASHED_FV_FLAG_MEASURED_BOOT) == 0) {
+  continue;
+}
 
 //
 // Skip any FV not meant for current boot mode.
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH v2 1/1] SecurityPkg/FvReportPei: Remove the ASSERT to allow neither M nor V

2021-10-14 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2673

M mean that Measured Boot, V mean that Verified Boot.

The FvReport do below:
1. Do nothing if neither M nor V
2. Allocate pages to save the firmware volume and use it to install
   firmware info Ppi
3. Install PreHashFv Ppi if the FV need measurement.
4. Verify the Hash if the FV need verification

Notes:
1. The component is used to verify the FV or measure the FV
2. Copy action is just for security purpose but not main purpose.
3. If you use this component, Doesn't need to copy in other compoent
   which result time consumption.

Signed-off-by: Guomin Jiang 
Cc: Jiewen Yao 
Cc: Jian J Wang 
---
 SecurityPkg/FvReportPei/FvReportPei.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/FvReportPei/FvReportPei.c 
b/SecurityPkg/FvReportPei/FvReportPei.c
index 9f3ebd8ed174..6dce3298e3a2 100644
--- a/SecurityPkg/FvReportPei/FvReportPei.c
+++ b/SecurityPkg/FvReportPei/FvReportPei.c
@@ -150,10 +150,12 @@ VerifyHashedFv (
   FvHashValue = HashValue;
   for (FvIndex = 0; FvIndex < FvNumber; ++FvIndex) {
 //
-// FV must be meant for verified boot and/or measured boot.
+// Not meant for verified boot and/or measured boot?
 //
-ASSERT ((FvInfo[FvIndex].Flag & HASHED_FV_FLAG_VERIFIED_BOOT) != 0 ||
-(FvInfo[FvIndex].Flag & HASHED_FV_FLAG_MEASURED_BOOT) != 0);
+if ((FvInfo[FvIndex].Flag & HASHED_FV_FLAG_VERIFIED_BOOT) == 0 &&
+  (FvInfo[FvIndex].Flag & HASHED_FV_FLAG_MEASURED_BOOT) == 0) {
+  continue;
+}
 
 //
 // Skip any FV not meant for current boot mode.
-- 
2.30.0.windows.2



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




Re: [edk2-devel] [PATCH v6 2/3] CryptoPkg/CryptLib: Add QuickSort function on BaseLib

2021-10-21 Thread Guomin Jiang
Reviewed-by: Guomin Jiang 

> -Original Message-
> From: Kuo, IanX 
> Sent: Monday, October 18, 2021 12:21 PM
> To: devel@edk2.groups.io
> Cc: Chan, Amy ; Ni, Ray ; Kuo,
> IanX ; Yao, Jiewen ; Wang,
> Jian J ; Lu, XiaoyuX ; Jiang,
> Guomin 
> Subject: [PATCH v6 2/3] CryptoPkg/CryptLib: Add QuickSort function on
> BaseLib
> 
> From: IanX Kuo 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3675
> 
> Use QuickSort instead of QuickSortWorker
> 
> Cc: Ray Ni 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Xiaoyu Lu 
> Cc: Guomin Jiang 
> Signed-off-by: IanX Kuo 
> ---
>  .../Library/BaseCryptLib/SysCall/CrtWrapper.c | 92 +--
>  1 file changed, 2 insertions(+), 90 deletions(-)
> 
> diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
> b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
> index 42235ab96a..b10edaae5b 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
> +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
> @@ -2,7 +2,7 @@
>C Run-Time Libraries (CRT) Wrapper Implementation for OpenSSL-based
> 
>Cryptographic Library.
> 
> 
> 
> -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> 
> +Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -22,91 +22,6 @@ int
>IN  VOID  *Buffer2
> 
>);
> 
> 
> 
> -//
> 
> -// Duplicated from EDKII BaseSortLib for qsort() wrapper
> 
> -//
> 
> -STATIC
> 
> -VOID
> 
> -QuickSortWorker (
> 
> -  IN OUTVOID  *BufferToSort,
> 
> -  IN CONST  UINTN Count,
> 
> -  IN CONST  UINTN ElementSize,
> 
> -  INSORT_COMPARE  CompareFunction,
> 
> -  INVOID  *Buffer
> 
> -  )
> 
> -{
> 
> -  VOID*Pivot;
> 
> -  UINTN   LoopCount;
> 
> -  UINTN   NextSwapLocation;
> 
> -
> 
> -  ASSERT(BufferToSort!= NULL);
> 
> -  ASSERT(CompareFunction != NULL);
> 
> -  ASSERT(Buffer  != NULL);
> 
> -
> 
> -  if (Count < 2 || ElementSize  < 1) {
> 
> -return;
> 
> -  }
> 
> -
> 
> -  NextSwapLocation = 0;
> 
> -
> 
> -  //
> 
> -  // Pick a pivot (we choose last element)
> 
> -  //
> 
> -  Pivot = ((UINT8 *)BufferToSort + ((Count - 1) * ElementSize));
> 
> -
> 
> -  //
> 
> -  // Now get the pivot such that all on "left" are below it
> 
> -  // and everything "right" are above it
> 
> -  //
> 
> -  for (LoopCount = 0; LoopCount < Count - 1;  LoopCount++)
> 
> -  {
> 
> -//
> 
> -// If the element is less than the pivot
> 
> -//
> 
> -if (CompareFunction ((VOID *)((UINT8 *)BufferToSort + ((LoopCount) *
> ElementSize)), Pivot) <= 0) {
> 
> -  //
> 
> -  // Swap
> 
> -  //
> 
> -  CopyMem (Buffer, (UINT8 *)BufferToSort + (NextSwapLocation *
> ElementSize), ElementSize);
> 
> -  CopyMem ((UINT8 *)BufferToSort + (NextSwapLocation * ElementSize),
> (UINT8 *)BufferToSort + ((LoopCount) * ElementSize), ElementSize);
> 
> -  CopyMem ((UINT8 *)BufferToSort + ((LoopCount) * ElementSize), Buffer,
> ElementSize);
> 
> -
> 
> -  //
> 
> -  // Increment NextSwapLocation
> 
> -  //
> 
> -  NextSwapLocation++;
> 
> -}
> 
> -  }
> 
> -  //
> 
> -  // Swap pivot to its final position (NextSwapLocation)
> 
> -  //
> 
> -  CopyMem (Buffer, Pivot, ElementSize);
> 
> -  CopyMem (Pivot, (UINT8 *)BufferToSort + (NextSwapLocation *
> ElementSize), ElementSize);
> 
> -  CopyMem ((UINT8 *)BufferToSort + (NextSwapLocation * ElementSize),
> Buffer, ElementSize);
> 
> -
> 
> -  //
> 
> -  // Now recurse on 2 partial lists.  Neither of these will have the 'pivot'
> element.
> 
> -  // IE list is sorted left half, pivot element, sorted right half...
> 
> -  //
> 
> -  QuickSortWorker (
> 
> -BufferToSort,
> 
> -NextSwapLocation,
> 
> -ElementSize,
> 
> -CompareFunction,
> 
> -Buffer
> 
> -);
> 
> -
> 
> -  QuickSortWorker (
> 
> -(UINT8 *)BufferToSort + (NextSwapLocation + 1) * ElementSize,
> 
> -Count - NextSwapLocation - 1,
> 
> -ElementSize,
> 
> -CompareFunction,
> 
> -Buffer
> 
> -);
> 
> -
> 
> -  return;
> 
> -}
> 
> -
> 
>  //-
> 
>  // Standard C Run-time Li

Re: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-05-13 Thread Guomin Jiang
imestamp, etc 2. This change is not target for
> > > > resolving all issue in replication build 3. I think it is a small
> > > > step toward space even though it haven't fix every thing.
> > > >
> > > > Thank
> > > > Guomin
> > > >
> > > > > -Original Message-
> > > > > From: devel@edk2.groups.io  On Behalf Of
> > > > > gaoliming
> > > > > Sent: Wednesday, April 13, 2022 9:03 AM
> > > > > To: Jiang, Guomin ; devel@edk2.groups.io
> > > > > Cc: Kinney, Michael D ; Liu,
> > > > > Zhiguang 
> > > > > Subject: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> > > > > DEBUG_FILE_PATH to specify debug file path.
> > > > >
> > > > > Guomin:
> > > > >   Can you introduce DEBUG_FILE_PATH usage? If the developer
> > > > > wants
> > to
> > > > > enable this feature, how configure DEBUG_FILE_PATH?
> > > > >
> > > > > Thanks
> > > > > Liming
> > > > > > -邮件原件-
> > > > > > 发件人: Guomin Jiang 
> > > > > > 发送时间: 2022年4月12日 18:25
> > > > > > 收件人: devel@edk2.groups.io
> > > > > > 抄送: Michael D Kinney ; Liming Gao
> > > > > > ; Zhiguang Liu
> > > > > > 
> > > > > > 主题: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to
> > > specify
> > > > > > debug file path.
> > > > > >
> > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> > > > > >
> > > > > > Use DEBUG_FILE_PATH to control ASSERT path
> > > > > >
> > > > > > Motivation and Goal:
> > > > > > 1. Make replication build more easy and less toolchain dependency
> 2.
> > > > > > Consume the ASSERT string easy for downstream 3. Make code
> > > > > > more
> > > > clear
> > > > > >
> > > > > > Cc: Michael D Kinney 
> > > > > > Cc: Liming Gao 
> > > > > > Cc: Zhiguang Liu 
> > > > > > Signed-off-by: Guomin Jiang 
> > > > > > ---
> > > > > >  MdePkg/Include/Library/DebugLib.h | 34
> > > > > > +--
> > > > > >  1 file changed, 23 insertions(+), 11 deletions(-)
> > > > > >
> > > > > > diff --git a/MdePkg/Include/Library/DebugLib.h
> > > > > > b/MdePkg/Include/Library/DebugLib.h
> > > > > > index 8d3d08638d73..a76a268a00b6 100644
> > > > > > --- a/MdePkg/Include/Library/DebugLib.h
> > > > > > +++ b/MdePkg/Include/Library/DebugLib.h
> > > > > > @@ -8,7 +8,7 @@
> > > > > >of size reduction when compiler optimization is disabled.
> > > > > > If MDEPKG_NDEBUG is
> > > > > >defined, then debug and assert related macros wrapped by it
> > > > > > are the NULL implementations.
> > > > > >
> > > > > > -Copyright (c) 2006 - 2020, Intel Corporation. All rights
> > > > > > reserved.
> > > > > > +Copyright (c) 2006 - 2022, Intel Corporation. All rights
> > > > > > +reserved.
> > > > > >  SPDX-License-Identifier: BSD-2-Clause-Patent
> > > > > >
> > > > > >  **/
> > > > > > @@ -85,6 +85,26 @@ SPDX-License-Identifier:
> > > > > > BSD-2-Clause-Patent #define DEBUG_LINE_NUMBER  __LINE__
> > > > > > #endif
> > > > > >
> > > > > > +//
> > > > > > +// Source file path.
> > > > > > +// Default is use the __FILE__ macro value provided by compiler.
> > > > > > +The
> > > > > > __FILE__
> > > > > > +// mapping can be overriden by predefining DEBUG_FILE_PATH //
> > > > > > +// Defining DEBUG_FILE_PATH to a fixed value is useful when
> > > > > > +comparing
> > > > > > builds
> > > > > > +// across machine or configuration with different slash or path 
> > > > > > file.
> > > > > > +//
> > > > > > +#ifndef DEBUG_FILE_PATH
> > > > > > +#define DEBUG_FILE_PATH  __FILE__ #endif
> > > > > > +
> > > > > > +//
> > > > > > +// Use below override to keep CLANG specific behavior // #if
> > > > > > +defined
> > > > > > +(__clang__) && defined (__FILE_NAME__)
> > > > > > +  #undef DEBUG_FILE_PATH
> > > > > > +#define DEBUG_FILE_PATH  __FILE_NAME__ #endif
> > > > > > +
> > > > > >  /**
> > > > > >Macro that converts a Boolean expression to a
> > > > > > Null-terminated ASCII string.
> > > > > >
> > > > > > @@ -337,17 +357,9 @@ UnitTestDebugAssert (
> > > > > >IN CONST CHAR8  *Description
> > > > > >);
> > > > > >
> > > > > > -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> > > > > > _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__,
> > > > > > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > > > > > -  #else
> > > > > > -#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__,
> > > > > > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > > > > > -  #endif
> > > > > > +#define _ASSERT(Expression)  UnitTestDebugAssert
> > > > (DEBUG_FILE_PATH,
> > > > > > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > > > #else
> > > > > > -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> > > > > > _ASSERT(Expression)  DebugAssert (__FILE_NAME__,
> > > > > DEBUG_LINE_NUMBER,
> > > > > > DEBUG_EXPRESSION_STRING (Expression))
> > > > > > -  #else
> > > > > > -#define _ASSERT(Expression)  DebugAssert (__FILE__,
> > > > > > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > > > > > -  #endif
> > > > > > +#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE_PATH,
> > > > > > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > > > > #endif
> > > > > >
> > > > > >  /**
> > > > > > --
> > > > > > 2.35.1.windows.2
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > 
> > > > >
> > >
> > >
> 
> 



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




[edk2-devel] [edk2-platforms Patch v2 1/3] PurleyOpenBoardPkg: Remove All UGA support

2022-07-13 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support in PurleyOpenBoardPkg

Cc: Nate DeSimone 
Cc: Chasel Chiu 
Signed-off-by: Guomin Jiang 
---
 .../BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
 
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
index fd943b3ca793..292d02a4ef4d 100644
--- 
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
+++ 
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for BDS Hook Library
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.26.2.windows.1



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




[edk2-devel] [edk2-platforms Patch v2 3/3] OptionRomPkg: Remove all UGA support

2022-07-13 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 .../CirrusLogic5430Dxe/CirrusLogic5430.c  |  91 +---
 .../CirrusLogic5430Dxe/CirrusLogic5430.h  |  21 +-
 .../CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf |   9 +-
 .../CirrusLogic5430UgaDraw.c  | 412 --
 Drivers/OptionRomPkg/OptionRomPkg.dec |   3 -
 5 files changed, 3 insertions(+), 533 deletions(-)
 delete mode 100644 
Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430UgaDraw.c

diff --git a/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c 
b/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
index 4e7830ea94b3..48e0c012957a 100644
--- a/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
+++ b/Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430.c
@@ -11,7 +11,7 @@
   documentation on UGA for details on how to write a UGA driver that is able
   to function both in the EFI pre-boot environment and from the OS runtime.
 
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -316,7 +316,6 @@ CirrusLogic5430ControllerDriverStart (
 goto Error;
   }
 
-  if (FeaturePcdGet (PcdSupportGop)) {
 //
 // Set Gop Device Path
 //
@@ -357,7 +356,6 @@ CirrusLogic5430ControllerDriverStart (
   NULL
   );
 }
-  }
 
   //
   // Construct video mode buffer
@@ -367,24 +365,6 @@ CirrusLogic5430ControllerDriverStart (
 goto Error;
   }
 
-  if (FeaturePcdGet (PcdSupportUga)) {
-//
-// Start the UGA Draw software stack.
-//
-Status = CirrusLogic5430UgaDrawConstructor (Private);
-ASSERT_EFI_ERROR (Status);
-
-Private->UgaDevicePath = ParentDevicePath;
-Status = gBS->InstallMultipleProtocolInterfaces (
-&Controller,
-&gEfiUgaDrawProtocolGuid,
-&Private->UgaDraw,
-&gEfiDevicePathProtocolGuid,
-Private->UgaDevicePath,
-NULL
-);
-
-  } else if (FeaturePcdGet (PcdSupportGop)) {
 if (Private->GopDevicePath == NULL) {
   //
   // If RemainingDevicePath is the End of Device Path Node, 
@@ -410,14 +390,6 @@ CirrusLogic5430ControllerDriverStart (
   NULL
   );
 }
-  } else {
-//
-// This driver must support eithor GOP or UGA or both.
-//
-ASSERT (FALSE);
-Status = EFI_UNSUPPORTED;
-  }
-
 
 Error:
   if (EFI_ERROR (Status)) {
@@ -470,55 +442,11 @@ CirrusLogic5430ControllerDriverStop (
   IN EFI_HANDLE *ChildHandleBuffer
   )
 {
-  EFI_UGA_DRAW_PROTOCOL   *UgaDraw;
   EFI_GRAPHICS_OUTPUT_PROTOCOL*GraphicsOutput;
 
   EFI_STATUS  Status;
   CIRRUS_LOGIC_5430_PRIVATE_DATA  *Private;
 
-  if (FeaturePcdGet (PcdSupportUga)) {
-Status = gBS->OpenProtocol (
-Controller,
-&gEfiUgaDrawProtocolGuid,
-(VOID **) &UgaDraw,
-This->DriverBindingHandle,
-Controller,
-EFI_OPEN_PROTOCOL_GET_PROTOCOL
-);
-if (EFI_ERROR (Status)) {
-  return Status;
-}
-//
-// Get our private context information
-//
-Private = CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (UgaDraw);
-CirrusLogic5430UgaDrawDestructor (Private);
-
-if (FeaturePcdGet (PcdSupportGop)) {
-  CirrusLogic5430GraphicsOutputDestructor (Private);
-  //
-  // Remove the UGA and GOP protocol interface from the system
-  //
-  Status = gBS->UninstallMultipleProtocolInterfaces (
-  Private->Handle,
-  &gEfiUgaDrawProtocolGuid,
-  &Private->UgaDraw,
-  &gEfiGraphicsOutputProtocolGuid,
-  &Private->GraphicsOutput,
-  NULL
-  );
-} else {
-  //
-  // Remove the UGA Draw interface from the system
-  //
-  Status = gBS->UninstallMultipleProtocolInterfaces (
-  Private->Handle,
-  &gEfiUgaDrawProtocolGuid,
-  &Private->UgaDraw,
-  NULL
-  );
-}
-  } else {
 Status = gBS->OpenProtocol (
 Controller,
 &gEfiGraphicsOutputProtocolGuid,
@@ -542,13 +470,10 @@ CirrusLogic5430ControllerDriverStop (
 //
 Status = gBS->UninstallMultipleProtocolInterfaces (
 Private->Handle,
-&gEfiUgaDrawProtocolGuid,
-&Private->UgaDraw,

[edk2-devel] [edk2-platforms Patch v2 0/3] Remove all UGA support

2022-07-13 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Guomin Jiang (3):
  PurleyOpenBoardPkg: Remove All UGA support
  BoardModulePkg: Remove all UGA support
  OptionRomPkg: Remove all UGA support

 .../CirrusLogic5430Dxe/CirrusLogic5430.c  |  91 +---
 .../CirrusLogic5430Dxe/CirrusLogic5430.h  |  21 +-
 .../CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf |   9 +-
 .../CirrusLogic5430UgaDraw.c  | 412 --
 Drivers/OptionRomPkg/OptionRomPkg.dec |   3 -
 .../Library/BoardBdsHookLib/BoardBdsHook.h|   3 +-
 .../Library/BoardBdsHookLib/BoardBdsHook.h|   3 +-
 7 files changed, 5 insertions(+), 537 deletions(-)
 delete mode 100644 
Drivers/OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430UgaDraw.c

-- 
2.26.2.windows.1



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




[edk2-devel] [edk2-platforms Patch v2 2/3] BoardModulePkg: Remove all UGA support

2022-07-13 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

Cc: Eric Dong 
Cc: Liming Gao 
Signed-off-by: Guomin Jiang 
---
 .../BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git 
a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h 
b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
index fd943b3ca793..292d02a4ef4d 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for BDS Hook Library
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.26.2.windows.1



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




[edk2-devel] [Patch v2 09/11] MdeModulePkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in MdeModulePkg, first remove from library.
Remove the PcdConOutGopSupport definition.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Cc: Hao A Wu 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |   4 +-
 MdeModulePkg/Include/Library/BootLogoLib.h|   4 +-
 .../Library/BootLogoLib/BootLogoLib.c | 228 +-
 .../Library/BootLogoLib/BootLogoLib.inf   |   6 +-
 4 files changed, 61 insertions(+), 181 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
index 337b2090d98e..50ce9a9eaff2 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
@@ -8,7 +8,7 @@
   PCI Root Bridges. So it means platform needs install PCI Root Bridge IO 
protocol for each
   PCI Root Bus and install PCI Host Bridge Resource Allocation Protocol.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -49,7 +49,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
EFI_PCI_HOTPLUG_REQUEST_PROTOCOL  mPciHotPlugReque
   Installs driver module protocols and. Creates virtual device handles for 
ConIn,
   ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex 
protocol,
   Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
-  Installs Graphics Output protocol and/or UGA Draw protocol if needed.
+  Installs Graphics Output protocol if needed.
 
   @param[in] ImageHandleThe firmware allocated handle for the EFI image.
   @param[in] SystemTableA pointer to the EFI System Table.
diff --git a/MdeModulePkg/Include/Library/BootLogoLib.h 
b/MdeModulePkg/Include/Library/BootLogoLib.h
index 2d6209a2789b..854d5b636713 100644
--- a/MdeModulePkg/Include/Library/BootLogoLib.h
+++ b/MdeModulePkg/Include/Library/BootLogoLib.h
@@ -2,7 +2,7 @@
   This library is only intended to be used by PlatformBootManagerLib
   to show progress bar and LOGO.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -26,7 +26,7 @@ BootLogoEnableLogo (
   Use SystemTable ConOut to turn on video based Simple Text Out consoles. The
   Simple Text Out screens will now be synced up with all non-video output 
devices.
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic device are back in text mode and synced up.
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c 
b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
index 478ec2d40e2b..4a823912e014 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
@@ -2,7 +2,7 @@
   This library is only intended to be used by PlatformBootManagerLib
   to show progress bar and LOGO.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.
 Copyright (c) 2016, Microsoft Corporation
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -47,9 +46,6 @@ BootLogoEnableLogo (
   UINT32 Instance;
   EFI_IMAGE_INPUTImage;
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Blt;
-  EFI_UGA_DRAW_PROTOCOL  *UgaDraw;
-  UINT32 ColorDepth;
-  UINT32 RefreshRate;
   EFI_GRAPHICS_OUTPUT_PROTOCOL   *GraphicsOutput;
   EFI_BOOT_LOGO_PROTOCOL *BootLogo;
   EDKII_BOOT_LOGO2_PROTOCOL  *BootLogo2;
@@ -68,21 +64,10 @@ BootLogoEnableLogo (
 return EFI_UNSUPPORTED;
   }
 
-  UgaDraw = NULL;
   //
   // Try to open GOP first
   //
   Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-GraphicsOutput = NULL;
-//
-// Open GOP failed, try to open UGA
-//
-Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiUgaDrawProtocolGuid, (VOID **)&UgaDraw);
-if (EFI_ERROR (Status)) {
-  UgaDraw = NULL;
-}
-  }
 
   if (EFI_ERROR (Status)) {
 return EFI_UNSUPPORTED;
@@ -109,16 +94,8 @@ BootLogoEnableLogo (
   //
   gST->ConOut->EnableCursor (gST->ConOut, FALSE);
 
-  if (GraphicsOutput != NULL) {
-SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
-SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
-  } else {
-ASSERT (UgaDraw != NUL

[edk2-devel] [Patch v2 08/11] MdeModulePkg/GraphicsConsoleDxe: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in GraphicsConsoleDxe, remove comment about UGA
in HiiDatabaseDxe.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Cc: Dandan Bi 
Cc: Eric Dong 
---
 .../GraphicsConsoleDxe/GraphicsConsole.c  | 300 +-
 .../GraphicsConsoleDxe/GraphicsConsole.h  |  21 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf |   8 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.uni |   6 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |   4 +-
 5 files changed, 23 insertions(+), 316 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index b895dafedeaa..facb813276cd 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 GRAPHICS_CONSOLE_DEV  mGraphicsConsoleDevTemplate = {
   GRAPHICS_CONSOLE_DEV_SIGNATURE,
   (EFI_GRAPHICS_OUTPUT_PROTOCOL *)NULL,
-  (EFI_UGA_DRAW_PROTOCOL *)NULL,
   {
 GraphicsConsoleConOutReset,
 GraphicsConsoleConOutOutputString,
@@ -104,9 +103,8 @@ EFI_DRIVER_BINDING_PROTOCOL  gGraphicsConsoleDriverBinding 
= {
 /**
   Test to see if Graphics Console could be supported on the Controller.
 
-  Graphics Console could be supported if Graphics Output Protocol or UGA Draw
-  Protocol exists on the Controller. (UGA Draw Protocol could be skipped
-  if PcdUgaConsumeSupport is set to FALSE.)
+  Graphics Console could be supported if Graphics Output Protocol
+  exists on the Controller.
 
   @param  ThisProtocol instance pointer.
   @param  Controller  Handle of device to test.
@@ -127,11 +125,9 @@ GraphicsConsoleControllerDriverSupported (
 {
   EFI_STATUSStatus;
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
-  EFI_UGA_DRAW_PROTOCOL *UgaDraw;
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
 
   GraphicsOutput = NULL;
-  UgaDraw= NULL;
   //
   // Open the IO Abstraction(s) needed to perform the supported test
   //
@@ -143,21 +139,6 @@ GraphicsConsoleControllerDriverSupported (
   Controller,
   EFI_OPEN_PROTOCOL_BY_DRIVER
   );
-
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-//
-// Open Graphics Output Protocol failed, try to open UGA Draw Protocol
-//
-Status = gBS->OpenProtocol (
-Controller,
-&gEfiUgaDrawProtocolGuid,
-(VOID **)&UgaDraw,
-This->DriverBindingHandle,
-Controller,
-EFI_OPEN_PROTOCOL_BY_DRIVER
-);
-  }
-
   if (EFI_ERROR (Status)) {
 return Status;
   }
@@ -202,13 +183,6 @@ Error:
This->DriverBindingHandle,
Controller
);
-  } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
-gBS->CloseProtocol (
-   Controller,
-   &gEfiUgaDrawProtocolGuid,
-   This->DriverBindingHandle,
-   Controller
-   );
   }
 
   return Status;
@@ -369,9 +343,8 @@ InitializeGraphicsConsoleTextMode (
 }
 
 /**
-  Start this driver on Controller by opening Graphics Output protocol or
-  UGA Draw protocol, and installing Simple Text Out protocol on Controller.
-  (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
+  Start this driver on Controller by opening Graphics Output protocol
+  and installing Simple Text Out protocol on Controller.
 
   @param  This Protocol instance pointer.
   @param  Controller   Handle of device to bind driver to
@@ -394,8 +367,6 @@ GraphicsConsoleControllerDriverStart (
   GRAPHICS_CONSOLE_DEV  *Private;
   UINT32HorizontalResolution;
   UINT32VerticalResolution;
-  UINT32ColorDepth;
-  UINT32RefreshRate;
   UINT32ModeIndex;
   UINTN MaxMode;
   UINT32ModeNumber;
@@ -432,18 +403,6 @@ GraphicsConsoleControllerDriverStart (
   Controller,
   EFI_OPEN_PROTOCOL_BY_DRIVER
   );
-
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-Status = gBS->OpenProtocol (
-Controller,
-&gEfiUgaDrawProtocolGuid,
-(VOID **)&Private->UgaDraw,
-This->DriverBindingHandle,
-Controller,
-EFI_OPEN_PROTOCOL_BY_DRIVER
-);
-  }
-
   if (E

[edk2-devel] [Patch v2 10/11] BaseTools: Remove all UGA support

2022-07-14 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove UGA code in BaseTools

Signed-off-by: Guomin Jiang 
Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
---
 .../Source/C/Include/Protocol/HiiFramework.h  |  53 +-
 BaseTools/Source/C/Include/Protocol/UgaDraw.h | 161 --
 2 files changed, 1 insertion(+), 213 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/Protocol/UgaDraw.h

diff --git a/BaseTools/Source/C/Include/Protocol/HiiFramework.h 
b/BaseTools/Source/C/Include/Protocol/HiiFramework.h
index 448350967bbf..4c651f89e0eb 100644
--- a/BaseTools/Source/C/Include/Protocol/HiiFramework.h
+++ b/BaseTools/Source/C/Include/Protocol/HiiFramework.h
@@ -6,7 +6,7 @@
   @par Revision Reference:
   This protocol is defined in HII spec 0.92.
 
-  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -28,20 +28,6 @@
 0xd7ad636e, 0xb997, 0x459b, {0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 
0xe1} \
   }
 
-// BugBug:
-//
-// If UGA goes away we need to put this some place. I'm not sure where?
-//
-//typedef struct {
-//  UINT8 Blue;
-//  UINT8 Green;
-//  UINT8 Red;
-//  UINT8 Reserved;
-//} EFI_UGA_PIXEL;
-
-//
-//
-
 typedef struct _EFI_HII_PROTOCOL  EFI_HII_PROTOCOL;
 
 //
@@ -575,39 +561,6 @@ EFI_STATUS
   IN OUT UINT32*InternalStatus
   );
 
-/**
-  Translates a glyph into the format required for input to the Universal
-  Graphics Adapter (UGA) Block Transfer (BLT) routines.
-
-  @param  This  A pointer to the EFI_HII_PROTOCOL instance.
-  @param  GlyphBuffer   A pointer to the buffer that contains glyph 
data.
-  @param  ForegroundThe foreground setting requested to be used 
for the
-generated BltBuffer data.
-  @param  BackgroundThe background setting requested to be used 
for the
-generated BltBuffer data.
-  @param  Count The entry in the BltBuffer upon which to act.
-  @param  Width The width in bits of the glyph being converted.
-  @param  HeightThe height in bits of the glyph being converted
-  @param  BltBuffer A pointer to the buffer that contains the data 
that is
-ready to be used by the UGA BLT routines.
-
-  @retval EFI_SUCCESS   It worked.
-  @retval EFI_NOT_FOUND A glyph for a character was not found.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *EFI_HII_GLYPH_TO_BLT) (
-  IN EFI_HII_PROTOCOL *This,
-  IN UINT8*GlyphBuffer,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
-  IN UINTN Count,
-  IN UINTN Width,
-  IN UINTN Height,
-  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
-  );
-
 /**
   Allows a new string to be added to an already existing string package.
 
@@ -878,9 +831,6 @@ EFI_STATUS
   @param GetGlyph
   Translates a Unicode character into the corresponding font glyph.
 
-  @param GlyphToBlt
-  Converts a glyph value into a format that is ready for a UGA BLT command.
-
   @param NewString
   Allows a new string to be added to an already existing string package.
 
@@ -924,7 +874,6 @@ struct _EFI_HII_PROTOCOL {
 
   EFI_HII_TEST_STRING TestString;
   EFI_HII_GET_GLYPH   GetGlyph;
-  EFI_HII_GLYPH_TO_BLTGlyphToBlt;
 
   EFI_HII_NEW_STRING  NewString;
   EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;
diff --git a/BaseTools/Source/C/Include/Protocol/UgaDraw.h 
b/BaseTools/Source/C/Include/Protocol/UgaDraw.h
deleted file mode 100644
index 412b000aeb6b..
--- a/BaseTools/Source/C/Include/Protocol/UgaDraw.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/** @file
-  UGA Draw protocol from the EFI 1.1 specification.
-
-  Abstraction of a very simple graphics device.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __UGA_DRAW_H__
-#define __UGA_DRAW_H__
-
-#define EFI_UGA_DRAW_PROTOCOL_GUID \
-  { \
-0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 
0x39 } \
-  }
-
-typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
-
-/**
-  Return the current video mode information.
-
-  @param  This  Protocol instance pointer.
-  @param  HorizontalResolution  Current video horizontal resolution in pixels
-  @param  VerticalResolutionCurrent video vertical resolution in pixels
-  @param  ColorDepthCurrent video color depth in bits per pixel
-  @param  RefreshRate   Current video refresh

[edk2-devel] [Patch v2 11/11] MdePkg/UefiLib: Remove all UGA support

2022-07-14 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA code in MdePkg except the definition

The reason why keep definition is because downstream need it to pass
build.
It will be removed when all downstream remove UGA support

Signed-off-by: Guomin Jiang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
---
 MdePkg/Library/UefiLib/UefiLib.inf   |  4 +-
 MdePkg/Library/UefiLib/UefiLibInternal.h |  3 +-
 MdePkg/Library/UefiLib/UefiLibPrint.c| 91 +---
 MdePkg/MdePkg.dsc|  3 -
 4 files changed, 3 insertions(+), 98 deletions(-)

diff --git a/MdePkg/Library/UefiLib/UefiLib.inf 
b/MdePkg/Library/UefiLib/UefiLib.inf
index 01ed92092da2..ac9d68907261 100644
--- a/MdePkg/Library/UefiLib/UefiLib.inf
+++ b/MdePkg/Library/UefiLib/UefiLib.inf
@@ -7,7 +7,7 @@
 #  EFI Driver Model related protocols, manage Unicode string tables for UEFI 
Drivers,
 #  and print messages on the console output and standard error devices.
 #
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -67,7 +67,6 @@
   gEfiGraphicsOutputProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiHiiFontProtocolGuid ## SOMETIMES_CONSUMES
   gEfiSimpleFileSystemProtocolGuid## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid | gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport  
   ## SOMETIMES_CONSUMES # Consumes if gEfiGraphicsOutputProtocolGuid 
uninstalled
   gEfiComponentNameProtocolGuid  | NOT 
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable   ## SOMETIMES_PRODUCES # User 
chooses to produce it
   gEfiComponentName2ProtocolGuid | NOT 
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable  ## SOMETIMES_PRODUCES # User 
chooses to produce it
   gEfiDriverConfigurationProtocolGuid## 
SOMETIMES_PRODUCES # User chooses to produce it
@@ -84,5 +83,4 @@
   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable## CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable   ## CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable   ## CONSUMES
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport   ## CONSUMES
 
diff --git a/MdePkg/Library/UefiLib/UefiLibInternal.h 
b/MdePkg/Library/UefiLib/UefiLibInternal.h
index 4365282cf213..be5c9ddcdde8 100644
--- a/MdePkg/Library/UefiLib/UefiLibInternal.h
+++ b/MdePkg/Library/UefiLib/UefiLibInternal.h
@@ -1,7 +1,7 @@
 /** @file
   Internal include file for UefiLib.
 
-  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c 
b/MdePkg/Library/UefiLib/UefiLibPrint.c
index 39edeb7283dd..2451775aeb90 100644
--- a/MdePkg/Library/UefiLib/UefiLibPrint.c
+++ b/MdePkg/Library/UefiLib/UefiLibPrint.c
@@ -2,7 +2,7 @@
   Mde UEFI library API implementation.
   Print to StdErr or ConOut defined in EFI_SYSTEM_TABLE
 
-  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -344,20 +344,14 @@ InternalPrintGraphic (
   EFI_STATUS   Status;
   UINT32   HorizontalResolution;
   UINT32   VerticalResolution;
-  UINT32   ColorDepth;
-  UINT32   RefreshRate;
   EFI_HII_FONT_PROTOCOL*HiiFont;
   EFI_IMAGE_OUTPUT *Blt;
   EFI_FONT_DISPLAY_INFOFontInfo;
   EFI_HII_ROW_INFO *RowInfoArray;
   UINTNRowInfoArraySize;
   EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
-  EFI_UGA_DRAW_PROTOCOL*UgaDraw;
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *Sto;
   EFI_HANDLE   ConsoleHandle;
-  UINTNWidth;
-  UINTNHeight;
-  UINTNDelta;
 
   HorizontalResolution = 0;
   VerticalResolution   = 0;
@@ -374,20 +368,6 @@ InternalPrintGraphic (
   (VOID **)&GraphicsOutput
   );
 
-  UgaDraw = NULL;
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-//
-// If no GOP available, try to open UGA Draw protocol if supported.
-//
-GraphicsOutput = NULL;
-
-Status = gBS->HandleProtocol (
-ConsoleHandle,
-&gEfiUgaDrawProtocolGuid,
-(VOID **)&UgaDraw
-);
-  }
-
   if (EFI_ERROR (Status)) {
 goto Error;
   }
@@ -405,8 +385,6 @@ InternalPrintGraphic (
   if 

[edk2-devel] [Patch v2 07/11] MdeModulePkg/ConSplitterDxe: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove the PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in ConSplitterDxe component.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
---
 .../Console/ConSplitterDxe/ConSplitter.c  | 405 +++---
 .../Console/ConSplitterDxe/ConSplitter.h  | 138 +-
 .../Console/ConSplitterDxe/ConSplitterDxe.inf |  17 +-
 .../Console/ConSplitterDxe/ConSplitterDxe.uni |  12 +-
 .../ConSplitterDxe/ConSplitterGraphics.c  | 310 +-
 5 files changed, 80 insertions(+), 802 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c 
b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
index 8b5e62e3a883..663fccff046d 100644
--- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
+++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
@@ -16,7 +16,7 @@
   never removed. Such design ensures system function well during none console
   device situation.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -107,15 +107,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
TEXT_IN_SPLITTER_PRIVATE_DATA  mConIn = {
   FALSE
 };
 
-//
-// Uga Draw Protocol Private Data template
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL  mUgaDrawProtocolTemplate 
= {
-  ConSplitterUgaDrawGetMode,
-  ConSplitterUgaDrawSetMode,
-  ConSplitterUgaDrawBlt
-};
-
 //
 // Graphics Output Protocol Private Data template
 //
@@ -153,16 +144,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
TEXT_OUT_SPLITTER_PRIVATE_DATA  mConOut = {
 FALSE,
   },
 
-  {
-NULL,
-NULL,
-NULL
-  },
-  0,
-  0,
-  0,
-  0,
-
   {
 NULL,
 NULL,
@@ -171,7 +152,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
TEXT_OUT_SPLITTER_PRIVATE_DATA  mConOut = {
   },
   (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL,
   0,
-  0,
 
   0,
   (TEXT_OUT_AND_GOP_DATA *)NULL,
@@ -209,16 +189,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
TEXT_OUT_SPLITTER_PRIVATE_DATA  mStdErr = {
 FALSE,
   },
 
-  {
-NULL,
-NULL,
-NULL
-  },
-  0,
-  0,
-  0,
-  0,
-
   {
 NULL,
 NULL,
@@ -227,7 +197,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
TEXT_OUT_SPLITTER_PRIVATE_DATA  mStdErr = {
   },
   (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL,
   0,
-  0,
 
   0,
   (TEXT_OUT_AND_GOP_DATA *)NULL,
@@ -422,7 +391,7 @@ ToggleStateSyncReInitialization (
   Installs driver module protocols and. Creates virtual device handles for 
ConIn,
   ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex 
protocol,
   Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
-  Installs Graphics Output protocol and/or UGA Draw protocol if needed.
+  Installs Graphics Output protocol if need.
 
   @param[in] ImageHandleThe firmware allocated handle for the EFI image.
   @param[in] SystemTableA pointer to the EFI System Table.
@@ -493,14 +462,6 @@ ConSplitterDriverEntry (
  );
   ASSERT_EFI_ERROR (Status);
 
-  //
-  // Either Graphics Output protocol or UGA Draw protocol must be supported.
-  //
-  ASSERT (
-FeaturePcdGet (PcdConOutGopSupport) ||
-FeaturePcdGet (PcdConOutUgaSupport)
-);
-
   //
   // The driver creates virtual handles for ConIn, ConOut, StdErr.
   // The virtual handles will always exist even if no console exist in the
@@ -757,13 +718,7 @@ ConSplitterTextOutConstructor (
   //
   // Copy protocols template
   //
-  if (FeaturePcdGet (PcdConOutUgaSupport)) {
-CopyMem (&ConOutPrivate->UgaDraw, &mUgaDrawProtocolTemplate, sizeof 
(EFI_UGA_DRAW_PROTOCOL));
-  }
-
-  if (FeaturePcdGet (PcdConOutGopSupport)) {
-CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, 
sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL));
-  }
+  CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, 
sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL));
 
   //
   // Initialize console output splitter's private data.
@@ -806,56 +761,47 @@ ConSplitterTextOutConstructor (
   ConOutPrivate->TextOutQueryData[0].Rows= 25;
   TextOutSetMode (ConOutPrivate, 0);
 
-  if (FeaturePcdGet (PcdConOutUgaSupport)) {
-//
-// Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
-//
-ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60);
+  //
+  // Setup resource for mode information in Graphics Output Protocol interface
+  //
+  if ((ConOutPrivate->GraphicsOutput.Mode = AllocateZeroPool (sizeof 
(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE))) == NULL) {
+return EFI_OUT_OF_RESOURCES;
   }
 
-  if (FeaturePcdGet (PcdConOutGopSupport)) {
-//
-// Setup resource for mode information in Graphics Output Protocol 
interface
-//
-if ((ConOutPriv

[edk2-devel] [Patch v2 02/11] ArmVirtPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in ArmVirtPkg

Signed-off-by: Guomin Jiang 
Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
---
 ArmVirtPkg/ArmVirtQemu.dsc   | 7 +--
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 7 +--
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 9369a88858fd..dc87050f3f3a 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -125,11 +125,6 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
 
-  ## If TRUE, Graphics Output Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-
   gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
 
   gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE)
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 7f7d15d6eee3..0d13d8edb407 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -107,11 +107,6 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
 
-  ## If TRUE, Graphics Output Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-
   gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
 
 [PcdsFixedAtBuild.common]
-- 
2.26.2.windows.1



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




[edk2-devel] [Patch v2 00/11] Remove all UGA support

2022-07-14 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

The Plan:
1. Remove the upstream UGA code first but keep definition in Edk2 at
first
2. Then downstream owner to remove UGA related code
3. Remove Edk2 definition last.

GuoMinJ (9):
  UefiPayloadPkg: Remove All UGA Support
  ArmVirtPkg: Remove All UGA Support
  ArmPkg: Remove All UGA Support
  EmulatorPkg: Remove All UGA Support
  ShellPkg: Remove All UGA Support
  OvmfPkg: Remove All UGA Support
  MdeModulePkg/ConSplitterDxe: Remove All UGA Support
  MdeModulePkg/GraphicsConsoleDxe: Remove All UGA Support
  MdeModulePkg: Remove All UGA Support

Guomin Jiang (2):
  BaseTools: Remove all UGA support
  MdePkg/UefiLib: Remove all UGA support

 .../PlatformBootManagerLib/PlatformBm.h   |   4 +-
 .../PlatformBootManagerLib.inf|   5 +-
 ArmVirtPkg/ArmVirtQemu.dsc|   7 +-
 ArmVirtPkg/ArmVirtQemuKernel.dsc  |   7 +-
 .../Source/C/Include/Protocol/HiiFramework.h  |  53 +--
 BaseTools/Source/C/Include/Protocol/UgaDraw.h | 161 ---
 EmulatorPkg/EmuGopDxe/Gop.h   |  10 +-
 EmulatorPkg/EmuGopDxe/GopScreen.c |  14 +-
 EmulatorPkg/Include/Protocol/EmuFileSystem.h  |  24 +-
 .../Include/Protocol/EmuGraphicsWindow.h  |  18 +-
 .../Library/PlatformBmLib/PlatformBm.h|   4 +-
 .../Library/PlatformBmLib/PlatformBmData.c|   6 +-
 EmulatorPkg/Unix/Host/Gasket.h|  12 +-
 EmulatorPkg/Unix/Host/Host.h  |   3 +-
 EmulatorPkg/Unix/Host/Ia32/Gasket.S   |   2 +-
 EmulatorPkg/Unix/Host/X11GraphicsWindow.c |  82 ++--
 EmulatorPkg/Unix/Host/X64/Gasket.S|   2 +-
 EmulatorPkg/Win/Host/WinGopScreen.c   |  10 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |   4 +-
 MdeModulePkg/Include/Library/BootLogoLib.h|   4 +-
 .../Library/BootLogoLib/BootLogoLib.c | 228 +++---
 .../Library/BootLogoLib/BootLogoLib.inf   |   6 +-
 .../Console/ConSplitterDxe/ConSplitter.c  | 405 +++---
 .../Console/ConSplitterDxe/ConSplitter.h  | 138 +-
 .../Console/ConSplitterDxe/ConSplitterDxe.inf |  17 +-
 .../Console/ConSplitterDxe/ConSplitterDxe.uni |  12 +-
 .../ConSplitterDxe/ConSplitterGraphics.c  | 310 +-
 .../GraphicsConsoleDxe/GraphicsConsole.c  | 300 +
 .../GraphicsConsoleDxe/GraphicsConsole.h  |  21 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf |   8 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.uni |   6 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |   4 +-
 MdePkg/Library/UefiLib/UefiLib.inf|   4 +-
 MdePkg/Library/UefiLib/UefiLibInternal.h  |   3 +-
 MdePkg/Library/UefiLib/UefiLibPrint.c |  91 +---
 MdePkg/MdePkg.dsc |   3 -
 OvmfPkg/AmdSev/AmdSevX64.dsc  |   4 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|   4 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|   4 +-
 OvmfPkg/OvmfPkgIa32.dsc   |   2 -
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 -
 OvmfPkg/OvmfPkgX64.dsc|   2 -
 OvmfPkg/OvmfXen.dsc   |   4 +-
 .../UefiHandleParsingLib.c|   4 +-
 .../UefiHandleParsingLib.h|   4 +-
 .../UefiHandleParsingLib.inf  |   4 +-
 .../UefiHandleParsingLib.uni  |   4 +-
 .../PlatformBootManager.h |   4 +-
 .../PlatformBootManagerLib.inf|   4 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc |   2 -
 50 files changed, 276 insertions(+), 1760 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/Protocol/UgaDraw.h

-- 
2.26.2.windows.1



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




[edk2-devel] [Patch v2 04/11] EmulatorPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in EmulatorPkg.

Signed-off-by: Guomin Jiang 
Cc: Andrew Fish 
Cc: Ray Ni 
---
 EmulatorPkg/EmuGopDxe/Gop.h   | 10 +--
 EmulatorPkg/EmuGopDxe/GopScreen.c | 14 ++--
 EmulatorPkg/Include/Protocol/EmuFileSystem.h  | 24 +++---
 .../Include/Protocol/EmuGraphicsWindow.h  | 18 ++--
 .../Library/PlatformBmLib/PlatformBm.h|  4 +-
 .../Library/PlatformBmLib/PlatformBmData.c|  6 +-
 EmulatorPkg/Unix/Host/Gasket.h| 12 +--
 EmulatorPkg/Unix/Host/Host.h  |  3 +-
 EmulatorPkg/Unix/Host/Ia32/Gasket.S   |  2 +-
 EmulatorPkg/Unix/Host/X11GraphicsWindow.c | 82 +--
 EmulatorPkg/Unix/Host/X64/Gasket.S|  2 +-
 EmulatorPkg/Win/Host/WinGopScreen.c   | 10 +--
 12 files changed, 92 insertions(+), 95 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/Gop.h b/EmulatorPkg/EmuGopDxe/Gop.h
index 7f7dc4e8eb9f..59ebfda912eb 100644
--- a/EmulatorPkg/EmuGopDxe/Gop.h
+++ b/EmulatorPkg/EmuGopDxe/Gop.h
@@ -1,13 +1,13 @@
 /*++ @file
 
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 Portions copyright (c) 2010,Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef __UGA_H_
-#define __UGA_H_
+#ifndef GOP_H_
+#define GOP_H_
 
 #include 
 
@@ -60,8 +60,6 @@ typedef struct {
 extern EFI_DRIVER_BINDING_PROTOCOL  gEmuGopDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL  gEmuGopComponentName;
 
-#define EMU_UGA_CLASS_NAME  L"EmuGopWindow"
-
 #define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('G', 'o', 'p', 'N')
 typedef struct {
   UINT64   Signature;
@@ -83,7 +81,7 @@ typedef struct {
   GOP_MODE_DATA*ModeData;
 
   //
-  // UGA Private Data knowing when to start hardware
+  // Private Data knowing when to start hardware
   //
   BOOLEAN  HardwareNeedsStarting;
 
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c 
b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 88d95b88e162..113b496861b4 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -10,7 +10,7 @@ Module Name:
 
 Abstract:
 
-  This file produces the graphics abstration of UGA. It is called by
+  This file produces the graphics abstration of GOP. It is called by
   EmuGopDriver.c file which deals with the EFI 1.1 driver model.
   This file just does graphics.
 
@@ -209,7 +209,7 @@ EmuGopBlt (
   // the number of bytes in each row can be computed.
   //
   if (Delta == 0) {
-Delta = Width * sizeof (EFI_UGA_PIXEL);
+Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
   }
 
   //
@@ -220,8 +220,8 @@ EmuGopBlt (
   OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
 
   //
-  // Pack UGA Draw protocol parameters to EMU_GRAPHICS_WINDOWS__BLT_ARGS 
structure to adapt to
-  // GopBlt() API of Unix UGA IO protocol.
+  // Pack GOP protocol parameters to EMU_GRAPHICS_WINDOWS__BLT_ARGS structure 
to adapt to
+  // GopBlt() API of GOP protocol.
   //
   GopBltArgs.DestinationX = DestinationX;
   GopBltArgs.DestinationY = DestinationY;
@@ -232,8 +232,8 @@ EmuGopBlt (
   GopBltArgs.Delta= Delta;
   Status  = Private->EmuGraphicsWindow->Blt (
   
Private->EmuGraphicsWindow,
-  (EFI_UGA_PIXEL 
*)BltBuffer,
-  
(EFI_UGA_BLT_OPERATION)BltOperation,
+  BltBuffer,
+  BltOperation,
   &GopBltArgs
   );
 
@@ -384,7 +384,7 @@ ShutdownGopEvent (
 
 Routine Description:
 
-  This is the UGA screen's callback notification function for 
exit-boot-services.
+  This is the screen's callback notification function for exit-boot-services.
   All we do here is call EmuGopDestructor().
 
 Arguments:
diff --git a/EmulatorPkg/Include/Protocol/EmuFileSystem.h 
b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
index 15de43ac022e..062508fafc9d 100644
--- a/EmulatorPkg/Include/Protocol/EmuFileSystem.h
+++ b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
@@ -7,19 +7,19 @@
 
   UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
 
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 Portions copyright (c) 2011, Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef _EMU_UGA_IO_H_
-#define _EMU_UGA_IO_H_
+#ifndef EMU_GRAPHICS_WINDOW_H_
+#define EMU_GRAPHICS_W

[edk2-devel] [Patch v2 06/11] OvmfPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Delete PcdConOutGopSupport, it is unnecessary any more.

Signed-off-by: Guomin Jiang 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Min Xu 
Cc: Tom Lendacky 
Cc: Rebecca Cran 
Cc: Peter Grehan 
Cc: Anthony Perard 
Cc: Julien Grall 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc   | 4 +---
 OvmfPkg/Bhyve/BhyveX64.dsc | 4 +---
 OvmfPkg/Microvm/MicrovmX64.dsc | 4 +---
 OvmfPkg/OvmfPkgIa32.dsc| 2 --
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 --
 OvmfPkg/OvmfPkgX64.dsc | 2 --
 OvmfPkg/OvmfXen.dsc| 4 +---
 7 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 726521c94381..8fc1f85ad012 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -3,7 +3,7 @@
 #  virtual machine remote attestation and secret injection
 #
 #  Copyright (c) 2020 James Bottomley, IBM Corporation.
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -379,8 +379,6 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d4f0c90b8e00..d827adec363c 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -1,6 +1,6 @@
 #
 #  Copyright (c) 2020, Rebecca Cran 
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) 2014, Pluribus Networks, Inc.
 #
@@ -419,8 +419,6 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 61db9b6e4c83..bea69475387d 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
 #
@@ -454,8 +454,6 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e708411076ca..92355f67aa50 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -458,8 +458,6 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !ifdef $(CSM_ENABLE)
   gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 0b036d8bb53f..a73e52701d17 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -464,8 +464,6 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !ifdef $(CSM_ENABLE)
   gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 8ad04b50f74f..8c4e4d9ec578 100644

[edk2-devel] [Patch v2 05/11] ShellPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in ShellPkg.

Signed-off-by: Guomin Jiang 
Cc: Ray Ni 
Cc: Zhichao Gao 
---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c  | 4 +---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h  | 4 +---
 .../Library/UefiHandleParsingLib/UefiHandleParsingLib.inf | 4 +---
 .../Library/UefiHandleParsingLib/UefiHandleParsingLib.uni | 4 +---
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index aa0115bdd498..08215ab8039c 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
 
-  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
   (C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -2238,8 +2238,6 @@ STATIC CONST GUID_INFO_BLOCK  mGuidStringList[] = {
   { STRING_TOKEN (STR_SHELL_ENV2),  &gEfiShellEnvironment2Guid,
NULL },
   { STRING_TOKEN (STR_SHELL_ENV),   &gEfiShellEnvironment2Guid,
NULL },
   { STRING_TOKEN (STR_DEVICE_IO),   &gEfiDeviceIoProtocolGuid, 
NULL },
-  { STRING_TOKEN (STR_UGA_DRAW),&gEfiUgaDrawProtocolGuid,  
NULL },
-  { STRING_TOKEN (STR_UGA_IO),  &gEfiUgaIoProtocolGuid,
NULL },
   { STRING_TOKEN (STR_ESP), &gEfiPartTypeSystemPartGuid,   
NULL },
   { STRING_TOKEN (STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid,
NULL },
   { STRING_TOKEN (STR_DRIVER_CONFIG),   
&gEfiDriverConfigurationProtocolGuid,  NULL 
},
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
index 6be0d78c4c5a..b3433eda029b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
 
-  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
   (C) Copyright 2013-2016 Hewlett-Packard Development Company, L.P.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -94,8 +94,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 0d483805e712..af16569b07bd 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -1,6 +1,6 @@
 ##  @file
 #  Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
-#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. 
+#  Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved. 
 #  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
 #  (C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP
 #
@@ -129,8 +129,6 @@
   gEfiHiiConfigAccessProtocolGuid ## UNDEFINED
   gEfiFormBrowser2ProtocolGuid## UNDEFINED
   gEfiDeviceIoProtocolGuid## UNDEFINED
-  gEfiUgaDrawProtocolGuid ## UNDEFINED
-  gEfiUgaIoProtocolGuid   ## UNDEFINED
   gEfiDriverConfigurationProtocolGuid ## UNDEFINED
   gEfiDriverConfiguration2ProtocolGuid## UNDEFINED
   gEfiSimpleTextInputExProtocolGuid   ## UNDEFINED
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
index aa3396cea94d..04beea8e7f3e 100644
--- a/Shell

[edk2-devel] [Patch v2 01/11] UefiPayloadPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in UefiPayloadPkg.

Signed-off-by: Guomin Jiang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
---
 .../Library/PlatformBootManagerLib/PlatformBootManager.h  | 4 ++--
 .../Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 4 +---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 --
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
index 5614aadafb98..0f93287ac1f7 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
@@ -1,7 +1,7 @@
 /** @file
Head file for BDS Platform specific code
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -98,7 +98,7 @@ PlatformBootManagerEnableQuietBoot (
   Use SystemTable Conout to turn on video based Simple Text Out consoles. The
   Simple Text Out screens will now be synced up with all non video output 
devices
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic devices are back in text mode and synced up.
 
 **/
 EFI_STATUS
diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 9f58c460cd6b..2ebe7b3fd960 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Include all platform action which can be customized by IBV/OEM.
 #
-#  Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -55,7 +55,6 @@
 [Protocols]
   gEfiGenericMemTestProtocolGuid  ## CONSUMES
   gEfiGraphicsOutputProtocolGuid  ## CONSUMES
-  gEfiUgaDrawProtocolGuid ## CONSUMES
   gEfiBootLogoProtocolGuid## CONSUMES
   gEfiDxeSmmReadyToLockProtocolGuid
   gEfiSmmAccess2ProtocolGuid
@@ -65,7 +64,6 @@
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
   gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 2428bb2ce9a9..50b9b017588d 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -373,8 +373,6 @@
 

 [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   ## This PCD specified whether ACPI SDT protocol is installed.
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
-- 
2.26.2.windows.1



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




[edk2-devel] [Patch v2 03/11] ArmPkg: Remove All UGA Support

2022-07-14 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in ArmPkg.

Signed-off-by: Guomin Jiang 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Sami Mujawar 
---
 ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h   | 4 ++--
 .../PlatformBootManagerLib/PlatformBootManagerLib.inf| 5 +
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h 
b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
index a40a2ff5cb4f..a2ec4c4ad6c7 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
@@ -2,7 +2,7 @@
   Head file for BDS Platform specific code
 
   Copyright (C) 2015-2016, Red Hat, Inc.
-  Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+  Copyright (c) 2004 - 2022, Intel Corporation. All rights reserved.
   Copyright (c) 2016, Linaro Ltd. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -43,7 +43,7 @@ EnableQuietBoot (
   Simple Text Out screens will now be synced up with all non video output
   devices
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic devices are back in text mode and synced up.
 **/
 EFI_STATUS
 DisableQuietBoot (
diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 86751b45f82b..63d1d83ab0ef 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -3,7 +3,7 @@
 #
 #  Copyright (C) 2015-2016, Red Hat, Inc.
 #  Copyright (c) 2014, ARM Ltd. All rights reserved.
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 #  Copyright (c) 2016, Linaro Ltd. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -51,9 +51,6 @@
   UefiLib
   UefiRuntimeServicesTableLib
 
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
-
 [FixedPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
-- 
2.26.2.windows.1



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




Re: [edk2-devel] [Patch v2 02/11] ArmVirtPkg: Remove All UGA Support

2022-07-18 Thread Guomin Jiang
Hi Sami,

I am sure that the PcdConOutGopSupport will being removed.

We will keep it in dec file temporarily because some downstream project still 
need it
First we will remove all related code except definition and header
Second we will highlight it and downstream should remove all related code in 
their project
Last we will remove the definition and header and all UGA will be clean totally.

Thanks
Guomin
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Sami
> Mujawar
> Sent: Friday, July 15, 2022 5:42 PM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: GuoMinJ ; Ard Biesheuvel
> ; Leif Lindholm ; Gerd
> Hoffmann ; n...@arm.com
> Subject: Re: [edk2-devel] [Patch v2 02/11] ArmVirtPkg: Remove All UGA
> Support
> 
> Hi Guomin,
> 
> Thank you for this patch.
> 
> Please find my response inline marked [SAMI].
> 
> Regards,
> 
> Sami Mujawar
> 
> On 15/07/2022 02:50 am, Guomin Jiang wrote:
> > From: GuoMinJ 
> >
> > REF: https//bugzilla.tianocore.org/show_bug.cgi?id=2368
> >
> > Remove PcdConOutGopSupport, it is unnecessary any more.
> > Remove All UGA Support in ArmVirtPkg
> >
> > Signed-off-by: Guomin Jiang 
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Cc: Sami Mujawar 
> > Cc: Gerd Hoffmann 
> > ---
> >   ArmVirtPkg/ArmVirtQemu.dsc   | 7 +--
> >   ArmVirtPkg/ArmVirtQemuKernel.dsc | 7 +--
> >   2 files changed, 2 insertions(+), 12 deletions(-)
> >
> > diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> > index 9369a88858fd..dc87050f3f3a 100644
> > --- a/ArmVirtPkg/ArmVirtQemu.dsc
> > +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> > @@ -1,7 +1,7 @@
> >   #
> >   #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> >   #  Copyright (c) 2014, Linaro Limited. All rights reserved.
> > -#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
> > +#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
> >   #
> >   #  SPDX-License-Identifier: BSD-2-Clause-Patent
> >   #
> > @@ -125,11 +125,6 @@
> > gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
> >
> gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
> >
> > -  ## If TRUE, Graphics Output Protocol will be installed on virtual handle
> created by ConsplitterDxe.
> > -  #  It could be set FALSE to save size.
> > -  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
> 
> [SAMI] I am assuming PcdConOutGopSupport is going to be removed. Can
> you confiirm, please?
> 
> I am not sure I am looking at the right pull request. But the patch at
> https://github.com/tianocore/edk2/pull/290/commits/49838844df66826c5d0
> 9a2dad075dfe0d37ee709#diff-
> 6bdd1bc5bd7bacf61a4499e556ae002cbc49fc24c19e424fdf544d91e163bbb8
> does not seem to drop it.
> 
> Also the subject line for the commit is same as for the patch at
> https://edk2.groups.io/g/devel/message/91390 in this series.
> 
> [/SAMI]
> 
> > -  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> > -
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
> >
> > gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE)
> > diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > index 7f7d15d6eee3..0d13d8edb407 100644
> > --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > @@ -1,7 +1,7 @@
> >   #
> >   #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
> >   #  Copyright (c) 2014, Linaro Limited. All rights reserved.
> > -#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
> > +#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
> >   #
> >   #  SPDX-License-Identifier: BSD-2-Clause-Patent
> >   #
> > @@ -107,11 +107,6 @@
> > gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
> >
> gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
> >
> > -  ## If TRUE, Graphics Output Protocol will be installed on virtual handle
> created by ConsplitterDxe.
> > -  #  It could be set FALSE to save size.
> > -  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
> > -  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> > -
> >
> gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
> >
> >   [PcdsFixedAtBuild.common]
> 
> 
> 
> 



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




Re: [edk2-devel] [Patch v2 04/11] EmulatorPkg: Remove All UGA Support

2022-07-18 Thread Guomin Jiang
Hi Ray,

I tried it yesterday

It can boot normally in Win Emulator.
But I encounter issues mentioned in 
https://bugzilla.tianocore.org/show_bug.cgi?id=2639 in Unix. I think it is not 
related to this change.

Thanks
Guomin
> -Original Message-
> From: Ni, Ray 
> Sent: Friday, July 15, 2022 10:23 AM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: GuoMinJ ; Andrew Fish 
> Subject: RE: [Patch v2 04/11] EmulatorPkg: Remove All UGA Support
> 
> Guomin,
> Did you try booting the Emulator Win and Linux with this change?
> 
> > -Original Message-
> > From: Jiang, Guomin 
> > Sent: Friday, July 15, 2022 9:51 AM
> > To: devel@edk2.groups.io
> > Cc: GuoMinJ ; Andrew Fish
> ;
> > Ni, Ray 
> > Subject: [Patch v2 04/11] EmulatorPkg: Remove All UGA Support
> >
> > From: GuoMinJ 
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368
> >
> > Remove All UGA Support in EmulatorPkg.
> >
> > Signed-off-by: Guomin Jiang 
> > Cc: Andrew Fish 
> > Cc: Ray Ni 
> > ---
> >  EmulatorPkg/EmuGopDxe/Gop.h   | 10 +--
> >  EmulatorPkg/EmuGopDxe/GopScreen.c | 14 ++--
> >  EmulatorPkg/Include/Protocol/EmuFileSystem.h  | 24 +++---
> >  .../Include/Protocol/EmuGraphicsWindow.h  | 18 ++--
> >  .../Library/PlatformBmLib/PlatformBm.h|  4 +-
> >  .../Library/PlatformBmLib/PlatformBmData.c|  6 +-
> >  EmulatorPkg/Unix/Host/Gasket.h| 12 +--
> >  EmulatorPkg/Unix/Host/Host.h  |  3 +-
> >  EmulatorPkg/Unix/Host/Ia32/Gasket.S   |  2 +-
> >  EmulatorPkg/Unix/Host/X11GraphicsWindow.c | 82 +--
> >  EmulatorPkg/Unix/Host/X64/Gasket.S|  2 +-
> >  EmulatorPkg/Win/Host/WinGopScreen.c   | 10 +--
> >  12 files changed, 92 insertions(+), 95 deletions(-)
> >
> > diff --git a/EmulatorPkg/EmuGopDxe/Gop.h
> b/EmulatorPkg/EmuGopDxe/Gop.h
> > index 7f7dc4e8eb9f..59ebfda912eb 100644
> > --- a/EmulatorPkg/EmuGopDxe/Gop.h
> > +++ b/EmulatorPkg/EmuGopDxe/Gop.h
> > @@ -1,13 +1,13 @@
> >  /*++ @file
> >
> > -Copyright (c) 2006 - 2008, Intel Corporation. All rights
> > reserved.
> > +Copyright (c) 2006 - 2022, Intel Corporation. All rights
> > +reserved.
> >  Portions copyright (c) 2010,Apple Inc. All rights reserved.
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> >
> > -#ifndef __UGA_H_
> > -#define __UGA_H_
> > +#ifndef GOP_H_
> > +#define GOP_H_
> >
> >  #include 
> >
> > @@ -60,8 +60,6 @@ typedef struct {
> >  extern EFI_DRIVER_BINDING_PROTOCOL  gEmuGopDriverBinding;  extern
> > EFI_COMPONENT_NAME_PROTOCOL  gEmuGopComponentName;
> >
> > -#define EMU_UGA_CLASS_NAME  L"EmuGopWindow"
> > -
> >  #define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('G', 'o', 'p', 'N')
> > typedef struct {
> >UINT64   Signature;
> > @@ -83,7 +81,7 @@ typedef struct {
> >GOP_MODE_DATA*ModeData;
> >
> >//
> > -  // UGA Private Data knowing when to start hardware
> > +  // Private Data knowing when to start hardware
> >//
> >BOOLEAN  HardwareNeedsStarting;
> >
> > diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c
> > b/EmulatorPkg/EmuGopDxe/GopScreen.c
> > index 88d95b88e162..113b496861b4 100644
> > --- a/EmulatorPkg/EmuGopDxe/GopScreen.c
> > +++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
> > @@ -10,7 +10,7 @@ Module Name:
> >
> >  Abstract:
> >
> > -  This file produces the graphics abstration of UGA. It is called by
> > +  This file produces the graphics abstration of GOP. It is called by
> >EmuGopDriver.c file which deals with the EFI 1.1 driver model.
> >This file just does graphics.
> >
> > @@ -209,7 +209,7 @@ EmuGopBlt (
> >// the number of bytes in each row can be computed.
> >//
> >if (Delta == 0) {
> > -Delta = Width * sizeof (EFI_UGA_PIXEL);
> > +Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
> >}
> >
> >//
> > @@ -220,8 +220,8 @@ EmuGopBlt (
> >OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
> >
> >//
> > -  // Pack UGA Draw protocol parameters to
> > EMU_GRAPHICS_WINDOWS__BLT_ARGS structure to adapt to
> > -  // GopBlt() API of Unix UGA IO protocol.
> > +  // Pack GOP protocol parameters to
> EMU_GRAPHICS_WINDOW

[edk2-devel] [PATCH 1/1] MdeModulePkg/Core: Move Private calculation after TemporaryRamMigration

2022-07-23 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2639

Move Private calculation after TemporaryRamMigration to avoid calculate
Private twice.

RootCause:
1. ebp is used as Private pointer
2. It is calculated in TemporaryRamMigration again
3. So Private point to the invalid address after second calculation
4. When MigrateMemoryPages consume Private, Segmentation fault happened

Detail analysis can refer
https://bugzilla.tianocore.org/show_bug.cgi?id=2639#c18

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Dandan Bi 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
---
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 22 +--
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 3552feda8f1b..4b6ec00f71bd 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -837,17 +837,6 @@ PeiCheckAndSwitchStack (
 
   DEBUG ((DEBUG_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", 
(UINT64)Private->HeapOffset, (UINT64)Private->StackOffset));
 
-  //
-  // Calculate new HandOffTable and PrivateData address in permanent 
memory's stack
-  //
-  if (StackOffsetPositive) {
-SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID 
*)SecCoreData + StackOffset);
-Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private + 
StackOffset);
-  } else {
-SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID 
*)SecCoreData - StackOffset);
-Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - 
StackOffset);
-  }
-
   //
   // Temporary Ram Support PPI is provided by platform, it will copy
   // temporary memory to permanent memory and do stack switching.
@@ -861,6 +850,17 @@ PeiCheckAndSwitchStack (
 TemporaryRamSize
 );
 
+  //
+  // Calculate new HandOffTable and PrivateData address in permanent 
memory's stack
+  //
+  if (StackOffsetPositive) {
+SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID 
*)SecCoreData + StackOffset);
+Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private + 
StackOffset);
+  } else {
+SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID 
*)SecCoreData - StackOffset);
+Private = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - 
StackOffset);
+  }
+
   //
   // Migrate memory pages allocated in pre-memory phase.
   // It could not be called before calling 
TemporaryRamSupportPpi->TemporaryRamMigration()
-- 
2.26.2.windows.1



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




Re: [edk2-devel] [PATCH v1 1/1] FmpDevicePkg/FmpDxe: Update FmpDeviceCheckImageWithStatus() handling

2022-01-06 Thread Guomin Jiang
Reviewed-by: Guomin Jiang 

Guomin

> -Original Message-
> From: mikub...@linux.microsoft.com 
> Sent: Wednesday, January 5, 2022 4:38 AM
> To: devel@edk2.groups.io
> Cc: Gao, Liming ; Kinney, Michael D
> ; Jiang, Guomin ;
> Xu, Wei6 
> Subject: [PATCH v1 1/1] FmpDevicePkg/FmpDxe: Update
> FmpDeviceCheckImageWithStatus() handling
> 
> From: Michael Kubacki 
> 
> Update the logic handling last attempt status codes from
> FmpDeviceCheckImageWithStatus() implementations to account for cases
> when the function return status code is EFI_SUCCESS (since the image was
> checked successfully) but the ImageUpdatable value is not valid.
> 
> In addition the following sentence is removed from the LastAttemptStatus
> parameter definition for
> FmpDeviceCheckImageWithStatus() since it can lead to confusion.
> The expected status code value range is sufficient to implement the library
> API.
> 
>   "This value will only be checked when this
>    function returns an error."
> 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Guomin Jiang 
> Cc: Wei6 Xu 
> Signed-off-by: Michael Kubacki 
> ---
>  FmpDevicePkg/FmpDxe/FmpDxe.c | 23 
> +++-
>  FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c |  3 +--
>  FmpDevicePkg/Include/Library/FmpDeviceLib.h  |  3 +--
>  3 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c
> b/FmpDevicePkg/FmpDxe/FmpDxe.c index 197df28c8dd6..1e7ec4a09e16
> 100644
> --- a/FmpDevicePkg/FmpDxe/FmpDxe.c
> +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
> @@ -1040,8 +1040,19 @@ CheckTheImageInternal (
>//
>Status = FmpDeviceCheckImageWithStatus UINT8 *)Image) +
> AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
>if (EFI_ERROR (Status)) {
> +// The image cannot be valid if an error occurred checking the image
> +if (*ImageUpdatable == IMAGE_UPDATABLE_VALID) {
> +  *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
> +}
> +
>  DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib
> CheckImage failed. Status = %r\n", mImageIdName, Status));
> +  }
> 
> +  //
> +  // Only validate the library last attempt status code if the image is not
> updatable.
> +  // This specifically avoids converting LAST_ATTEMPT_STATUS_SUCCESS if it
> set for an updatable image.
> +  //
> +  if (*ImageUpdatable != IMAGE_UPDATABLE_VALID) {
>  //
>  // LastAttemptStatus returned from the device library should fall within
> the designated error range
>  // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE,
> LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
> @@ -1049,12 +1060,12 @@ CheckTheImageInternal (
>  if ((*LastAttemptStatus <
> LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||
>  (*LastAttemptStatus >
> LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))
>  {
> -  DEBUG (
> -(DEBUG_ERROR,
> - "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from
> FmpDeviceCheckImageWithStatus() is invalid.\n",
> - mImageIdName,
> - *LastAttemptStatus)
> -);
> +  DEBUG ((
> +DEBUG_ERROR,
> +"FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from
> FmpDeviceCheckImageWithStatus() is invalid.\n",
> +mImageIdName,
> +*LastAttemptStatus
> +));
>*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
>  }
>}
> diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
> b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
> index 2e5c17b2b0f9..82219e87a430 100644
> --- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
> +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
> @@ -434,8 +434,7 @@ FmpDeviceCheckImage (
>  IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
>@param[out] LastAttemptStatus   A pointer to a UINT32 that holds the last
> attempt
>status to report back to the ESRT table in 
> case
> -  of error. This value will only be checked 
> when this
> -  function returns an error.
> +  of error.
> 
>The return status code must fall in the 
> range of
> 
> LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to
> diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h
> b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
> index a14406abe8b5..f82ef64503fa 100644
> --- a/FmpDevicePkg/Include/Library/FmpDeviceLib.h
> +++ b/FmpDevic

Re: [edk2-devel] [PATCH] Wiki: Add optional steps for developer to run CI test before sending

2022-01-10 Thread Guomin Jiang
Reviewed-by: Guomin Jiang 

Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> Zhiguang Liu
> Sent: Monday, January 10, 2022 11:26 AM
> To: devel@edk2.groups.io
> Cc: Gao, Liming 
> Subject: [edk2-devel] [PATCH] Wiki: Add optional steps for developer to run
> CI test before sending
> 
> Cc: Liming Gao 
> Signed-off-by: Zhiguang Liu 
> ---
>  EDK-II-Development-Process.md | 60
> +---
>  1 file changed, 45 insertions(+), 15 deletions(-)
> 
> diff --git a/EDK-II-Development-Process.md b/EDK-II-Development-
> Process.md
> index 469a979..747c6e1 100644
> --- a/EDK-II-Development-Process.md
> +++ b/EDK-II-Development-Process.md
> @@ -59,20 +59,50 @@ The developer process for the EDK II project
> 
>  `$ git rebase origin/master`
> 
> -9. Run the automated code formatting tool (Uncrustify) against your
> changes
> 
> -
> 
> -   - [EDK-II-Code-Formatting](EDK-II-Code-Formatting "wikilink")
> 
> -
> 
> -   - The changes must pass local CI which includes a code formatting check
> 
> - in order to be merged into the code base.
> 
> -
> 
> -   - It is strongly recommended that you format the code after each commit.
> 
> - The code can then be easily amended with the formatted output. Some
> 
> - developers might also prefer to format frequently while writing the
> 
> - code using the plugin instructions described in the code formatting
> 
> - wiki page.
> 
> -
> 
> -10. Create patch (serial) to the [[edk2-devel]] mailing list
> 
> +9. Run the automated code formatting tool (Uncrustify) against your
> changes
> +
> +   - [EDK-II-Code-Formatting](EDK-II-Code-Formatting "wikilink")
> +
> +   - The changes must pass local CI which includes a code formatting check
> + in order to be merged into the code base.
> +
> +   - It is strongly recommended that you format the code after each commit.
> + The code can then be easily amended with the formatted output. Some
> + developers might also prefer to format frequently while writing the
> + code using the plugin instructions described in the code formatting
> + wiki page.
> +
> +10. (Optional) Push changes to the developer's fork of the EDK II project
> +repository.
> +
> +- How to create a [GitHub
> fork](https://help.github.com/en/github/getting-started-with-github/fork-
> a-repo)
> +  - **NOTE:** A GitHub fork can also be created using the command line
> +utility called [`hub`](https://github.com/github/hub/releases).  The
> +`hub` usage information can be found
> [here](https://hub.github.com/hub.1.html).
> +
> +- Add remote to the developer's fork of the EDK II project
> +
> +`$ git remote add  https://github.com/ id>/edk2.git`
> +
> +- Push the integration branch.
> +
> +`$ git push  `
> +
> +11. (Optional) Create a GitHub pull request from the developer's
> + to edk2/master to run CI check.
> +
> +- How to create a [GitHub pull
> request](https://help.github.com/en/github/collaborating-with-issues-and-
> pull-requests/creating-a-pull-request)
> +  - **NOTE:** A GitHub pull request can also be created using the
> command
> +line utility called [`hub`](https://github.com/github/hub/releases).
> +The `hub` usage information can be found
> [here](https://hub.github.com/hub.1.html).
> +
> +- Declare that it is for CI check test in the pull request title and
> +  description.
> +
> +- Resolve GitHub pull request issues if it fails. Please refrence step 8
> +  in the below **The maintainer process for the EDK II project**
> +
> +12. Create patch (serial) to the [[edk2-devel]] mailing list
> 
>  - Clean out any old patches: `$ rm *.patch`
> 
> @@ -86,7 +116,7 @@ The developer process for the EDK II project
> 
>  - `$ git send-email *.patch`
> 
> -11. Modify local commits based on the review feedbacks and repeat steps
> 
> +13. Modify local commits based on the review feedbacks and repeat steps
>  3 to 9
> 
>  - For the latest commit, you can use `$ git commit --amend`
> --
> 2.32.0.windows.2
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#85435): https://edk2.groups.io/g/devel/message/85435
> Mute This Topic: https://groups.io/mt/88316431/4399222
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub
> [guomin.ji...@intel.com]
> -=-=-=-=-=-=
> 



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




[edk2-devel] [PATCH 01/11] UefiPayloadPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in UefiPayloadPkg.

Signed-off-by: Guomin Jiang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc   | 2 --
 .../Library/PlatformBootManagerLib/PlatformBootManagerLib.inf   | 2 --
 .../Library/PlatformBootManagerLib/PlatformBootManager.h| 2 +-
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 3d08edfe3164..f99e640baa0c 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -361,8 +361,6 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
 

 [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   ## This PCD specified whether ACPI SDT protocol is installed.
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 9c4a9da94350..07b5ad0eb424 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -55,7 +55,6 @@ [Guids]
 [Protocols]
   gEfiGenericMemTestProtocolGuid  ## CONSUMES
   gEfiGraphicsOutputProtocolGuid  ## CONSUMES
-  gEfiUgaDrawProtocolGuid ## CONSUMES
   gEfiBootLogoProtocolGuid## CONSUMES
   gEfiDxeSmmReadyToLockProtocolGuid
   gEfiSmmAccess2ProtocolGuid
@@ -63,7 +62,6 @@ [Protocols]
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
   gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
index 5614aadafb98..082d88caa66d 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.h
@@ -98,7 +98,7 @@ PlatformBootManagerEnableQuietBoot (
   Use SystemTable Conout to turn on video based Simple Text Out consoles. The
   Simple Text Out screens will now be synced up with all non video output 
devices
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic devices are back in text mode and synced up.
 
 **/
 EFI_STATUS
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 00/11] Remove All UGA support

2022-01-13 Thread Guomin Jiang
REF: https//bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove UGA protocol support and only support GOP protocol
GOP is modern graphic protocol of EDK2 and UGA is deprecated in fact.

GuoMinJ (11):
  UefiPayloadPkg: Remove All UGA Support
  ArmVirtPkg: Remove All UGA Support
  ArmPkg: Remove All UGA Support
  EmulatorPkg: Remove All UGA Support
  ShellPkg: Remove All UGA Support
  OvmfPkg: Remove All UGA Support
  MdeModulePkg/ConSplitterDxe: Remove All UGA Support
  MdeModulePkg/GraphicsConsoleDxe: Remove All UGA Support
  MdeModulePkg: Remove All UGA Support
  BaseTools: Remove All UGA Support
  MdePkg: Remove All UGA Support

 MdeModulePkg/MdeModulePkg.dec |  14 -
 MdePkg/MdePkg.dec |  12 -
 ArmVirtPkg/ArmVirtQemu.dsc|   5 -
 ArmVirtPkg/ArmVirtQemuKernel.dsc  |   5 -
 MdePkg/MdePkg.dsc |   3 -
 OvmfPkg/AmdSev/AmdSevX64.dsc  |   2 -
 OvmfPkg/Bhyve/BhyveX64.dsc|   2 -
 OvmfPkg/Microvm/MicrovmX64.dsc|   2 -
 OvmfPkg/OvmfPkgIa32.dsc   |   2 -
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 -
 OvmfPkg/OvmfPkgX64.dsc|   2 -
 OvmfPkg/OvmfXen.dsc   |   2 -
 UefiPayloadPkg/UefiPayloadPkg.dsc |   2 -
 .../PlatformBootManagerLib.inf|   3 -
 .../Library/BootLogoLib/BootLogoLib.inf   |   4 -
 .../Console/ConSplitterDxe/ConSplitterDxe.inf |  17 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf |   8 +-
 MdePkg/Library/UefiLib/UefiLib.inf|   2 -
 .../UefiHandleParsingLib.inf  |   4 +-
 .../PlatformBootManagerLib.inf|   2 -
 .../PlatformBootManagerLib/PlatformBm.h   |   2 +-
 .../Source/C/Include/Protocol/HiiFramework.h  |  53 +--
 BaseTools/Source/C/Include/Protocol/UgaDraw.h | 161 ---
 EmulatorPkg/EmuGopDxe/Gop.h   |  10 +-
 EmulatorPkg/Include/Protocol/EmuFileSystem.h  |  24 +-
 .../Include/Protocol/EmuGraphicsWindow.h  |  18 +-
 .../Library/PlatformBmLib/PlatformBm.h|   4 +-
 EmulatorPkg/Unix/Host/Gasket.h|  12 +-
 EmulatorPkg/Unix/Host/Host.h  |   3 +-
 MdeModulePkg/Include/Library/BootLogoLib.h|   4 +-
 .../Console/ConSplitterDxe/ConSplitter.h  | 138 +-
 .../GraphicsConsoleDxe/GraphicsConsole.h  |  21 +-
 MdePkg/Include/Protocol/UgaDraw.h | 159 ---
 MdePkg/Include/Protocol/UgaIo.h   | 189 
 MdePkg/Library/UefiLib/UefiLibInternal.h  |   1 -
 .../UefiHandleParsingLib.h|   4 +-
 .../PlatformBootManager.h |   2 +-
 EmulatorPkg/EmuGopDxe/GopScreen.c |  16 +-
 .../Library/PlatformBmLib/PlatformBmData.c|   6 +-
 EmulatorPkg/Unix/Host/X11GraphicsWindow.c |  82 ++--
 EmulatorPkg/Win/Host/WinGopScreen.c   |  10 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |   4 +-
 .../Library/BootLogoLib/BootLogoLib.c | 228 +++---
 .../Console/ConSplitterDxe/ConSplitter.c  | 405 +++---
 .../ConSplitterDxe/ConSplitterGraphics.c  | 310 +-
 .../GraphicsConsoleDxe/GraphicsConsole.c  | 302 +
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |   4 +-
 MdePkg/Library/UefiLib/UefiLibPrint.c |  89 
 .../UefiHandleParsingLib.c|   4 +-
 EmulatorPkg/Unix/Host/Ia32/Gasket.S   |   2 +-
 EmulatorPkg/Unix/Host/X64/Gasket.S|   2 +-
 MdeModulePkg/MdeModulePkg.uni |  12 -
 .../Console/ConSplitterDxe/ConSplitterDxe.uni |  12 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.uni |   6 +-
 MdePkg/MdePkg.uni |   6 -
 .../UefiHandleParsingLib.uni  |   4 +-
 56 files changed, 264 insertions(+), 2140 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/Protocol/UgaDraw.h
 delete mode 100644 MdePkg/Include/Protocol/UgaDraw.h
 delete mode 100644 MdePkg/Include/Protocol/UgaIo.h

-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 02/11] ArmVirtPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in ArmVirtPkg

Signed-off-by: Guomin Jiang 
Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
---
 ArmVirtPkg/ArmVirtQemu.dsc   | 5 -
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 5 -
 2 files changed, 10 deletions(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 84c28b0c1df4..d18ad9c26672 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -124,11 +124,6 @@ [PcdsFeatureFlag.common]
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
 
-  ## If TRUE, Graphics Output Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-
   gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
 
   gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE)
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 8e82c5050f6b..c8af8cefc2c5 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -107,11 +107,6 @@ [PcdsFeatureFlag.common]
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|TRUE
 
-  ## If TRUE, Graphics Output Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
-
   gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
 
 [PcdsFixedAtBuild.common]
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 03/11] ArmPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in ArmPkg.

Signed-off-by: Guomin Jiang 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
---
 .../Library/PlatformBootManagerLib/PlatformBootManagerLib.inf  | 3 ---
 ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 86751b45f82b..9270fd3e30d6 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -51,9 +51,6 @@ [LibraryClasses]
   UefiLib
   UefiRuntimeServicesTableLib
 
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
-
 [FixedPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h 
b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
index a40a2ff5cb4f..bab86495c1e6 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.h
@@ -43,7 +43,7 @@ EnableQuietBoot (
   Simple Text Out screens will now be synced up with all non video output
   devices
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic devices are back in text mode and synced up.
 **/
 EFI_STATUS
 DisableQuietBoot (
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 04/11] EmulatorPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in EmulatorPkg.

Signed-off-by: Guomin Jiang 
Cc: Andrew Fish 
Cc: Ray Ni 
---
 EmulatorPkg/EmuGopDxe/Gop.h   | 10 +--
 EmulatorPkg/Include/Protocol/EmuFileSystem.h  | 24 +++---
 .../Include/Protocol/EmuGraphicsWindow.h  | 18 ++--
 .../Library/PlatformBmLib/PlatformBm.h|  4 +-
 EmulatorPkg/Unix/Host/Gasket.h| 12 +--
 EmulatorPkg/Unix/Host/Host.h  |  3 +-
 EmulatorPkg/EmuGopDxe/GopScreen.c | 16 ++--
 .../Library/PlatformBmLib/PlatformBmData.c|  6 +-
 EmulatorPkg/Unix/Host/X11GraphicsWindow.c | 82 +--
 EmulatorPkg/Win/Host/WinGopScreen.c   | 10 +--
 EmulatorPkg/Unix/Host/Ia32/Gasket.S   |  2 +-
 EmulatorPkg/Unix/Host/X64/Gasket.S|  2 +-
 12 files changed, 93 insertions(+), 96 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/Gop.h b/EmulatorPkg/EmuGopDxe/Gop.h
index 7f7dc4e8eb9f..099449f5007f 100644
--- a/EmulatorPkg/EmuGopDxe/Gop.h
+++ b/EmulatorPkg/EmuGopDxe/Gop.h
@@ -1,13 +1,13 @@
 /*++ @file
 
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 Portions copyright (c) 2010,Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef __UGA_H_
-#define __UGA_H_
+#ifndef GOP_H_
+#define GOP_H_
 
 #include 
 
@@ -60,8 +60,6 @@ typedef struct {
 extern EFI_DRIVER_BINDING_PROTOCOL  gEmuGopDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL  gEmuGopComponentName;
 
-#define EMU_UGA_CLASS_NAME  L"EmuGopWindow"
-
 #define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('G', 'o', 'p', 'N')
 typedef struct {
   UINT64   Signature;
@@ -83,7 +81,7 @@ typedef struct {
   GOP_MODE_DATA*ModeData;
 
   //
-  // UGA Private Data knowing when to start hardware
+  // Private Data knowing when to start hardware
   //
   BOOLEAN  HardwareNeedsStarting;
 
diff --git a/EmulatorPkg/Include/Protocol/EmuFileSystem.h 
b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
index 15de43ac022e..d0c0dee26bff 100644
--- a/EmulatorPkg/Include/Protocol/EmuFileSystem.h
+++ b/EmulatorPkg/Include/Protocol/EmuFileSystem.h
@@ -7,19 +7,19 @@
 
   UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
 
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 Portions copyright (c) 2011, Apple Inc. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef _EMU_UGA_IO_H_
-#define _EMU_UGA_IO_H_
+#ifndef EMU_GRAPHICS_WINDOW_H_
+#define EMU_GRAPHICS_WINDOW_H_
 
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #define EMU_GRAPHICS_WINDOW_PROTOCOL_GUID \
  { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 
0xC1 } }
@@ -29,13 +29,13 @@ typedef struct _EMU_GRAPHICS_WINDOW_PROTOCOL 
EMU_GRAPHICS_WINDOW_PROTOCOL;
 typedef
 EFI_STATUS
 (EFIAPI *EMU_GRAPHICS_WINDOWS_CLOSE)(
-  EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows
   );
 
 typedef
 EFI_STATUS
 (EFIAPI *EMU_GRAPHICS_WINDOWS_SIZE)(
-  EMU_GRAPHICS_WINDOW_PROTOCOL  *Uga,
+  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsWindows,
   UINT32Width,
   UINT32Height
   );
@@ -43,13 +43,13 @@ EFI_STATUS
 typedef
 EFI_STATUS
 (EFIAPI *EMU_GRAPHICS_WINDOWS_CHECK_KEY)(
-  EMU_GRAPHICS_WINDOW_PROTOCOL *Uga
+  EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows
   );
 
 typedef
 EFI_STATUS
 (EFIAPI *EMU_GRAPHICS_WINDOWS_GET_KEY)(
-  EMU_GRAPHICS_WINDOW_PROTOCOL  *Uga,
+  EMU_GRAPHICS_WINDOW_PROTOCOL  *GraphicsWindows,
   EFI_KEY_DATA  *key
   );
 
@@ -88,10 +88,10 @@ typedef struct {
 typedef
 EFI_STATUS
 (EFIAPI *EMU_GRAPHICS_WINDOWS_BLT)(
-  IN  EMU_GRAPHICS_WINDOW_PROTOCOL*GraphicsWindows,
-  IN  EFI_UGA_PIXEL   *BltBuffer OPTIONAL,
-  IN  EFI_UGA_BLT_OPERATION   BltOperation,
-  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS  *Args
+  IN  EMU_GRAPHICS_WINDOW_PROTOCOL   *GraphicsWindows,
+  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer OPTIONAL,
+  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,
+  IN  EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
   );
 
 typedef
diff --git a/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h 
b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
index 7c495b25eb1b..ed7b71611f90 100644
--- a/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
+++ b/EmulatorPkg/Include/Protocol/EmuGraphicsWindow.h
@@ -6,13 +6,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef _EMU_UGA_IO_H_
-#define _EMU_UGA_IO_H_
+#ifndef EMU_GRAPHICS_WINDOW_H_
+#define EMU_GRAPHICS_WINDOW_H_
 
 #include 
 #include 
 #include 
-#include 
+#inc

[edk2-devel] [PATCH 05/11] ShellPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in ShellPkg.

Signed-off-by: Guomin Jiang 
Cc: Ray Ni 
Cc: Zhichao Gao 
---
 .../Library/UefiHandleParsingLib/UefiHandleParsingLib.inf | 4 +---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h  | 4 +---
 ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c  | 4 +---
 .../Library/UefiHandleParsingLib/UefiHandleParsingLib.uni | 4 +---
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 0d483805e712..97fed1a50859 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -1,6 +1,6 @@
 ##  @file
 #  Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
-#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. 
+#  Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved. 
 #  (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
 #  (C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP
 #
@@ -129,8 +129,6 @@ [Protocols]
   gEfiHiiConfigAccessProtocolGuid ## UNDEFINED
   gEfiFormBrowser2ProtocolGuid## UNDEFINED
   gEfiDeviceIoProtocolGuid## UNDEFINED
-  gEfiUgaDrawProtocolGuid ## UNDEFINED
-  gEfiUgaIoProtocolGuid   ## UNDEFINED
   gEfiDriverConfigurationProtocolGuid ## UNDEFINED
   gEfiDriverConfiguration2ProtocolGuid## UNDEFINED
   gEfiSimpleTextInputExProtocolGuid   ## UNDEFINED
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
index 6be0d78c4c5a..ab66ed141757 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
 
-  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP
   (C) Copyright 2013-2016 Hewlett-Packard Development Company, L.P.
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -94,8 +94,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index aa0115bdd498..d67ca16b5ece 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle 
and protocol database.
 
-  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
   (C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -2238,8 +2238,6 @@ STATIC CONST GUID_INFO_BLOCK  mGuidStringList[] = {
   { STRING_TOKEN (STR_SHELL_ENV2),  &gEfiShellEnvironment2Guid,
NULL },
   { STRING_TOKEN (STR_SHELL_ENV),   &gEfiShellEnvironment2Guid,
NULL },
   { STRING_TOKEN (STR_DEVICE_IO),   &gEfiDeviceIoProtocolGuid, 
NULL },
-  { STRING_TOKEN (STR_UGA_DRAW),&gEfiUgaDrawProtocolGuid,  
NULL },
-  { STRING_TOKEN (STR_UGA_IO),  &gEfiUgaIoProtocolGuid,
NULL },
   { STRING_TOKEN (STR_ESP), &gEfiPartTypeSystemPartGuid,   
NULL },
   { STRING_TOKEN (STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid,
NULL },
   { STRING_TOKEN (STR_DRIVER_CONFIG),   
&gEfiDriverConfigurationProtocolGuid,  NULL 
},
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni 
b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
index aa3396cea94d..1ecc99ba03fe 100644
--- a/Shell

[edk2-devel] [PATCH 06/11] OvmfPkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Delete PcdConOutGopSupport, it is unnecessary any more.

Signed-off-by: Guomin Jiang 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Anthony Perard 
Cc: Julien Grall 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc   | 2 --
 OvmfPkg/Bhyve/BhyveX64.dsc | 2 --
 OvmfPkg/Microvm/MicrovmX64.dsc | 2 --
 OvmfPkg/OvmfPkgIa32.dsc| 2 --
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 --
 OvmfPkg/OvmfPkgX64.dsc | 2 --
 OvmfPkg/OvmfXen.dsc| 2 --
 7 files changed, 14 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 04ae61cf69d8..bf649cc3796a 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -423,8 +423,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 5fa08bebd73c..df417365aab3 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -412,8 +412,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 1c2e600febee..6a66f4fbf6d9 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -435,8 +435,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 085cc7ece15d..28ef361f5316 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -454,8 +454,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !ifdef $(CSM_ENABLE)
   gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 0ce122ddb50c..f93675fcfba3 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -458,8 +458,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !ifdef $(CSM_ENABLE)
   gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 4589adff388d..79740c04457f 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -459,8 +459,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 !ifdef $(CSM_ENABLE)
   gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index de0d30bfb807..83114e7f7ee8 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -353,8 +353,6 @@ [PcdsFeatureFlag]
   gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE

[edk2-devel] [PATCH 07/11] MdeModulePkg/ConSplitterDxe: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove the PcdConOutGopSupport, it is unnecessary any more.
Remove All UGA Support in ConSplitterDxe component.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
---
 .../Console/ConSplitterDxe/ConSplitterDxe.inf |  17 +-
 .../Console/ConSplitterDxe/ConSplitter.h  | 138 +-
 .../Console/ConSplitterDxe/ConSplitter.c  | 405 +++---
 .../ConSplitterDxe/ConSplitterGraphics.c  | 310 +-
 .../Console/ConSplitterDxe/ConSplitterDxe.uni |  12 +-
 5 files changed, 80 insertions(+), 802 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf 
b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
index 9aa1dade752a..c0c57193b04d 100644
--- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
@@ -3,14 +3,9 @@
 #
 # This driver acts as a virtual console, takes over the console I/O control 
from selected
 # standard console devices, and transmits console I/O to related console 
device drivers.
-# Consplitter could install Graphics Output protocol and/or UGA Draw protocol 
in system
-# table according PCD settings(PcdConOutGopSupport, and PcdConOutUgaSupport). 
It always
-# consumes Graphics Output protocol which is produced by display device, and 
consumes UGA Draw
-# protocol which is produced by display device according to 
PcdUgaConsumeSupport value.
-# Note: If only UGA Draw protocol is installed in system, PcdUgaConsumeSupport 
should be
-# set to TRUE.
+# It always consumes Graphics Output protocol which is produced by display 
device
 #
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -92,14 +87,6 @@ [Protocols]
   ## SOMETIMES_PRODUCES
   ## SOMETIMES_CONSUMES
   gEfiGraphicsOutputProtocolGuid
-  ## SOMETIMES_PRODUCES
-  ## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid
-
-[FeaturePcd]
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport   ## CONSUMES
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport   ## CONSUMES
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport## CONSUMES
 
 [Pcd]
   ## SOMETIMES_PRODUCES
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h 
b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
index a1fe74726058..ec74415a2fb1 100644
--- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
+++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
@@ -1,7 +1,7 @@
 /** @file
   Private data structures for the Console Splitter driver
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -182,7 +181,6 @@ typedef struct {
 
 typedef struct {
   EFI_GRAPHICS_OUTPUT_PROTOCOL   *GraphicsOutput;
-  EFI_UGA_DRAW_PROTOCOL  *UgaDraw;
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*TextOut;
 } TEXT_OUT_AND_GOP_DATA;
 
@@ -195,16 +193,9 @@ typedef struct {
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL TextOut;
   EFI_SIMPLE_TEXT_OUTPUT_MODE TextOutMode;
 
-  EFI_UGA_DRAW_PROTOCOL   UgaDraw;
-  UINT32  UgaHorizontalResolution;
-  UINT32  UgaVerticalResolution;
-  UINT32  UgaColorDepth;
-  UINT32  UgaRefreshRate;
-
   EFI_GRAPHICS_OUTPUT_PROTOCOLGraphicsOutput;
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION*GraphicsOutputModeBuffer;
   UINTN   CurrentNumberOfGraphicsOutput;
-  UINTN   CurrentNumberOfUgaDraw;
 
   UINTN   CurrentNumberOfConsoles;
   TEXT_OUT_AND_GOP_DATA   *TextOutList;
@@ -230,13 +221,6 @@ typedef struct {
   TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE  \
   )
 
-#define UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \
-  CR ((a),  \
-  TEXT_OUT_SPLITTER_PRIVATE_DATA,   \
-  UgaDraw,  \
-  TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE  \
-  )
-
 #define CONSOLE_CONTROL_SPLITTER_PRIVATE_DATA_FROM_THIS(a)  \
   CR ((a),  \
   TEXT_OUT_SPLITTER_PRIVATE_DATA,   \
@@ -254,7 +238,7 @@ typedef struct {
   Installs driver module protocols and. Creates virtual device handles for 
ConIn,
   ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex 
protocol,
   Simple Pointer

[edk2-devel] [PATCH 08/11] MdeModulePkg/GraphicsConsoleDxe: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in GraphicsConsoleDxe, remove comment about UGA
in HiiDatabaseDxe.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Cc: Dandan Bi 
Cc: Eric Dong 
---
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.inf |   8 +-
 .../GraphicsConsoleDxe/GraphicsConsole.h  |  21 +-
 .../GraphicsConsoleDxe/GraphicsConsole.c  | 302 +-
 MdeModulePkg/Universal/HiiDatabaseDxe/Image.c |   4 +-
 .../GraphicsConsoleDxe/GraphicsConsoleDxe.uni |   6 +-
 5 files changed, 24 insertions(+), 317 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
index bcfd306eee13..67c6e878efbb 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
@@ -2,9 +2,9 @@
 #  Console support on graphic devices.
 #
 #  This driver will install Simple Text Output protocol by consuming Graphices 
Output
-#  protocol or UGA Draw protocol on graphic devices.
+#  protocol on graphic devices.
 #
-#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 #
@@ -53,15 +53,11 @@ [Protocols]
   gEfiDevicePathProtocolGuid## TO_START
   gEfiSimpleTextOutProtocolGuid ## BY_START
   gEfiGraphicsOutputProtocolGuid## TO_START
-  gEfiUgaDrawProtocolGuid   ## TO_START
   gEfiHiiFontProtocolGuid   ## TO_START
   ## TO_START
   ## NOTIFY
   gEfiHiiDatabaseProtocolGuid
 
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES
-
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## 
SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution   ## 
SOMETIMES_CONSUMES
diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
index e4abad40f49a..ab700f31aa97 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
@@ -1,7 +1,7 @@
 /** @file
   Header file for GraphicsConsole driver.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -59,7 +58,6 @@ typedef struct {
 typedef struct {
   UINTN  Signature;
   EFI_GRAPHICS_OUTPUT_PROTOCOL   *GraphicsOutput;
-  EFI_UGA_DRAW_PROTOCOL  *UgaDraw;
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLSimpleTextOutput;
   EFI_SIMPLE_TEXT_OUTPUT_MODESimpleTextOutputMode;
   GRAPHICS_CONSOLE_MODE_DATA *ModeData;
@@ -417,9 +415,8 @@ GraphicsConsoleConOutEnableCursor (
 /**
   Test to see if Graphics Console could be supported on the Controller.
 
-  Graphics Console could be supported if Graphics Output Protocol or UGADraw
-  Protocol exists on the Controller. (UGA Draw Protocol could be skipped
-  if PcdUgaConsumeSupport is set to FALSE.)
+  Graphics Console could be supported if Graphics Output Protocol
+  exists on the Controller.
 
   @param  ThisProtocol instance pointer.
   @param  Controller  Handle of device to test.
@@ -439,9 +436,8 @@ GraphicsConsoleControllerDriverSupported (
   );
 
 /**
-  Start this driver on Controller by opening Graphics Output protocol or
-  UGA Draw protocol, and installing Simple Text Out protocol on Controller.
-  (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
+  Start this driver on Controller by opening Graphics Output protocol
+  and installing Simple Text Out protocol on Controller.
 
   @param  This Protocol instance pointer.
   @param  Controller   Handle of device to bind driver to
@@ -462,9 +458,7 @@ GraphicsConsoleControllerDriverStart (
 
 /**
   Stop this driver on Controller by removing Simple Text Out protocol
-  and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
-  (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
-
+  and closing the Graphics Output Protocol on Controller.
 
   @param  This  Protocol instance pointer.
   @param  ControllerHandle of device to stop driver on
@@ -526,8 +520,7 @@ GetTextColors (
   @param  Count The count of Unicode string.
 
   @retval EFI_OUT_OF_RESOURCES  If no memory resource to use.
-  @retval EFI_UNSUPPORTED   If no

[edk2-devel] [PATCH 09/11] MdeModulePkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in MdeModulePkg, first remove from library.
Remove the PcdConOutGopSupport definition.

Signed-off-by: Guomin Jiang 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Cc: Hao A Wu 
---
 MdeModulePkg/MdeModulePkg.dec |  14 --
 .../Library/BootLogoLib/BootLogoLib.inf   |   4 -
 MdeModulePkg/Include/Library/BootLogoLib.h|   4 +-
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |   4 +-
 .../Library/BootLogoLib/BootLogoLib.c | 228 +-
 MdeModulePkg/MdeModulePkg.uni |  12 -
 6 files changed, 60 insertions(+), 206 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 463e889e9a68..21e037269cce 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -726,20 +726,6 @@ [PcdsFeatureFlag]
   # @Prompt Enable Unicode Collation 2 support.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdUnicodeCollation2Support|TRUE|BOOLEAN|0x00010041
 
-  ## Indicates if Graphics Output Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  #   TRUE  - Installs Graphics Output Protocol on virtual handle created by 
ConsplitterDxe.
-  #   FALSE - Does not install Graphics Output Protocol on virtual handle 
created by ConsplitterDxe.
-  # @Prompt Enable ConOut GOP support.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE|BOOLEAN|0x00010042
-
-  ## Indicates if UGA Draw Protocol will be installed on virtual handle 
created by ConsplitterDxe.
-  #  It could be set FALSE to save size.
-  #   TRUE  - Installs UGA Draw Protocol on virtual handle created by 
ConsplitterDxe.
-  #   FALSE - Does not install UGA Draw Protocol on virtual handle created by 
ConsplitterDxe.
-  # @Prompt Enable ConOut UGA support.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|TRUE|BOOLEAN|0x00010043
-
   ## Indicates PeiCore will first search TE section from the PEIM to load the 
image, or PE32 section, when PeiCore dispatches a PEI module.
   #  This PCD is used to tune PEI phase performance to reduce the search image 
time.
   #  It can be set according to the generated image section type.
diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf 
b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
index 7d50f2dfa3ab..03fd70451bc6 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -42,11 +42,7 @@ [LibraryClasses]
 
 [Protocols]
   gEfiGraphicsOutputProtocolGuid## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid |PcdUgaConsumeSupport ## SOMETIMES_CONSUMES
   gEfiBootLogoProtocolGuid  ## SOMETIMES_CONSUMES
   gEdkiiBootLogo2ProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiUserManagerProtocolGuid   ## CONSUMES
   gEdkiiPlatformLogoProtocolGuid## CONSUMES
-
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES
diff --git a/MdeModulePkg/Include/Library/BootLogoLib.h 
b/MdeModulePkg/Include/Library/BootLogoLib.h
index 2d6209a2789b..a774a7392590 100644
--- a/MdeModulePkg/Include/Library/BootLogoLib.h
+++ b/MdeModulePkg/Include/Library/BootLogoLib.h
@@ -2,7 +2,7 @@
   This library is only intended to be used by PlatformBootManagerLib
   to show progress bar and LOGO.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -26,7 +26,7 @@ BootLogoEnableLogo (
   Use SystemTable ConOut to turn on video based Simple Text Out consoles. The
   Simple Text Out screens will now be synced up with all non-video output 
devices.
 
-  @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
+  @retval EFI_SUCCESS Graphic device are back in text mode and synced up.
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
index 337b2090d98e..c4e45c2d3de9 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
@@ -8,7 +8,7 @@
   PCI Root Bridges. So it means platform needs install PCI Root Bridge IO 
protocol for each
   PCI Root Bus and install PCI Host Bridge Resource Allocation Protocol.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -49,7 +49,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED 
EFI_PCI_HOTPLUG_REQUEST_PROTOCOL  mPciHotPlugReque
   Installs driver module protocols and. Creates virtual device handles for 
ConIn,
   ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex 
protocol,
   Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
-  Installs Graphics Output protocol and/or

[edk2-devel] [PATCH 10/11] BaseTools: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove all UGA support in BaseTools package.

Signed-off-by: Guomin Jiang 
Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
---
 .../Source/C/Include/Protocol/HiiFramework.h  |  53 +-
 BaseTools/Source/C/Include/Protocol/UgaDraw.h | 161 --
 2 files changed, 1 insertion(+), 213 deletions(-)
 delete mode 100644 BaseTools/Source/C/Include/Protocol/UgaDraw.h

diff --git a/BaseTools/Source/C/Include/Protocol/HiiFramework.h 
b/BaseTools/Source/C/Include/Protocol/HiiFramework.h
index 448350967bbf..8cd2cb80c01c 100644
--- a/BaseTools/Source/C/Include/Protocol/HiiFramework.h
+++ b/BaseTools/Source/C/Include/Protocol/HiiFramework.h
@@ -6,7 +6,7 @@
   @par Revision Reference:
   This protocol is defined in HII spec 0.92.
 
-  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -28,20 +28,6 @@
 0xd7ad636e, 0xb997, 0x459b, {0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 
0xe1} \
   }
 
-// BugBug:
-//
-// If UGA goes away we need to put this some place. I'm not sure where?
-//
-//typedef struct {
-//  UINT8 Blue;
-//  UINT8 Green;
-//  UINT8 Red;
-//  UINT8 Reserved;
-//} EFI_UGA_PIXEL;
-
-//
-//
-
 typedef struct _EFI_HII_PROTOCOL  EFI_HII_PROTOCOL;
 
 //
@@ -575,39 +561,6 @@ EFI_STATUS
   IN OUT UINT32*InternalStatus
   );
 
-/**
-  Translates a glyph into the format required for input to the Universal
-  Graphics Adapter (UGA) Block Transfer (BLT) routines.
-
-  @param  This  A pointer to the EFI_HII_PROTOCOL instance.
-  @param  GlyphBuffer   A pointer to the buffer that contains glyph 
data.
-  @param  ForegroundThe foreground setting requested to be used 
for the
-generated BltBuffer data.
-  @param  BackgroundThe background setting requested to be used 
for the
-generated BltBuffer data.
-  @param  Count The entry in the BltBuffer upon which to act.
-  @param  Width The width in bits of the glyph being converted.
-  @param  HeightThe height in bits of the glyph being converted
-  @param  BltBuffer A pointer to the buffer that contains the data 
that is
-ready to be used by the UGA BLT routines.
-
-  @retval EFI_SUCCESS   It worked.
-  @retval EFI_NOT_FOUND A glyph for a character was not found.
-
-**/
-typedef
-EFI_STATUS
-(EFIAPI *EFI_HII_GLYPH_TO_BLT) (
-  IN EFI_HII_PROTOCOL *This,
-  IN UINT8*GlyphBuffer,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
-  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
-  IN UINTN Count,
-  IN UINTN Width,
-  IN UINTN Height,
-  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
-  );
-
 /**
   Allows a new string to be added to an already existing string package.
 
@@ -878,9 +831,6 @@ EFI_STATUS
   @param GetGlyph
   Translates a Unicode character into the corresponding font glyph.
 
-  @param GlyphToBlt
-  Converts a glyph value into a format that is ready for a UGA BLT command.
-
   @param NewString
   Allows a new string to be added to an already existing string package.
 
@@ -924,7 +874,6 @@ struct _EFI_HII_PROTOCOL {
 
   EFI_HII_TEST_STRING TestString;
   EFI_HII_GET_GLYPH   GetGlyph;
-  EFI_HII_GLYPH_TO_BLTGlyphToBlt;
 
   EFI_HII_NEW_STRING  NewString;
   EFI_HII_GET_PRI_LANGUAGES   GetPrimaryLanguages;
diff --git a/BaseTools/Source/C/Include/Protocol/UgaDraw.h 
b/BaseTools/Source/C/Include/Protocol/UgaDraw.h
deleted file mode 100644
index 412b000aeb6b..
--- a/BaseTools/Source/C/Include/Protocol/UgaDraw.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/** @file
-  UGA Draw protocol from the EFI 1.1 specification.
-
-  Abstraction of a very simple graphics device.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __UGA_DRAW_H__
-#define __UGA_DRAW_H__
-
-#define EFI_UGA_DRAW_PROTOCOL_GUID \
-  { \
-0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 
0x39 } \
-  }
-
-typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
-
-/**
-  Return the current video mode information.
-
-  @param  This  Protocol instance pointer.
-  @param  HorizontalResolution  Current video horizontal resolution in pixels
-  @param  VerticalResolutionCurrent video vertical resolution in pixels
-  @param  ColorDepthCurrent video color depth in bits per pixel
-  @param  Refres

[edk2-devel] [PATCH 11/11] MdePkg: Remove All UGA Support

2022-01-13 Thread Guomin Jiang
From: GuoMinJ 

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

Remove All UGA Support in MdePkg.

Signed-off-by: Guomin Jiang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
---
 MdePkg/MdePkg.dec|  12 --
 MdePkg/MdePkg.dsc|   3 -
 MdePkg/Library/UefiLib/UefiLib.inf   |   2 -
 MdePkg/Include/Protocol/UgaDraw.h| 159 ---
 MdePkg/Include/Protocol/UgaIo.h  | 189 ---
 MdePkg/Library/UefiLib/UefiLibInternal.h |   1 -
 MdePkg/Library/UefiLib/UefiLibPrint.c|  89 ---
 MdePkg/MdePkg.uni|   6 -
 8 files changed, 461 deletions(-)
 delete mode 100644 MdePkg/Include/Protocol/UgaDraw.h
 delete mode 100644 MdePkg/Include/Protocol/UgaIo.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 59b405928bf8..9960c44754bc 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1446,12 +1446,6 @@ [Protocols]
   ## Include/Protocol/EdidOverride.h
   gEfiEdidOverrideProtocolGuid   = { 0x48ECB431, 0xFB72, 0x45C0, { 0xA9, 0x22, 
0xF4, 0x58, 0xFE, 0x04, 0x0B, 0xD5 }}
 
-  ## Include/Protocol/UgaIo.h
-  gEfiUgaIoProtocolGuid  = { 0x61A4D49E, 0x6F68, 0x4F1B, { 0xB9, 0x22, 
0xA8, 0x6E, 0xED, 0x0B, 0x07, 0xA2 }}
-
-  ## Include/Protocol/UgaDraw.h
-  gEfiUgaDrawProtocolGuid= { 0x982C298B, 0xF4FA, 0x41CB, { 0xB8, 0x38, 
0x77, 0xAA, 0x68, 0x8F, 0xB8, 0x39 }}
-
   ## Include/Protocol/LoadedImage.h
   gEfiLoadedImageProtocolGuid= { 0x5B1B31A1, 0x9562, 0x11D2, { 0x8E, 0x3F, 
0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }}
 
@@ -1942,12 +1936,6 @@ [PcdsFeatureFlag]
   # @Prompt Deprecate Global Variable LangCodes.
   
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate|FALSE|BOOLEAN|0x0012
 
-  ## Indicates if UGA Draw Protocol is still consumed.
-  #   TRUE  - Consume UGA Draw protocol.
-  #   FALSE - Does not consume UGA Draw protocol.
-  # @Prompt Consume UGA Draw Protocol.
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|TRUE|BOOLEAN|0x0027
-
   ## Indicates if a check will be made to see if a specified node is a member 
of linked list
   #  in the following BaseLib functions: GetNextNode(), IsNull(), 
IsNodeAtEnd(), SwapListEntries().
   #   TRUE  - Verify a specified node is a member of linked list.
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index a94959169b2f..939e1a7b5299 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -23,9 +23,6 @@ [Defines]
 
 !include MdePkg/MdeLibs.dsc.inc
 
-[PcdsFeatureFlag]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|TRUE
-
 [PcdsFixedAtBuild]
   gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0f
   gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000
diff --git a/MdePkg/Library/UefiLib/UefiLib.inf 
b/MdePkg/Library/UefiLib/UefiLib.inf
index 01ed92092da2..9f3863787833 100644
--- a/MdePkg/Library/UefiLib/UefiLib.inf
+++ b/MdePkg/Library/UefiLib/UefiLib.inf
@@ -67,7 +67,6 @@ [Protocols]
   gEfiGraphicsOutputProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiHiiFontProtocolGuid ## SOMETIMES_CONSUMES
   gEfiSimpleFileSystemProtocolGuid## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid | gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport  
   ## SOMETIMES_CONSUMES # Consumes if gEfiGraphicsOutputProtocolGuid 
uninstalled
   gEfiComponentNameProtocolGuid  | NOT 
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable   ## SOMETIMES_PRODUCES # User 
chooses to produce it
   gEfiComponentName2ProtocolGuid | NOT 
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable  ## SOMETIMES_PRODUCES # User 
chooses to produce it
   gEfiDriverConfigurationProtocolGuid## 
SOMETIMES_PRODUCES # User chooses to produce it
@@ -84,5 +83,4 @@ [FeaturePcd]
   gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable## CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable   ## CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable   ## CONSUMES
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport   ## CONSUMES
 
diff --git a/MdePkg/Include/Protocol/UgaDraw.h 
b/MdePkg/Include/Protocol/UgaDraw.h
deleted file mode 100644
index 8d33bf873cad..
--- a/MdePkg/Include/Protocol/UgaDraw.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/** @file
-  UGA Draw protocol from the EFI 1.10 specification.
-
-  Abstraction of a very simple graphics device.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __UGA_DRAW_H__
-#define __UGA_DRAW_H__
-
-#define EFI_UGA_DRAW_PROTOCOL_GUID \
-  { \
-0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 
0x39 } \
-  }
-
-typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
-
-/**
-  Return the current video mode information.
-
-  @param  This  The EFI_UGA_DRAW_PROTOCOL instance.
-  @param  HorizontalResolution  The size of video screen in pixels in the X 
dimension.
-  @param

[edk2-devel] [ed2-platforms][PATCH 1/2] Platform/Intel/SimicsOpenBoardPkg: Remove all UGA support

2022-01-20 Thread Guomin Jiang
From: GuoMinJ 

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

Cc: Nate DeSimone 
Signed-off-by: Guomin Jiang 
---
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc |  4 +-
 .../Library/DxeLogoLib/DxeLogoLib.inf |  6 +--
 .../Library/DxeLogoLib/Logo.c | 45 +--
 3 files changed, 3 insertions(+), 52 deletions(-)

diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc 
b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index 88009b8f1022..9b81726623dc 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  PCD configuration build description file for the X58Ich10 board.
 #
-# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved. 
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved. 
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -31,8 +31,6 @@ [PcdsFeatureFlag.common]
   # Edk2 Configuration
   ##
   gEfiMdeModulePkgTokenSpaceGuid.PcdBrowerGrayOutReadOnlyMenu|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf 
b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
index ff08c385b3a0..cd9565e123db 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/DxeLogoLib.inf
@@ -6,7 +6,7 @@
 # 2) BDS boot device connect interface;
 # 3) BDS Misc interfaces for mainting boot variable, ouput string, etc.
 #
-# Copyright (c) 2007 - 2019 Intel Corporation. All rights reserved. 
+# Copyright (c) 2007 - 2022 Intel Corporation. All rights reserved. 
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -41,15 +41,11 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
   SimicsOpenBoardPkg/OpenBoardPkg.dec
 
-[FeaturePcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
-
 [Sources]
   Logo.c
 
 [Protocols]
   gEfiGraphicsOutputProtocolGuid## SOMETIMES_CONSUMES
-  gEfiUgaDrawProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiBootLogoProtocolGuid  ## SOMETIMES_CONSUMES
   gEfiUserManagerProtocolGuid   ## CONSUMES
   gEfiOemBadgingProtocolGuid## CONSUMES
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c 
b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
index 48a718a90d46..9cea5f4665d0 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/DxeLogoLib/Logo.c
@@ -1,7 +1,7 @@
 /** @file
   BDS Lib functions which contain all the code to connect console device
 
-  Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. 
+  Copyright (c) 2006 - 2022 Intel Corporation. All rights reserved. 
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -300,9 +299,6 @@ EnableBootLogo (
   UINTN Height;
   UINTN Width;
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  EFI_UGA_DRAW_PROTOCOL *UgaDraw;
-  UINT32ColorDepth;
-  UINT32RefreshRate;
   EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
   EFI_BOOT_LOGO_PROTOCOL*BootLogo;
   UINTN NumberOfLogos;
@@ -317,18 +313,10 @@ EnableBootLogo (
   UINTN NewWidth;
   UINT64BufferSize;
 
-  UgaDraw = NULL;
   //
   // Try to open GOP first
   //
   Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
-GraphicsOutput = NULL;
-//
-// Open GOP failed, try to open UGA
-//
-Status = gBS->HandleProtocol (gST->ConsoleOutHandle, 
&gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
-  }
   if (EFI_ERROR (Status)) {
 return EFI_UNSUPPORTED;
   }
@@ -351,11 +339,6 @@ EnableBootLogo (
 SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
 SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
 
-  } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {
-Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, 
&RefreshRate);
-if (EFI_ERROR (Status)) {
-  return EFI_UNSUPPORTED;
-}
   } else {
 return EFI_UNSUPPORTE

[edk2-devel] [ed2-platforms][PATCH 0/2] Remove all UGA support

2022-01-20 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2368

Remove all UGA support

GuoMinJ (2):
  Platform/Intel/SimicsOpenBoardPkg: Remove all UGA support
  Platform/Intel: Remove All UGA Support

 .../BoardX58Ich10/OpenBoardPkgPcd.dsc |  4 +-
 .../Library/DxeLogoLib/DxeLogoLib.inf |  6 +--
 .../DxePlatformBootManagerLib/BdsPlatform.h   |  1 -
 .../Library/DxeLogoLib/Logo.c | 45 +--
 4 files changed, 3 insertions(+), 53 deletions(-)

-- 
2.30.0.windows.2



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




[edk2-devel] [ed2-platforms][PATCH 2/2] Platform/Intel: Remove All UGA Support

2022-01-20 Thread Guomin Jiang
From: GuoMinJ 

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

Remove all UGA Support in INTEL platform.

Cc: Nate DeSimone 
Cc: Zailiang Sun 
Cc: Yi Qian 
Signed-off-by: Guomin Jiang 
---
 .../Library/DxePlatformBootManagerLib/BdsPlatform.h  | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
index 0bdc11bdd824..6cc4e3acf279 100644
--- 
a/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
+++ 
b/Platform/Intel/Vlv2TbltDevicePkg/Library/DxePlatformBootManagerLib/BdsPlatform.h
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 1/1] UefiPayloadPkg/PayloadLoaderPeim: Replace Delta type INTN with UINTN

2022-01-29 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3818

ProcessRelocation64 use INTN  Delta. However it force it to UINTN when
call it.

It will have some potential issue when memory larger than 2G because
the high memory address will be fill with 0x if use INTN.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Signed-off-by: Guomin Jiang 
---
 UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c 
b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
index dc47a05c6e4a..ee530322d7ed 100644
--- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
+++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
@@ -108,7 +108,7 @@ ProcessRelocation64 (
   IN  UINT64  RelaSize,
   IN  UINT64  RelaEntrySize,
   IN  UINT64  RelaType,
-  IN  INTNDelta,
+  IN  UINTN   Delta,
   IN  BOOLEAN DynamicLinking
   )
 {
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 1/1] UefiPayloadPkg/PayloadLoaderPeim: Force UINTN before save Ptr

2022-02-09 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3818

It will have some potential issue when memory larger than 2G because
the high memory address will be fill with 0x when do the
operation of UINT64 + INTN.

V2:
1. Force the data type to UINTN to avoid high dword be filled with
0x
2. Keep INTN because the offset may postive or negative.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Signed-off-by: Guomin Jiang 
---
 UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c 
b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
index dc47a05c6e4a..68200fcadd3f 100644
--- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
+++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
@@ -143,7 +143,7 @@ ProcessRelocation64 (
   DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
   ASSERT (FALSE);
 } else {
-  *Ptr += Delta;
+  *Ptr = *(UINTN *)Ptr + Delta;
 }
 
 break;
@@ -177,12 +177,12 @@ ProcessRelocation64 (
   // Calculation: B + A
   //
   if (RelaType == SHT_RELA) {
-*Ptr = Delta + Rela->r_addend;
+*Ptr = Delta + (UINTN)Rela->r_addend;
   } else {
 //
 // A is stored in the field of relocation for REL type.
 //
-*Ptr = Delta + *Ptr;
+*Ptr = Delta + *(UINTN *)Ptr;
   }
 } else {
   //
-- 
2.30.0.windows.2



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




[edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size

2022-02-17 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840

1. Use DEBUG_FILE to control ASSERT path
2. Default use file name as ASSERT path

Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
   can save many size meanwhile.

Guomin Jiang (2):
  BaseTools/Conf: Reduce the ASSERT patch to save the binary size
  MdePkg/Include: Define new DEBUG_FILE to specify path.

 BaseTools/Conf/build_rule.template | 10 
 MdePkg/Include/Library/DebugLib.h  | 39 +-
 2 files changed, 33 insertions(+), 16 deletions(-)

-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path.

2022-02-17 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840

Use DEBUG_FILE to control ASSERT path

Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
   can save many size meanwhile.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Guomin Jiang 
---
 MdePkg/Include/Library/DebugLib.h | 39 ++-
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 8d3d08638d73..5469c6308422 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL 
implementations.
 
-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -85,6 +85,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define DEBUG_LINE_NUMBER  __LINE__
 #endif
 
+//
+// Source file.
+// Default is use the to compiler provided __FILE__ macro value. The __FILE__
+// mapping can be overriden by predefining DEBUG_FILE
+//
+// Defining DEBUG_FILE to a fixed value is useful when comparing builds
+// across machine or configuration with different slash or path
+// file.
+//
+// Another benefit is we can customize the ASSERT path without depending on
+// compiler ability
+//
+// It's for all no matter VS, GCC, CLANG
+//
+#ifdef DEBUG_FILE
+#else
+#define DEBUG_FILE  __FILE__
+#endif
+
+// Blow override for keep clang behavior
+#if defined (__clang__) && defined (__FILE_NAME__)
+#undef DEBUG_FILE
+#define DEBUG_FILE __FILE_NAME__
+#endif
+
 /**
   Macro that converts a Boolean expression to a Null-terminated ASCII string.
 
@@ -337,17 +362,9 @@ UnitTestDebugAssert (
   IN CONST CHAR8  *Description
   );
 
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
 #else
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  DebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
 #endif
 
 /**
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size

2022-02-17 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840

Use DEBUG_FILE to control ASSERT path

Motivation and Goal:
1. The path will occupy many size in DEBUG build when file path is long
2. We hope can reduce the size but not impact the debug capability
3. If only use filename, we can search the filename to locate file. It
   can save many size meanwhile.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
Signed-off-by: Guomin Jiang 
---
 BaseTools/Conf/build_rule.template | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index f40118234471..ad0bae42be62 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 #  Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
 #  Copyright (c) 2020, ARM Ltd. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -126,14 +126,14 @@
 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
 
 
-"$(CC)" /Fo${dst} $(DEPS_FLAGS) $(CC_FLAGS) $(INC) ${src}
+"$(CC)" /Fo${dst} $(DEPS_FLAGS) /D DEBUG_FILE="\"${s_base}.c\"" 
$(CC_FLAGS) $(INC) ${src}
 
 
 # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
-"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
+"$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) -c 
-o ${dst} $(INC) ${src}
 
 
-"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -o ${dst} $(INC) ${src}
+"$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) -o 
${dst} $(INC) ${src}
 
 
[C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-File.PEIM.ARM]
 
@@ -146,7 +146,7 @@
 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
 
 
-"$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
+"$(CC)" -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS) $(CC_XIPFLAGS) -c 
-o ${dst} $(INC) ${src}
 
 [C-Header-File]
 
-- 
2.35.1.windows.2



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




Re: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the binary size

2022-02-20 Thread Guomin Jiang
Comment inline

Thank
Guomin

> -Original Message-
> From: Kinney, Michael D 
> Sent: Friday, February 18, 2022 11:34 AM
> To: devel@edk2.groups.io; Jiang, Guomin ; Kinney,
> Michael D 
> Subject: RE: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> binary size
> 
> Guomin,
> 
> I think there is a cleaner solution to this problem using compiler flags to
> change the contents of the __FILE__ macro.

Thanks for your information. It is useful.
1. From the link, it seem that the VS haven't support it yet.
2. From my though, It is not good solution that we have strong depend on 
compiler.

> 
> https://blog.conan.io/2019/09/02/Deterministic-builds-with-C-C++.html
> https://reproducible-builds.org/docs/build-path/
> https://developercommunity.visualstudio.com/t/map-file-to-a-relative-
> path/1393881
> 
> I found this content when I was working on the CompareBuild tool and using
> these techniques can guarantee the same binaries are produced when the
> path to WORKSPACE is different on different build systems.
>

 
> Does your change provide a module-relative, package-relative, or
> workspace-relative file path in the ASSERT()?

No, I only use filename to replace the __FILE__

> 
> How does ASSERT() in autogen work?
> 

It is need to do some POC.

> Thanks,
> 
> Mike
> 
> 
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> Guomin
> > Jiang
> > Sent: Thursday, February 17, 2022 6:30 PM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [PATCH 0/2] Reduce the ASSERT patch to save the
> > binary size
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> >
> > 1. Use DEBUG_FILE to control ASSERT path 2. Default use file name as
> > ASSERT path
> >
> > Motivation and Goal:
> > 1. The path will occupy many size in DEBUG build when file path is
> > long 2. We hope can reduce the size but not impact the debug
> > capability 3. If only use filename, we can search the filename to locate 
> > file.
> It
> >can save many size meanwhile.
> >
> > Guomin Jiang (2):
> >   BaseTools/Conf: Reduce the ASSERT patch to save the binary size
> >   MdePkg/Include: Define new DEBUG_FILE to specify path.
> >
> >  BaseTools/Conf/build_rule.template | 10 
> > MdePkg/Include/Library/DebugLib.h  | 39 +--
> ---
> >  2 files changed, 33 insertions(+), 16 deletions(-)
> >
> > --
> > 2.35.1.windows.2
> >
> >
> >
> > 
> >



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




[edk2-devel] [PATCH v3 1/1] UefiPayloadPkg/PayloadLoaderPeim: Use INT64 as input parameter

2022-02-20 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3818

It will have some potential issue when memory larger than 2G because
the high memory address will be fill with 0x when do the
operation of INTN + INT64 but it is 32 bit normal data in fact.

Should use same data type INT64 + INT64.

V3:
1. Use INT64 as input parameter because all date type is 64 bit
V2:
1. Force the data type to UINTN to avoid high dword be filled with
0x
2. Keep INTN because the offset may postive or negative.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Signed-off-by: Guomin Jiang 
---
 UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c 
b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
index dc47a05c6e4a..c8dbb887340b 100644
--- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
+++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/Elf64Lib.c
@@ -108,7 +108,7 @@ ProcessRelocation64 (
   IN  UINT64  RelaSize,
   IN  UINT64  RelaEntrySize,
   IN  UINT64  RelaType,
-  IN  INTNDelta,
+  IN  INT64   Delta,
   IN  BOOLEAN DynamicLinking
   )
 {
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 0/2] Avoid Emulator Segmentation fault

2022-02-21 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

Correct the logic to handle the case that XServer not present to avoid
Segmentation fault

Guomin Jiang (2):
  MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
  EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

 EmulatorPkg/EmuGopDxe/GopScreen.c |  9 +
 .../Console/GraphicsConsoleDxe/GraphicsConsole.c  | 15 ++-
 2 files changed, 7 insertions(+), 17 deletions(-)

-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

2022-02-21 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

WindowOpen will fail in some case. for example, without XServer.

Shouldn't set ModeInfo in this case to avoid the caller use it
incorrectly

Cc: Andrew Fish 
Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 EmulatorPkg/EmuGopDxe/GopScreen.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c 
b/EmulatorPkg/EmuGopDxe/GopScreen.c
index 41f748bc6402..ec5ef795d6e5 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -108,10 +108,6 @@ EmuGopSetMode (
   }
 
   ModeData = 
&Private->ModeData[ModeNumber];
-  This->Mode->Mode = ModeNumber;
-  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
-  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
-  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
 
   if (Private->HardwareNeedsStarting) {
 Status = EmuGopStartWindow (
@@ -128,6 +124,11 @@ EmuGopSetMode (
 Private->HardwareNeedsStarting = FALSE;
   }
 
+  This->Mode->Mode = ModeNumber;
+  Private->GraphicsOutput.Mode->Info->HorizontalResolution = 
ModeData->HorizontalResolution;
+  Private->GraphicsOutput.Mode->Info->VerticalResolution   = 
ModeData->VerticalResolution;
+  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= 
ModeData->HorizontalResolution;
+
   Status = Private->EmuGraphicsWindow->Size (
  Private->EmuGraphicsWindow,
  ModeData->HorizontalResolution,
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error

2022-02-21 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.

If we don't handle it, it will Segmentation fault.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Zhichao Gao 
Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 .../Console/GraphicsConsoleDxe/GraphicsConsole.c  | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c 
b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 1bdd1b8a6732..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
@@ -1,7 +1,7 @@
 /** @file
   This is the main routine for initializing the Graphics Console support 
routines.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
   }
 }
 
-if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+if (EFI_ERROR (Status) || (ModeNumber != 
Private->GraphicsOutput->Mode->Mode)) {
   //
   // Current graphics mode is not set or is not set to the mode which we 
have found,
   // set the new graphic mode.
@@ -531,17 +531,6 @@ GraphicsConsoleControllerDriverStart (
 goto Error;
   }
 }
-
-//
-// Double confirm SetMode can success
-//
-Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, 
ModeNumber);
-if (EFI_ERROR (Status)) {
-  //
-  // The mode set operation failed
-  //
-  goto Error;
-}
   } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
 //
 // At first try to set user-defined resolution
-- 
2.35.1.windows.2



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




Re: [edk2-devel] [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully

2022-02-23 Thread Guomin Jiang
Hi Fish and Ray,

Can you help review it?

Thanks
Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guomin
> Jiang
> Sent: Tuesday, February 22, 2022 11:41 AM
> To: devel@edk2.groups.io
> Cc: Andrew Fish ; Ni, Ray 
> Subject: [edk2-devel] [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo
> after Open successfully
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
> 
> WindowOpen will fail in some case. for example, without XServer.
> 
> Shouldn't set ModeInfo in this case to avoid the caller use it incorrectly
> 
> Cc: Andrew Fish 
> Cc: Ray Ni 
> Signed-off-by: Guomin Jiang 
> ---
>  EmulatorPkg/EmuGopDxe/GopScreen.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c
> b/EmulatorPkg/EmuGopDxe/GopScreen.c
> index 41f748bc6402..ec5ef795d6e5 100644
> --- a/EmulatorPkg/EmuGopDxe/GopScreen.c
> +++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
> @@ -108,10 +108,6 @@ EmuGopSetMode (
>}
> 
>ModeData = 
> &Private->ModeData[ModeNumber];
> -  This->Mode->Mode = ModeNumber;
> -  Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData-
> >HorizontalResolution;
> -  Private->GraphicsOutput.Mode->Info->VerticalResolution   = ModeData-
> >VerticalResolution;
> -  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= ModeData-
> >HorizontalResolution;
> 
>if (Private->HardwareNeedsStarting) {
>  Status = EmuGopStartWindow (
> @@ -128,6 +124,11 @@ EmuGopSetMode (
>  Private->HardwareNeedsStarting = FALSE;
>}
> 
> +  This->Mode->Mode = ModeNumber;
> +  Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData-
> >HorizontalResolution;
> +  Private->GraphicsOutput.Mode->Info->VerticalResolution   = ModeData-
> >VerticalResolution;
> +  Private->GraphicsOutput.Mode->Info->PixelsPerScanLine= ModeData-
> >HorizontalResolution;
> +
>Status = Private->EmuGraphicsWindow->Size (
>   Private->EmuGraphicsWindow,
>   ModeData->HorizontalResolution,
> --
> 2.35.1.windows.2
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error

2022-02-23 Thread Guomin Jiang
Hi Liming, Jian, Zhichao, Ray,

Can you help review it?

Thanks
Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guomin
> Jiang
> Sent: Tuesday, February 22, 2022 11:41 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Gao, Liming
> ; Gao, Zhichao ; Ni,
> Ray 
> Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe:
> Check status to make sure no error
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668
> 
> SetMode will fail in some case. for example, without XServer.
> Should handle these case when SetMode fail.
> 
> If we don't handle it, it will Segmentation fault.
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Zhichao Gao 
> Cc: Ray Ni 
> Signed-off-by: Guomin Jiang 
> ---
>  .../Console/GraphicsConsoleDxe/GraphicsConsole.c  | 15 ++-
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole
> .c
> b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsol
> e.c
> index 1bdd1b8a6732..07436cbd15bf 100644
> ---
> a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole
> .c
> +++
> b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsol
> e.c
> @@ -1,7 +1,7 @@
>  /** @file
>This is the main routine for initializing the Graphics Console support 
> routines.
> 
> -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
>}
>  }
> 
> -if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
> +if (EFI_ERROR (Status) || (ModeNumber != Private->GraphicsOutput-
> >Mode->Mode)) {
>//
>// Current graphics mode is not set or is not set to the mode which we
> have found,
>// set the new graphic mode.
> @@ -531,17 +531,6 @@ GraphicsConsoleControllerDriverStart (
>  goto Error;
>}
>  }
> -
> -//
> -// Double confirm SetMode can success
> -//
> -Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput,
> ModeNumber);
> -if (EFI_ERROR (Status)) {
> -  //
> -  // The mode set operation failed
> -  //
> -  goto Error;
> -}
>} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
>  //
>  // At first try to set user-defined resolution
> --
> 2.35.1.windows.2
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH 2/2] MdePkg/Include: Define new DEBUG_FILE to specify path.

2022-02-23 Thread Guomin Jiang
Hi Kinney, Liming, Zhiguang,

Can you give comments on this patch

Thanks
Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guomin
> Jiang
> Sent: Friday, February 18, 2022 10:30 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D ; Gao, Liming
> ; Liu, Zhiguang 
> Subject: [edk2-devel] [PATCH 2/2] MdePkg/Include: Define new
> DEBUG_FILE to specify path.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> 
> Use DEBUG_FILE to control ASSERT path
> 
> Motivation and Goal:
> 1. The path will occupy many size in DEBUG build when file path is long 2. We
> hope can reduce the size but not impact the debug capability 3. If only use
> filename, we can search the filename to locate file. It
>can save many size meanwhile.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Signed-off-by: Guomin Jiang 
> ---
>  MdePkg/Include/Library/DebugLib.h | 39 ++---
> --
>  1 file changed, 28 insertions(+), 11 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/DebugLib.h
> b/MdePkg/Include/Library/DebugLib.h
> index 8d3d08638d73..5469c6308422 100644
> --- a/MdePkg/Include/Library/DebugLib.h
> +++ b/MdePkg/Include/Library/DebugLib.h
> @@ -8,7 +8,7 @@
>of size reduction when compiler optimization is disabled. If
> MDEPKG_NDEBUG is
>defined, then debug and assert related macros wrapped by it are the NULL
> implementations.
> 
> -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -85,6 +85,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent  #define
> DEBUG_LINE_NUMBER  __LINE__  #endif
> 
> +//
> +// Source file.
> +// Default is use the to compiler provided __FILE__ macro value. The
> +__FILE__ // mapping can be overriden by predefining DEBUG_FILE // //
> +Defining DEBUG_FILE to a fixed value is useful when comparing builds //
> +across machine or configuration with different slash or path // file.
> +//
> +// Another benefit is we can customize the ASSERT path without
> +depending on // compiler ability // // It's for all no matter VS, GCC,
> +CLANG // #ifdef DEBUG_FILE #else #define DEBUG_FILE  __FILE__ #endif
> +
> +// Blow override for keep clang behavior #if defined (__clang__) &&
> +defined (__FILE_NAME__) #undef DEBUG_FILE #define DEBUG_FILE
> +__FILE_NAME__ #endif
> +
>  /**
>Macro that converts a Boolean expression to a Null-terminated ASCII string.
> 
> @@ -337,17 +362,9 @@ UnitTestDebugAssert (
>IN CONST CHAR8  *Description
>);
> 
> -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #else
> -#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #endif
> +#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE,
> +DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
>  #else
> -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> _ASSERT(Expression)  DebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #else
> -#define _ASSERT(Expression)  DebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #endif
> +#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE,
> +DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
>  #endif
> 
>  /**
> --
> 2.35.1.windows.2
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the binary size

2022-02-28 Thread Guomin Jiang
Hi Bob,

Have and the review link to the Bugzilla.

Thanks

> -Original Message-
> From: Feng, Bob C 
> Sent: Monday, February 28, 2022 5:52 PM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: Gao, Liming ; Chen, Christine
> 
> Subject: RE: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save
> the binary size
> 
> Hi Guomin,
> 
> I think this patch should work.
> I concern the case that there would be already DEBUG_FILE macro defined in
> some existing platform.
> 
> Could you add the 2 patches' review link to the Bugzilla?
> 
> And I'd like to see the other associated patch review comments also.
> 
> Thanks,
> Bob
> 
> -Original Message-
> From: Jiang, Guomin 
> Sent: Friday, February 18, 2022 10:30 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C ; Gao, Liming
> ; Chen, Christine 
> Subject: [PATCH 1/2] BaseTools/Conf: Reduce the ASSERT patch to save the
> binary size
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> 
> Use DEBUG_FILE to control ASSERT path
> 
> Motivation and Goal:
> 1. The path will occupy many size in DEBUG build when file path is long 2. We
> hope can reduce the size but not impact the debug capability 3. If only use
> filename, we can search the filename to locate file. It
>can save many size meanwhile.
> 
> Cc: Bob Feng 
> Cc: Liming Gao 
> Cc: Yuwei Chen 
> Signed-off-by: Guomin Jiang 
> ---
>  BaseTools/Conf/build_rule.template | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/BaseTools/Conf/build_rule.template
> b/BaseTools/Conf/build_rule.template
> index f40118234471..ad0bae42be62 100755
> --- a/BaseTools/Conf/build_rule.template
> +++ b/BaseTools/Conf/build_rule.template
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2007 - 2022, Intel Corporation. All rights
> +reserved.
>  #  Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.  #
> Copyright (c) 2020, ARM Ltd. All rights reserved.  #  SPDX-License-
> Identifier: BSD-2-Clause-Patent @@ -126,14 +126,14 @@
>  $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
> 
>  
> -"$(CC)" /Fo${dst} $(DEPS_FLAGS) $(CC_FLAGS) $(INC) ${src}
> +"$(CC)" /Fo${dst} $(DEPS_FLAGS) /D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) $(INC) ${src}
> 
>  
>  # For RVCTCYGWIN CC_FLAGS must be first to work around pathing
> issues
> -"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
> +"$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
> 
>  
> -"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) -o ${dst} $(INC) ${src}
> +"$(CC)" $(DEPS_FLAGS) -D DEBUG_FILE="\"${s_base}.c\""
> + $(CC_FLAGS) -o ${dst} $(INC) ${src}
> 
>  [C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-
> File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-
> File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-
> File.PEIM.ARM]
>  
> @@ -146,7 +146,7 @@
>  $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
> 
>  
> -"$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
> +"$(CC)" -D DEBUG_FILE="\"${s_base}.c\"" $(CC_FLAGS)
> + $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
> 
>  [C-Header-File]
>  
> --
> 2.35.1.windows.2



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




Re: [edk2-devel] [PATCH v6 0/4] AMD processor MSR_IA32_MISC_ENABLE

2020-07-07 Thread Guomin Jiang
Thanks all of you that response my confusion.

Both of you are so kindly.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Laszlo
> Ersek
> Sent: Wednesday, July 8, 2020 7:32 AM
> To: Dong, Eric ; Ni, Ray ; Wu, Hao
> A 
> Cc: devel@edk2.groups.io; Kirkendall, Garrett
> ; Jiang, Guomin 
> Subject: Re: [edk2-devel] [PATCH v6 0/4] AMD processor
> MSR_IA32_MISC_ENABLE
> 
> Hi Eric,
> 
> On 07/07/20 04:38, Dong, Eric wrote:
> > Hi Laszlo,
> >
> > I have fixed the issue reported by Guomin in below change.
> >
> > SHA-1: 0060e0a694f3f249c3ec081b0e61287c36f64ebb
> >
> > * IntelFsp2Pkg/FspSecCore: Use UefiCpuLib.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2825
> 
> Thank you very much for filing and fixing that BZ!
> 
> Thank you all for granting the necessary feedback tags, as well.
> 
> Series merged as commit range 627d1d6693b0..bdafda8c457e, via
> .
> 
> Thanks,
> Laszlo
> 
> 
> 


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

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



[edk2-devel] [PATCH v3 07/11] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
From: Michael Kubacki 

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

Adds a PEIM that republishes structures produced in SEC. This
is done because SEC modules may not be shadowed in some platforms
due to space constraints or special alignment requirements. The
SecMigrationPei module locates interfaces that may be published in
SEC and reinstalls the interface with permanent memory addresses.

This is important if pre-memory address access is forbidden after
memory initialization and data such as a PPI descriptor, PPI GUID,
or PPI inteface reside in pre-memory.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
---
 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 154 +++
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 378 ++
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 10 files changed, 698 insertions(+), 2 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 762badf5d239..0a005bd20311 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -66,6 +66,10 @@ [Guids]
   ## Include/Guid/MicrocodePatchHob.h
   gEdkiiMicrocodePatchHobGuid= { 0xd178f11d, 0x8716, 0x418e, { 0xa1, 0x31, 
0x96, 0x7d, 0x2a, 0xc4, 0x28, 0x43 }}
 
+[Ppis]
+  ## Include/Ppi/RepublishSecPpi.h
+  gRepublishSecPpiPpiGuid   = { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 
0x52, 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }}
+
 [Protocols]
   ## Include/Protocol/SmmCpuService.h
   gEfiSmmCpuServiceProtocolGuid  = { 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 
0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 }}
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index afa304128221..964720048dd7 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -146,6 +146,7 @@ [Components.IA32, Components.X64]
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
   UefiCpuPkg/SecCore/SecCore.inf
+  UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index 0562820c95e0..545781d6b4b3 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -68,6 +68,8 @@ [Ppis]
   ## SOMETIMES_CONSUMES
   gPeiSecPerformancePpiGuid
   gEfiPeiCoreFvLocationPpiGuid
+  ## CONSUMES
+  gRepublishSecPpiPpiGuid
 
 [Guids]
   ## SOMETIMES_PRODUCES   ## HOB
diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf 
b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
new file mode 100644
index ..f4c2f6b658fb
--- /dev/null
+++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
@@ -0,0 +1,67 @@
+## @file
+#  Migrates SEC structures after permanent memory is installed.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SecMigrationPei
+  MODULE_UNI_FILE= SecMigrationPei.uni
+  FILE_GUID  = 58B35361-8922-41BC-B313-EF7ED9ADFDF7
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  ENTRY_POINT= SecMigrationPeiInitialize
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  SecMigrationPei.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  HobLib
+  MemoryAllocationLib
+  PeimEntryPoint
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  ## PRODUCES
+  gRepublishSecPpiPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gEfiTemporaryRamDonePpiGuid
+
+  ## SOMETIME_PRODUCES
+  gEfiTemporaryRamSupportPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gPeiSecPerformancePpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## PRODUCES
+  gEfiSecPlatformInformationPpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## SOMETIMES_PRODUCES
+  gEfiSecPlatformInformation2PpiGuid
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGui

[edk2-devel] [PATCH v3 08/11] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save the rebased PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.

The MigratedFvInfo HOB will never produce when
PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control
the total feature.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Guomin Jiang 
---
 MdeModulePkg/MdeModulePkg.dec |  3 ++
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Core/Pei/PeiMain.h   |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 22 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++
 5 files changed, 55 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 8077f3d14c6e..0ef4e964e2c2 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -389,6 +389,9 @@ [Guids]
   ## GUID indicates the capsule is to store Capsule On Disk file names.
   gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x9a, 
0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
 
+  ## Include/Guid/MigratedFvInfo.h
+  gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 
0xce, 0xfd, 0x17, 0x98, 0x71 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 5b36d516b3fa..0cf357371a16 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -77,6 +77,7 @@ [Guids]
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
   gStatusCodeCallbackGuid
+  gEdkiiMigratedFvInfoGuid  ## SOMETIMES_PRODUCES ## 
HOB
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index b0101dba5e30..cbf74d5b9d9a 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 ///
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h 
b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
new file mode 100644
index ..061c17ed0e48
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
@@ -0,0 +1,22 @@
+/** @file
+  Migrated FV information
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+#define __EDKII_MIGRATED_FV_INFO_GUID_H__
+
+typedef struct {
+  UINT32   FvOrgBase;  // original FV address
+  UINT32   FvNewBase;  // new FV address
+  UINT32   FvDataBase; // original FV data
+  UINT32   FvLength;   // Fv Length
+} EDKII_MIGRATED_FV_INFO;
+
+extern EFI_GUID gEdkiiMigratedFvInfoGuid;
+
+#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index ef88b3423376..f654cea15c59 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1223,10 +1223,12 @@ EvacuateTempRam (
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*ChildFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedFvHeader;
+  EFI_FIRMWARE_VOLUME_HEADER*RawDataFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedChildFvHeader;
 
   PEI_CORE_FV_HANDLEPeiCoreFvHandle;
   EFI_PEI_CORE_FV_LOCATION_PPI  *PeiCoreFvLocationPpi;
+  EDKII_MIGRATED_FV_INFOMigratedFvInfo;
 
   ASSERT (Private->PeiMemoryInstalled);
 
@@ -1263,6 +1265,9 @@ EvacuateTempRam (
 (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1)) < 
Private->FreePhysicalMemoryTop)
 )
   ) {
+  //
+  // Allocate page to save the rebased PEIMs, the PEIMs will get control 
later
+  //
   Status =  PeiServicesAllocatePages (
   EfiBootServicesCode,
   EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength),
@@ -1270,6 +1275,17 @@ EvacuateTempRam (
   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Allocate pool to save the raw PEIMs, it used to keep consistent 
context across
+  // multiple boot and PCR0 will keep same no matter if

[edk2-devel] [PATCH v3 04/11] OvmfPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes

2020-07-07 Thread Guomin Jiang
The evacuate temporary memory is for physical platform and unnecessary
for virtual platform temporarily.

Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Signed-off-by: Guomin Jiang 
---
 OvmfPkg/OvmfPkgIa32.dsc| 2 ++
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
 OvmfPkg/OvmfPkgX64.dsc | 2 ++
 OvmfPkg/OvmfXen.dsc| 2 ++
 4 files changed, 8 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index b4ee7376791b..aa2209568efc 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -559,6 +559,8 @@ [PcdsFixedAtBuild]
   # Point to the MdeModulePkg/Application/UiApp/UiApp.inf
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 

 #
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index ed68b080f2a2..218b2d2da3b1 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -536,6 +536,8 @@ [PcdsFixedAtBuild]
   gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
 !endif
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 [PcdsFixedAtBuild.IA32]
   #
   # The NumberOfPages values below are ad-hoc. They are updated sporadically at
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index cb7e8068a3d8..01a43cb734cd 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -563,6 +563,8 @@ [PcdsFixedAtBuild]
   # Point to the MdeModulePkg/Application/UiApp/UiApp.inf
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 

 #
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 782803cb2787..7ea7a34bd5a8 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -433,6 +433,8 @@ [PcdsFixedAtBuild]
   ## Xen vlapic's frequence is 100 MHz
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 

 #
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 11/11] UefiCpuPkg: Correct some typos.

2020-07-07 Thread Guomin Jiang
Correct some typos.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 UefiCpuPkg/CpuMpPei/CpuPaging.c   | 4 ++--
 .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c| 4 ++--
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 783bdacc7fb9..4987c87cb577 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -153,7 +153,7 @@ GetPhysicalAddressWidth (
   Get the type of top level page table.
 
   @retval Page512G  PML4 paging.
-  @retval Page1GPAE paing.
+  @retval Page1GPAE paging.
 
 **/
 PAGE_ATTRIBUTE
@@ -583,7 +583,7 @@ SetupStackGuardPage (
 }
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index 1aafb7dac139..903449e0daa9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -18,8 +18,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
+  IN  UINTN   InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
index 20148db74cf8..d4ae153c5742 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
@@ -87,7 +87,7 @@ InitializeCpuExceptionHandlers (
   IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof 
(IA32_IDT_GATE_DESCRIPTOR);
   if (IdtEntryCount > CPU_EXCEPTION_NUM) {
 //
-// CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at 
most
+// CPU exception library only setup CPU_EXCEPTION_NUM exception handler at 
most
 //
 IdtEntryCount = CPU_EXCEPTION_NUM;
   }
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 05/11] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
From: Michael Kubacki 

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

Introduces new changes to PeiCore to move the contents of temporary
RAM visible to the PeiCore to permanent memory. This expands on
pre-existing shadowing support in the PeiCore to perform the following
additional actions:

 1. Migrate pointers in PPIs installed in PeiCore to the permanent
memory copy of PeiCore.

 2. Copy all installed firmware volumes to permanent memory.

 3. Relocate and fix up the PEIMs within the firmware volumes.

 4. Convert all PPIs into the migrated firmware volume to the corresponding
PPI address in the permanent memory location.

This applies to PPIs and PEI notifications.

 5. Convert all status code callbacks in the migrated firmware volume to
the corresponding address in the permanent memory location.

 6. Update the FV HOB to the corresponding firmware volume in permanent
memory.

 7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the
feature or not. when the PCD disable, the EvacuateTempRam() will
never be called.

The function control flow as below:
  PeiCore()
DumpPpiList()
EvacuateTempRam()
  ConvertPeiCorePpiPointers()
ConvertPpiPointersFv()
  MigratePeimsInFv()
MigratePeim()
  PeiGetPe32Data()
  LoadAndRelocatePeCoffImageInPlace()
  MigrateSecModulesInFv()
  ConvertPpiPointersFv()
  ConvertStatusCodeCallbacks()
  ConvertFvHob()
  RemoveFvHobsInTemporaryMemory()
DumpPpiList()

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Core/Pei/PeiMain.inf |   2 +
 MdeModulePkg/Core/Pei/PeiMain.h   | 168 
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 402 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  22 +
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 +
 7 files changed, 1078 insertions(+)

diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 6e25cc40232a..5b36d516b3fa 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -76,6 +76,7 @@ [Guids]
   ## CONSUMES   ## UNDEFINED # Locate PPI
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
+  gStatusCodeCallbackGuid
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
@@ -109,6 +110,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 # [BootMode]
 # S3_RESUME ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 56b3bd85793d..b0101dba5e30 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -394,6 +394,41 @@ PeimDispatchReadiness (
   IN VOID   *DependencyExpression
   );
 
+/**
+  Migrate a PEIM from Temporary RAM to permanent memory.
+
+  @param PeimFileHandle   Pointer to the FFS file header of the image.
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated 
image.
+
+  @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent 
memory.
+
+**/
+EFI_STATUS
+EFIAPI
+MigratePeim (
+  IN  EFI_PEI_FILE_HANDLE FileHandle,
+  IN  EFI_PEI_FILE_HANDLE MigratedFileHandle
+  );
+
+/**
+  Migrate FVs out of Temporary RAM before the cache is flushed.
+
+  @param Private PeiCore's private data structure
+  @param SecCoreData Points to a data structure containing information 
about the PEI core's operating
+ environment, such as the size and location of 
temporary RAM, the stack location and
+ the BFV location.
+
+  @retval EFI_SUCCESS   Succesfully migrated installed FVs from 
Temporary RAM to permanent memory.
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed 
pages.
+
+**/
+EFI_STATUS
+EFIAPI
+EvacuateTempRam (
+  IN PEI_CORE_INSTANCE*Private,
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData
+  );
+
 /**
   Conduct PEIM dispatch.
 
@@ -477,6 +512,50 @@ ConvertPpiPointers (
   IN PEI_CORE_INSTANCE   *PrivateData
   );
 
+/**
+
+  Migrate Notify Pointers inside an FV from temporary memory to permanent 
memory.
+
+  @param PrivateData  Pointer to PeiCore's private data structure.
+  @param OrgFvHandle  A

[edk2-devel] [PATCH v3 10/11] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

To avoid the TOCTOU, enable paging and set Not Present flag so when
access any code in the flash range, it will trigger #NP exception.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  3 +++
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 21 +++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index f4d11b861f77..7e511325d8b8 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -46,6 +46,9 @@ [LibraryClasses]
   BaseMemoryLib
   CpuLib
 
+[Guids]
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
+
 [Ppis]
   gEfiPeiMpServicesPpiGuid  ## PRODUCES
   gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 3bf0574b34c6..783bdacc7fb9 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include "CpuMpPei.h"
 
@@ -605,6 +606,8 @@ MemoryDiscoveredPpiNotifyCallback (
   EFI_STATUS  Status;
   BOOLEAN InitStackGuard;
   BOOLEAN InterruptState;
+  EDKII_MIGRATED_FV_INFO *MigratedFvInfo;
+  EFI_PEI_HOB_POINTERS   Hob;
 
   if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
 InterruptState = SaveAndDisableInterrupts ();
@@ -619,9 +622,14 @@ MemoryDiscoveredPpiNotifyCallback (
   // the task switch (for the sake of stack switch).
   //
   InitStackGuard = FALSE;
-  if (IsIa32PaeSupported () && PcdGetBool (PcdCpuStackGuard)) {
+  Hob.Raw = NULL;
+  if (IsIa32PaeSupported ()) {
+Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+InitStackGuard = PcdGetBool (PcdCpuStackGuard);
+  }
+
+  if (InitStackGuard || Hob.Raw != NULL) {
 EnablePaging ();
-InitStackGuard = TRUE;
   }
 
   Status = InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices);
@@ -631,6 +639,15 @@ MemoryDiscoveredPpiNotifyCallback (
 SetupStackGuardPage ();
   }
 
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+ConvertMemoryPageAttributes (MigratedFvInfo->FvOrgBase, 
MigratedFvInfo->FvLength, 0);
+
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+  CpuFlushTlb ();
+
   return Status;
 }
 
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 09/11] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save rebased the PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.
The Tcg2Pei calculate the hash and it use the Migrated FV Info.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf |  1 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c   | 31 ++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
index 3d361e8859e7..367df21eedaf 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
@@ -63,6 +63,7 @@ [Guids]
   gTcgEvent2EntryHobGuid   ## 
PRODUCES   ## HOB
   gEfiTpmDeviceInstanceNoneGuid## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
   gEfiTpmDeviceInstanceTpm12Guid   ## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
   gEfiPeiFirmwareVolumeInfoPpiGuid ## 
SOMETIMES_CONSUMES ## NOTIFY
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 4852d8690617..651a60c1f0e2 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -536,6 +537,10 @@ MeasureFvImage (
   EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI   *PrehashedFvPpi;
   HASH_INFO *PreHashInfo;
   UINT32HashAlgoMask;
+  EFI_PHYSICAL_ADDRESS  FvOrgBase;
+  EFI_PHYSICAL_ADDRESS  FvDataBase;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATED_FV_INFO*MigratedFvInfo;
 
   //
   // Check Excluded FV list
@@ -621,6 +626,26 @@ MeasureFvImage (
 Instance++;
   } while (!EFI_ERROR(Status));
 
+  //
+  // Search the matched migration FV info
+  //
+  FvOrgBase  = FvBase;
+  FvDataBase = FvBase;
+  Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && 
(MigratedFvInfo->FvLength == (UINT32) FvLength)) {
+  //
+  // Found the migrated FV info
+  //
+  FvOrgBase  = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgBase;
+  FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvDataBase;
+  break;
+}
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+
   //
   // Init the log event for FV measurement
   //
@@ -631,13 +656,13 @@ MeasureFvImage (
 if (FvName != NULL) {
   AsciiSPrint ((CHAR8 *)FvBlob2.BlobDescription, 
sizeof(FvBlob2.BlobDescription), "Fv(%g)", FvName);
 }
-FvBlob2.BlobBase  = FvBase;
+FvBlob2.BlobBase  = FvOrgBase;
 FvBlob2.BlobLength= FvLength;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB2;
 TcgEventHdr.EventSize = sizeof (FvBlob2);
 EventData = &FvBlob2;
   } else {
-FvBlob.BlobBase   = FvBase;
+FvBlob.BlobBase   = FvOrgBase;
 FvBlob.BlobLength = FvLength;
 TcgEventHdr.PCRIndex  = 0;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB;
@@ -672,7 +697,7 @@ MeasureFvImage (
 //
 Status = HashLogExtendEvent (
0,
-   (UINT8*) (UINTN) FvBase, // HashData
+   (UINT8*) (UINTN) FvDataBase, // HashData
(UINTN) FvLength,// HashDataLen
&TcgEventHdr,// EventHdr
EventData// EventData
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 00/11] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
The TOCTOU vulnerability allow that the physical present person to replace the 
code with the normal BootGuard check and PCR0 value.
The issue occur when BootGuard measure IBB and access flash code after NEM 
disable.
the reason why we access the flash code is that we have some pointer to flash.
To avoid this vulnerability, we need to convert those pointers, the patch 
series do this work and make sure that no code will access flash address.

v2:
Create gEdkiiMigratedFvInfoGuid HOB and add 
PcdMigrateTemporaryRamFirmwareVolumes to control whole feature.

v3:
Remove changes which is not related with the feature and disable the feature in 
virtual platform.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Rahul Kumar 
Cc: Jiewen Yao 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Micheal Kubacki 
Guomin Jiang (8):
  MdeModulePkg: Add new PCD to control the evacuate temporary memory
feature (CVE-2019-11098)
  ArmVirtPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes
  EmulatorPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes
  OvmfPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes
  MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU
(CVE-2019-11098)
  UefiCpuPkg: Correct some typos.

Michael Kubacki (3):
  MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support
(CVE-2019-11098)
  UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

 MdeModulePkg/MdeModulePkg.dec |   8 +
 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 ArmVirtPkg/ArmVirt.dsc.inc|   2 +
 EmulatorPkg/EmulatorPkg.dsc   |   2 +
 OvmfPkg/OvmfPkgIa32.dsc   |   2 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 +
 OvmfPkg/OvmfPkgX64.dsc|   2 +
 OvmfPkg/OvmfXen.dsc   |   2 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 MdeModulePkg/Core/Pei/PeiMain.inf |   3 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf  |   4 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
 MdeModulePkg/Core/Pei/PeiMain.h   | 169 +++
 MdeModulePkg/Include/Guid/MigratedFvInfo.h|  22 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h|  12 +
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 154 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 430 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  22 +
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  31 +-
 UefiCpuPkg/CpuMpPei/CpuMpPei.c|  37 ++
 UefiCpuPkg/CpuMpPei/CpuPaging.c   |  37 +-
 .../Ia32/ArchExceptionHandler.c   |   4 +-
 .../SecPeiCpuException.c  |   2 +-
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 378 +++
 MdeModulePkg/MdeModulePkg.uni |   6 +
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 34 files changed, 1970 insertions(+), 14 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 02/11] ArmVirtPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes

2020-07-07 Thread Guomin Jiang
The evacuate temporary memory feature is for physical platform and
unnecessary for virtual platform temporarily.

Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Signed-off-by: Guomin Jiang 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index cf44fc73890b..d6f917b5ae22 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -364,6 +364,8 @@ [PcdsFixedAtBuild.common]
   #
   
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC0007FD1
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 [Components.common]
   #
   # Ramdisk support
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 01/11] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

The security researcher found that we can get control after NEM disable.

The reason is that the flash content reside in NEM at startup and the
code will get the content from flash directly after disable NEM.

To avoid this vulnerability, the feature will copy the PEIMs from
temporary memory to permanent memory and only execute the code in
permanent memory.

The vulnerability is exist in physical platform and haven't report in
virtual platform, so the virtual can disable the feature currently.

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Guomin Jiang 
---
 MdeModulePkg/MdeModulePkg.dec | 5 +
 MdeModulePkg/MdeModulePkg.uni | 6 ++
 2 files changed, 11 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 843e963ad34b..8077f3d14c6e 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1220,6 +1220,11 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # @Prompt Shadow Peim and PeiCore on boot
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
 
+  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
+  # TRUE - Evacuate temporary memory, the actions include copy memory, convert 
PPI pointers and so on.
+  # FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|TRUE|BOOLEAN|0x3000102A
+
   ## The mask is used to control memory profile behavior.
   #  BIT0 - Enable UEFI memory profile.
   #  BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2007e0596c4f..5235dee561ad 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -214,6 +214,12 @@

"TRUE  - Shadow PEIM on S3 boot path after memory is ready.\n"

"FALSE - Not shadow PEIM on S3 boot path after memory is ready."
 
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_HELP 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not.\n"
+   
   "It will allocate page to save the temporary PEIMs 
resided in NEM(or CAR) to the permanent memory and change all pointers pointed 
to the NEM(or CAR) to permanent memory.\n"
+   
   "After then, there are no pointer pointed to NEM(or CAR) 
and TOCTOU volnerability can be avoid.\n"
+
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_PROMPT 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not"
+
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT  
#language en-US "Default OEM ID for ACPI table creation"
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP  #language 
en-US "Default OEM ID for ACPI table creation, its length must be 0x6 bytes to 
follow ACPI specification."
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 06/11] UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support (CVE-2019-11098)

2020-07-07 Thread Guomin Jiang
From: Michael Kubacki 

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

Moves the GDT and IDT to permanent memory in a memory discovered
callback. This is done to ensure the GDT and IDT authenticated in
pre-memory is not fetched from outside a verified location after
the permanent memory transition.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 12 +++
 UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 37 
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 12 +--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index caead3ce34d4..f4d11b861f77 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -63,6 +63,7 @@ [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList  ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize   ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 7d5c527d6006..309478cbe14c 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -397,6 +397,18 @@ SecPlatformInformation2 (
  OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
   );
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  );
+
 /**
   Initializes MP and exceptions handlers.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 07ccbe7c6a91..d07540cf7471 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -429,6 +429,43 @@ GetGdtr (
   AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer);
 }
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   GdtBufferSize;
+  IA32_DESCRIPTOR Gdtr;
+  VOID*GdtBuffer;
+
+  AsmReadGdtr ((IA32_DESCRIPTOR *) &Gdtr);
+  GdtBufferSize = sizeof (IA32_SEGMENT_DESCRIPTOR) -1 + Gdtr.Limit + 1;
+
+  Status =  PeiServicesAllocatePool (
+  GdtBufferSize,
+  &GdtBuffer
+  );
+  ASSERT (GdtBuffer != NULL);
+  if (EFI_ERROR (Status)) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  GdtBuffer = ALIGN_POINTER (GdtBuffer, sizeof (IA32_SEGMENT_DESCRIPTOR));
+  CopyMem (GdtBuffer, (VOID *) Gdtr.Base, Gdtr.Limit + 1);
+  Gdtr.Base = (UINTN) GdtBuffer;
+  AsmWriteGdtr (&Gdtr);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Initializes CPU exceptions handlers for the sake of stack switch requirement.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index a462e7ee1e38..3bf0574b34c6 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -602,8 +602,16 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   )
 {
-  EFI_STATUS  Status;
-  BOOLEAN InitStackGuard;
+  EFI_STATUS  Status;
+  BOOLEAN InitStackGuard;
+  BOOLEAN InterruptState;
+
+  if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
+InterruptState = SaveAndDisableInterrupts ();
+Status = MigrateGdt ();
+ASSERT_EFI_ERROR (Status);
+SetInterruptState (InterruptState);
+  }
 
   //
   // Paging must be setup first. Otherwise the exception TSS setup during MP
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v3 03/11] EmulatorPkg: Disable PcdMigrateTemporaryRamFirmwareVolumes

2020-07-07 Thread Guomin Jiang
The evacuate temporary memory is for physical platform and unnecessary
for virtual platform temporarily.

Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Ray Ni 
Signed-off-by: Guomin Jiang 
---
 EmulatorPkg/EmulatorPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 86a62717353b..791123ad1e74 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -225,6 +225,8 @@ [PcdsFixedAtBuild]
   #  0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE
+
 [PcdsDynamicDefault.common.DEFAULT]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 0/9] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
The TOCTOU vulnerability allow that the physical present person to replace the 
code with the normal BootGuard check and PCR0 value.
The issue occur when BootGuard measure IBB and access flash code after NEM 
disable.
the reason why we access the flash code is that we have some pointer to flash.
To avoid this vulnerability, we need to convert those pointers, the patch 
series do this work and make sure that no code will access flash address.

v2:
Create gEdkiiMigratedFvInfoGuid HOB and add 
PcdMigrateTemporaryRamFirmwareVolumes to control whole feature.

v3:
Remove changes which is not related with the feature and disable the feature in 
virtual platform.

v4:
Disable the feature as default, Copy the Tcg2Pei behavior to TcgPei

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Rahul Kumar 
Cc: Jiewen Yao 
Cc: Chao Zhang 
Cc: Qi Zhang 

Guomin Jiang (6):
  MdeModulePkg: Add new PCD to control the evacuate temporary memory
feature (CVE-2019-11098)
  MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU
(CVE-2019-11098)
  UefiCpuPkg: Correct some typos.
  SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)

Michael Kubacki (3):
  MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support
(CVE-2019-11098)
  UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

 MdeModulePkg/MdeModulePkg.dec |  10 +
 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 MdeModulePkg/Core/Pei/PeiMain.inf |   3 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   1 +
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf  |   4 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
 MdeModulePkg/Core/Pei/PeiMain.h   | 169 +++
 MdeModulePkg/Include/Guid/MigratedFvInfo.h|  22 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h|  12 +
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 154 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 430 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  22 +
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  31 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  29 +-
 UefiCpuPkg/CpuMpPei/CpuMpPei.c|  37 ++
 UefiCpuPkg/CpuMpPei/CpuPaging.c   |  42 +-
 .../Ia32/ArchExceptionHandler.c   |   4 +-
 .../SecPeiCpuException.c  |   2 +-
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 378 +++
 MdeModulePkg/MdeModulePkg.uni |   6 +
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 30 files changed, 1993 insertions(+), 16 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 2/9] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
From: Michael Kubacki 

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

Introduces new changes to PeiCore to move the contents of temporary
RAM visible to the PeiCore to permanent memory. This expands on
pre-existing shadowing support in the PeiCore to perform the following
additional actions:

 1. Migrate pointers in PPIs installed in PeiCore to the permanent
memory copy of PeiCore.

 2. Copy all installed firmware volumes to permanent memory.

 3. Relocate and fix up the PEIMs within the firmware volumes.

 4. Convert all PPIs into the migrated firmware volume to the corresponding
PPI address in the permanent memory location.

This applies to PPIs and PEI notifications.

 5. Convert all status code callbacks in the migrated firmware volume to
the corresponding address in the permanent memory location.

 6. Update the FV HOB to the corresponding firmware volume in permanent
memory.

 7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the
feature or not. when the PCD disable, the EvacuateTempRam() will
never be called.

The function control flow as below:
  PeiCore()
DumpPpiList()
EvacuateTempRam()
  ConvertPeiCorePpiPointers()
ConvertPpiPointersFv()
  MigratePeimsInFv()
MigratePeim()
  PeiGetPe32Data()
  LoadAndRelocatePeCoffImageInPlace()
  MigrateSecModulesInFv()
  ConvertPpiPointersFv()
  ConvertStatusCodeCallbacks()
  ConvertFvHob()
  RemoveFvHobsInTemporaryMemory()
DumpPpiList()

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Core/Pei/PeiMain.inf |   2 +
 MdeModulePkg/Core/Pei/PeiMain.h   | 168 
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 402 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  22 +
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 +
 7 files changed, 1078 insertions(+)

diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 6e25cc40232a..5b36d516b3fa 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -76,6 +76,7 @@ [Guids]
   ## CONSUMES   ## UNDEFINED # Locate PPI
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
+  gStatusCodeCallbackGuid
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
@@ -109,6 +110,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 # [BootMode]
 # S3_RESUME ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 56b3bd85793d..b0101dba5e30 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -394,6 +394,41 @@ PeimDispatchReadiness (
   IN VOID   *DependencyExpression
   );
 
+/**
+  Migrate a PEIM from Temporary RAM to permanent memory.
+
+  @param PeimFileHandle   Pointer to the FFS file header of the image.
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated 
image.
+
+  @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent 
memory.
+
+**/
+EFI_STATUS
+EFIAPI
+MigratePeim (
+  IN  EFI_PEI_FILE_HANDLE FileHandle,
+  IN  EFI_PEI_FILE_HANDLE MigratedFileHandle
+  );
+
+/**
+  Migrate FVs out of Temporary RAM before the cache is flushed.
+
+  @param Private PeiCore's private data structure
+  @param SecCoreData Points to a data structure containing information 
about the PEI core's operating
+ environment, such as the size and location of 
temporary RAM, the stack location and
+ the BFV location.
+
+  @retval EFI_SUCCESS   Succesfully migrated installed FVs from 
Temporary RAM to permanent memory.
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed 
pages.
+
+**/
+EFI_STATUS
+EFIAPI
+EvacuateTempRam (
+  IN PEI_CORE_INSTANCE*Private,
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData
+  );
+
 /**
   Conduct PEIM dispatch.
 
@@ -477,6 +512,50 @@ ConvertPpiPointers (
   IN PEI_CORE_INSTANCE   *PrivateData
   );
 
+/**
+
+  Migrate Notify Pointers inside an FV from temporary memory to permanent 
memory.
+
+  @param PrivateData  Pointer to PeiCore's private data structure.
+  @param OrgFvHandle  A

[edk2-devel] [PATCH v4 9/9] SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save rebased the PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.
The TcgPei calculate the hash and it use the Migrated FV Info.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |  1 +
 SecurityPkg/Tcg/TcgPei/TcgPei.c   | 29 +++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf 
b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
index c0bff6e85e9d..6d1951f8ed65 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf
@@ -58,6 +58,7 @@ [Guids]
   gTpmErrorHobGuid## 
SOMETIMES_PRODUCES ## HOB
   gMeasuredFvHobGuid  ## 
PRODUCES   ## HOB
   gEfiTpmDeviceInstanceTpm12Guid  ## 
PRODUCES   ## GUID   # TPM device identifier
+  gEdkiiMigratedFvInfoGuid## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
   gPeiLockPhysicalPresencePpiGuid ## 
SOMETIMES_CONSUMES ## NOTIFY
diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c
index a9a808c9ecf3..9701bfe8715b 100644
--- a/SecurityPkg/Tcg/TcgPei/TcgPei.c
+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -378,6 +379,10 @@ MeasureFvImage (
   EFI_STATUSStatus;
   EFI_PLATFORM_FIRMWARE_BLOBFvBlob;
   TCG_PCR_EVENT_HDR TcgEventHdr;
+  EFI_PHYSICAL_ADDRESS  FvOrgBase;
+  EFI_PHYSICAL_ADDRESS  FvDataBase;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATED_FV_INFO*MigratedFvInfo;
 
   //
   // Check if it is in Excluded FV list
@@ -401,10 +406,30 @@ MeasureFvImage (
 }
   }
 
+  //
+  // Search the matched migration FV info
+  //
+  FvOrgBase  = FvBase;
+  FvDataBase = FvBase;
+  Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && 
(MigratedFvInfo->FvLength == (UINT32) FvLength)) {
+  //
+  // Found the migrated FV info
+  //
+  FvOrgBase  = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgBase;
+  FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvDataBase;
+  break;
+}
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+
   //
   // Measure and record the FV to the TPM
   //
-  FvBlob.BlobBase   = FvBase;
+  FvBlob.BlobBase   = FvOrgBase;
   FvBlob.BlobLength = FvLength;
 
   DEBUG ((DEBUG_INFO, "The FV which is measured by TcgPei starts at: 0x%x\n", 
FvBlob.BlobBase));
@@ -416,7 +441,7 @@ MeasureFvImage (
 
   Status = HashLogExtendEvent (
  (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
- (UINT8*) (UINTN) FvBlob.BlobBase,
+ (UINT8*) (UINTN) FvDataBase,
  (UINTN) FvBlob.BlobLength,
  &TcgEventHdr,
  (UINT8*) &FvBlob
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 1/9] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

The security researcher found that we can get control after NEM disable.

The reason is that the flash content reside in NEM at startup and the
code will get the content from flash directly after disable NEM.

To avoid this vulnerability, the feature will copy the PEIMs from
temporary memory to permanent memory and only execute the code in
permanent memory.

The vulnerability is exist in physical platform and haven't report in
virtual platform, so the virtual can disable the feature currently.

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Guomin Jiang 
---
 MdeModulePkg/MdeModulePkg.dec | 7 +++
 MdeModulePkg/MdeModulePkg.uni | 6 ++
 2 files changed, 13 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 843e963ad34b..16db17d0a873 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1220,6 +1220,13 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # @Prompt Shadow Peim and PeiCore on boot
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
 
+  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
+  #  Set FALSE as default, if the developer need this feature to avoid this 
vulnerability, please
+  #  enable it in dsc file.
+  # TRUE - Evacuate temporary memory, the actions include copy memory, convert 
PPI pointers and so on.
+  # FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A
+
   ## The mask is used to control memory profile behavior.
   #  BIT0 - Enable UEFI memory profile.
   #  BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2007e0596c4f..5235dee561ad 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -214,6 +214,12 @@

"TRUE  - Shadow PEIM on S3 boot path after memory is ready.\n"

"FALSE - Not shadow PEIM on S3 boot path after memory is ready."
 
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_HELP 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not.\n"
+   
   "It will allocate page to save the temporary PEIMs 
resided in NEM(or CAR) to the permanent memory and change all pointers pointed 
to the NEM(or CAR) to permanent memory.\n"
+   
   "After then, there are no pointer pointed to NEM(or CAR) 
and TOCTOU volnerability can be avoid.\n"
+
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_PROMPT 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not"
+
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT  
#language en-US "Default OEM ID for ACPI table creation"
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP  #language 
en-US "Default OEM ID for ACPI table creation, its length must be 0x6 bytes to 
follow ACPI specification."
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 8/9] UefiCpuPkg: Correct some typos.

2020-07-08 Thread Guomin Jiang
Correct some typos.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 UefiCpuPkg/CpuMpPei/CpuPaging.c   | 4 ++--
 .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c| 4 ++--
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 04a16fb2b620..891d1ef50cac 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -153,7 +153,7 @@ GetPhysicalAddressWidth (
   Get the type of top level page table.
 
   @retval Page512G  PML4 paging.
-  @retval Page1GPAE paing.
+  @retval Page1GPAE paging.
 
 **/
 PAGE_ATTRIBUTE
@@ -583,7 +583,7 @@ SetupStackGuardPage (
 }
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index 1aafb7dac139..903449e0daa9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -18,8 +18,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
+  IN  UINTN   InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
index 20148db74cf8..d4ae153c5742 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
@@ -87,7 +87,7 @@ InitializeCpuExceptionHandlers (
   IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof 
(IA32_IDT_GATE_DESCRIPTOR);
   if (IdtEntryCount > CPU_EXCEPTION_NUM) {
 //
-// CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at 
most
+// CPU exception library only setup CPU_EXCEPTION_NUM exception handler at 
most
 //
 IdtEntryCount = CPU_EXCEPTION_NUM;
   }
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 5/9] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save the rebased PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.

The MigratedFvInfo HOB will never produce when
PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control
the total feature.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Guomin Jiang 
---
 MdeModulePkg/MdeModulePkg.dec |  3 ++
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Core/Pei/PeiMain.h   |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 22 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++
 5 files changed, 55 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 16db17d0a873..40197dba862c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -389,6 +389,9 @@ [Guids]
   ## GUID indicates the capsule is to store Capsule On Disk file names.
   gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x9a, 
0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
 
+  ## Include/Guid/MigratedFvInfo.h
+  gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 
0xce, 0xfd, 0x17, 0x98, 0x71 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 5b36d516b3fa..0cf357371a16 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -77,6 +77,7 @@ [Guids]
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
   gStatusCodeCallbackGuid
+  gEdkiiMigratedFvInfoGuid  ## SOMETIMES_PRODUCES ## 
HOB
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index b0101dba5e30..cbf74d5b9d9a 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 ///
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h 
b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
new file mode 100644
index ..061c17ed0e48
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
@@ -0,0 +1,22 @@
+/** @file
+  Migrated FV information
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+#define __EDKII_MIGRATED_FV_INFO_GUID_H__
+
+typedef struct {
+  UINT32   FvOrgBase;  // original FV address
+  UINT32   FvNewBase;  // new FV address
+  UINT32   FvDataBase; // original FV data
+  UINT32   FvLength;   // Fv Length
+} EDKII_MIGRATED_FV_INFO;
+
+extern EFI_GUID gEdkiiMigratedFvInfoGuid;
+
+#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index ef88b3423376..f654cea15c59 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1223,10 +1223,12 @@ EvacuateTempRam (
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*ChildFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedFvHeader;
+  EFI_FIRMWARE_VOLUME_HEADER*RawDataFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedChildFvHeader;
 
   PEI_CORE_FV_HANDLEPeiCoreFvHandle;
   EFI_PEI_CORE_FV_LOCATION_PPI  *PeiCoreFvLocationPpi;
+  EDKII_MIGRATED_FV_INFOMigratedFvInfo;
 
   ASSERT (Private->PeiMemoryInstalled);
 
@@ -1263,6 +1265,9 @@ EvacuateTempRam (
 (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1)) < 
Private->FreePhysicalMemoryTop)
 )
   ) {
+  //
+  // Allocate page to save the rebased PEIMs, the PEIMs will get control 
later
+  //
   Status =  PeiServicesAllocatePages (
   EfiBootServicesCode,
   EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength),
@@ -1270,6 +1275,17 @@ EvacuateTempRam (
   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Allocate pool to save the raw PEIMs, it used to keep consistent 
context across
+  // multiple boot and PCR0 will keep same no matter if

[edk2-devel] [PATCH v4 3/9] UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
From: Michael Kubacki 

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

Moves the GDT and IDT to permanent memory in a memory discovered
callback. This is done to ensure the GDT and IDT authenticated in
pre-memory is not fetched from outside a verified location after
the permanent memory transition.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 12 +++
 UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 37 
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 12 +--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index caead3ce34d4..f4d11b861f77 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -63,6 +63,7 @@ [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList  ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize   ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 7d5c527d6006..309478cbe14c 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -397,6 +397,18 @@ SecPlatformInformation2 (
  OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
   );
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  );
+
 /**
   Initializes MP and exceptions handlers.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 07ccbe7c6a91..d07540cf7471 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -429,6 +429,43 @@ GetGdtr (
   AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer);
 }
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   GdtBufferSize;
+  IA32_DESCRIPTOR Gdtr;
+  VOID*GdtBuffer;
+
+  AsmReadGdtr ((IA32_DESCRIPTOR *) &Gdtr);
+  GdtBufferSize = sizeof (IA32_SEGMENT_DESCRIPTOR) -1 + Gdtr.Limit + 1;
+
+  Status =  PeiServicesAllocatePool (
+  GdtBufferSize,
+  &GdtBuffer
+  );
+  ASSERT (GdtBuffer != NULL);
+  if (EFI_ERROR (Status)) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  GdtBuffer = ALIGN_POINTER (GdtBuffer, sizeof (IA32_SEGMENT_DESCRIPTOR));
+  CopyMem (GdtBuffer, (VOID *) Gdtr.Base, Gdtr.Limit + 1);
+  Gdtr.Base = (UINTN) GdtBuffer;
+  AsmWriteGdtr (&Gdtr);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Initializes CPU exceptions handlers for the sake of stack switch requirement.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index a462e7ee1e38..3bf0574b34c6 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -602,8 +602,16 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   )
 {
-  EFI_STATUS  Status;
-  BOOLEAN InitStackGuard;
+  EFI_STATUS  Status;
+  BOOLEAN InitStackGuard;
+  BOOLEAN InterruptState;
+
+  if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
+InterruptState = SaveAndDisableInterrupts ();
+Status = MigrateGdt ();
+ASSERT_EFI_ERROR (Status);
+SetInterruptState (InterruptState);
+  }
 
   //
   // Paging must be setup first. Otherwise the exception TSS setup during MP
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 4/9] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
From: Michael Kubacki 

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

Adds a PEIM that republishes structures produced in SEC. This
is done because SEC modules may not be shadowed in some platforms
due to space constraints or special alignment requirements. The
SecMigrationPei module locates interfaces that may be published in
SEC and reinstalls the interface with permanent memory addresses.

This is important if pre-memory address access is forbidden after
memory initialization and data such as a PPI descriptor, PPI GUID,
or PPI inteface reside in pre-memory.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
---
 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 154 +++
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 378 ++
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 10 files changed, 698 insertions(+), 2 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 762badf5d239..0a005bd20311 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -66,6 +66,10 @@ [Guids]
   ## Include/Guid/MicrocodePatchHob.h
   gEdkiiMicrocodePatchHobGuid= { 0xd178f11d, 0x8716, 0x418e, { 0xa1, 0x31, 
0x96, 0x7d, 0x2a, 0xc4, 0x28, 0x43 }}
 
+[Ppis]
+  ## Include/Ppi/RepublishSecPpi.h
+  gRepublishSecPpiPpiGuid   = { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 
0x52, 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }}
+
 [Protocols]
   ## Include/Protocol/SmmCpuService.h
   gEfiSmmCpuServiceProtocolGuid  = { 0x1d202cab, 0xc8ab, 0x4d5c, { 0x94, 0xf7, 
0x3c, 0xfc, 0xc0, 0xd3, 0xd3, 0x35 }}
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index afa304128221..964720048dd7 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -146,6 +146,7 @@ [Components.IA32, Components.X64]
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
   UefiCpuPkg/SecCore/SecCore.inf
+  UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index 0562820c95e0..545781d6b4b3 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -68,6 +68,8 @@ [Ppis]
   ## SOMETIMES_CONSUMES
   gPeiSecPerformancePpiGuid
   gEfiPeiCoreFvLocationPpiGuid
+  ## CONSUMES
+  gRepublishSecPpiPpiGuid
 
 [Guids]
   ## SOMETIMES_PRODUCES   ## HOB
diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf 
b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
new file mode 100644
index ..f4c2f6b658fb
--- /dev/null
+++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
@@ -0,0 +1,67 @@
+## @file
+#  Migrates SEC structures after permanent memory is installed.
+#
+# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SecMigrationPei
+  MODULE_UNI_FILE= SecMigrationPei.uni
+  FILE_GUID  = 58B35361-8922-41BC-B313-EF7ED9ADFDF7
+  MODULE_TYPE= PEIM
+  VERSION_STRING = 1.0
+  ENTRY_POINT= SecMigrationPeiInitialize
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  SecMigrationPei.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  HobLib
+  MemoryAllocationLib
+  PeimEntryPoint
+  PeiServicesLib
+  PeiServicesTablePointerLib
+
+[Ppis]
+  ## PRODUCES
+  gRepublishSecPpiPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gEfiTemporaryRamDonePpiGuid
+
+  ## SOMETIME_PRODUCES
+  gEfiTemporaryRamSupportPpiGuid
+
+  ## SOMETIMES_PRODUCES
+  gPeiSecPerformancePpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## PRODUCES
+  gEfiSecPlatformInformationPpiGuid
+
+  ## SOMETIMES_CONSUMES
+  ## SOMETIMES_PRODUCES
+  gEfiSecPlatformInformation2PpiGuid
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGui

[edk2-devel] [PATCH v4 6/9] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save rebased the PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.
The Tcg2Pei calculate the hash and it use the Migrated FV Info.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Chao Zhang 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf |  1 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c   | 31 ++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
index 3d361e8859e7..367df21eedaf 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
@@ -63,6 +63,7 @@ [Guids]
   gTcgEvent2EntryHobGuid   ## 
PRODUCES   ## HOB
   gEfiTpmDeviceInstanceNoneGuid## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
   gEfiTpmDeviceInstanceTpm12Guid   ## 
SOMETIMES_PRODUCES ## GUID   # TPM device identifier
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
   gEfiPeiFirmwareVolumeInfoPpiGuid ## 
SOMETIMES_CONSUMES ## NOTIFY
diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c 
b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
index 4852d8690617..651a60c1f0e2 100644
--- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -536,6 +537,10 @@ MeasureFvImage (
   EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI   *PrehashedFvPpi;
   HASH_INFO *PreHashInfo;
   UINT32HashAlgoMask;
+  EFI_PHYSICAL_ADDRESS  FvOrgBase;
+  EFI_PHYSICAL_ADDRESS  FvDataBase;
+  EFI_PEI_HOB_POINTERS  Hob;
+  EDKII_MIGRATED_FV_INFO*MigratedFvInfo;
 
   //
   // Check Excluded FV list
@@ -621,6 +626,26 @@ MeasureFvImage (
 Instance++;
   } while (!EFI_ERROR(Status));
 
+  //
+  // Search the matched migration FV info
+  //
+  FvOrgBase  = FvBase;
+  FvDataBase = FvBase;
+  Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+if ((MigratedFvInfo->FvNewBase == (UINT32) FvBase) && 
(MigratedFvInfo->FvLength == (UINT32) FvLength)) {
+  //
+  // Found the migrated FV info
+  //
+  FvOrgBase  = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgBase;
+  FvDataBase = (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvDataBase;
+  break;
+}
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+
   //
   // Init the log event for FV measurement
   //
@@ -631,13 +656,13 @@ MeasureFvImage (
 if (FvName != NULL) {
   AsciiSPrint ((CHAR8 *)FvBlob2.BlobDescription, 
sizeof(FvBlob2.BlobDescription), "Fv(%g)", FvName);
 }
-FvBlob2.BlobBase  = FvBase;
+FvBlob2.BlobBase  = FvOrgBase;
 FvBlob2.BlobLength= FvLength;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB2;
 TcgEventHdr.EventSize = sizeof (FvBlob2);
 EventData = &FvBlob2;
   } else {
-FvBlob.BlobBase   = FvBase;
+FvBlob.BlobBase   = FvOrgBase;
 FvBlob.BlobLength = FvLength;
 TcgEventHdr.PCRIndex  = 0;
 TcgEventHdr.EventType = EV_EFI_PLATFORM_FIRMWARE_BLOB;
@@ -672,7 +697,7 @@ MeasureFvImage (
 //
 Status = HashLogExtendEvent (
0,
-   (UINT8*) (UINTN) FvBase, // HashData
+   (UINT8*) (UINTN) FvDataBase, // HashData
(UINTN) FvLength,// HashDataLen
&TcgEventHdr,// EventHdr
EventData// EventData
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v4 7/9] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

To avoid the TOCTOU, enable paging and set Not Present flag so when
access any code in the flash range, it will trigger #NP exception.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  3 +++
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 26 --
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index f4d11b861f77..7e511325d8b8 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -46,6 +46,9 @@ [LibraryClasses]
   BaseMemoryLib
   CpuLib
 
+[Guids]
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
+
 [Ppis]
   gEfiPeiMpServicesPpiGuid  ## PRODUCES
   gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 3bf0574b34c6..04a16fb2b620 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include "CpuMpPei.h"
 
@@ -605,6 +606,8 @@ MemoryDiscoveredPpiNotifyCallback (
   EFI_STATUS  Status;
   BOOLEAN InitStackGuard;
   BOOLEAN InterruptState;
+  EDKII_MIGRATED_FV_INFO *MigratedFvInfo;
+  EFI_PEI_HOB_POINTERS   Hob;
 
   if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
 InterruptState = SaveAndDisableInterrupts ();
@@ -619,9 +622,14 @@ MemoryDiscoveredPpiNotifyCallback (
   // the task switch (for the sake of stack switch).
   //
   InitStackGuard = FALSE;
-  if (IsIa32PaeSupported () && PcdGetBool (PcdCpuStackGuard)) {
+  Hob.Raw = NULL;
+  if (IsIa32PaeSupported ()) {
+Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+InitStackGuard = PcdGetBool (PcdCpuStackGuard);
+  }
+
+  if (InitStackGuard || Hob.Raw != NULL) {
 EnablePaging ();
-InitStackGuard = TRUE;
   }
 
   Status = InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices);
@@ -631,6 +639,20 @@ MemoryDiscoveredPpiNotifyCallback (
 SetupStackGuardPage ();
   }
 
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+
+//
+// Enable #NP exception, so if the code access after disable NEM, it will 
generate
+// to avoid potential vulnerability.
+//
+ConvertMemoryPageAttributes (MigratedFvInfo->FvOrgBase, 
MigratedFvInfo->FvLength, 0);
+
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+  CpuFlushTlb ();
+
   return Status;
 }
 
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v5 3/9] UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
From: Michael Kubacki 

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

Moves the GDT and IDT to permanent memory in a memory discovered
callback. This is done to ensure the GDT and IDT authenticated in
pre-memory is not fetched from outside a verified location after
the permanent memory transition.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Michael Kubacki 
Reviewed-by: Laszlo Ersek 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   | 12 +++
 UefiCpuPkg/CpuMpPei/CpuMpPei.c   | 37 
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 12 +--
 4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index caead3ce34d4..f4d11b861f77 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -63,6 +63,7 @@ [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList  ## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize## 
SOMETIMES_CONSUMES
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize   ## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 [Depex]
   TRUE
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 7d5c527d6006..309478cbe14c 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -397,6 +397,18 @@ SecPlatformInformation2 (
  OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2
   );
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  );
+
 /**
   Initializes MP and exceptions handlers.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 07ccbe7c6a91..d07540cf7471 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -429,6 +429,43 @@ GetGdtr (
   AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer);
 }
 
+/**
+  Migrates the Global Descriptor Table (GDT) to permanent memory.
+
+  @retval   EFI_SUCCESS   The GDT was migrated successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The GDT could not be migrated due to lack of 
available memory.
+
+**/
+EFI_STATUS
+MigrateGdt (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   GdtBufferSize;
+  IA32_DESCRIPTOR Gdtr;
+  VOID*GdtBuffer;
+
+  AsmReadGdtr ((IA32_DESCRIPTOR *) &Gdtr);
+  GdtBufferSize = sizeof (IA32_SEGMENT_DESCRIPTOR) -1 + Gdtr.Limit + 1;
+
+  Status =  PeiServicesAllocatePool (
+  GdtBufferSize,
+  &GdtBuffer
+  );
+  ASSERT (GdtBuffer != NULL);
+  if (EFI_ERROR (Status)) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  GdtBuffer = ALIGN_POINTER (GdtBuffer, sizeof (IA32_SEGMENT_DESCRIPTOR));
+  CopyMem (GdtBuffer, (VOID *) Gdtr.Base, Gdtr.Limit + 1);
+  Gdtr.Base = (UINTN) GdtBuffer;
+  AsmWriteGdtr (&Gdtr);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Initializes CPU exceptions handlers for the sake of stack switch requirement.
 
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index a462e7ee1e38..3bf0574b34c6 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -602,8 +602,16 @@ MemoryDiscoveredPpiNotifyCallback (
   IN VOID   *Ppi
   )
 {
-  EFI_STATUS  Status;
-  BOOLEAN InitStackGuard;
+  EFI_STATUS  Status;
+  BOOLEAN InitStackGuard;
+  BOOLEAN InterruptState;
+
+  if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
+InterruptState = SaveAndDisableInterrupts ();
+Status = MigrateGdt ();
+ASSERT_EFI_ERROR (Status);
+SetInterruptState (InterruptState);
+  }
 
   //
   // Paging must be setup first. Otherwise the exception TSS setup during MP
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v5 5/9] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

When we allocate pool to save the rebased PEIMs, the address will change
randomly, therefore the hash will change and result PCR0 change as well.
To avoid this, we save the raw PEIMs and use it to calculate hash.

The MigratedFvInfo HOB will never produce when
PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control
the total feature.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
---
 MdeModulePkg/MdeModulePkg.dec |  3 ++
 MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
 MdeModulePkg/Core/Pei/PeiMain.h   |  1 +
 MdeModulePkg/Include/Guid/MigratedFvInfo.h| 22 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++
 5 files changed, 55 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 16db17d0a873..40197dba862c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -389,6 +389,9 @@ [Guids]
   ## GUID indicates the capsule is to store Capsule On Disk file names.
   gEdkiiCapsuleOnDiskNameGuid = { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x9a, 
0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } }
 
+  ## Include/Guid/MigratedFvInfo.h
+  gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 
0xce, 0xfd, 0x17, 0x98, 0x71 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 5b36d516b3fa..0cf357371a16 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -77,6 +77,7 @@ [Guids]
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
   gStatusCodeCallbackGuid
+  gEdkiiMigratedFvInfoGuid  ## SOMETIMES_PRODUCES ## 
HOB
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index b0101dba5e30..cbf74d5b9d9a 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 ///
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h 
b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
new file mode 100644
index ..061c17ed0e48
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h
@@ -0,0 +1,22 @@
+/** @file
+  Migrated FV information
+
+Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+#define __EDKII_MIGRATED_FV_INFO_GUID_H__
+
+typedef struct {
+  UINT32   FvOrgBase;  // original FV address
+  UINT32   FvNewBase;  // new FV address
+  UINT32   FvDataBase; // original FV data
+  UINT32   FvLength;   // Fv Length
+} EDKII_MIGRATED_FV_INFO;
+
+extern EFI_GUID gEdkiiMigratedFvInfoGuid;
+
+#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__
+
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c 
b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index ef88b3423376..f654cea15c59 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -1223,10 +1223,12 @@ EvacuateTempRam (
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*ChildFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedFvHeader;
+  EFI_FIRMWARE_VOLUME_HEADER*RawDataFvHeader;
   EFI_FIRMWARE_VOLUME_HEADER*MigratedChildFvHeader;
 
   PEI_CORE_FV_HANDLEPeiCoreFvHandle;
   EFI_PEI_CORE_FV_LOCATION_PPI  *PeiCoreFvLocationPpi;
+  EDKII_MIGRATED_FV_INFOMigratedFvInfo;
 
   ASSERT (Private->PeiMemoryInstalled);
 
@@ -1263,6 +1265,9 @@ EvacuateTempRam (
 (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1)) < 
Private->FreePhysicalMemoryTop)
 )
   ) {
+  //
+  // Allocate page to save the rebased PEIMs, the PEIMs will get control 
later
+  //
   Status =  PeiServicesAllocatePages (
   EfiBootServicesCode,
   EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength),
@@ -1270,6 +1275,17 @@ EvacuateTempRam (
   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Allocate pool to save the raw PEIMs, it used to keep consistent 
context across
+  // multiple boot and PCR0 will k

[edk2-devel] [PATCH v5 0/9] Add new feature that evacuate temporary to permanent memory (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
The TOCTOU vulnerability allow that the physical present person to replace the 
code with the normal BootGuard check and PCR0 value.
The issue occur when BootGuard measure IBB and access flash code after NEM 
disable.
the reason why we access the flash code is that we have some pointer to flash.
To avoid this vulnerability, we need to convert those pointers, the patch 
series do this work and make sure that no code will access flash address.

v2:
Create gEdkiiMigratedFvInfoGuid HOB and add 
PcdMigrateTemporaryRamFirmwareVolumes to control whole feature.

v3:
Remove changes which is not related with the feature and disable the feature in 
virtual platform.

v4:
Disable the feature as default, Copy the Tcg2Pei behavior to TcgPei

v5:
Initialize local variable Shadow and return EFI_ABORTED when RepublishSecPpi 
not installed.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Rahul Kumar 
Cc: Jiewen Yao 
Cc: Chao Zhang 
Cc: Qi Zhang 

Guomin Jiang (6):
  MdeModulePkg: Add new PCD to control the evacuate temporary memory
feature (CVE-2019-11098)
  MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU
(CVE-2019-11098)
  UefiCpuPkg: Correct some typos.
  SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash
(CVE-2019-11098)

Michael Kubacki (3):
  MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore
(CVE-2019-11098)
  UefiCpuPkg/CpuMpPei: Add GDT and IDT migration support
(CVE-2019-11098)
  UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098)

 MdeModulePkg/MdeModulePkg.dec |  10 +
 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 MdeModulePkg/Core/Pei/PeiMain.inf |   3 +
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf   |   1 +
 SecurityPkg/Tcg/TcgPei/TcgPei.inf |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf  |   4 +
 UefiCpuPkg/SecCore/SecCore.inf|   2 +
 .../SecMigrationPei/SecMigrationPei.inf   |  67 +++
 MdeModulePkg/Core/Pei/PeiMain.h   | 169 +++
 MdeModulePkg/Include/Guid/MigratedFvInfo.h|  22 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.h|  14 +-
 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h  |  54 +++
 .../CpuExceptionCommon.h  |   4 +-
 UefiCpuPkg/SecCore/SecMain.h  |   1 +
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h  | 154 +++
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 430 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  24 +
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 
 SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  31 +-
 SecurityPkg/Tcg/TcgPei/TcgPei.c   |  29 +-
 UefiCpuPkg/CpuMpPei/CpuMpPei.c|  37 ++
 UefiCpuPkg/CpuMpPei/CpuPaging.c   |  42 +-
 .../Ia32/ArchExceptionHandler.c   |   4 +-
 .../SecPeiCpuException.c  |   2 +-
 .../X64/ArchExceptionHandler.c|   4 +-
 UefiCpuPkg/SecCore/SecMain.c  |  26 +-
 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c  | 381 
 MdeModulePkg/MdeModulePkg.uni |   6 +
 .../SecMigrationPei/SecMigrationPei.uni   |  13 +
 32 files changed, 2003 insertions(+), 21 deletions(-)
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
 create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h
 create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c
 create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni

-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v5 8/9] UefiCpuPkg: Correct some typos.

2020-07-08 Thread Guomin Jiang
Correct some typos.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.h| 2 +-
 .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h   | 4 ++--
 UefiCpuPkg/CpuMpPei/CpuPaging.c   | 4 ++--
 .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c| 4 ++--
 .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c   | 2 +-
 .../Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 309478cbe14c..6a481a84dcc7 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -424,7 +424,7 @@ InitializeCpuMpWorker (
   );
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
index 805dd9cbb4ff..0544d6dba631 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h
@@ -90,8 +90,8 @@ AsmGetTemplateAddressMap (
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR   *IdtEntry,
+  IN  UINTN  InterruptHandler
   );
 
 /**
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 04a16fb2b620..891d1ef50cac 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -153,7 +153,7 @@ GetPhysicalAddressWidth (
   Get the type of top level page table.
 
   @retval Page512G  PML4 paging.
-  @retval Page1GPAE paing.
+  @retval Page1GPAE paging.
 
 **/
 PAGE_ATTRIBUTE
@@ -583,7 +583,7 @@ SetupStackGuardPage (
 }
 
 /**
-  Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
+  Enable/setup stack guard for each processor if PcdCpuStackGuard is set to 
TRUE.
 
   Doing this in the memory-discovered callback is to make sure the Stack Guard
   feature to cover as most PEI code as possible.
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
index 1aafb7dac139..903449e0daa9 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c
@@ -18,8 +18,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
+  IN  UINTN   InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
index 20148db74cf8..d4ae153c5742 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c
@@ -87,7 +87,7 @@ InitializeCpuExceptionHandlers (
   IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof 
(IA32_IDT_GATE_DESCRIPTOR);
   if (IdtEntryCount > CPU_EXCEPTION_NUM) {
 //
-// CPU exeption library only setup CPU_EXCEPTION_NUM exception handler at 
most
+// CPU exception library only setup CPU_EXCEPTION_NUM exception handler at 
most
 //
 IdtEntryCount = CPU_EXCEPTION_NUM;
   }
diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
index 894c1cfb7533..d3da16e4dfa2 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c
@@ -17,8 +17,8 @@
 **/
 VOID
 ArchUpdateIdtEntry (
-  IN IA32_IDT_GATE_DESCRIPTOR*IdtEntry,
-  IN UINTN   InterruptHandler
+  OUT IA32_IDT_GATE_DESCRIPTOR   *IdtEntry,
+  IN  UINTN  InterruptHandler
   )
 {
   IdtEntry->Bits.OffsetLow   = (UINT16)(UINTN)InterruptHandler;
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v5 2/9] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
From: Michael Kubacki 

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

Introduces new changes to PeiCore to move the contents of temporary
RAM visible to the PeiCore to permanent memory. This expands on
pre-existing shadowing support in the PeiCore to perform the following
additional actions:

 1. Migrate pointers in PPIs installed in PeiCore to the permanent
memory copy of PeiCore.

 2. Copy all installed firmware volumes to permanent memory.

 3. Relocate and fix up the PEIMs within the firmware volumes.

 4. Convert all PPIs into the migrated firmware volume to the corresponding
PPI address in the permanent memory location.

This applies to PPIs and PEI notifications.

 5. Convert all status code callbacks in the migrated firmware volume to
the corresponding address in the permanent memory location.

 6. Update the FV HOB to the corresponding firmware volume in permanent
memory.

 7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the
feature or not. when the PCD disable, the EvacuateTempRam() will
never be called.

The function control flow as below:
  PeiCore()
DumpPpiList()
EvacuateTempRam()
  ConvertPeiCorePpiPointers()
ConvertPpiPointersFv()
  MigratePeimsInFv()
MigratePeim()
  PeiGetPe32Data()
  LoadAndRelocatePeCoffImageInPlace()
  MigrateSecModulesInFv()
  ConvertPpiPointersFv()
  ConvertStatusCodeCallbacks()
  ConvertFvHob()
  RemoveFvHobsInTemporaryMemory()
DumpPpiList()

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Debkumar De 
Cc: Harry Han 
Cc: Catharine West 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Core/Pei/PeiMain.inf |   2 +
 MdeModulePkg/Core/Pei/PeiMain.h   | 168 
 MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 402 ++
 MdeModulePkg/Core/Pei/Image/Image.c   | 115 +
 MdeModulePkg/Core/Pei/Memory/MemoryServices.c |  82 
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c   |  24 ++
 MdeModulePkg/Core/Pei/Ppi/Ppi.c   | 287 +
 7 files changed, 1080 insertions(+)

diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf 
b/MdeModulePkg/Core/Pei/PeiMain.inf
index 6e25cc40232a..5b36d516b3fa 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.inf
+++ b/MdeModulePkg/Core/Pei/PeiMain.inf
@@ -76,6 +76,7 @@ [Guids]
   ## CONSUMES   ## UNDEFINED # Locate PPI
   ## CONSUMES   ## GUID  # Used to compare with FV's file system GUID and 
get the FV's file system format
   gEfiFirmwareFileSystem3Guid
+  gStatusCodeCallbackGuid
 
 [Ppis]
   gEfiPeiStatusCodePpiGuid  ## SOMETIMES_CONSUMES # 
PeiReportStatusService is not ready if this PPI doesn't exist
@@ -109,6 +110,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot  ## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot## 
CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack## 
CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes  ## 
CONSUMES
 
 # [BootMode]
 # S3_RESUME ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 56b3bd85793d..b0101dba5e30 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -394,6 +394,41 @@ PeimDispatchReadiness (
   IN VOID   *DependencyExpression
   );
 
+/**
+  Migrate a PEIM from Temporary RAM to permanent memory.
+
+  @param PeimFileHandle   Pointer to the FFS file header of the image.
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated 
image.
+
+  @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent 
memory.
+
+**/
+EFI_STATUS
+EFIAPI
+MigratePeim (
+  IN  EFI_PEI_FILE_HANDLE FileHandle,
+  IN  EFI_PEI_FILE_HANDLE MigratedFileHandle
+  );
+
+/**
+  Migrate FVs out of Temporary RAM before the cache is flushed.
+
+  @param Private PeiCore's private data structure
+  @param SecCoreData Points to a data structure containing information 
about the PEI core's operating
+ environment, such as the size and location of 
temporary RAM, the stack location and
+ the BFV location.
+
+  @retval EFI_SUCCESS   Succesfully migrated installed FVs from 
Temporary RAM to permanent memory.
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed 
pages.
+
+**/
+EFI_STATUS
+EFIAPI
+EvacuateTempRam (
+  IN PEI_CORE_INSTANCE*Private,
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData
+  );
+
 /**
   Conduct PEIM dispatch.
 
@@ -477,6 +512,50 @@ ConvertPpiPointers (
   IN PEI_CORE_INSTANCE   *PrivateData
   );
 
+/**
+
+  Migrate Notify Pointers inside an FV from temporary memory to permanent 
memory.
+
+  @param PrivateData  Pointer to PeiCore's private data structure.
+  @param OrgFvHandle  

[edk2-devel] [PATCH v5 7/9] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

To avoid the TOCTOU, enable paging and set Not Present flag so when
access any code in the flash range, it will trigger #NP exception.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |  3 +++
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 26 --
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index f4d11b861f77..7e511325d8b8 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -46,6 +46,9 @@ [LibraryClasses]
   BaseMemoryLib
   CpuLib
 
+[Guids]
+  gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
+
 [Ppis]
   gEfiPeiMpServicesPpiGuid  ## PRODUCES
   gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index 3bf0574b34c6..04a16fb2b620 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include "CpuMpPei.h"
 
@@ -605,6 +606,8 @@ MemoryDiscoveredPpiNotifyCallback (
   EFI_STATUS  Status;
   BOOLEAN InitStackGuard;
   BOOLEAN InterruptState;
+  EDKII_MIGRATED_FV_INFO *MigratedFvInfo;
+  EFI_PEI_HOB_POINTERS   Hob;
 
   if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
 InterruptState = SaveAndDisableInterrupts ();
@@ -619,9 +622,14 @@ MemoryDiscoveredPpiNotifyCallback (
   // the task switch (for the sake of stack switch).
   //
   InitStackGuard = FALSE;
-  if (IsIa32PaeSupported () && PcdGetBool (PcdCpuStackGuard)) {
+  Hob.Raw = NULL;
+  if (IsIa32PaeSupported ()) {
+Hob.Raw  = GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid);
+InitStackGuard = PcdGetBool (PcdCpuStackGuard);
+  }
+
+  if (InitStackGuard || Hob.Raw != NULL) {
 EnablePaging ();
-InitStackGuard = TRUE;
   }
 
   Status = InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices);
@@ -631,6 +639,20 @@ MemoryDiscoveredPpiNotifyCallback (
 SetupStackGuardPage ();
   }
 
+  while (Hob.Raw != NULL) {
+MigratedFvInfo = GET_GUID_HOB_DATA (Hob);
+
+//
+// Enable #NP exception, so if the code access after disable NEM, it will 
generate
+// to avoid potential vulnerability.
+//
+ConvertMemoryPageAttributes (MigratedFvInfo->FvOrgBase, 
MigratedFvInfo->FvLength, 0);
+
+Hob.Raw = GET_NEXT_HOB (Hob);
+Hob.Raw = GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw);
+  }
+  CpuFlushTlb ();
+
   return Status;
 }
 
-- 
2.25.1.windows.1


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

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



[edk2-devel] [PATCH v5 1/9] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098)

2020-07-08 Thread Guomin Jiang
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1614

The security researcher found that we can get control after NEM disable.

The reason is that the flash content reside in NEM at startup and the
code will get the content from flash directly after disable NEM.

To avoid this vulnerability, the feature will copy the PEIMs from
temporary memory to permanent memory and only execute the code in
permanent memory.

The vulnerability is exist in physical platform and haven't report in
virtual platform, so the virtual can disable the feature currently.

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Guomin Jiang 
Acked-by: Laszlo Ersek 
---
 MdeModulePkg/MdeModulePkg.dec | 7 +++
 MdeModulePkg/MdeModulePkg.uni | 6 ++
 2 files changed, 13 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 843e963ad34b..16db17d0a873 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1220,6 +1220,13 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   # @Prompt Shadow Peim and PeiCore on boot
   gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x30001029
 
+  ## Enable the feature that evacuate temporary memory to permanent memory or 
not
+  #  Set FALSE as default, if the developer need this feature to avoid this 
vulnerability, please
+  #  enable it in dsc file.
+  # TRUE - Evacuate temporary memory, the actions include copy memory, convert 
PPI pointers and so on.
+  # FALSE - Do nothing, for example, no copy memory, no convert PPI pointers 
and so on.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FALSE|BOOLEAN|0x3000102A
+
   ## The mask is used to control memory profile behavior.
   #  BIT0 - Enable UEFI memory profile.
   #  BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni
index 2007e0596c4f..5235dee561ad 100644
--- a/MdeModulePkg/MdeModulePkg.uni
+++ b/MdeModulePkg/MdeModulePkg.uni
@@ -214,6 +214,12 @@

"TRUE  - Shadow PEIM on S3 boot path after memory is ready.\n"

"FALSE - Not shadow PEIM on S3 boot path after memory is ready."
 
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_HELP 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not.\n"
+   
   "It will allocate page to save the temporary PEIMs 
resided in NEM(or CAR) to the permanent memory and change all pointers pointed 
to the NEM(or CAR) to permanent memory.\n"
+   
   "After then, there are no pointer pointed to NEM(or CAR) 
and TOCTOU volnerability can be avoid.\n"
+
+#string 
STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareVolumes_PROMPT 
#language en-US "Enable the feature that evacuate temporary memory to permanent 
memory or not"
+
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT  
#language en-US "Default OEM ID for ACPI table creation"
 
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP  #language 
en-US "Default OEM ID for ACPI table creation, its length must be 0x6 bytes to 
follow ACPI specification."
-- 
2.25.1.windows.1


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

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



  1   2   3   4   >