[edk2-devel] [edk2-platforms] [PATCH V1 4/5] BoardModulePkg: Add BdsSerialPortTerminalLib

2022-06-17 Thread Nate DeSimone
BdsSerialPortTerminalLib add a terminal device
to the Serial UART device created by
MdeModulePkg/Universal/SerialDxe to the UEFI
Console Variables (ConIn, ConOut, ErrOut). This
allows BIOS Setup, UEFI Shell, etc. to be used
on a headless system via a null modem and
terminal emulation software.

Cc: Eric Dong 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Sai Chaganty 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 
---
 .../Intel/BoardModulePkg/BoardModulePkg.dsc   |   3 +-
 .../BdsSerialPortTerminalLib.c| 114 ++
 .../BdsSerialPortTerminalLib.h|  53 
 .../BdsSerialPortTerminalLib.inf  |  49 
 4 files changed, 218 insertions(+), 1 deletion(-)
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc 
b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
index 9f00592a19..c93b536f0d 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
@@ -6,7 +6,7 @@
 # INF files to generate AutoGen.c and AutoGen.h files
 # for the build infrastructure.
 #
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -91,3 +91,4 @@
 
   
BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaInfoLib.inf
   BoardModulePkg/Library/BdsPs2KbcLib/BdsPs2KbcLib.inf
+  BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
diff --git 
a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
 
b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
new file mode 100644
index 00..178ca2b3ac
--- /dev/null
+++ 
b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
@@ -0,0 +1,114 @@
+/** @file
+  Main file for NULL named library that adds a Terminal Device connected
+  to SerialDxe to the UEFI Console Variables. This allows BIOS Setup, UEFI
+  Shell, etc. to be used on a headless system via a null modem and terminal
+  emulator.
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "BdsSerialPortTerminalLib.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID  *mTerminalType[] = {
+  ,
+  ,
+  ,
+  ,
+  
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath = {
+  {
+{
+  HARDWARE_DEVICE_PATH,
+  HW_VENDOR_DP,
+  {
+(UINT8) sizeof (VENDOR_DEVICE_PATH),
+(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+  }
+},
+EDKII_SERIAL_PORT_LIB_VENDOR_GUID
+  },
+  {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_UART_DP,
+  {
+(UINT8) sizeof (UART_DEVICE_PATH),
+(UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+  }
+},
+0,  // Reserved
+115200, // BaudRate
+8,  // DataBits
+1,  // Parity
+1   // StopBits
+  },
+  {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_VENDOR_DP,
+  {
+(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
+  }
+},
+DEVICE_PATH_MESSAGING_PC_ANSI
+  },
+  gEndEntire
+};
+
+/**
+  Updates the ConOut, ConIn, ErrOut variables with the serial terminal device 
path
+  @paramnone
+  @retval   none
+**/
+VOID
+AddSerialTerminal (
+  VOID
+  )
+{
+  DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n"));
+
+  //
+  // Update the Terminal Device Configuration Parameters
+  //
+  mSerialDevicePath.Uart.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
+  mSerialDevicePath.Uart.DataBits = PcdGet8 (PcdUartDefaultDataBits);
+  mSerialDevicePath.Uart.Parity   = PcdGet8 (PcdUartDefaultParity);
+  mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits);
+  CopyMem (
+(VOID *) &(mSerialDevicePath.TerminalType.Guid),
+(VOID *) mTerminalType[PcdGet8 (PcdDefaultTerminalType)],
+sizeof (EFI_GUID)
+);
+
+  //
+  // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut"
+  //
+  EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *) 
, NULL);
+  EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) 
, NULL);
+  EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL *) 
, NULL);
+}
+
+/**
+  Constructor for the Serial Port Terminal Device library.
+
+  @param ImageHandleThe Image Handle of the process
+  @param SystemTableThe EFI 

[edk2-devel] [edk2-platforms] [PATCH V1 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port

2022-06-17 Thread Nate DeSimone
Enables usage of the HDMI DDC I2C Bus SerialPortLib implementation
on the GalagoPro3 board.

Cc: Chasel Chiu 
Cc: Sai Chaganty 
Cc: Isaac Oram 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 
---
 .../GalagoPro3/OpenBoardPkg.dsc   | 78 ++-
 .../GalagoPro3/OpenBoardPkg.fdf   |  6 +-
 .../GalagoPro3/OpenBoardPkgPcd.dsc| 30 +++
 3 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 5cf2d424ff..2e3c6d3ca5 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -142,6 +142,12 @@
   
PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
   
SiliconPolicyUpdateLib|$(PROJECT)/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
 
+[LibraryClasses.common.PEI_CORE]
+!if $(TARGET) == DEBUG && 
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
+!endif
+
 [LibraryClasses.IA32.SEC]
   ###
   # Edk2 Packages
@@ -166,7 +172,6 @@
   ###
   
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
-  
SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLibNull.inf
 
   ###
   # Silicon Package
@@ -183,6 +188,7 @@
 !if $(TARGET) == DEBUG
   
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/PeiTestPointCheckLib.inf
 !endif
+  
SetCacheMtrrLib|$(PLATFORM_PACKAGE)/Library/SetCacheMtrrLib/SetCacheMtrrLibNull.inf
 
   ###
   # Board Package
@@ -193,7 +199,19 @@
   
PeiTbtPolicyLib|$(PLATFORM_BOARD_PACKAGE)/Features/Tbt/Library/PeiTbtPolicyLib/PeiTbtPolicyLib.inf
 !endif
 
+[LibraryClasses.common.DXE_CORE]
+!if $(TARGET) == DEBUG
+  
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
 [LibraryClasses.common.DXE_DRIVER]
+  ###
+  # Edk2 Packages
+  ###
+!if $(TARGET) == DEBUG
+  
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
   ###
   # Silicon Initialization Package
   ###
@@ -225,11 +243,24 @@
   
SiliconPolicyUpdateLib|$(PROJECT)/Policy/Library/DxeSiliconPolicyUpdateLib/DxeSiliconPolicyUpdateLib.inf
 
 [LibraryClasses.X64.DXE_RUNTIME_DRIVER]
+  ###
+  # Edk2 Packages
+  ###
+!if $(TARGET) == DEBUG
+  
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+!endif
+
   ###
   # Silicon Initialization Package
   ###
   
ResetSystemLib|$(PLATFORM_SI_PACKAGE)/Pch/Library/DxeRuntimeResetSystemLib/DxeRuntimeResetSystemLib.inf
 
+[LibraryClasses.common.SMM_CORE]
+!if $(TARGET) == DEBUG && 
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+!endif
+
 [LibraryClasses.X64.DXE_SMM_DRIVER]
   ###
   # Silicon Initialization Package
@@ -245,6 +276,14 @@
 !if $(TARGET) == DEBUG
   
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf
 !endif
+# @todo DebugLibReportStatusCode isn't working for SMM drivers for some reason
+#   temporary W/A is to link the serial port lib into every SMM driver
+#   I think the only driver that needs this is PiSmmCpuDxeSmm...
+#   But more testing is needed.
+!if $(TARGET) == DEBUG && 
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  
SerialPortLib|$(PLATFORM_BOARD_PACKAGE)/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf
+!endif
 
 ###
 # PEI Components
@@ -258,11 +297,17 @@
   UefiCpuPkg/SecCore/SecCore.inf {
 
   PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+!if $(TARGET) == DEBUG  && 
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortEnable == TRUE
+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+!endif
   }
 

[edk2-devel] [edk2-platforms] [PATCH V1 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib

2022-06-17 Thread Nate DeSimone
This library initializes any GPIOs nessesary for
the HDMI DDC bus to operate. This can be called
very early (SEC phase) to enable closed chassis
debug through the HDMI DDC I2C bus.

Cc: Chasel Chiu 
Cc: Sai Chaganty 
Cc: Isaac Oram 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 
---
 .../AspireVn7Dash572G/OpenBoardPkg.dsc|   3 +-
 .../GalagoPro3/OpenBoardPkg.dsc   |   3 +-
 .../Include/Library/HdmiDebugGpioInitLib.h|  26 +++
 .../KabylakeRvp3/OpenBoardPkg.dsc |   3 +-
 .../HdmiDebugGpioInitLib.c| 221 ++
 .../HdmiDebugGpioInitLib.inf  |  42 
 6 files changed, 295 insertions(+), 3 deletions(-)
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
index 29aa8d9111..ec5591e00f 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the Aspire VN7-572G board.
 #
-# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -184,6 +184,7 @@
   
GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   
I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
   
PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+  
HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 93cf93942b..1df3cf13a3 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the GalagoPro3 board.
 #
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -128,6 +128,7 @@
   
GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   
I2cAccessLib|$(PLATFORM_BOARD_PACKAGE)/Library/PeiI2cAccessLib/PeiI2cAccessLib.inf
   
PlatformSecLib|$(PLATFORM_PACKAGE)/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+  
HdmiDebugGpioInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 
   # Thunderbolt
 !if gKabylakeOpenBoardPkgTokenSpaceGuid.PcdTbtEnable == TRUE
diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h 
b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
new file mode 100644
index 00..33bdeb74fc
--- /dev/null
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
@@ -0,0 +1,26 @@
+/** @file
+  GPIO initialization for the HDMI I2C Debug Port
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef HDMI_DEBUG_GPIO_INIT_LIB_H_
+#define HDMI_DEBUG_GPIO_INIT_LIB_H_
+
+#include 
+
+/**
+  Configures GPIOs to enable usage of the HDMI DDC I2C Bus
+
+  @retval EFI_SUCCESSThe function completed successfully
+  @retval EFI_UNSUPPORTEDThe platform is using a PCH that is not supported 
yet.
+
+**/
+EFI_STATUS
+HdmiDebugGpioInit (
+  VOID
+  );
+
+#endif
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
index a46d36b056..1f2950be72 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/OpenBoardPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  The main build description file for the KabylakeRvp3 board.
 #
-# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -171,6 +171,7 @@
   
GpioExpanderLib|$(PLATFORM_BOARD_PACKAGE)/Library/BaseGpioExpanderLib/BaseGpioExpanderLib.inf
   

[edk2-devel] [edk2-platforms] [PATCH V1 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib

2022-06-17 Thread Nate DeSimone
Add new SerialPortLib implementation that routes log
messages over the I2C bus included in the integrated
graphics HDMI port. Normally this I2C bus is used to
read the EDID data from the monitor. An unintended
but useful property of this interface is that is does
not require DMA to perform I/O. This means that this
interface can be used to perform I/O before DRAM is
initialized.

HDMI video output is a common feature of many laptops.
This makes the HDMI DDC bus the only I/O interface
that is often exposed outside of the laptop chassis
while simultaneously capable of being used in Pre-Memory.
Oddly, this makes it ideal for closed chassis debug.

Cc: Chasel Chiu 
Cc: Sai Chaganty 
Cc: Isaac Oram 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 
---
 .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc |   9 +
 .../GalagoPro3/OpenBoardPkgPcd.dsc|   9 +
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc  |   9 +
 .../DxeI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../DxeSmmI2cHdmiDebugSerialPortLib.c | 161 
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 826 ++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 324 +++
 .../I2cDebugPortProtocol.c| 194 
 .../I2cDebugPortProtocol.h|  77 ++
 .../I2cDebugPortTplDxe.c  |  44 +
 .../I2cDebugPortTplNull.c |  36 +
 .../I2cHdmiDebugSerialPortLib.c   | 201 +
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.c   | 112 +++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.h   | 146 
 .../PeiI2cHdmiDebugSerialPortLib.c| 237 +
 .../PeiI2cHdmiDebugSerialPortLib.inf  |  52 ++
 .../SecI2cHdmiDebugSerialPortLib.c| 134 +++
 .../SecI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../SmmI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec |  15 +-
 20 files changed, 2737 insertions(+), 2 deletions(-)
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/Gmbus.h
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortProtocol.h
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplDxe.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cDebugPortTplNull.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/I2cHdmiDebugSerialPortLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/IgfxI2c.h
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/PeiI2cHdmiDebugSerialPortLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SecI2cHdmiDebugSerialPortLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/SmmI2cHdmiDebugSerialPortLib.inf

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
index 02080aa864..822040c06f 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkgPcd.dsc
@@ -427,6 +427,15 @@
   ##
   gBoardModulePkgTokenSpaceGuid.PcdPs2KbMsEnable|1
   gBoardModulePkgTokenSpaceGuid.PcdSuperIoPciIsaBridgeDevice|{0x00, 0x00, 
0x1F, 0x00}
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGttMmAddress|0xDF00
+
+  ## Specifies the DDC I2C channel to claim as the HDMI debug port
+  #  The value is defined as below.
+  #  2: DDC channel B
+  #  3: DDC channel C
+  #  4: DDC channel D
+  # @Prompt DDC I2C channel to claim as the HDMI debug port
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdI2cHdmiDebugPortDdcI2cChannel|0x00  
#@todo - Set to correct value for VN7-572G
 
 [PcdsFixedAtBuild.IA32]
   ##
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkgPcd.dsc 

[edk2-devel] [edk2-platforms] [PATCH V1 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging

2022-06-17 Thread Nate DeSimone
Normally the HDMI DDC I2C bus is used to read the EDID
data from the monitor. An unintended but useful property
of this interface is that is does not require DMA to
perform I/O. This means that this interface can be used
to perform I/O before DRAM is initialized.

HDMI video output is a common feature of many laptops.
This makes the HDMI DDC bus the only I/O interface
that is often exposed outside of the laptop chassis
while simultaneously capable of being used in Pre-Memory.
Oddly... this makes it an ideal and novel way to perform
closed chassis debug.

This patch series adds a implementation of using the HDMI
DDC I2C Bus as a "poor man's" UART. This is accomplished
using the GMBUS that is part of the Intel HD Graphics
device. Accordingly, this implementation will only work
on systems with the HDMI port routed to the Intel
graphics device, and will not work on systems with HDMI
routed to a discrete GPU.

In order to use this implementation, one will also need
a BusPirate programmed with Nate's Custom Bus Pirate FW
for I2C Serial Debug. This firmware is available from:

https://github.com/nate-desimone/Bus_Pirate

This firmware interfaces with the I2C Bus and forwards
traffic from it to the FTDI USB Serial Adapter that is
integrated with the BusPirate. In combination, this
results in the HDMI port appearing to function as a
regular UART to the user.

If you would like to see this in action, I made a short
YouTube video:

https://www.youtube.com/watch?v=xe7cFhRsr80

Cc: Chasel Chiu 
Cc: Sai Chaganty 
Cc: Isaac Oram 
Cc: Eric Dong 
Cc: Liming Gao 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 

Nate DeSimone (5):
  KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib
  KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib
  KabylakeOpenBoardPkg: Add SecBoardInitLib
  BoardModulePkg: Add BdsSerialPortTerminalLib
  KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port

 .../Intel/BoardModulePkg/BoardModulePkg.dsc   |   3 +-
 .../BdsSerialPortTerminalLib.c| 114 +++
 .../BdsSerialPortTerminalLib.h|  53 ++
 .../BdsSerialPortTerminalLib.inf  |  49 ++
 .../PeiAspireVn7Dash572GInitPreMemLib.c   |   3 +-
 .../AspireVn7Dash572G/OpenBoardPkg.dsc|  11 +-
 .../AspireVn7Dash572G/OpenBoardPkgPcd.dsc |   9 +
 .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c |  13 +-
 .../GalagoPro3/OpenBoardPkg.dsc   |  88 +-
 .../GalagoPro3/OpenBoardPkg.fdf   |   6 +-
 .../GalagoPro3/OpenBoardPkgPcd.dsc|  39 +
 .../Include/Library/HdmiDebugGpioInitLib.h|  26 +
 .../PeiKabylakeRvp3InitPreMemLib.c|  13 +-
 .../KabylakeRvp3/OpenBoardPkg.dsc |  11 +-
 .../KabylakeRvp3/OpenBoardPkgPcd.dsc  |   9 +
 .../HdmiDebugGpioInitLib.c| 221 +
 .../HdmiDebugGpioInitLib.inf  |  42 +
 .../DxeI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../DxeSmmI2cHdmiDebugSerialPortLib.c | 161 
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.c | 826 ++
 .../Library/I2cHdmiDebugSerialPortLib/Gmbus.h | 324 +++
 .../I2cDebugPortProtocol.c| 194 
 .../I2cDebugPortProtocol.h|  77 ++
 .../I2cDebugPortTplDxe.c  |  44 +
 .../I2cDebugPortTplNull.c |  36 +
 .../I2cHdmiDebugSerialPortLib.c   | 201 +
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.c   | 112 +++
 .../I2cHdmiDebugSerialPortLib/IgfxI2c.h   | 146 
 .../PeiI2cHdmiDebugSerialPortLib.c| 237 +
 .../PeiI2cHdmiDebugSerialPortLib.inf  |  52 ++
 .../SecI2cHdmiDebugSerialPortLib.c| 134 +++
 .../SecI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../SmmI2cHdmiDebugSerialPortLib.inf  |  51 ++
 .../SecBoardInitLib/Ia32/SecBoardInit.nasm|  18 +
 .../Library/SecBoardInitLib/SecBoardInitLib.c |  35 +
 .../SecBoardInitLib/SecBoardInitLib.inf   |  39 +
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec |  33 +-
 37 files changed, 3498 insertions(+), 34 deletions(-)
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h
 create mode 100644 
Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Include/Library/HdmiDebugGpioInitLib.h
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/HdmiDebugGpioInitLib/HdmiDebugGpioInitLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeI2cHdmiDebugSerialPortLib.inf
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/I2cHdmiDebugSerialPortLib/DxeSmmI2cHdmiDebugSerialPortLib.c
 

[edk2-devel] [edk2-platforms] [PATCH V1 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib

2022-06-17 Thread Nate DeSimone
Adds a board-specific implementation of SecBoardInitLib.
This implementation will invoke the GPIO initialization
routine for the HDMI DDC Bus if the HDMI DDC Bus is being
used for debug log output. Adds PCDs for enable/disable
of using HDMI DDC I2C Bus as a Serial Port.

Cc: Chasel Chiu 
Cc: Sai Chaganty 
Cc: Isaac Oram 
Cc: Benjamin Doron 
Cc: Michael Kubacki 
Cc: Jeremy Soller 
Signed-off-by: Nate DeSimone 
---
 .../PeiAspireVn7Dash572GInitPreMemLib.c   |  3 +-
 .../AspireVn7Dash572G/OpenBoardPkg.dsc|  8 +++-
 .../BoardInitLib/PeiGalagoPro3InitPreMemLib.c | 13 ++-
 .../GalagoPro3/OpenBoardPkg.dsc   |  7 +++-
 .../PeiKabylakeRvp3InitPreMemLib.c| 13 ++-
 .../KabylakeRvp3/OpenBoardPkg.dsc |  8 +++-
 .../SecBoardInitLib/Ia32/SecBoardInit.nasm| 18 +
 .../Library/SecBoardInitLib/SecBoardInitLib.c | 35 +
 .../SecBoardInitLib/SecBoardInitLib.inf   | 39 +++
 .../KabylakeOpenBoardPkg/OpenBoardPkg.dec | 18 +
 10 files changed, 137 insertions(+), 25 deletions(-)
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/Ia32/SecBoardInit.nasm
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.c
 create mode 100644 
Platform/Intel/KabylakeOpenBoardPkg/Library/SecBoardInitLib/SecBoardInitLib.inf

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
 
b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
index d17685be82..1c9a65399b 100644
--- 
a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
+++ 
b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/PeiAspireVn7Dash572GInitPreMemLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -251,7 +251,6 @@ AspireVn7Dash572GBoardDebugInit (
   ///
   /// Do Early PCH init
   ///
-  EarlySiliconInit ();
   LpcInit ();
 
   // NB: MinPlatform specification defines platform initialisation flow.
diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc 
b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
index ec5591e00f..261f141056 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/OpenBoardPkg.dsc
@@ -209,8 +209,12 @@
   # Platform Package
   ###
   
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
-  
SecBoardInitLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SecBoardInitLibNull/SecBoardInitLibNull.inf
-  
SiliconPolicyUpdateLib|MinPlatformPkg/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+  
SiliconPolicyUpdateLib|$(PLATFORM_PACKAGE)/PlatformInit/Library/SiliconPolicyUpdateLibNull/SiliconPolicyUpdateLibNull.inf
+
+  ###
+  # Board-specific
+  ###
+  
SecBoardInitLib|$(PLATFORM_BOARD_PACKAGE)/Library/SecBoardInitLib/SecBoardInitLib.inf
 
 [LibraryClasses.common.PEI_CORE]
   ###
diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
index f4833149f3..051dac0b20 100644
--- 
a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
+++ 
b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/Library/BoardInitLib/PeiGalagoPro3InitPreMemLib.c
@@ -1,7 +1,7 @@
 /** @file
   System 76 GalagoPro3 board pre-memory initialization.
 
-Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -167,9 +167,9 @@ SioInit (
 }
 
 /**
-  Configues the IC2 Controller on which GPIO Expander Communicates.
-  This Function is to enable the I2CGPIOExapanderLib to programm the Gpios
-  Complete intilization will be done in later Stage
+  Configures the IC2 Controller on which GPIO Expander Communicates.
+  This Function is to enable the I2CGPIOExapanderLib to program the Gpios
+  Complete initialization will be done in later Stage
 
 **/
 VOID
@@ -227,10 +227,6 @@ GalagoPro3BoardDebugInit (
   VOID
   )
 {
-  ///
-  /// Do Early PCH init
-  ///
-  EarlySiliconInit ();
   return EFI_SUCCESS;
 }
 
@@ -242,4 +238,3 @@ GalagoPro3BoardBootModeDetect (
 {
   return BOOT_WITH_FULL_CONFIGURATION;
 }
-
diff --git 

Re: [edk2-devel] [PATCH v2 1/1] ArmPlatformPkg: Remove overly verbose DEBUG lines in LcdGraphicsBlt

2022-06-17 Thread Rebecca Cran

It looks like this hasn't been pushed. Could someone commit/push it please?


--

Rebecca Cran


On 5/16/22 10:26, Sami Mujawar wrote:

Hi Rebecca,

Thank you for this patch.
These changes look good to me.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar 



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




[edk2-devel] [PATCH 3/3] OvmfPkg: Initialize NvVarStore with Configuration FV in Td guest

2022-06-17 Thread Min Xu
From: Min M Xu 

QEMU command option -pflash is not supported in Tdx guest. When Tdx guest
is booted, EmuVariableFvbRuntimeDxe driver is loaded and the NvVarStore
is initialized with empty content. This patch is to initialize the
NvVarStore with the content of Configuration FV (CFV).

Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 
---
 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c   | 19 +++
 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c 
b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
index 4fc715dc3681..96895272d806 100644
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
@@ -717,6 +717,8 @@ FvbInitialize (
   EFI_HANDLEHandle;
   EFI_PHYSICAL_ADDRESS  Address;
   RETURN_STATUS PcdStatus;
+  UINT8 *CfvBase;
+  UINT32CfvSize;
 
   DEBUG ((DEBUG_INFO, "EMU Variable FVB Started\n"));
 
@@ -774,6 +776,23 @@ FvbInitialize (
 
   mEmuVarsFvb.BufferPtr = Ptr;
 
+  //
+  // In Tdx guest the VarNvStore content should be initialized by the 
Configuration FV (CFV).
+  // Integrity of the CFV has been validated by TdxValidateCfv 
(@PlatformInitLib)
+  //
+  if (TdIsEnabled ()) {
+CfvBase = (UINT8 *)(UINTN)PcdGet32 (PcdCfvBase);
+CfvSize = (UINT32)PcdGet32 (PcdCfvRawDataSize);
+
+if (CfvSize > mEmuVarsFvb.Size) {
+  DEBUG ((DEBUG_ERROR, "Size of CFV is larger than the EMU Variable 
FVB.\n"));
+  ASSERT (FALSE);
+} else {
+  CopyMem (Ptr, CfvBase, CfvSize);
+  Initialize = FALSE;
+}
+  }
+
   //
   // Initialize the main FV header and variable store header
   //
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf 
b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
index 0811545cf7b3..15e8e673e8a0 100644
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
@@ -56,6 +56,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+  gUefiOvmfPkgTokenSpaceGuid.PcdCfvBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH 2/3] OvmfPkg: Validate Cfv integrity in Tdx guest

2022-06-17 Thread Min Xu
From: Min M Xu 

Validate Configurtion FV (CFV) in Tdx guest.

Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 
---
 OvmfPkg/Sec/SecMain.c   | 8 
 OvmfPkg/Sec/SecMain.inf | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 1167d22a68cc..f6c00b8dab96 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -768,6 +768,14 @@ SecCoreStartupWithStack (
 if (ProcessTdxHobList () != EFI_SUCCESS) {
   CpuDeadLoop ();
 }
+
+//
+// Config FV (Cfv) contains the configuration information and its integrity
+// should be validated.
+//
+if (!TdxValidateCfv ((UINT8 *)(UINTN)FixedPcdGet32 (PcdCfvBase), 
FixedPcdGet32 (PcdCfvRawDataSize))) {
+  CpuDeadLoop ();
+}
   }
 
  #endif
diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 561a840f29c5..ae0094a15eda 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -84,6 +84,8 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBackupBase
   gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageSize
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdCfvBase
+  gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize
 
 [FeaturePcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH 1/3] OvmfPkg: Move TdxValidateCfv from PeilessStartupLib to PlatformInitLib

2022-06-17 Thread Min Xu
From: Min M Xu 

TdxValidateCfv validates the integrity of Configuration FV (CFV). It was
implemented in PeilessStartupLib which is included in IntelTdxX64.

In OvmfPkgX64 we should validate CFV as well. So it is moved from
PeilessStartupLib to PlatformInitLib so that it can be called in both
OvmfPkgX64 and IntelTdxX64.

Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 
---
 OvmfPkg/Include/Library/PlatformInitLib.h |  17 ++
 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c  | 153 --
 .../PeilessStartupInternal.h  |  17 --
 OvmfPkg/Library/PlatformInitLib/IntelTdx.c| 153 ++
 4 files changed, 170 insertions(+), 170 deletions(-)

diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h 
b/OvmfPkg/Include/Library/PlatformInitLib.h
index 2987a367cc9c..a3acfb1fb196 100644
--- a/OvmfPkg/Include/Library/PlatformInitLib.h
+++ b/OvmfPkg/Include/Library/PlatformInitLib.h
@@ -234,4 +234,21 @@ PlatformTdxPublishRamRegions (
   VOID
   );
 
+/**
+  Check the integrity of CFV data.
+
+  @param[in] TdxCfvBase - A pointer to CFV header
+  @param[in] TdxCfvSize - CFV data size
+
+  @retval  TRUE   - The CFV data is valid.
+  @retval  FALSE  - The CFV data is invalid.
+
+**/
+BOOLEAN
+EFIAPI
+TdxValidateCfv (
+  IN UINT8   *TdxCfvBase,
+  IN UINT32  TdxCfvSize
+  );
+
 #endif // PLATFORM_INIT_LIB_H_
diff --git a/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c 
b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
index 484fd21057c8..216c413caad5 100644
--- a/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
+++ b/OvmfPkg/Library/PeilessStartupLib/IntelTdx.c
@@ -7,8 +7,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -37,157 +35,6 @@ typedef struct {
 
 #pragma pack()
 
-/**
-  Check padding data all bit should be 1.
-
-  @param[in] Buffer - A pointer to buffer header
-  @param[in] BufferSize - Buffer size
-
-  @retval  TRUE   - The padding data is valid.
-  @retval  TRUE  - The padding data is invalid.
-
-**/
-BOOLEAN
-CheckPaddingData (
-  IN UINT8   *Buffer,
-  IN UINT32  BufferSize
-  )
-{
-  UINT32  index;
-
-  for (index = 0; index < BufferSize; index++) {
-if (Buffer[index] != 0xFF) {
-  return FALSE;
-}
-  }
-
-  return TRUE;
-}
-
-/**
-  Check the integrity of CFV data.
-
-  @param[in] TdxCfvBase - A pointer to CFV header
-  @param[in] TdxCfvSize - CFV data size
-
-  @retval  TRUE   - The CFV data is valid.
-  @retval  FALSE  - The CFV data is invalid.
-
-**/
-BOOLEAN
-EFIAPI
-TdxValidateCfv (
-  IN UINT8   *TdxCfvBase,
-  IN UINT32  TdxCfvSize
-  )
-{
-  UINT16 Checksum;
-  UINTN  VariableBase;
-  UINT32 VariableOffset;
-  UINT32 VariableOffsetBeforeAlign;
-  EFI_FIRMWARE_VOLUME_HEADER *CfvFvHeader;
-  VARIABLE_STORE_HEADER  *CfvVariableStoreHeader;
-  AUTHENTICATED_VARIABLE_HEADER  *VariableHeader;
-
-  static EFI_GUID  FvHdrGUID   = EFI_SYSTEM_NV_DATA_FV_GUID;
-  static EFI_GUID  VarStoreHdrGUID = EFI_AUTHENTICATED_VARIABLE_GUID;
-
-  VariableOffset = 0;
-
-  if (TdxCfvBase == NULL) {
-DEBUG ((DEBUG_ERROR, "TDX CFV: CFV pointer is NULL\n"));
-return FALSE;
-  }
-
-  //
-  // Verify the header zerovetor, filesystemguid,
-  // revision, signature, attributes, fvlength, checksum
-  // HeaderLength cannot be an odd number
-  //
-  CfvFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)TdxCfvBase;
-
-  if ((!IsZeroBuffer (CfvFvHeader->ZeroVector, 16)) ||
-  (!CompareGuid (, >FileSystemGuid)) ||
-  (CfvFvHeader->Signature != EFI_FVH_SIGNATURE) ||
-  (CfvFvHeader->Attributes != 0x4feff) ||
-  (CfvFvHeader->Revision != EFI_FVH_REVISION) ||
-  (CfvFvHeader->FvLength != TdxCfvSize)
-  )
-  {
-DEBUG ((DEBUG_ERROR, "TDX CFV: Basic FV headers were invalid\n"));
-return FALSE;
-  }
-
-  //
-  // Verify the header checksum
-  //
-  Checksum = CalculateSum16 ((VOID *)CfvFvHeader, CfvFvHeader->HeaderLength);
-
-  if (Checksum != 0) {
-DEBUG ((DEBUG_ERROR, "TDX CFV: FV checksum was invalid\n"));
-return FALSE;
-  }
-
-  //
-  // Verify the header signature, size, format, state
-  //
-  CfvVariableStoreHeader = (VARIABLE_STORE_HEADER *)(TdxCfvBase + 
CfvFvHeader->HeaderLength);
-  if ((!CompareGuid (, >Signature)) ||
-  (CfvVariableStoreHeader->Format != VARIABLE_STORE_FORMATTED) ||
-  (CfvVariableStoreHeader->State != VARIABLE_STORE_HEALTHY) ||
-  (CfvVariableStoreHeader->Size > (CfvFvHeader->FvLength - 
CfvFvHeader->HeaderLength)) ||
-  (CfvVariableStoreHeader->Size < sizeof (VARIABLE_STORE_HEADER))
-  )
-  {
-DEBUG ((DEBUG_ERROR, "TDX CFV: Variable Store header was invalid\n"));
-return FALSE;
-  }
-
-  //
-  // Verify the header startId, state
-  // Verify data to the end
-  //
-  VariableBase = (UINTN)TdxCfvBase + CfvFvHeader->HeaderLength + sizeof 
(VARIABLE_STORE_HEADER);
-  while 

[edk2-devel] [PATCH 0/3] Enable Secure-Boot in Tdx guest

2022-06-17 Thread Min Xu
Secure-Boot related variables include the PK/KEK/DB/DBX and they are
stored in NvVarStore (OVMF_VARS.fd). But QEMU command option -pflash is
not supported in Tdx guest. So when Tdx guest is booted,
EmuVariableFvbRuntimeDxe driver is loaded and the NvVarStore is
initialized with empty content. This patch-set is to initialize the
NvVarStore with the content of Configuration FV (CFV).

Before the NvVarStore is initialized with the content of CFV, CFV's
integrity should be validated. So patch #1/2 are imported to do such
validation.

Code: https://github.com/mxu9/edk2/tree/secure-boot.v1

Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 

*** BLURB HERE ***

Min M Xu (3):
  OvmfPkg: Move TdxValidateCfv from PeilessStartupLib to PlatformInitLib
  OvmfPkg: Validate Cfv integrity in Tdx guest
  OvmfPkg: Initialize NvVarStore with Configuration FV in Td guest

 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c|  19 +++
 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf  |   2 +
 OvmfPkg/Include/Library/PlatformInitLib.h |  17 ++
 OvmfPkg/Library/PeilessStartupLib/IntelTdx.c  | 153 --
 .../PeilessStartupInternal.h  |  17 --
 OvmfPkg/Library/PlatformInitLib/IntelTdx.c| 153 ++
 OvmfPkg/Sec/SecMain.c |   8 +
 OvmfPkg/Sec/SecMain.inf   |   2 +
 8 files changed, 201 insertions(+), 170 deletions(-)

-- 
2.29.2.windows.2



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




[edk2-devel] [PATCH] NetworkPkg/HttpBootDxe: Add Support for HTTP Boot Basic Authentication

2022-06-17 Thread Saloni Kasbekar
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2504

Add support for TLS Client Authentication using Basic Authentication
for HTTP Boot

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 MdePkg/Include/IndustryStandard/Http11.h   |  8 +++
 MdePkg/Include/Protocol/HttpBootCallback.h |  6 +-
 NetworkPkg/HttpBootDxe/HttpBootClient.c| 84 +-
 NetworkPkg/HttpBootDxe/HttpBootClient.h|  6 +-
 NetworkPkg/HttpBootDxe/HttpBootDxe.h   |  6 ++
 NetworkPkg/HttpBootDxe/HttpBootImpl.c  | 23 +-
 6 files changed, 128 insertions(+), 5 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Http11.h 
b/MdePkg/Include/IndustryStandard/Http11.h
index f1f113e04b..2137ef1f1a 100644
--- a/MdePkg/Include/IndustryStandard/Http11.h
+++ b/MdePkg/Include/IndustryStandard/Http11.h
@@ -204,6 +204,14 @@
 ///
 #define HTTP_HEADER_IF_NONE_MATCH  "If-None-Match"
 
+///
+/// The WWW-Authenticate Response Header
+/// If a server receives a request for an access-protected object, and an
+/// acceptable Authorization header is not sent, the server responds with
+/// a "401 Unauthorized" status code, and a WWW-Authenticate header.
+///
+#define HTTP_HEADER_WWW_AUTHENTICATE  "WWW-Authenticate"
+
 ///
 /// Authorization Request Header
 /// The Authorization field value consists of credentials
diff --git a/MdePkg/Include/Protocol/HttpBootCallback.h 
b/MdePkg/Include/Protocol/HttpBootCallback.h
index 926f6c1b30..b56c631b1f 100644
--- a/MdePkg/Include/Protocol/HttpBootCallback.h
+++ b/MdePkg/Include/Protocol/HttpBootCallback.h
@@ -32,7 +32,7 @@ typedef enum {
   ///
   HttpBootDhcp6,
   ///
-  /// Data points to an EFI_HTTP_MESSAGE structure, whichcontians a HTTP 
request message
+  /// Data points to an EFI_HTTP_MESSAGE structure, which contains a HTTP 
request message
   /// to be transmitted.
   ///
   HttpBootHttpRequest,
@@ -46,6 +46,10 @@ typedef enum {
   /// buffer of the entity body data.
   ///
   HttpBootHttpEntityBody,
+  ///
+  /// Data points to the authentication information to provide to the HTTP 
server.
+  ///
+  HttpBootHttpAuthInfo,
   HttpBootTypeMax
 } EFI_HTTP_BOOT_CALLBACK_DATA_TYPE;
 
diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 62e87238fe..448141fb7c 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -922,6 +922,7 @@ HttpBootGetBootFileCallback (
   @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the 
current directory entry.
BufferSize has been updated with the size 
needed to complete
the request.
+  @retval EFI_ACCESS_DENIEDThe server needs to authenticate the client.
   @retval Others   Unexpected error happened.
 
 **/
@@ -951,6 +952,9 @@ HttpBootGetBootFile (
   CHAR16   *Url;
   BOOLEAN  IdentityMode;
   UINTNReceivedSize;
+  CHAR8BaseAuthValue[80];
+  EFI_HTTP_HEADER  *HttpHeader;
+  CHAR8*Data;
 
   ASSERT (Private != NULL);
   ASSERT (Private->HttpCreated);
@@ -1009,8 +1013,9 @@ HttpBootGetBootFile (
   //   Host
   //   Accept
   //   User-Agent
+  //   [Authorization]
   //
-  HttpIoHeader = HttpIoCreateHeader (3);
+  HttpIoHeader = HttpIoCreateHeader ((Private->AuthData != NULL) ? 4 : 3);
   if (HttpIoHeader == NULL) {
 Status = EFI_OUT_OF_RESOURCES;
 goto ERROR_2;
@@ -1063,6 +1068,35 @@ HttpBootGetBootFile (
 goto ERROR_3;
   }
 
+  //
+  // Add HTTP header field 4: Authorization
+  //
+  if (Private->AuthData != NULL) {
+ASSERT (HttpIoHeader->MaxHeaderCount == 4);
+
+if ((Private->AuthScheme != NULL) && (CompareMem (Private->AuthScheme, 
"Basic", 5) != 0)) {
+  Status = EFI_UNSUPPORTED;
+  goto ERROR_3;
+}
+
+AsciiSPrint (
+  BaseAuthValue,
+  sizeof (BaseAuthValue),
+  "%a %a",
+  "Basic",
+  Private->AuthData
+  );
+
+Status = HttpIoSetHeader (
+   HttpIoHeader,
+   HTTP_HEADER_AUTHORIZATION,
+   BaseAuthValue
+   );
+if (EFI_ERROR (Status)) {
+  goto ERROR_3;
+}
+  }
+
   //
   // 2.2 Build the rest of HTTP request info.
   //
@@ -,6 +1145,7 @@ HttpBootGetBootFile (
 goto ERROR_4;
   }
 
+  Data   = NULL;
   Status = HttpIoRecvResponse (
  >HttpIo,
  TRUE,
@@ -1121,6 +1156,53 @@ HttpBootGetBootFile (
   StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode;
   HttpBootPrintErrorMessage (StatusCode);
   Status = ResponseData->Status;
+  if ((StatusCode == HTTP_STATUS_401_UNAUTHORIZED) || \
+  (StatusCode == HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED))
+  {
+//
+// Server indicates the user has to provide a user-id and password as 
a means of identification.
+//
+if 

Re: [edk2-devel] Windows 10 build failing

2022-06-17 Thread M.T.
Thank you Andrew

That did it!

xp

On Fri, Jun 17, 2022 at 2:11 PM Andrew Fish  wrote:

>
>
> On Jun 17, 2022, at 9:55 AM, M.T.  wrote:
>
> I think I'm getting somewhere now.
>
> I set everything up and I started getting a consistent error (see logfile
> from my last email)
> I had to comment out BrDummyMalloc from BrotliDecUefiSupport.h, and now I
> am able to build MdeModulePkg.
>
> Now one other error I'm dealing with:
> error 4000: Instance of library class [RegisterFilterLib] is not found
> in
> [c:\users\maciej\uefi\edk2\MdePkg\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf
>
>
> That library dependency should be resolved by including
> MdePkg/MdeLibs.dsc.inc in the dSC file?
>
> /Volumes/Case/edk2(master)*>*git grep "MdePkg/MdeLibs.dsc.inc"
> ArmPkg/ArmPkg.dsc:36:!include *MdePkg/MdeLibs.dsc.inc*
> ArmPlatformPkg/ArmPlatformPkg.dsc:36:!include *MdePkg/MdeLibs.dsc.inc*
> ArmVirtPkg/ArmVirtCloudHv.dsc:60:!include *MdePkg/MdeLibs.dsc.inc*
> ArmVirtPkg/ArmVirtKvmTool.dsc:39:!include *MdePkg/MdeLibs.dsc.inc*
> ArmVirtPkg/ArmVirtQemu.dsc:53:!include *MdePkg/MdeLibs.dsc.inc*
> ArmVirtPkg/ArmVirtQemuKernel.dsc:51:!include *MdePkg/MdeLibs.dsc.inc*
> ArmVirtPkg/ArmVirtXen.dsc:28:!include *MdePkg/MdeLibs.dsc.inc*
> CryptoPkg/CryptoPkg.dsc:56:!include *MdePkg/MdeLibs.dsc.inc*
> DynamicTablesPkg/DynamicTablesPkg.dsc:23:!include *MdePkg/MdeLibs.dsc.inc*
> EmbeddedPkg/EmbeddedPkg.dsc:44:!include *MdePkg/MdeLibs.dsc.inc*
> EmulatorPkg/EmulatorPkg.dsc:47:!include *MdePkg/MdeLibs.dsc.inc*
> FatPkg/FatPkg.dsc:29:!include *MdePkg/MdeLibs.dsc.inc*
> FmpDevicePkg/FmpDevicePkg.dsc:41:!include *MdePkg/MdeLibs.dsc.inc*
> IntelFsp2Pkg/IntelFsp2Pkg.dsc:19:!include *MdePkg/MdeLibs.dsc.inc*
> IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc:75:!include
> *MdePkg/MdeLibs.dsc.inc*
> IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc:19:!include
> *MdePkg/MdeLibs.dsc.inc*
> MdeModulePkg/MdeModulePkg.dsc:22:!include *MdePkg/MdeLibs.dsc.inc*
> MdePkg/MdeLibs.dsc.inc:5:# by using "!include *MdePkg/MdeLibs.dsc.inc*"
> to specify the library instances
> MdePkg/MdePkg.dsc:24:!include *MdePkg/MdeLibs.dsc.inc*
> NetworkPkg/NetworkPkg.dsc:23:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/AmdSev/AmdSevX64.dsc:110:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/Bhyve/BhyveX64.dsc:116:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/CloudHv/CloudHvX64.dsc:126:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/IntelTdx/IntelTdxX64.dsc:108:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/Microvm/MicrovmX64.dsc:124:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/OvmfPkgIa32.dsc:122:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/OvmfPkgIa32X64.dsc:126:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/OvmfPkgX64.dsc:139:!include *MdePkg/MdeLibs.dsc.inc*
> OvmfPkg/OvmfXen.dsc:116:!include *MdePkg/MdeLibs.dsc.inc*
> PcAtChipsetPkg/PcAtChipsetPkg.dsc:21:!include *MdePkg/MdeLibs.dsc.inc*
> RedfishPkg/RedfishPkg.dsc:21:!include *MdePkg/MdeLibs.dsc.inc*
> SecurityPkg/SecurityPkg.dsc:20:!include *MdePkg/MdeLibs.dsc.inc*
> ShellPkg/ShellPkg.dsc:22:!include *MdePkg/MdeLibs.dsc.inc*
> SignedCapsulePkg/SignedCapsulePkg.dsc:20:!include *MdePkg/MdeLibs.dsc.inc*
> SourceLevelDebugPkg/SourceLevelDebugPkg.dsc:26:!include
> *MdePkg/MdeLibs.dsc.inc*
> StandaloneMmPkg/StandaloneMmPkg.dsc:36:!include *MdePkg/MdeLibs.dsc.inc*
> UefiCpuPkg/UefiCpuPkg.dsc:24:!include *MdePkg/MdeLibs.dsc.inc*
> UefiPayloadPkg/UefiPayloadPkg.dsc:150:!include *MdePkg/MdeLibs.dsc.inc*
> UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc:22:!include
> *MdePkg/MdeLibs.dsc.inc*
>
> /Volumes/Case/edk2(master)*>*cat MdePkg/MdeLibs.dsc.inc
> ## @file
> # Mde DSC include file for [LibraryClasses*] section of all Architectures.
> #
> # This file can be included to the [LibraryClasses*] section(s) of a
> platform DSC file
> # by using "!include MdePkg/MdeLibs.dsc.inc" to specify the library
> instances
> # of some EDKII basic/common library classes.
> #
> # Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
> #
> #SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> ##
>
> [LibraryClasses]
>
> RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
>   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>
> SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf
>
>
> Thanks,
>
> Andrew Fish
>
> I saw some posts that this was resolved back in 2021, yet I'm still
> getting hit with it.
> Any advice on how to resolve this?
>
> Thank you
> xp
>
>
>
> On Fri, Jun 17, 2022 at 9:58 AM M.T. via groups.io  gmail@groups.io> wrote:
>
>> I tried all your suggestions, but it looks like still no cigar.
>>
>> I deleted and recloned the repo with --recursive, built emulatorPkg,
>> which worked fine, then tried MdeModulePkg
>> I get the same error on both my setups, real and VM.
>> I ran the build with -n 1 and -j after deleting the Build directory,
>> please find the log file attached.
>>
>> Command history is as follows:
>> git clone --recursive https://github.com/tianocore/edk2.git

Re: [edk2-devel] Windows 10 build failing

2022-06-17 Thread Andrew Fish via groups.io


> On Jun 17, 2022, at 9:55 AM, M.T.  wrote:
> 
> I think I'm getting somewhere now.
> 
> I set everything up and I started getting a consistent error (see logfile 
> from my last email)
> I had to comment out BrDummyMalloc from BrotliDecUefiSupport.h, and now I am 
> able to build MdeModulePkg.
> 
> Now one other error I'm dealing with:
> error 4000: Instance of library class [RegisterFilterLib] is not found
> in 
> [c:\users\maciej\uefi\edk2\MdePkg\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf
> 

That library dependency should be resolved by including MdePkg/MdeLibs.dsc.inc 
in the dSC file?

/Volumes/Case/edk2(master)>git grep "MdePkg/MdeLibs.dsc.inc"
ArmPkg/ArmPkg.dsc:36:!include MdePkg/MdeLibs.dsc.inc
ArmPlatformPkg/ArmPlatformPkg.dsc:36:!include MdePkg/MdeLibs.dsc.inc
ArmVirtPkg/ArmVirtCloudHv.dsc:60:!include MdePkg/MdeLibs.dsc.inc
ArmVirtPkg/ArmVirtKvmTool.dsc:39:!include MdePkg/MdeLibs.dsc.inc
ArmVirtPkg/ArmVirtQemu.dsc:53:!include MdePkg/MdeLibs.dsc.inc
ArmVirtPkg/ArmVirtQemuKernel.dsc:51:!include MdePkg/MdeLibs.dsc.inc
ArmVirtPkg/ArmVirtXen.dsc:28:!include MdePkg/MdeLibs.dsc.inc
CryptoPkg/CryptoPkg.dsc:56:!include MdePkg/MdeLibs.dsc.inc
DynamicTablesPkg/DynamicTablesPkg.dsc:23:!include MdePkg/MdeLibs.dsc.inc
EmbeddedPkg/EmbeddedPkg.dsc:44:!include MdePkg/MdeLibs.dsc.inc
EmulatorPkg/EmulatorPkg.dsc:47:!include MdePkg/MdeLibs.dsc.inc
FatPkg/FatPkg.dsc:29:!include MdePkg/MdeLibs.dsc.inc
FmpDevicePkg/FmpDevicePkg.dsc:41:!include MdePkg/MdeLibs.dsc.inc
IntelFsp2Pkg/IntelFsp2Pkg.dsc:19:!include MdePkg/MdeLibs.dsc.inc
IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc:75:!include MdePkg/MdeLibs.dsc.inc
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc:19:!include MdePkg/MdeLibs.dsc.inc
MdeModulePkg/MdeModulePkg.dsc:22:!include MdePkg/MdeLibs.dsc.inc
MdePkg/MdeLibs.dsc.inc:5:# by using "!include MdePkg/MdeLibs.dsc.inc" to 
specify the library instances
MdePkg/MdePkg.dsc:24:!include MdePkg/MdeLibs.dsc.inc
NetworkPkg/NetworkPkg.dsc:23:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/AmdSev/AmdSevX64.dsc:110:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/Bhyve/BhyveX64.dsc:116:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/CloudHv/CloudHvX64.dsc:126:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/IntelTdx/IntelTdxX64.dsc:108:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/Microvm/MicrovmX64.dsc:124:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/OvmfPkgIa32.dsc:122:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/OvmfPkgIa32X64.dsc:126:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/OvmfPkgX64.dsc:139:!include MdePkg/MdeLibs.dsc.inc
OvmfPkg/OvmfXen.dsc:116:!include MdePkg/MdeLibs.dsc.inc
PcAtChipsetPkg/PcAtChipsetPkg.dsc:21:!include MdePkg/MdeLibs.dsc.inc
RedfishPkg/RedfishPkg.dsc:21:!include MdePkg/MdeLibs.dsc.inc
SecurityPkg/SecurityPkg.dsc:20:!include MdePkg/MdeLibs.dsc.inc
ShellPkg/ShellPkg.dsc:22:!include MdePkg/MdeLibs.dsc.inc
SignedCapsulePkg/SignedCapsulePkg.dsc:20:!include MdePkg/MdeLibs.dsc.inc
SourceLevelDebugPkg/SourceLevelDebugPkg.dsc:26:!include MdePkg/MdeLibs.dsc.inc
StandaloneMmPkg/StandaloneMmPkg.dsc:36:!include MdePkg/MdeLibs.dsc.inc
UefiCpuPkg/UefiCpuPkg.dsc:24:!include MdePkg/MdeLibs.dsc.inc
UefiPayloadPkg/UefiPayloadPkg.dsc:150:!include MdePkg/MdeLibs.dsc.inc
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc:22:!include MdePkg/MdeLibs.dsc.inc

/Volumes/Case/edk2(master)>cat MdePkg/MdeLibs.dsc.inc
## @file
# Mde DSC include file for [LibraryClasses*] section of all Architectures.
#
# This file can be included to the [LibraryClasses*] section(s) of a platform 
DSC file
# by using "!include MdePkg/MdeLibs.dsc.inc" to specify the library instances
# of some EDKII basic/common library classes.
#
# Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
#
#SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[LibraryClasses]
  
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
  
SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf


Thanks,

Andrew Fish

> I saw some posts that this was resolved back in 2021, yet I'm still getting 
> hit with it.
> Any advice on how to resolve this?
> 
> Thank you
> xp
> 
> 
> 
> On Fri, Jun 17, 2022 at 9:58 AM M.T. via groups.io  
> mailto:gmail@groups.io>> wrote:
> I tried all your suggestions, but it looks like still no cigar.
> 
> I deleted and recloned the repo with --recursive, built emulatorPkg, which 
> worked fine, then tried MdeModulePkg
> I get the same error on both my setups, real and VM.
> I ran the build with -n 1 and -j after deleting the Build directory, please 
> find the log file attached.
> 
> Command history is as follows:
> git clone --recursive https://github.com/tianocore/edk2.git 
> 
> cd edk2
> git submodule update --init
> edksetup.bat Rebuild
> // edit target.txt and change to VS2017, X64 and MdeModulePkg/MdeModulePkg.dsc
> build -n 1 -j logfile.txt
> 
> Thank you
> xp
> 
> 
> On Thu, Jun 16, 2022 at 11:05 PM 

Re: [edk2-devel] Windows 10 build failing

2022-06-17 Thread M.T.
I think I'm getting somewhere now.

I set everything up and I started getting a consistent error (see logfile
from my last email)
I had to comment out BrDummyMalloc from BrotliDecUefiSupport.h, and now I
am able to build MdeModulePkg.

Now one other error I'm dealing with:
error 4000: Instance of library class [RegisterFilterLib] is not found
in
[c:\users\maciej\uefi\edk2\MdePkg\Library\BaseIoLibIntrinsic\BaseIoLibIntrinsic.inf

I saw some posts that this was resolved back in 2021, yet I'm still getting
hit with it.
Any advice on how to resolve this?

Thank you
xp



On Fri, Jun 17, 2022 at 9:58 AM M.T. via groups.io  wrote:

> I tried all your suggestions, but it looks like still no cigar.
>
> I deleted and recloned the repo with --recursive, built emulatorPkg, which
> worked fine, then tried MdeModulePkg
> I get the same error on both my setups, real and VM.
> I ran the build with -n 1 and -j after deleting the Build directory,
> please find the log file attached.
>
> Command history is as follows:
> git clone --recursive https://github.com/tianocore/edk2.git
> cd edk2
> git submodule update --init
> edksetup.bat Rebuild
> // edit target.txt and change to VS2017, X64 and
> MdeModulePkg/MdeModulePkg.dsc
> build -n 1 -j logfile.txt
>
> Thank you
> xp
>
>
> On Thu, Jun 16, 2022 at 11:05 PM Kilian Kegel 
> wrote:
>
>>
>>
>> git clone --recursive https://github.com/tianocore/edk2.git
>>
>>
>>
>> That works!
>>
>> You forgot “—recursive”
>>
>>
>>
>>
>>
>> *From: *M.T. 
>> *Sent: *Thursday, June 16, 2022 10:19 PM
>> *To: *devel@edk2.groups.io; Maciej T. 
>> *Cc: *Kinney, Michael D 
>> *Subject: *Re: [edk2-devel] Windows 10 build failing
>>
>>
>>
>> I spun up a windows 10 pro VM and started from scratch, now I'm
>> consistently hitting a redefinition error.
>>
>> EmulatorPkg built, so it is something with this Brotoli Library
>>
>>
>>
>> Building ...
>> c:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib.inf
>> [X64]
>> "C:\Program Files (x86)\Microsoft Visual
>> Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64\cl.exe"
>> /Foc:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\OUTPUT\brotli\c\common\
>> /showIncludes /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy
>> /FIAutoGen.h /EHs-c- /GR- /GF /Z7 /Gw
>> /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\include\brotli
>>  
>> /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\dec
>>  
>> /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\common
>>  /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib
>>  
>> /Ic:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\DEBUG
>>  /Ic:\users\user\uefi\edk2\MdePkg  /Ic:\users\user\uefi\edk2\MdePkg\Include
>>  /Ic:\users\user\uefi\edk2\MdePkg\Test\UnitTest\Include
>>  /Ic:\users\user\uefi\edk2\MdePkg\Include\X64
>>  /Ic:\users\user\uefi\edk2\MdeModulePkg
>>  /Ic:\users\user\uefi\edk2\MdeModulePkg\Include
>>  
>> /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\include
>> @c:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\OUTPUT\cc_resp_3.txt
>> transform.c
>> dictionary.c
>> C:\Program Files (x86)\Windows
>> Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(103): error C2220:
>> warning treated as error - no 'object' file generated
>> C:\Program Files (x86)\Windows
>> Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(103): warning C4559:
>> 'BrDummyMalloc': redefinition; the function gains __declspec(restrict)
>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
>> Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64\cl.exe"' :
>> return code '0x2'
>> Stop.
>>
>>
>> build.py...
>>  : error 7000: Failed to execute command
>> C:\Program Files (x86)\Microsoft Visual
>> Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\nmake.exe
>> /nologo tbuild
>> [c:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib]
>>
>>
>> build.py...
>>  : error F002: Failed to build module
>>
>> c:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib.inf
>> [X64, VS2017, DEBUG]
>>
>>
>>
>> xp
>>
>>
>>
>> On Thu, Jun 16, 2022 at 3:06 PM M.T. via groups.io > gmail@groups.io> wrote:
>>
>> I get NASM version 2.15 compiled on Jun 27 2020
>>
>>
>>
>> I bumped it up to the same version you have just in case, several
>> attempts in build and recompiling results in the original error where
>> BrotliCustomDecompressLib fails, but I also now see these two:
>>
>>
>>
>> Building ...
>> 

Re: [edk2-devel] Windows 10 build failing

2022-06-17 Thread Kilian Kegel
I checkout latest stable tag: edk2-stable202205
I use VS2015 toolchain.
It works on my side…

From: M.T.
Sent: Friday, June 17, 2022 03:58 PM
To: Kilian Kegel
Cc: devel@edk2.groups.io; Kinney, Michael 
D
Subject: Re: [edk2-devel] Windows 10 build failing

I tried all your suggestions, but it looks like still no cigar.

I deleted and recloned the repo with --recursive, built emulatorPkg, which 
worked fine, then tried MdeModulePkg
I get the same error on both my setups, real and VM.
I ran the build with -n 1 and -j after deleting the Build directory, please 
find the log file attached.

Command history is as follows:
git clone --recursive https://github.com/tianocore/edk2.git
cd edk2
git submodule update --init
edksetup.bat Rebuild
// edit target.txt and change to VS2017, X64 and MdeModulePkg/MdeModulePkg.dsc
build -n 1 -j logfile.txt

Thank you
xp


On Thu, Jun 16, 2022 at 11:05 PM Kilian Kegel 
mailto:kilian_ke...@outlook.com>> wrote:

git clone --recursive https://github.com/tianocore/edk2.git

That works!
You forgot “—recursive”


From: M.T.
Sent: Thursday, June 16, 2022 10:19 PM
To: devel@edk2.groups.io; Maciej 
T.
Cc: Kinney, Michael D
Subject: Re: [edk2-devel] Windows 10 build failing

I spun up a windows 10 pro VM and started from scratch, now I'm consistently 
hitting a redefinition error.
EmulatorPkg built, so it is something with this Brotoli Library

Building ... 
c:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib.inf
 [X64]
"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64\cl.exe" 
/Foc:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\OUTPUT\brotli\c\common\
 /showIncludes /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1b2s /GL /Gy 
/FIAutoGen.h /EHs-c- /GR- /GF /Z7 /Gw 
/Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\include\brotli
  
/Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\dec
  
/Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\common
  /Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib  
/Ic:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\DEBUG
  /Ic:\users\user\uefi\edk2\MdePkg  /Ic:\users\user\uefi\edk2\MdePkg\Include  
/Ic:\users\user\uefi\edk2\MdePkg\Test\UnitTest\Include  
/Ic:\users\user\uefi\edk2\MdePkg\Include\X64  
/Ic:\users\user\uefi\edk2\MdeModulePkg  
/Ic:\users\user\uefi\edk2\MdeModulePkg\Include  
/Ic:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\brotli\c\include
 
@c:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib\OUTPUT\cc_resp_3.txt
transform.c
dictionary.c
C:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(103): error C2220: warning 
treated as error - no 'object' file generated
C:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(103): warning C4559: 
'BrDummyMalloc': redefinition; the function gains __declspec(restrict)
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64\cl.exe"' : 
return code '0x2'
Stop.


build.py...
 : error 7000: Failed to execute command
C:\Program Files (x86)\Microsoft Visual 
Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\nmake.exe 
/nologo tbuild 
[c:\users\user\uefi\edk2\Build\MdeModule\DEBUG_VS2017\X64\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib]


build.py...
 : error F002: Failed to build module

c:\users\user\uefi\edk2\MdeModulePkg\Library\BrotliCustomDecompressLib\BrotliCustomDecompressLib.inf
 [X64, VS2017, DEBUG]

xp

On Thu, Jun 16, 2022 at 3:06 PM M.T. via groups.io 
mailto:gmail@groups.io>> wrote:
I get NASM version 2.15 compiled on Jun 27 2020

I bumped it up to the same version you have just in case, several attempts in 
build and recompiling results in the original error where 
BrotliCustomDecompressLib fails, but I also now see these two:

Building ... 
c:\users\maciej\uefi\edk2\MdeModulePkg\Library\SmmReportStatusCodeLib\SmmReportStatusCodeLib.inf
 [X64]
C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt_malloc.h(103): error C2220: warning 
treated as error - no 'object' file generated
C:\Program Files (x86)\Windows 
Kits\10\include\10.0.22621.0\ucrt\corecrt_malloc.h(103): warning C4559: 
'BrDummyMalloc': redefinition; the function gains 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-06-17 Thread Jeff Brasen via groups.io
Any thoughts on this patch?

> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, February 14, 2022 11:46 AM
> To: devel@edk2.groups.io
> Cc: hao.a...@intel.com; ray...@intel.com; Jeff Brasen
> 
> Subject: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow
> partial FreeBuffer
> 
> Add support for partial free of non cached buffers.
> If a request for less than the full size is requested new allocations for the
> remaining head and tail of the buffer are added to the list.
> Added verification that Buffer is EFI_PAGE_SIZE aligned.
> The XHCI driver does this if the page size for the controller is >4KB.
> 
> Signed-off-by: Jeff Brasen 
> ---
>  .../NonDiscoverablePciDeviceIo.c  | 53 ++-
>  1 file changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> index c1c5c6267c..77809cfedf 100644
> ---
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> +++
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> Pc
> +++ iDeviceIo.c
> @@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
>LIST_ENTRY   *Entry;
>EFI_STATUS   Status;
>NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
> +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
> + NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
>BOOLEAN  Found;
> +  UINTNStartPages;
> +  UINTNEndPages;
> +
> +  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
> +ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +return EFI_INVALID_PARAMETER;
> +  }
> 
>Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
> 
>Found = FALSE;
>Alloc = NULL;
> +  AllocHead = NULL;
> +  AllocTail = NULL;
> 
>//
>// Find the uncached allocation list entry associated @@ -976,9 +987,13 @@
> NonCoherentPciIoFreeBuffer (
> Entry = Entry->ForwardLink)
>{
>  Alloc = BASE_CR (Entry,
> NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
> -if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages))
> {
> +StartPages = 0;
> +if (Alloc->HostAddress < HostAddress) {
> +  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
> +}
> +if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >=
> + (Pages + StartPages))) {
>//
> -  // We are freeing the exact allocation we were given
> +  // We are freeing at least part of what we were given
>// before by AllocateBuffer()
>//
>Found = TRUE;
> @@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
>  return EFI_NOT_FOUND;
>}
> 
> +  EndPages = Alloc->NumPages - (Pages + StartPages);
> +
> +  if (StartPages != 0) {
> +AllocHead = AllocatePool (sizeof *AllocHead);
> +if (AllocHead == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocHead->HostAddress = Alloc->HostAddress;
> +AllocHead->NumPages = StartPages;
> +AllocHead->Attributes = Alloc->Attributes;  }
> +
> +  if (EndPages != 0) {
> +AllocTail = AllocatePool (sizeof *AllocTail);
> +if (AllocTail == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) *
> EFI_PAGE_SIZE);
> +AllocTail->NumPages = EndPages;
> +AllocTail->Attributes = Alloc->Attributes;  }
> +
>RemoveEntryList (>List);
> +  //
> +  // Record this new sub allocations in the linked list, so we  // can
> + restore the memory space attributes later  //  if (AllocHead != NULL)
> + {
> +InsertHeadList (>UncachedAllocationList, >List);  }
> + if (AllocTail != NULL) {
> +InsertHeadList (>UncachedAllocationList, >List);  }
> 
>Status = gDS->SetMemorySpaceAttributes (
>(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
> --
> 2.17.1



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




Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs

2022-06-17 Thread Jeff Brasen via groups.io
Anything else needed prior to getting this merged to edk2?

> -Original Message-
> From: gaoliming 
> Sent: Thursday, May 19, 2022 7:19 PM
> To: devel@edk2.groups.io; bob.c.f...@intel.com; Jeff Brasen
> 
> Cc: 'Chen, Christine' 
> Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> 
> External email: Use caution opening links or attachments
> 
> 
> Reviewed-by: Liming Gao 
> 
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Bob Feng
> > 发送时间: 2022年5月18日 15:15
> > 收件人: devel@edk2.groups.io; Gao, Liming
> ;
> > jbra...@nvidia.com
> > 抄送: Chen, Christine 
> > 主题: Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> >
> > They are the BaseTools build log files that are generated by
> > BaseTools/Edk2ToolsBuild.py.
> >
> > Thanks,
> > Bob
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> > gaoliming
> > Sent: Wednesday, May 18, 2022 2:40 PM
> > To: devel@edk2.groups.io; jbra...@nvidia.com
> > Cc: Feng, Bob C ; Chen, Christine
> > 
> > Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools build
> > logs
> >
> > Bob:
> >   Do you know what files will be generated in BaseTools/BaseToolsBuild
> > directory?
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Jeff
> Brasen
> > via
> > > groups.io
> > > 发送时间: 2022年4月22日 1:01
> > > 收件人: devel@edk2.groups.io
> > > 抄送: bob.c.f...@intel.com; gaolim...@byosoft.com.cn;
> > > yuwei.c...@intel.com; Jeff Brasen 
> > > 主题: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> > >
> > > The python BaseTools/Edk2ToolsBuild.py creates files in
> > > BaseTools/BaseToolsBuild and should be ignored.
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  BaseTools/.gitignore | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/BaseTools/.gitignore b/BaseTools/.gitignore index
> > > a45689bc89..ddf93b7116 100644
> > > --- a/BaseTools/.gitignore
> > > +++ b/BaseTools/.gitignore
> > > @@ -17,4 +17,5 @@ Source/C/VfrCompile/VfrTokens.h  Source/C/bin/
> > > Source/C/libs/
> > >  Bin/Win32
> > > -Lib
> > > \ No newline at end of file
> > > +Lib
> > > +BaseToolsBuild/
> > > \ No newline at end of file
> > > --
> > > 2.25.1
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > 
> >
> 
> 



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




Re: [edk2-devel] [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY

2022-06-17 Thread Jeff Brasen via groups.io
Resending this as I replying via edk2.groups.io doesn't seem to copy 
maintainers.

Resuming this patch to see if there are any additional thoughts on this.

In response to the query about DXE/BDS services we have some internal 
connection logic that runs in DXE to connect the devices that are needed for 
arch services that have to be connected prior the end of dxe.

Thanks,
Jeff

> -Original Message-
> From: Jeff Brasen
> Sent: Tuesday, December 14, 2021 9:48 PM
> To: Wu, Hao A ; devel@edk2.groups.io
> Cc: Ni, Ray 
> Subject: RE: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> 
> 
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Tuesday, December 14, 2021 8:00 PM
> > To: Jeff Brasen ; devel@edk2.groups.io
> > Cc: Ni, Ray 
> > Subject: RE: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> >
> > External email: Use caution opening links or attachments
> >
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Wednesday, December 15, 2021 1:59 AM
> > > To: devel@edk2.groups.io
> > > Cc: Wu, Hao A ; Ni, Ray ; Jeff
> > > Brasen 
> > > Subject: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> > >
> > > Increase TPL to TPL_NOTIFY to allow for use if caller is > TPL_CALLBACK.
> > > This allows services like variable services that run at TPL_NOTIFY
> > > to be hosted on ScsiDisks (i.e. UFS)
> > >
> > > Aligns with the eMMC driver that also uses a higher TPL.
> > > This change was made in 3b1d8241d0dac25c5e678c364fa2754ac1731060
> >
> >
> > Sorry, my take is that this change is not equivalent to the one made
> > in the SD/MMC stack.
> >
> > For the SD/MMC change you mentioned (commit
> > 3b1d8241d0dac25c5e678c364fa2754ac1731060), the TPL is raised to
> > TPL_NOTIFY only when:
> >   a) Operation to the linked lists that manage the asynchronous IO tasks
> >   b) Callback functions that process the asynchronous IO tasks The TPL
> > remains TPL_CALLBACK during the BlockIO services and the majority of
> > the
> > BlockIO2 services (operations to asynchronous tasks linked list are
> > the exceptions).
> >
> > But the proposed change in ScsiDisk modifies the TPL level of the
> > entire
> > BlockIO/BlockIO2 (and other protocols) services to TPL_NOTIFY.
> > For me, this is not aligned with the "TPL Restrictions" documented in
> > the UEFI specification.
> >
> > Best Regards,
> > Hao Wu
> >
> >
> 
> I had sent out a query on this before and didn't see any response. The core
> of the issue I am trying to solve it support variable services on a UFS 
> device.
> When the UFS blockIO is invoked from variable services it is not allowed
> (which does align from the UEFI spec perspective but does not allow me to
> implement variables services on UFS)
> 
>  The other way that worked was lowering the lock TPL level in the PCD driver
> and Variable down to callback. The PCD one seems like it should be done as
> variable services is supposed to only be called from <= TPL_CALLBACK.
> However, I was worried about that having a larger system impact on that
> change.
> 
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 22
> > > ++--
> > >  1 file changed, 11 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > index 98e84b4ea8..b6e5848e77 100644
> > > --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > @@ -514,7 +514,7 @@ ScsiDiskReset (
> > >SCSI_DISK_DEV  *ScsiDiskDevice;
> > >EFI_STATUS Status;
> > >
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >
> > > @@ -581,7 +581,7 @@ ScsiDiskReadBlocks (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >Media  = ScsiDiskDevice->BlkIo.Media;
> > >
> > > @@ -733,7 +733,7 @@ ScsiDiskWriteBlocks (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >Media  = ScsiDiskDevice->BlkIo.Media;
> > >
> > > @@ -898,7 +898,7 @@ ScsiDiskResetEx (
> > >SCSI_DISK_DEV  *ScsiDiskDevice;
> > >EFI_STATUS Status;
> > >
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> > >
> > > @@ -975,7 +975,7 @@ ScsiDiskReadBlocksEx (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl  

Re: [edk2-devel] [edk2-platforms] [PATCH 1/1] Platform/Sgi: Add support to disable isolated cpus

2022-06-17 Thread Thomas Abraham




On 17/06/2022 07:07, Nishant Sharma wrote:

Isolated CPUs are those that are not to be used on the platform for
various reasons. The isolated CPU list is an array of MPID values of
the CPUs that have to be isolated. This list is supplied via the
NT_FW_CONFIG dtb.

Add support to search for isolated CPUs MPID list and, if present,
update the MADT table to disable the corresponding CPUs.

Signed-off-by: Nishant Sharma 
---
  Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf |   1 -
  Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf |   8 +-
  Platform/ARM/SgiPkg/Include/SgiPlatform.h |   7 ++
  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 131 
+++-
  Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c  |  45 ++-
  5 files changed, 186 insertions(+), 6 deletions(-)


Reviewed-by: Thomas Abraham 
Tested-by: Thomas Abraham 


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




Re: [edk2-devel] [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference with py3.7

2022-06-17 Thread Jayaprakash, N
This is a simple documentation fix. Could some one from the group review and 
merge these changes?

Regards,
JP

-Original Message-
From: Jayaprakash, N  
Sent: 10 June 2022 09:19
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 
; Jayaprakash, N 
Subject: [edk2 Patch 1/1] Windows-systems.mediawiki: replaced p2.7 reference 
with py3.7

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

Removed an outdated reference to py2.7 in the Windows systems wiki page and 
replaced it with the py3.7 to align with the updated build instructions

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Jayaprakash N 
---
 Windows-systems.mediawiki | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Windows-systems.mediawiki b/Windows-systems.mediawiki index 
0b69b56..cca2b73 100644
--- a/Windows-systems.mediawiki
+++ b/Windows-systems.mediawiki
@@ -88,7 +88,7 @@ Example:
 Example:
 *Open Command prompt and CD C:\edk2:
 
- C:\edk2> set PYTHON_HOME=C:\Python27
+ C:\edk2> set PYTHON_HOME=C:\Python37
  C:\edk2> edksetup.bat Rebuild
 
 
--
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib : Changes to Std LibC to facilitate 32 bit GCC builds

2022-06-17 Thread Jayaprakash, N
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3779

This comit fixes the Python interpreter build issues with GCC 32 bit
compiler tool chain. The changes are needed in StdLibC as given below

* Add __divmoddi4 to Gcc.c produced by newer GCC compilers
* Add -fno-lto to IA32 GCC builds of LibC.inf to support use of
  GCC intrinsics from Gcc.c.
* Moved Main/Ia32/ftol2.obj in LibC.inf from binaries section to
  Sources.IA32 required only for MSFT IA32 compiler tool chain

Cc: Michael D Kinney 
Cc: Rebecca Cran 
Signed-off-by: Jayaprakash N 
---
 StdLib/LibC/CRT/Gcc.c | 7 +++
 StdLib/LibC/LibC.inf  | 7 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/StdLib/LibC/CRT/Gcc.c b/StdLib/LibC/CRT/Gcc.c
index cbf4ec2..bc1a4b2 100644
--- a/StdLib/LibC/CRT/Gcc.c
+++ b/StdLib/LibC/CRT/Gcc.c
@@ -193,3 +193,10 @@ unsigned long long __umodti3(unsigned long long Dividend, 
unsigned long long Div
 
   return (unsigned long long) Remainder;
 }
+
+INT64 __divmoddi4 (INT64 num, INT64 den, INT64 *rem_p)
+{
+  DEBUG((DEBUG_INFO, "%a:\n", __func__));
+  return DivS64x64Remainder (num, den, rem_p);
+}
+
diff --git a/StdLib/LibC/LibC.inf b/StdLib/LibC/LibC.inf
index 5bb2053..4771204 100644
--- a/StdLib/LibC/LibC.inf
+++ b/StdLib/LibC/LibC.inf
@@ -46,7 +46,8 @@
   Main/Ia32/fpu_rmode.S   | GCC
   Main/Ia32/isinfl.c
   Main/Ia32/isnanl.c
-
+  Main/Ia32/ftol2.obj | MSFT
+  
   # Compiler helper (C RunTime) functions
   CRT/Ia32/llmul.c  | MSFT# __allmul
   CRT/Ia32/llshl.c  | MSFT# __allshl
@@ -88,9 +89,6 @@
 [Sources.AARCH64]
   Main/Arm/flt_rounds.c
 
-[Binaries.IA32]
-  LIB|Main/Ia32/ftol2.obj|*|MSFT
-
 [Packages]
   StdLib/StdLib.dec
   StdLibPrivateInternalFiles/DoNotUse.dec
@@ -116,4 +114,5 @@
 #
 [BuildOptions]
   MSFT:*_*_IA32_CC_FLAGS = /GL-
+  GCC:*_*_IA32_CC_FLAGS = -fno-lto
   GCC:*_*_ARM_CC_FLAGS = -fno-lto
-- 
2.33.0.windows.1



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




[edk2-devel] [edk2-libc Patch 0/1] Changes to StdLib to facilitate gcc 32 bit builds

2022-06-17 Thread Jayaprakash, N
This patch contains the changes required for StdLib to facilitate the 
gcc 32 bit builds. 

Jayaprakash Nevara (1):
  edk2-libc/StdLib : Changes to Std LibC to facilitate 32 bit GCC builds

 StdLib/LibC/CRT/Gcc.c | 7 +++
 StdLib/LibC/LibC.inf  | 7 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

-- 
2.33.0.windows.1



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




[edk2-devel] [PATCH v2] UefiPayloadPkg: Always split page table entry to 4K if it covers stack.

2022-06-17 Thread Zhiguang Liu
We observed page fault in the following situation:
1.PayloadEntry uses 2M entry in page table to cover DXE stack range.
2.In DXE phase, image protection code needs to mark some sub-range in
this 2M entry as readonly. So the the 2M page table entry is split to
512 4K entries, and some of the entries are marked as readonly.
(the entries covering stack still remain R/W)
3.Page fault exception happens when trying to access stack.

Always split the page table entry to 4K if it covers stack to avoid this
issue.
More discussion about this issue can be seen at below link
https://edk2.groups.io/g/devel/topic/91446026

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Cc: Gerd Hoffmann 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685..74b667a62a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -218,16 +218,8 @@ ToSplitPageTable (
 return TRUE;
   }
 
-  if (PcdGetBool (PcdCpuStackGuard)) {
-if ((StackBase >= Address) && (StackBase < (Address + Size))) {
-  return TRUE;
-}
-  }
-
-  if (PcdGetBool (PcdSetNxForStack)) {
-if ((Address < StackBase + StackSize) && ((Address + Size) > StackBase)) {
-  return TRUE;
-}
+  if ((Address < StackBase + StackSize) && ((Address + Size) > StackBase)) {
+return TRUE;
   }
 
   if (GhcbBase != 0) {
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90572): https://edk2.groups.io/g/devel/message/90572
Mute This Topic: https://groups.io/mt/91817347/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/1] Platform/Sgi: Add support to disable isolated cpus

2022-06-17 Thread Nishant Sharma
Isolated CPUs are those that are not to be used on the platform for
various reasons. The isolated CPU list is an array of MPID values of
the CPUs that have to be isolated. This list is supplied via the
NT_FW_CONFIG dtb.

Add support to search for isolated CPUs MPID list and, if present,
update the MADT table to disable the corresponding CPUs.

Signed-off-by: Nishant Sharma 
---
 Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf |   1 -
 Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf |   8 +-
 Platform/ARM/SgiPkg/Include/SgiPlatform.h |   7 ++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 131 
+++-
 Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPeim.c  |  45 ++-
 5 files changed, 186 insertions(+), 6 deletions(-)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf 
b/Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf
index 4b36c3e5ceb2..e13c2f08ce6e 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/RdN2Cfg1AcpiTables.inf
@@ -18,7 +18,6 @@
   Dbg2.aslc
   Fadt.aslc
   Gtdt.aslc
-  Iort.aslc
   Mcfg.aslc
   RdN2Cfg1/Dsdt.asl
   RdN2Cfg1/Madt.aslc
diff --git a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf 
b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf
index 407160c07563..fbf061ad3bdb 100644
--- a/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf
+++ b/Platform/ARM/SgiPkg/Library/SgiPlatformPei/SgiPlatformPei.inf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2018, ARM Limited. All rights reserved.
+#  Copyright (c) 2018-2022, ARM Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -13,6 +13,7 @@
   ENTRY_POINT= SgiPlatformPeim
 
 [Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdePkg/MdePkg.dec
   Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -21,6 +22,11 @@
   FdtLib
   PeimEntryPoint
 
+[FixedPcd]
+  gArmSgiTokenSpaceGuid.PcdChipCount
+  gArmPlatformTokenSpaceGuid.PcdCoreCount
+  gArmPlatformTokenSpaceGuid.PcdClusterCount
+
 [Sources]
   SgiPlatformPeim.c
 
diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h 
b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
index dddb58832d73..311286ce5337 100644
--- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h
+++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
@@ -65,11 +65,18 @@
 #define DRAM_BLOCK2_BASE_REMOTE(ChipId) \
   (SGI_REMOTE_CHIP_MEM_OFFSET (ChipId) + FixedPcdGet64 
(PcdDramBlock2Base))
 
+// List of isolated CPUs MPID
+typedef struct {
+  UINT64  Count;// Number of elements present in the list
+  UINT64  Mpid[];   // List containing isolated CPU MPIDs
+} SGI_ISOLATED_CPU_LIST;
+
 // ARM platform description data.
 typedef struct {
   UINTN  PlatformId;
   UINTN  ConfigId;
   UINTN  MultiChipMode;
+  SGI_ISOLATED_CPU_LIST  IsolatedCpuList;
 } SGI_PLATFORM_DESCRIPTOR;
 
 // Arm SGI/RD Product IDs
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
index 2f72e7152ff3..80190120ff32 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -1,14 +1,17 @@
 /** @file
 *
-*  Copyright (c) 2018, ARM Limited. All rights reserved.
+*  Copyright (c) 2018 - 2022, ARM Limited. All rights reserved.
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
 **/
 
+#include 
+
 #include 
 #include 
 #include 
+#include 
 #include 
 
 VOID
@@ -16,6 +19,127 @@ InitVirtioDevices (
   VOID
   );
 
+/**
+  Search for a MPID in a list
+
+  Performs a linear search for a specified MPID on the given linear
+  list of MPIDs.
+
+  @param[in]  MpidList  Pointer to list.
+  @param[in]  Count Number of the elements in the list.
+  @param[in]  Mpid  Target MPID.
+
+  @retval TRUE   MPID is present.
+  @retval FALSE  MPID is not present.
+**/
+STATIC
+BOOLEAN
+CheckIfMpidIsPresent (
+  IN UINT64  *MpidList,
+  IN UINT64  Count,
+  IN UINT64  Mpid
+  )
+{
+  UINT64 Idx;
+
+  for (Idx = 0; Idx < Count; Idx++) {
+if (MpidList[Idx] == Mpid) {
+  return TRUE;
+}
+  }
+
+  return FALSE;
+}
+
+/**
+  Disables isolated CPUs in the MADT table
+
+  Parse the IsolatedCpuInfo from the Hob list and updates the MADT table to
+  disable cpu's which are not available on the platfrom.
+
+  @param[in] AcpiHeader  Points to the Madt table.
+  @param[in] HobData Points to the unusable cpuinfo in hoblist.
+**/
+STATIC
+VOID
+UpdateMadtTable (
+  IN EFI_ACPI_DESCRIPTION_HEADER  *AcpiHeader,
+  IN SGI_PLATFORM_DESCRIPTOR  *HobData
+  )
+{
+  UINT8 *StructureListHead;
+  UINT8 *StructureListTail;
+  EFI_ACPI_6_4_GIC_STRUCTURE *GicStructure;
+  BOOLEAN MpidPresent;
+
+  if (HobData->IsolatedCpuList.Count == 0) {
+return;
+  }
+
+  StructureListHead =
+((UINT8 *)AcpiHeader) +
+