diff --git a/.edk2.metadata b/.edk2.metadata deleted file mode 100644 index 334c41f..0000000 --- a/.edk2.metadata +++ /dev/null @@ -1,2 +0,0 @@ -ae830c7278f985cb25e90f4687b46c8b22316bef SOURCES/edk2-bb1bba3d77.tar.xz -85388ae6525650667302c6b553894430197d9e0d SOURCES/openssl-rhel-cf317b2bb227899cb2e761b9163210f62cab1b1e.tar.xz diff --git a/.gitignore b/.gitignore index 440a2b8..abc0b04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -SOURCES/edk2-bb1bba3d77.tar.xz -SOURCES/openssl-rhel-cf317b2bb227899cb2e761b9163210f62cab1b1e.tar.xz +DBXUpdate-20230509.x64.bin +edk2-3e722403cd.tar.xz +openssl-rhel-0205b589887203b065154ddc8e8107c4ac8625a1.tar.xz diff --git a/0003-Remove-paths-leading-to-submodules.patch b/0003-Remove-paths-leading-to-submodules.patch new file mode 100644 index 0000000..1c76597 --- /dev/null +++ b/0003-Remove-paths-leading-to-submodules.patch @@ -0,0 +1,65 @@ +From 890270bd27f2177f0eb2158ca8c75b101d27283b Mon Sep 17 00:00:00 2001 +From: Miroslav Rezanina +Date: Thu, 24 Mar 2022 03:23:02 -0400 +Subject: [PATCH] Remove paths leading to submodules + +We removed submodules used upstream. However, edk2 build system requires +such include paths to resolve successfully, regardless of the firmware +platform being built. + +Signed-off-by: Miroslav Rezanina +--- + BaseTools/Source/C/GNUmakefile | 1 - + MdeModulePkg/MdeModulePkg.dec | 3 --- + MdePkg/MdePkg.dec | 5 ----- + 3 files changed, 9 deletions(-) + +diff --git a/BaseTools/Source/C/GNUmakefile b/BaseTools/Source/C/GNUmakefile +index 5275f657ef..39d7199753 100644 +--- a/BaseTools/Source/C/GNUmakefile ++++ b/BaseTools/Source/C/GNUmakefile +@@ -51,7 +51,6 @@ all: makerootdir subdirs + LIBRARIES = Common + VFRAUTOGEN = VfrCompile/VfrLexer.h + APPLICATIONS = \ +- BrotliCompress \ + VfrCompile \ + EfiRom \ + GenFfs \ +diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec +index f7339f0aec..badb93238f 100644 +--- a/MdeModulePkg/MdeModulePkg.dec ++++ b/MdeModulePkg/MdeModulePkg.dec +@@ -26,9 +26,6 @@ + Include + Test/Mock/Include + +-[Includes.Common.Private] +- Library/BrotliCustomDecompressLib/brotli/c/include +- + [LibraryClasses] + ## @libraryclass Defines a set of methods to reset whole system. + ResetSystemLib|Include/Library/ResetSystemLib.h +diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec +index bf94549cbf..605b0f1be8 100644 +--- a/MdePkg/MdePkg.dec ++++ b/MdePkg/MdePkg.dec +@@ -29,7 +29,6 @@ + Include + Test/UnitTest/Include + Test/Mock/Include +- Library/MipiSysTLib/mipisyst/library/include + + [Includes.IA32] + Include/Ia32 +@@ -295,10 +294,6 @@ + # + FdtLib|Include/Library/FdtLib.h + +- ## @libraryclass Provides general mipi sys-T services. +- # +- MipiSysTLib|Include/Library/MipiSysTLib.h +- + ## @libraryclass Provides API to output Trace Hub debug message. + # + TraceHubDebugSysTLib|Include/Library/TraceHubDebugSysTLib.h diff --git a/SOURCES/0012-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch b/0004-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch similarity index 84% rename from SOURCES/0012-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch rename to 0004-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch index 0e74204..081fccc 100644 --- a/SOURCES/0012-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch +++ b/0004-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch @@ -1,8 +1,20 @@ -From fbfd113142f594c4f257b5a044a6e17ef7f66505 Mon Sep 17 00:00:00 2001 +From 496d843eaa1efdc7c113ba9a919dcc6c2ae53c9f Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 25 Feb 2014 22:40:01 +0100 -Subject: MdeModulePkg: TerminalDxe: set xterm resolution on mode change (RH - only) +Subject: [PATCH] MdeModulePkg: TerminalDxe: set xterm resolution on mode + change (RH only) + +Notes for rebase to edk2-stable202311: + +- Minor context changes due to new PCDs (for USB Networking) being added. + +Notes for rebase to edk2-stable202205: + +- Minor context changes due to fd306d1dbc MdeModulePkg: Add PcdTdxSharedBitMask + +Notes for rebase to edk2-stable202202: + +- Minor context changes due to 1436aea4d MdeModulePkg: Apply uncrustify changes Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -87,84 +99,84 @@ Signed-off-by: Laszlo Ersek 3 files changed, 36 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec -index 9d69fb86ed..08d59dfb3e 100644 +index badb93238f..3a67acc090 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec -@@ -2076,6 +2076,10 @@ - # @Prompt Enable PCIe Resizable BAR Capability support. - gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport|FALSE|BOOLEAN|0x10000024 +@@ -2222,6 +2222,10 @@ + # @Prompt The value is use for Usb Network rate limiting supported. + gEfiMdeModulePkgTokenSpaceGuid.PcdUsbNetworkRateLimitingFactor|100|UINT32|0x10000028 -+ ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal -+ # mode change. -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080 -+ ++ ## Controls whether TerminalDxe outputs an XTerm resize sequence on terminal ++ # mode change. ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE|BOOLEAN|0x00010080 ++ [PcdsPatchableInModule] ## Specify memory size with page number for PEI code when # Loading Module at Fixed Address feature is enabled. diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c -index aae470e956..26156857aa 100644 +index 7809869e7d..3be801039b 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ -+#include -+ ++#include ++ #include "Terminal.h" // -@@ -80,6 +82,16 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 - CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 }; - CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 }; +@@ -80,6 +82,16 @@ CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 + CHAR16 mCursorForwardString[] = { ESC, '[', '0', '0', 'C', 0 }; + CHAR16 mCursorBackwardString[] = { ESC, '[', '0', '0', 'D', 0 }; -+// -+// Note that this is an ASCII format string, taking two INT32 arguments: -+// rows, columns. -+// -+// A %d (INT32) format specification can expand to at most 11 characters. -+// -+CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt"; -+#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2)) -+ -+ ++// ++// Note that this is an ASCII format string, taking two INT32 arguments: ++// rows, columns. ++// ++// A %d (INT32) format specification can expand to at most 11 characters. ++// ++CHAR8 mResizeTextAreaFormatString[] = "\x1B[8;%d;%dt"; ++#define RESIZE_SEQ_SIZE (sizeof mResizeTextAreaFormatString + 2 * (11 - 2)) ++ ++ // // Body of the ConOut functions // -@@ -506,6 +518,24 @@ TerminalConOutSetMode ( +@@ -498,6 +510,24 @@ TerminalConOutSetMode ( return EFI_DEVICE_ERROR; } -+ if (PcdGetBool (PcdResizeXterm)) { -+ CHAR16 ResizeSequence[RESIZE_SEQ_SIZE]; -+ -+ UnicodeSPrintAsciiFormat ( -+ ResizeSequence, -+ sizeof ResizeSequence, -+ mResizeTextAreaFormatString, -+ (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows, -+ (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns -+ ); -+ TerminalDevice->OutputEscChar = TRUE; -+ Status = This->OutputString (This, ResizeSequence); -+ TerminalDevice->OutputEscChar = FALSE; -+ if (EFI_ERROR (Status)) { -+ return EFI_DEVICE_ERROR; -+ } -+ } -+ - This->Mode->Mode = (INT32) ModeNumber; ++ if (PcdGetBool (PcdResizeXterm)) { ++ CHAR16 ResizeSequence[RESIZE_SEQ_SIZE]; ++ ++ UnicodeSPrintAsciiFormat ( ++ ResizeSequence, ++ sizeof ResizeSequence, ++ mResizeTextAreaFormatString, ++ (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows, ++ (INT32) TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns ++ ); ++ TerminalDevice->OutputEscChar = TRUE; ++ Status = This->OutputString (This, ResizeSequence); ++ TerminalDevice->OutputEscChar = FALSE; ++ if (EFI_ERROR (Status)) { ++ return EFI_DEVICE_ERROR; ++ } ++ } ++ + This->Mode->Mode = (INT32)ModeNumber; - Status = This->ClearScreen (This); + Status = This->ClearScreen (This); diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -index b2a8aeba85..eff6253465 100644 +index b2a8aeba85..96810f337c 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf @@ -55,6 +55,7 @@ DebugLib PcdLib BaseLib -+ PrintLib ++ PrintLib [Guids] ## SOMETIMES_PRODUCES ## Variable:L"ConInDev" @@ -172,10 +184,7 @@ index b2a8aeba85..eff6253465 100644 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## CONSUMES -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## CONSUMES ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## CONSUMES # [Event] # # Relative timer event set by UnicodeToEfiKey(), used to be one 2 seconds input timeout. --- -2.27.0 - diff --git a/SOURCES/0013-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch b/0005-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch similarity index 57% rename from SOURCES/0013-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch rename to 0005-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch index ae76f7c..98fddad 100644 --- a/SOURCES/0013-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch +++ b/0005-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch @@ -1,7 +1,12 @@ -From 9ea7b3f689bf7d21b869adb829139be7eb91bb33 Mon Sep 17 00:00:00 2001 +From 3830b4cfd575bcb5d44b69f4d8f8d49f6992fcc3 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 14 Oct 2015 15:59:06 +0200 -Subject: OvmfPkg: take PcdResizeXterm from the QEMU command line (RH only) +Subject: [PATCH] OvmfPkg: take PcdResizeXterm from the QEMU command line (RH + only) + +Notes about edk2-stable202205 rebase + +- Necessary minor fixes for upstream changes Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -66,87 +71,142 @@ Signed-off-by: Laszlo Ersek (cherry picked from commit 2cc462ee963d0be119bc97bfc9c70d292a40516f) (cherry picked from commit 51e0de961029af84b5bdbfddcc9762b1819d500f) --- - OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + - OvmfPkg/OvmfPkgIa32.dsc | 1 + - OvmfPkg/OvmfPkgIa32X64.dsc | 1 + - OvmfPkg/OvmfPkgX64.dsc | 1 + - OvmfPkg/PlatformPei/Platform.c | 1 + - OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ - 6 files changed, 7 insertions(+) + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + + OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + + OvmfPkg/Microvm/MicrovmX64.dsc | 2 +- + OvmfPkg/OvmfPkgIa32.dsc | 1 + + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + + OvmfPkg/OvmfPkgX64.dsc | 1 + + OvmfPkg/PlatformPei/Platform.c | 13 +++++++++++++ + OvmfPkg/PlatformPei/PlatformPei.inf | 1 + + 9 files changed, 21 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index 5ee5445116..6ea3621225 100644 +index 8eb6f4f24f..627fded641 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -534,6 +534,7 @@ +@@ -484,6 +484,7 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 +diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc +index 4996885301..51a49c09ad 100644 +--- a/OvmfPkg/CloudHv/CloudHvX64.dsc ++++ b/OvmfPkg/CloudHv/CloudHvX64.dsc +@@ -581,6 +581,7 @@ + # ($(SMM_REQUIRE) == FALSE) + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 + ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE + !if $(SMM_REQUIRE) == FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 +diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc +index 0931ce061a..9f49b60ff0 100644 +--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc ++++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc +@@ -477,6 +477,7 @@ + # ($(SMM_REQUIRE) == FALSE) + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 + ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 +diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc +index 69de4dd3f1..fb73f2e089 100644 +--- a/OvmfPkg/Microvm/MicrovmX64.dsc ++++ b/OvmfPkg/Microvm/MicrovmX64.dsc +@@ -590,7 +590,7 @@ + # only set when + # ($(SMM_REQUIRE) == FALSE) + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 +- ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 6a5be97c05..4cacf0ea94 100644 +index 2ca005d768..dddef5ed0e 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -594,6 +594,7 @@ +@@ -599,6 +599,7 @@ # ($(SMM_REQUIRE) == FALSE) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE !if $(SMM_REQUIRE) == FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 71227d1b70..6225f8e095 100644 +index a39070a626..933abb258f 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -600,6 +600,7 @@ +@@ -611,6 +611,7 @@ # ($(SMM_REQUIRE) == FALSE) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE !if $(SMM_REQUIRE) == FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 52f7598cf1..b66fc67563 100644 +index 1b90aa8f57..04157ab14b 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -600,6 +600,7 @@ +@@ -629,6 +629,7 @@ # ($(SMM_REQUIRE) == FALSE) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE !if $(SMM_REQUIRE) == FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c -index df2d9ad015..d0e2c08de9 100644 +index df35726ff6..6c786bfc1e 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c -@@ -752,6 +752,7 @@ InitializePlatform ( - MemTypeInfoInitialization (); - MemMapInitialization (); - NoexecDxeInitialization (); -+ UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm); +@@ -41,6 +41,18 @@ + + #include "Platform.h" + ++#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ ++ do { \ ++ BOOLEAN Setting; \ ++ RETURN_STATUS PcdStatus; \ ++ \ ++ if (!RETURN_ERROR (QemuFwCfgParseBool ( \ ++ "opt/ovmf/" #TokenName, &Setting))) { \ ++ PcdStatus = PcdSetBoolS (TokenName, Setting); \ ++ ASSERT_RETURN_ERROR (PcdStatus); \ ++ } \ ++ } while (0) ++ + EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { + { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, +@@ -355,6 +367,7 @@ InitializePlatform ( + MemTypeInfoInitialization (PlatformInfoHob); + MemMapInitialization (PlatformInfoHob); + NoexecDxeInitialization (PlatformInfoHob); ++ UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm); } InstallClearCacheCallback (); diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf -index 67eb7aa716..7d26b43680 100644 +index e036018eab..a2f59e8fc8 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf -@@ -93,6 +93,8 @@ +@@ -103,6 +103,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved -+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack --- -2.27.0 - diff --git a/SOURCES/0014-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch b/0006-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch similarity index 85% rename from SOURCES/0014-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch rename to 0006-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch index 31d88dc..1669840 100644 --- a/SOURCES/0014-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch +++ b/0006-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch @@ -1,7 +1,8 @@ -From b846a65eeb926a483cff3e35242097eb6d21ceab Mon Sep 17 00:00:00 2001 +From 7461128f36076d1a5e45f89f00c8b2a5d92bd745 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Sun, 26 Jul 2015 08:02:50 +0000 -Subject: ArmVirtPkg: take PcdResizeXterm from the QEMU command line (RH only) +Subject: [PATCH] ArmVirtPkg: take PcdResizeXterm from the QEMU command line + (RH only) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -90,127 +91,111 @@ Signed-off-by: Laszlo Ersek ArmVirtPkg/ArmVirtQemu.dsc | 7 +++- .../TerminalPcdProducerLib.c | 34 +++++++++++++++++++ .../TerminalPcdProducerLib.inf | 33 ++++++++++++++++++ - OvmfPkg/PlatformPei/PlatformPei.inf | 1 - - 4 files changed, 73 insertions(+), 2 deletions(-) + 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c create mode 100644 ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc -index 891e065311..e0476ede4f 100644 +index 64aa4e96e5..c37c4ba61e 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc -@@ -282,6 +282,8 @@ - gEfiSecurityPkgTokenSpaceGuid.PcdTpm2HashMask|0 +@@ -311,6 +311,8 @@ + gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress|0x0 !endif -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE -+ ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE ++ [PcdsDynamicHii] - gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVariableGuid|0x0|FALSE|NV,BS + gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGuid|0x0|FALSE|NV,BS -@@ -384,7 +386,10 @@ +@@ -416,7 +418,10 @@ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf - MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf { -+ -+ NULL|ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf -+ } ++ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf { ++ ++ NULL|ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf ++ } MdeModulePkg/Universal/SerialDxe/SerialDxe.inf MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf diff --git a/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c new file mode 100644 -index 0000000000..bfd3a6a535 +index 0000000000..37f71c5e4c --- /dev/null +++ b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c @@ -0,0 +1,34 @@ -+/** @file -+* Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg -+* -+* Copyright (C) 2015-2020, Red Hat, Inc. -+* Copyright (c) 2014, Linaro Ltd. All rights reserved.
-+* -+* SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+ -+#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ -+ do { \ -+ BOOLEAN Setting; \ -+ RETURN_STATUS PcdStatus; \ -+ \ -+ if (!RETURN_ERROR (QemuFwCfgParseBool ( \ -+ "opt/org.tianocore.edk2.aavmf/" #TokenName, &Setting))) { \ -+ PcdStatus = PcdSetBoolS (TokenName, Setting); \ -+ ASSERT_RETURN_ERROR (PcdStatus); \ -+ } \ -+ } while (0) -+ -+RETURN_STATUS -+EFIAPI -+TerminalPcdProducerLibConstructor ( -+ VOID -+ ) -+{ -+ UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm); -+ return RETURN_SUCCESS; -+} ++/** @file ++* Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg ++* ++* Copyright (C) 2015-2020, Red Hat, Inc. ++* Copyright (c) 2014, Linaro Ltd. All rights reserved.
++* ++* SPDX-License-Identifier: BSD-2-Clause-Patent ++**/ ++ ++#include ++#include ++#include ++ ++#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ ++ do { \ ++ BOOLEAN Setting; \ ++ RETURN_STATUS PcdStatus; \ ++ \ ++ if (!RETURN_ERROR (QemuFwCfgParseBool ( \ ++ "opt/org.tianocore.edk2.aavmf/" #TokenName, &Setting))) { \ ++ PcdStatus = PcdSetBoolS (TokenName, Setting); \ ++ ASSERT_RETURN_ERROR (PcdStatus); \ ++ } \ ++ } while (0) ++ ++RETURN_STATUS ++EFIAPI ++TerminalPcdProducerLibConstructor ( ++ VOID ++ ) ++{ ++ UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm); ++ return RETURN_SUCCESS; ++} diff --git a/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf new file mode 100644 -index 0000000000..a51dbd1670 +index 0000000000..c840f6f97a --- /dev/null +++ b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf @@ -0,0 +1,33 @@ -+## @file -+# Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg -+# -+# Copyright (C) 2015-2020, Red Hat, Inc. -+# Copyright (c) 2014, Linaro Ltd. All rights reserved.
-+# -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+ -+[Defines] -+ INF_VERSION = 0x00010005 -+ BASE_NAME = TerminalPcdProducerLib -+ FILE_GUID = 4a0c5ed7-8c42-4c01-8f4c-7bf258316a96 -+ MODULE_TYPE = BASE -+ VERSION_STRING = 1.0 -+ LIBRARY_CLASS = NULL -+ CONSTRUCTOR = TerminalPcdProducerLibConstructor -+ -+[Sources] -+ TerminalPcdProducerLib.c -+ -+[Packages] -+ MdeModulePkg/MdeModulePkg.dec -+ MdePkg/MdePkg.dec -+ OvmfPkg/OvmfPkg.dec -+ -+[LibraryClasses] -+ DebugLib -+ PcdLib -+ QemuFwCfgSimpleParserLib -+ -+[Pcd] -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## SOMETIMES_PRODUCES -diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf -index 7d26b43680..69eb3edad3 100644 ---- a/OvmfPkg/PlatformPei/PlatformPei.inf -+++ b/OvmfPkg/PlatformPei/PlatformPei.inf -@@ -93,7 +93,6 @@ - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved -- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration - gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm - gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode - gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable --- -2.27.0 - ++## @file ++# Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg ++# ++# Copyright (C) 2015-2020, Red Hat, Inc. ++# Copyright (c) 2014, Linaro Ltd. All rights reserved.
++# ++# SPDX-License-Identifier: BSD-2-Clause-Patent ++## ++ ++[Defines] ++ INF_VERSION = 0x00010005 ++ BASE_NAME = TerminalPcdProducerLib ++ FILE_GUID = 4a0c5ed7-8c42-4c01-8f4c-7bf258316a96 ++ MODULE_TYPE = BASE ++ VERSION_STRING = 1.0 ++ LIBRARY_CLASS = NULL ++ CONSTRUCTOR = TerminalPcdProducerLibConstructor ++ ++[Sources] ++ TerminalPcdProducerLib.c ++ ++[Packages] ++ MdeModulePkg/MdeModulePkg.dec ++ MdePkg/MdePkg.dec ++ OvmfPkg/OvmfPkg.dec ++ ++[LibraryClasses] ++ DebugLib ++ PcdLib ++ QemuFwCfgSimpleParserLib ++ ++[Pcd] ++ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm ## SOMETIMES_PRODUCES diff --git a/SOURCES/0019-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch b/0007-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch similarity index 92% rename from SOURCES/0019-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch rename to 0007-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch index 070ecc4..5ad755d 100644 --- a/SOURCES/0019-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch +++ b/0007-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch @@ -1,7 +1,7 @@ -From 02687f83845b9ae8455655e117f0b7cdaa18ba5c Mon Sep 17 00:00:00 2001 +From 9f24c54074c15630f78e019e018f791296a768d7 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 21 Nov 2017 00:57:45 +0100 -Subject: OvmfPkg: enable DEBUG_VERBOSE (RHEL only) +Subject: [PATCH] OvmfPkg: enable DEBUG_VERBOSE (RHEL only) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -65,23 +65,23 @@ Signed-off-by: Paolo Bonzini 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index 6ea3621225..366fa79f62 100644 +index 627fded641..cef43b34b7 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -486,7 +486,7 @@ +@@ -429,7 +429,7 @@ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may # // significantly impact boot performance # DEBUG_ERROR 0x80000000 // Error - gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8040004F ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8040004F !if $(SOURCE_DEBUG_ENABLE) == TRUE gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 4cacf0ea94..2aacf1a5ff 100644 +index dddef5ed0e..270bd612e5 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -534,7 +534,7 @@ +@@ -535,7 +535,7 @@ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may # // significantly impact boot performance # DEBUG_ERROR 0x80000000 // Error @@ -91,10 +91,10 @@ index 4cacf0ea94..2aacf1a5ff 100644 !if $(SOURCE_DEBUG_ENABLE) == TRUE gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 6225f8e095..2613c83adb 100644 +index 933abb258f..269a4b2b21 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -538,7 +538,7 @@ +@@ -542,7 +542,7 @@ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may # // significantly impact boot performance # DEBUG_ERROR 0x80000000 // Error @@ -104,10 +104,10 @@ index 6225f8e095..2613c83adb 100644 !if $(SOURCE_DEBUG_ENABLE) == TRUE gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index b66fc67563..d7d34eeef2 100644 +index 04157ab14b..9614cc1c56 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -540,7 +540,7 @@ +@@ -561,7 +561,7 @@ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may # // significantly impact boot performance # DEBUG_ERROR 0x80000000 // Error @@ -116,6 +116,3 @@ index b66fc67563..d7d34eeef2 100644 !if $(SOURCE_DEBUG_ENABLE) == TRUE gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 --- -2.27.0 - diff --git a/SOURCES/0020-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch b/0008-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch similarity index 84% rename from SOURCES/0020-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch rename to 0008-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch index 3ec8a64..4fbcec0 100644 --- a/SOURCES/0020-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch +++ b/0008-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch @@ -1,9 +1,13 @@ -From a5dd9e06c570b2c003a2b6aea681f0d93bfbfdc4 Mon Sep 17 00:00:00 2001 +From 271d90ce05cbdb95c8f839e3bee5d0a0937e12fc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 21 Nov 2017 00:57:46 +0100 -Subject: OvmfPkg: silence DEBUG_VERBOSE (0x00400000) in +Subject: [PATCH] OvmfPkg: silence DEBUG_VERBOSE (0x00400000) in QemuVideoDxe/QemuRamfbDxe (RH) +edk2-stable202402 rebase: + +- context changes due to CSM support removal. + Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -82,92 +86,86 @@ Signed-off-by: Paolo Bonzini 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index 366fa79f62..a289d8a573 100644 +index cef43b34b7..f53380aca2 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -750,8 +750,14 @@ +@@ -691,8 +691,14 @@ + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf - OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf -+ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ } -+ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ } ++ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { ++ ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F ++ } ++ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { ++ ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F ++ } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf # diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 2aacf1a5ff..1a5cfa4c6d 100644 +index 270bd612e5..d942c7354a 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -846,9 +846,15 @@ - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf +@@ -828,8 +828,14 @@ + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - !ifndef $(CSM_ENABLE) - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } - !endif -- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf - # diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 2613c83adb..11002ffd95 100644 +index 269a4b2b21..d915b847cb 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -860,9 +860,15 @@ - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf +@@ -842,8 +842,14 @@ + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - !ifndef $(CSM_ENABLE) - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } - !endif -- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf - # diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index d7d34eeef2..f176aa4061 100644 +index 9614cc1c56..12ee5510bd 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -858,9 +858,15 @@ - MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf +@@ -910,8 +910,14 @@ + MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf + MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf - !ifndef $(CSM_ENABLE) - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } - !endif -- OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf + OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf - # --- -2.27.0 - diff --git a/SOURCES/0021-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch b/0009-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch similarity index 91% rename from SOURCES/0021-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch rename to 0009-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch index 7160188..a2e83e7 100644 --- a/SOURCES/0021-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch +++ b/0009-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch @@ -1,8 +1,8 @@ -From ccc2c9c85f43662f942bf5c303f4a1a9f964c36d Mon Sep 17 00:00:00 2001 +From f3810904a75876f09592863281fe4e8464851f18 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 27 Jan 2016 03:05:18 +0100 -Subject: ArmVirtPkg: silence DEBUG_VERBOSE (0x00400000) in QemuRamfbDxe (RH - only) +Subject: [PATCH] ArmVirtPkg: silence DEBUG_VERBOSE (0x00400000) in + QemuRamfbDxe (RH only) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -61,37 +61,34 @@ Signed-off-by: Laszlo Ersek 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc -index ec0edf6e7b..e6fad9f066 100644 +index c37c4ba61e..00e656d0c9 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc -@@ -509,7 +509,10 @@ +@@ -546,7 +546,10 @@ # # Video support # - OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf -+ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|($(DEBUG_PRINT_ERROR_LEVEL)) & 0xFFBFFFFF -+ } ++ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { ++ ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|($(DEBUG_PRINT_ERROR_LEVEL)) & 0xFFBFFFFF ++ } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf OvmfPkg/PlatformDxe/Platform.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc -index a8bb83b288..656c9d99a3 100644 +index 2cf96accbd..c7918c8cf3 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc -@@ -438,7 +438,10 @@ +@@ -450,7 +450,10 @@ # # Video support # - OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf -+ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|($(DEBUG_PRINT_ERROR_LEVEL)) & 0xFFBFFFFF -+ } ++ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf { ++ ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|($(DEBUG_PRINT_ERROR_LEVEL)) & 0xFFBFFFFF ++ } OvmfPkg/VirtioGpuDxe/VirtioGpu.inf OvmfPkg/PlatformDxe/Platform.inf --- -2.27.0 - diff --git a/SOURCES/0022-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch b/0010-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch similarity index 89% rename from SOURCES/0022-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch rename to 0010-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch index 9cf8fe5..4ee0977 100644 --- a/SOURCES/0022-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch +++ b/0010-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch @@ -1,8 +1,8 @@ -From b3147a5ce92a149532ef1ec47cdf14082a56654d Mon Sep 17 00:00:00 2001 +From 3fba0b8213fc5be8a164b3908d54af511fa21a10 Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daude Date: Thu, 1 Aug 2019 20:43:48 +0200 -Subject: OvmfPkg: QemuRamfbDxe: Do not report DXE failure on Aarch64 silent - builds (RH only) +Subject: [PATCH] OvmfPkg: QemuRamfbDxe: Do not report DXE failure on Aarch64 + silent builds (RH only) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -47,49 +47,46 @@ Signed-off-by: Laszlo Ersek 2 files changed, 15 insertions(+) diff --git a/OvmfPkg/QemuRamfbDxe/QemuRamfb.c b/OvmfPkg/QemuRamfbDxe/QemuRamfb.c -index 0d49d8bbab..dbf9bcbe16 100644 +index 5a1044f0dc..83c6d26c74 100644 --- a/OvmfPkg/QemuRamfbDxe/QemuRamfb.c +++ b/OvmfPkg/QemuRamfbDxe/QemuRamfb.c @@ -13,6 +13,7 @@ #include #include #include -+#include ++#include #include #include #include -@@ -242,6 +243,19 @@ InitializeQemuRamfb ( +@@ -259,6 +260,19 @@ InitializeQemuRamfb ( Status = QemuFwCfgFindFile ("etc/ramfb", &mRamfbFwCfgItem, &FwCfgSize); if (EFI_ERROR (Status)) { -+#if defined (MDE_CPU_AARCH64) -+ // -+ // RHBZ#1714446 -+ // If no ramfb device was configured, this platform DXE driver should -+ // returns EFI_NOT_FOUND, so the DXE Core can unload it. However, even -+ // using a silent build, an error message is issued to the guest console. -+ // Since this confuse users, return success and stay resident. The wasted -+ // guest RAM still gets freed later after ExitBootServices(). -+ // -+ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { -+ return EFI_SUCCESS; -+ } -+#endif ++#if defined (MDE_CPU_AARCH64) ++ // ++ // RHBZ#1714446 ++ // If no ramfb device was configured, this platform DXE driver should ++ // returns EFI_NOT_FOUND, so the DXE Core can unload it. However, even ++ // using a silent build, an error message is issued to the guest console. ++ // Since this confuse users, return success and stay resident. The wasted ++ // guest RAM still gets freed later after ExitBootServices(). ++ // ++ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { ++ return EFI_SUCCESS; ++ } ++#endif return EFI_NOT_FOUND; } - if (FwCfgSize != sizeof (RAMFB_CONFIG)) { + diff --git a/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf b/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf -index e3890b8c20..6ffee5acb2 100644 +index e3890b8c20..f79a4bc987 100644 --- a/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf +++ b/OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf @@ -29,6 +29,7 @@ BaseLib BaseMemoryLib DebugLib -+ DebugPrintErrorLevelLib ++ DebugPrintErrorLevelLib DevicePathLib FrameBufferBltLib MemoryAllocationLib --- -2.27.0 - diff --git a/SOURCES/0023-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch b/0011-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch similarity index 87% rename from SOURCES/0023-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch rename to 0011-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch index fd57bb6..13abca5 100644 --- a/SOURCES/0023-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch +++ b/0011-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch @@ -1,8 +1,8 @@ -From a663867a4a99b97d0e1c5fdfed0389312fecd767 Mon Sep 17 00:00:00 2001 +From 57370ffc06e8d5de6eb5c41e5b33a7891cdcc0e7 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 21 Nov 2017 00:57:47 +0100 -Subject: OvmfPkg: silence EFI_D_VERBOSE (0x00400000) in NvmExpressDxe (RH - only) +Subject: [PATCH] OvmfPkg: silence EFI_D_VERBOSE (0x00400000) in NvmExpressDxe + (RH only) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -63,27 +63,27 @@ Signed-off-by: Paolo Bonzini 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index a289d8a573..ccdf9b8ce0 100644 +index f53380aca2..32f47704bc 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -744,7 +744,10 @@ - OvmfPkg/SataControllerDxe/SataControllerDxe.inf +@@ -686,7 +686,10 @@ + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -+ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf { -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ } ++ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf { ++ ++ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F ++ } MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 1a5cfa4c6d..a0666930d6 100644 +index d942c7354a..49540d54d0 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -839,7 +839,10 @@ - OvmfPkg/SataControllerDxe/SataControllerDxe.inf +@@ -823,7 +823,10 @@ + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf @@ -95,11 +95,11 @@ index 1a5cfa4c6d..a0666930d6 100644 MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 11002ffd95..5efeb42bf3 100644 +index d915b847cb..1c4e0514ed 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -853,7 +853,10 @@ - OvmfPkg/SataControllerDxe/SataControllerDxe.inf +@@ -837,7 +837,10 @@ + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf @@ -111,11 +111,11 @@ index 11002ffd95..5efeb42bf3 100644 MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index f176aa4061..10fb7d7069 100644 +index 12ee5510bd..e50e63b3f6 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -851,7 +851,10 @@ - OvmfPkg/SataControllerDxe/SataControllerDxe.inf +@@ -905,7 +905,10 @@ + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf @@ -126,6 +126,3 @@ index f176aa4061..10fb7d7069 100644 MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf --- -2.27.0 - diff --git a/SOURCES/0025-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch b/0012-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch similarity index 89% rename from SOURCES/0025-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch rename to 0012-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch index 1ee9e11..573fcb7 100644 --- a/SOURCES/0025-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch +++ b/0012-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch @@ -1,8 +1,8 @@ -From d9416e3015cadb3214d5ca409e57fd2352ae1961 Mon Sep 17 00:00:00 2001 +From 1025d0336c038ed12354830fccef84771f611656 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 24 Jun 2020 11:31:36 +0200 -Subject: OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no "-kernel" in - silent aa64 build (RH) +Subject: [PATCH] OvmfPkg/QemuKernelLoaderFsDxe: suppress error on no "-kernel" + in silent aa64 build (RH) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -32,52 +32,49 @@ Signed-off-by: Miroslav Rezanina 2 files changed, 18 insertions(+) diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c -index 6832d563bc..08ed67f5ff 100644 +index 3c12085f6c..e192809198 100644 --- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c +++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.c @@ -19,6 +19,7 @@ #include #include #include -+#include ++#include #include #include #include -@@ -1054,6 +1055,22 @@ QemuKernelLoaderFsDxeEntrypoint ( +@@ -1081,6 +1082,22 @@ QemuKernelLoaderFsDxeEntrypoint ( if (KernelBlob->Data == NULL) { Status = EFI_NOT_FOUND; -+#if defined (MDE_CPU_AARCH64) -+ // -+ // RHBZ#1844682 -+ // -+ // If the "-kernel" QEMU option is not being used, this platform DXE driver -+ // should return EFI_NOT_FOUND, so that the DXE Core can unload it. -+ // However, the associated error message, logged by the DXE Core to the -+ // serial console, is not desired in the silent edk2-aarch64 build, given -+ // that the absence of "-kernel" is nothing out of the ordinary. Therefore, -+ // return success and stay resident. The wasted guest RAM still gets freed -+ // after ExitBootServices(). -+ // -+ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { -+ Status = EFI_SUCCESS; -+ } -+#endif ++#if defined (MDE_CPU_AARCH64) ++ // ++ // RHBZ#1844682 ++ // ++ // If the "-kernel" QEMU option is not being used, this platform DXE driver ++ // should return EFI_NOT_FOUND, so that the DXE Core can unload it. ++ // However, the associated error message, logged by the DXE Core to the ++ // serial console, is not desired in the silent edk2-aarch64 build, given ++ // that the absence of "-kernel" is nothing out of the ordinary. Therefore, ++ // return success and stay resident. The wasted guest RAM still gets freed ++ // after ExitBootServices(). ++ // ++ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { ++ Status = EFI_SUCCESS; ++ } ++#endif goto FreeBlobs; } diff --git a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf -index 7b35adb8e0..e0331c6e2c 100644 +index 7b35adb8e0..23d9f5fca1 100644 --- a/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf +++ b/OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf @@ -28,6 +28,7 @@ BaseLib BaseMemoryLib DebugLib -+ DebugPrintErrorLevelLib ++ DebugPrintErrorLevelLib DevicePathLib MemoryAllocationLib QemuFwCfgLib --- -2.27.0 - diff --git a/SOURCES/0026-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch b/0013-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch similarity index 83% rename from SOURCES/0026-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch rename to 0013-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch index 1db7c47..13fd6eb 100644 --- a/SOURCES/0026-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch +++ b/0013-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch @@ -1,8 +1,8 @@ -From fd19e4e33d52e843e6e35adde2c1e266497e8a7b Mon Sep 17 00:00:00 2001 +From 49bcb15e8b15f3a02427787981a09f09d17528f7 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 24 Jun 2020 11:40:09 +0200 -Subject: SecurityPkg/Tcg2Dxe: suppress error on no swtpm in silent aa64 build - (RH) +Subject: [PATCH] SecurityPkg/Tcg2Dxe: suppress error on no swtpm in silent + aa64 build (RH) Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: @@ -31,52 +31,49 @@ Signed-off-by: Miroslav Rezanina 2 files changed, 18 insertions(+) diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c -index 6d17616c1c..f1a97d4b2d 100644 +index b55b6c12d2..0be885c391 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c -@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent +@@ -29,6 +29,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include -+#include ++#include #include #include #include -@@ -2642,6 +2643,22 @@ DriverEntry ( - if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid) || - CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ +@@ -2743,6 +2744,22 @@ DriverEntry ( + CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) + { DEBUG ((DEBUG_INFO, "No TPM2 instance required!\n")); -+#if defined (MDE_CPU_AARCH64) -+ // -+ // RHBZ#1844682 -+ // -+ // If swtpm / vTPM2 is not being used, this driver should return -+ // EFI_UNSUPPORTED, so that the DXE Core can unload it. However, the -+ // associated error message, logged by the DXE Core to the serial console, -+ // is not desired in the silent edk2-aarch64 build, given that the absence -+ // of swtpm / vTPM2 is nothing out of the ordinary. Therefore, return -+ // success and stay resident. The wasted guest RAM still gets freed after -+ // ExitBootServices(). -+ // -+ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { -+ return EFI_SUCCESS; -+ } -+#endif ++#if defined (MDE_CPU_AARCH64) ++ // ++ // RHBZ#1844682 ++ // ++ // If swtpm / vTPM2 is not being used, this driver should return ++ // EFI_UNSUPPORTED, so that the DXE Core can unload it. However, the ++ // associated error message, logged by the DXE Core to the serial console, ++ // is not desired in the silent edk2-aarch64 build, given that the absence ++ // of swtpm / vTPM2 is nothing out of the ordinary. Therefore, return ++ // success and stay resident. The wasted guest RAM still gets freed after ++ // ExitBootServices(). ++ // ++ if (GetDebugPrintErrorLevel () == DEBUG_ERROR) { ++ return EFI_SUCCESS; ++ } ++#endif return EFI_UNSUPPORTED; } diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf -index 7dc7a2683d..3bc8833931 100644 +index a645474bf3..dbb7a52f33 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf +++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf @@ -55,6 +55,7 @@ UefiRuntimeServicesTableLib BaseMemoryLib DebugLib -+ DebugPrintErrorLevelLib ++ DebugPrintErrorLevelLib Tpm2CommandLib PrintLib UefiLib --- -2.27.0 - diff --git a/0014-OvmfPkg-Remove-EbcDxe-RHEL-only.patch b/0014-OvmfPkg-Remove-EbcDxe-RHEL-only.patch new file mode 100644 index 0000000..044e031 --- /dev/null +++ b/0014-OvmfPkg-Remove-EbcDxe-RHEL-only.patch @@ -0,0 +1,126 @@ +From b42de989e72259b0acd839b1fb6670ad9ff97aed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:28:49 +0200 +Subject: [PATCH] OvmfPkg: Remove EbcDxe (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [2/19] 6777c3dc453e4aecddc20216f783ba2a5acccaa0 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove EFI Byte Code interpreter. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 - + OvmfPkg/AmdSev/AmdSevX64.fdf | 1 - + OvmfPkg/OvmfPkgIa32.dsc | 1 - + OvmfPkg/OvmfPkgIa32.fdf | 1 - + OvmfPkg/OvmfPkgIa32X64.dsc | 1 - + OvmfPkg/OvmfPkgIa32X64.fdf | 1 - + OvmfPkg/OvmfPkgX64.dsc | 1 - + OvmfPkg/OvmfPkgX64.fdf | 1 - + 8 files changed, 8 deletions(-) + +diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc +index 32f47704bc..6b6e108d11 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.dsc ++++ b/OvmfPkg/AmdSev/AmdSevX64.dsc +@@ -611,7 +611,6 @@ + !include OvmfPkg/Include/Dsc/OvmfTpmSecurityStub.dsc.inc + } + +- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + UefiCpuPkg/CpuDxe/CpuDxe.inf + OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf +index 595945181c..c176043482 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.fdf ++++ b/OvmfPkg/AmdSev/AmdSevX64.fdf +@@ -212,7 +212,6 @@ INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf +-INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + INF UefiCpuPkg/CpuDxe/CpuDxe.inf + INF OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index 49540d54d0..d368aa11fe 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -746,7 +746,6 @@ + !include OvmfPkg/Include/Dsc/OvmfTpmSecurityStub.dsc.inc + } + +- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + UefiCpuPkg/CpuDxe/CpuDxe.inf + OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index 0d4abb50a8..ef933def99 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -216,7 +216,6 @@ INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf +-INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + INF UefiCpuPkg/CpuDxe/CpuDxe.inf + INF OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index 1c4e0514ed..cf09bdf785 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -760,7 +760,6 @@ + !include OvmfPkg/Include/Dsc/OvmfTpmSecurityStub.dsc.inc + } + +- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + UefiCpuPkg/CpuDxe/CpuDxe.inf + OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index 23a825a012..0cd98ada5a 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -217,7 +217,6 @@ INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf +-INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + INF UefiCpuPkg/CpuDxe/CpuDxe.inf + INF OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index e50e63b3f6..098d569381 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -805,7 +805,6 @@ + !include OvmfPkg/Include/Dsc/OvmfTpmSecurityStub.dsc.inc + } + +- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + + UefiCpuPkg/CpuDxe/CpuDxe.inf { +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index 4dcd6a033c..b201505214 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -245,7 +245,6 @@ INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf + + INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf + INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf +-INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf + + INF UefiCpuPkg/CpuDxe/CpuDxe.inf diff --git a/0015-OvmfPkg-Remove-VirtioGpu-device-driver-RHEL-only.patch b/0015-OvmfPkg-Remove-VirtioGpu-device-driver-RHEL-only.patch new file mode 100644 index 0000000..ac2a76d --- /dev/null +++ b/0015-OvmfPkg-Remove-VirtioGpu-device-driver-RHEL-only.patch @@ -0,0 +1,126 @@ +From a16503fb8e213d321920b195d6fc40015a00cc20 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:28:59 +0200 +Subject: [PATCH] OvmfPkg: Remove VirtioGpu device driver (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [4/19] f0a41317291f2e9e3b5bd3125149c3866f23ab08 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +QemuVideoDxe binds virtio-vga, so VirtioGpu is not needed. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 - + OvmfPkg/AmdSev/AmdSevX64.fdf | 1 - + OvmfPkg/OvmfPkgIa32.dsc | 1 - + OvmfPkg/OvmfPkgIa32.fdf | 1 - + OvmfPkg/OvmfPkgIa32X64.dsc | 1 - + OvmfPkg/OvmfPkgIa32X64.fdf | 1 - + OvmfPkg/OvmfPkgX64.dsc | 1 - + OvmfPkg/OvmfPkgX64.fdf | 1 - + 8 files changed, 8 deletions(-) + +diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc +index 6b6e108d11..5461c1290d 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.dsc ++++ b/OvmfPkg/AmdSev/AmdSevX64.dsc +@@ -701,7 +701,6 @@ + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } +- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + + # + # ISA Support +diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf +index c176043482..10538a0465 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.fdf ++++ b/OvmfPkg/AmdSev/AmdSevX64.fdf +@@ -300,7 +300,6 @@ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf + + INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf +-INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + INF OvmfPkg/PlatformDxe/Platform.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf + INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index d368aa11fe..40e78014c4 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -838,7 +838,6 @@ + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } +- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf + + # +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index ef933def99..68d59968ec 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -317,7 +317,6 @@ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf + INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf +-INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + INF OvmfPkg/PlatformDxe/Platform.inf + INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf + INF OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index cf09bdf785..6ade9aa0ef 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -852,7 +852,6 @@ + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } +- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf + + # +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index 0cd98ada5a..8891d96422 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -323,7 +323,6 @@ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf + INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf +-INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + INF OvmfPkg/PlatformDxe/Platform.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf + INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index 098d569381..8563835ae5 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -920,7 +920,6 @@ + + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F + } +- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + OvmfPkg/VirtHstiDxe/VirtHstiDxe.inf + + # +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index b201505214..06ac4423da 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -356,7 +356,6 @@ INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + INF OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf + INF OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf +-INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + INF OvmfPkg/PlatformDxe/Platform.inf + INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf + INF OvmfPkg/IoMmuDxe/IoMmuDxe.inf diff --git a/0016-OvmfPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL-on.patch b/0016-OvmfPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL-on.patch new file mode 100644 index 0000000..7e2fecc --- /dev/null +++ b/0016-OvmfPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL-on.patch @@ -0,0 +1,100 @@ +From 1c3ff57eaf5b559a1b390888ab6f5e235bec414d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:13 +0200 +Subject: [PATCH] OvmfPkg: Remove VirtioFsDxe filesystem driver (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [9/19] b40d8a6b9c38568a74fb922b12bbae9f0e721f95 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the virtio-fs driver. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/OvmfPkgIa32.dsc | 1 - + OvmfPkg/OvmfPkgIa32.fdf | 1 - + OvmfPkg/OvmfPkgIa32X64.dsc | 1 - + OvmfPkg/OvmfPkgIa32X64.fdf | 1 - + OvmfPkg/OvmfPkgX64.dsc | 1 - + OvmfPkg/OvmfPkgX64.fdf | 1 - + 6 files changed, 6 deletions(-) + +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index 40e78014c4..afd2a3c5c0 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -816,7 +816,6 @@ + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index 68d59968ec..c392b96470 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -290,7 +290,6 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour + + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +-INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index 6ade9aa0ef..f5a4c57c8e 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -830,7 +830,6 @@ + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index 8891d96422..6278daeeee 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -291,7 +291,6 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour + + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +-INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index 8563835ae5..08b73a64c9 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -898,7 +898,6 @@ + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index 06ac4423da..fc4b6dd3a4 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -322,7 +322,6 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour + + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +-INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + diff --git a/0017-ArmVirtPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL.patch b/0017-ArmVirtPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL.patch new file mode 100644 index 0000000..f78d50f --- /dev/null +++ b/0017-ArmVirtPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL.patch @@ -0,0 +1,61 @@ +From d074f2941368b1b91ede467445c4f18904b7c228 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:16 +0200 +Subject: [PATCH] ArmVirtPkg: Remove VirtioFsDxe filesystem driver (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [10/19] 808ad4385c24fbf34fb0ba359808e6d364e1d030 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the virtio-fs driver. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + ArmVirtPkg/ArmVirtQemu.dsc | 1 - + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 - + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 - + 3 files changed, 3 deletions(-) + +diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc +index 00e656d0c9..d1deccaadc 100644 +--- a/ArmVirtPkg/ArmVirtQemu.dsc ++++ b/ArmVirtPkg/ArmVirtQemu.dsc +@@ -464,7 +464,6 @@ + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + # + # Bds +diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +index 38906004d7..7205274bed 100644 +--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc ++++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +@@ -85,7 +85,6 @@ READ_LOCK_STATUS = TRUE + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + # + # Status Code Routing +diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc +index c7918c8cf3..9643fd5427 100644 +--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc ++++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc +@@ -368,7 +368,6 @@ + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf +- OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf + + # + # Bds diff --git a/0018-OvmfPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch b/0018-OvmfPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch new file mode 100644 index 0000000..c7b6315 --- /dev/null +++ b/0018-OvmfPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch @@ -0,0 +1,126 @@ +From cb327136ecf44079a7fcc1dd9b68d98e1124becc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:19 +0200 +Subject: [PATCH] OvmfPkg: Remove UdfDxe filesystem driver (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [11/19] 21614de37221fca27d4eec0f03c5c8bce5911af3 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the UDF driver. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 - + OvmfPkg/AmdSev/AmdSevX64.fdf | 1 - + OvmfPkg/OvmfPkgIa32.dsc | 1 - + OvmfPkg/OvmfPkgIa32.fdf | 1 - + OvmfPkg/OvmfPkgIa32X64.dsc | 1 - + OvmfPkg/OvmfPkgIa32X64.fdf | 1 - + OvmfPkg/OvmfPkgX64.dsc | 1 - + OvmfPkg/OvmfPkgX64.fdf | 1 - + 8 files changed, 8 deletions(-) + +diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc +index 5461c1290d..cf1ad83e09 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.dsc ++++ b/OvmfPkg/AmdSev/AmdSevX64.dsc +@@ -679,7 +679,6 @@ + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf +index 10538a0465..c56c98dc85 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.fdf ++++ b/OvmfPkg/AmdSev/AmdSevX64.fdf +@@ -280,7 +280,6 @@ INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf + INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + INF FatPkg/EnhancedFatDxe/Fat.inf +-INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + INF OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf + INF OvmfPkg/AmdSev/Grub/Grub.inf +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index afd2a3c5c0..d8ae542686 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -815,7 +815,6 @@ + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index c392b96470..0ffa3be750 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -289,7 +289,6 @@ INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf + INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + INF FatPkg/EnhancedFatDxe/Fat.inf +-INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index f5a4c57c8e..52ac2c96fc 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -829,7 +829,6 @@ + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index 6278daeeee..c4f3ec0735 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -290,7 +290,6 @@ INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf + INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + INF FatPkg/EnhancedFatDxe/Fat.inf +-INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index 08b73a64c9..f76d0ef7bc 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -897,7 +897,6 @@ + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index fc4b6dd3a4..bedd85ef7a 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -321,7 +321,6 @@ INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf + INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf + + INF FatPkg/EnhancedFatDxe/Fat.inf +-INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + INF MdeModulePkg/Logo/LogoDxe.inf + diff --git a/0019-ArmVirtPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch b/0019-ArmVirtPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch new file mode 100644 index 0000000..20ab8c5 --- /dev/null +++ b/0019-ArmVirtPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch @@ -0,0 +1,61 @@ +From 2b7c645f028c66efbaa7f7132e4f2fcec003869b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:22 +0200 +Subject: [PATCH] ArmVirtPkg: Remove UdfDxe filesystem driver (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [12/19] fcadb6a747b65e4d449d48131c9a2eeed4bd3c9a +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the UDF driver. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + ArmVirtPkg/ArmVirtQemu.dsc | 1 - + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 - + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 - + 3 files changed, 3 deletions(-) + +diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc +index d1deccaadc..f91bb09fa3 100644 +--- a/ArmVirtPkg/ArmVirtQemu.dsc ++++ b/ArmVirtPkg/ArmVirtQemu.dsc +@@ -463,7 +463,6 @@ + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + # + # Bds +diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +index 7205274bed..24a9dac2fd 100644 +--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc ++++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +@@ -84,7 +84,6 @@ READ_LOCK_STATUS = TRUE + INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf +- INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + # + # Status Code Routing +diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc +index 9643fd5427..c2825aa4c2 100644 +--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc ++++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc +@@ -367,7 +367,6 @@ + MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf + MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf + FatPkg/EnhancedFatDxe/Fat.inf +- MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf + + # + # Bds diff --git a/0020-OvmfPkg-Remove-TftpDynamicCommand-from-shell-RHEL-on.patch b/0020-OvmfPkg-Remove-TftpDynamicCommand-from-shell-RHEL-on.patch new file mode 100644 index 0000000..98fa968 --- /dev/null +++ b/0020-OvmfPkg-Remove-TftpDynamicCommand-from-shell-RHEL-on.patch @@ -0,0 +1,55 @@ +From 11a0907d91727e05a5b86b5ede4f0e75572a894e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:25 +0200 +Subject: [PATCH] OvmfPkg: Remove TftpDynamicCommand from shell (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rebase to edk2-stable202405: + +rewrite due to shell build config being moved to an include file + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [13/19] cf9ef346386ac89fa05b29d429d8d1b27cf0e3b0 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to download files in the shell via TFTP. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/Include/Dsc/ShellComponents.dsc.inc | 4 ---- + OvmfPkg/Include/Fdf/ShellDxe.fdf.inc | 1 - + 2 files changed, 5 deletions(-) + +diff --git a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +index 4075688e41..3663938054 100644 +--- a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++++ b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +@@ -6,10 +6,6 @@ + + !if $(TOOL_CHAIN_TAG) != "XCODE5" + !if $(NETWORK_ENABLE) == TRUE +- ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } + ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf { + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +diff --git a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +index 38f69747b0..1637083ff1 100644 +--- a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++++ b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +@@ -6,7 +6,6 @@ + + !if $(TOOL_CHAIN_TAG) != "XCODE5" + !if $(NETWORK_ENABLE) == TRUE +-INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf + INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf + !endif + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf diff --git a/0021-ArmVirtPkg-Remove-TftpDynamicCommand-from-shell-RHEL.patch b/0021-ArmVirtPkg-Remove-TftpDynamicCommand-from-shell-RHEL.patch new file mode 100644 index 0000000..2c1aafb --- /dev/null +++ b/0021-ArmVirtPkg-Remove-TftpDynamicCommand-from-shell-RHEL.patch @@ -0,0 +1,54 @@ +From 886bace5ff4ab40fd94475ffb2668def36149790 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:28 +0200 +Subject: [PATCH] ArmVirtPkg: Remove TftpDynamicCommand from shell (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [14/19] 12436014941bd4a7c99a26d779ebdcd75f169403 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to download files in the shell via TFTP. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + ArmVirtPkg/ArmVirt.dsc.inc | 7 +++---- + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 - + 2 files changed, 3 insertions(+), 5 deletions(-) + +diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc +index 7044790a1e..ee98673e98 100644 +--- a/ArmVirtPkg/ArmVirt.dsc.inc ++++ b/ArmVirtPkg/ArmVirt.dsc.inc +@@ -391,10 +391,9 @@ + # + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + +- ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } ++ # ++ # UEFI application (Shell Embedded Boot Loader) ++ # + ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf { + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +index 24a9dac2fd..1341de0a2f 100644 +--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc ++++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +@@ -100,7 +100,6 @@ READ_LOCK_STATUS = TRUE + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + + INF ShellPkg/Application/Shell/Shell.inf +- INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf + INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf + INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf diff --git a/0022-OvmfPkg-Remove-HttpDynamicCommand-from-shell-RHEL-on.patch b/0022-OvmfPkg-Remove-HttpDynamicCommand-from-shell-RHEL-on.patch new file mode 100644 index 0000000..97ac08a --- /dev/null +++ b/0022-OvmfPkg-Remove-HttpDynamicCommand-from-shell-RHEL-on.patch @@ -0,0 +1,63 @@ +From 54738f50a11c9b607a22100dfd712bed0bc5c019 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:31 +0200 +Subject: [PATCH] OvmfPkg: Remove HttpDynamicCommand from shell (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rebase to edk2-stable202405: + +rewrite due to shell build config being moved to an include file + +Rebase to edk2-stable202311: + +Minor update, context change due to new variable policy shell command. + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [15/19] 1911cf04f27467ef1175b1976864c1111d93d19e +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to download files in the shell via HTTP(S). + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/Include/Dsc/ShellComponents.dsc.inc | 6 ------ + OvmfPkg/Include/Fdf/ShellDxe.fdf.inc | 3 --- + 2 files changed, 9 deletions(-) + +diff --git a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +index 3663938054..a568f1ecc5 100644 +--- a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++++ b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +@@ -5,12 +5,6 @@ + !if $(BUILD_SHELL) == TRUE + + !if $(TOOL_CHAIN_TAG) != "XCODE5" +-!if $(NETWORK_ENABLE) == TRUE +- ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } +-!endif + ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf { + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +diff --git a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +index 1637083ff1..c0118a46e2 100644 +--- a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++++ b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +@@ -5,9 +5,6 @@ + !if $(BUILD_SHELL) == TRUE && $(SECURE_BOOT_ENABLE) == FALSE + + !if $(TOOL_CHAIN_TAG) != "XCODE5" +-!if $(NETWORK_ENABLE) == TRUE +-INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf +-!endif + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf + INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf + !endif diff --git a/0023-ArmVirtPkg-Remove-HttpDynamicCommand-from-shell-RHEL.patch b/0023-ArmVirtPkg-Remove-HttpDynamicCommand-from-shell-RHEL.patch new file mode 100644 index 0000000..833cb16 --- /dev/null +++ b/0023-ArmVirtPkg-Remove-HttpDynamicCommand-from-shell-RHEL.patch @@ -0,0 +1,55 @@ +From 2d3f1c042054454de24c4842e768957c2a875129 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:34 +0200 +Subject: [PATCH] ArmVirtPkg: Remove HttpDynamicCommand from shell (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Rebase to edk2-stable202311: + +Minor update, context change due to new variable policy shell command. + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [16/19] 07a74f1fdcdbb9a31d25ce9760edcd852e9574c3 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to download files in the shell via HTTP(S). + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + ArmVirtPkg/ArmVirt.dsc.inc | 4 ---- + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 - + 2 files changed, 5 deletions(-) + +diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc +index ee98673e98..996b4ddfc4 100644 +--- a/ArmVirtPkg/ArmVirt.dsc.inc ++++ b/ArmVirtPkg/ArmVirt.dsc.inc +@@ -394,10 +394,6 @@ + # + # UEFI application (Shell Embedded Boot Loader) + # +- ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } + ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf { + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +index 1341de0a2f..b49bf7ad4e 100644 +--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc ++++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +@@ -100,7 +100,6 @@ READ_LOCK_STATUS = TRUE + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + + INF ShellPkg/Application/Shell/Shell.inf +- INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf + INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf + diff --git a/0024-OvmfPkg-Remove-LinuxInitrdDynamicShellCommand-RHEL-o.patch b/0024-OvmfPkg-Remove-LinuxInitrdDynamicShellCommand-RHEL-o.patch new file mode 100644 index 0000000..320c3dd --- /dev/null +++ b/0024-OvmfPkg-Remove-LinuxInitrdDynamicShellCommand-RHEL-o.patch @@ -0,0 +1,64 @@ +From 8b920381f97c2c32d6bff465a58dd7c901626a34 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:39 +0200 +Subject: [PATCH] OvmfPkg: Remove LinuxInitrdDynamicShellCommand (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rebase to edk2-stable202405: + +rewrite due to shell build config being moved to an include file + +Rebase to edk2-stable202311: + +Minor update, context change due to new variable policy shell command. + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [17/19] 491fe1301ea29c7cb56c20272e45614d5fcb6f14 +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to register a file in the shell as the +initial ramdisk for a UEFI stubbed kernel, to be booted next. + +Note: as further dynamic shell commands might show up upstream, +we intentionally preserve the empty !ifdef'ry context to ease +future downstream rebases. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + OvmfPkg/Include/Dsc/ShellComponents.dsc.inc | 4 ---- + OvmfPkg/Include/Fdf/ShellDxe.fdf.inc | 1 - + 2 files changed, 5 deletions(-) + +diff --git a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +index a568f1ecc5..f7e0f5e90e 100644 +--- a/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++++ b/OvmfPkg/Include/Dsc/ShellComponents.dsc.inc +@@ -9,10 +9,6 @@ + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE + } +- OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } + !endif + + ShellPkg/Application/Shell/Shell.inf { +diff --git a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +index c0118a46e2..dced75e388 100644 +--- a/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++++ b/OvmfPkg/Include/Fdf/ShellDxe.fdf.inc +@@ -6,7 +6,6 @@ + + !if $(TOOL_CHAIN_TAG) != "XCODE5" + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf +-INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf + !endif + + INF ShellPkg/Application/Shell/Shell.inf diff --git a/0025-ArmVirtPkg-Remove-LinuxInitrdDynamicShellCommand-RHE.patch b/0025-ArmVirtPkg-Remove-LinuxInitrdDynamicShellCommand-RHE.patch new file mode 100644 index 0000000..11e5379 --- /dev/null +++ b/0025-ArmVirtPkg-Remove-LinuxInitrdDynamicShellCommand-RHE.patch @@ -0,0 +1,66 @@ +From 8b574a1461c50e453bb431a304bb0c63d14c5ab8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= +Date: Thu, 1 Jul 2021 20:29:46 +0200 +Subject: [PATCH] ArmVirtPkg: Remove LinuxInitrdDynamicShellCommand (RHEL only) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Rebase to edk2-stable202311: + +Minor update, context change due to new variable policy shell command. + +RH-Author: Philippe Mathieu-Daudé +RH-MergeRequest: 3: Disable features for RHEL9 +RH-Commit: [18/19] 8f4e4007108462533e3d2050b84d8830073a7c0d +RH-Bugzilla: 1967747 +RH-Acked-by: Laszlo Ersek + +Remove the command to register a file in the shell as the initial +ramdisk for a UEFI stubbed kernel, to be booted next. + +Suggested-by: Laszlo Ersek +Signed-off-by: Philippe Mathieu-Daudé +Signed-off-by: Miroslav Rezanina +--- + ArmVirtPkg/ArmVirt.dsc.inc | 10 +++------- + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 - + 2 files changed, 3 insertions(+), 8 deletions(-) + +diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc +index 996b4ddfc4..2561e10ff5 100644 +--- a/ArmVirtPkg/ArmVirt.dsc.inc ++++ b/ArmVirtPkg/ArmVirt.dsc.inc +@@ -391,17 +391,13 @@ + # + MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf + +- # +- # UEFI application (Shell Embedded Boot Loader) +- # ++ # ++ # UEFI application (Shell Embedded Boot Loader) ++ # + ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf { + + gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE + } +- OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf { +- +- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE +- } + ShellPkg/Application/Shell/Shell.inf { + + ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf +diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +index b49bf7ad4e..753afd799b 100644 +--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc ++++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +@@ -101,7 +101,6 @@ READ_LOCK_STATUS = TRUE + + INF ShellPkg/Application/Shell/Shell.inf + INF ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyDynamicCommand.inf +- INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf + + # + # Bds diff --git a/SOURCES/edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch b/0026-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch similarity index 68% rename from SOURCES/edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch rename to 0026-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch index 2739061..1de9bc0 100644 --- a/SOURCES/edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch +++ b/0026-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch @@ -1,28 +1,31 @@ -From c32f4994552ea5835cf00ce06f2f7d88c71249e5 Mon Sep 17 00:00:00 2001 +From 827b877dfc01336a12539b31753358e7e264b7f3 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 28 Feb 2023 15:47:00 +0100 Subject: [PATCH] UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug -RH-Author: Miroslav Rezanina -RH-MergeRequest: 29: UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug -RH-Bugzilla: 2150267 -RH-Acked-by: Oliver Steffen -RH-Acked-by: Jon Maloy -RH-Commit: [1/1] e7e332ac0e6edf207b1b9692f2e1aed4a1fe7c0c +RH-Author: Gerd Hoffmann +RH-MergeRequest: 42: UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug +RH-Bugzilla: 2124143 +RH-Acked-by: Laszlo Ersek +RH-Commit: [1/1] 5168501c31541a57aaeb3b3bd7c3602205eb7cdf (kraxel/centos-edk2) In case the number of CPUs can in increase beyond 255 due to CPU hotplug choose x2apic mode. Signed-off-by: Gerd Hoffmann + +patch_name: edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch +present_in_specfile: true +location_in_specfile: 38 --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c -index b9a06747ed..177d15ab5b 100644 +index d724456502..c478878bb0 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c -@@ -495,7 +495,9 @@ CollectProcessorCount ( +@@ -534,7 +534,9 @@ CollectProcessorCount ( // // Enable x2APIC mode if // 1. Number of CPU is greater than 255; or @@ -33,7 +36,7 @@ index b9a06747ed..177d15ab5b 100644 // X2Apic = FALSE; if (CpuMpData->CpuCount > 255) { -@@ -503,6 +505,10 @@ CollectProcessorCount ( +@@ -542,6 +544,10 @@ CollectProcessorCount ( // If there are more than 255 processor found, force to enable X2APIC // X2Apic = TRUE; @@ -42,8 +45,5 @@ index b9a06747ed..177d15ab5b 100644 + { + X2Apic = TRUE; } else { - CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; + CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; for (Index = 0; Index < CpuMpData->CpuCount; Index++) { --- -2.37.3 - diff --git a/0027-OvmfPkg-AmdSevDxe-Shim-Reboot-workaround-RHEL-only.patch b/0027-OvmfPkg-AmdSevDxe-Shim-Reboot-workaround-RHEL-only.patch new file mode 100644 index 0000000..a750874 --- /dev/null +++ b/0027-OvmfPkg-AmdSevDxe-Shim-Reboot-workaround-RHEL-only.patch @@ -0,0 +1,121 @@ +From 24fe28e0ee42ef36f48763e7e4d738fd4c6b3583 Mon Sep 17 00:00:00 2001 +From: Oliver Steffen +Date: Wed, 16 Aug 2023 12:09:40 +0200 +Subject: [PATCH] OvmfPkg/AmdSevDxe: Shim Reboot workaround (RHEL only) + +RH-Author: Oliver Steffen +RH-MergeRequest: 46: OvmfPkg/AmdSevDxe: Shim Reboot workaround (RHEL only) +RH-Bugzilla: 2218196 +RH-Acked-by: Gerd Hoffmann +RH-Commit: [1/1] 9bf3bb989e36253aa34bf82ecfe8faa7312e8d22 (osteffen/edk2) + +Add a callback at the end of the Dxe phase that sets the +"FB_NO_REBOOT" variable under the Shim GUID. +This is a workaround for a boot loop in case a confidential +guest that uses shim is booted with a vtpm device present. + +BZ 2218196 + +Signed-off-by: Oliver Steffen + +patch_name: edk2-OvmfPkg-AmdSevDxe-Shim-Reboot-workaround-RHEL-only.patch +present_in_specfile: true +location_in_specfile: 44 +--- + OvmfPkg/AmdSevDxe/AmdSevDxe.c | 42 +++++++++++++++++++++++++++++++++ + OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 2 ++ + 2 files changed, 44 insertions(+) + +diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c +index d497a343d3..0eb88e50ff 100644 +--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c ++++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -28,6 +29,10 @@ + // Present, initialized, tested bits defined in MdeModulePkg/Core/Dxe/DxeMain.h + #define EFI_MEMORY_INTERNAL_MASK 0x0700000000000000ULL + ++static EFI_GUID ShimLockGuid = { ++ 0x605dab50, 0xe046, 0x4300, { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } ++}; ++ + STATIC + EFI_STATUS + AllocateConfidentialComputingBlob ( +@@ -191,6 +196,32 @@ STATIC EDKII_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol = { + AmdSevMemoryAccept + }; + ++VOID ++EFIAPI ++PopulateVarstore ( ++ EFI_EVENT Event, ++ VOID *Context ++ ) ++{ ++ EFI_SYSTEM_TABLE *SystemTable = (EFI_SYSTEM_TABLE *)Context; ++ EFI_STATUS Status; ++ ++ DEBUG ((DEBUG_INFO, "Populating Varstore\n")); ++ UINT32 data = 1; ++ ++ Status = SystemTable->RuntimeServices->SetVariable ( ++ L"FB_NO_REBOOT", ++ &ShimLockGuid, ++ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS, ++ sizeof (data), ++ &data ++ ); ++ ASSERT_EFI_ERROR (Status); ++ ++ Status = SystemTable->BootServices->CloseEvent (Event); ++ ASSERT_EFI_ERROR (Status); ++} ++ + EFI_STATUS + EFIAPI + AmdSevDxeEntryPoint ( +@@ -203,6 +234,7 @@ AmdSevDxeEntryPoint ( + UINTN NumEntries; + UINTN Index; + CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION *SnpBootDxeTable; ++ EFI_EVENT PopulateVarstoreEvent; + + // + // Do nothing when SEV is not enabled +@@ -361,5 +393,15 @@ AmdSevDxeEntryPoint ( + ); + } + ++ Status = gBS->CreateEventEx ( ++ EVT_NOTIFY_SIGNAL, ++ TPL_CALLBACK, ++ PopulateVarstore, ++ SystemTable, ++ &gEfiEndOfDxeEventGroupGuid, ++ &PopulateVarstoreEvent ++ ); ++ ASSERT_EFI_ERROR (Status); ++ + return EFI_SUCCESS; + } +diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +index e7c7d526c9..09cbd2b0ca 100644 +--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf ++++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +@@ -54,6 +54,8 @@ + [Guids] + gConfidentialComputingSevSnpBlobGuid + gEfiEventBeforeExitBootServicesGuid ++ gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event ++ + + [Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/0028-CryptoPkg-CrtLib-add-stat.h-include-file.patch b/0028-CryptoPkg-CrtLib-add-stat.h-include-file.patch new file mode 100644 index 0000000..3ce2d6c --- /dev/null +++ b/0028-CryptoPkg-CrtLib-add-stat.h-include-file.patch @@ -0,0 +1,28 @@ +From 95345a66f0c8e7d77ebc1b5cae3e745a2c201751 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Mon, 28 Aug 2023 13:11:02 +0200 +Subject: [PATCH] CryptoPkg/CrtLib: add stat.h include file. + +Needed by rhel downstream openssl patches. + +Signed-off-by: Gerd Hoffmann +--- + CryptoPkg/Library/Include/sys/stat.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + create mode 100644 CryptoPkg/Library/Include/sys/stat.h + +diff --git a/CryptoPkg/Library/Include/sys/stat.h b/CryptoPkg/Library/Include/sys/stat.h +new file mode 100644 +index 0000000000..22247bb2db +--- /dev/null ++++ b/CryptoPkg/Library/Include/sys/stat.h +@@ -0,0 +1,9 @@ ++/** @file ++ Include file to support building the third-party cryptographic library. ++ ++Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
++SPDX-License-Identifier: BSD-2-Clause-Patent ++ ++**/ ++ ++#include diff --git a/0029-CryptoPkg-CrtLib-add-access-open-read-write-close-sy.patch b/0029-CryptoPkg-CrtLib-add-access-open-read-write-close-sy.patch new file mode 100644 index 0000000..287a7df --- /dev/null +++ b/0029-CryptoPkg-CrtLib-add-access-open-read-write-close-sy.patch @@ -0,0 +1,139 @@ +From 0cac1a197d1e84bcde60aba246c1e16bf5508091 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Mon, 28 Aug 2023 13:27:09 +0200 +Subject: [PATCH] CryptoPkg/CrtLib: add access/open/read/write/close syscalls + +Needed by rhel downstream openssl patches, they use unix syscalls +for file access (instead of fopen + friends like the rest of the +code base). No actual file access is needed for edk2, so just +add stubs to make linking work. + +Signed-off-by: Gerd Hoffmann +--- + .../Library/BaseCryptLib/SysCall/CrtWrapper.c | 46 +++++++++++++++++++ + CryptoPkg/Library/Include/CrtLibSupport.h | 41 +++++++++++++++++ + 2 files changed, 87 insertions(+) + +diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c +index 37cdecc9bd..dfdb635536 100644 +--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c ++++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c +@@ -550,6 +550,52 @@ fread ( + return 0; + } + ++int ++access( ++ const char*, ++ int ++ ) ++{ ++ return -1; ++} ++ ++int ++open ( ++ const char *, ++ int ++ ) ++{ ++ return -1; ++} ++ ++ssize_t ++read ( ++ int, ++ void*, ++ size_t ++ ) ++{ ++ return -1; ++} ++ ++ssize_t ++write ( ++ int, ++ const void*, ++ size_t ++ ) ++{ ++ return -1; ++} ++ ++int ++close ( ++ int ++ ) ++{ ++ return -1; ++} ++ + uid_t + getuid ( + void +diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h +index f36fe08f0c..7d98496af8 100644 +--- a/CryptoPkg/Library/Include/CrtLibSupport.h ++++ b/CryptoPkg/Library/Include/CrtLibSupport.h +@@ -78,6 +78,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent + // + // Definitions for global constants used by CRT library routines + // ++#define EINTR 4 + #define EINVAL 22 /* Invalid argument */ + #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ + #define INT_MAX 0x7FFFFFFF /* Maximum (signed) int value */ +@@ -102,6 +103,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent + #define NS_INADDRSZ 4 /*%< IPv4 T_A */ + #define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */ + ++#define O_RDONLY 00000000 ++#define O_WRONLY 00000001 ++#define O_RDWR 00000002 ++ ++#define R_OK 4 ++#define W_OK 2 ++#define X_OK 1 ++#define F_OK 0 ++ + // + // Basic types mapping + // +@@ -324,6 +334,37 @@ fprintf ( + ... + ); + ++int ++access( ++ const char*, ++ int ++ ); ++ ++int ++open ( ++ const char *, ++ int ++ ); ++ ++ssize_t ++read ( ++ int, ++ void*, ++ size_t ++ ); ++ ++ssize_t ++write ( ++ int, ++ const void*, ++ size_t ++ ); ++ ++int ++close ( ++ int ++ ); ++ + time_t + time ( + time_t * diff --git a/0030-OvmfPkg-Sec-Setup-MTRR-early-in-the-boot-process.patch b/0030-OvmfPkg-Sec-Setup-MTRR-early-in-the-boot-process.patch new file mode 100644 index 0000000..5c97db0 --- /dev/null +++ b/0030-OvmfPkg-Sec-Setup-MTRR-early-in-the-boot-process.patch @@ -0,0 +1,194 @@ +From 348ea6ca54889a2b4006cc71168a173e8182f12e Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 30 Jan 2024 14:04:38 +0100 +Subject: [PATCH] OvmfPkg/Sec: Setup MTRR early in the boot process. + +RH-Author: Gerd Hoffmann +RH-MergeRequest: 55: OvmfPkg/Sec: Setup MTRR early in the boot process. +RH-Jira: RHEL-21704 +RH-Acked-by: Laszlo Ersek +RH-Commit: [1/4] c4061788d34f409944898b48642d610c259161f3 (kraxel.rh/centos-src-edk2) + +Specifically before running lzma uncompress of the main firmware volume. +This is needed to make sure caching is enabled, otherwise the uncompress +can be extremely slow. + +Adapt the ASSERTs and MTRR setup in PlatformInitLib to the changes. + +Background: Depending on virtual machine configuration kvm may uses EPT +memory types to apply guest MTRR settings. In case MTRRs are disabled +kvm will use the uncachable memory type for all mappings. The +vmx_get_mt_mask() function in the linux kernel handles this and can be +found here: + +https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/x86/kvm/vmx/vmx.c?h=v6.7.1#n7580 + +In most VM configurations kvm uses MTRR_TYPE_WRBACK unconditionally. In +case the VM has a mdev device assigned that is not the case though. + +Before commit e8aa4c6546ad ("UefiCpuPkg/ResetVector: Cache Disable +should not be set by default in CR0") kvm also ended up using +MTRR_TYPE_WRBACK due to KVM_X86_QUIRK_CD_NW_CLEARED. After that commit +kvm evaluates guest mtrr settings, which why setting up MTRRs early is +important now. + +Reviewed-by: Laszlo Ersek +Signed-off-by: Gerd Hoffmann +Message-ID: <20240130130441.772484-2-kraxel@redhat.com> + +[ kraxel: Downstream-only for now. Timely upstream merge is unlikely + due to chinese holidays and rhel-9.4 deadlines are close. + QE regression testing passed. So go with upstream posted + series v3 ] + +patch_name: edk2-OvmfPkg-Sec-Setup-MTRR-early-in-the-boot-process.patch +present_in_specfile: true +location_in_specfile: 49 +--- + OvmfPkg/IntelTdx/Sec/SecMain.c | 32 +++++++++++++++++++++ + OvmfPkg/Library/PlatformInitLib/MemDetect.c | 10 +++---- + OvmfPkg/Sec/SecMain.c | 32 +++++++++++++++++++++ + 3 files changed, 69 insertions(+), 5 deletions(-) + +diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.c b/OvmfPkg/IntelTdx/Sec/SecMain.c +index 4e750755bf..7094d86159 100644 +--- a/OvmfPkg/IntelTdx/Sec/SecMain.c ++++ b/OvmfPkg/IntelTdx/Sec/SecMain.c +@@ -26,6 +26,8 @@ + #include + #include + #include ++#include ++#include + + #define SEC_IDT_ENTRY_COUNT 34 + +@@ -47,6 +49,31 @@ IA32_IDT_GATE_DESCRIPTOR mIdtEntryTemplate = { + } + }; + ++// ++// Enable MTRR early, set default type to write back. ++// Needed to make sure caching is enabled, ++// without this lzma decompress can be very slow. ++// ++STATIC ++VOID ++SecMtrrSetup ( ++ VOID ++ ) ++{ ++ CPUID_VERSION_INFO_EDX Edx; ++ MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; ++ ++ AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32); ++ if (!Edx.Bits.MTRR) { ++ return; ++ } ++ ++ DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); ++ DefType.Bits.Type = 6; /* write back */ ++ DefType.Bits.E = 1; /* enable */ ++ AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); ++} ++ + VOID + EFIAPI + SecCoreStartupWithStack ( +@@ -203,6 +230,11 @@ SecCoreStartupWithStack ( + InitializeApicTimer (0, MAX_UINT32, TRUE, 5); + DisableApicTimerInterrupt (); + ++ // ++ // Initialize MTRR ++ // ++ SecMtrrSetup (); ++ + PeilessStartup (&SecCoreData); + + ASSERT (FALSE); +diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c +index e64c0ee324..b6ba63ef95 100644 +--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c ++++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c +@@ -1164,18 +1164,18 @@ PlatformQemuInitializeRam ( + MtrrGetAllMtrrs (&MtrrSettings); + + // +- // MTRRs disabled, fixed MTRRs disabled, default type is uncached ++ // See SecMtrrSetup(), default type should be write back + // +- ASSERT ((MtrrSettings.MtrrDefType & BIT11) == 0); ++ ASSERT ((MtrrSettings.MtrrDefType & BIT11) != 0); + ASSERT ((MtrrSettings.MtrrDefType & BIT10) == 0); +- ASSERT ((MtrrSettings.MtrrDefType & 0xFF) == 0); ++ ASSERT ((MtrrSettings.MtrrDefType & 0xFF) == MTRR_CACHE_WRITE_BACK); + + // + // flip default type to writeback + // +- SetMem (&MtrrSettings.Fixed, sizeof MtrrSettings.Fixed, 0x06); ++ SetMem (&MtrrSettings.Fixed, sizeof MtrrSettings.Fixed, MTRR_CACHE_WRITE_BACK); + ZeroMem (&MtrrSettings.Variables, sizeof MtrrSettings.Variables); +- MtrrSettings.MtrrDefType |= BIT11 | BIT10 | 6; ++ MtrrSettings.MtrrDefType |= BIT10; + MtrrSetAllMtrrs (&MtrrSettings); + + // +diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c +index 60dfa61842..725b57e2fa 100644 +--- a/OvmfPkg/Sec/SecMain.c ++++ b/OvmfPkg/Sec/SecMain.c +@@ -29,6 +29,8 @@ + #include + #include + #include ++#include ++#include + #include "AmdSev.h" + + #define SEC_IDT_ENTRY_COUNT 34 +@@ -743,6 +745,31 @@ FindAndReportEntryPoints ( + return; + } + ++// ++// Enable MTRR early, set default type to write back. ++// Needed to make sure caching is enabled, ++// without this lzma decompress can be very slow. ++// ++STATIC ++VOID ++SecMtrrSetup ( ++ VOID ++ ) ++{ ++ CPUID_VERSION_INFO_EDX Edx; ++ MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType; ++ ++ AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &Edx.Uint32); ++ if (!Edx.Bits.MTRR) { ++ return; ++ } ++ ++ DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); ++ DefType.Bits.Type = 6; /* write back */ ++ DefType.Bits.E = 1; /* enable */ ++ AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); ++} ++ + VOID + EFIAPI + SecCoreStartupWithStack ( +@@ -942,6 +969,11 @@ SecCoreStartupWithStack ( + InitializeApicTimer (0, MAX_UINT32, TRUE, 5); + DisableApicTimerInterrupt (); + ++ // ++ // Initialize MTRR ++ // ++ SecMtrrSetup (); ++ + // + // Initialize Debug Agent to support source level debug in SEC/PEI phases before memory ready. + // diff --git a/0031-MdePkg-ArchitecturalMsr.h-add-defines-for-MTRR-cache.patch b/0031-MdePkg-ArchitecturalMsr.h-add-defines-for-MTRR-cache.patch new file mode 100644 index 0000000..897e776 --- /dev/null +++ b/0031-MdePkg-ArchitecturalMsr.h-add-defines-for-MTRR-cache.patch @@ -0,0 +1,41 @@ +From d521976e1641c242c86d0495647f200694f6ba44 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 30 Jan 2024 14:04:39 +0100 +Subject: [PATCH] MdePkg/ArchitecturalMsr.h: add #defines for MTRR cache types + +RH-Author: Gerd Hoffmann +RH-MergeRequest: 55: OvmfPkg/Sec: Setup MTRR early in the boot process. +RH-Jira: RHEL-21704 +RH-Acked-by: Laszlo Ersek +RH-Commit: [2/4] a568bc2793d677462a2971aae9566a9bbc64b063 (kraxel.rh/centos-src-edk2) + +Reviewed-by: Michael D Kinney +Reviewed-by: Laszlo Ersek +Signed-off-by: Gerd Hoffmann +Message-ID: <20240130130441.772484-3-kraxel@redhat.com> + +patch_name: edk2-MdePkg-ArchitecturalMsr.h-add-defines-for-MTRR-cache.patch +present_in_specfile: true +location_in_specfile: 50 +--- + MdePkg/Include/Register/Intel/ArchitecturalMsr.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/MdePkg/Include/Register/Intel/ArchitecturalMsr.h b/MdePkg/Include/Register/Intel/ArchitecturalMsr.h +index 756e7c86ec..08ba949cf7 100644 +--- a/MdePkg/Include/Register/Intel/ArchitecturalMsr.h ++++ b/MdePkg/Include/Register/Intel/ArchitecturalMsr.h +@@ -2103,6 +2103,13 @@ typedef union { + #define MSR_IA32_MTRR_PHYSBASE9 0x00000212 + /// @} + ++#define MSR_IA32_MTRR_CACHE_UNCACHEABLE 0 ++#define MSR_IA32_MTRR_CACHE_WRITE_COMBINING 1 ++#define MSR_IA32_MTRR_CACHE_WRITE_THROUGH 4 ++#define MSR_IA32_MTRR_CACHE_WRITE_PROTECTED 5 ++#define MSR_IA32_MTRR_CACHE_WRITE_BACK 6 ++#define MSR_IA32_MTRR_CACHE_INVALID_TYPE 7 ++ + /** + MSR information returned for MSR indexes #MSR_IA32_MTRR_PHYSBASE0 to + #MSR_IA32_MTRR_PHYSBASE9 diff --git a/0032-UefiCpuPkg-MtrrLib.h-use-cache-type-defines-from-Arc.patch b/0032-UefiCpuPkg-MtrrLib.h-use-cache-type-defines-from-Arc.patch new file mode 100644 index 0000000..c92f2b1 --- /dev/null +++ b/0032-UefiCpuPkg-MtrrLib.h-use-cache-type-defines-from-Arc.patch @@ -0,0 +1,70 @@ +From 75618356e04278e4346ffc5e147b9f6f101e8173 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 30 Jan 2024 14:04:40 +0100 +Subject: [PATCH] UefiCpuPkg/MtrrLib.h: use cache type #defines from + ArchitecturalMsr.h + +RH-Author: Gerd Hoffmann +RH-MergeRequest: 55: OvmfPkg/Sec: Setup MTRR early in the boot process. +RH-Jira: RHEL-21704 +RH-Acked-by: Laszlo Ersek +RH-Commit: [3/4] 8b766c97b247a8665662697534455c19423ff23c (kraxel.rh/centos-src-edk2) + +Reviewed-by: Michael D Kinney +Reviewed-by: Laszlo Ersek +Signed-off-by: Gerd Hoffmann +Message-ID: <20240130130441.772484-4-kraxel@redhat.com> + +patch_name: edk2-UefiCpuPkg-MtrrLib.h-use-cache-type-defines-from-Arc.patch +present_in_specfile: true +location_in_specfile: 51 +--- + UefiCpuPkg/Include/Library/MtrrLib.h | 26 ++++++++++++++------------ + 1 file changed, 14 insertions(+), 12 deletions(-) + +diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Library/MtrrLib.h +index 86cc1aab3b..287d249a99 100644 +--- a/UefiCpuPkg/Include/Library/MtrrLib.h ++++ b/UefiCpuPkg/Include/Library/MtrrLib.h +@@ -9,6 +9,8 @@ + #ifndef _MTRR_LIB_H_ + #define _MTRR_LIB_H_ + ++#include ++ + // + // According to IA32 SDM, MTRRs number and MSR offset are always consistent + // for IA32 processor family +@@ -82,20 +84,20 @@ typedef struct _MTRR_SETTINGS_ { + // Memory cache types + // + typedef enum { +- CacheUncacheable = 0, +- CacheWriteCombining = 1, +- CacheWriteThrough = 4, +- CacheWriteProtected = 5, +- CacheWriteBack = 6, +- CacheInvalid = 7 ++ CacheUncacheable = MSR_IA32_MTRR_CACHE_UNCACHEABLE, ++ CacheWriteCombining = MSR_IA32_MTRR_CACHE_WRITE_COMBINING, ++ CacheWriteThrough = MSR_IA32_MTRR_CACHE_WRITE_THROUGH, ++ CacheWriteProtected = MSR_IA32_MTRR_CACHE_WRITE_PROTECTED, ++ CacheWriteBack = MSR_IA32_MTRR_CACHE_WRITE_BACK, ++ CacheInvalid = MSR_IA32_MTRR_CACHE_INVALID_TYPE, + } MTRR_MEMORY_CACHE_TYPE; + +-#define MTRR_CACHE_UNCACHEABLE 0 +-#define MTRR_CACHE_WRITE_COMBINING 1 +-#define MTRR_CACHE_WRITE_THROUGH 4 +-#define MTRR_CACHE_WRITE_PROTECTED 5 +-#define MTRR_CACHE_WRITE_BACK 6 +-#define MTRR_CACHE_INVALID_TYPE 7 ++#define MTRR_CACHE_UNCACHEABLE MSR_IA32_MTRR_CACHE_UNCACHEABLE ++#define MTRR_CACHE_WRITE_COMBINING MSR_IA32_MTRR_CACHE_WRITE_COMBINING ++#define MTRR_CACHE_WRITE_THROUGH MSR_IA32_MTRR_CACHE_WRITE_THROUGH ++#define MTRR_CACHE_WRITE_PROTECTED MSR_IA32_MTRR_CACHE_WRITE_PROTECTED ++#define MTRR_CACHE_WRITE_BACK MSR_IA32_MTRR_CACHE_WRITE_BACK ++#define MTRR_CACHE_INVALID_TYPE MSR_IA32_MTRR_CACHE_INVALID_TYPE + + typedef struct { + UINT64 BaseAddress; diff --git a/0033-OvmfPkg-Sec-use-cache-type-defines-from-Architectura.patch b/0033-OvmfPkg-Sec-use-cache-type-defines-from-Architectura.patch new file mode 100644 index 0000000..af197ec --- /dev/null +++ b/0033-OvmfPkg-Sec-use-cache-type-defines-from-Architectura.patch @@ -0,0 +1,49 @@ +From 4eea9b4625d7ea5eaf5ae0d541d96bfccacf7810 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 30 Jan 2024 14:04:41 +0100 +Subject: [PATCH] OvmfPkg/Sec: use cache type #defines from ArchitecturalMsr.h + +RH-Author: Gerd Hoffmann +RH-MergeRequest: 55: OvmfPkg/Sec: Setup MTRR early in the boot process. +RH-Jira: RHEL-21704 +RH-Acked-by: Laszlo Ersek +RH-Commit: [4/4] 55f00e3e153ca945ca458e7abc26780a8d83ac85 (kraxel.rh/centos-src-edk2) + +Reviewed-by: Laszlo Ersek +Signed-off-by: Gerd Hoffmann +Message-ID: <20240130130441.772484-5-kraxel@redhat.com> + +patch_name: edk2-OvmfPkg-Sec-use-cache-type-defines-from-Architectura.patch +present_in_specfile: true +location_in_specfile: 52 +--- + OvmfPkg/IntelTdx/Sec/SecMain.c | 2 +- + OvmfPkg/Sec/SecMain.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/OvmfPkg/IntelTdx/Sec/SecMain.c b/OvmfPkg/IntelTdx/Sec/SecMain.c +index 7094d86159..1a19f26178 100644 +--- a/OvmfPkg/IntelTdx/Sec/SecMain.c ++++ b/OvmfPkg/IntelTdx/Sec/SecMain.c +@@ -69,7 +69,7 @@ SecMtrrSetup ( + } + + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); +- DefType.Bits.Type = 6; /* write back */ ++ DefType.Bits.Type = MSR_IA32_MTRR_CACHE_WRITE_BACK; + DefType.Bits.E = 1; /* enable */ + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); + } +diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c +index 725b57e2fa..26963b924d 100644 +--- a/OvmfPkg/Sec/SecMain.c ++++ b/OvmfPkg/Sec/SecMain.c +@@ -765,7 +765,7 @@ SecMtrrSetup ( + } + + DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE); +- DefType.Bits.Type = 6; /* write back */ ++ DefType.Bits.Type = MSR_IA32_MTRR_CACHE_WRITE_BACK; + DefType.Bits.E = 1; /* enable */ + AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64); + } diff --git a/0034-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch b/0034-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch new file mode 100644 index 0000000..b79e47f --- /dev/null +++ b/0034-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch @@ -0,0 +1,54 @@ +From ee4774a753c2bc1061761e818d543a3e925ca1f0 Mon Sep 17 00:00:00 2001 +From: Sam +Date: Wed, 29 May 2024 07:46:03 +0800 +Subject: [PATCH] NetworkPkg TcpDxe: Fixed system stuck on PXE boot flow in + iPXE environment +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This bug fix is based on the following commit "NetworkPkg TcpDxe: SECURITY PATCH" +REF: 1904a64 + +Issue Description: +An "Invalid handle" error was detected during runtime when attempting to destroy a child instance of the hashing protocol. The problematic code segment was: + +NetworkPkg\TcpDxe\TcpDriver.c +Status = Hash2ServiceBinding->DestroyChild(Hash2ServiceBinding, ​&mHash2ServiceHandle); + +Root Cause Analysis: +The root cause of the error was the passing of an incorrect parameter type, a pointer to an EFI_HANDLE instead of an EFI_HANDLE itself, to the DestroyChild function. This mismatch resulted in the function receiving an invalid handle. + +Implemented Solution: +To resolve this issue, the function call was corrected to pass mHash2ServiceHandle directly: + +NetworkPkg\TcpDxe\TcpDriver.c +Status = Hash2ServiceBinding->DestroyChild(Hash2ServiceBinding, mHash2ServiceHandle); + +This modification ensures the correct handle type is used, effectively rectifying the "Invalid handle" error. + +Verification: +Testing has been conducted, confirming the efficacy of the fix. Additionally, the BIOS can boot into the OS in an iPXE environment. + +Cc: Doug Flick [MSFT] + +Signed-off-by: Sam Tsai [Wiwynn] +Reviewed-by: Saloni Kasbekar +(cherry picked from commit ced13b93afea87a8a1fe6ddbb67240a84cb2e3d3) +--- + NetworkPkg/TcpDxe/TcpDriver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c +index 40bba4080c..c6e7c0df54 100644 +--- a/NetworkPkg/TcpDxe/TcpDriver.c ++++ b/NetworkPkg/TcpDxe/TcpDriver.c +@@ -509,7 +509,7 @@ TcpDestroyService ( + // + // Destroy the instance of the hashing protocol for this controller. + // +- Status = Hash2ServiceBinding->DestroyChild (Hash2ServiceBinding, &mHash2ServiceHandle); ++ Status = Hash2ServiceBinding->DestroyChild (Hash2ServiceBinding, mHash2ServiceHandle); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } diff --git a/0035-OvmfPkg-add-morlock-support.patch b/0035-OvmfPkg-add-morlock-support.patch new file mode 100644 index 0000000..ed673ae --- /dev/null +++ b/0035-OvmfPkg-add-morlock-support.patch @@ -0,0 +1,127 @@ +From 0f36c7f078215008ffa3a8e776aacd87793b8392 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Wed, 8 May 2024 13:14:26 +0200 +Subject: [PATCH] OvmfPkg: add morlock support + +Add dsc + fdf include files to add the MorLock drivers to the build. +Add the include files to OVMF build configurations. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit b45aff0dc9cb87f316eb17a11e5d4438175d9cca) +--- + OvmfPkg/Include/Dsc/MorLock.dsc.inc | 10 ++++++++++ + OvmfPkg/Include/Fdf/MorLock.fdf.inc | 10 ++++++++++ + OvmfPkg/OvmfPkgIa32.dsc | 1 + + OvmfPkg/OvmfPkgIa32.fdf | 1 + + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + + OvmfPkg/OvmfPkgIa32X64.fdf | 1 + + OvmfPkg/OvmfPkgX64.dsc | 1 + + OvmfPkg/OvmfPkgX64.fdf | 1 + + 8 files changed, 26 insertions(+) + create mode 100644 OvmfPkg/Include/Dsc/MorLock.dsc.inc + create mode 100644 OvmfPkg/Include/Fdf/MorLock.fdf.inc + +diff --git a/OvmfPkg/Include/Dsc/MorLock.dsc.inc b/OvmfPkg/Include/Dsc/MorLock.dsc.inc +new file mode 100644 +index 0000000000..a8c5fb24b8 +--- /dev/null ++++ b/OvmfPkg/Include/Dsc/MorLock.dsc.inc +@@ -0,0 +1,10 @@ ++## ++# SPDX-License-Identifier: BSD-2-Clause-Patent ++# ++# MorLock support ++## ++ ++ SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf ++!if $(SMM_REQUIRE) == TRUE ++ SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.inf ++!endif +diff --git a/OvmfPkg/Include/Fdf/MorLock.fdf.inc b/OvmfPkg/Include/Fdf/MorLock.fdf.inc +new file mode 100644 +index 0000000000..20b7d6619a +--- /dev/null ++++ b/OvmfPkg/Include/Fdf/MorLock.fdf.inc +@@ -0,0 +1,10 @@ ++## ++# SPDX-License-Identifier: BSD-2-Clause-Patent ++# ++# MorLock support ++## ++ ++INF SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf ++!if $(SMM_REQUIRE) == TRUE ++INF SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.inf ++!endif +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index d8ae542686..65a866ae0c 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -887,6 +887,7 @@ + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/MorLock.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index 0ffa3be750..10eb6fe72b 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -355,6 +355,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + !include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/MorLock.fdf.inc + + !if $(LOAD_X64_ON_IA32_ENABLE) == TRUE + INF OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index 52ac2c96fc..679e25501b 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -901,6 +901,7 @@ + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/MorLock.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index c4f3ec0735..ff06bbfc6f 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -362,6 +362,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + !include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/MorLock.fdf.inc + + ################################################################################ + +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index f76d0ef7bc..d294fd4625 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -969,6 +969,7 @@ + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/MorLock.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index bedd85ef7a..f3b787201f 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -402,6 +402,7 @@ INF OvmfPkg/Tcg/TdTcg2Dxe/TdTcg2Dxe.inf + !include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/MorLock.fdf.inc + + ################################################################################ + diff --git a/SOURCES/edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch b/0036-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch similarity index 58% rename from SOURCES/edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch rename to 0036-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch index 6067e74..710d5d7 100644 --- a/SOURCES/edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch +++ b/0036-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch @@ -1,60 +1,42 @@ -From 1d4b6d489cb919faa3ad67a3ae53fe26c4cd0a75 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 10:32:29 -0400 -Subject: [PATCH 25/31] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check - CPUID +From 1691865ebaa8730203e8eb6bb052edff14dbaa70 Mon Sep 17 00:00:00 2001 +From: Pedro Falcato +Date: Tue, 22 Nov 2022 22:31:03 +0000 +Subject: [PATCH] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [25/31] 11804d6f86a644ae2c3dcad89c633ad63b794d3f +RDRAND has notoriously been broken many times over its lifespan. +Add a smoketest to RDRAND, in order to better sniff out potential +security concerns. -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 +Also add a proper CPUID test in order to support older CPUs which may +not have it; it was previously being tested but then promptly ignored. -commit c3a8ca7b54a9fd17acdf16c6282a92cc989fa92a -Author: Pedro Falcato -Date: Tue Nov 22 22:31:03 2022 +0000 +Testing algorithm inspired by linux's arch/x86/kernel/cpu/rdrand.c +:x86_init_rdrand() per commit 049f9ae9.. - MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID +Many thanks to Jason Donenfeld for relicensing his linux RDRAND detection +code to MIT and the public domain. - RDRAND has notoriously been broken many times over its lifespan. - Add a smoketest to RDRAND, in order to better sniff out potential - security concerns. +>On Tue, Nov 22, 2022 at 2:21 PM Jason A. Donenfeld wrote: + <..> +> I (re)wrote that function in Linux. I hereby relicense it as MIT, and +> also place it into public domain. Do with it what you will now. +> +> Jason - Also add a proper CPUID test in order to support older CPUs which may - not have it; it was previously being tested but then promptly ignored. +BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4163 - Testing algorithm inspired by linux's arch/x86/kernel/cpu/rdrand.c - :x86_init_rdrand() per commit 049f9ae9.. - - Many thanks to Jason Donenfeld for relicensing his linux RDRAND detection - code to MIT and the public domain. - - >On Tue, Nov 22, 2022 at 2:21 PM Jason A. Donenfeld wrote: - <..> - > I (re)wrote that function in Linux. I hereby relicense it as MIT, and - > also place it into public domain. Do with it what you will now. - > - > Jason - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4163 - - Signed-off-by: Pedro Falcato - Cc: Michael D Kinney - Cc: Liming Gao - Cc: Zhiguang Liu - Cc: Jason A. Donenfeld - -Signed-off-by: Jon Maloy +Signed-off-by: Pedro Falcato +Cc: Michael D Kinney +Cc: Liming Gao +Cc: Zhiguang Liu +Cc: Jason A. Donenfeld +(cherry picked from commit c3a8ca7b54a9fd17acdf16c6282a92cc989fa92a) --- MdePkg/Library/BaseRngLib/Rand/RdRand.c | 99 +++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/MdePkg/Library/BaseRngLib/Rand/RdRand.c b/MdePkg/Library/BaseRngLib/Rand/RdRand.c -index aee8ea04e8..7132ab0efd 100644 +index 9bd68352f9..06d2a6f12d 100644 --- a/MdePkg/Library/BaseRngLib/Rand/RdRand.c +++ b/MdePkg/Library/BaseRngLib/Rand/RdRand.c @@ -3,6 +3,7 @@ @@ -65,9 +47,9 @@ index aee8ea04e8..7132ab0efd 100644 Copyright (c) 2021, NUVIA Inc. All rights reserved.
Copyright (c) 2015, Intel Corporation. All rights reserved.
-@@ -25,6 +26,88 @@ SPDX-License-Identifier: BSD-2-Clause-Patent +@@ -24,6 +25,88 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - STATIC BOOLEAN mRdRandSupported; + STATIC BOOLEAN mRdRandSupported; +// +// Intel SDM says 10 tries is good enough for reliable RDRAND usage. @@ -154,7 +136,7 @@ index aee8ea04e8..7132ab0efd 100644 /** The constructor function checks whether or not RDRAND instruction is supported by the host hardware. -@@ -49,10 +132,13 @@ BaseRngLibConstructor ( +@@ -48,10 +131,13 @@ BaseRngLibConstructor ( // CPUID. A value of 1 indicates that processor support RDRAND instruction. // AsmCpuid (1, 0, 0, &RegEcx, 0); @@ -169,31 +151,31 @@ index aee8ea04e8..7132ab0efd 100644 return EFI_SUCCESS; } -@@ -71,6 +157,7 @@ ArchGetRandomNumber16 ( - OUT UINT16 *Rand +@@ -70,6 +156,7 @@ ArchGetRandomNumber16 ( + OUT UINT16 *Rand ) { + ASSERT (mRdRandSupported); return AsmRdRand16 (Rand); } -@@ -89,6 +176,7 @@ ArchGetRandomNumber32 ( - OUT UINT32 *Rand +@@ -88,6 +175,7 @@ ArchGetRandomNumber32 ( + OUT UINT32 *Rand ) { + ASSERT (mRdRandSupported); return AsmRdRand32 (Rand); } -@@ -107,6 +195,7 @@ ArchGetRandomNumber64 ( - OUT UINT64 *Rand +@@ -106,6 +194,7 @@ ArchGetRandomNumber64 ( + OUT UINT64 *Rand ) { + ASSERT (mRdRandSupported); return AsmRdRand64 (Rand); } -@@ -123,13 +212,7 @@ ArchIsRngSupported ( +@@ -122,13 +211,7 @@ ArchIsRngSupported ( VOID ) { @@ -208,6 +190,3 @@ index aee8ea04e8..7132ab0efd 100644 } /** --- -2.39.3 - diff --git a/0037-SecurityPkg-RngDxe-add-rng-test.patch b/0037-SecurityPkg-RngDxe-add-rng-test.patch new file mode 100644 index 0000000..abe2ab4 --- /dev/null +++ b/0037-SecurityPkg-RngDxe-add-rng-test.patch @@ -0,0 +1,43 @@ +From da8fda9932ab4a64a07d318d30b03baafbf1e0c1 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Fri, 31 May 2024 09:49:13 +0200 +Subject: [PATCH] SecurityPkg/RngDxe: add rng test + +Check whenever RngLib actually returns random numbers, only return +a non-zero number of Algorithms if that is the case. + +This has the effect that RndDxe loads and installs EFI_RNG_PROTOCOL +only in case it can actually deliver random numbers. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit a61bc0accb8a76edba4f073fdc7bafc908df045d) +--- + SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +index 5723ed6957..8b0742bab6 100644 +--- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c ++++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +@@ -23,6 +23,7 @@ + + #include + #include ++#include + + #include "RngDxeInternals.h" + +@@ -43,7 +44,12 @@ GetAvailableAlgorithms ( + VOID + ) + { +- mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT; ++ UINT64 RngTest; ++ ++ if (GetRandomNumber64 (&RngTest)) { ++ mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT; ++ } ++ + return EFI_SUCCESS; + } + diff --git a/0038-OvmfPkg-wire-up-RngDxe.patch b/0038-OvmfPkg-wire-up-RngDxe.patch new file mode 100644 index 0000000..e3a18f2 --- /dev/null +++ b/0038-OvmfPkg-wire-up-RngDxe.patch @@ -0,0 +1,301 @@ +From 7703744d07e81a9cd3109dca9184a61f16584d44 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Fri, 24 May 2024 12:51:17 +0200 +Subject: [PATCH] OvmfPkg: wire up RngDxe + +Add OvmfRng include snippets with the random number generator +configuration for OVMF. Include RngDxe, build with BaseRngLib, +so the rdrand instruction is used (if available). + +Also move VirtioRng to the include snippets. + +Use the new include snippets for OVMF builds. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit 712797cf19acd292bf203522a79e40e7e13d268b) +--- + OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +- + OvmfPkg/AmdSev/AmdSevX64.fdf | 2 +- + OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc | 9 +++++++++ + OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc | 6 ++++++ + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 +- + OvmfPkg/IntelTdx/IntelTdxX64.fdf | 2 +- + OvmfPkg/Microvm/MicrovmX64.dsc | 2 +- + OvmfPkg/Microvm/MicrovmX64.fdf | 2 +- + OvmfPkg/OvmfPkgIa32.dsc | 2 +- + OvmfPkg/OvmfPkgIa32.fdf | 2 +- + OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- + OvmfPkg/OvmfPkgIa32X64.fdf | 2 +- + OvmfPkg/OvmfPkgX64.dsc | 2 +- + OvmfPkg/OvmfPkgX64.fdf | 2 +- + 14 files changed, 27 insertions(+), 12 deletions(-) + create mode 100644 OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + create mode 100644 OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + +diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc +index cf1ad83e09..4edc2a9069 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.dsc ++++ b/OvmfPkg/AmdSev/AmdSevX64.dsc +@@ -649,7 +649,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + !if $(PVSCSI_ENABLE) == TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf + !endif +@@ -740,6 +739,7 @@ + OvmfPkg/AmdSev/Grub/Grub.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + OvmfPkg/PlatformDxe/Platform.inf + OvmfPkg/AmdSevDxe/AmdSevDxe.inf { +diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf +index c56c98dc85..480837b0fa 100644 +--- a/OvmfPkg/AmdSev/AmdSevX64.fdf ++++ b/OvmfPkg/AmdSev/AmdSevX64.fdf +@@ -227,7 +227,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + INF OvmfPkg/Virtio10Dxe/Virtio10.inf + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + !if $(PVSCSI_ENABLE) == TRUE + INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf + !endif +@@ -318,6 +317,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + !include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + ################################################################################ + +diff --git a/OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc b/OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc +new file mode 100644 +index 0000000000..68839a0caa +--- /dev/null ++++ b/OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc +@@ -0,0 +1,9 @@ ++## ++# SPDX-License-Identifier: BSD-2-Clause-Patent ++## ++ ++ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf { ++ ++ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf ++ } ++ OvmfPkg/VirtioRngDxe/VirtioRng.inf +diff --git a/OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc b/OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc +new file mode 100644 +index 0000000000..99cb4a32b1 +--- /dev/null ++++ b/OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc +@@ -0,0 +1,6 @@ ++## ++# SPDX-License-Identifier: BSD-2-Clause-Patent ++## ++ ++INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf ++INF OvmfPkg/VirtioRngDxe/VirtioRng.inf +diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc +index 9f49b60ff0..4b7e1596fc 100644 +--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc ++++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc +@@ -636,7 +636,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + !if $(PVSCSI_ENABLE) == TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf + !endif +@@ -719,6 +718,7 @@ + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.fdf b/OvmfPkg/IntelTdx/IntelTdxX64.fdf +index ce5d542048..88d0f75ae2 100644 +--- a/OvmfPkg/IntelTdx/IntelTdxX64.fdf ++++ b/OvmfPkg/IntelTdx/IntelTdxX64.fdf +@@ -285,7 +285,6 @@ READ_LOCK_STATUS = TRUE + # + INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + !if $(PVSCSI_ENABLE) == TRUE + INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf + !endif +@@ -326,6 +325,7 @@ INF OvmfPkg/VirtioGpuDxe/VirtioGpu.inf + INF OvmfPkg/PlatformDxe/Platform.inf + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + ################################################################################ + +diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc +index fb73f2e089..9206f01816 100644 +--- a/OvmfPkg/Microvm/MicrovmX64.dsc ++++ b/OvmfPkg/Microvm/MicrovmX64.dsc +@@ -760,7 +760,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf + MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf +@@ -846,6 +845,7 @@ + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf +index 055e659a35..c8268d7e8c 100644 +--- a/OvmfPkg/Microvm/MicrovmX64.fdf ++++ b/OvmfPkg/Microvm/MicrovmX64.fdf +@@ -207,7 +207,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + INF OvmfPkg/Virtio10Dxe/Virtio10.inf + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + + !if $(SECURE_BOOT_ENABLE) == TRUE +@@ -299,6 +298,7 @@ INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + ################################################################################ + +diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc +index 65a866ae0c..b64c215585 100644 +--- a/OvmfPkg/OvmfPkgIa32.dsc ++++ b/OvmfPkg/OvmfPkgIa32.dsc +@@ -784,7 +784,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -888,6 +887,7 @@ + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc + !include OvmfPkg/Include/Dsc/MorLock.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf +index 10eb6fe72b..c31276e4a3 100644 +--- a/OvmfPkg/OvmfPkgIa32.fdf ++++ b/OvmfPkg/OvmfPkgIa32.fdf +@@ -231,7 +231,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + INF OvmfPkg/Virtio10Dxe/Virtio10.inf + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -356,6 +355,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc + !include OvmfPkg/Include/Fdf/MorLock.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + !if $(LOAD_X64_ON_IA32_ENABLE) == TRUE + INF OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc +index 679e25501b..ececac3757 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.dsc ++++ b/OvmfPkg/OvmfPkgIa32X64.dsc +@@ -798,7 +798,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -902,6 +901,7 @@ + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc + !include OvmfPkg/Include/Dsc/MorLock.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf +index ff06bbfc6f..a7b4aeac08 100644 +--- a/OvmfPkg/OvmfPkgIa32X64.fdf ++++ b/OvmfPkg/OvmfPkgIa32X64.fdf +@@ -232,7 +232,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + INF OvmfPkg/Virtio10Dxe/Virtio10.inf + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -363,6 +362,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc + !include OvmfPkg/Include/Fdf/MorLock.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + ################################################################################ + +diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc +index d294fd4625..0ab4d3df06 100644 +--- a/OvmfPkg/OvmfPkgX64.dsc ++++ b/OvmfPkg/OvmfPkgX64.dsc +@@ -866,7 +866,6 @@ + OvmfPkg/Virtio10Dxe/Virtio10.inf + OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +- OvmfPkg/VirtioRngDxe/VirtioRng.inf + OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -970,6 +969,7 @@ + + !include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc + !include OvmfPkg/Include/Dsc/MorLock.dsc.inc ++!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc + + !if $(SECURE_BOOT_ENABLE) == TRUE + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf +diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf +index f3b787201f..ae08ac4fe9 100644 +--- a/OvmfPkg/OvmfPkgX64.fdf ++++ b/OvmfPkg/OvmfPkgX64.fdf +@@ -263,7 +263,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf + INF OvmfPkg/Virtio10Dxe/Virtio10.inf + INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf + INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf +-INF OvmfPkg/VirtioRngDxe/VirtioRng.inf + INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf + !if $(PVSCSI_ENABLE) == TRUE + INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +@@ -403,6 +402,7 @@ INF OvmfPkg/Tcg/TdTcg2Dxe/TdTcg2Dxe.inf + + !include OvmfPkg/Include/Fdf/ShellDxe.fdf.inc + !include OvmfPkg/Include/Fdf/MorLock.fdf.inc ++!include OvmfPkg/Include/Fdf/OvmfRngDxe.fdf.inc + + ################################################################################ + diff --git a/0039-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch b/0039-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch new file mode 100644 index 0000000..fc469c4 --- /dev/null +++ b/0039-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch @@ -0,0 +1,37 @@ +From ef076eab3cad92111c550d0041ac8d1a4e979714 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Fri, 14 Jun 2024 11:45:49 +0200 +Subject: [PATCH] CryptoPkg/Test: call ProcessLibraryConstructorList + +Needed to properly initialize BaseRngLib. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit 94961b8817eec6f8d0434555ac50a7aa51c22201) +--- + .../Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c +index d0c1c7a4f7..48d463b8ad 100644 +--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c ++++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c +@@ -8,6 +8,12 @@ + **/ + #include "TestBaseCryptLib.h" + ++VOID ++EFIAPI ++ProcessLibraryConstructorList ( ++ VOID ++ ); ++ + /** + Initialize the unit test framework, suite, and unit tests for the + sample unit tests and run the unit tests. +@@ -76,5 +82,6 @@ main ( + char *argv[] + ) + { ++ ProcessLibraryConstructorList (); + return UefiTestMain (); + } diff --git a/0040-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch b/0040-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch new file mode 100644 index 0000000..ca30f84 --- /dev/null +++ b/0040-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch @@ -0,0 +1,43 @@ +From 46f82fa0cfe716f147b7878b7155983f7f6edb20 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Fri, 14 Jun 2024 11:45:53 +0200 +Subject: [PATCH] MdePkg/X86UnitTestHost: set rdrand cpuid bit + +Set the rdrand feature bit when faking cpuid for host test cases. +Needed to make the CryptoPkg test cases work. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit 5e776299a2604b336a947e68593012ab2cc16eb4) +--- + MdePkg/Library/BaseLib/X86UnitTestHost.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/MdePkg/Library/BaseLib/X86UnitTestHost.c b/MdePkg/Library/BaseLib/X86UnitTestHost.c +index 8ba4f54a38..7f7276f7f4 100644 +--- a/MdePkg/Library/BaseLib/X86UnitTestHost.c ++++ b/MdePkg/Library/BaseLib/X86UnitTestHost.c +@@ -66,6 +66,15 @@ UnitTestHostBaseLibAsmCpuid ( + OUT UINT32 *Edx OPTIONAL + ) + { ++ UINT32 RetEcx; ++ ++ RetEcx = 0; ++ switch (Index) { ++ case 1: ++ RetEcx |= BIT30; /* RdRand */ ++ break; ++ } ++ + if (Eax != NULL) { + *Eax = 0; + } +@@ -75,7 +84,7 @@ UnitTestHostBaseLibAsmCpuid ( + } + + if (Ecx != NULL) { +- *Ecx = 0; ++ *Ecx = RetEcx; + } + + if (Edx != NULL) { diff --git a/SOURCES/edk2-ovmf-sb.json b/30-edk2-ovmf-x64-sb-enrolled.json similarity index 96% rename from SOURCES/edk2-ovmf-sb.json rename to 30-edk2-ovmf-x64-sb-enrolled.json index a0203e8..d77ed08 100644 --- a/SOURCES/edk2-ovmf-sb.json +++ b/30-edk2-ovmf-x64-sb-enrolled.json @@ -5,6 +5,7 @@ ], "mapping": { "device": "flash", + "mode": "split", "executable": { "filename": "/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd", "format": "raw" @@ -24,7 +25,6 @@ ], "features": [ "acpi-s3", - "amd-sev", "enrolled-keys", "requires-smm", "secure-boot", diff --git a/SOURCES/edk2-ovmf.json b/40-edk2-ovmf-x64-sb.json similarity index 96% rename from SOURCES/edk2-ovmf.json rename to 40-edk2-ovmf-x64-sb.json index 74d00e3..02a7622 100644 --- a/SOURCES/edk2-ovmf.json +++ b/40-edk2-ovmf-x64-sb.json @@ -5,6 +5,7 @@ ], "mapping": { "device": "flash", + "mode": "split", "executable": { "filename": "/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd", "format": "raw" @@ -24,7 +25,6 @@ ], "features": [ "acpi-s3", - "amd-sev", "requires-smm", "secure-boot", "verbose-dynamic" diff --git a/50-edk2-aarch64-qcow2.json b/50-edk2-aarch64-qcow2.json new file mode 100644 index 0000000..937d295 --- /dev/null +++ b/50-edk2-aarch64-qcow2.json @@ -0,0 +1,32 @@ +{ + "description": "UEFI firmware for ARM64 virtual machines", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode": "split", + "executable": { + "filename": "/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.qcow2", + "format": "qcow2" + }, + "nvram-template": { + "filename": "/usr/share/edk2/aarch64/vars-template-pflash.qcow2", + "format": "qcow2" + } + }, + "targets": [ + { + "architecture": "aarch64", + "machines": [ + "virt-*" + ] + } + ], + "features": [ + + ], + "tags": [ + + ] +} diff --git a/SOURCES/edk2-ovmf-cc.json b/50-edk2-ovmf-x64-nosb.json similarity index 73% rename from SOURCES/edk2-ovmf-cc.json rename to 50-edk2-ovmf-x64-nosb.json index 64c38d0..c660e0c 100644 --- a/SOURCES/edk2-ovmf-cc.json +++ b/50-edk2-ovmf-x64-nosb.json @@ -1,12 +1,13 @@ { - "description": "OVMF with SEV-ES support", + "description": "OVMF without SB+SMM, empty varstore", "interface-types": [ "uefi" ], "mapping": { "device": "flash", + "mode": "split", "executable": { - "filename": "/usr/share/edk2/ovmf/OVMF_CODE.cc.fd", + "filename": "/usr/share/edk2/ovmf/OVMF_CODE.fd", "format": "raw" }, "nvram-template": { @@ -18,12 +19,12 @@ { "architecture": "x86_64", "machines": [ - "pc-q35-rhel8.6.0", - "pc-q35-rhel8.5.0" + "pc-q35-*" ] } ], "features": [ + "acpi-s3", "amd-sev", "amd-sev-es", "verbose-dynamic" diff --git a/SOURCES/edk2-aarch64.json b/51-edk2-aarch64-raw.json similarity index 96% rename from SOURCES/edk2-aarch64.json rename to 51-edk2-aarch64-raw.json index c5a73cb..506bbe6 100644 --- a/SOURCES/edk2-aarch64.json +++ b/51-edk2-aarch64-raw.json @@ -5,6 +5,7 @@ ], "mapping": { "device": "flash", + "mode": "split", "executable": { "filename": "/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw", "format": "raw" diff --git a/52-edk2-aarch64-verbose-qcow2.json b/52-edk2-aarch64-verbose-qcow2.json new file mode 100644 index 0000000..976f2a6 --- /dev/null +++ b/52-edk2-aarch64-verbose-qcow2.json @@ -0,0 +1,32 @@ +{ + "description": "UEFI firmware for ARM64 virtual machines, verbose logs", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode": "split", + "executable": { + "filename": "/usr/share/edk2/aarch64/QEMU_EFI-pflash.qcow2", + "format": "qcow2" + }, + "nvram-template": { + "filename": "/usr/share/edk2/aarch64/vars-template-pflash.qcow2", + "format": "qcow2" + } + }, + "targets": [ + { + "architecture": "aarch64", + "machines": [ + "virt-*" + ] + } + ], + "features": [ + "verbose-static" + ], + "tags": [ + + ] +} diff --git a/SOURCES/edk2-aarch64-verbose.json b/53-edk2-aarch64-verbose-raw.json similarity index 96% rename from SOURCES/edk2-aarch64-verbose.json rename to 53-edk2-aarch64-verbose-raw.json index ceec878..fa0ed91 100644 --- a/SOURCES/edk2-aarch64-verbose.json +++ b/53-edk2-aarch64-verbose-raw.json @@ -5,6 +5,7 @@ ], "mapping": { "device": "flash", + "mode": "split", "executable": { "filename": "/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw", "format": "raw" diff --git a/60-edk2-ovmf-x64-amdsev.json b/60-edk2-ovmf-x64-amdsev.json new file mode 100644 index 0000000..9a561bc --- /dev/null +++ b/60-edk2-ovmf-x64-amdsev.json @@ -0,0 +1,31 @@ +{ + "description": "OVMF with SEV-ES support", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode": "stateless", + "executable": { + "filename": "/usr/share/edk2/ovmf/OVMF.amdsev.fd", + "format": "raw" + } + }, + "targets": [ + { + "architecture": "x86_64", + "machines": [ + "pc-q35-*" + ] + } + ], + "features": [ + "amd-sev", + "amd-sev-es", + "amd-sev-snp", + "verbose-dynamic" + ], + "tags": [ + + ] +} diff --git a/60-edk2-ovmf-x64-inteltdx.json b/60-edk2-ovmf-x64-inteltdx.json new file mode 100644 index 0000000..445eb70 --- /dev/null +++ b/60-edk2-ovmf-x64-inteltdx.json @@ -0,0 +1,27 @@ +{ + "description": "OVMF with TDX support", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "memory", + "filename": "/usr/share/edk2/ovmf/OVMF.inteltdx.secboot.fd" + }, + "targets": [ + { + "architecture": "x86_64", + "machines": [ + "pc-q35-*" + ] + } + ], + "features": [ + "enrolled-keys", + "intel-tdx", + "secure-boot", + "verbose-dynamic" + ], + "tags": [ + + ] +} diff --git a/SOURCES/0008-BaseTools-do-not-build-BrotliCompress-RH-only.patch b/SOURCES/0008-BaseTools-do-not-build-BrotliCompress-RH-only.patch deleted file mode 100644 index fcfa987..0000000 --- a/SOURCES/0008-BaseTools-do-not-build-BrotliCompress-RH-only.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0790c9c4f796fdce8ba6618359b78e1d0b331c95 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Thu, 4 Jun 2020 13:34:12 +0200 -Subject: BaseTools: do not build BrotliCompress (RH only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- New patch. - -BrotliCompress is not used for building ArmVirtPkg or OvmfPkg platforms. -It depends on one of the upstream Brotli git submodules that we removed -earlier in this rebase series. (See patch "remove upstream edk2's Brotli -submodules (RH only"). - -Do not attempt to build BrotliCompress. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit db8ccca337e2c5722c1d408d2541cf653d3371a2) ---- - BaseTools/Source/C/GNUmakefile | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/BaseTools/Source/C/GNUmakefile b/BaseTools/Source/C/GNUmakefile -index 8c191e0c38..3eae824a1c 100644 ---- a/BaseTools/Source/C/GNUmakefile -+++ b/BaseTools/Source/C/GNUmakefile -@@ -48,7 +48,6 @@ all: makerootdir subdirs - LIBRARIES = Common - VFRAUTOGEN = VfrCompile/VfrLexer.h - APPLICATIONS = \ -- BrotliCompress \ - VfrCompile \ - EfiRom \ - GenFfs \ --- -2.27.0 - diff --git a/SOURCES/0009-MdeModulePkg-remove-package-private-Brotli-include-p.patch b/SOURCES/0009-MdeModulePkg-remove-package-private-Brotli-include-p.patch deleted file mode 100644 index a8ef274..0000000 --- a/SOURCES/0009-MdeModulePkg-remove-package-private-Brotli-include-p.patch +++ /dev/null @@ -1,49 +0,0 @@ -From df9e25b7e6179a7764d44f915de95af5f850a020 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Thu, 4 Jun 2020 13:39:08 +0200 -Subject: MdeModulePkg: remove package-private Brotli include path (RH only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- New patch. - -Originating from upstream commit 58802e02c41b -("MdeModulePkg/BrotliCustomDecompressLib: Make brotli a submodule", -2020-04-16), "MdeModulePkg/MdeModulePkg.dec" contains a package-internal -include path into a Brotli submodule. - -The edk2 build system requires such include paths to resolve successfully, -regardless of the firmware platform being built. Because -BrotliCustomDecompressLib is not consumed by any OvmfPkg or ArmVirtPkg -platforms, and we've removed the submodule earlier in this patch set, -remove the include path too. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit e05e0de713c4a2b8adb6ff9809611f222bfe50ed) ---- - MdeModulePkg/MdeModulePkg.dec | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec -index 463e889e9a..9d69fb86ed 100644 ---- a/MdeModulePkg/MdeModulePkg.dec -+++ b/MdeModulePkg/MdeModulePkg.dec -@@ -24,9 +24,6 @@ - [Includes] - Include - --[Includes.Common.Private] -- Library/BrotliCustomDecompressLib/brotli/c/include -- - [LibraryClasses] - ## @libraryclass Defines a set of methods to reset whole system. - ResetSystemLib|Include/Library/ResetSystemLib.h --- -2.27.0 - diff --git a/SOURCES/0010-OvmfPkg-increase-max-debug-message-length-to-512-RHE.patch b/SOURCES/0010-OvmfPkg-increase-max-debug-message-length-to-512-RHE.patch deleted file mode 100644 index 4107e96..0000000 --- a/SOURCES/0010-OvmfPkg-increase-max-debug-message-length-to-512-RHE.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 1a1bdd69fad22bbf48e3906bb73b33ede6632102 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Thu, 20 Feb 2014 22:54:45 +0100 -Subject: OvmfPkg: increase max debug message length to 512 (RHEL only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- no change - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- trivial context difference due to upstream commit 2fe5f2f52918 - ("OvmfPkg/PlatformDebugLibIoPort: Add new APIs", 2019-04-02), resolved - by git-cherry-pick automatically - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- no changes - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- no changes - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- no changes - -Upstream prefers short debug messages (sometimes even limited to 80 -characters), but any line length under 512 characters is just unsuitable -for effective debugging. (For example, config strings in HII routing, -logged by the platform driver "OvmfPkg/PlatformDxe" on DEBUG_VERBOSE -level, can be several hundred characters long.) 512 is an empirically good -value. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit bfe568d18dba15602604f155982e3b73add63dfb) -(cherry picked from commit 29435a32ec9428720c74c454ce9817662e601fb6) -(cherry picked from commit 58e1d1ebb78bfdaf05f4c6e8abf8d4908dfa038a) -(cherry picked from commit 1df2c822c996ad767f2f45570ab2686458f7604a) -(cherry picked from commit 22c9b4e971c70c69b4adf8eb93133824ccb6426a) -(cherry picked from commit a1260c9122c95bcbef1efc5eebe11902767813c2) -(cherry picked from commit e949bab1268f83f0f5815a96cd1cb9dd3b21bfb5) -(cherry picked from commit a95cff0b9573bf23699551beb4786383f697ff1e) ---- - OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c -index dffb20822d..0577c43c3d 100644 ---- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c -+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c -@@ -21,7 +21,7 @@ - // - // Define the maximum debug and assert message length that this library supports - // --#define MAX_DEBUG_MESSAGE_LENGTH 0x100 -+#define MAX_DEBUG_MESSAGE_LENGTH 0x200 - - // - // VA_LIST can not initialize to NULL for all compiler, so we use this to --- -2.27.0 - diff --git a/SOURCES/0011-MdeModulePkg-TerminalDxe-add-other-text-resolutions-.patch b/SOURCES/0011-MdeModulePkg-TerminalDxe-add-other-text-resolutions-.patch deleted file mode 100644 index 1ff85cd..0000000 --- a/SOURCES/0011-MdeModulePkg-TerminalDxe-add-other-text-resolutions-.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 8ea4ac38206664e1d833085a0b7d4e0736870c2b Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Tue, 25 Feb 2014 18:40:35 +0100 -Subject: MdeModulePkg: TerminalDxe: add other text resolutions (RHEL only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- no changes - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- no changes - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- no change - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- update commit message as requested in - - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- adapt commit 0bc77c63de03 (code and commit message) to upstream commit - 390b95a49c14 ("MdeModulePkg/TerminalDxe: Refine - InitializeTerminalConsoleTextMode", 2017-01-10). - -When the console output is multiplexed to several devices by -ConSplitterDxe, then ConSplitterDxe builds an intersection of text modes -supported by all console output devices. - -Two notable output devices are provided by: -(1) MdeModulePkg/Universal/Console/GraphicsConsoleDxe, -(2) MdeModulePkg/Universal/Console/TerminalDxe. - -GraphicsConsoleDxe supports four modes at most -- see -InitializeGraphicsConsoleTextMode() and "mGraphicsConsoleModeData": - -(1a) 80x25 (required by the UEFI spec as mode 0), -(1b) 80x50 (not necessarily supported, but if it is, then the UEFI spec - requires the driver to provide it as mode 1), -(1c) 100x31 (corresponding to graphics resolution 800x600, which the UEFI - spec requires from all plug-in graphics devices), -(1d) "full screen" resolution, derived form the underlying GOP's - horizontal and vertical resolutions with division by EFI_GLYPH_WIDTH - (8) and EFI_GLYPH_HEIGHT (19), respectively. - -The automatic "full screen resolution" makes GraphicsConsoleDxe's -character console very flexible. However, TerminalDxe (which runs on -serial ports) only provides the following fixed resolutions -- see -InitializeTerminalConsoleTextMode() and "mTerminalConsoleModeData": - -(2a) 80x25 (required by the UEFI spec as mode 0), -(2b) 80x50 (since the character resolution of a serial device cannot be - interrogated easily, this is added unconditionally as mode 1), -(2c) 100x31 (since the character resolution of a serial device cannot be - interrogated easily, this is added unconditionally as mode 2). - -When ConSplitterDxe combines (1) and (2), multiplexing console output to -both video output and serial terminal, the list of commonly supported text -modes (ie. the "intersection") comprises: - -(3a) 80x25, unconditionally, from (1a) and (2a), -(3b) 80x50, if the graphics console provides at least 640x950 pixel - resolution, from (1b) and (2b) -(3c) 100x31, if the graphics device is a plug-in one (because in that case - 800x600 is a mandated pixel resolution), from (1c) and (2c). - -Unfortunately, the "full screen resolution" (1d) of the GOP-based text -console is not available in general. - -Mitigate this problem by extending "mTerminalConsoleModeData" with a -handful of text resolutions that are derived from widespread maximal pixel -resolutions. This way TerminalDxe won't cause ConSplitterDxe to filter out -the most frequent (1d) values from the intersection, and eg. the MODE -command in the UEFI shell will offer the "best" (ie. full screen) -resolution too. - -Upstreaming efforts for this patch have been discontinued; it was clear -from the off-list thread that consensus was impossible to reach. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit 99dc3720ac86059f60156197328cc433603c536e) -(cherry picked from commit d2066c1748f885043026c51dec1bc8d6d406ae8f) -(cherry picked from commit 1facdd58e946c584a3dc1e5be8f2f837b5a7c621) -(cherry picked from commit 28faeb5f94b4866b9da16cf2a1e4e0fc09a26e37) -(cherry picked from commit 4e4e15b80a5b2103eadd495ef4a830d46dd4ed51) -(cherry picked from commit 12cb13a1da913912bd9148ce8f2353a75be77f18) -(cherry picked from commit 82b9edc5fef3a07227a45059bbe821af7b9abd69) ---- - .../Universal/Console/TerminalDxe/Terminal.c | 41 +++++++++++++++++-- - 1 file changed, 38 insertions(+), 3 deletions(-) - -diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c -index a98b690c8b..ded5513c74 100644 ---- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c -+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c -@@ -115,9 +115,44 @@ TERMINAL_DEV mTerminalDevTemplate = { - }; - - TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = { -- {80, 25}, -- {80, 50}, -- {100, 31}, -+ { 80, 25 }, // from graphics resolution 640 x 480 -+ { 80, 50 }, // from graphics resolution 640 x 960 -+ { 100, 25 }, // from graphics resolution 800 x 480 -+ { 100, 31 }, // from graphics resolution 800 x 600 -+ { 104, 32 }, // from graphics resolution 832 x 624 -+ { 120, 33 }, // from graphics resolution 960 x 640 -+ { 128, 31 }, // from graphics resolution 1024 x 600 -+ { 128, 40 }, // from graphics resolution 1024 x 768 -+ { 144, 45 }, // from graphics resolution 1152 x 864 -+ { 144, 45 }, // from graphics resolution 1152 x 870 -+ { 160, 37 }, // from graphics resolution 1280 x 720 -+ { 160, 40 }, // from graphics resolution 1280 x 760 -+ { 160, 40 }, // from graphics resolution 1280 x 768 -+ { 160, 42 }, // from graphics resolution 1280 x 800 -+ { 160, 50 }, // from graphics resolution 1280 x 960 -+ { 160, 53 }, // from graphics resolution 1280 x 1024 -+ { 170, 40 }, // from graphics resolution 1360 x 768 -+ { 170, 40 }, // from graphics resolution 1366 x 768 -+ { 175, 55 }, // from graphics resolution 1400 x 1050 -+ { 180, 47 }, // from graphics resolution 1440 x 900 -+ { 200, 47 }, // from graphics resolution 1600 x 900 -+ { 200, 63 }, // from graphics resolution 1600 x 1200 -+ { 210, 55 }, // from graphics resolution 1680 x 1050 -+ { 240, 56 }, // from graphics resolution 1920 x 1080 -+ { 240, 63 }, // from graphics resolution 1920 x 1200 -+ { 240, 75 }, // from graphics resolution 1920 x 1440 -+ { 250, 105 }, // from graphics resolution 2000 x 2000 -+ { 256, 80 }, // from graphics resolution 2048 x 1536 -+ { 256, 107 }, // from graphics resolution 2048 x 2048 -+ { 320, 75 }, // from graphics resolution 2560 x 1440 -+ { 320, 84 }, // from graphics resolution 2560 x 1600 -+ { 320, 107 }, // from graphics resolution 2560 x 2048 -+ { 350, 110 }, // from graphics resolution 2800 x 2100 -+ { 400, 126 }, // from graphics resolution 3200 x 2400 -+ { 480, 113 }, // from graphics resolution 3840 x 2160 -+ { 512, 113 }, // from graphics resolution 4096 x 2160 -+ { 960, 227 }, // from graphics resolution 7680 x 4320 -+ { 1024, 227 }, // from graphics resolution 8192 x 4320 - // - // New modes can be added here. - // --- -2.27.0 - diff --git a/SOURCES/0015-OvmfPkg-allow-exclusion-of-the-shell-from-the-firmwa.patch b/SOURCES/0015-OvmfPkg-allow-exclusion-of-the-shell-from-the-firmwa.patch deleted file mode 100644 index 03a185b..0000000 --- a/SOURCES/0015-OvmfPkg-allow-exclusion-of-the-shell-from-the-firmwa.patch +++ /dev/null @@ -1,172 +0,0 @@ -From e8e12cb7d3a47e5823cf2cb12c9bfe5901d3b100 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Tue, 4 Nov 2014 23:02:53 +0100 -Subject: OvmfPkg: allow exclusion of the shell from the firmware image (RH - only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- No manual / explicit code change is necessary, because the newly - inherited OvmfPkg/AmdSev platform already has its own BUILD_SHELL - build-time macro (feature test flag), with default value FALSE -- from - upstream commit b261a30c900a ("OvmfPkg/AmdSev: add Grub Firmware Volume - Package", 2020-12-14). - -- Contextual differences from new upstream commits 2d8ca4f90eae ("OvmfPkg: - enable HttpDynamicCommand", 2020-10-01) and 5ab6a0e1c8e9 ("OvmfPkg: - introduce VirtioFsDxe", 2020-12-21) have been auto-resolved by - git-cherry-pick. - -- Remove obsolete commit message tags related to downstream patch - management: Message-id, Patchwork-id, O-Subject, Acked-by - (RHBZ#1846481). - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- context difference from upstream commit ec41733cfd10 ("OvmfPkg: add the - 'initrd' dynamic shell command", 2020-03-04) correctly auto-resolved - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- no change - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- update the patch against the following upstream commits: - - 4b888334d234 ("OvmfPkg: Remove EdkShellBinPkg in FDF", 2018-11-19) - - 277a3958d93a ("OvmfPkg: Don't include TftpDynamicCommand in XCODE5 - tool chain", 2018-11-27) - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- no change - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- no changes - -Bugzilla: 1147592 - -When '-D EXCLUDE_SHELL_FROM_FD' is passed to 'build', exclude the shell -binary from the firmware image. - -Peter Jones advised us that firmware vendors for physical systems disable -the memory-mapped, firmware image-contained UEFI shell in -SecureBoot-enabled builds. The reason being that the memory-mapped shell -can always load, it may have direct access to various hardware in the -system, and it can run UEFI shell scripts (which cannot be signed at all). - -Intended use of the new build option: - -- In-tree builds: don't pass '-D EXCLUDE_SHELL_FROM_FD'. The resultant - firmware image will contain a shell binary, independently of SecureBoot - enablement, which is flexible for interactive development. (Ie. no - change for in-tree builds.) - -- RPM builds: pass both '-D SECURE_BOOT_ENABLE' and - '-D EXCLUDE_SHELL_FROM_FD'. The resultant RPM will provide: - - - OVMF_CODE.fd: SecureBoot-enabled firmware, without builtin UEFI shell, - - - OVMF_VARS.fd: variable store template matching OVMF_CODE.fd, - - - UefiShell.iso: a bootable ISO image with the shell on it as default - boot loader. The shell binary will load when SecureBoot is turned off, - and won't load when SecureBoot is turned on (because it is not - signed). - - UefiShell.iso is the reason we're not excluding the shell from the DSC - files as well, only the FDF files -- when '-D EXCLUDE_SHELL_FROM_FD' - is specified, the shell binary needs to be built the same, only it - will be included in UefiShell.iso. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit 9c391def70366cabae08e6008814299c3372fafd) -(cherry picked from commit d9dd9ee42937b2611fe37183cc9ec7f62d946933) -(cherry picked from commit 23df46ebbe7b09451d3a05034acd4d3a25e7177b) -(cherry picked from commit f0303f71d576c51b01c4ff961b429d0e0e707245) -(cherry picked from commit bbd64eb8658e9a33eab4227d9f4e51ad78d9f687) -(cherry picked from commit 8628ef1b8d675ebec39d83834abbe3c8c8c42cf4) -(cherry picked from commit 229c88dc3ded9baeaca8b87767dc5c41c05afd6e) -(cherry picked from commit c2812d7189dee06c780f05a5880eb421c359a687) ---- - OvmfPkg/OvmfPkgIa32.fdf | 2 ++ - OvmfPkg/OvmfPkgIa32X64.fdf | 2 ++ - OvmfPkg/OvmfPkgX64.fdf | 2 ++ - 3 files changed, 6 insertions(+) - -diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf -index 775ea2d710..00ea14adf0 100644 ---- a/OvmfPkg/OvmfPkgIa32.fdf -+++ b/OvmfPkg/OvmfPkgIa32.fdf -@@ -290,12 +290,14 @@ INF FatPkg/EnhancedFatDxe/Fat.inf - INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf - INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf - -+!ifndef $(EXCLUDE_SHELL_FROM_FD) - !if $(TOOL_CHAIN_TAG) != "XCODE5" - INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf - INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf - INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf - !endif - INF ShellPkg/Application/Shell/Shell.inf -+!endif - - INF MdeModulePkg/Logo/LogoDxe.inf - -diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf -index 9d8695922f..e33a40c44e 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.fdf -+++ b/OvmfPkg/OvmfPkgIa32X64.fdf -@@ -294,12 +294,14 @@ INF FatPkg/EnhancedFatDxe/Fat.inf - INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf - INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf - -+!ifndef $(EXCLUDE_SHELL_FROM_FD) - !if $(TOOL_CHAIN_TAG) != "XCODE5" - INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf - INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf - INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf - !endif - INF ShellPkg/Application/Shell/Shell.inf -+!endif - - INF MdeModulePkg/Logo/LogoDxe.inf - -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index b6cc3cabdd..85b4b23857 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -310,12 +310,14 @@ INF FatPkg/EnhancedFatDxe/Fat.inf - INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf - INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf - -+!ifndef $(EXCLUDE_SHELL_FROM_FD) - !if $(TOOL_CHAIN_TAG) != "XCODE5" - INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf - INF ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf - INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf - !endif - INF ShellPkg/Application/Shell/Shell.inf -+!endif - - INF MdeModulePkg/Logo/LogoDxe.inf - --- -2.27.0 - diff --git a/SOURCES/0016-ArmPlatformPkg-introduce-fixed-PCD-for-early-hello-m.patch b/SOURCES/0016-ArmPlatformPkg-introduce-fixed-PCD-for-early-hello-m.patch deleted file mode 100644 index 2019fb9..0000000 --- a/SOURCES/0016-ArmPlatformPkg-introduce-fixed-PCD-for-early-hello-m.patch +++ /dev/null @@ -1,93 +0,0 @@ -From eba5ecf4b2611d593a978ccac804314ab7848754 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Wed, 14 Oct 2015 13:49:43 +0200 -Subject: ArmPlatformPkg: introduce fixed PCD for early hello message (RH only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- no change - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- no change - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- no change - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- no changes - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- no changes - -Drew has proposed that ARM|AARCH64 platform firmware (especially virtual -machine firmware) print a reasonably early, simple hello message to the -serial port, regardless of debug mask settings. This should inform -interactive users, and provide some rough help in localizing boot -problems, even with restrictive debug masks. - -If a platform doesn't want this feature, it should stick with the default -empty string. - -RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1270279 -Downstream only: -. - -Suggested-by: Drew Jones -Contributed-under: TianoCore Contribution Agreement 1.0 -Signed-off-by: Laszlo Ersek -(cherry picked from commit 7ce97b06421434c82095f01a1753a8c9c546cc30) -(cherry picked from commit 20b1f1cbd0590aa71c6d99d35e23cf08e0707750) -(cherry picked from commit 6734b88cf7abcaf42632e3d2fc469b2169dd2f16) -(cherry picked from commit ef77da632559e9baa1c69869e4cbea377068ef27) -(cherry picked from commit 58755c51d3252312d80cbcb97928d71199c2f5e1) -(cherry picked from commit c3f07e323e76856f1b42ea7b8c598ba3201c28a2) -(cherry picked from commit 9f756c1ad83cc81f7d892cd036d59a2b567b02dc) -(cherry picked from commit c75aea7a738ac7fb944c0695a4bfffc3985afaa9) ---- - ArmPlatformPkg/ArmPlatformPkg.dec | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec -index 3a25ddcdc8..b2b58553c7 100644 ---- a/ArmPlatformPkg/ArmPlatformPkg.dec -+++ b/ArmPlatformPkg/ArmPlatformPkg.dec -@@ -121,6 +121,13 @@ - ## If set, this will swap settings for HDLCD RED_SELECT and BLUE_SELECT registers - gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BOOLEAN|0x00000045 - -+ # -+ # Early hello message (ASCII string), printed to the serial port. -+ # If set to the empty string, nothing is printed. -+ # Otherwise, a trailing CRLF should be specified explicitly. -+ # -+ gArmPlatformTokenSpaceGuid.PcdEarlyHelloMessage|""|VOID*|0x00000100 -+ - [PcdsFixedAtBuild.common,PcdsDynamic.common] - ## PL031 RealTimeClock - gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024 --- -2.27.0 - diff --git a/SOURCES/0017-ArmPlatformPkg-PrePeiCore-write-early-hello-message-.patch b/SOURCES/0017-ArmPlatformPkg-PrePeiCore-write-early-hello-message-.patch deleted file mode 100644 index 258c56d..0000000 --- a/SOURCES/0017-ArmPlatformPkg-PrePeiCore-write-early-hello-message-.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 8be1d7253ba8a7d30bb54835ef1fc866aa62e216 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Wed, 14 Oct 2015 13:59:20 +0200 -Subject: ArmPlatformPkg: PrePeiCore: write early hello message to the serial - port (RH) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- no change - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- no change - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- no change - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- adapt to upstream commit 7e2a8dfe8a9a ("ArmPlatformPkg/PrePeiCore: seed - temporary stack before entering PEI core", 2017-11-09) -- conflict - resolution in "ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf" - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- no changes - -The FixedPcdGetSize() macro expands to an integer constant, therefore an -optimizing compiler can eliminate the new code, if the platform DSC -doesn't override the empty string (size=1) default of -PcdEarlyHelloMessage. - -RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1270279 -Downstream only: -. - -Contributed-under: TianoCore Contribution Agreement 1.0 -Signed-off-by: Laszlo Ersek -(cherry picked from commit b16c4c505ce0e27305235533eac9236aa66f132e) -(cherry picked from commit 742e5bf6d5ce5a1e73879d6e5c0dd00feda7a9ac) -(cherry picked from commit 93d69eb9393cf05af90676253875c59c1bec67fd) -(cherry picked from commit 638594083b191f84f5d9333eb6147a31570f5a5a) -(cherry picked from commit f4b7aae411d88b2b83f85d20ef06a4032a57e7de) -(cherry picked from commit bb71490fdda3b38fa9f071d281b863f9b64363bf) -(cherry picked from commit 8d5a8827aabc67cb2a046697e1a750ca8d9cc453) -(cherry picked from commit 49fe5596cd79c94d903c4d506c563d642ccd69aa) ---- - ArmPlatformPkg/PrePeiCore/MainMPCore.c | 5 +++++ - ArmPlatformPkg/PrePeiCore/MainUniCore.c | 5 +++++ - ArmPlatformPkg/PrePeiCore/PrePeiCore.h | 1 + - ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf | 2 ++ - ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf | 2 ++ - 5 files changed, 15 insertions(+) - -diff --git a/ArmPlatformPkg/PrePeiCore/MainMPCore.c b/ArmPlatformPkg/PrePeiCore/MainMPCore.c -index 859f1adf20..cf9e65bb7c 100644 ---- a/ArmPlatformPkg/PrePeiCore/MainMPCore.c -+++ b/ArmPlatformPkg/PrePeiCore/MainMPCore.c -@@ -111,6 +111,11 @@ PrimaryMain ( - UINTN TemporaryRamBase; - UINTN TemporaryRamSize; - -+ if (FixedPcdGetSize (PcdEarlyHelloMessage) > 1) { -+ SerialPortWrite (FixedPcdGetPtr (PcdEarlyHelloMessage), -+ FixedPcdGetSize (PcdEarlyHelloMessage) - 1); -+ } -+ - CreatePpiList (&PpiListSize, &PpiList); - - // Enable the GIC Distributor -diff --git a/ArmPlatformPkg/PrePeiCore/MainUniCore.c b/ArmPlatformPkg/PrePeiCore/MainUniCore.c -index 220f9b5680..158cc34c77 100644 ---- a/ArmPlatformPkg/PrePeiCore/MainUniCore.c -+++ b/ArmPlatformPkg/PrePeiCore/MainUniCore.c -@@ -29,6 +29,11 @@ PrimaryMain ( - UINTN TemporaryRamBase; - UINTN TemporaryRamSize; - -+ if (FixedPcdGetSize (PcdEarlyHelloMessage) > 1) { -+ SerialPortWrite (FixedPcdGetPtr (PcdEarlyHelloMessage), -+ FixedPcdGetSize (PcdEarlyHelloMessage) - 1); -+ } -+ - CreatePpiList (&PpiListSize, &PpiList); - - // Adjust the Temporary Ram as the new Ppi List (Common + Platform Ppi Lists) is created at -diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h -index 7b155a8a61..e9e283f9ec 100644 ---- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h -+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - - #include - #include -diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf -index fb01dd1a11..a6681c1032 100644 ---- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf -+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf -@@ -69,6 +69,8 @@ - gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize - gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize - -+ gArmPlatformTokenSpaceGuid.PcdEarlyHelloMessage -+ - gArmTokenSpaceGuid.PcdGicDistributorBase - gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase - gArmTokenSpaceGuid.PcdGicSgiIntId -diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf -index e9eb092d3a..c98dc82f0c 100644 ---- a/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf -+++ b/ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf -@@ -67,4 +67,6 @@ - gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize - gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize - -+ gArmPlatformTokenSpaceGuid.PcdEarlyHelloMessage -+ - gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack --- -2.27.0 - diff --git a/SOURCES/0018-ArmVirtPkg-set-early-hello-message-RH-only.patch b/SOURCES/0018-ArmVirtPkg-set-early-hello-message-RH-only.patch deleted file mode 100644 index 23137c2..0000000 --- a/SOURCES/0018-ArmVirtPkg-set-early-hello-message-RH-only.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 12873d08db00e113ef28eb4552f478cd4ffb3393 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Wed, 14 Oct 2015 14:07:17 +0200 -Subject: ArmVirtPkg: set early hello message (RH only) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- no change - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- context difference from upstream commit f5cb3767038e - ("ArmVirtPkg/ArmVirtQemu: add ResetSystem PEIM for upcoming TPM2 - support", 2020-03-04) automatically resolved correctly - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- no change - -Notes about the RHEL-8.0/20180508-ee3198e672e2 -> -RHEL-8.1/20190308-89910a39dcfd rebase: - -- resolve context conflict with upstream commit eaa1e98ae31d ("ArmVirtPkg: - don't set PcdCoreCount", 2019-02-13) - -Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 -> -RHEL-8.0/20180508-ee3198e672e2 rebase: - -- reorder the rebase changelog in the commit message so that it reads like - a blog: place more recent entries near the top -- no changes to the patch body - -Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase: - -- no changes - -Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase: - -- no changes - -Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase: - -- no changes - -Print a friendly banner on QEMU, regardless of debug mask settings. - -RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1270279 -Downstream only: -. - -Contributed-under: TianoCore Contribution Agreement 1.0 -Signed-off-by: Laszlo Ersek -(cherry picked from commit 5d4a15b9019728b2d96322bc679099da49916925) -(cherry picked from commit 179df76dbb0d199bd905236e98775b4059c6502a) -(cherry picked from commit ce3f59d0710c24c162d5222bbf5cd7e36180c80c) -(cherry picked from commit c201a8e6ae28d75f7ba581828b533c3b26fa7f18) -(cherry picked from commit 2d4db6ec70e004cd9ac147615d17033bee5d3b18) -(cherry picked from commit fb2032bbea7e02c426855cf86a323556d493fd8a) -(cherry picked from commit ba73b99d5cb38f87c1a8f0936d515eaaefa3f04b) -(cherry picked from commit 72550e12ae469012a505bf5b98a6543a754028d3) ---- - ArmVirtPkg/ArmVirtQemu.dsc | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc -index e0476ede4f..ec0edf6e7b 100644 ---- a/ArmVirtPkg/ArmVirtQemu.dsc -+++ b/ArmVirtPkg/ArmVirtQemu.dsc -@@ -134,6 +134,7 @@ - gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled|$(TPM2_ENABLE) - - [PcdsFixedAtBuild.common] -+ gArmPlatformTokenSpaceGuid.PcdEarlyHelloMessage|"UEFI firmware starting.\r\n" - !if $(ARCH) == AARCH64 - gArmTokenSpaceGuid.PcdVFPEnabled|1 - !endif --- -2.27.0 - diff --git a/SOURCES/0024-CryptoPkg-OpensslLib-list-RHEL8-specific-OpenSSL-fil.patch b/SOURCES/0024-CryptoPkg-OpensslLib-list-RHEL8-specific-OpenSSL-fil.patch deleted file mode 100644 index 8546eb5..0000000 --- a/SOURCES/0024-CryptoPkg-OpensslLib-list-RHEL8-specific-OpenSSL-fil.patch +++ /dev/null @@ -1,179 +0,0 @@ -From e0b349962f12a500afa449900a81440a96ca21f4 Mon Sep 17 00:00:00 2001 -From: Laszlo Ersek -Date: Sat, 16 Nov 2019 17:11:27 +0100 -Subject: CryptoPkg/OpensslLib: list RHEL8-specific OpenSSL files in the INFs - (RH) - -Notes about the RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] -> -RHEL-8.5/20210520-e1999b264f1f [edk2-stable202105] rebase: - -- Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1938257 - -- Recreate the patch based on downstream commits: - - - 56c4bb81b311 ("CryptoPkg/OpensslLib: list RHEL8-specific OpenSSL files - in the INFs (RH)", 2020-06-05), - - e81751a1c303 ("CryptoPkg/OpensslLib: Upgrade OpenSSL to 1.1.1g", - 2020-11-23), - - 3e3fe5e62079 ("redhat: bump OpenSSL dist-git submodule to 1.1.1g+ / - RHEL-8.4", 2020-11-23). - - (1) At e81751a1c303, downstream edk2 was in sync with upstream edk2 - consuming OpenSSL 1.1.1g (upstream edk2 commit 8c30327debb2 - ("CryptoPkg/OpensslLib: Upgrade OpenSSL to 1.1.1g", 2020-07-25)). - - Since commit 8c30327debb2, upstream edk2 modified the OpensslLib INF - files, namely - - - CryptoPkg/Library/OpensslLib/OpensslLib.inf - - CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - - in the following commits only: - - - be01087e0780 ("CryptoPkg/Library: Remove the redundant build - option", 2020-08-12), which did not affect the source file list at - all, - - - b5701a4c7a0f ("CryptoPkg: OpensslLib: Use RngLib to generate - entropy in rand_pool", 2020-09-18), which replaced some of the - *edk2-specific* "rand_pool_noise" source files with an RngLib - dependency. - - This means that the list of required, actual OpenSSL source files - has not changed in upstream edk2 since our downstream edk2 commit - e81751a1c303. - - (2) At commit 3e3fe5e62079 (the direct child of e81751a1c303), - downstream edk2's OpenSSL dependency was satisfied with RHEL-8 - OpenSSL at dist-git commit bdd048e929dc ("Two fixes that will be - shipped in RHEL-8.3.0.z", 2020-10-23). - - Since commit bdd048e929dc, RHEL-8 OpenSSL dist-git advanced - (fast-forwarded) to commit a75722161d20 ("Update to version 1.1.1k", - 2021-05-25), which is the current head of the rhel-8.5.0 branch. - (See also .) - - At both dist-git bdd048e929dc and dist-git a75722161d20, I built the - respective RHEL-8 OpenSSL *source* RPM, and prepped the respective - source tree, with "rpmbuild -bp". Subsequently I compared the - prepped source trees recursively. - - - The following files disappeared: - - - 29 backup files created by "patch", - - - the assembly generator perl script called - "ecp_nistz256-avx2.pl", which is not used during the build. - - - The following new files appeared: - - - 18 files directly or indirectly under the "test" subdirectory, - which are not used during the build, - - - 5 backup files created by "patch", - - - 2 DCL scripts used when building OpenSSL on OpenVMS. - - This means that the total list of RHEL-8 OpenSSL source files has - not changed in RHEL-8 OpenSSL dist-git since our downstream edk2 - commit 3e3fe5e62079. - - As a result, copy the "RHEL8-specific OpenSSL file list" sections - verbatim from the INF files, at downstream commit e81751a1c303. (I used - the "git checkout -p e81751a1c303 -- Library/OpensslLib/OpensslLib.inf - CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf" command.) - -Notes about the RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] -> -RHEL-8.3/20200603-ca407c7246bf [edk2-stable202005] rebase: - -- "OpensslLib.inf": - - - Automatic leading context refresh against upstream commit c72ca4666886 - ("CryptoPkg/OpensslLib: Add "sort" keyword to header file parsing - loop", 2020-03-10). - - - Manual trailing context refresh against upstream commit b49a6c8f80d9 - ("CryptoPkg/OpensslLib: improve INF file consistency", 2019-12-02). - -- "OpensslLibCrypto.inf": - - - Automatic leading context refresh against upstream commits - 8906f076de35 ("CryptoPkg/OpensslLib: Add missing header files in INF - file", 2019-08-16) and 9f4fbd56d430 ("CryptoPkg/OpensslLib: Update - process_files.pl to generate .h files", 2019-10-30). - -Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] -> -RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase: - -- new patch - -The downstream changes in RHEL8's OpenSSL package, for example in -"openssl-1.1.1-evp-kdf.patch", introduce new files, and even move some -preexistent code into those new files. In order to avoid undefined -references in link editing, we have to list the new files. - -Note: "process_files.pl" is not re-run at this time manually, because - -(a) "process_files.pl" would pollute the file list (and some of the - auto-generated header files) with RHEL8-specific FIPS artifacts, which - are explicitly unwanted in edk2, - -(b) The RHEL OpenSSL maintainer, Tomas Mraz, identified this specific set - of files in , - and will help with future changes too. - -Signed-off-by: Laszlo Ersek -(cherry picked from commit 57bd3f146590df8757865d8f2cdd1db3cf3f4d40) -(cherry picked from commit 56c4bb81b311dfcee6a34c81d3e4feeda7f88995) ---- - CryptoPkg/Library/OpensslLib/OpensslLib.inf | 11 +++++++++++ - CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 11 +++++++++++ - 2 files changed, 22 insertions(+) - -diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf -index d84bde056a..19913a4ac6 100644 ---- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf -+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf -@@ -570,6 +570,17 @@ - $(OPENSSL_PATH)/ssl/statem/statem.h - $(OPENSSL_PATH)/ssl/statem/statem_local.h - # Autogenerated files list ends here -+# RHEL8-specific OpenSSL file list starts here -+ $(OPENSSL_PATH)/crypto/evp/kdf_lib.c -+ $(OPENSSL_PATH)/crypto/evp/pkey_kdf.c -+ $(OPENSSL_PATH)/crypto/kdf/kbkdf.c -+ $(OPENSSL_PATH)/crypto/kdf/kdf_local.h -+ $(OPENSSL_PATH)/crypto/kdf/kdf_util.c -+ $(OPENSSL_PATH)/crypto/kdf/krb5kdf.c -+ $(OPENSSL_PATH)/crypto/kdf/pbkdf2.c -+ $(OPENSSL_PATH)/crypto/kdf/sshkdf.c -+ $(OPENSSL_PATH)/crypto/kdf/sskdf.c -+# RHEL8-specific OpenSSL file list ends here - buildinf.h - ossl_store.c - rand_pool.c -diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -index cdeed0d073..5057857e8d 100644 ---- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -@@ -519,6 +519,17 @@ - $(OPENSSL_PATH)/crypto/x509v3/standard_exts.h - $(OPENSSL_PATH)/crypto/x509v3/v3_admis.h - # Autogenerated files list ends here -+# RHEL8-specific OpenSSL file list starts here -+ $(OPENSSL_PATH)/crypto/evp/kdf_lib.c -+ $(OPENSSL_PATH)/crypto/evp/pkey_kdf.c -+ $(OPENSSL_PATH)/crypto/kdf/kbkdf.c -+ $(OPENSSL_PATH)/crypto/kdf/kdf_local.h -+ $(OPENSSL_PATH)/crypto/kdf/kdf_util.c -+ $(OPENSSL_PATH)/crypto/kdf/krb5kdf.c -+ $(OPENSSL_PATH)/crypto/kdf/pbkdf2.c -+ $(OPENSSL_PATH)/crypto/kdf/sshkdf.c -+ $(OPENSSL_PATH)/crypto/kdf/sskdf.c -+# RHEL8-specific OpenSSL file list ends here - buildinf.h - ossl_store.c - rand_pool.c --- -2.27.0 - diff --git a/SOURCES/LICENSE.qosb b/SOURCES/LICENSE.qosb deleted file mode 100644 index 9849381..0000000 --- a/SOURCES/LICENSE.qosb +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Patrick Uiterwijk - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/SOURCES/RedHatSecureBootPkKek1.pem b/SOURCES/RedHatSecureBootPkKek1.pem deleted file mode 100644 index d302362..0000000 --- a/SOURCES/RedHatSecureBootPkKek1.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDoDCCAoigAwIBAgIJAP71iOjzlsDxMA0GCSqGSIb3DQEBCwUAMFExKzApBgNV -BAMTIlJlZCBIYXQgU2VjdXJlIEJvb3QgKFBLL0tFSyBrZXkgMSkxIjAgBgkqhkiG -9w0BCQEWE3NlY2FsZXJ0QHJlZGhhdC5jb20wHhcNMTQxMDMxMTExNTM3WhcNMzcx -MDI1MTExNTM3WjBRMSswKQYDVQQDEyJSZWQgSGF0IFNlY3VyZSBCb290IChQSy9L -RUsga2V5IDEpMSIwIAYJKoZIhvcNAQkBFhNzZWNhbGVydEByZWRoYXQuY29tMIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkB+Ee42865cmgm2Iq4rJjGhw -+d9LB7I3gwsCyGdoMJ7j8PCZSrhZV8ZB9jiL/mZMSek3N5IumAEeWxRQ5qiNJQ31 -huarMMtAFuqNixaGcEM38s7Akd9xFI6ZDom2TG0kHozkL08l0LoG+MboGRh2cx2B -bajYBc86yHsoyDajFg0pjJmaaNyrwE2Nv1q7K6k5SwSXHPk2u8U6hgSur9SCe+Cr -3kkFaPz2rmgabJBNVxk8ZGYD9sdSm/eUz5NqoWjJqs+Za7yqXgjnORz3+A+6Bn7x -y+h23f4i2q06Xls06rPJ4E0EKX64YLkF77XZF1hWFmC5MDLwNkrD8nmNEkBw8wID -AQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVy -YXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUPOlg4/8ZoQp7o0L0jUIutNWccuww -HwYDVR0jBBgwFoAUPOlg4/8ZoQp7o0L0jUIutNWccuwwDQYJKoZIhvcNAQELBQAD -ggEBAFxNkoi0gl8drYsR7N8GpnqlK583VQyNbgUArbcMQYlpz9ZlBptReNKtx7+c -3AVzf+ceORO06rYwfUB1q5xDC9+wwhu/MOD0/sDbYiGY9sWv3jtPSQrmHvmGsD8N -1tRGN9tUdF7/EcJgxnBYxRxv7LLYbm/DvDOHOKTzRGScNDsolCZ4J58WF+g7aQol -qXM2fp43XOzoP9uR+RKzPc7n3RXDrowFIGGbld6br/qxXBzll+fDNBGF9YonJqRw -NuwM9oM9kPc28/nzFdSQYr5TtK/TSa/v9HPoe3bkRCo3uoGkmQw6MSRxoOTktxrL -R+SqIs/vdWGA40O3SFdzET14m2k= ------END CERTIFICATE----- diff --git a/SOURCES/edk2-Apply-uncrustify-changes-to-.c-.h-files-in-the-Netwo.patch b/SOURCES/edk2-Apply-uncrustify-changes-to-.c-.h-files-in-the-Netwo.patch deleted file mode 100644 index 0ef1750..0000000 --- a/SOURCES/edk2-Apply-uncrustify-changes-to-.c-.h-files-in-the-Netwo.patch +++ /dev/null @@ -1,1735 +0,0 @@ -From 0f2a885790fe3f397dee527a19ef7753a1961688 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 15 Feb 2024 11:38:46 -0500 -Subject: [PATCH 01/15] Apply uncrustify changes to .c/.h files in the - NetworkPkg package - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [1/15] 7a6f3c908d076e6497e0c8978785b679a23b83cf - -JIRA: https://issues.redhat.com/browse/RHEL-21844 -CVE: CVE-2022-45231 -Upstream: Merged -Conflicts: This commit is too intrusive to apply completely. We still save - us a lot of problems (git cherry-pick basically bails out) in - the following commits in this series if we apply it on the files - modified by those commits. - -commit d1050b9dff1cace252aff86630bfdb59dff5f507 -Author: Michael Kubacki -Date: Sun Dec 5 14:54:07 2021 -0800 - - NetworkPkg: Apply uncrustify changes - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 - - Apply uncrustify changes to .c/.h files in the NetworkPkg package - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael D Kinney - Signed-off-by: Michael Kubacki - Reviewed-by: Maciej Rabeda - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Ip6Dxe/Ip6Nd.h | 312 ++++++------- - NetworkPkg/Ip6Dxe/Ip6Option.c | 805 +++++++++++++++++----------------- - NetworkPkg/Ip6Dxe/Ip6Option.h | 88 ++-- - 3 files changed, 605 insertions(+), 600 deletions(-) - -diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.h b/NetworkPkg/Ip6Dxe/Ip6Nd.h -index 5f1bd6fb92..860934a167 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Nd.h -+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.h -@@ -13,82 +13,82 @@ - #define IP6_GET_TICKS(Ms) (((Ms) + IP6_TIMER_INTERVAL_IN_MS - 1) / IP6_TIMER_INTERVAL_IN_MS) - - enum { -- IP6_INF_ROUTER_LIFETIME = 0xFFFF, -+ IP6_INF_ROUTER_LIFETIME = 0xFFFF, - - IP6_MAX_RTR_SOLICITATION_DELAY = 1000, ///< 1000 milliseconds - IP6_MAX_RTR_SOLICITATIONS = 3, - IP6_RTR_SOLICITATION_INTERVAL = 4000, - -- IP6_MIN_RANDOM_FACTOR_SCALED = 1, -- IP6_MAX_RANDOM_FACTOR_SCALED = 3, -- IP6_RANDOM_FACTOR_SCALE = 2, -+ IP6_MIN_RANDOM_FACTOR_SCALED = 1, -+ IP6_MAX_RANDOM_FACTOR_SCALED = 3, -+ IP6_RANDOM_FACTOR_SCALE = 2, - -- IP6_MAX_MULTICAST_SOLICIT = 3, -- IP6_MAX_UNICAST_SOLICIT = 3, -- IP6_MAX_ANYCAST_DELAY_TIME = 1, -- IP6_MAX_NEIGHBOR_ADV = 3, -- IP6_REACHABLE_TIME = 30000, -- IP6_RETRANS_TIMER = 1000, -- IP6_DELAY_FIRST_PROBE_TIME = 5000, -+ IP6_MAX_MULTICAST_SOLICIT = 3, -+ IP6_MAX_UNICAST_SOLICIT = 3, -+ IP6_MAX_ANYCAST_DELAY_TIME = 1, -+ IP6_MAX_NEIGHBOR_ADV = 3, -+ IP6_REACHABLE_TIME = 30000, -+ IP6_RETRANS_TIMER = 1000, -+ IP6_DELAY_FIRST_PROBE_TIME = 5000, - -- IP6_MIN_LINK_MTU = 1280, -- IP6_MAX_LINK_MTU = 1500, -+ IP6_MIN_LINK_MTU = 1280, -+ IP6_MAX_LINK_MTU = 1500, - -- IP6_IS_ROUTER_FLAG = 0x80, -- IP6_SOLICITED_FLAG = 0x40, -- IP6_OVERRIDE_FLAG = 0x20, -+ IP6_IS_ROUTER_FLAG = 0x80, -+ IP6_SOLICITED_FLAG = 0x40, -+ IP6_OVERRIDE_FLAG = 0x20, - -- IP6_M_ADDR_CONFIG_FLAG = 0x80, -- IP6_O_CONFIG_FLAG = 0x40, -+ IP6_M_ADDR_CONFIG_FLAG = 0x80, -+ IP6_O_CONFIG_FLAG = 0x40, - -- IP6_ON_LINK_FLAG = 0x80, -- IP6_AUTO_CONFIG_FLAG = 0x40, -+ IP6_ON_LINK_FLAG = 0x80, -+ IP6_AUTO_CONFIG_FLAG = 0x40, - -- IP6_ND_LENGTH = 24, -- IP6_RA_LENGTH = 16, -- IP6_REDITECT_LENGTH = 40, -- IP6_DAD_ENTRY_SIGNATURE = SIGNATURE_32 ('I', 'P', 'D', 'E') -+ IP6_ND_LENGTH = 24, -+ IP6_RA_LENGTH = 16, -+ IP6_REDITECT_LENGTH = 40, -+ IP6_DAD_ENTRY_SIGNATURE = SIGNATURE_32 ('I', 'P', 'D', 'E') - }; - - typedef - VOID - (*IP6_ARP_CALLBACK) ( -- VOID *Context -+ VOID *Context - ); - - typedef struct _IP6_OPTION_HEADER { -- UINT8 Type; -- UINT8 Length; -+ UINT8 Type; -+ UINT8 Length; - } IP6_OPTION_HEADER; - - STATIC_ASSERT (sizeof (IP6_OPTION_HEADER) == 2, "IP6_OPTION_HEADER is expected to be exactly 2 bytes long."); - - typedef struct _IP6_ETHE_ADDR_OPTION { -- UINT8 Type; -- UINT8 Length; -- UINT8 EtherAddr[6]; -+ UINT8 Type; -+ UINT8 Length; -+ UINT8 EtherAddr[6]; - } IP6_ETHER_ADDR_OPTION; - - STATIC_ASSERT (sizeof (IP6_ETHER_ADDR_OPTION) == 8, "IP6_ETHER_ADDR_OPTION is expected to be exactly 8 bytes long."); - - typedef struct _IP6_MTU_OPTION { -- UINT8 Type; -- UINT8 Length; -- UINT16 Reserved; -- UINT32 Mtu; -+ UINT8 Type; -+ UINT8 Length; -+ UINT16 Reserved; -+ UINT32 Mtu; - } IP6_MTU_OPTION; - - STATIC_ASSERT (sizeof (IP6_MTU_OPTION) == 8, "IP6_MTU_OPTION is expected to be exactly 8 bytes long."); - - typedef struct _IP6_PREFIX_INFO_OPTION { -- UINT8 Type; -- UINT8 Length; -- UINT8 PrefixLength; -- UINT8 Reserved1; -- UINT32 ValidLifetime; -- UINT32 PreferredLifetime; -- UINT32 Reserved2; -- EFI_IPv6_ADDRESS Prefix; -+ UINT8 Type; -+ UINT8 Length; -+ UINT8 PrefixLength; -+ UINT8 Reserved1; -+ UINT32 ValidLifetime; -+ UINT32 PreferredLifetime; -+ UINT32 Reserved2; -+ EFI_IPv6_ADDRESS Prefix; - } IP6_PREFIX_INFO_OPTION; - - STATIC_ASSERT (sizeof (IP6_PREFIX_INFO_OPTION) == 32, "IP6_PREFIX_INFO_OPTION is expected to be exactly 32 bytes long."); -@@ -102,25 +102,25 @@ VOID - ); - - typedef struct _IP6_DAD_ENTRY { -- UINT32 Signature; -- LIST_ENTRY Link; -- UINT32 MaxTransmit; -- UINT32 Transmit; -- UINT32 Receive; -- UINT32 RetransTick; -- IP6_ADDRESS_INFO *AddressInfo; -- EFI_IPv6_ADDRESS Destination; -- IP6_DAD_CALLBACK Callback; -- VOID *Context; -+ UINT32 Signature; -+ LIST_ENTRY Link; -+ UINT32 MaxTransmit; -+ UINT32 Transmit; -+ UINT32 Receive; -+ UINT32 RetransTick; -+ IP6_ADDRESS_INFO *AddressInfo; -+ EFI_IPv6_ADDRESS Destination; -+ IP6_DAD_CALLBACK Callback; -+ VOID *Context; - } IP6_DAD_ENTRY; - - typedef struct _IP6_DELAY_JOIN_LIST { -- LIST_ENTRY Link; -- UINT32 DelayTime; ///< in tick per 50 milliseconds -- IP6_INTERFACE *Interface; -- IP6_ADDRESS_INFO *AddressInfo; -- IP6_DAD_CALLBACK DadCallback; -- VOID *Context; -+ LIST_ENTRY Link; -+ UINT32 DelayTime; ///< in tick per 50 milliseconds -+ IP6_INTERFACE *Interface; -+ IP6_ADDRESS_INFO *AddressInfo; -+ IP6_DAD_CALLBACK DadCallback; -+ VOID *Context; - } IP6_DELAY_JOIN_LIST; - - typedef struct _IP6_NEIGHBOR_ENTRY { -@@ -142,20 +142,20 @@ typedef struct _IP6_NEIGHBOR_ENTRY { - } IP6_NEIGHBOR_ENTRY; - - typedef struct _IP6_DEFAULT_ROUTER { -- LIST_ENTRY Link; -- INTN RefCnt; -- UINT16 Lifetime; -- EFI_IPv6_ADDRESS Router; -- IP6_NEIGHBOR_ENTRY *NeighborCache; -+ LIST_ENTRY Link; -+ INTN RefCnt; -+ UINT16 Lifetime; -+ EFI_IPv6_ADDRESS Router; -+ IP6_NEIGHBOR_ENTRY *NeighborCache; - } IP6_DEFAULT_ROUTER; - - typedef struct _IP6_PREFIX_LIST_ENTRY { -- LIST_ENTRY Link; -- INTN RefCnt; -- UINT32 ValidLifetime; -- UINT32 PreferredLifetime; -- UINT8 PrefixLength; -- EFI_IPv6_ADDRESS Prefix; -+ LIST_ENTRY Link; -+ INTN RefCnt; -+ UINT32 ValidLifetime; -+ UINT32 PreferredLifetime; -+ UINT8 PrefixLength; -+ EFI_IPv6_ADDRESS Prefix; - } IP6_PREFIX_LIST_ENTRY; - - /** -@@ -172,9 +172,9 @@ typedef struct _IP6_PREFIX_LIST_ENTRY { - **/ - EFI_STATUS - Ip6BuildEfiNeighborCache ( -- IN IP6_PROTOCOL *IpInstance, -- OUT UINT32 *NeighborCount, -- OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache -+ IN IP6_PROTOCOL *IpInstance, -+ OUT UINT32 *NeighborCount, -+ OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache - ); - - /** -@@ -210,9 +210,9 @@ Ip6BuildPrefixTable ( - **/ - IP6_DEFAULT_ROUTER * - Ip6CreateDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address, -- IN UINT16 RouterLifetime -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ IN UINT16 RouterLifetime - ); - - /** -@@ -224,8 +224,8 @@ Ip6CreateDefaultRouter ( - **/ - VOID - Ip6DestroyDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN IP6_DEFAULT_ROUTER *DefaultRouter -+ IN IP6_SERVICE *IpSb, -+ IN IP6_DEFAULT_ROUTER *DefaultRouter - ); - - /** -@@ -236,7 +236,7 @@ Ip6DestroyDefaultRouter ( - **/ - VOID - Ip6CleanDefaultRouterList ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ); - - /** -@@ -251,8 +251,8 @@ Ip6CleanDefaultRouterList ( - **/ - IP6_DEFAULT_ROUTER * - Ip6FindDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address - ); - - /** -@@ -289,10 +289,10 @@ Ip6OnDADFinished ( - **/ - EFI_STATUS - Ip6InitDADProcess ( -- IN IP6_INTERFACE *IpIf, -- IN IP6_ADDRESS_INFO *AddressInfo, -- IN IP6_DAD_CALLBACK Callback OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_INTERFACE *IpIf, -+ IN IP6_ADDRESS_INFO *AddressInfo, -+ IN IP6_DAD_CALLBACK Callback OPTIONAL, -+ IN VOID *Context OPTIONAL - ); - - /** -@@ -309,9 +309,9 @@ Ip6InitDADProcess ( - **/ - IP6_DAD_ENTRY * - Ip6FindDADEntry ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Target, -- OUT IP6_INTERFACE **Interface OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Target, -+ OUT IP6_INTERFACE **Interface OPTIONAL - ); - - /** -@@ -334,12 +334,12 @@ Ip6FindDADEntry ( - **/ - IP6_PREFIX_LIST_ENTRY * - Ip6CreatePrefixListEntry ( -- IN IP6_SERVICE *IpSb, -- IN BOOLEAN OnLinkOrAuto, -- IN UINT32 ValidLifetime, -- IN UINT32 PreferredLifetime, -- IN UINT8 PrefixLength, -- IN EFI_IPv6_ADDRESS *Prefix -+ IN IP6_SERVICE *IpSb, -+ IN BOOLEAN OnLinkOrAuto, -+ IN UINT32 ValidLifetime, -+ IN UINT32 PreferredLifetime, -+ IN UINT8 PrefixLength, -+ IN EFI_IPv6_ADDRESS *Prefix - ); - - /** -@@ -377,10 +377,10 @@ Ip6DestroyPrefixListEntry ( - **/ - IP6_PREFIX_LIST_ENTRY * - Ip6FindPrefixListEntry ( -- IN IP6_SERVICE *IpSb, -- IN BOOLEAN OnLinkOrAuto, -- IN UINT8 PrefixLength, -- IN EFI_IPv6_ADDRESS *Prefix -+ IN IP6_SERVICE *IpSb, -+ IN BOOLEAN OnLinkOrAuto, -+ IN UINT8 PrefixLength, -+ IN EFI_IPv6_ADDRESS *Prefix - ); - - /** -@@ -393,8 +393,8 @@ Ip6FindPrefixListEntry ( - **/ - VOID - Ip6CleanPrefixListTable ( -- IN IP6_SERVICE *IpSb, -- IN LIST_ENTRY *ListHead -+ IN IP6_SERVICE *IpSb, -+ IN LIST_ENTRY *ListHead - ); - - /** -@@ -413,10 +413,10 @@ Ip6CleanPrefixListTable ( - **/ - IP6_NEIGHBOR_ENTRY * - Ip6CreateNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN IP6_ARP_CALLBACK CallBack, -- IN EFI_IPv6_ADDRESS *Ip6Address, -- IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_ARP_CALLBACK CallBack, -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL - ); - - /** -@@ -431,8 +431,8 @@ Ip6CreateNeighborEntry ( - **/ - IP6_NEIGHBOR_ENTRY * - Ip6FindNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address - ); - - /** -@@ -458,13 +458,13 @@ Ip6FindNeighborEntry ( - **/ - EFI_STATUS - Ip6FreeNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN IP6_NEIGHBOR_ENTRY *NeighborCache, -- IN BOOLEAN SendIcmpError, -- IN BOOLEAN FullFree, -- IN EFI_STATUS IoStatus, -- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_NEIGHBOR_ENTRY *NeighborCache, -+ IN BOOLEAN SendIcmpError, -+ IN BOOLEAN FullFree, -+ IN EFI_STATUS IoStatus, -+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL, -+ IN VOID *Context OPTIONAL - ); - - /** -@@ -493,11 +493,11 @@ Ip6FreeNeighborEntry ( - **/ - EFI_STATUS - Ip6AddNeighbor ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -- IN UINT32 Timeout, -- IN BOOLEAN Override -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -+ IN UINT32 Timeout, -+ IN BOOLEAN Override - ); - - /** -@@ -521,11 +521,11 @@ Ip6AddNeighbor ( - **/ - EFI_STATUS - Ip6DelNeighbor ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -- IN UINT32 Timeout, -- IN BOOLEAN Override -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -+ IN UINT32 Timeout, -+ IN BOOLEAN Override - ); - - /** -@@ -544,9 +544,9 @@ Ip6DelNeighbor ( - **/ - EFI_STATUS - Ip6ProcessNeighborSolicit ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ); - - /** -@@ -564,9 +564,9 @@ Ip6ProcessNeighborSolicit ( - **/ - EFI_STATUS - Ip6ProcessNeighborAdvertise ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ); - - /** -@@ -584,9 +584,9 @@ Ip6ProcessNeighborAdvertise ( - **/ - EFI_STATUS - Ip6ProcessRouterAdvertise ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ); - - /** -@@ -607,9 +607,9 @@ Ip6ProcessRouterAdvertise ( - **/ - EFI_STATUS - Ip6ProcessRedirect ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ); - - /** -@@ -631,11 +631,11 @@ Ip6ProcessRedirect ( - **/ - EFI_STATUS - Ip6SendRouterSolicit ( -- IN IP6_SERVICE *IpSb, -- IN IP6_INTERFACE *Interface OPTIONAL, -- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, -- IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL, -- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_INTERFACE *Interface OPTIONAL, -+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, -+ IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL, -+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL - ); - - /** -@@ -658,11 +658,11 @@ Ip6SendRouterSolicit ( - **/ - EFI_STATUS - Ip6SendNeighborSolicit ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *SourceAddress, -- IN EFI_IPv6_ADDRESS *DestinationAddress, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *SourceAddress, -+ IN EFI_IPv6_ADDRESS *DestinationAddress, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL - ); - - /** -@@ -690,14 +690,14 @@ Ip6SendNeighborSolicit ( - **/ - EFI_STATUS - Ip6SetAddress ( -- IN IP6_INTERFACE *Interface, -- IN EFI_IPv6_ADDRESS *Ip6Addr, -- IN BOOLEAN IsAnycast, -- IN UINT8 PrefixLength, -- IN UINT32 ValidLifetime, -- IN UINT32 PreferredLifetime, -- IN IP6_DAD_CALLBACK DadCallback OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_INTERFACE *Interface, -+ IN EFI_IPv6_ADDRESS *Ip6Addr, -+ IN BOOLEAN IsAnycast, -+ IN UINT8 PrefixLength, -+ IN UINT32 ValidLifetime, -+ IN UINT32 PreferredLifetime, -+ IN IP6_DAD_CALLBACK DadCallback OPTIONAL, -+ IN VOID *Context OPTIONAL - ); - - /** -@@ -712,8 +712,8 @@ Ip6SetAddress ( - VOID - EFIAPI - Ip6NdFasterTimerTicking ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ); - - /** -@@ -726,7 +726,7 @@ Ip6NdFasterTimerTicking ( - **/ - VOID - Ip6NdTimerTicking ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ); - - /** -@@ -739,7 +739,7 @@ Ip6NdTimerTicking ( - **/ - VOID - Ip6OnArpResolved ( -- IN VOID *Context -+ IN VOID *Context - ); - - /** -diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.c b/NetworkPkg/Ip6Dxe/Ip6Option.c -index 6b4b029d14..199eea124d 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Option.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Option.c -@@ -28,15 +28,15 @@ - **/ - BOOLEAN - Ip6IsOptionValid ( -- IN IP6_SERVICE *IpSb, -- IN NET_BUF *Packet, -- IN UINT8 *Option, -- IN UINT8 OptionLen, -- IN UINT32 Pointer -+ IN IP6_SERVICE *IpSb, -+ IN NET_BUF *Packet, -+ IN UINT8 *Option, -+ IN UINT8 OptionLen, -+ IN UINT32 Pointer - ) - { -- UINT8 Offset; -- UINT8 OptionType; -+ UINT8 Offset; -+ UINT8 OptionType; - - Offset = 0; - -@@ -44,68 +44,67 @@ Ip6IsOptionValid ( - OptionType = *(Option + Offset); - - switch (OptionType) { -- case Ip6OptionPad1: -- // -- // It is a Pad1 option -- // -- Offset++; -- break; -- case Ip6OptionPadN: -- // -- // It is a PadN option -- // -- Offset = (UINT8) (Offset + *(Option + Offset + 1) + 2); -- break; -- case Ip6OptionRouterAlert: -- // -- // It is a Router Alert Option -- // -- Offset += 4; -- break; -- default: -- // -- // The highest-order two bits specify the action must be taken if -- // the processing IPv6 node does not recognize the option type. -- // -- switch (OptionType & Ip6OptionMask) { -- case Ip6OptionSkip: -- Offset = (UINT8) (Offset + *(Option + Offset + 1)); -+ case Ip6OptionPad1: -+ // -+ // It is a Pad1 option -+ // -+ Offset++; - break; -- case Ip6OptionDiscard: -- return FALSE; -- case Ip6OptionParameterProblem: -- Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER); -- Ip6SendIcmpError ( -- IpSb, -- Packet, -- NULL, -- &Packet->Ip.Ip6->SourceAddress, -- ICMP_V6_PARAMETER_PROBLEM, -- 2, -- &Pointer -- ); -- return FALSE; -- case Ip6OptionMask: -- if (!IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -- Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER); -- Ip6SendIcmpError ( -- IpSb, -- Packet, -- NULL, -- &Packet->Ip.Ip6->SourceAddress, -- ICMP_V6_PARAMETER_PROBLEM, -- 2, -- &Pointer -- ); -+ case Ip6OptionPadN: -+ // -+ // It is a PadN option -+ // -+ Offset = (UINT8)(Offset + *(Option + Offset + 1) + 2); -+ break; -+ case Ip6OptionRouterAlert: -+ // -+ // It is a Router Alert Option -+ // -+ Offset += 4; -+ break; -+ default: -+ // -+ // The highest-order two bits specify the action must be taken if -+ // the processing IPv6 node does not recognize the option type. -+ // -+ switch (OptionType & Ip6OptionMask) { -+ case Ip6OptionSkip: -+ Offset = (UINT8)(Offset + *(Option + Offset + 1)); -+ break; -+ case Ip6OptionDiscard: -+ return FALSE; -+ case Ip6OptionParameterProblem: -+ Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER); -+ Ip6SendIcmpError ( -+ IpSb, -+ Packet, -+ NULL, -+ &Packet->Ip.Ip6->SourceAddress, -+ ICMP_V6_PARAMETER_PROBLEM, -+ 2, -+ &Pointer -+ ); -+ return FALSE; -+ case Ip6OptionMask: -+ if (!IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -+ Pointer = Pointer + Offset + sizeof (EFI_IP6_HEADER); -+ Ip6SendIcmpError ( -+ IpSb, -+ Packet, -+ NULL, -+ &Packet->Ip.Ip6->SourceAddress, -+ ICMP_V6_PARAMETER_PROBLEM, -+ 2, -+ &Pointer -+ ); -+ } -+ -+ return FALSE; -+ break; - } - -- return FALSE; - break; -- } -- -- break; - } -- - } - - return TRUE; -@@ -125,13 +124,13 @@ Ip6IsOptionValid ( - **/ - BOOLEAN - Ip6IsNDOptionValid ( -- IN UINT8 *Option, -- IN UINT16 OptionLen -+ IN UINT8 *Option, -+ IN UINT16 OptionLen - ) - { -- UINT32 Offset; -- UINT16 Length; -- IP6_OPTION_HEADER *OptionHeader; -+ UINT32 Offset; -+ UINT16 Length; -+ IP6_OPTION_HEADER *OptionHeader; - - if (Option == NULL) { - ASSERT (Option != NULL); -@@ -146,50 +145,54 @@ Ip6IsNDOptionValid ( - // fit within the input buffer. - // - while (Offset + sizeof (IP6_OPTION_HEADER) - 1 < OptionLen) { -- OptionHeader = (IP6_OPTION_HEADER*) (Option + Offset); -- Length = (UINT16) OptionHeader->Length * 8; -+ OptionHeader = (IP6_OPTION_HEADER *)(Option + Offset); -+ Length = (UINT16)OptionHeader->Length * 8; - - switch (OptionHeader->Type) { -- case Ip6OptionPrefixInfo: -- if (Length != 32) { -- return FALSE; -- } -- break; -+ case Ip6OptionPrefixInfo: -+ if (Length != 32) { -+ return FALSE; -+ } - -- case Ip6OptionMtu: -- if (Length != 8) { -- return FALSE; -- } -- break; -+ break; - -- default: -- // RFC 4861 states that Length field cannot be 0. -- if (Length == 0) { -- return FALSE; -- } -- break; -+ case Ip6OptionMtu: -+ if (Length != 8) { -+ return FALSE; -+ } -+ -+ break; -+ -+ default: -+ // RFC 4861 states that Length field cannot be 0. -+ if (Length == 0) { -+ return FALSE; -+ } -+ -+ break; - } - - // - // Check whether recognized options are within the input buffer's scope. - // - switch (OptionHeader->Type) { -- case Ip6OptionEtherSource: -- case Ip6OptionEtherTarget: -- case Ip6OptionPrefixInfo: -- case Ip6OptionRedirected: -- case Ip6OptionMtu: -- if (Offset + Length > (UINT32) OptionLen) { -- return FALSE; -- } -- break; -+ case Ip6OptionEtherSource: -+ case Ip6OptionEtherTarget: -+ case Ip6OptionPrefixInfo: -+ case Ip6OptionRedirected: -+ case Ip6OptionMtu: -+ if (Offset + Length > (UINT32)OptionLen) { -+ return FALSE; -+ } - -- default: -- // -- // Unrecognized options can be either valid (but unused) or invalid -- // (garbage in between or right after valid options). Silently ignore. -- // -- break; -+ break; -+ -+ default: -+ // -+ // Unrecognized options can be either valid (but unused) or invalid -+ // (garbage in between or right after valid options). Silently ignore. -+ // -+ break; - } - - // -@@ -202,7 +205,6 @@ Ip6IsNDOptionValid ( - return TRUE; - } - -- - /** - Validate whether the NextHeader is a known valid protocol or one of the user configured - protocols from the upper layer. -@@ -216,18 +218,19 @@ Ip6IsNDOptionValid ( - **/ - BOOLEAN - Ip6IsValidProtocol ( -- IN IP6_SERVICE *IpSb, -- IN UINT8 NextHeader -+ IN IP6_SERVICE *IpSb, -+ IN UINT8 NextHeader - ) - { -- LIST_ENTRY *Entry; -- IP6_PROTOCOL *IpInstance; -- -- if (NextHeader == EFI_IP_PROTO_TCP || -- NextHeader == EFI_IP_PROTO_UDP || -- NextHeader == IP6_ICMP || -- NextHeader == IP6_ESP -- ) { -+ LIST_ENTRY *Entry; -+ IP6_PROTOCOL *IpInstance; -+ -+ if ((NextHeader == EFI_IP_PROTO_TCP) || -+ (NextHeader == EFI_IP_PROTO_UDP) || -+ (NextHeader == IP6_ICMP) || -+ (NextHeader == IP6_ESP) -+ ) -+ { - return TRUE; - } - -@@ -281,29 +284,29 @@ Ip6IsValidProtocol ( - **/ - BOOLEAN - Ip6IsExtsValid ( -- IN IP6_SERVICE *IpSb OPTIONAL, -- IN NET_BUF *Packet OPTIONAL, -- IN UINT8 *NextHeader, -- IN UINT8 *ExtHdrs, -- IN UINT32 ExtHdrsLen, -- IN BOOLEAN Rcvd, -- OUT UINT32 *FormerHeader OPTIONAL, -- OUT UINT8 **LastHeader, -- OUT UINT32 *RealExtsLen OPTIONAL, -- OUT UINT32 *UnFragmentLen OPTIONAL, -- OUT BOOLEAN *Fragmented OPTIONAL -+ IN IP6_SERVICE *IpSb OPTIONAL, -+ IN NET_BUF *Packet OPTIONAL, -+ IN UINT8 *NextHeader, -+ IN UINT8 *ExtHdrs, -+ IN UINT32 ExtHdrsLen, -+ IN BOOLEAN Rcvd, -+ OUT UINT32 *FormerHeader OPTIONAL, -+ OUT UINT8 **LastHeader, -+ OUT UINT32 *RealExtsLen OPTIONAL, -+ OUT UINT32 *UnFragmentLen OPTIONAL, -+ OUT BOOLEAN *Fragmented OPTIONAL - ) - { -- UINT32 Pointer; -- UINT32 Offset; -- UINT8 *Option; -- UINT8 OptionLen; -- BOOLEAN Flag; -- UINT8 CountD; -- UINT8 CountA; -- IP6_FRAGMENT_HEADER *FragmentHead; -- UINT16 FragmentOffset; -- IP6_ROUTING_HEADER *RoutingHead; -+ UINT32 Pointer; -+ UINT32 Offset; -+ UINT8 *Option; -+ UINT8 OptionLen; -+ BOOLEAN Flag; -+ UINT8 CountD; -+ UINT8 CountA; -+ IP6_FRAGMENT_HEADER *FragmentHead; -+ UINT16 FragmentOffset; -+ IP6_ROUTING_HEADER *RoutingHead; - - if (RealExtsLen != NULL) { - *RealExtsLen = 0; -@@ -319,11 +322,11 @@ Ip6IsExtsValid ( - - *LastHeader = NextHeader; - -- if (ExtHdrs == NULL && ExtHdrsLen == 0) { -+ if ((ExtHdrs == NULL) && (ExtHdrsLen == 0)) { - return TRUE; - } - -- if ((ExtHdrs == NULL && ExtHdrsLen != 0) || (ExtHdrs != NULL && ExtHdrsLen == 0)) { -+ if (((ExtHdrs == NULL) && (ExtHdrsLen != 0)) || ((ExtHdrs != NULL) && (ExtHdrsLen == 0))) { - return FALSE; - } - -@@ -334,236 +337,240 @@ Ip6IsExtsValid ( - CountA = 0; - - while (Offset <= ExtHdrsLen) { -- - switch (*NextHeader) { -- case IP6_HOP_BY_HOP: -- if (Offset != 0) { -- if (!Rcvd) { -+ case IP6_HOP_BY_HOP: -+ if (Offset != 0) { -+ if (!Rcvd) { -+ return FALSE; -+ } -+ -+ // -+ // Hop-by-Hop Options header is restricted to appear immediately after an IPv6 header only. -+ // If not, generate a ICMP parameter problem message with code value of 1. -+ // -+ if (Pointer == 0) { -+ Pointer = sizeof (EFI_IP6_HEADER); -+ } else { -+ Pointer = Offset + sizeof (EFI_IP6_HEADER); -+ } -+ -+ if ((IpSb != NULL) && (Packet != NULL) && -+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) -+ { -+ Ip6SendIcmpError ( -+ IpSb, -+ Packet, -+ NULL, -+ &Packet->Ip.Ip6->SourceAddress, -+ ICMP_V6_PARAMETER_PROBLEM, -+ 1, -+ &Pointer -+ ); -+ } -+ - return FALSE; - } -- // -- // Hop-by-Hop Options header is restricted to appear immediately after an IPv6 header only. -- // If not, generate a ICMP parameter problem message with code value of 1. -- // -- if (Pointer == 0) { -- Pointer = sizeof (EFI_IP6_HEADER); -- } else { -- Pointer = Offset + sizeof (EFI_IP6_HEADER); -+ -+ Flag = TRUE; -+ -+ // -+ // Fall through -+ // -+ case IP6_DESTINATION: -+ if (*NextHeader == IP6_DESTINATION) { -+ CountD++; - } - -- if ((IpSb != NULL) && (Packet != NULL) && -- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -- Ip6SendIcmpError ( -- IpSb, -- Packet, -- NULL, -- &Packet->Ip.Ip6->SourceAddress, -- ICMP_V6_PARAMETER_PROBLEM, -- 1, -- &Pointer -- ); -+ if (CountD > 2) { -+ return FALSE; - } -- return FALSE; -- } - -- Flag = TRUE; -+ NextHeader = ExtHdrs + Offset; -+ Pointer = Offset; - -- // -- // Fall through -- // -- case IP6_DESTINATION: -- if (*NextHeader == IP6_DESTINATION) { -- CountD++; -- } -+ Offset++; -+ Option = ExtHdrs + Offset; -+ OptionLen = (UINT8)((*Option + 1) * 8 - 2); -+ Option++; -+ Offset++; - -- if (CountD > 2) { -- return FALSE; -- } -+ if ((IpSb != NULL) && (Packet != NULL) && !Ip6IsOptionValid (IpSb, Packet, Option, OptionLen, Offset)) { -+ return FALSE; -+ } - -- NextHeader = ExtHdrs + Offset; -- Pointer = Offset; -+ Offset = Offset + OptionLen; - -- Offset++; -- Option = ExtHdrs + Offset; -- OptionLen = (UINT8) ((*Option + 1) * 8 - 2); -- Option++; -- Offset++; -+ if (Flag) { -+ if (UnFragmentLen != NULL) { -+ *UnFragmentLen = Offset; -+ } - -- if (IpSb != NULL && Packet != NULL && !Ip6IsOptionValid (IpSb, Packet, Option, OptionLen, Offset)) { -- return FALSE; -- } -+ Flag = FALSE; -+ } -+ -+ break; - -- Offset = Offset + OptionLen; -+ case IP6_ROUTING: -+ NextHeader = ExtHdrs + Offset; -+ RoutingHead = (IP6_ROUTING_HEADER *)NextHeader; - -- if (Flag) { -- if (UnFragmentLen != NULL) { -- *UnFragmentLen = Offset; -+ // -+ // Type 0 routing header is defined in RFC2460 and deprecated in RFC5095. -+ // Thus all routing types are processed as unrecognized. -+ // -+ if (RoutingHead->SegmentsLeft == 0) { -+ // -+ // Ignore the routing header and proceed to process the next header. -+ // -+ Offset = Offset + (RoutingHead->HeaderLen + 1) * 8; -+ -+ if (UnFragmentLen != NULL) { -+ *UnFragmentLen = Offset; -+ } -+ } else { -+ // -+ // Discard the packet and send an ICMP Parameter Problem, Code 0, message -+ // to the packet's source address, pointing to the unrecognized routing -+ // type. -+ // -+ Pointer = Offset + 2 + sizeof (EFI_IP6_HEADER); -+ if ((IpSb != NULL) && (Packet != NULL) && -+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) -+ { -+ Ip6SendIcmpError ( -+ IpSb, -+ Packet, -+ NULL, -+ &Packet->Ip.Ip6->SourceAddress, -+ ICMP_V6_PARAMETER_PROBLEM, -+ 0, -+ &Pointer -+ ); -+ } -+ -+ return FALSE; - } - -- Flag = FALSE; -- } -+ break; - -- break; -+ case IP6_FRAGMENT: - -- case IP6_ROUTING: -- NextHeader = ExtHdrs + Offset; -- RoutingHead = (IP6_ROUTING_HEADER *) NextHeader; -+ // -+ // RFC2402, AH header should after fragment header. -+ // -+ if (CountA > 1) { -+ return FALSE; -+ } - -- // -- // Type 0 routing header is defined in RFC2460 and deprecated in RFC5095. -- // Thus all routing types are processed as unrecognized. -- // -- if (RoutingHead->SegmentsLeft == 0) { - // -- // Ignore the routing header and proceed to process the next header. -+ // RFC2460, ICMP Parameter Problem message with code 0 should be sent -+ // if the length of a fragment is not a multiple of 8 octets and the M -+ // flag of that fragment is 1, pointing to the Payload length field of the -+ // fragment packet. - // -- Offset = Offset + (RoutingHead->HeaderLen + 1) * 8; -+ if ((IpSb != NULL) && (Packet != NULL) && ((ExtHdrsLen % 8) != 0)) { -+ // -+ // Check whether it is the last fragment. -+ // -+ FragmentHead = (IP6_FRAGMENT_HEADER *)(ExtHdrs + Offset); -+ if (FragmentHead == NULL) { -+ return FALSE; -+ } -+ -+ FragmentOffset = NTOHS (FragmentHead->FragmentOffset); -+ -+ if (((FragmentOffset & 0x1) == 0x1) && -+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) -+ { -+ Pointer = sizeof (UINT32); -+ Ip6SendIcmpError ( -+ IpSb, -+ Packet, -+ NULL, -+ &Packet->Ip.Ip6->SourceAddress, -+ ICMP_V6_PARAMETER_PROBLEM, -+ 0, -+ &Pointer -+ ); -+ return FALSE; -+ } -+ } -+ -+ if (Fragmented != NULL) { -+ *Fragmented = TRUE; -+ } -+ -+ if (Rcvd && (FormerHeader != NULL)) { -+ *FormerHeader = (UINT32)(NextHeader - ExtHdrs); -+ } -+ -+ NextHeader = ExtHdrs + Offset; -+ Offset = Offset + 8; -+ break; - -- if (UnFragmentLen != NULL) { -- *UnFragmentLen = Offset; -+ case IP6_AH: -+ if (++CountA > 1) { -+ return FALSE; - } - -- } else { -+ Option = ExtHdrs + Offset; -+ NextHeader = Option; -+ Option++; - // -- // Discard the packet and send an ICMP Parameter Problem, Code 0, message -- // to the packet's source address, pointing to the unrecognized routing -- // type. -+ // RFC2402, Payload length is specified in 32-bit words, minus "2". - // -- Pointer = Offset + 2 + sizeof (EFI_IP6_HEADER); -- if ((IpSb != NULL) && (Packet != NULL) && -- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -- Ip6SendIcmpError ( -- IpSb, -- Packet, -- NULL, -- &Packet->Ip.Ip6->SourceAddress, -- ICMP_V6_PARAMETER_PROBLEM, -- 0, -- &Pointer -- ); -- } -+ OptionLen = (UINT8)((*Option + 2) * 4); -+ Offset = Offset + OptionLen; -+ break; - -+ case IP6_NO_NEXT_HEADER: -+ *LastHeader = NextHeader; - return FALSE; -- } -+ break; - -- break; -+ default: -+ if (Ip6IsValidProtocol (IpSb, *NextHeader)) { -+ *LastHeader = NextHeader; - -- case IP6_FRAGMENT: -+ if (RealExtsLen != NULL) { -+ *RealExtsLen = Offset; -+ } - -- // -- // RFC2402, AH header should after fragment header. -- // -- if (CountA > 1) { -- return FALSE; -- } -+ return TRUE; -+ } - -- // -- // RFC2460, ICMP Parameter Problem message with code 0 should be sent -- // if the length of a fragment is not a multiple of 8 octets and the M -- // flag of that fragment is 1, pointing to the Payload length field of the -- // fragment packet. -- // -- if (IpSb != NULL && Packet != NULL && (ExtHdrsLen % 8) != 0) { - // -- // Check whether it is the last fragment. -+ // The Next Header value is unrecognized by the node, discard the packet and -+ // send an ICMP parameter problem message with code value of 1. - // -- FragmentHead = (IP6_FRAGMENT_HEADER *) (ExtHdrs + Offset); -- if (FragmentHead == NULL) { -- return FALSE; -+ if (Offset == 0) { -+ // -+ // The Next Header directly follows IPv6 basic header. -+ // -+ Pointer = 6; -+ } else { -+ if (Pointer == 0) { -+ Pointer = sizeof (EFI_IP6_HEADER); -+ } else { -+ Pointer = Offset + sizeof (EFI_IP6_HEADER); -+ } - } - -- FragmentOffset = NTOHS (FragmentHead->FragmentOffset); -- -- if (((FragmentOffset & 0x1) == 0x1) && -- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -- Pointer = sizeof (UINT32); -+ if ((IpSb != NULL) && (Packet != NULL) && -+ !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) -+ { - Ip6SendIcmpError ( - IpSb, - Packet, - NULL, - &Packet->Ip.Ip6->SourceAddress, - ICMP_V6_PARAMETER_PROBLEM, -- 0, -+ 1, - &Pointer - ); -- return FALSE; - } -- } -- -- if (Fragmented != NULL) { -- *Fragmented = TRUE; -- } - -- if (Rcvd && FormerHeader != NULL) { -- *FormerHeader = (UINT32) (NextHeader - ExtHdrs); -- } -- -- NextHeader = ExtHdrs + Offset; -- Offset = Offset + 8; -- break; -- -- case IP6_AH: -- if (++CountA > 1) { - return FALSE; -- } -- -- Option = ExtHdrs + Offset; -- NextHeader = Option; -- Option++; -- // -- // RFC2402, Payload length is specified in 32-bit words, minus "2". -- // -- OptionLen = (UINT8) ((*Option + 2) * 4); -- Offset = Offset + OptionLen; -- break; -- -- case IP6_NO_NEXT_HEADER: -- *LastHeader = NextHeader; -- return FALSE; -- break; -- -- default: -- if (Ip6IsValidProtocol (IpSb, *NextHeader)) { -- -- *LastHeader = NextHeader; -- -- if (RealExtsLen != NULL) { -- *RealExtsLen = Offset; -- } -- -- return TRUE; -- } -- -- // -- // The Next Header value is unrecognized by the node, discard the packet and -- // send an ICMP parameter problem message with code value of 1. -- // -- if (Offset == 0) { -- // -- // The Next Header directly follows IPv6 basic header. -- // -- Pointer = 6; -- } else { -- if (Pointer == 0) { -- Pointer = sizeof (EFI_IP6_HEADER); -- } else { -- Pointer = Offset + sizeof (EFI_IP6_HEADER); -- } -- } -- -- if ((IpSb != NULL) && (Packet != NULL) && -- !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) { -- Ip6SendIcmpError ( -- IpSb, -- Packet, -- NULL, -- &Packet->Ip.Ip6->SourceAddress, -- ICMP_V6_PARAMETER_PROBLEM, -- 1, -- &Pointer -- ); -- } -- return FALSE; - } - } - -@@ -592,12 +599,12 @@ Ip6IsExtsValid ( - **/ - EFI_STATUS - Ip6FillHopByHop ( -- OUT UINT8 *Buffer, -- IN OUT UINTN *BufferLen, -- IN UINT8 NextHeader -+ OUT UINT8 *Buffer, -+ IN OUT UINTN *BufferLen, -+ IN UINT8 NextHeader - ) - { -- UINT8 BufferArray[8]; -+ UINT8 BufferArray[8]; - - if (*BufferLen < 8) { - *BufferLen = 8; -@@ -640,23 +647,23 @@ Ip6FillHopByHop ( - **/ - EFI_STATUS - Ip6FillFragmentHeader ( -- IN IP6_SERVICE *IpSb, -- IN UINT8 NextHeader, -- IN UINT8 LastHeader, -- IN UINT8 *ExtHdrs, -- IN UINT32 ExtHdrsLen, -- IN UINT16 FragmentOffset, -- OUT UINT8 **UpdatedExtHdrs -+ IN IP6_SERVICE *IpSb, -+ IN UINT8 NextHeader, -+ IN UINT8 LastHeader, -+ IN UINT8 *ExtHdrs, -+ IN UINT32 ExtHdrsLen, -+ IN UINT16 FragmentOffset, -+ OUT UINT8 **UpdatedExtHdrs - ) - { -- UINT32 Length; -- UINT8 *Buffer; -- UINT32 FormerHeader; -- UINT32 Offset; -- UINT32 Part1Len; -- UINT32 HeaderLen; -- UINT8 Current; -- IP6_FRAGMENT_HEADER FragmentHead; -+ UINT32 Length; -+ UINT8 *Buffer; -+ UINT32 FormerHeader; -+ UINT32 Offset; -+ UINT32 Part1Len; -+ UINT32 HeaderLen; -+ UINT8 Current; -+ IP6_FRAGMENT_HEADER FragmentHead; - - if (UpdatedExtHdrs == NULL) { - return EFI_INVALID_PARAMETER; -@@ -668,82 +675,81 @@ Ip6FillFragmentHeader ( - return EFI_OUT_OF_RESOURCES; - } - -- Offset = 0; -- Part1Len = 0; -- FormerHeader = 0; -- Current = NextHeader; -+ Offset = 0; -+ Part1Len = 0; -+ FormerHeader = 0; -+ Current = NextHeader; - - while ((ExtHdrs != NULL) && (Offset <= ExtHdrsLen)) { - switch (NextHeader) { -- case IP6_ROUTING: -- case IP6_HOP_BY_HOP: -- case IP6_DESTINATION: -- Current = NextHeader; -- NextHeader = *(ExtHdrs + Offset); -+ case IP6_ROUTING: -+ case IP6_HOP_BY_HOP: -+ case IP6_DESTINATION: -+ Current = NextHeader; -+ NextHeader = *(ExtHdrs + Offset); -+ -+ if ((Current == IP6_DESTINATION) && (NextHeader != IP6_ROUTING)) { -+ // -+ // Destination Options header should occur at most twice, once before -+ // a Routing header and once before the upper-layer header. Here we -+ // find the one before the upper-layer header. Insert the Fragment -+ // Header before it. -+ // -+ CopyMem (Buffer, ExtHdrs, Part1Len); -+ *(Buffer + FormerHeader) = IP6_FRAGMENT; -+ // -+ // Exit the loop. -+ // -+ Offset = ExtHdrsLen + 1; -+ break; -+ } - -- if ((Current == IP6_DESTINATION) && (NextHeader != IP6_ROUTING)) { -- // -- // Destination Options header should occur at most twice, once before -- // a Routing header and once before the upper-layer header. Here we -- // find the one before the upper-layer header. Insert the Fragment -- // Header before it. -- // -- CopyMem (Buffer, ExtHdrs, Part1Len); -- *(Buffer + FormerHeader) = IP6_FRAGMENT; -- // -- // Exit the loop. -- // -- Offset = ExtHdrsLen + 1; -+ FormerHeader = Offset; -+ HeaderLen = (*(ExtHdrs + Offset + 1) + 1) * 8; -+ Part1Len = Part1Len + HeaderLen; -+ Offset = Offset + HeaderLen; - break; -- } -- - -- FormerHeader = Offset; -- HeaderLen = (*(ExtHdrs + Offset + 1) + 1) * 8; -- Part1Len = Part1Len + HeaderLen; -- Offset = Offset + HeaderLen; -- break; -- -- case IP6_FRAGMENT: -- Current = NextHeader; -- -- if (Part1Len != 0) { -- CopyMem (Buffer, ExtHdrs, Part1Len); -- } -- -- *(Buffer + FormerHeader) = IP6_FRAGMENT; -- -- // -- // Exit the loop. -- // -- Offset = ExtHdrsLen + 1; -- break; -+ case IP6_FRAGMENT: -+ Current = NextHeader; - -- case IP6_AH: -- Current = NextHeader; -- NextHeader = *(ExtHdrs + Offset); -- // -- // RFC2402, Payload length is specified in 32-bit words, minus "2". -- // -- HeaderLen = (*(ExtHdrs + Offset + 1) + 2) * 4; -- Part1Len = Part1Len + HeaderLen; -- Offset = Offset + HeaderLen; -- break; -+ if (Part1Len != 0) { -+ CopyMem (Buffer, ExtHdrs, Part1Len); -+ } - -- default: -- if (Ip6IsValidProtocol (IpSb, NextHeader)) { -- Current = NextHeader; -- CopyMem (Buffer, ExtHdrs, Part1Len); - *(Buffer + FormerHeader) = IP6_FRAGMENT; -+ - // - // Exit the loop. - // - Offset = ExtHdrsLen + 1; - break; -- } - -- FreePool (Buffer); -- return EFI_UNSUPPORTED; -+ case IP6_AH: -+ Current = NextHeader; -+ NextHeader = *(ExtHdrs + Offset); -+ // -+ // RFC2402, Payload length is specified in 32-bit words, minus "2". -+ // -+ HeaderLen = (*(ExtHdrs + Offset + 1) + 2) * 4; -+ Part1Len = Part1Len + HeaderLen; -+ Offset = Offset + HeaderLen; -+ break; -+ -+ default: -+ if (Ip6IsValidProtocol (IpSb, NextHeader)) { -+ Current = NextHeader; -+ CopyMem (Buffer, ExtHdrs, Part1Len); -+ *(Buffer + FormerHeader) = IP6_FRAGMENT; -+ // -+ // Exit the loop. -+ // -+ Offset = ExtHdrsLen + 1; -+ break; -+ } -+ -+ FreePool (Buffer); -+ return EFI_UNSUPPORTED; - } - } - -@@ -778,4 +784,3 @@ Ip6FillFragmentHeader ( - - return EFI_SUCCESS; - } -- -diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.h b/NetworkPkg/Ip6Dxe/Ip6Option.h -index c81b3fda2f..bd8e223c8a 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Option.h -+++ b/NetworkPkg/Ip6Dxe/Ip6Option.h -@@ -10,20 +10,20 @@ - #ifndef __EFI_IP6_OPTION_H__ - #define __EFI_IP6_OPTION_H__ - --#define IP6_FRAGMENT_OFFSET_MASK (~0x3) -+#define IP6_FRAGMENT_OFFSET_MASK (~0x3) - - typedef struct _IP6_FRAGMENT_HEADER { -- UINT8 NextHeader; -- UINT8 Reserved; -- UINT16 FragmentOffset; -- UINT32 Identification; -+ UINT8 NextHeader; -+ UINT8 Reserved; -+ UINT16 FragmentOffset; -+ UINT32 Identification; - } IP6_FRAGMENT_HEADER; - - typedef struct _IP6_ROUTING_HEADER { -- UINT8 NextHeader; -- UINT8 HeaderLen; -- UINT8 RoutingType; -- UINT8 SegmentsLeft; -+ UINT8 NextHeader; -+ UINT8 HeaderLen; -+ UINT8 RoutingType; -+ UINT8 SegmentsLeft; - } IP6_ROUTING_HEADER; - - typedef enum { -@@ -35,11 +35,11 @@ typedef enum { - Ip6OptionParameterProblem = 0x80, - Ip6OptionMask = 0xc0, - -- Ip6OptionEtherSource = 1, -- Ip6OptionEtherTarget = 2, -- Ip6OptionPrefixInfo = 3, -- Ip6OptionRedirected = 4, -- Ip6OptionMtu = 5 -+ Ip6OptionEtherSource = 1, -+ Ip6OptionEtherTarget = 2, -+ Ip6OptionPrefixInfo = 3, -+ Ip6OptionRedirected = 4, -+ Ip6OptionMtu = 5 - } IP6_OPTION_TYPE; - - /** -@@ -72,17 +72,17 @@ typedef enum { - **/ - BOOLEAN - Ip6IsExtsValid ( -- IN IP6_SERVICE *IpSb OPTIONAL, -- IN NET_BUF *Packet OPTIONAL, -- IN UINT8 *NextHeader, -- IN UINT8 *ExtHdrs, -- IN UINT32 ExtHdrsLen, -- IN BOOLEAN Rcvd, -- OUT UINT32 *FormerHeader OPTIONAL, -- OUT UINT8 **LastHeader, -- OUT UINT32 *RealExtsLen OPTIONAL, -- OUT UINT32 *UnFragmentLen OPTIONAL, -- OUT BOOLEAN *Fragmented OPTIONAL -+ IN IP6_SERVICE *IpSb OPTIONAL, -+ IN NET_BUF *Packet OPTIONAL, -+ IN UINT8 *NextHeader, -+ IN UINT8 *ExtHdrs, -+ IN UINT32 ExtHdrsLen, -+ IN BOOLEAN Rcvd, -+ OUT UINT32 *FormerHeader OPTIONAL, -+ OUT UINT8 **LastHeader, -+ OUT UINT32 *RealExtsLen OPTIONAL, -+ OUT UINT32 *UnFragmentLen OPTIONAL, -+ OUT BOOLEAN *Fragmented OPTIONAL - ); - - /** -@@ -101,9 +101,9 @@ Ip6IsExtsValid ( - **/ - EFI_STATUS - Ip6FillHopByHop ( -- OUT UINT8 *Buffer, -- IN OUT UINTN *BufferLen, -- IN UINT8 NextHeader -+ OUT UINT8 *Buffer, -+ IN OUT UINTN *BufferLen, -+ IN UINT8 NextHeader - ); - - /** -@@ -127,13 +127,13 @@ Ip6FillHopByHop ( - **/ - EFI_STATUS - Ip6FillFragmentHeader ( -- IN IP6_SERVICE *IpSb, -- IN UINT8 NextHeader, -- IN UINT8 LastHeader, -- IN UINT8 *ExtHdrs, -- IN UINT32 ExtHdrsLen, -- IN UINT16 FragmentOffset, -- OUT UINT8 **UpdatedExtHdrs -+ IN IP6_SERVICE *IpSb, -+ IN UINT8 NextHeader, -+ IN UINT8 LastHeader, -+ IN UINT8 *ExtHdrs, -+ IN UINT32 ExtHdrsLen, -+ IN UINT16 FragmentOffset, -+ OUT UINT8 **UpdatedExtHdrs - ); - - /** -@@ -155,13 +155,13 @@ Ip6FillFragmentHeader ( - **/ - EFI_STATUS - Ip6CopyExts ( -- IN UINT8 NextHeader, -- IN UINT8 *ExtHdrs, -- IN UINT8 *LastHeader, -- IN UINT16 FragmentOffset, -- IN UINT32 UnFragmentHdrLen, -- IN OUT UINT8 *Buf, -- IN OUT UINT32 *BufLen -+ IN UINT8 NextHeader, -+ IN UINT8 *ExtHdrs, -+ IN UINT8 *LastHeader, -+ IN UINT16 FragmentOffset, -+ IN UINT32 UnFragmentHdrLen, -+ IN OUT UINT8 *Buf, -+ IN OUT UINT32 *BufLen - ); - - /** -@@ -178,8 +178,8 @@ Ip6CopyExts ( - **/ - BOOLEAN - Ip6IsNDOptionValid ( -- IN UINT8 *Option, -- IN UINT16 OptionLen -+ IN UINT8 *Option, -+ IN UINT16 OptionLen - ); - - #endif --- -2.39.3 - diff --git a/SOURCES/edk2-ArmVirtPkg-ArmVirtQemu-migrate-to-OVMF-s-VirtNorFlas.patch b/SOURCES/edk2-ArmVirtPkg-ArmVirtQemu-migrate-to-OVMF-s-VirtNorFlas.patch deleted file mode 100644 index 43848d5..0000000 --- a/SOURCES/edk2-ArmVirtPkg-ArmVirtQemu-migrate-to-OVMF-s-VirtNorFlas.patch +++ /dev/null @@ -1,149 +0,0 @@ -From 9ef10bbe9a03f22aa5c5ff659012794d37ef9839 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 18:41:22 +0200 -Subject: [PATCH 17/18] ArmVirtPkg/ArmVirtQemu: migrate to OVMF's - VirtNorFlashDxe - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [19/20] 2160140b0ea566451ab723e941d2ab91e1ad874e - -Switch to the virt specific NorFlashDxe driver implementation that was -added recently. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit b92298af8218dd074c231947bc95f2be94af663c) ---- - ArmVirtPkg/ArmVirtQemu.dsc | 4 ++-- - ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 2 +- - ArmVirtPkg/ArmVirtQemuKernel.dsc | 4 ++-- - ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 12 ++++++------ - .../Library/NorFlashQemuLib/NorFlashQemuLib.inf | 4 ++-- - 5 files changed, 13 insertions(+), 13 deletions(-) - -diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc -index e6fad9f066..2b23becf30 100644 ---- a/ArmVirtPkg/ArmVirtQemu.dsc -+++ b/ArmVirtPkg/ArmVirtQemu.dsc -@@ -67,7 +67,7 @@ - ArmPlatformLib|ArmPlatformPkg/Library/ArmPlatformLibNull/ArmPlatformLibNull.inf - - TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf -- NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf -+ VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf - - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf -@@ -400,7 +400,7 @@ - - NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf - } -- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -+ OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - - # -diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc -index f6a538df72..7c655d384d 100644 ---- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc -+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc -@@ -73,7 +73,7 @@ READ_LOCK_STATUS = TRUE - - INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf - INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf -- INF ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -+ INF OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf - INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - - # -diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc -index 656c9d99a3..344e2c4ed9 100644 ---- a/ArmVirtPkg/ArmVirtQemuKernel.dsc -+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc -@@ -65,7 +65,7 @@ - ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf - - TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf -- NorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf -+ VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf - - CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf - BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf -@@ -329,7 +329,7 @@ - - NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf - } -- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -+ OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - - # -diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c -index 271d7f0efb..93a2fed40f 100644 ---- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c -+++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c -@@ -8,8 +8,8 @@ - - #include - #include --#include - #include -+#include - - #include - -@@ -18,19 +18,19 @@ - #define MAX_FLASH_BANKS 4 - - EFI_STATUS --NorFlashPlatformInitialization ( -+VirtNorFlashPlatformInitialization ( - VOID - ) - { - return EFI_SUCCESS; - } - --NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS]; -+STATIC VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS]; - - EFI_STATUS --NorFlashPlatformGetDevices ( -- OUT NOR_FLASH_DESCRIPTION **NorFlashDescriptions, -- OUT UINT32 *Count -+VirtNorFlashPlatformGetDevices ( -+ OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions, -+ OUT UINT32 *Count - ) - { - FDT_CLIENT_PROTOCOL *FdtClient; -diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf -index 4c3683bf5d..a6b5865be9 100644 ---- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf -+++ b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf -@@ -14,17 +14,17 @@ - FILE_GUID = 339B7829-4C5F-4EFC-B2DD-5050E530DECE - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 -- LIBRARY_CLASS = NorFlashPlatformLib -+ LIBRARY_CLASS = VirtNorFlashPlatformLib - - [Sources.common] - NorFlashQemuLib.c - - [Packages] - MdePkg/MdePkg.dec -- ArmPlatformPkg/ArmPlatformPkg.dec - ArmPkg/ArmPkg.dec - ArmVirtPkg/ArmVirtPkg.dec - EmbeddedPkg/EmbeddedPkg.dec -+ OvmfPkg/OvmfPkg.dec - - [LibraryClasses] - BaseLib --- -2.41.0 - diff --git a/SOURCES/edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch b/SOURCES/edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch deleted file mode 100644 index 1ae0b2a..0000000 --- a/SOURCES/edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 045496325e278716e724ffdf9685667a8766d4f3 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 10:34:52 -0400 -Subject: [PATCH 28/31] CryptoPkg/Test: call ProcessLibraryConstructorList - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [28/31] 5ff484fbc68d094fbcdda2772c2869818c67de8d - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 94961b8817eec6f8d0434555ac50a7aa51c22201 -Author: Gerd Hoffmann -Date: Fri Jun 14 11:45:49 2024 +0200 - - CryptoPkg/Test: call ProcessLibraryConstructorList - - Needed to properly initialize BaseRngLib. - - Signed-off-by: Gerd Hoffmann - -Signed-off-by: Jon Maloy ---- - CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c -index 88a3f96305..0ba9f35840 100644 ---- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c -+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/UnitTestMain.c -@@ -8,6 +8,11 @@ - **/ - #include "TestBaseCryptLib.h" - -+VOID -+EFIAPI -+ProcessLibraryConstructorList ( -+ VOID -+ ); - - /** - Initialize the unit test framework, suite, and unit tests for the -@@ -77,5 +82,6 @@ main ( - char *argv[] - ) - { -+ ProcessLibraryConstructorList (); - return UefiTestMain (); - } --- -2.39.3 - diff --git a/SOURCES/edk2-EmbeddedPkg-Hob-Integer-Overflow-in-CreateHob.patch b/SOURCES/edk2-EmbeddedPkg-Hob-Integer-Overflow-in-CreateHob.patch deleted file mode 100644 index 8a5d148..0000000 --- a/SOURCES/edk2-EmbeddedPkg-Hob-Integer-Overflow-in-CreateHob.patch +++ /dev/null @@ -1,174 +0,0 @@ -From f8691984227809170b702f6fd087add1f95ee8fe Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 5 Mar 2024 16:38:49 -0500 -Subject: [PATCH 1/2] EmbeddedPkg/Hob: Integer Overflow in CreateHob() - -RH-Author: Jon Maloy -RH-MergeRequest: 66: EmbeddedPkg/Hob: Integer Overflow in CreateHob() -RH-Jira: RHEL-21158 -RH-Acked-by: Oliver Steffen -RH-Acked-by: Gerd Hoffmann -RH-Commit: [1/2] 301d3bfe82c39179fb85d510788831aa340212d9 - -JIRA: https://issues.redhat.com/browse/RHEL-21158 -CVE: CVE-2022-36765 -Upstream: Merged - -commit aeaee8944f0eaacbf4cdf39279785b9ba4836bb6 -Author: Gua Guo -Date: Thu Jan 11 13:07:50 2024 +0800 - - EmbeddedPkg/Hob: Integer Overflow in CreateHob() - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4166 - - Fix integer overflow in various CreateHob instances. - Fixes: CVE-2022-36765 - - The CreateHob() function aligns the requested size to 8 - performing the following operation: - ``` - HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); - ``` - - No checks are performed to ensure this value doesn't - overflow, and could lead to CreateHob() returning a smaller - HOB than requested, which could lead to OOB HOB accesses. - - Reported-by: Marc Beatove - Cc: Leif Lindholm - Reviewed-by: Ard Biesheuvel - Cc: Abner Chang - Cc: John Mathew - Authored-by: Gerd Hoffmann - Signed-off-by: Gua Guo - -Signed-off-by: Jon Maloy ---- - EmbeddedPkg/Library/PrePiHobLib/Hob.c | 47 +++++++++++++++++++++++++-- - 1 file changed, 45 insertions(+), 2 deletions(-) - -diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c -index b5cc6c5d8f..f4c99369c6 100644 ---- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c -+++ b/EmbeddedPkg/Library/PrePiHobLib/Hob.c -@@ -112,6 +112,13 @@ CreateHob ( - - HandOffHob = GetHobList (); - -+ // -+ // Check Length to avoid data overflow. -+ // -+ if (HobLength > MAX_UINT16 - 0x7) { -+ return NULL; -+ } -+ - HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); - - FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; -@@ -161,7 +168,10 @@ BuildResourceDescriptorHob ( - EFI_HOB_RESOURCE_DESCRIPTOR *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); -- ASSERT(Hob != NULL); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->ResourceType = ResourceType; - Hob->ResourceAttribute = ResourceAttribute; -@@ -403,6 +413,10 @@ BuildModuleHob ( - ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)); - - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid); - Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; -@@ -450,7 +464,12 @@ BuildGuidHob ( - // - ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE))); - -- Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength)); -+ Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return NULL; -+ } -+ - CopyGuid (&Hob->Name, Guid); - return Hob + 1; - } -@@ -516,6 +535,10 @@ BuildFvHob ( - EFI_HOB_FIRMWARE_VOLUME *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; -@@ -548,6 +571,10 @@ BuildFv2Hob ( - EFI_HOB_FIRMWARE_VOLUME2 *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; -@@ -589,6 +616,10 @@ BuildFv3Hob ( - EFI_HOB_FIRMWARE_VOLUME3 *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_FV3, sizeof (EFI_HOB_FIRMWARE_VOLUME3)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; -@@ -645,6 +676,10 @@ BuildCpuHob ( - EFI_HOB_CPU *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->SizeOfMemorySpace = SizeOfMemorySpace; - Hob->SizeOfIoSpace = SizeOfIoSpace; -@@ -681,6 +716,10 @@ BuildStackHob ( - ((Length & (EFI_PAGE_SIZE - 1)) == 0)); - - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid); - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; -@@ -761,6 +800,10 @@ BuildMemoryAllocationHob ( - ((Length & (EFI_PAGE_SIZE - 1)) == 0)); - - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; --- -2.39.3 - diff --git a/SOURCES/edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch b/SOURCES/edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch deleted file mode 100644 index 9726ce4..0000000 --- a/SOURCES/edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch +++ /dev/null @@ -1,11782 +0,0 @@ -From 3d6c7242687a2253d5d70e3c9aedb73ba300df0c Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Mon, 10 Jun 2024 18:13:29 -0400 -Subject: [PATCH 01/31] MdeModulePkg: Change use of EFI_D_* to DEBUG_* - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [1/31] a5706fbb91131cd294fc93e56f18ce9973824c5d - -JIRA: https://issues.redhat.com/browse/RHEL-40099 -CVE: CVE-2024-1298 -Upstream: Merged - -commit 87000d77082339be464d07855d9fc194c6b4e8a6 -Author: Michael D Kinney -Date: Tue Nov 16 19:21:29 2021 -0800 - - MdeModulePkg: Change use of EFI_D_* to DEBUG_* - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3739 - - Update all use of EFI_D_* defines in DEBUG() macros to DEBUG_* defines. - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael Kubacki - Signed-off-by: Michael D Kinney - Reviewed-by: Liming Gao - -Signed-off-by: Jon Maloy ---- - .../MemoryProfileInfo/MemoryProfileInfo.c | 12 +- - .../Bus/Ata/AtaAtapiPassThru/AhciMode.c | 15 +- - .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 9 +- - .../Bus/Ata/AtaAtapiPassThru/IdeMode.c | 43 ++- - MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c | 11 +- - .../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 24 +- - MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c | 18 +- - MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c | 20 +- - MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c | 53 ++-- - MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c | 124 ++++----- - MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c | 14 +- - MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c | 12 +- - MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c | 2 +- - MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c | 34 +-- - .../Bus/Pci/NvmExpressDxe/NvmExpress.c | 18 +- - .../Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 74 ++--- - .../Pci/NvmExpressDxe/NvmExpressPassthru.c | 107 ++++--- - .../Bus/Pci/PciBusDxe/PciEnumerator.c | 3 +- - .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c | 23 +- - MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 36 +-- - .../Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 22 +- - .../Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 14 +- - MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 6 +- - .../Bus/Pci/PciSioSerialDxe/SerialIo.c | 12 +- - .../Pci/SataControllerDxe/SataController.c | 21 +- - .../Bus/Pci/SdMmcPciHcPei/SdMmcPciHcPei.c | 2 +- - .../Bus/Pci/UfsPciHcPei/UfsPciHcPei.c | 2 +- - MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c | 5 +- - MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c | 51 ++-- - MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.c | 10 +- - MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c | 4 +- - MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 2 +- - MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c | 2 +- - MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 63 +++-- - MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 25 +- - MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 122 ++++---- - MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c | 59 ++-- - MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 121 ++++---- - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 44 +-- - .../Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c | 6 +- - MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c | 37 ++- - MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c | 3 +- - MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c | 5 +- - .../Bus/Sd/SdBlockIoPei/SdBlockIoPei.c | 2 +- - MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c | 60 ++-- - MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 5 +- - MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c | 5 +- - .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 24 +- - MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 61 ++-- - MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 4 +- - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c | 24 +- - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c | 26 +- - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 78 +++--- - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c | 34 +-- - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c | 5 +- - MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c | 8 +- - MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c | 4 +- - MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c | 42 ++- - .../Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c | 16 +- - .../Bus/Usb/UsbMassStorageDxe/UsbMassBot.c | 11 +- - .../Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c | 6 +- - .../Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c | 40 +-- - MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 2 +- - MdeModulePkg/Core/Dxe/Event/Tpl.c | 4 +- - MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 6 +- - MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 4 +- - MdeModulePkg/Core/Dxe/Image/Image.c | 8 +- - .../Core/Dxe/Mem/MemoryProfileRecord.c | 2 +- - MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 4 +- - .../Core/Dxe/Misc/MemoryAttributesTable.c | 22 +- - .../Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 3 +- - .../Core/DxeIplPeim/X64/DxeLoadFunc.c | 2 +- - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 37 ++- - MdeModulePkg/Core/Pei/FwVol/FwVol.c | 36 +-- - MdeModulePkg/Core/Pei/Hob/Hob.c | 6 +- - MdeModulePkg/Core/Pei/Image/Image.c | 18 +- - MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 8 +- - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 2 +- - MdeModulePkg/Core/Pei/Ppi/Ppi.c | 11 +- - MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 4 +- - MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 2 +- - MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 6 +- - .../Core/PiSmmCore/SmramProfileRecord.c | 129 +++++---- - .../BootMaintenanceManagerUiLib/BootOption.c | 3 +- - .../Library/BootManagerUiLib/BootManager.c | 3 +- - .../DxeIpmiLibIpmiProtocol.c | 2 +- - .../FrameBufferBltLib/FrameBufferBltLib.c | 14 +- - .../PciHostBridgeLibNull.c | 8 +- - .../PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c | 2 +- - .../ReportStatusCodeLib.c | 2 +- - .../PiDxeS3BootScriptLib/BootScriptExecute.c | 261 +++++++++--------- - .../PiDxeS3BootScriptLib/BootScriptSave.c | 4 +- - .../PlatformVarCleanupLib/PlatVarCleanupLib.c | 28 +- - .../SmmIpmiLibSmmIpmiProtocol.c | 2 +- - .../Library/UefiBootManagerLib/BmBoot.c | 6 +- - .../Library/UefiBootManagerLib/BmConsole.c | 4 +- - .../UefiBootManagerLib/BmDriverHealth.c | 10 +- - .../Library/UefiBootManagerLib/BmHotkey.c | 14 +- - .../Library/UefiBootManagerLib/BmLoadOption.c | 2 +- - .../Library/UefiBootManagerLib/BmMisc.c | 16 +- - .../Library/VarCheckLib/VarCheckLib.c | 14 +- - .../VarCheckPcdLib/VarCheckPcdLibNullClass.c | 70 ++--- - .../VarCheckUefiLibNullClass.c | 4 +- - .../Universal/Acpi/AcpiTableDxe/AcpiSdt.c | 4 +- - .../Acpi/AcpiTableDxe/AmlNamespace.c | 18 +- - .../Universal/Acpi/AcpiTableDxe/AmlString.c | 14 +- - .../BootScriptExecutorDxe/ScriptExecute.c | 3 +- - .../FirmwarePerformanceDxe.c | 20 +- - .../FirmwarePerformancePei.c | 12 +- - .../Acpi/S3SaveStateDxe/AcpiS3ContextSave.c | 17 +- - MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 24 +- - .../Universal/CapsulePei/X64/X64Entry.c | 2 +- - .../X64/SaveLongModeContext.c | 2 +- - .../Console/ConSplitterDxe/ConSplitter.c | 6 +- - .../GraphicsConsoleDxe/GraphicsConsole.c | 6 +- - .../GraphicsOutputDxe/GraphicsOutput.c | 8 +- - .../Console/TerminalDxe/TerminalConIn.c | 2 +- - .../Disk/CdExpressPei/PeiCdExpress.c | 18 +- - .../Universal/Disk/DiskIoDxe/DiskIo.c | 8 +- - .../Universal/Disk/PartitionDxe/ElTorito.c | 8 +- - .../Universal/Disk/PartitionDxe/Gpt.c | 74 ++--- - .../Universal/Disk/PartitionDxe/Mbr.c | 2 +- - .../Universal/Disk/PartitionDxe/Partition.c | 5 +- - .../Universal/Disk/RamDiskDxe/RamDiskDriver.c | 6 +- - .../Disk/RamDiskDxe/RamDiskProtocol.c | 6 +- - .../DriverHealthManagerDxe.c | 6 +- - MdeModulePkg/Universal/EbcDxe/EbcInt.c | 18 +- - MdeModulePkg/Universal/EsrtDxe/EsrtDxe.c | 10 +- - MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c | 8 +- - .../FaultTolerantWrite.c | 25 +- - .../FaultTolerantWriteSmm.c | 20 +- - .../Universal/FaultTolerantWriteDxe/FtwMisc.c | 39 ++- - .../UpdateWorkingBlock.c | 10 +- - .../FaultTolerantWritePei.c | 16 +- - .../HiiDatabaseDxe/ConfigKeywordHandler.c | 4 +- - .../Universal/LockBox/SmmLockBox/SmmLockBox.c | 28 +- - MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 36 +-- - .../SmbiosMeasurementDxe.c | 66 ++--- - .../SmmCommunicationBufferDxe.c | 20 +- - .../Universal/TimestampDxe/TimestampDxe.c | 2 +- - .../Universal/Variable/Pei/Variable.c | 6 +- - .../Variable/RuntimeDxe/Measurement.c | 6 +- - .../Universal/Variable/RuntimeDxe/Variable.c | 35 ++- - .../Variable/RuntimeDxe/VariableDxe.c | 3 +- - .../Variable/RuntimeDxe/VariableSmm.c | 30 +- - .../WatchdogTimerDxe/WatchdogTimer.c | 2 +- - 146 files changed, 1563 insertions(+), 1622 deletions(-) - -diff --git a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c -index 191c310685..99a2d52db1 100644 ---- a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c -+++ b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c -@@ -1027,7 +1027,7 @@ GetUefiMemoryProfileData ( - - Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **) &ProfileProtocol); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UefiMemoryProfile: Locate MemoryProfile protocol - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UefiMemoryProfile: Locate MemoryProfile protocol - %r\n", Status)); - return Status; - } - -@@ -1136,7 +1136,7 @@ GetSmramProfileData ( - - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &SmmCommunication); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmramProfile: Locate SmmCommunication protocol - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SmramProfile: Locate SmmCommunication protocol - %r\n", Status)); - return Status; - } - -@@ -1157,7 +1157,7 @@ GetSmramProfileData ( - (VOID **) &PiSmmCommunicationRegionTable - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmramProfile: Get PiSmmCommunicationRegionTable - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SmramProfile: Get PiSmmCommunicationRegionTable - %r\n", Status)); - return Status; - } - ASSERT (PiSmmCommunicationRegionTable != NULL); -@@ -1193,7 +1193,7 @@ GetSmramProfileData ( - CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength; - Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmramProfile: SmmCommunication - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SmramProfile: SmmCommunication - %r\n", Status)); - return Status; - } - -@@ -1349,12 +1349,12 @@ UefiMain ( - - Status = GetUefiMemoryProfileData (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "GetUefiMemoryProfileData - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "GetUefiMemoryProfileData - %r\n", Status)); - } - - Status = GetSmramProfileData (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "GetSmramProfileData - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "GetSmramProfileData - %r\n", Status)); - } - - return EFI_SUCCESS; -diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c -index bda900a161..aec7d0cfbe 100644 ---- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c -+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c -@@ -1723,7 +1723,7 @@ AhciAtaSmartReturnStatusCheck ( - // - // The threshold exceeded condition is not detected by the device - // -- DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n")); -+ DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n")); - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD) -@@ -1732,7 +1732,7 @@ AhciAtaSmartReturnStatusCheck ( - // - // The threshold exceeded condition is detected by the device - // -- DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n")); -+ DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n")); - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD) -@@ -1775,7 +1775,7 @@ AhciAtaSmartSupport ( - // - // S.M.A.R.T is not supported by the device - // -- DEBUG ((EFI_D_INFO, "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n", -+ DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n", - Port, PortMultiplier)); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -1851,7 +1851,7 @@ AhciAtaSmartSupport ( - AtaStatusBlock - ); - -- DEBUG ((EFI_D_INFO, "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n", -+ DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n", - Port, PortMultiplier)); - } - -@@ -2785,7 +2785,7 @@ AhciModeInitialization ( - NULL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "AhciModeInitialization: failed to enable 64-bit DMA on 64-bit capable controller (%r)\n", - Status)); - } -@@ -2991,7 +2991,7 @@ AhciModeInitialization ( - &SupportedModes - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Calculate Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Calculate Mode Fail, Status = %r\n", Status)); - continue; - } - -@@ -3022,7 +3022,7 @@ AhciModeInitialization ( - - Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, 0, 0x03, (UINT32)(*(UINT8 *)&TransferMode), ATA_ATAPI_TIMEOUT); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); - continue; - } - -@@ -3061,4 +3061,3 @@ AhciModeInitialization ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c -index 86fe9d954f..1c94b5f39d 100644 ---- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c -+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c -@@ -682,7 +682,7 @@ AtaAtapiPassThruStart ( - Instance = NULL; - OriginalPciAttributes = 0; - -- DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Start== Controller = %x\n", Controller)); -+ DEBUG ((DEBUG_INFO, "==AtaAtapiPassThru Start== Controller = %x\n", Controller)); - - Status = gBS->OpenProtocol ( - Controller, -@@ -694,7 +694,7 @@ AtaAtapiPassThruStart ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Open Ide_Controller_Init Error, Status=%r", Status)); -+ DEBUG ((DEBUG_ERROR, "Open Ide_Controller_Init Error, Status=%r", Status)); - goto ErrorExit; - } - -@@ -707,7 +707,7 @@ AtaAtapiPassThruStart ( - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Get Pci_Io Protocol Error, Status=%r", Status)); -+ DEBUG ((DEBUG_ERROR, "Get Pci_Io Protocol Error, Status=%r", Status)); - goto ErrorExit; - } - -@@ -872,7 +872,7 @@ AtaAtapiPassThruStop ( - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_AHCI_REGISTERS *AhciRegisters; - -- DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller)); -+ DEBUG ((DEBUG_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller)); - - Status = gBS->OpenProtocol ( - Controller, -@@ -2646,4 +2646,3 @@ Exit: - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c -index d284cc600b..9a6d0e60e4 100644 ---- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c -+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c -@@ -252,36 +252,36 @@ DumpAllIdeRegisters ( - - DEBUG_CODE_BEGIN (); - if ((StatusBlock.AtaStatus & ATA_STSREG_DWF) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Write Fault\n", StatusBlock.AtaStatus)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Write Fault\n", StatusBlock.AtaStatus)); - } - - if ((StatusBlock.AtaStatus & ATA_STSREG_CORR) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Corrected Data\n", StatusBlock.AtaStatus)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Corrected Data\n", StatusBlock.AtaStatus)); - } - - if ((StatusBlock.AtaStatus & ATA_STSREG_ERR) != 0) { - if ((StatusBlock.AtaError & ATA_ERRREG_BBK) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Bad Block Detected\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Bad Block Detected\n", StatusBlock.AtaError)); - } - - if ((StatusBlock.AtaError & ATA_ERRREG_UNC) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Uncorrectable Data\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Uncorrectable Data\n", StatusBlock.AtaError)); - } - - if ((StatusBlock.AtaError & ATA_ERRREG_MC) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Media Change\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Media Change\n", StatusBlock.AtaError)); - } - - if ((StatusBlock.AtaError & ATA_ERRREG_ABRT) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Abort\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Abort\n", StatusBlock.AtaError)); - } - - if ((StatusBlock.AtaError & ATA_ERRREG_TK0NF) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Track 0 Not Found\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Track 0 Not Found\n", StatusBlock.AtaError)); - } - - if ((StatusBlock.AtaError & ATA_ERRREG_AMNF) != 0) { -- DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Address Mark Not Found\n", StatusBlock.AtaError)); -+ DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Address Mark Not Found\n", StatusBlock.AtaError)); - } - } - DEBUG_CODE_END (); -@@ -1162,7 +1162,7 @@ AtaUdmStatusWait ( - IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET); - RegisterValue = IdeReadPortB (PciIo, IoPortForBmis); - if (((RegisterValue & BMIS_ERROR) != 0) || (Timeout == 0)) { -- DEBUG ((EFI_D_ERROR, "ATA UDMA operation fails\n")); -+ DEBUG ((DEBUG_ERROR, "ATA UDMA operation fails\n")); - Status = EFI_DEVICE_ERROR; - break; - } -@@ -1217,7 +1217,7 @@ AtaUdmStatusCheck ( - RegisterValue = IdeReadPortB (PciIo, IoPortForBmis); - - if ((RegisterValue & BMIS_ERROR) != 0) { -- DEBUG ((EFI_D_ERROR, "ATA UDMA operation fails\n")); -+ DEBUG ((DEBUG_ERROR, "ATA UDMA operation fails\n")); - return EFI_DEVICE_ERROR; - } - -@@ -2077,7 +2077,7 @@ IdeAtaSmartReturnStatusCheck ( - // - // The threshold exceeded condition is not detected by the device - // -- DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n")); -+ DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is not detected\n")); - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD) -@@ -2086,7 +2086,7 @@ IdeAtaSmartReturnStatusCheck ( - // - // The threshold exceeded condition is detected by the device - // -- DEBUG ((EFI_D_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n")); -+ DEBUG ((DEBUG_INFO, "The S.M.A.R.T threshold exceeded condition is detected\n")); - REPORT_STATUS_CODE ( - EFI_PROGRESS_CODE, - (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD) -@@ -2126,7 +2126,7 @@ IdeAtaSmartSupport ( - // - // S.M.A.R.T is not supported by the device - // -- DEBUG ((EFI_D_INFO, "S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n", -+ DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n", - (Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master")); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -2195,7 +2195,7 @@ IdeAtaSmartSupport ( - } - } - -- DEBUG ((EFI_D_INFO, "Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n", -+ DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n", - (Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master")); - - } -@@ -2392,7 +2392,7 @@ DetectAndConfigIdeDevice ( - - Status = WaitForBSYClear (PciIo, IdeRegisters, 350000000); - if (EFI_ERROR (Status)) { -- DEBUG((EFI_D_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status)); -+ DEBUG((DEBUG_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status)); - continue; - } - -@@ -2453,7 +2453,7 @@ DetectAndConfigIdeDevice ( - continue; - } - -- DEBUG ((EFI_D_INFO, "[%a] channel [%a] [%a] device\n", -+ DEBUG ((DEBUG_INFO, "[%a] channel [%a] [%a] device\n", - (IdeChannel == 1) ? "secondary" : "primary ", (IdeDevice == 1) ? "slave " : "master", - DeviceType == EfiIdeCdrom ? "cdrom " : "harddisk")); - // -@@ -2484,7 +2484,7 @@ DetectAndConfigIdeDevice ( - &SupportedModes - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Calculate Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Calculate Mode Fail, Status = %r\n", Status)); - continue; - } - -@@ -2503,7 +2503,7 @@ DetectAndConfigIdeDevice ( - Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); - continue; - } - } -@@ -2520,7 +2520,7 @@ DetectAndConfigIdeDevice ( - Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); - continue; - } - } else if (SupportedModes->MultiWordDmaMode.Valid) { -@@ -2529,7 +2529,7 @@ DetectAndConfigIdeDevice ( - Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Set transfer Mode Fail, Status = %r\n", Status)); - continue; - } - } -@@ -2619,7 +2619,7 @@ IdeModeInitialization ( - &MaxDevices - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[GetChannel, Status=%x]", Status)); -+ DEBUG ((DEBUG_ERROR, "[GetChannel, Status=%x]", Status)); - continue; - } - -@@ -2658,4 +2658,3 @@ IdeModeInitialization ( - ErrorExit: - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c -index 28f8638c52..6c3268896b 100644 ---- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c -+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c -@@ -358,7 +358,7 @@ RegisterAtaDevice ( - // If yes, then install Storage Security Protocol at the ata device handle. - // - if ((AtaDevice->IdentifyData->trusted_computing_support & BIT0) != 0) { -- DEBUG ((EFI_D_INFO, "Found TCG support in Port %x PortMultiplierPort %x\n", Port, PortMultiplierPort)); -+ DEBUG ((DEBUG_INFO, "Found TCG support in Port %x PortMultiplierPort %x\n", Port, PortMultiplierPort)); - Status = gBS->InstallProtocolInterface ( - &AtaDevice->Handle, - &gEfiStorageSecurityCommandProtocolGuid, -@@ -368,7 +368,7 @@ RegisterAtaDevice ( - if (EFI_ERROR (Status)) { - goto Done; - } -- DEBUG ((EFI_D_INFO, "Successfully Install Storage Security Protocol on the ATA device\n")); -+ DEBUG ((DEBUG_INFO, "Successfully Install Storage Security Protocol on the ATA device\n")); - } - - gBS->OpenProtocol ( -@@ -387,7 +387,7 @@ Done: - - if (EFI_ERROR (Status) && (AtaDevice != NULL)) { - ReleaseAtaResources (AtaDevice); -- DEBUG ((EFI_D_ERROR | EFI_D_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status)); -+ DEBUG ((DEBUG_ERROR | DEBUG_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status)); - } - return Status; - } -@@ -1537,7 +1537,7 @@ AtaStorageSecurityReceiveData ( - ATA_DEVICE *Private; - EFI_TPL OldTpl; - -- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Read\n")); -+ DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Read\n")); - if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) { - return EFI_INVALID_PARAMETER; - } -@@ -1647,7 +1647,7 @@ AtaStorageSecuritySendData ( - ATA_DEVICE *Private; - EFI_TPL OldTpl; - -- DEBUG ((EFI_D_INFO, "EFI Storage Security Protocol - Send\n")); -+ DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Send\n")); - if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) { - return EFI_INVALID_PARAMETER; - } -@@ -1709,4 +1709,3 @@ InitializeAtaBus( - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c -index 79026a4a95..8655da599d 100644 ---- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c -+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c -@@ -309,7 +309,7 @@ IdentifyAtaDevice ( - return EFI_UNSUPPORTED; - } - -- DEBUG ((EFI_D_INFO, "AtaBus - Identify Device: Port %x PortMultiplierPort %x\n", AtaDevice->Port, AtaDevice->PortMultiplierPort)); -+ DEBUG ((DEBUG_INFO, "AtaBus - Identify Device: Port %x PortMultiplierPort %x\n", AtaDevice->Port, AtaDevice->PortMultiplierPort)); - - // - // Check whether the WORD 88 (supported UltraDMA by drive) is valid -@@ -674,7 +674,7 @@ AtaNonBlockingCallBack ( - } - - DEBUG (( -- EFI_D_BLKIO, -+ DEBUG_BLKIO, - "NON-BLOCKING EVENT FINISHED!- STATUS = %r\n", - Task->Token->TransactionStatus - )); -@@ -683,7 +683,7 @@ AtaNonBlockingCallBack ( - // Reduce the SubEventCount, till it comes to zero. - // - (*Task->UnsignalledEventCount) --; -- DEBUG ((EFI_D_BLKIO, "UnsignalledEventCount = %d\n", *Task->UnsignalledEventCount)); -+ DEBUG ((DEBUG_BLKIO, "UnsignalledEventCount = %d\n", *Task->UnsignalledEventCount)); - - // - // Remove the SubTask from the Task list. -@@ -696,7 +696,7 @@ AtaNonBlockingCallBack ( - // - if (!(*Task->IsError)) { - gBS->SignalEvent (Task->Token->Event); -- DEBUG ((EFI_D_BLKIO, "Signal the upper layer event!\n")); -+ DEBUG ((DEBUG_BLKIO, "Signal the upper layer event!\n")); - } - - FreePool (Task->UnsignalledEventCount); -@@ -709,8 +709,8 @@ AtaNonBlockingCallBack ( - if (!IsListEmpty (&AtaDevice->AtaTaskList)) { - Entry = GetFirstNode (&AtaDevice->AtaTaskList); - AtaTask = ATA_ASYN_TASK_FROM_ENTRY (Entry); -- DEBUG ((EFI_D_BLKIO, "Start to embark a new Ata Task\n")); -- DEBUG ((EFI_D_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token)); -+ DEBUG ((DEBUG_BLKIO, "Start to embark a new Ata Task\n")); -+ DEBUG ((DEBUG_BLKIO, "AtaTask->NumberOfBlocks = %x; AtaTask->Token=%x\n", AtaTask->NumberOfBlocks, AtaTask->Token)); - Status = AccessAtaDevice ( - AtaTask->AtaDevice, - AtaTask->Buffer, -@@ -729,7 +729,7 @@ AtaNonBlockingCallBack ( - } - - DEBUG (( -- EFI_D_BLKIO, -+ DEBUG_BLKIO, - "PACKET INFO: Write=%s, Length=%x, LowCylinder=%x, HighCylinder=%x, SectionNumber=%x\n", - Task->Packet.OutDataBuffer != NULL ? L"YES" : L"NO", - Task->Packet.OutDataBuffer != NULL ? Task->Packet.OutTransferLength : Task->Packet.InTransferLength, -@@ -838,13 +838,13 @@ AccessAtaDevice( - FreePool (EventCount); - return EFI_OUT_OF_RESOURCES; - } -- DEBUG ((EFI_D_BLKIO, "Allocation IsError Addr=%x\n", IsError)); -+ DEBUG ((DEBUG_BLKIO, "Allocation IsError Addr=%x\n", IsError)); - *IsError = FALSE; - TempCount = (NumberOfBlocks + MaxTransferBlockNumber - 1) / MaxTransferBlockNumber; - *EventCount = TempCount; -- DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks)); -- DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber)); -- DEBUG ((EFI_D_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount)); -+ DEBUG ((DEBUG_BLKIO, "AccessAtaDevice, NumberOfBlocks=%x\n", NumberOfBlocks)); -+ DEBUG ((DEBUG_BLKIO, "AccessAtaDevice, MaxTransferBlockNumber=%x\n", MaxTransferBlockNumber)); -+ DEBUG ((DEBUG_BLKIO, "AccessAtaDevice, EventCount=%x\n", TempCount)); - } else { - while (!IsListEmpty (&AtaDevice->AtaTaskList) || !IsListEmpty (&AtaDevice->AtaSubTaskList)) { - // -@@ -906,7 +906,7 @@ AccessAtaDevice( - // - // Blocking Mode. - // -- DEBUG ((EFI_D_BLKIO, "Blocking AccessAtaDevice, TransferBlockNumber=%x; StartLba = %x\n", TransferBlockNumber, StartLba)); -+ DEBUG ((DEBUG_BLKIO, "Blocking AccessAtaDevice, TransferBlockNumber=%x; StartLba = %x\n", TransferBlockNumber, StartLba)); - Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, NULL); - } - -diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c -index 1833c0afb8..fa58632703 100644 ---- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c -+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c -@@ -312,7 +312,7 @@ CheckRemainingDevicePath ( - ((!SystemHasControllerNode) && (RemainingHasControllerNode) && (RemainingControllerNumber == 0)) || - ((SystemHasControllerNode) && (RemainingHasControllerNode) && (SystemControllerNumber == RemainingControllerNumber)) || - ((!SystemHasControllerNode) && (!RemainingHasControllerNode))) { -- DEBUG ((EFI_D_ERROR, "This I2C device has been already started.\n")); -+ DEBUG ((DEBUG_ERROR, "This I2C device has been already started.\n")); - Status = EFI_UNSUPPORTED; - break; - } -@@ -572,7 +572,7 @@ I2cBusDriverStart ( - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: open I2C host error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: open I2C host error, Status = %r\n", Status)); - return Status; - } - -@@ -586,7 +586,7 @@ I2cBusDriverStart ( - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: open private protocol error, Status = %r.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: open private protocol error, Status = %r.\n", Status)); - return Status; - } - } -@@ -603,7 +603,7 @@ I2cBusDriverStart ( - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: open I2C enumerate error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: open I2C enumerate error, Status = %r\n", Status)); - goto Error; - } - -@@ -616,7 +616,7 @@ I2cBusDriverStart ( - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: open device path error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: open device path error, Status = %r\n", Status)); - goto Error; - } - -@@ -637,7 +637,7 @@ I2cBusDriverStart ( - // - I2cBusContext = AllocateZeroPool (sizeof (I2C_BUS_CONTEXT)); - if (I2cBusContext == NULL) { -- DEBUG ((EFI_D_ERROR, "I2cBus: there is no enough memory to allocate.\n")); -+ DEBUG ((DEBUG_ERROR, "I2cBus: there is no enough memory to allocate.\n")); - Status = EFI_OUT_OF_RESOURCES; - goto Error; - } -@@ -676,7 +676,7 @@ I2cBusDriverStart ( - NULL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: install private protocol error, Status = %r.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: install private protocol error, Status = %r.\n", Status)); - goto Error; - } - } -@@ -690,7 +690,7 @@ I2cBusDriverStart ( - - Error: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cBus: Start() function failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cBus: Start() function failed, Status = %r\n", Status)); - if (ParentDevicePath != NULL) { - gBS->CloseProtocol ( - Controller, -@@ -921,7 +921,7 @@ RegisterI2cDevice ( - // Determine if the device info is valid - // - if ((Device->DeviceGuid == NULL) || (Device->SlaveAddressCount == 0) || (Device->SlaveAddressArray == NULL)) { -- DEBUG ((EFI_D_ERROR, "Invalid EFI_I2C_DEVICE reported by I2c Enumerate protocol.\n")); -+ DEBUG ((DEBUG_ERROR, "Invalid EFI_I2C_DEVICE reported by I2c Enumerate protocol.\n")); - continue; - } - -diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c -index 95294c9c98..8dec43bcb1 100644 ---- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c -+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c -@@ -343,7 +343,7 @@ I2cHostDriverStart ( - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: Open I2C bus configuration error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: Open I2C bus configuration error, Status = %r\n", Status)); - return Status; - } - -@@ -359,7 +359,7 @@ I2cHostDriverStart ( - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: Open I2C master error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: Open I2C master error, Status = %r\n", Status)); - goto Exit; - } - -@@ -368,7 +368,7 @@ I2cHostDriverStart ( - // - I2cHostContext = AllocateZeroPool (sizeof (I2C_HOST_CONTEXT)); - if (I2cHostContext == NULL) { -- DEBUG ((EFI_D_ERROR, "I2cHost: there is no enough memory to allocate.\n")); -+ DEBUG ((DEBUG_ERROR, "I2cHost: there is no enough memory to allocate.\n")); - Status = EFI_OUT_OF_RESOURCES; - goto Exit; - } -@@ -387,7 +387,7 @@ I2cHostDriverStart ( - // - Status = I2cMaster->Reset (I2cMaster); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: I2C controller reset failed!\n")); -+ DEBUG ((DEBUG_ERROR, "I2cHost: I2C controller reset failed!\n")); - goto Exit; - } - -@@ -402,7 +402,7 @@ I2cHostDriverStart ( - &I2cHostContext->I2cEvent - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: create complete event error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: create complete event error, Status = %r\n", Status)); - goto Exit; - } - -@@ -417,7 +417,7 @@ I2cHostDriverStart ( - &I2cHostContext->I2cBusConfigurationEvent - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: create bus available event error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: create bus available event error, Status = %r\n", Status)); - goto Exit; - } - -@@ -438,7 +438,7 @@ I2cHostDriverStart ( - ); - Exit: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "I2cHost: Start() function failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: Start() function failed, Status = %r\n", Status)); - if (I2cBusConfigurationManagement != NULL) { - gBS->CloseProtocol ( - Controller, -@@ -514,7 +514,7 @@ I2cHostDriverStop ( - - TplPrevious = EfiGetCurrentTpl (); - if (TplPrevious > TPL_I2C_SYNC) { -- DEBUG ((EFI_D_ERROR, "I2cHost: TPL %d is too high in Stop.\n", TplPrevious)); -+ DEBUG ((DEBUG_ERROR, "I2cHost: TPL %d is too high in Stop.\n", TplPrevious)); - return EFI_DEVICE_ERROR; - } - -@@ -982,7 +982,7 @@ I2cHostQueueRequest ( - // - TplPrevious = EfiGetCurrentTpl (); - if ((TplPrevious > TPL_I2C_SYNC) || ((Event == NULL) && (TplPrevious > TPL_CALLBACK))) { -- DEBUG ((EFI_D_ERROR, "ERROR - TPL %d is too high!\n", TplPrevious)); -+ DEBUG ((DEBUG_ERROR, "ERROR - TPL %d is too high!\n", TplPrevious)); - return EFI_INVALID_PARAMETER; - } - -@@ -991,7 +991,7 @@ I2cHostQueueRequest ( - // - I2cRequest = AllocateZeroPool (sizeof (I2C_REQUEST)); - if (I2cRequest == NULL) { -- DEBUG ((EFI_D_ERROR, "WARNING - Failed to allocate I2C_REQUEST!\n")); -+ DEBUG ((DEBUG_ERROR, "WARNING - Failed to allocate I2C_REQUEST!\n")); - return EFI_OUT_OF_RESOURCES; - } - -diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c -index bdd9c27db5..0e41ee17ec 100644 ---- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c -+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c -@@ -85,7 +85,7 @@ EhcGetCapability ( - *PortNumber = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); - *Is64BitCapable = (UINT8) Ehc->Support64BitDma; - -- DEBUG ((EFI_D_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable)); -+ DEBUG ((DEBUG_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable)); - - gBS->RestoreTPL (OldTpl); - return EFI_SUCCESS; -@@ -181,7 +181,7 @@ EhcReset ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "EhcReset: exit status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcReset: exit status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - return Status; - } -@@ -225,7 +225,7 @@ EhcGetState ( - - gBS->RestoreTPL (OldTpl); - -- DEBUG ((EFI_D_INFO, "EhcGetState: current state %d\n", *State)); -+ DEBUG ((DEBUG_INFO, "EhcGetState: current state %d\n", *State)); - return EFI_SUCCESS; - } - -@@ -299,7 +299,7 @@ EhcSetState ( - Status = EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_INFO, "EhcSetState: exit status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcSetState: exit status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - return Status; - } -@@ -470,7 +470,7 @@ EhcSetRootHubPortFeature ( - Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature :failed to start HC - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcSetRootHubPortFeature :failed to start HC - %r\n", Status)); - break; - } - } -@@ -503,7 +503,7 @@ EhcSetRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature: exit status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcSetRootHubPortFeature: exit status %r\n", Status)); - - gBS->RestoreTPL (OldTpl); - return Status; -@@ -638,7 +638,7 @@ EhcClearRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "EhcClearRootHubPortFeature: exit status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcClearRootHubPortFeature: exit status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - return Status; - } -@@ -729,7 +729,7 @@ EhcControlTransfer ( - *TransferResult = EFI_USB_ERR_SYSTEM; - - if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { -- DEBUG ((EFI_D_ERROR, "EhcControlTransfer: HC halted at entrance\n")); -+ DEBUG ((DEBUG_ERROR, "EhcControlTransfer: HC halted at entrance\n")); - - EhcAckAllInterrupt (Ehc); - goto ON_EXIT; -@@ -765,7 +765,7 @@ EhcControlTransfer ( - ); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "EhcControlTransfer: failed to create URB")); -+ DEBUG ((DEBUG_ERROR, "EhcControlTransfer: failed to create URB")); - - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; -@@ -794,7 +794,7 @@ ON_EXIT: - gBS->RestoreTPL (OldTpl); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - return Status; -@@ -878,7 +878,7 @@ EhcBulkTransfer ( - Status = EFI_DEVICE_ERROR; - - if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { -- DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: HC is halted\n")); -+ DEBUG ((DEBUG_ERROR, "EhcBulkTransfer: HC is halted\n")); - - EhcAckAllInterrupt (Ehc); - goto ON_EXIT; -@@ -908,7 +908,7 @@ EhcBulkTransfer ( - ); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: failed to create URB\n")); -+ DEBUG ((DEBUG_ERROR, "EhcBulkTransfer: failed to create URB\n")); - - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; -@@ -934,7 +934,7 @@ ON_EXIT: - gBS->RestoreTPL (OldTpl); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - return Status; -@@ -1023,14 +1023,14 @@ EhcAsyncInterruptTransfer ( - if (!IsNewTransfer) { - Status = EhciDelAsyncIntTransfer (Ehc, DeviceAddress, EndPointAddress, DataToggle); - -- DEBUG ((EFI_D_INFO, "EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status)); - goto ON_EXIT; - } - - Status = EFI_SUCCESS; - - if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { -- DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: HC is halt\n")); -+ DEBUG ((DEBUG_ERROR, "EhcAsyncInterruptTransfer: HC is halt\n")); - EhcAckAllInterrupt (Ehc); - - Status = EFI_DEVICE_ERROR; -@@ -1139,7 +1139,7 @@ EhcSyncInterruptTransfer ( - Status = EFI_DEVICE_ERROR; - - if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { -- DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: HC is halt\n")); -+ DEBUG ((DEBUG_ERROR, "EhcSyncInterruptTransfer: HC is halt\n")); - - EhcAckAllInterrupt (Ehc); - goto ON_EXIT; -@@ -1165,7 +1165,7 @@ EhcSyncInterruptTransfer ( - ); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: failed to create URB\n")); -+ DEBUG ((DEBUG_ERROR, "EhcSyncInterruptTransfer: failed to create URB\n")); - - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; -@@ -1189,7 +1189,7 @@ ON_EXIT: - gBS->RestoreTPL (OldTpl); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - return Status; -@@ -1562,7 +1562,7 @@ EhcCreateUsb2Hc ( - Ehc->HcCapParams = EhcReadCapRegister (Ehc, EHC_HCCPARAMS_OFFSET); - Ehc->CapLen = EhcReadCapRegister (Ehc, EHC_CAPLENGTH_OFFSET) & 0x0FF; - -- DEBUG ((EFI_D_INFO, "EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen)); -+ DEBUG ((DEBUG_INFO, "EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen)); - - // - // EHCI Controllers with a CapLen of 0 are ignored. -@@ -1723,7 +1723,7 @@ EhcDriverBindingStart ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to enable controller\n")); -+ DEBUG ((DEBUG_ERROR, "EhcDriverBindingStart: failed to enable controller\n")); - goto CLOSE_PCIIO; - } - -@@ -1834,7 +1834,7 @@ EhcDriverBindingStart ( - Ehc = EhcCreateUsb2Hc (PciIo, HcDevicePath, OriginalPciAttributes); - - if (Ehc == NULL) { -- DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to create USB2_HC\n")); -+ DEBUG ((DEBUG_ERROR, "EhcDriverBindingStart: failed to create USB2_HC\n")); - - Status = EFI_OUT_OF_RESOURCES; - goto CLOSE_PCIIO; -@@ -1854,7 +1854,7 @@ EhcDriverBindingStart ( - if (!EFI_ERROR (Status)) { - Ehc->Support64BitDma = TRUE; - } else { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n", - __FUNCTION__, Controller, Status)); - } -@@ -1868,7 +1868,7 @@ EhcDriverBindingStart ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to install USB2_HC Protocol\n")); -+ DEBUG ((DEBUG_ERROR, "EhcDriverBindingStart: failed to install USB2_HC Protocol\n")); - goto FREE_POOL; - } - -@@ -1887,7 +1887,7 @@ EhcDriverBindingStart ( - Status = EhcInitHC (Ehc); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to init host controller\n")); -+ DEBUG ((DEBUG_ERROR, "EhcDriverBindingStart: failed to init host controller\n")); - goto UNINSTALL_USBHC; - } - -@@ -1897,7 +1897,7 @@ EhcDriverBindingStart ( - Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to start async interrupt monitor\n")); -+ DEBUG ((DEBUG_ERROR, "EhcDriverBindingStart: failed to start async interrupt monitor\n")); - - EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT); - goto UNINSTALL_USBHC; -@@ -1938,7 +1938,7 @@ EhcDriverBindingStart ( - ); - - -- DEBUG ((EFI_D_INFO, "EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller)); -+ DEBUG ((DEBUG_INFO, "EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller)); - return EFI_SUCCESS; - - UNINSTALL_USBHC: -@@ -2083,4 +2083,3 @@ EhcDriverBindingStop ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c -index db0e2c6d39..55cbb68570 100644 ---- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c -+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c -@@ -23,38 +23,38 @@ EhcDumpStatus ( - ) - { - if (EHC_BIT_IS_SET (State, QTD_STAT_DO_PING)) { -- DEBUG ((EFI_D_VERBOSE, " Do_Ping")); -+ DEBUG ((DEBUG_VERBOSE, " Do_Ping")); - } else { -- DEBUG ((EFI_D_VERBOSE, " Do_Out")); -+ DEBUG ((DEBUG_VERBOSE, " Do_Out")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_DO_CS)) { -- DEBUG ((EFI_D_VERBOSE, " Do_CS")); -+ DEBUG ((DEBUG_VERBOSE, " Do_CS")); - } else { -- DEBUG ((EFI_D_VERBOSE, " Do_SS")); -+ DEBUG ((DEBUG_VERBOSE, " Do_SS")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_TRANS_ERR)) { -- DEBUG ((EFI_D_VERBOSE, " Transfer_Error")); -+ DEBUG ((DEBUG_VERBOSE, " Transfer_Error")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_BABBLE_ERR)) { -- DEBUG ((EFI_D_VERBOSE, " Babble_Error")); -+ DEBUG ((DEBUG_VERBOSE, " Babble_Error")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_BUFF_ERR)) { -- DEBUG ((EFI_D_VERBOSE, " Buffer_Error")); -+ DEBUG ((DEBUG_VERBOSE, " Buffer_Error")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) { -- DEBUG ((EFI_D_VERBOSE, " Halted")); -+ DEBUG ((DEBUG_VERBOSE, " Halted")); - } - - if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) { -- DEBUG ((EFI_D_VERBOSE, " Active")); -+ DEBUG ((DEBUG_VERBOSE, " Active")); - } - -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - } - - -@@ -75,37 +75,37 @@ EhcDumpQtd ( - UINTN Index; - - if (Msg != NULL) { -- DEBUG ((EFI_D_VERBOSE, Msg)); -+ DEBUG ((DEBUG_VERBOSE, Msg)); - } - -- DEBUG ((EFI_D_VERBOSE, "Queue TD @ 0x%p, data length %d\n", Qtd, (UINT32)Qtd->DataLen)); -+ DEBUG ((DEBUG_VERBOSE, "Queue TD @ 0x%p, data length %d\n", Qtd, (UINT32)Qtd->DataLen)); - - QtdHw = &Qtd->QtdHw; - -- DEBUG ((EFI_D_VERBOSE, "Next QTD : %x\n", QtdHw->NextQtd)); -- DEBUG ((EFI_D_VERBOSE, "AltNext QTD : %x\n", QtdHw->AltNext)); -- DEBUG ((EFI_D_VERBOSE, "Status : %x\n", QtdHw->Status)); -+ DEBUG ((DEBUG_VERBOSE, "Next QTD : %x\n", QtdHw->NextQtd)); -+ DEBUG ((DEBUG_VERBOSE, "AltNext QTD : %x\n", QtdHw->AltNext)); -+ DEBUG ((DEBUG_VERBOSE, "Status : %x\n", QtdHw->Status)); - EhcDumpStatus (QtdHw->Status); - - if (QtdHw->Pid == QTD_PID_SETUP) { -- DEBUG ((EFI_D_VERBOSE, "PID : Setup\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : Setup\n")); - - } else if (QtdHw->Pid == QTD_PID_INPUT) { -- DEBUG ((EFI_D_VERBOSE, "PID : IN\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : IN\n")); - - } else if (QtdHw->Pid == QTD_PID_OUTPUT) { -- DEBUG ((EFI_D_VERBOSE, "PID : OUT\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : OUT\n")); - - } - -- DEBUG ((EFI_D_VERBOSE, "Error Count : %d\n", QtdHw->ErrCnt)); -- DEBUG ((EFI_D_VERBOSE, "Current Page : %d\n", QtdHw->CurPage)); -- DEBUG ((EFI_D_VERBOSE, "IOC : %d\n", QtdHw->Ioc)); -- DEBUG ((EFI_D_VERBOSE, "Total Bytes : %d\n", QtdHw->TotalBytes)); -- DEBUG ((EFI_D_VERBOSE, "Data Toggle : %d\n", QtdHw->DataToggle)); -+ DEBUG ((DEBUG_VERBOSE, "Error Count : %d\n", QtdHw->ErrCnt)); -+ DEBUG ((DEBUG_VERBOSE, "Current Page : %d\n", QtdHw->CurPage)); -+ DEBUG ((DEBUG_VERBOSE, "IOC : %d\n", QtdHw->Ioc)); -+ DEBUG ((DEBUG_VERBOSE, "Total Bytes : %d\n", QtdHw->TotalBytes)); -+ DEBUG ((DEBUG_VERBOSE, "Data Toggle : %d\n", QtdHw->DataToggle)); - - for (Index = 0; Index < 5; Index++) { -- DEBUG ((EFI_D_VERBOSE, "Page[%d] : 0x%x\n", (UINT32)Index, QtdHw->Page[Index])); -+ DEBUG ((DEBUG_VERBOSE, "Page[%d] : 0x%x\n", (UINT32)Index, QtdHw->Page[Index])); - } - } - -@@ -131,60 +131,60 @@ EhcDumpQh ( - UINTN Index; - - if (Msg != NULL) { -- DEBUG ((EFI_D_VERBOSE, Msg)); -+ DEBUG ((DEBUG_VERBOSE, Msg)); - } - -- DEBUG ((EFI_D_VERBOSE, "Queue head @ 0x%p, interval %ld, next qh %p\n", -+ DEBUG ((DEBUG_VERBOSE, "Queue head @ 0x%p, interval %ld, next qh %p\n", - Qh, (UINT64)Qh->Interval, Qh->NextQh)); - - QhHw = &Qh->QhHw; - -- DEBUG ((EFI_D_VERBOSE, "Hoziontal link: %x\n", QhHw->HorizonLink)); -- DEBUG ((EFI_D_VERBOSE, "Device address: %d\n", QhHw->DeviceAddr)); -- DEBUG ((EFI_D_VERBOSE, "Inactive : %d\n", QhHw->Inactive)); -- DEBUG ((EFI_D_VERBOSE, "EP number : %d\n", QhHw->EpNum)); -- DEBUG ((EFI_D_VERBOSE, "EP speed : %d\n", QhHw->EpSpeed)); -- DEBUG ((EFI_D_VERBOSE, "DT control : %d\n", QhHw->DtCtrl)); -- DEBUG ((EFI_D_VERBOSE, "Reclaim head : %d\n", QhHw->ReclaimHead)); -- DEBUG ((EFI_D_VERBOSE, "Max packet len: %d\n", QhHw->MaxPacketLen)); -- DEBUG ((EFI_D_VERBOSE, "Ctrl EP : %d\n", QhHw->CtrlEp)); -- DEBUG ((EFI_D_VERBOSE, "Nak reload : %d\n", QhHw->NakReload)); -- -- DEBUG ((EFI_D_VERBOSE, "SMask : %x\n", QhHw->SMask)); -- DEBUG ((EFI_D_VERBOSE, "CMask : %x\n", QhHw->CMask)); -- DEBUG ((EFI_D_VERBOSE, "Hub address : %d\n", QhHw->HubAddr)); -- DEBUG ((EFI_D_VERBOSE, "Hub port : %d\n", QhHw->PortNum)); -- DEBUG ((EFI_D_VERBOSE, "Multiplier : %d\n", QhHw->Multiplier)); -- -- DEBUG ((EFI_D_VERBOSE, "Cur QTD : %x\n", QhHw->CurQtd)); -- -- DEBUG ((EFI_D_VERBOSE, "Next QTD : %x\n", QhHw->NextQtd)); -- DEBUG ((EFI_D_VERBOSE, "AltNext QTD : %x\n", QhHw->AltQtd)); -- DEBUG ((EFI_D_VERBOSE, "Status : %x\n", QhHw->Status)); -+ DEBUG ((DEBUG_VERBOSE, "Hoziontal link: %x\n", QhHw->HorizonLink)); -+ DEBUG ((DEBUG_VERBOSE, "Device address: %d\n", QhHw->DeviceAddr)); -+ DEBUG ((DEBUG_VERBOSE, "Inactive : %d\n", QhHw->Inactive)); -+ DEBUG ((DEBUG_VERBOSE, "EP number : %d\n", QhHw->EpNum)); -+ DEBUG ((DEBUG_VERBOSE, "EP speed : %d\n", QhHw->EpSpeed)); -+ DEBUG ((DEBUG_VERBOSE, "DT control : %d\n", QhHw->DtCtrl)); -+ DEBUG ((DEBUG_VERBOSE, "Reclaim head : %d\n", QhHw->ReclaimHead)); -+ DEBUG ((DEBUG_VERBOSE, "Max packet len: %d\n", QhHw->MaxPacketLen)); -+ DEBUG ((DEBUG_VERBOSE, "Ctrl EP : %d\n", QhHw->CtrlEp)); -+ DEBUG ((DEBUG_VERBOSE, "Nak reload : %d\n", QhHw->NakReload)); -+ -+ DEBUG ((DEBUG_VERBOSE, "SMask : %x\n", QhHw->SMask)); -+ DEBUG ((DEBUG_VERBOSE, "CMask : %x\n", QhHw->CMask)); -+ DEBUG ((DEBUG_VERBOSE, "Hub address : %d\n", QhHw->HubAddr)); -+ DEBUG ((DEBUG_VERBOSE, "Hub port : %d\n", QhHw->PortNum)); -+ DEBUG ((DEBUG_VERBOSE, "Multiplier : %d\n", QhHw->Multiplier)); -+ -+ DEBUG ((DEBUG_VERBOSE, "Cur QTD : %x\n", QhHw->CurQtd)); -+ -+ DEBUG ((DEBUG_VERBOSE, "Next QTD : %x\n", QhHw->NextQtd)); -+ DEBUG ((DEBUG_VERBOSE, "AltNext QTD : %x\n", QhHw->AltQtd)); -+ DEBUG ((DEBUG_VERBOSE, "Status : %x\n", QhHw->Status)); - - EhcDumpStatus (QhHw->Status); - - if (QhHw->Pid == QTD_PID_SETUP) { -- DEBUG ((EFI_D_VERBOSE, "PID : Setup\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : Setup\n")); - - } else if (QhHw->Pid == QTD_PID_INPUT) { -- DEBUG ((EFI_D_VERBOSE, "PID : IN\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : IN\n")); - - } else if (QhHw->Pid == QTD_PID_OUTPUT) { -- DEBUG ((EFI_D_VERBOSE, "PID : OUT\n")); -+ DEBUG ((DEBUG_VERBOSE, "PID : OUT\n")); - } - -- DEBUG ((EFI_D_VERBOSE, "Error Count : %d\n", QhHw->ErrCnt)); -- DEBUG ((EFI_D_VERBOSE, "Current Page : %d\n", QhHw->CurPage)); -- DEBUG ((EFI_D_VERBOSE, "IOC : %d\n", QhHw->Ioc)); -- DEBUG ((EFI_D_VERBOSE, "Total Bytes : %d\n", QhHw->TotalBytes)); -- DEBUG ((EFI_D_VERBOSE, "Data Toggle : %d\n", QhHw->DataToggle)); -+ DEBUG ((DEBUG_VERBOSE, "Error Count : %d\n", QhHw->ErrCnt)); -+ DEBUG ((DEBUG_VERBOSE, "Current Page : %d\n", QhHw->CurPage)); -+ DEBUG ((DEBUG_VERBOSE, "IOC : %d\n", QhHw->Ioc)); -+ DEBUG ((DEBUG_VERBOSE, "Total Bytes : %d\n", QhHw->TotalBytes)); -+ DEBUG ((DEBUG_VERBOSE, "Data Toggle : %d\n", QhHw->DataToggle)); - - for (Index = 0; Index < 5; Index++) { -- DEBUG ((EFI_D_VERBOSE, "Page[%d] : 0x%x\n", Index, QhHw->Page[Index])); -+ DEBUG ((DEBUG_VERBOSE, "Page[%d] : 0x%x\n", Index, QhHw->Page[Index])); - } - -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - - BASE_LIST_FOR_EACH (Entry, &Qh->Qtds) { - Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList); -@@ -214,13 +214,11 @@ EhcDumpBuf ( - - for (Index = 0; Index < Len; Index++) { - if (Index % 16 == 0) { -- DEBUG ((EFI_D_VERBOSE,"\n")); -+ DEBUG ((DEBUG_VERBOSE,"\n")); - } - -- DEBUG ((EFI_D_VERBOSE, "%02x ", Buf[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", Buf[Index])); - } - -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - } -- -- -diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c -index ca63736f20..7bd01c1aee 100644 ---- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c -+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c -@@ -40,7 +40,7 @@ EhcReadCapRegister ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcReadCapRegister: Pci Io read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "EhcReadCapRegister: Pci Io read error - %r at %d\n", Status, Offset)); - Data = 0xFFFF; - } - -@@ -76,7 +76,7 @@ EhcReadDbgRegister ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcReadDbgRegister: Pci Io read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "EhcReadDbgRegister: Pci Io read error - %r at %d\n", Status, Offset)); - Data = 0xFFFF; - } - -@@ -168,7 +168,7 @@ EhcReadOpReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "EhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset)); - Data = 0xFFFF; - } - -@@ -205,7 +205,7 @@ EhcWriteOpReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "EhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); - } - } - -@@ -310,7 +310,7 @@ EhcClearLegacySupport ( - UINT32 Value; - UINT32 TimeOut; - -- DEBUG ((EFI_D_INFO, "EhcClearLegacySupport: called to clear legacy support\n")); -+ DEBUG ((DEBUG_INFO, "EhcClearLegacySupport: called to clear legacy support\n")); - - PciIo = Ehc->PciIo; - ExtendCap = (Ehc->HcCapParams >> 8) & 0xFF; -@@ -654,14 +654,14 @@ EhcInitHC ( - Status = EhcEnablePeriodSchd (Ehc, EHC_GENERIC_TIMEOUT); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcInitHC: failed to enable period schedule\n")); -+ DEBUG ((DEBUG_ERROR, "EhcInitHC: failed to enable period schedule\n")); - return Status; - } - - Status = EhcEnableAsyncSchd (Ehc, EHC_GENERIC_TIMEOUT); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcInitHC: failed to enable async schedule\n")); -+ DEBUG ((DEBUG_ERROR, "EhcInitHC: failed to enable async schedule\n")); - return Status; - } - -diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c -index 5fe7cf4669..34ee40c4bb 100644 ---- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c -+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c -@@ -377,7 +377,7 @@ EhcUnlinkQhFromAsync ( - Status = EhcSetAndWaitDoorBell (Ehc, EHC_GENERIC_TIMEOUT); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcUnlinkQhFromAsync: Failed to synchronize with doorbell\n")); -+ DEBUG ((DEBUG_ERROR, "EhcUnlinkQhFromAsync: Failed to synchronize with doorbell\n")); - } - } - -@@ -636,13 +636,13 @@ EhcCheckUrbResult ( - // - PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Ehc->ShortReadStop, sizeof (EHC_QTD)); - if (QtdHw->AltNext == QTD_LINK (PciAddr, FALSE)) { -- DEBUG ((EFI_D_VERBOSE, "EhcCheckUrbResult: Short packet read, break\n")); -+ DEBUG ((DEBUG_VERBOSE, "EhcCheckUrbResult: Short packet read, break\n")); - - Finished = TRUE; - goto ON_EXIT; - } - -- DEBUG ((EFI_D_VERBOSE, "EhcCheckUrbResult: Short packet read, continue\n")); -+ DEBUG ((DEBUG_VERBOSE, "EhcCheckUrbResult: Short packet read, continue\n")); - } - } - } -@@ -713,13 +713,13 @@ EhcExecTransfer ( - } - - if (!Finished) { -- DEBUG ((EFI_D_ERROR, "EhcExecTransfer: transfer not finished in %dms\n", (UINT32)TimeOut)); -+ DEBUG ((DEBUG_ERROR, "EhcExecTransfer: transfer not finished in %dms\n", (UINT32)TimeOut)); - EhcDumpQh (Urb->Qh, NULL, FALSE); - - Status = EFI_TIMEOUT; - - } else if (Urb->Result != EFI_USB_NOERROR) { -- DEBUG ((EFI_D_ERROR, "EhcExecTransfer: transfer failed with %x\n", Urb->Result)); -+ DEBUG ((DEBUG_ERROR, "EhcExecTransfer: transfer failed with %x\n", Urb->Result)); - EhcDumpQh (Urb->Qh, NULL, FALSE); - - Status = EFI_DEVICE_ERROR; -@@ -1069,7 +1069,7 @@ EhcMonitorAsyncRequests ( - // - Status = EhcFlushAsyncIntMap (Ehc, Urb); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EhcMonitorAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n")); -+ DEBUG ((DEBUG_ERROR, "EhcMonitorAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n")); - } - - // -diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c -index 43d0968dca..f39d0b57c0 100644 ---- a/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c -+++ b/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c -@@ -470,7 +470,7 @@ UsbHcAllocateMem ( - NewBlock = UsbHcAllocMemBlock (Pool, Pages); - - if (NewBlock == NULL) { -- DEBUG ((EFI_D_ERROR, "UsbHcAllocateMem: failed to allocate block\n")); -+ DEBUG ((DEBUG_ERROR, "UsbHcAllocateMem: failed to allocate block\n")); - return NULL; - } - -diff --git a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c b/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c -index 2f888424d9..436d5971d0 100644 ---- a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c -+++ b/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c -@@ -76,7 +76,7 @@ AtapiPeimEntry ( - AtapiBlkIoDev->PpiDescriptor2.Guid = &gEfiPeiVirtualBlockIo2PpiGuid; - AtapiBlkIoDev->PpiDescriptor2.Ppi = &AtapiBlkIoDev->AtapiBlkIo2; - -- DEBUG ((EFI_D_INFO, "Atatpi Device Count is %d\n", AtapiBlkIoDev->DeviceCount)); -+ DEBUG ((DEBUG_INFO, "Atatpi Device Count is %d\n", AtapiBlkIoDev->DeviceCount)); - if (AtapiBlkIoDev->DeviceCount != 0) { - Status = PeiServicesInstallPpi (&AtapiBlkIoDev->PpiDescriptor); - if (EFI_ERROR (Status)) { -@@ -189,11 +189,11 @@ AtapiGetBlockDeviceMediaInfo ( - // - // probe media and retrieve latest media information - // -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo DevicePosition is %d\n", AtapiBlkIoDev->DeviceInfo[Index].DevicePosition)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo DeviceType is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.DeviceType)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo MediaPresent is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.MediaPresent)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo BlockSize is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.BlockSize)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo LastBlock is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.LastBlock)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo DevicePosition is %d\n", AtapiBlkIoDev->DeviceInfo[Index].DevicePosition)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo DeviceType is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.DeviceType)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo MediaPresent is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.MediaPresent)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo BlockSize is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.BlockSize)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo LastBlock is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.LastBlock)); - - Status = DetectMedia ( - AtapiBlkIoDev, -@@ -205,11 +205,11 @@ AtapiGetBlockDeviceMediaInfo ( - return EFI_DEVICE_ERROR; - } - -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo DevicePosition is %d\n", AtapiBlkIoDev->DeviceInfo[Index].DevicePosition)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo DeviceType is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.DeviceType)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo MediaPresent is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.MediaPresent)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo BlockSize is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.BlockSize)); -- DEBUG ((EFI_D_INFO, "Atatpi GetInfo LastBlock is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.LastBlock)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo DevicePosition is %d\n", AtapiBlkIoDev->DeviceInfo[Index].DevicePosition)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo DeviceType is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.DeviceType)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo MediaPresent is %d\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.MediaPresent)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo BlockSize is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.BlockSize)); -+ DEBUG ((DEBUG_INFO, "Atatpi GetInfo LastBlock is 0x%x\n", AtapiBlkIoDev->DeviceInfo[Index].MediaInfo.LastBlock)); - - // - // Get media info from AtapiBlkIoDev -@@ -549,7 +549,7 @@ AtapiEnumerateDevices ( - // Allow SATA Devices to spin-up. This is needed if - // SEC and PEI phase is too short, for example Release Build. - // -- DEBUG ((EFI_D_INFO, "Delay for %d seconds for SATA devices to spin-up\n", PcdGet16 (PcdSataSpinUpDelayInSecForRecoveryPath))); -+ DEBUG ((DEBUG_INFO, "Delay for %d seconds for SATA devices to spin-up\n", PcdGet16 (PcdSataSpinUpDelayInSecForRecoveryPath))); - MicroSecondDelay (PcdGet16 (PcdSataSpinUpDelayInSecForRecoveryPath) * 1000 * 1000); // - - // -@@ -600,10 +600,10 @@ AtapiEnumerateDevices ( - CopyMem (&(AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo), &MediaInfo, sizeof (MediaInfo)); - CopyMem (&(AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2), &MediaInfo2, sizeof (MediaInfo2)); - -- DEBUG ((EFI_D_INFO, "Atatpi Device Position is %d\n", DevicePosition)); -- DEBUG ((EFI_D_INFO, "Atatpi DeviceType is %d\n", MediaInfo.DeviceType)); -- DEBUG ((EFI_D_INFO, "Atatpi MediaPresent is %d\n", MediaInfo.MediaPresent)); -- DEBUG ((EFI_D_INFO, "Atatpi BlockSize is 0x%x\n", MediaInfo.BlockSize)); -+ DEBUG ((DEBUG_INFO, "Atatpi Device Position is %d\n", DevicePosition)); -+ DEBUG ((DEBUG_INFO, "Atatpi DeviceType is %d\n", MediaInfo.DeviceType)); -+ DEBUG ((DEBUG_INFO, "Atatpi MediaPresent is %d\n", MediaInfo.MediaPresent)); -+ DEBUG ((DEBUG_INFO, "Atatpi BlockSize is 0x%x\n", MediaInfo.BlockSize)); - - if (EFI_ERROR (Status)) { - AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo.MediaPresent = FALSE; -@@ -1764,7 +1764,7 @@ DetectMedia ( - SenseBuffers, - &SenseCounts - ); -- DEBUG ((EFI_D_INFO, "Atapi Request Sense Count is %d\n", SenseCounts)); -+ DEBUG ((DEBUG_INFO, "Atapi Request Sense Count is %d\n", SenseCounts)); - if (IsDeviceStateUnclear (SenseBuffers, SenseCounts) || IsNoMedia (SenseBuffers, SenseCounts)) { - // - // We are not sure whether the media is present or not, try again -diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c -index 62886d5c91..f60c2fcd79 100644 ---- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c -+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c -@@ -271,11 +271,11 @@ EnumerateNvmeDevNamespace ( - // - // Dump NvmExpress Identify Namespace Data - // -- DEBUG ((EFI_D_INFO, " == NVME IDENTIFY NAMESPACE [%d] DATA ==\n", NamespaceId)); -- DEBUG ((EFI_D_INFO, " NSZE : 0x%x\n", NamespaceData->Nsze)); -- DEBUG ((EFI_D_INFO, " NCAP : 0x%x\n", NamespaceData->Ncap)); -- DEBUG ((EFI_D_INFO, " NUSE : 0x%x\n", NamespaceData->Nuse)); -- DEBUG ((EFI_D_INFO, " LBAF0.LBADS : 0x%x\n", (NamespaceData->LbaFormat[0].Lbads))); -+ DEBUG ((DEBUG_INFO, " == NVME IDENTIFY NAMESPACE [%d] DATA ==\n", NamespaceId)); -+ DEBUG ((DEBUG_INFO, " NSZE : 0x%x\n", NamespaceData->Nsze)); -+ DEBUG ((DEBUG_INFO, " NCAP : 0x%x\n", NamespaceData->Ncap)); -+ DEBUG ((DEBUG_INFO, " NUSE : 0x%x\n", NamespaceData->Nuse)); -+ DEBUG ((DEBUG_INFO, " LBAF0.LBADS : 0x%x\n", (NamespaceData->LbaFormat[0].Lbads))); - - // - // Build controller name for Component Name (2) protocol. -@@ -906,7 +906,7 @@ NvmExpressDriverBindingStart ( - UINTN Bytes; - EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *Passthru; - -- DEBUG ((EFI_D_INFO, "NvmExpressDriverBindingStart: start\n")); -+ DEBUG ((DEBUG_INFO, "NvmExpressDriverBindingStart: start\n")); - - Private = NULL; - Passthru = NULL; -@@ -944,7 +944,7 @@ NvmExpressDriverBindingStart ( - Private = AllocateZeroPool (sizeof (NVME_CONTROLLER_PRIVATE_DATA)); - - if (Private == NULL) { -- DEBUG ((EFI_D_ERROR, "NvmExpressDriverBindingStart: allocating pool for Nvme Private Data failed!\n")); -+ DEBUG ((DEBUG_ERROR, "NvmExpressDriverBindingStart: allocating pool for Nvme Private Data failed!\n")); - Status = EFI_OUT_OF_RESOURCES; - goto Exit; - } -@@ -1084,7 +1084,7 @@ NvmExpressDriverBindingStart ( - } - } - -- DEBUG ((EFI_D_INFO, "NvmExpressDriverBindingStart: end successfully\n")); -+ DEBUG ((DEBUG_INFO, "NvmExpressDriverBindingStart: end successfully\n")); - return EFI_SUCCESS; - - Exit: -@@ -1122,7 +1122,7 @@ Exit: - Controller - ); - -- DEBUG ((EFI_D_INFO, "NvmExpressDriverBindingStart: end with %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "NvmExpressDriverBindingStart: end with %r\n", Status)); - - return Status; - } -diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c -index 450d372b2f..08f9d50ff5 100644 ---- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c -+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c -@@ -128,13 +128,13 @@ WriteNvmeControllerConfiguration ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Cc.En: %d\n", Cc->En)); -- DEBUG ((EFI_D_INFO, "Cc.Css: %d\n", Cc->Css)); -- DEBUG ((EFI_D_INFO, "Cc.Mps: %d\n", Cc->Mps)); -- DEBUG ((EFI_D_INFO, "Cc.Ams: %d\n", Cc->Ams)); -- DEBUG ((EFI_D_INFO, "Cc.Shn: %d\n", Cc->Shn)); -- DEBUG ((EFI_D_INFO, "Cc.Iosqes: %d\n", Cc->Iosqes)); -- DEBUG ((EFI_D_INFO, "Cc.Iocqes: %d\n", Cc->Iocqes)); -+ DEBUG ((DEBUG_INFO, "Cc.En: %d\n", Cc->En)); -+ DEBUG ((DEBUG_INFO, "Cc.Css: %d\n", Cc->Css)); -+ DEBUG ((DEBUG_INFO, "Cc.Mps: %d\n", Cc->Mps)); -+ DEBUG ((DEBUG_INFO, "Cc.Ams: %d\n", Cc->Ams)); -+ DEBUG ((DEBUG_INFO, "Cc.Shn: %d\n", Cc->Shn)); -+ DEBUG ((DEBUG_INFO, "Cc.Iosqes: %d\n", Cc->Iosqes)); -+ DEBUG ((DEBUG_INFO, "Cc.Iocqes: %d\n", Cc->Iocqes)); - - return EFI_SUCCESS; - } -@@ -214,8 +214,8 @@ WriteNvmeAdminQueueAttributes ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Aqa.Asqs: %d\n", Aqa->Asqs)); -- DEBUG ((EFI_D_INFO, "Aqa.Acqs: %d\n", Aqa->Acqs)); -+ DEBUG ((DEBUG_INFO, "Aqa.Asqs: %d\n", Aqa->Asqs)); -+ DEBUG ((DEBUG_INFO, "Aqa.Acqs: %d\n", Aqa->Acqs)); - - return EFI_SUCCESS; - } -@@ -257,7 +257,7 @@ WriteNvmeAdminSubmissionQueueBaseAddress ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Asq: %lx\n", *Asq)); -+ DEBUG ((DEBUG_INFO, "Asq: %lx\n", *Asq)); - - return EFI_SUCCESS; - } -@@ -300,7 +300,7 @@ WriteNvmeAdminCompletionQueueBaseAddress ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Acq: %lxh\n", *Acq)); -+ DEBUG ((DEBUG_INFO, "Acq: %lxh\n", *Acq)); - - return EFI_SUCCESS; - } -@@ -379,7 +379,7 @@ NvmeDisableController ( - ); - } - -- DEBUG ((EFI_D_INFO, "NVMe controller is disabled with status [%r].\n", Status)); -+ DEBUG ((DEBUG_INFO, "NVMe controller is disabled with status [%r].\n", Status)); - return Status; - } - -@@ -453,7 +453,7 @@ NvmeEnableController ( - ); - } - -- DEBUG ((EFI_D_INFO, "NVMe controller is enabled with status [%r].\n", Status)); -+ DEBUG ((DEBUG_INFO, "NVMe controller is enabled with status [%r].\n", Status)); - return Status; - } - -@@ -764,7 +764,7 @@ NvmeControllerInit ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "NvmeControllerInit: failed to enable controller\n")); -+ DEBUG ((DEBUG_INFO, "NvmeControllerInit: failed to enable controller\n")); - return Status; - } - -@@ -778,7 +778,7 @@ NvmeControllerInit ( - NULL - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_WARN, "NvmeControllerInit: failed to enable 64-bit DMA (%r)\n", Status)); -+ DEBUG ((DEBUG_WARN, "NvmeControllerInit: failed to enable 64-bit DMA (%r)\n", Status)); - } - - // -@@ -790,7 +790,7 @@ NvmeControllerInit ( - } - - if (Private->Cap.Css != 0x01) { -- DEBUG ((EFI_D_INFO, "NvmeControllerInit: the controller doesn't support NVMe command set\n")); -+ DEBUG ((DEBUG_INFO, "NvmeControllerInit: the controller doesn't support NVMe command set\n")); - return EFI_UNSUPPORTED; - } - -@@ -854,15 +854,15 @@ NvmeControllerInit ( - Private->CqBuffer[2] = (NVME_CQ *)(UINTN)(Private->Buffer + 5 * EFI_PAGE_SIZE); - Private->CqBufferPciAddr[2] = (NVME_CQ *)(UINTN)(Private->BufferPciAddr + 5 * EFI_PAGE_SIZE); - -- DEBUG ((EFI_D_INFO, "Private->Buffer = [%016X]\n", (UINT64)(UINTN)Private->Buffer)); -- DEBUG ((EFI_D_INFO, "Admin Submission Queue size (Aqa.Asqs) = [%08X]\n", Aqa.Asqs)); -- DEBUG ((EFI_D_INFO, "Admin Completion Queue size (Aqa.Acqs) = [%08X]\n", Aqa.Acqs)); -- DEBUG ((EFI_D_INFO, "Admin Submission Queue (SqBuffer[0]) = [%016X]\n", Private->SqBuffer[0])); -- DEBUG ((EFI_D_INFO, "Admin Completion Queue (CqBuffer[0]) = [%016X]\n", Private->CqBuffer[0])); -- DEBUG ((EFI_D_INFO, "Sync I/O Submission Queue (SqBuffer[1]) = [%016X]\n", Private->SqBuffer[1])); -- DEBUG ((EFI_D_INFO, "Sync I/O Completion Queue (CqBuffer[1]) = [%016X]\n", Private->CqBuffer[1])); -- DEBUG ((EFI_D_INFO, "Async I/O Submission Queue (SqBuffer[2]) = [%016X]\n", Private->SqBuffer[2])); -- DEBUG ((EFI_D_INFO, "Async I/O Completion Queue (CqBuffer[2]) = [%016X]\n", Private->CqBuffer[2])); -+ DEBUG ((DEBUG_INFO, "Private->Buffer = [%016X]\n", (UINT64)(UINTN)Private->Buffer)); -+ DEBUG ((DEBUG_INFO, "Admin Submission Queue size (Aqa.Asqs) = [%08X]\n", Aqa.Asqs)); -+ DEBUG ((DEBUG_INFO, "Admin Completion Queue size (Aqa.Acqs) = [%08X]\n", Aqa.Acqs)); -+ DEBUG ((DEBUG_INFO, "Admin Submission Queue (SqBuffer[0]) = [%016X]\n", Private->SqBuffer[0])); -+ DEBUG ((DEBUG_INFO, "Admin Completion Queue (CqBuffer[0]) = [%016X]\n", Private->CqBuffer[0])); -+ DEBUG ((DEBUG_INFO, "Sync I/O Submission Queue (SqBuffer[1]) = [%016X]\n", Private->SqBuffer[1])); -+ DEBUG ((DEBUG_INFO, "Sync I/O Completion Queue (CqBuffer[1]) = [%016X]\n", Private->CqBuffer[1])); -+ DEBUG ((DEBUG_INFO, "Async I/O Submission Queue (SqBuffer[2]) = [%016X]\n", Private->SqBuffer[2])); -+ DEBUG ((DEBUG_INFO, "Async I/O Completion Queue (CqBuffer[2]) = [%016X]\n", Private->CqBuffer[2])); - - // - // Program admin queue attributes. -@@ -925,20 +925,20 @@ NvmeControllerInit ( - Sn[20] = 0; - CopyMem (Mn, Private->ControllerData->Mn, sizeof (Private->ControllerData->Mn)); - Mn[40] = 0; -- DEBUG ((EFI_D_INFO, " == NVME IDENTIFY CONTROLLER DATA ==\n")); -- DEBUG ((EFI_D_INFO, " PCI VID : 0x%x\n", Private->ControllerData->Vid)); -- DEBUG ((EFI_D_INFO, " PCI SSVID : 0x%x\n", Private->ControllerData->Ssvid)); -- DEBUG ((EFI_D_INFO, " SN : %a\n", Sn)); -- DEBUG ((EFI_D_INFO, " MN : %a\n", Mn)); -- DEBUG ((EFI_D_INFO, " FR : 0x%x\n", *((UINT64*)Private->ControllerData->Fr))); -+ DEBUG ((DEBUG_INFO, " == NVME IDENTIFY CONTROLLER DATA ==\n")); -+ DEBUG ((DEBUG_INFO, " PCI VID : 0x%x\n", Private->ControllerData->Vid)); -+ DEBUG ((DEBUG_INFO, " PCI SSVID : 0x%x\n", Private->ControllerData->Ssvid)); -+ DEBUG ((DEBUG_INFO, " SN : %a\n", Sn)); -+ DEBUG ((DEBUG_INFO, " MN : %a\n", Mn)); -+ DEBUG ((DEBUG_INFO, " FR : 0x%x\n", *((UINT64*)Private->ControllerData->Fr))); - DEBUG ((DEBUG_INFO, " TNVMCAP (high 8-byte) : 0x%lx\n", *((UINT64*)(Private->ControllerData->Tnvmcap + 8)))); - DEBUG ((DEBUG_INFO, " TNVMCAP (low 8-byte) : 0x%lx\n", *((UINT64*)Private->ControllerData->Tnvmcap))); -- DEBUG ((EFI_D_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab)); -- DEBUG ((EFI_D_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oui)); -- DEBUG ((EFI_D_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl)); -- DEBUG ((EFI_D_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes)); -- DEBUG ((EFI_D_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes)); -- DEBUG ((EFI_D_INFO, " NN : 0x%x\n", Private->ControllerData->Nn)); -+ DEBUG ((DEBUG_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab)); -+ DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oui)); -+ DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl)); -+ DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes)); -+ DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes)); -+ DEBUG ((DEBUG_INFO, " NN : 0x%x\n", Private->ControllerData->Nn)); - - // - // Create two I/O completion queues. -diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c -index e9357b1239..a46a098258 100644 ---- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c -+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c -@@ -21,80 +21,80 @@ NvmeDumpStatus ( - IN NVME_CQ *Cq - ) - { -- DEBUG ((EFI_D_VERBOSE, "Dump NVMe Completion Entry Status from [0x%x]:\n", Cq)); -+ DEBUG ((DEBUG_VERBOSE, "Dump NVMe Completion Entry Status from [0x%x]:\n", Cq)); - -- DEBUG ((EFI_D_VERBOSE, " SQ Identifier : [0x%x], Phase Tag : [%d], Cmd Identifier : [0x%x]\n", Cq->Sqid, Cq->Pt, Cq->Cid)); -+ DEBUG ((DEBUG_VERBOSE, " SQ Identifier : [0x%x], Phase Tag : [%d], Cmd Identifier : [0x%x]\n", Cq->Sqid, Cq->Pt, Cq->Cid)); - -- DEBUG ((EFI_D_VERBOSE, " NVMe Cmd Execution Result - ")); -+ DEBUG ((DEBUG_VERBOSE, " NVMe Cmd Execution Result - ")); - - switch (Cq->Sct) { - case 0x0: - switch (Cq->Sc) { - case 0x0: -- DEBUG ((EFI_D_VERBOSE, "Successful Completion\n")); -+ DEBUG ((DEBUG_VERBOSE, "Successful Completion\n")); - break; - case 0x1: -- DEBUG ((EFI_D_VERBOSE, "Invalid Command Opcode\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Command Opcode\n")); - break; - case 0x2: -- DEBUG ((EFI_D_VERBOSE, "Invalid Field in Command\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Field in Command\n")); - break; - case 0x3: -- DEBUG ((EFI_D_VERBOSE, "Command ID Conflict\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command ID Conflict\n")); - break; - case 0x4: -- DEBUG ((EFI_D_VERBOSE, "Data Transfer Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "Data Transfer Error\n")); - break; - case 0x5: -- DEBUG ((EFI_D_VERBOSE, "Commands Aborted due to Power Loss Notification\n")); -+ DEBUG ((DEBUG_VERBOSE, "Commands Aborted due to Power Loss Notification\n")); - break; - case 0x6: -- DEBUG ((EFI_D_VERBOSE, "Internal Device Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "Internal Device Error\n")); - break; - case 0x7: -- DEBUG ((EFI_D_VERBOSE, "Command Abort Requested\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command Abort Requested\n")); - break; - case 0x8: -- DEBUG ((EFI_D_VERBOSE, "Command Aborted due to SQ Deletion\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command Aborted due to SQ Deletion\n")); - break; - case 0x9: -- DEBUG ((EFI_D_VERBOSE, "Command Aborted due to Failed Fused Command\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command Aborted due to Failed Fused Command\n")); - break; - case 0xA: -- DEBUG ((EFI_D_VERBOSE, "Command Aborted due to Missing Fused Command\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command Aborted due to Missing Fused Command\n")); - break; - case 0xB: -- DEBUG ((EFI_D_VERBOSE, "Invalid Namespace or Format\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Namespace or Format\n")); - break; - case 0xC: -- DEBUG ((EFI_D_VERBOSE, "Command Sequence Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "Command Sequence Error\n")); - break; - case 0xD: -- DEBUG ((EFI_D_VERBOSE, "Invalid SGL Last Segment Descriptor\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid SGL Last Segment Descriptor\n")); - break; - case 0xE: -- DEBUG ((EFI_D_VERBOSE, "Invalid Number of SGL Descriptors\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Number of SGL Descriptors\n")); - break; - case 0xF: -- DEBUG ((EFI_D_VERBOSE, "Data SGL Length Invalid\n")); -+ DEBUG ((DEBUG_VERBOSE, "Data SGL Length Invalid\n")); - break; - case 0x10: -- DEBUG ((EFI_D_VERBOSE, "Metadata SGL Length Invalid\n")); -+ DEBUG ((DEBUG_VERBOSE, "Metadata SGL Length Invalid\n")); - break; - case 0x11: -- DEBUG ((EFI_D_VERBOSE, "SGL Descriptor Type Invalid\n")); -+ DEBUG ((DEBUG_VERBOSE, "SGL Descriptor Type Invalid\n")); - break; - case 0x80: -- DEBUG ((EFI_D_VERBOSE, "LBA Out of Range\n")); -+ DEBUG ((DEBUG_VERBOSE, "LBA Out of Range\n")); - break; - case 0x81: -- DEBUG ((EFI_D_VERBOSE, "Capacity Exceeded\n")); -+ DEBUG ((DEBUG_VERBOSE, "Capacity Exceeded\n")); - break; - case 0x82: -- DEBUG ((EFI_D_VERBOSE, "Namespace Not Ready\n")); -+ DEBUG ((DEBUG_VERBOSE, "Namespace Not Ready\n")); - break; - case 0x83: -- DEBUG ((EFI_D_VERBOSE, "Reservation Conflict\n")); -+ DEBUG ((DEBUG_VERBOSE, "Reservation Conflict\n")); - break; - } - break; -@@ -102,61 +102,61 @@ NvmeDumpStatus ( - case 0x1: - switch (Cq->Sc) { - case 0x0: -- DEBUG ((EFI_D_VERBOSE, "Completion Queue Invalid\n")); -+ DEBUG ((DEBUG_VERBOSE, "Completion Queue Invalid\n")); - break; - case 0x1: -- DEBUG ((EFI_D_VERBOSE, "Invalid Queue Identifier\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Queue Identifier\n")); - break; - case 0x2: -- DEBUG ((EFI_D_VERBOSE, "Maximum Queue Size Exceeded\n")); -+ DEBUG ((DEBUG_VERBOSE, "Maximum Queue Size Exceeded\n")); - break; - case 0x3: -- DEBUG ((EFI_D_VERBOSE, "Abort Command Limit Exceeded\n")); -+ DEBUG ((DEBUG_VERBOSE, "Abort Command Limit Exceeded\n")); - break; - case 0x5: -- DEBUG ((EFI_D_VERBOSE, "Asynchronous Event Request Limit Exceeded\n")); -+ DEBUG ((DEBUG_VERBOSE, "Asynchronous Event Request Limit Exceeded\n")); - break; - case 0x6: -- DEBUG ((EFI_D_VERBOSE, "Invalid Firmware Slot\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Firmware Slot\n")); - break; - case 0x7: -- DEBUG ((EFI_D_VERBOSE, "Invalid Firmware Image\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Firmware Image\n")); - break; - case 0x8: -- DEBUG ((EFI_D_VERBOSE, "Invalid Interrupt Vector\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Interrupt Vector\n")); - break; - case 0x9: -- DEBUG ((EFI_D_VERBOSE, "Invalid Log Page\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Log Page\n")); - break; - case 0xA: -- DEBUG ((EFI_D_VERBOSE, "Invalid Format\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Format\n")); - break; - case 0xB: -- DEBUG ((EFI_D_VERBOSE, "Firmware Application Requires Conventional Reset\n")); -+ DEBUG ((DEBUG_VERBOSE, "Firmware Application Requires Conventional Reset\n")); - break; - case 0xC: -- DEBUG ((EFI_D_VERBOSE, "Invalid Queue Deletion\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Queue Deletion\n")); - break; - case 0xD: -- DEBUG ((EFI_D_VERBOSE, "Feature Identifier Not Saveable\n")); -+ DEBUG ((DEBUG_VERBOSE, "Feature Identifier Not Saveable\n")); - break; - case 0xE: -- DEBUG ((EFI_D_VERBOSE, "Feature Not Changeable\n")); -+ DEBUG ((DEBUG_VERBOSE, "Feature Not Changeable\n")); - break; - case 0xF: -- DEBUG ((EFI_D_VERBOSE, "Feature Not Namespace Specific\n")); -+ DEBUG ((DEBUG_VERBOSE, "Feature Not Namespace Specific\n")); - break; - case 0x10: -- DEBUG ((EFI_D_VERBOSE, "Firmware Application Requires NVM Subsystem Reset\n")); -+ DEBUG ((DEBUG_VERBOSE, "Firmware Application Requires NVM Subsystem Reset\n")); - break; - case 0x80: -- DEBUG ((EFI_D_VERBOSE, "Conflicting Attributes\n")); -+ DEBUG ((DEBUG_VERBOSE, "Conflicting Attributes\n")); - break; - case 0x81: -- DEBUG ((EFI_D_VERBOSE, "Invalid Protection Information\n")); -+ DEBUG ((DEBUG_VERBOSE, "Invalid Protection Information\n")); - break; - case 0x82: -- DEBUG ((EFI_D_VERBOSE, "Attempted Write to Read Only Range\n")); -+ DEBUG ((DEBUG_VERBOSE, "Attempted Write to Read Only Range\n")); - break; - } - break; -@@ -164,25 +164,25 @@ NvmeDumpStatus ( - case 0x2: - switch (Cq->Sc) { - case 0x80: -- DEBUG ((EFI_D_VERBOSE, "Write Fault\n")); -+ DEBUG ((DEBUG_VERBOSE, "Write Fault\n")); - break; - case 0x81: -- DEBUG ((EFI_D_VERBOSE, "Unrecovered Read Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "Unrecovered Read Error\n")); - break; - case 0x82: -- DEBUG ((EFI_D_VERBOSE, "End-to-end Guard Check Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "End-to-end Guard Check Error\n")); - break; - case 0x83: -- DEBUG ((EFI_D_VERBOSE, "End-to-end Application Tag Check Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "End-to-end Application Tag Check Error\n")); - break; - case 0x84: -- DEBUG ((EFI_D_VERBOSE, "End-to-end Reference Tag Check Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "End-to-end Reference Tag Check Error\n")); - break; - case 0x85: -- DEBUG ((EFI_D_VERBOSE, "Compare Failure\n")); -+ DEBUG ((DEBUG_VERBOSE, "Compare Failure\n")); - break; - case 0x86: -- DEBUG ((EFI_D_VERBOSE, "Access Denied\n")); -+ DEBUG ((DEBUG_VERBOSE, "Access Denied\n")); - break; - } - break; -@@ -268,7 +268,7 @@ NvmeCreatePrpList ( - ); - - if (EFI_ERROR (Status) || (Bytes != EFI_PAGES_TO_SIZE (*PrpListNo))) { -- DEBUG ((EFI_D_ERROR, "NvmeCreatePrpList: create PrpList failure!\n")); -+ DEBUG ((DEBUG_ERROR, "NvmeCreatePrpList: create PrpList failure!\n")); - goto EXIT; - } - // -@@ -578,7 +578,7 @@ NvmExpressPassThru ( - // - ASSERT (Sq->Psdt == 0); - if (Sq->Psdt != 0) { -- DEBUG ((EFI_D_ERROR, "NvmExpressPassThru: doesn't support SGL mechanism\n")); -+ DEBUG ((DEBUG_ERROR, "NvmExpressPassThru: doesn't support SGL mechanism\n")); - return EFI_UNSUPPORTED; - } - -@@ -1182,4 +1182,3 @@ Exit: - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c -index 8db1ebf8ec..99f8642f13 100644 ---- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c -+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c -@@ -1003,7 +1003,7 @@ PciHostBridgeAdjustAllocation ( - Status = RejectPciDevice (PciResNode->PciDev); - if (Status == EFI_SUCCESS) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "PciBus: [%02x|%02x|%02x] was rejected due to resource confliction.\n", - PciResNode->PciDev->BusNumber, PciResNode->PciDev->DeviceNumber, PciResNode->PciDev->FunctionNumber - )); -@@ -2207,4 +2207,3 @@ AddHostBridgeEnumerator ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c -index 3a238d4e46..5111bd513a 100644 ---- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c -+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c -@@ -231,7 +231,7 @@ PciSearchDevice ( - PciIoDevice = NULL; - - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "PciBus: Discovered %s @ [%02x|%02x|%02x]\n", - IS_PCI_BRIDGE (Pci) ? L"PPB" : - IS_CARDBUS_BRIDGE (Pci) ? L"P2C" : -@@ -398,7 +398,7 @@ DumpPpbPaddingResource ( - - if ((Type != PciBarTypeUnknown) && ((ResourceType == PciBarTypeUnknown) || (ResourceType == Type))) { - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " Padding: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx\n", - mBarTypeStr[Type], Descriptor->AddrRangeMax, Descriptor->AddrLen - )); -@@ -425,7 +425,7 @@ DumpPciBars ( - } - - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " BAR[%d]: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx;\tOffset = 0x%02x\n", - Index, mBarTypeStr[MIN (PciIoDevice->PciBar[Index].BarType, PciBarTypeMaxType)], - PciIoDevice->PciBar[Index].Alignment, PciIoDevice->PciBar[Index].Length, PciIoDevice->PciBar[Index].Offset -@@ -438,13 +438,13 @@ DumpPciBars ( - } - - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " VFBAR[%d]: Type = %s; Alignment = 0x%lx;\tLength = 0x%lx;\tOffset = 0x%02x\n", - Index, mBarTypeStr[MIN (PciIoDevice->VfPciBar[Index].BarType, PciBarTypeMaxType)], - PciIoDevice->VfPciBar[Index].Alignment, PciIoDevice->VfPciBar[Index].Length, PciIoDevice->VfPciBar[Index].Offset - )); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - - /** -@@ -1903,7 +1903,7 @@ PciParseBar ( - // Fix the length to support some special 64 bit BAR - // - if (Value == 0) { -- DEBUG ((EFI_D_INFO, "[PciBus]BAR probing for upper 32bit of MEM64 BAR returns 0, change to 0xFFFFFFFF.\n")); -+ DEBUG ((DEBUG_INFO, "[PciBus]BAR probing for upper 32bit of MEM64 BAR returns 0, change to 0xFFFFFFFF.\n")); - Value = (UINT32) -1; - } else { - Value |= ((UINT32)(-1) << HighBitSet32 (Value)); -@@ -2282,7 +2282,7 @@ CreatePciIoDevice ( - &Data32 - ); - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " ARI: forwarding enabled for PPB[%02x:%02x:%02x]\n", - Bridge->BusNumber, - Bridge->DeviceNumber, -@@ -2291,7 +2291,7 @@ CreatePciIoDevice ( - } - } - -- DEBUG ((EFI_D_INFO, " ARI: CapOffset = 0x%x\n", PciIoDevice->AriCapabilityOffset)); -+ DEBUG ((DEBUG_INFO, " ARI: CapOffset = 0x%x\n", PciIoDevice->AriCapabilityOffset)); - } - } - -@@ -2401,12 +2401,12 @@ CreatePciIoDevice ( - PciIoDevice->ReservedBusNum = (UINT16)(EFI_PCI_BUS_OF_RID (LastVF) - Bus + 1); - - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " SR-IOV: SupportedPageSize = 0x%x; SystemPageSize = 0x%x; FirstVFOffset = 0x%x;\n", - SupportedPageSize, PciIoDevice->SystemPageSize >> 12, FirstVFOffset - )); - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - " InitialVFs = 0x%x; ReservedBusNum = 0x%x; CapOffset = 0x%x\n", - PciIoDevice->InitialVFs, PciIoDevice->ReservedBusNum, PciIoDevice->SrIovCapabilityOffset - )); -@@ -2421,7 +2421,7 @@ CreatePciIoDevice ( - NULL - ); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, " MR-IOV: CapOffset = 0x%x\n", PciIoDevice->MrIovCapabilityOffset)); -+ DEBUG ((DEBUG_INFO, " MR-IOV: CapOffset = 0x%x\n", PciIoDevice->MrIovCapabilityOffset)); - } - } - -@@ -2869,4 +2869,3 @@ ResetAllPpbBusNumber ( - } - } - } -- -diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c -index 4caac56f1d..0ad1dfa526 100644 ---- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c -+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c -@@ -215,7 +215,7 @@ DumpBridgeResource ( - - if ((BridgeResource != NULL) && (BridgeResource->Length != 0)) { - DEBUG (( -- EFI_D_INFO, "Type = %s; Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx\n", -+ DEBUG_INFO, "Type = %s; Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx\n", - mBarTypeStr[MIN (BridgeResource->ResType, PciBarTypeMaxType)], - BridgeResource->PciDev->PciBar[BridgeResource->Bar].BaseAddress, - BridgeResource->Length, BridgeResource->Alignment -@@ -228,7 +228,7 @@ DumpBridgeResource ( - if (Resource->ResourceUsage == PciResUsageTypical) { - Bar = Resource->Virtual ? Resource->PciDev->VfPciBar : Resource->PciDev->PciBar; - DEBUG (( -- EFI_D_INFO, " Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx;\tOwner = %s [%02x|%02x|%02x:", -+ DEBUG_INFO, " Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx;\tOwner = %s [%02x|%02x|%02x:", - Bar[Resource->Bar].BaseAddress, Resource->Length, Resource->Alignment, - IS_PCI_BRIDGE (&Resource->PciDev->Pci) ? L"PPB" : - IS_CARDBUS_BRIDGE (&Resource->PciDev->Pci) ? L"P2C" : -@@ -244,20 +244,20 @@ DumpBridgeResource ( - // - // The resource requirement comes from the device itself. - // -- DEBUG ((EFI_D_INFO, "%02x]", Bar[Resource->Bar].Offset)); -+ DEBUG ((DEBUG_INFO, "%02x]", Bar[Resource->Bar].Offset)); - } else { - // - // The resource requirement comes from the subordinate devices. - // -- DEBUG ((EFI_D_INFO, "**]")); -+ DEBUG ((DEBUG_INFO, "**]")); - } - } else { -- DEBUG ((EFI_D_INFO, " Base = Padding;\tLength = 0x%lx;\tAlignment = 0x%lx", Resource->Length, Resource->Alignment)); -+ DEBUG ((DEBUG_INFO, " Base = Padding;\tLength = 0x%lx;\tAlignment = 0x%lx", Resource->Length, Resource->Alignment)); - } - if (BridgeResource->ResType != Resource->ResType) { -- DEBUG ((EFI_D_INFO, "; Type = %s", mBarTypeStr[MIN (Resource->ResType, PciBarTypeMaxType)])); -+ DEBUG ((DEBUG_INFO, "; Type = %s", mBarTypeStr[MIN (Resource->ResType, PciBarTypeMaxType)])); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - } - } -@@ -321,7 +321,7 @@ DumpResourceMap ( - PCI_RESOURCE_NODE **ChildResources; - UINTN ChildResourceCount; - -- DEBUG ((EFI_D_INFO, "PciBus: Resource Map for ")); -+ DEBUG ((DEBUG_INFO, "PciBus: Resource Map for ")); - - Status = gBS->OpenProtocol ( - Bridge->Handle, -@@ -333,7 +333,7 @@ DumpResourceMap ( - ); - if (EFI_ERROR (Status)) { - DEBUG (( -- EFI_D_INFO, "Bridge [%02x|%02x|%02x]\n", -+ DEBUG_INFO, "Bridge [%02x|%02x|%02x]\n", - Bridge->BusNumber, Bridge->DeviceNumber, Bridge->FunctionNumber - )); - } else { -@@ -342,7 +342,7 @@ DumpResourceMap ( - FALSE, - FALSE - ); -- DEBUG ((EFI_D_INFO, "Root Bridge %s\n", Str != NULL ? Str : L"")); -+ DEBUG ((DEBUG_INFO, "Root Bridge %s\n", Str != NULL ? Str : L"")); - if (Str != NULL) { - FreePool (Str); - } -@@ -351,7 +351,7 @@ DumpResourceMap ( - for (Index = 0; Index < ResourceCount; Index++) { - DumpBridgeResource (Resources[Index]); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - - for ( Link = Bridge->ChildList.ForwardLink - ; Link != &Bridge->ChildList -@@ -622,7 +622,7 @@ PciHostBridgeResourceAllocator ( - // If SubmitResources returns error, PciBus isn't able to start. - // It's a fatal error so assertion is added. - // -- DEBUG ((EFI_D_INFO, "PciBus: HostBridge->SubmitResources() - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PciBus: HostBridge->SubmitResources() - %r\n", Status)); - ASSERT_EFI_ERROR (Status); - } - -@@ -654,7 +654,7 @@ PciHostBridgeResourceAllocator ( - // Notify platform to start to program the resource - // - Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeAllocateResources); -- DEBUG ((EFI_D_INFO, "PciBus: HostBridge->NotifyPhase(AllocateResources) - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PciBus: HostBridge->NotifyPhase(AllocateResources) - %r\n", Status)); - if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) { - // - // If Hot Plug is not supported -@@ -1340,9 +1340,9 @@ PciScanBus ( - TempReservedBusNum = PciDevice->ReservedBusNum; - - if (Func == 0) { -- DEBUG ((EFI_D_INFO, "PCI-IOV ScanBus - SubBusNumber - 0x%x\n", *SubBusNumber)); -+ DEBUG ((DEBUG_INFO, "PCI-IOV ScanBus - SubBusNumber - 0x%x\n", *SubBusNumber)); - } else { -- DEBUG ((EFI_D_INFO, "PCI-IOV ScanBus - SubBusNumber - 0x%x (Update)\n", *SubBusNumber)); -+ DEBUG ((DEBUG_INFO, "PCI-IOV ScanBus - SubBusNumber - 0x%x (Update)\n", *SubBusNumber)); - } - } - } -@@ -1522,7 +1522,7 @@ PciHostBridgeEnumerator ( - return Status; - } - -- DEBUG((EFI_D_INFO, "PCI Bus First Scanning\n")); -+ DEBUG((DEBUG_INFO, "PCI Bus First Scanning\n")); - RootBridgeHandle = NULL; - while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) { - -@@ -1601,7 +1601,7 @@ PciHostBridgeEnumerator ( - Status = AllRootHPCInitialized (STALL_1_SECOND * 15); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Some root HPC failed to initialize\n")); -+ DEBUG ((DEBUG_ERROR, "Some root HPC failed to initialize\n")); - return Status; - } - -@@ -1614,7 +1614,7 @@ PciHostBridgeEnumerator ( - return Status; - } - -- DEBUG((EFI_D_INFO, "PCI Bus Second Scanning\n")); -+ DEBUG((DEBUG_INFO, "PCI Bus Second Scanning\n")); - RootBridgeHandle = NULL; - while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) { - -diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c -index 163e931dd9..a71518652d 100644 ---- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c -+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c -@@ -119,13 +119,13 @@ IntersectIoDescriptor ( - Status = gDS->AddIoSpace (EfiGcdIoTypeIo, IntersectionBase, - IntersectionEnd - IntersectionBase); - -- DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, -+ DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, - "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__, - IntersectionBase, IntersectionEnd, Status)); - return Status; - } - -- DEBUG ((EFI_D_ERROR, "%a: %a: desc [%Lx, %Lx) type %u conflicts with " -+ DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u conflicts with " - "aperture [%Lx, %Lx)\n", gEfiCallerBaseName, __FUNCTION__, - Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length, - (UINT32)Descriptor->GcdIoType, Base, Base + Length)); -@@ -155,7 +155,7 @@ AddIoSpace ( - - Status = gDS->GetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a: %a: GetIoSpaceMap(): %r\n", -+ DEBUG ((DEBUG_ERROR, "%a: %a: GetIoSpaceMap(): %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return Status; - } -@@ -263,13 +263,13 @@ IntersectMemoryDescriptor ( - IntersectionBase, IntersectionEnd - IntersectionBase, - Capabilities); - -- DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, -+ DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, - "%a: %a: add [%Lx, %Lx): %r\n", gEfiCallerBaseName, __FUNCTION__, - IntersectionBase, IntersectionEnd, Status)); - return Status; - } - -- DEBUG ((EFI_D_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts " -+ DEBUG ((DEBUG_ERROR, "%a: %a: desc [%Lx, %Lx) type %u cap %Lx conflicts " - "with aperture [%Lx, %Lx) cap %Lx\n", gEfiCallerBaseName, __FUNCTION__, - Descriptor->BaseAddress, Descriptor->BaseAddress + Descriptor->Length, - (UINT32)Descriptor->GcdMemoryType, Descriptor->Capabilities, -@@ -302,7 +302,7 @@ AddMemoryMappedIoSpace ( - - Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n", -+ DEBUG ((DEBUG_ERROR, "%a: %a: GetMemorySpaceMap(): %r\n", - gEfiCallerBaseName, __FUNCTION__, Status)); - return Status; - } -@@ -828,7 +828,7 @@ NotifyPhase ( - } - } - -- DEBUG ((EFI_D_INFO, "PciHostBridge: NotifyPhase (AllocateResources)\n")); -+ DEBUG ((DEBUG_INFO, "PciHostBridge: NotifyPhase (AllocateResources)\n")); - for (Link = GetFirstNode (&HostBridge->RootBridges) - ; !IsNull (&HostBridge->RootBridges, Link) - ; Link = GetNextNode (&HostBridge->RootBridges, Link) -@@ -838,7 +838,7 @@ NotifyPhase ( - } - - RootBridge = ROOT_BRIDGE_FROM_LINK (Link); -- DEBUG ((EFI_D_INFO, " RootBridge: %s\n", RootBridge->DevicePathStr)); -+ DEBUG ((DEBUG_INFO, " RootBridge: %s\n", RootBridge->DevicePathStr)); - - for (Index1 = TypeIo; Index1 < TypeBus; Index1++) { - if (RootBridge->ResAllocNode[Index1].Status == ResNone) { -@@ -1360,7 +1360,7 @@ SubmitResources ( - ) { - RootBridge = ROOT_BRIDGE_FROM_LINK (Link); - if (RootBridgeHandle == RootBridge->Handle) { -- DEBUG ((EFI_D_INFO, "PciHostBridge: SubmitResources for %s\n", RootBridge->DevicePathStr)); -+ DEBUG ((DEBUG_INFO, "PciHostBridge: SubmitResources for %s\n", RootBridge->DevicePathStr)); - // - // Check the resource descriptors. - // If the Configuration includes one or more invalid resource descriptors, all the resource -@@ -1371,11 +1371,11 @@ SubmitResources ( - return EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_INFO, " %s: Granularity/SpecificFlag = %ld / %02x%s\n", -+ DEBUG ((DEBUG_INFO, " %s: Granularity/SpecificFlag = %ld / %02x%s\n", - mAcpiAddressSpaceTypeStr[Descriptor->ResType], Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, - (Descriptor->SpecificFlag & EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE) != 0 ? L" (Prefetchable)" : L"" - )); -- DEBUG ((EFI_D_INFO, " Length/Alignment = 0x%lx / 0x%lx\n", Descriptor->AddrLen, Descriptor->AddrRangeMax)); -+ DEBUG ((DEBUG_INFO, " Length/Alignment = 0x%lx / 0x%lx\n", Descriptor->AddrLen, Descriptor->AddrRangeMax)); - switch (Descriptor->ResType) { - case ACPI_ADDRESS_SPACE_TYPE_MEM: - if (Descriptor->AddrSpaceGranularity != 32 && Descriptor->AddrSpaceGranularity != 64) { -diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c -index d304fae422..2f1bed853d 100644 ---- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c -+++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c -@@ -71,17 +71,17 @@ CreateRootBridge ( - - DevicePathStr = NULL; - -- DEBUG ((EFI_D_INFO, "RootBridge: ")); -- DEBUG ((EFI_D_INFO, "%s\n", DevicePathStr = ConvertDevicePathToText (Bridge->DevicePath, FALSE, FALSE))); -- DEBUG ((EFI_D_INFO, " Support/Attr: %lx / %lx\n", Bridge->Supports, Bridge->Attributes)); -- DEBUG ((EFI_D_INFO, " DmaAbove4G: %s\n", Bridge->DmaAbove4G ? L"Yes" : L"No")); -- DEBUG ((EFI_D_INFO, "NoExtConfSpace: %s\n", Bridge->NoExtendedConfigSpace ? L"Yes" : L"No")); -- DEBUG ((EFI_D_INFO, " AllocAttr: %lx (%s%s)\n", Bridge->AllocationAttributes, -+ DEBUG ((DEBUG_INFO, "RootBridge: ")); -+ DEBUG ((DEBUG_INFO, "%s\n", DevicePathStr = ConvertDevicePathToText (Bridge->DevicePath, FALSE, FALSE))); -+ DEBUG ((DEBUG_INFO, " Support/Attr: %lx / %lx\n", Bridge->Supports, Bridge->Attributes)); -+ DEBUG ((DEBUG_INFO, " DmaAbove4G: %s\n", Bridge->DmaAbove4G ? L"Yes" : L"No")); -+ DEBUG ((DEBUG_INFO, "NoExtConfSpace: %s\n", Bridge->NoExtendedConfigSpace ? L"Yes" : L"No")); -+ DEBUG ((DEBUG_INFO, " AllocAttr: %lx (%s%s)\n", Bridge->AllocationAttributes, - (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM) != 0 ? L"CombineMemPMem " : L"", - (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_MEM64_DECODE) != 0 ? L"Mem64Decode" : L"" - )); - DEBUG (( -- EFI_D_INFO, " Bus: %lx - %lx Translation=%lx\n", -+ DEBUG_INFO, " Bus: %lx - %lx Translation=%lx\n", - Bridge->Bus.Base, Bridge->Bus.Limit, Bridge->Bus.Translation - )); - // -diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c -index 9fe8a482e0..4a9b49e347 100644 ---- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c -+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c -@@ -943,7 +943,7 @@ SerialControllerDriverStart ( - Node = NextDevicePathNode (Node); - } while (!IsDevicePathEnd (Node)); - Status = CreateSerialDevice (Controller, Uart, ParentDevicePath, FALSE, Acpi->UID, ParentIo, NULL, NULL); -- DEBUG ((EFI_D_INFO, "PciSioSerial: Create SIO child serial device - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PciSioSerial: Create SIO child serial device - %r\n", Status)); - } - } else { - Status = ParentIo.PciIo->Pci.Read (ParentIo.PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci); -@@ -1024,7 +1024,7 @@ SerialControllerDriverStart ( - } - - Status = CreateSerialDevice (Controller, Uart, ParentDevicePath, FALSE, 0, ParentIo, PciSerialParameter, PciDeviceInfo); -- DEBUG ((EFI_D_INFO, "PciSioSerial: Create PCI child serial device (single) - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PciSioSerial: Create PCI child serial device (single) - %r\n", Status)); - if (!EFI_ERROR (Status)) { - PciDeviceInfo->ChildCount++; - } -@@ -1045,7 +1045,7 @@ SerialControllerDriverStart ( - // - Status = CreateSerialDevice (Controller, Uart, ParentDevicePath, TRUE, PciSerialCount, ParentIo, PciSerialParameter, PciDeviceInfo); - PciSerialCount++; -- DEBUG ((EFI_D_INFO, "PciSioSerial: Create PCI child serial device (multiple) - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PciSioSerial: Create PCI child serial device (multiple) - %r\n", Status)); - if (!EFI_ERROR (Status)) { - PciDeviceInfo->ChildCount++; - } -diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c -index 56c5faf5db..f8b9a0e3ee 100644 ---- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c -+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c -@@ -134,9 +134,9 @@ VerifyUartParameters ( - } - - Percent = DivU64x32 (MultU64x32 (BaudRate, 100), ComputedBaudRate); -- DEBUG ((EFI_D_INFO, "ClockRate = %d\n", ClockRate)); -- DEBUG ((EFI_D_INFO, "Divisor = %ld\n", ComputedDivisor)); -- DEBUG ((EFI_D_INFO, "BaudRate/Actual (%ld/%d) = %d%%\n", BaudRate, ComputedBaudRate, Percent)); -+ DEBUG ((DEBUG_INFO, "ClockRate = %d\n", ClockRate)); -+ DEBUG ((DEBUG_INFO, "Divisor = %ld\n", ComputedDivisor)); -+ DEBUG ((DEBUG_INFO, "BaudRate/Actual (%ld/%d) = %d%%\n", BaudRate, ComputedBaudRate, Percent)); - - // - // If the requested BaudRate is not supported: -@@ -176,9 +176,9 @@ VerifyUartParameters ( - return FALSE; - } - -- DEBUG ((EFI_D_INFO, "ClockRate = %d\n", ClockRate)); -- DEBUG ((EFI_D_INFO, "Divisor = %ld\n", ComputedDivisor)); -- DEBUG ((EFI_D_INFO, "BaudRate/Actual (%ld/%d) = %d%%\n", BaudRate, ComputedBaudRate, Percent)); -+ DEBUG ((DEBUG_INFO, "ClockRate = %d\n", ClockRate)); -+ DEBUG ((DEBUG_INFO, "Divisor = %ld\n", ComputedDivisor)); -+ DEBUG ((DEBUG_INFO, "BaudRate/Actual (%ld/%d) = %d%%\n", BaudRate, ComputedBaudRate, Percent)); - - if (ActualBaudRate != NULL) { - *ActualBaudRate = ComputedBaudRate; -diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c -index ab06e2833c..1133e1c935 100644 ---- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c -+++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c -@@ -89,7 +89,7 @@ CalculateBestPioMode ( - if ((IdentifyData->AtaData.field_validity & 0x02) == 0x02) { - - AdvancedPioMode = IdentifyData->AtaData.advanced_pio_modes; -- DEBUG ((EFI_D_INFO, "CalculateBestPioMode: AdvancedPioMode = %x\n", AdvancedPioMode)); -+ DEBUG ((DEBUG_INFO, "CalculateBestPioMode: AdvancedPioMode = %x\n", AdvancedPioMode)); - - for (Index = 0; Index < 8; Index++) { - if ((AdvancedPioMode & 0x01) != 0) { -@@ -203,7 +203,7 @@ CalculateBestUdmaMode ( - } - - DeviceUDmaMode = IdentifyData->AtaData.ultra_dma_mode; -- DEBUG ((EFI_D_INFO, "CalculateBestUdmaMode: DeviceUDmaMode = %x\n", DeviceUDmaMode)); -+ DEBUG ((DEBUG_INFO, "CalculateBestUdmaMode: DeviceUDmaMode = %x\n", DeviceUDmaMode)); - DeviceUDmaMode &= 0x3f; - TempMode = 0; // initialize it to UDMA-0 - -@@ -362,7 +362,7 @@ SataControllerStart ( - UINT64 Supports; - UINT8 MaxPortNumber; - -- DEBUG ((EFI_D_INFO, "SataControllerStart start\n")); -+ DEBUG ((DEBUG_INFO, "SataControllerStart start\n")); - - Private = NULL; - -@@ -378,7 +378,7 @@ SataControllerStart ( - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SataControllerStart error. return status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SataControllerStart error. return status = %r\n", Status)); - return Status; - } - -@@ -419,7 +419,7 @@ SataControllerStart ( - } - - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "Original PCI Attributes = 0x%llx\n", - Private->OriginalPciAttributes - )); -@@ -434,7 +434,7 @@ SataControllerStart ( - goto Done; - } - -- DEBUG ((EFI_D_INFO, "Supported PCI Attributes = 0x%llx\n", Supports)); -+ DEBUG ((DEBUG_INFO, "Supported PCI Attributes = 0x%llx\n", Supports)); - - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; - Status = PciIo->Attributes ( -@@ -447,7 +447,7 @@ SataControllerStart ( - goto Done; - } - -- DEBUG ((EFI_D_INFO, "Enabled PCI Attributes = 0x%llx\n", Supports)); -+ DEBUG ((DEBUG_INFO, "Enabled PCI Attributes = 0x%llx\n", Supports)); - Private->PciAttributesChanged = TRUE; - - Status = PciIo->Pci.Read ( -@@ -561,7 +561,7 @@ Done: - } - } - -- DEBUG ((EFI_D_INFO, "SataControllerStart end with %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "SataControllerStart end with %r\n", Status)); - - return Status; - } -@@ -1048,7 +1048,7 @@ IdeInitCalculateMode ( - } else { - (*SupportedModes)->PioMode.Valid = FALSE; - } -- DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: PioMode = %x\n", (*SupportedModes)->PioMode.Mode)); -+ DEBUG ((DEBUG_INFO, "IdeInitCalculateMode: PioMode = %x\n", (*SupportedModes)->PioMode.Mode)); - - Status = CalculateBestUdmaMode ( - IdentifyData, -@@ -1063,7 +1063,7 @@ IdeInitCalculateMode ( - } else { - (*SupportedModes)->UdmaMode.Valid = FALSE; - } -- DEBUG ((EFI_D_INFO, "IdeInitCalculateMode: UdmaMode = %x\n", (*SupportedModes)->UdmaMode.Mode)); -+ DEBUG ((DEBUG_INFO, "IdeInitCalculateMode: UdmaMode = %x\n", (*SupportedModes)->UdmaMode.Mode)); - - // - // The modes other than PIO and UDMA are not supported -@@ -1105,4 +1105,3 @@ IdeInitSetTiming ( - { - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcPei/SdMmcPciHcPei.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcPei/SdMmcPciHcPei.c -index 3aa11f8eed..9c18e6fddc 100644 ---- a/MdeModulePkg/Bus/Pci/SdMmcPciHcPei/SdMmcPciHcPei.c -+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcPei/SdMmcPciHcPei.c -@@ -108,7 +108,7 @@ InitializeSdMmcHcPeim ( - - Private = (SD_MMC_HC_PEI_PRIVATE_DATA *) AllocateZeroPool (sizeof (SD_MMC_HC_PEI_PRIVATE_DATA)); - if (Private == NULL) { -- DEBUG ((EFI_D_ERROR, "Failed to allocate memory for SD_MMC_HC_PEI_PRIVATE_DATA! \n")); -+ DEBUG ((DEBUG_ERROR, "Failed to allocate memory for SD_MMC_HC_PEI_PRIVATE_DATA! \n")); - return EFI_OUT_OF_RESOURCES; - } - -diff --git a/MdeModulePkg/Bus/Pci/UfsPciHcPei/UfsPciHcPei.c b/MdeModulePkg/Bus/Pci/UfsPciHcPei/UfsPciHcPei.c -index 86f1529eec..68bfade9c2 100644 ---- a/MdeModulePkg/Bus/Pci/UfsPciHcPei/UfsPciHcPei.c -+++ b/MdeModulePkg/Bus/Pci/UfsPciHcPei/UfsPciHcPei.c -@@ -99,7 +99,7 @@ InitializeUfsHcPeim ( - - Private = (UFS_HC_PEI_PRIVATE_DATA *) AllocateZeroPool (sizeof (UFS_HC_PEI_PRIVATE_DATA)); - if (Private == NULL) { -- DEBUG ((EFI_D_ERROR, "Failed to allocate memory for UFS_HC_PEI_PRIVATE_DATA! \n")); -+ DEBUG ((DEBUG_ERROR, "Failed to allocate memory for UFS_HC_PEI_PRIVATE_DATA! \n")); - return EFI_OUT_OF_RESOURCES; - } - -diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c -index 3ec5ecf0e4..9f78f3dbd3 100644 ---- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c -+++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c -@@ -323,7 +323,7 @@ Uhci2GetCapability ( - - Uhc->RootPorts = *PortNumber; - -- DEBUG ((EFI_D_INFO, "Uhci2GetCapability: %d ports\n", (UINT32)Uhc->RootPorts)); -+ DEBUG ((DEBUG_INFO, "Uhci2GetCapability: %d ports\n", (UINT32)Uhc->RootPorts)); - return EFI_SUCCESS; - } - -@@ -378,7 +378,7 @@ Uhci2GetRootHubPortStatus ( - } - - if ((PortSC & USBPORTSC_SUSP) != 0) { -- DEBUG ((EFI_D_INFO, "Uhci2GetRootHubPortStatus: port %d is suspended\n", PortNumber)); -+ DEBUG ((DEBUG_INFO, "Uhci2GetRootHubPortStatus: port %d is suspended\n", PortNumber)); - PortStatus->PortStatus |= USB_PORT_STAT_SUSPEND; - } - -@@ -1880,4 +1880,3 @@ UhciDriverBindingStop ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c b/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c -index 517780a5f4..3d499c9baf 100644 ---- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c -+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciDebug.c -@@ -20,12 +20,12 @@ UhciDumpQh ( - IN UHCI_QH_SW *QhSw - ) - { -- DEBUG ((EFI_D_VERBOSE, "&QhSw @ 0x%p\n", QhSw)); -- DEBUG ((EFI_D_VERBOSE, "QhSw.NextQh - 0x%p\n", QhSw->NextQh)); -- DEBUG ((EFI_D_VERBOSE, "QhSw.TDs - 0x%p\n", QhSw->TDs)); -- DEBUG ((EFI_D_VERBOSE, "QhSw.QhHw:\n")); -- DEBUG ((EFI_D_VERBOSE, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink)); -- DEBUG ((EFI_D_VERBOSE, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink)); -+ DEBUG ((DEBUG_VERBOSE, "&QhSw @ 0x%p\n", QhSw)); -+ DEBUG ((DEBUG_VERBOSE, "QhSw.NextQh - 0x%p\n", QhSw->NextQh)); -+ DEBUG ((DEBUG_VERBOSE, "QhSw.TDs - 0x%p\n", QhSw->TDs)); -+ DEBUG ((DEBUG_VERBOSE, "QhSw.QhHw:\n")); -+ DEBUG ((DEBUG_VERBOSE, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink)); -+ DEBUG ((DEBUG_VERBOSE, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink)); - } - - -@@ -45,27 +45,26 @@ UhciDumpTds ( - CurTdSw = TdSw; - - while (CurTdSw != NULL) { -- DEBUG ((EFI_D_VERBOSE, "TdSw @ 0x%p\n", CurTdSw)); -- DEBUG ((EFI_D_VERBOSE, "TdSw.NextTd - 0x%p\n", CurTdSw->NextTd)); -- DEBUG ((EFI_D_VERBOSE, "TdSw.DataLen - %d\n", CurTdSw->DataLen)); -- DEBUG ((EFI_D_VERBOSE, "TdSw.Data - 0x%p\n", CurTdSw->Data)); -- DEBUG ((EFI_D_VERBOSE, "TdHw:\n")); -- DEBUG ((EFI_D_VERBOSE, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink)); -- DEBUG ((EFI_D_VERBOSE, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen)); -- DEBUG ((EFI_D_VERBOSE, " Status - 0x%x\n", CurTdSw->TdHw.Status)); -- DEBUG ((EFI_D_VERBOSE, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl)); -- DEBUG ((EFI_D_VERBOSE, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch)); -- DEBUG ((EFI_D_VERBOSE, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed)); -- DEBUG ((EFI_D_VERBOSE, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount)); -- DEBUG ((EFI_D_VERBOSE, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket)); -- DEBUG ((EFI_D_VERBOSE, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode)); -- DEBUG ((EFI_D_VERBOSE, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr)); -- DEBUG ((EFI_D_VERBOSE, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint)); -- DEBUG ((EFI_D_VERBOSE, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle)); -- DEBUG ((EFI_D_VERBOSE, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen)); -- DEBUG ((EFI_D_VERBOSE, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer)); -+ DEBUG ((DEBUG_VERBOSE, "TdSw @ 0x%p\n", CurTdSw)); -+ DEBUG ((DEBUG_VERBOSE, "TdSw.NextTd - 0x%p\n", CurTdSw->NextTd)); -+ DEBUG ((DEBUG_VERBOSE, "TdSw.DataLen - %d\n", CurTdSw->DataLen)); -+ DEBUG ((DEBUG_VERBOSE, "TdSw.Data - 0x%p\n", CurTdSw->Data)); -+ DEBUG ((DEBUG_VERBOSE, "TdHw:\n")); -+ DEBUG ((DEBUG_VERBOSE, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink)); -+ DEBUG ((DEBUG_VERBOSE, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen)); -+ DEBUG ((DEBUG_VERBOSE, " Status - 0x%x\n", CurTdSw->TdHw.Status)); -+ DEBUG ((DEBUG_VERBOSE, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl)); -+ DEBUG ((DEBUG_VERBOSE, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch)); -+ DEBUG ((DEBUG_VERBOSE, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed)); -+ DEBUG ((DEBUG_VERBOSE, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount)); -+ DEBUG ((DEBUG_VERBOSE, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket)); -+ DEBUG ((DEBUG_VERBOSE, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode)); -+ DEBUG ((DEBUG_VERBOSE, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr)); -+ DEBUG ((DEBUG_VERBOSE, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint)); -+ DEBUG ((DEBUG_VERBOSE, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle)); -+ DEBUG ((DEBUG_VERBOSE, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen)); -+ DEBUG ((DEBUG_VERBOSE, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer)); - - CurTdSw = CurTdSw->NextTd; - } - } -- -diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.c b/MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.c -index 582c25e78d..44bcde4c4e 100644 ---- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.c -+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciReg.c -@@ -38,7 +38,7 @@ UhciReadReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UhciReadReg: PciIo Io.Read error: %r at offset %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "UhciReadReg: PciIo Io.Read error: %r at offset %d\n", Status, Offset)); - - Data = 0xFFFF; - } -@@ -74,7 +74,7 @@ UhciWriteReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UhciWriteReg: PciIo Io.Write error: %r at offset %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "UhciWriteReg: PciIo Io.Write error: %r at offset %d\n", Status, Offset)); - } - } - -@@ -144,7 +144,7 @@ UhciAckAllInterrupt ( - // is a temporary error status. - // - if (!UhciIsHcWorking (Uhc->PciIo)) { -- DEBUG ((EFI_D_ERROR, "UhciAckAllInterrupt: re-enable the UHCI from system error\n")); -+ DEBUG ((DEBUG_ERROR, "UhciAckAllInterrupt: re-enable the UHCI from system error\n")); - Uhc->Usb2Hc.SetState (&Uhc->Usb2Hc, EfiUsbHcStateOperational); - } - } -@@ -208,7 +208,7 @@ UhciIsHcWorking ( - UsbSts = UhciReadReg (PciIo, USBSTS_OFFSET); - - if ((UsbSts & (USBSTS_HCPE | USBSTS_HSE | USBSTS_HCH)) != 0) { -- DEBUG ((EFI_D_ERROR, "UhciIsHcWorking: current USB state is %x\n", UsbSts)); -+ DEBUG ((DEBUG_ERROR, "UhciIsHcWorking: current USB state is %x\n", UsbSts)); - return FALSE; - } - -@@ -245,7 +245,7 @@ UhciSetFrameListBaseAddr ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UhciSetFrameListBaseAddr: PciIo Io.Write error: %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UhciSetFrameListBaseAddr: PciIo Io.Write error: %r\n", Status)); - } - } - -diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c -index e216418849..0829bc2a8c 100644 ---- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c -+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c -@@ -600,14 +600,14 @@ UhciExecuteTransfer ( - } - - if (!Finished) { -- DEBUG ((EFI_D_ERROR, "UhciExecuteTransfer: execution not finished for %dms\n", (UINT32)TimeOut)); -+ DEBUG ((DEBUG_ERROR, "UhciExecuteTransfer: execution not finished for %dms\n", (UINT32)TimeOut)); - UhciDumpQh (Qh); - UhciDumpTds (Td); - - Status = EFI_TIMEOUT; - - } else if (QhResult->Result != EFI_USB_NOERROR) { -- DEBUG ((EFI_D_ERROR, "UhciExecuteTransfer: execution failed with result %x\n", QhResult->Result)); -+ DEBUG ((DEBUG_ERROR, "UhciExecuteTransfer: execution failed with result %x\n", QhResult->Result)); - UhciDumpQh (Qh); - UhciDumpTds (Td); - -diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c -index 9aade19f8e..a8c098f9c3 100644 ---- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c -+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c -@@ -468,7 +468,7 @@ UsbHcAllocateMem ( - NewBlock = UsbHcAllocMemBlock (Pool, Pages); - - if (NewBlock == NULL) { -- DEBUG ((EFI_D_INFO, "UsbHcAllocateMem: failed to allocate block\n")); -+ DEBUG ((DEBUG_INFO, "UsbHcAllocateMem: failed to allocate block\n")); - return NULL; - } - -diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c -index aa69c47aad..005820e011 100644 ---- a/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c -+++ b/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c -@@ -503,7 +503,7 @@ UsbHcAllocateMem ( - NewBlock = UsbHcAllocMemBlock (Pool, Pages); - - if (NewBlock == NULL) { -- DEBUG ((EFI_D_ERROR, "UsbHcAllocateMem: failed to allocate block\n")); -+ DEBUG ((DEBUG_ERROR, "UsbHcAllocateMem: failed to allocate block\n")); - return NULL; - } - -diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c -index 43c53bad4e..5a1f907ff0 100644 ---- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c -+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c -@@ -120,7 +120,7 @@ XhcGetCapability ( - *MaxSpeed = EFI_USB_SPEED_SUPER; - *PortNumber = (UINT8) (Xhc->HcSParams1.Data.MaxPorts); - *Is64BitCapable = (UINT8) Xhc->Support64BitDma; -- DEBUG ((EFI_D_INFO, "XhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable)); -+ DEBUG ((DEBUG_INFO, "XhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable)); - - gBS->RestoreTPL (OldTpl); - -@@ -216,7 +216,7 @@ XhcReset ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcReset: status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcReset: status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - - return Status; -@@ -260,7 +260,7 @@ XhcGetState ( - *State = EfiUsbHcStateOperational; - } - -- DEBUG ((EFI_D_INFO, "XhcGetState: current state %d\n", *State)); -+ DEBUG ((DEBUG_INFO, "XhcGetState: current state %d\n", *State)); - gBS->RestoreTPL (OldTpl); - - return EFI_SUCCESS; -@@ -336,7 +336,7 @@ XhcSetState ( - Status = EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_INFO, "XhcSetState: status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcSetState: status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - - return Status; -@@ -530,7 +530,7 @@ XhcSetRootHubPortFeature ( - break; - - case EfiUsbPortReset: -- DEBUG ((EFI_D_INFO, "XhcUsbPortReset!\n")); -+ DEBUG ((DEBUG_INFO, "XhcUsbPortReset!\n")); - // - // Make sure Host Controller not halt before reset it - // -@@ -538,7 +538,7 @@ XhcSetRootHubPortFeature ( - Status = XhcRunHC (Xhc, XHC_GENERIC_TIMEOUT); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "XhcSetRootHubPortFeature :failed to start HC - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcSetRootHubPortFeature :failed to start HC - %r\n", Status)); - break; - } - } -@@ -571,7 +571,7 @@ XhcSetRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcSetRootHubPortFeature: status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcSetRootHubPortFeature: status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - - return Status; -@@ -706,7 +706,7 @@ XhcClearRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcClearRootHubPortFeature: status %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcClearRootHubPortFeature: status %r\n", Status)); - gBS->RestoreTPL (OldTpl); - - return Status; -@@ -914,7 +914,7 @@ XhcControlTransfer ( - Len = 0; - - if (XhcIsHalt (Xhc) || XhcIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcControlTransfer: HC halted at entrance\n")); -+ DEBUG ((DEBUG_ERROR, "XhcControlTransfer: HC halted at entrance\n")); - goto ON_EXIT; - } - -@@ -1043,7 +1043,7 @@ XhcControlTransfer ( - // Don't support multi-TT feature for super speed hub now. - // - MTT = 0; -- DEBUG ((EFI_D_ERROR, "XHCI: Don't support multi-TT feature for Hub now. (force to disable MTT)\n")); -+ DEBUG ((DEBUG_ERROR, "XHCI: Don't support multi-TT feature for Hub now. (force to disable MTT)\n")); - } else { - MTT = 0; - } -@@ -1162,7 +1162,7 @@ XhcControlTransfer ( - - ON_EXIT: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "XhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - gBS->RestoreTPL (OldTpl); -@@ -1250,7 +1250,7 @@ XhcBulkTransfer ( - Status = EFI_DEVICE_ERROR; - - if (XhcIsHalt (Xhc) || XhcIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcBulkTransfer: HC is halted\n")); -+ DEBUG ((DEBUG_ERROR, "XhcBulkTransfer: HC is halted\n")); - goto ON_EXIT; - } - -@@ -1282,7 +1282,7 @@ XhcBulkTransfer ( - - ON_EXIT: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "XhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - gBS->RestoreTPL (OldTpl); - -@@ -1386,14 +1386,14 @@ XhcAsyncInterruptTransfer ( - } - - Status = XhciDelAsyncIntTransfer (Xhc, DeviceAddress, EndPointAddress); -- DEBUG ((EFI_D_INFO, "XhcAsyncInterruptTransfer: remove old transfer for addr %d, Status = %r\n", DeviceAddress, Status)); -+ DEBUG ((DEBUG_INFO, "XhcAsyncInterruptTransfer: remove old transfer for addr %d, Status = %r\n", DeviceAddress, Status)); - goto ON_EXIT; - } - - Status = EFI_SUCCESS; - - if (XhcIsHalt (Xhc) || XhcIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcAsyncInterruptTransfer: HC is halt\n")); -+ DEBUG ((DEBUG_ERROR, "XhcAsyncInterruptTransfer: HC is halt\n")); - Status = EFI_DEVICE_ERROR; - goto ON_EXIT; - } -@@ -1508,7 +1508,7 @@ XhcSyncInterruptTransfer ( - Status = EFI_DEVICE_ERROR; - - if (XhcIsHalt (Xhc) || XhcIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: HC is halt\n")); -+ DEBUG ((DEBUG_ERROR, "EhcSyncInterruptTransfer: HC is halt\n")); - goto ON_EXIT; - } - -@@ -1536,7 +1536,7 @@ XhcSyncInterruptTransfer ( - - ON_EXIT: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "XhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - gBS->RestoreTPL (OldTpl); - -@@ -1805,14 +1805,14 @@ XhcCreateUsbHc ( - Xhc->UsbLegSupOffset = XhcGetCapabilityAddr (Xhc, XHC_CAP_USB_LEGACY); - Xhc->DebugCapSupOffset = XhcGetCapabilityAddr (Xhc, XHC_CAP_USB_DEBUG); - -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: Capability length 0x%x\n", Xhc->CapLength)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: HcSParams1 0x%x\n", Xhc->HcSParams1)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: HcSParams2 0x%x\n", Xhc->HcSParams2)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: HcCParams 0x%x\n", Xhc->HcCParams)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: DBOff 0x%x\n", Xhc->DBOff)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: RTSOff 0x%x\n", Xhc->RTSOff)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: UsbLegSupOffset 0x%x\n", Xhc->UsbLegSupOffset)); -- DEBUG ((EFI_D_INFO, "XhcCreateUsb3Hc: DebugCapSupOffset 0x%x\n", Xhc->DebugCapSupOffset)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: Capability length 0x%x\n", Xhc->CapLength)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: HcSParams1 0x%x\n", Xhc->HcSParams1)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: HcSParams2 0x%x\n", Xhc->HcSParams2)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: HcCParams 0x%x\n", Xhc->HcCParams)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: DBOff 0x%x\n", Xhc->DBOff)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: RTSOff 0x%x\n", Xhc->RTSOff)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: UsbLegSupOffset 0x%x\n", Xhc->UsbLegSupOffset)); -+ DEBUG ((DEBUG_INFO, "XhcCreateUsb3Hc: DebugCapSupOffset 0x%x\n", Xhc->DebugCapSupOffset)); - - // - // Create AsyncRequest Polling Timer -@@ -1972,7 +1972,7 @@ XhcDriverBindingStart ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to enable controller\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDriverBindingStart: failed to enable controller\n")); - goto CLOSE_PCIIO; - } - -@@ -1982,7 +1982,7 @@ XhcDriverBindingStart ( - Xhc = XhcCreateUsbHc (PciIo, HcDevicePath, OriginalPciAttributes); - - if (Xhc == NULL) { -- DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to create USB2_HC\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDriverBindingStart: failed to create USB2_HC\n")); - return EFI_OUT_OF_RESOURCES; - } - -@@ -2000,7 +2000,7 @@ XhcDriverBindingStart ( - if (!EFI_ERROR (Status)) { - Xhc->Support64BitDma = TRUE; - } else { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n", - __FUNCTION__, Controller, Status)); - } -@@ -2032,7 +2032,7 @@ XhcDriverBindingStart ( - // - Status = gBS->SetTimer (Xhc->PollTimer, TimerPeriodic, XHC_ASYNC_TIMER_INTERVAL); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to start async interrupt monitor\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDriverBindingStart: failed to start async interrupt monitor\n")); - XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT); - goto FREE_POOL; - } -@@ -2078,11 +2078,11 @@ XhcDriverBindingStart ( - &Xhc->Usb2Hc - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDriverBindingStart: failed to install USB2_HC Protocol\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDriverBindingStart: failed to install USB2_HC Protocol\n")); - goto FREE_POOL; - } - -- DEBUG ((EFI_D_INFO, "XhcDriverBindingStart: XHCI started for controller @ %x\n", Controller)); -+ DEBUG ((DEBUG_INFO, "XhcDriverBindingStart: XHCI started for controller @ %x\n", Controller)); - return EFI_SUCCESS; - - FREE_POOL: -@@ -2233,4 +2233,3 @@ XhcDriverBindingStop ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c -index 2bab09415b..70102a7fcf 100644 ---- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c -+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c -@@ -38,7 +38,7 @@ XhcReadCapReg8 ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcReadCapReg: Pci Io read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcReadCapReg: Pci Io read error - %r at %d\n", Status, Offset)); - Data = 0xFF; - } - -@@ -74,7 +74,7 @@ XhcReadCapReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcReadCapReg: Pci Io read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcReadCapReg: Pci Io read error - %r at %d\n", Status, Offset)); - Data = 0xFFFFFFFF; - } - -@@ -112,7 +112,7 @@ XhcReadOpReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset)); - Data = 0xFFFFFFFF; - } - -@@ -148,7 +148,7 @@ XhcWriteOpReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); - } - } - -@@ -185,7 +185,7 @@ XhcWriteDoorBellReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); - } - } - -@@ -219,7 +219,7 @@ XhcReadRuntimeReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcReadRuntimeReg: Pci Io Read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcReadRuntimeReg: Pci Io Read error - %r at %d\n", Status, Offset)); - Data = 0xFFFFFFFF; - } - -@@ -255,7 +255,7 @@ XhcWriteRuntimeReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcWriteRuntimeReg: Pci Io Write error: %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcWriteRuntimeReg: Pci Io Write error: %r at %d\n", Status, Offset)); - } - } - -@@ -289,7 +289,7 @@ XhcReadExtCapReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcReadExtCapReg: Pci Io Read error - %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcReadExtCapReg: Pci Io Read error - %r at %d\n", Status, Offset)); - Data = 0xFFFFFFFF; - } - -@@ -325,7 +325,7 @@ XhcWriteExtCapReg ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcWriteExtCapReg: Pci Io Write error: %r at %d\n", Status, Offset)); -+ DEBUG ((DEBUG_ERROR, "XhcWriteExtCapReg: Pci Io Write error: %r at %d\n", Status, Offset)); - } - } - -@@ -508,7 +508,7 @@ XhcSetBiosOwnership ( - return; - } - -- DEBUG ((EFI_D_INFO, "XhcSetBiosOwnership: called to set BIOS ownership\n")); -+ DEBUG ((DEBUG_INFO, "XhcSetBiosOwnership: called to set BIOS ownership\n")); - - Buffer = XhcReadExtCapReg (Xhc, Xhc->UsbLegSupOffset); - Buffer = ((Buffer & (~USBLEGSP_OS_SEMAPHORE)) | USBLEGSP_BIOS_SEMAPHORE); -@@ -532,7 +532,7 @@ XhcClearBiosOwnership ( - return; - } - -- DEBUG ((EFI_D_INFO, "XhcClearBiosOwnership: called to clear BIOS ownership\n")); -+ DEBUG ((DEBUG_INFO, "XhcClearBiosOwnership: called to clear BIOS ownership\n")); - - Buffer = XhcReadExtCapReg (Xhc, Xhc->UsbLegSupOffset); - Buffer = ((Buffer & (~USBLEGSP_BIOS_SEMAPHORE)) | USBLEGSP_OS_SEMAPHORE); -@@ -666,7 +666,7 @@ XhcResetHC ( - - Status = EFI_SUCCESS; - -- DEBUG ((EFI_D_INFO, "XhcResetHC!\n")); -+ DEBUG ((DEBUG_INFO, "XhcResetHC!\n")); - // - // Host can only be reset when it is halt. If not so, halt it - // -@@ -748,4 +748,3 @@ XhcRunHC ( - Status = XhcWaitOpRegBit (Xhc, XHC_USBSTS_OFFSET, XHC_USBSTS_HALT, FALSE, Timeout); - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c -index 6fcd2be627..92f63c29fc 100644 ---- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c -+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c -@@ -82,7 +82,7 @@ XhcCmdTransfer ( - Status = EFI_DEVICE_ERROR; - - if (XhcIsHalt (Xhc) || XhcIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcCmdTransfer: HC is halted\n")); -+ DEBUG ((DEBUG_ERROR, "XhcCmdTransfer: HC is halted\n")); - goto ON_EXIT; - } - -@@ -92,7 +92,7 @@ XhcCmdTransfer ( - Urb = XhcCreateCmdTrb (Xhc, CmdTrb); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "XhcCmdTransfer: failed to create URB\n")); -+ DEBUG ((DEBUG_ERROR, "XhcCmdTransfer: failed to create URB\n")); - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -@@ -172,7 +172,7 @@ XhcCreateUrb ( - Status = XhcCreateTransferTrb (Xhc, Urb); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcCreateUrb: XhcCreateTransferTrb Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcCreateUrb: XhcCreateTransferTrb Failed, Status = %r\n", Status)); - FreePool (Urb); - Urb = NULL; - } -@@ -269,7 +269,7 @@ XhcCreateTransferTrb ( - Status = Xhc->PciIo->Map (Xhc->PciIo, MapOp, Urb->Data, &Len, &PhyAddr, &Map); - - if (EFI_ERROR (Status) || (Len != Urb->DataLen)) { -- DEBUG ((EFI_D_ERROR, "XhcCreateTransferTrb: Fail to map Urb->Data.\n")); -+ DEBUG ((DEBUG_ERROR, "XhcCreateTransferTrb: Fail to map Urb->Data.\n")); - return EFI_OUT_OF_RESOURCES; - } - -@@ -446,7 +446,7 @@ XhcCreateTransferTrb ( - break; - - default: -- DEBUG ((EFI_D_INFO, "Not supported EPType 0x%x!\n",EPType)); -+ DEBUG ((DEBUG_INFO, "Not supported EPType 0x%x!\n",EPType)); - ASSERT (FALSE); - break; - } -@@ -582,7 +582,7 @@ XhcInitSched ( - XhcWriteOpReg (Xhc, XHC_DCBAAP_OFFSET, XHC_LOW_32BIT(DcbaaPhy)); - XhcWriteOpReg (Xhc, XHC_DCBAAP_OFFSET + 4, XHC_HIGH_32BIT (DcbaaPhy)); - -- DEBUG ((EFI_D_INFO, "XhcInitSched:DCBAA=0x%x\n", (UINT64)(UINTN)Xhc->DCBAA)); -+ DEBUG ((DEBUG_INFO, "XhcInitSched:DCBAA=0x%x\n", (UINT64)(UINTN)Xhc->DCBAA)); - - // - // Define the Command Ring Dequeue Pointer by programming the Command Ring Control Register -@@ -660,14 +660,14 @@ XhcRecoverHaltedEndpoint ( - Dci = XhcEndpointToDci (Urb->Ep.EpAddr, (UINT8)(Urb->Ep.Direction)); - ASSERT (Dci < 32); - -- DEBUG ((EFI_D_INFO, "Recovery Halted Slot = %x,Dci = %x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "Recovery Halted Slot = %x,Dci = %x\n", SlotId, Dci)); - - // - // 1) Send Reset endpoint command to transit from halt to stop state - // - Status = XhcResetEndpoint(Xhc, SlotId, Dci); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcRecoverHaltedEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcRecoverHaltedEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -676,7 +676,7 @@ XhcRecoverHaltedEndpoint ( - // - Status = XhcSetTrDequeuePointer(Xhc, SlotId, Dci, Urb); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcRecoverHaltedEndpoint: Set Transfer Ring Dequeue Pointer Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcRecoverHaltedEndpoint: Set Transfer Ring Dequeue Pointer Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -722,14 +722,14 @@ XhcDequeueTrbFromEndpoint ( - Dci = XhcEndpointToDci (Urb->Ep.EpAddr, (UINT8)(Urb->Ep.Direction)); - ASSERT (Dci < 32); - -- DEBUG ((EFI_D_INFO, "Stop Slot = %x,Dci = %x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "Stop Slot = %x,Dci = %x\n", SlotId, Dci)); - - // - // 1) Send Stop endpoint command to stop xHC from executing of the TDs on the endpoint - // - Status = XhcStopEndpoint(Xhc, SlotId, Dci, Urb); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDequeueTrbFromEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcDequeueTrbFromEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -1159,25 +1159,25 @@ XhcCheckUrbResult ( - case TRB_COMPLETION_STALL_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_STALL; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcCheckUrbResult: STALL_ERROR! Completecode = %x\n",EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: STALL_ERROR! Completecode = %x\n",EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_BABBLE_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_BABBLE; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcCheckUrbResult: BABBLE_ERROR! Completecode = %x\n",EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: BABBLE_ERROR! Completecode = %x\n",EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_DATA_BUFFER_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_BUFFER; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcCheckUrbResult: ERR_BUFFER! Completecode = %x\n",EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: ERR_BUFFER! Completecode = %x\n",EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_USB_TRANSACTION_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n",EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n",EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_STOPPED: -@@ -1193,7 +1193,7 @@ XhcCheckUrbResult ( - case TRB_COMPLETION_SHORT_PACKET: - case TRB_COMPLETION_SUCCESS: - if (EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) { -- DEBUG ((EFI_D_VERBOSE, "XhcCheckUrbResult: short packet happens!\n")); -+ DEBUG ((DEBUG_VERBOSE, "XhcCheckUrbResult: short packet happens!\n")); - } - - TRBType = (UINT8) (TRBPtr->Type); -@@ -1206,7 +1206,7 @@ XhcCheckUrbResult ( - break; - - default: -- DEBUG ((EFI_D_ERROR, "Transfer Default Error Occur! Completecode = 0x%x!\n",EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "Transfer Default Error Occur! Completecode = 0x%x!\n",EvtTrb->Completecode)); - CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT; - CheckedUrb->Finished = TRUE; - goto EXIT; -@@ -1396,7 +1396,7 @@ XhciDelAsyncIntTransfer ( - // - Status = XhcDequeueTrbFromEndpoint (Xhc, Urb); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhciDelAsyncIntTransfer: XhcDequeueTrbFromEndpoint failed\n")); -+ DEBUG ((DEBUG_ERROR, "XhciDelAsyncIntTransfer: XhcDequeueTrbFromEndpoint failed\n")); - } - - RemoveEntryList (&Urb->UrbList); -@@ -1434,7 +1434,7 @@ XhciDelAllAsyncIntTransfers ( - // - Status = XhcDequeueTrbFromEndpoint (Xhc, Urb); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhciDelAllAsyncIntTransfers: XhcDequeueTrbFromEndpoint failed\n")); -+ DEBUG ((DEBUG_ERROR, "XhciDelAllAsyncIntTransfers: XhcDequeueTrbFromEndpoint failed\n")); - } - - RemoveEntryList (&Urb->UrbList); -@@ -1644,7 +1644,7 @@ XhcMonitorAsyncRequests ( - // - Status = XhcFlushAsyncIntMap (Xhc, Urb); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcMonitorAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n")); -+ DEBUG ((DEBUG_ERROR, "XhcMonitorAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n")); - } - - // -@@ -2139,11 +2139,11 @@ XhcInitializeDeviceSlot ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcInitializeDeviceSlot: Enable Slot Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcInitializeDeviceSlot: Enable Slot Failed, Status = %r\n", Status)); - return Status; - } - ASSERT (EvtTrb->SlotId <= Xhc->MaxSlotsEn); -- DEBUG ((EFI_D_INFO, "Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); -+ DEBUG ((DEBUG_INFO, "Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); - SlotId = (UINT8)EvtTrb->SlotId; - ASSERT (SlotId != 0); - -@@ -2296,7 +2296,7 @@ XhcInitializeDeviceSlot ( - ); - if (!EFI_ERROR (Status)) { - DeviceAddress = (UINT8) ((DEVICE_CONTEXT *) OutputContext)->Slot.DeviceAddress; -- DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAddress)); -+ DEBUG ((DEBUG_INFO, " Address %d assigned successfully\n", DeviceAddress)); - Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; - } else { - DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); -@@ -2352,11 +2352,11 @@ XhcInitializeDeviceSlot64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcInitializeDeviceSlot64: Enable Slot Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcInitializeDeviceSlot64: Enable Slot Failed, Status = %r\n", Status)); - return Status; - } - ASSERT (EvtTrb->SlotId <= Xhc->MaxSlotsEn); -- DEBUG ((EFI_D_INFO, "Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); -+ DEBUG ((DEBUG_INFO, "Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); - SlotId = (UINT8)EvtTrb->SlotId; - ASSERT (SlotId != 0); - -@@ -2509,7 +2509,7 @@ XhcInitializeDeviceSlot64 ( - ); - if (!EFI_ERROR (Status)) { - DeviceAddress = (UINT8) ((DEVICE_CONTEXT_64 *) OutputContext)->Slot.DeviceAddress; -- DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAddress)); -+ DEBUG ((DEBUG_INFO, " Address %d assigned successfully\n", DeviceAddress)); - Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; - } else { - DEBUG ((DEBUG_ERROR, " Slot %d address not assigned successfully. Status = %r\n", SlotId, Status)); -@@ -2556,7 +2556,7 @@ XhcDisableSlotCmd ( - Status = XhcDisableSlotCmd (Xhc, Xhc->UsbDevContext[Index + 1].SlotId); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDisableSlotCmd: failed to disable child, ignore error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDisableSlotCmd: failed to disable child, ignore error\n")); - Xhc->UsbDevContext[Index + 1].SlotId = 0; - } - } -@@ -2564,7 +2564,7 @@ XhcDisableSlotCmd ( - // - // Construct the disable slot command - // -- DEBUG ((EFI_D_INFO, "Disable device slot %d!\n", SlotId)); -+ DEBUG ((DEBUG_INFO, "Disable device slot %d!\n", SlotId)); - - ZeroMem (&CmdTrbDisSlot, sizeof (CmdTrbDisSlot)); - CmdTrbDisSlot.CycleBit = 1; -@@ -2577,7 +2577,7 @@ XhcDisableSlotCmd ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); - return Status; - } - // -@@ -2663,7 +2663,7 @@ XhcDisableSlotCmd64 ( - Status = XhcDisableSlotCmd64 (Xhc, Xhc->UsbDevContext[Index + 1].SlotId); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDisableSlotCmd: failed to disable child, ignore error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcDisableSlotCmd: failed to disable child, ignore error\n")); - Xhc->UsbDevContext[Index + 1].SlotId = 0; - } - } -@@ -2671,7 +2671,7 @@ XhcDisableSlotCmd64 ( - // - // Construct the disable slot command - // -- DEBUG ((EFI_D_INFO, "Disable device slot %d!\n", SlotId)); -+ DEBUG ((DEBUG_INFO, "Disable device slot %d!\n", SlotId)); - - ZeroMem (&CmdTrbDisSlot, sizeof (CmdTrbDisSlot)); - CmdTrbDisSlot.CycleBit = 1; -@@ -2684,7 +2684,7 @@ XhcDisableSlotCmd64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); - return Status; - } - // -@@ -2851,7 +2851,7 @@ XhcInitializeEndpointContext ( - // - // Do not support isochronous transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext: Unsupport ISO EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unsupport ISO EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - case USB_ENDPOINT_INTERRUPT: -@@ -2903,9 +2903,9 @@ XhcInitializeEndpointContext ( - // - // Do not support control transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext: Unsupport Control EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unsupport Control EP found, Transfer ring is not allocated.\n")); - default: -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext: Unknown EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext: Unknown EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - } -@@ -3043,7 +3043,7 @@ XhcInitializeEndpointContext64 ( - // - // Do not support isochronous transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext64: Unsupport ISO EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport ISO EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - case USB_ENDPOINT_INTERRUPT: -@@ -3095,9 +3095,9 @@ XhcInitializeEndpointContext64 ( - // - // Do not support control transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext64: Unsupport Control EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unsupport Control EP found, Transfer ring is not allocated.\n")); - default: -- DEBUG ((EFI_D_INFO, "XhcInitializeEndpointContext64: Unknown EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcInitializeEndpointContext64: Unknown EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - } -@@ -3192,7 +3192,7 @@ XhcSetConfigCmd ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "Configure Endpoint\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -3200,7 +3200,7 @@ XhcSetConfigCmd ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSetConfigCmd: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcSetConfigCmd: Config Endpoint Failed, Status = %r\n", Status)); - } else { - Xhc->UsbDevContext[SlotId].ActiveConfiguration = ConfigDesc->ConfigurationValue; - } -@@ -3282,7 +3282,7 @@ XhcSetConfigCmd64 ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "Configure Endpoint\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -3290,7 +3290,7 @@ XhcSetConfigCmd64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSetConfigCmd64: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcSetConfigCmd64: Config Endpoint Failed, Status = %r\n", Status)); - } else { - Xhc->UsbDevContext[SlotId].ActiveConfiguration = ConfigDesc->ConfigurationValue; - } -@@ -3323,7 +3323,7 @@ XhcStopEndpoint ( - EVT_TRB_COMMAND_COMPLETION *EvtTrb; - CMD_TRB_STOP_ENDPOINT CmdTrbStopED; - -- DEBUG ((EFI_D_INFO, "XhcStopEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcStopEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); - - // - // When XhcCheckUrbResult waits for the Stop_Endpoint completion, it also checks -@@ -3363,7 +3363,7 @@ XhcStopEndpoint ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcStopEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcStopEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); - } - - Xhc->PendingUrb = NULL; -@@ -3394,7 +3394,7 @@ XhcResetEndpoint ( - EVT_TRB_COMMAND_COMPLETION *EvtTrb; - CMD_TRB_RESET_ENDPOINT CmdTrbResetED; - -- DEBUG ((EFI_D_INFO, "XhcResetEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcResetEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); - - // - // Send stop endpoint command to transit Endpoint from running to stop state -@@ -3411,7 +3411,7 @@ XhcResetEndpoint ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcResetEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcResetEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); - } - - return Status; -@@ -3444,7 +3444,7 @@ XhcSetTrDequeuePointer ( - CMD_SET_TR_DEQ_POINTER CmdSetTRDeq; - EFI_PHYSICAL_ADDRESS PhyAddr; - -- DEBUG ((EFI_D_INFO, "XhcSetTrDequeuePointer: Slot = 0x%x, Dci = 0x%x, Urb = 0x%x\n", SlotId, Dci, Urb)); -+ DEBUG ((DEBUG_INFO, "XhcSetTrDequeuePointer: Slot = 0x%x, Dci = 0x%x, Urb = 0x%x\n", SlotId, Dci, Urb)); - - // - // Send stop endpoint command to transit Endpoint from running to stop state -@@ -3464,7 +3464,7 @@ XhcSetTrDequeuePointer ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSetTrDequeuePointer: Set TR Dequeue Pointer Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcSetTrDequeuePointer: Set TR Dequeue Pointer Failed, Status = %r\n", Status)); - } - - return Status; -@@ -3652,7 +3652,7 @@ XhcSetInterface ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "SetInterface: Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "SetInterface: Configure Endpoint\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -3660,7 +3660,7 @@ XhcSetInterface ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SetInterface: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SetInterface: Config Endpoint Failed, Status = %r\n", Status)); - } else { - // - // Update the active AlternateSetting. -@@ -3854,7 +3854,7 @@ XhcSetInterface64 ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "SetInterface64: Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "SetInterface64: Configure Endpoint\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -3862,7 +3862,7 @@ XhcSetInterface64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SetInterface64: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SetInterface64: Config Endpoint Failed, Status = %r\n", Status)); - } else { - // - // Update the active AlternateSetting. -@@ -3916,7 +3916,7 @@ XhcEvaluateContext ( - CmdTrbEvalu.CycleBit = 1; - CmdTrbEvalu.Type = TRB_TYPE_EVALU_CONTXT; - CmdTrbEvalu.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Evaluate context\n")); -+ DEBUG ((DEBUG_INFO, "Evaluate context\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbEvalu, -@@ -3924,7 +3924,7 @@ XhcEvaluateContext ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcEvaluateContext: Evaluate Context Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcEvaluateContext: Evaluate Context Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -3971,7 +3971,7 @@ XhcEvaluateContext64 ( - CmdTrbEvalu.CycleBit = 1; - CmdTrbEvalu.Type = TRB_TYPE_EVALU_CONTXT; - CmdTrbEvalu.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Evaluate context\n")); -+ DEBUG ((DEBUG_INFO, "Evaluate context\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbEvalu, -@@ -3979,7 +3979,7 @@ XhcEvaluateContext64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcEvaluateContext64: Evaluate Context Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcEvaluateContext64: Evaluate Context Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -4040,7 +4040,7 @@ XhcConfigHubContext ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Hub Slot Context\n")); -+ DEBUG ((DEBUG_INFO, "Configure Hub Slot Context\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -4048,7 +4048,7 @@ XhcConfigHubContext ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcConfigHubContext: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcConfigHubContext: Config Endpoint Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -4108,7 +4108,7 @@ XhcConfigHubContext64 ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Hub Slot Context\n")); -+ DEBUG ((DEBUG_INFO, "Configure Hub Slot Context\n")); - Status = XhcCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -4116,9 +4116,7 @@ XhcConfigHubContext64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcConfigHubContext64: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcConfigHubContext64: Config Endpoint Failed, Status = %r\n", Status)); - } - return Status; - } -- -- -diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c b/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c -index 4b670ebedf..6bdf488413 100644 ---- a/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c -+++ b/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c -@@ -386,7 +386,7 @@ XhcPeiResetHC ( - MicroSecondDelay (1000); - Status = XhcPeiWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout); - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcPeiResetHC: %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiResetHC: %r\n", Status)); - return Status; - } - -@@ -410,7 +410,7 @@ XhcPeiHaltHC ( - - XhcPeiClearOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RUN); - Status = XhcPeiWaitOpRegBit (Xhc, XHC_USBSTS_OFFSET, XHC_USBSTS_HALT, TRUE, Timeout); -- DEBUG ((EFI_D_INFO, "XhcPeiHaltHC: %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiHaltHC: %r\n", Status)); - return Status; - } - -@@ -434,7 +434,7 @@ XhcPeiRunHC ( - - XhcPeiSetOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RUN); - Status = XhcPeiWaitOpRegBit (Xhc, XHC_USBSTS_OFFSET, XHC_USBSTS_HALT, FALSE, Timeout); -- DEBUG ((EFI_D_INFO, "XhcPeiRunHC: %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiRunHC: %r\n", Status)); - return Status; - } - -@@ -544,7 +544,7 @@ XhcPeiControlTransfer ( - Len = 0; - - if (XhcPeiIsHalt (Xhc) || XhcPeiIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiControlTransfer: HC is halted or has system error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiControlTransfer: HC is halted or has system error\n")); - goto ON_EXIT; - } - -@@ -611,7 +611,7 @@ XhcPeiControlTransfer ( - ); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "XhcPeiControlTransfer: failed to create URB")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiControlTransfer: failed to create URB")); - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -@@ -631,7 +631,7 @@ XhcPeiControlTransfer ( - // - RecoveryStatus = XhcPeiDequeueTrbFromEndpoint(Xhc, Urb); - if (EFI_ERROR(RecoveryStatus)) { -- DEBUG((EFI_D_ERROR, "XhcPeiControlTransfer: XhcPeiDequeueTrbFromEndpoint failed\n")); -+ DEBUG((DEBUG_ERROR, "XhcPeiControlTransfer: XhcPeiDequeueTrbFromEndpoint failed\n")); - } - XhcPeiFreeUrb (Xhc, Urb); - goto ON_EXIT; -@@ -641,7 +641,7 @@ XhcPeiControlTransfer ( - } else if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) { - RecoveryStatus = XhcPeiRecoverHaltedEndpoint(Xhc, Urb); - if (EFI_ERROR (RecoveryStatus)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiControlTransfer: XhcPeiRecoverHaltedEndpoint failed\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiControlTransfer: XhcPeiRecoverHaltedEndpoint failed\n")); - } - Status = EFI_DEVICE_ERROR; - XhcPeiFreeUrb (Xhc, Urb); -@@ -718,7 +718,7 @@ XhcPeiControlTransfer ( - // Don't support multi-TT feature for super speed hub now. - // - MTT = 0; -- DEBUG ((EFI_D_ERROR, "XHCI: Don't support multi-TT feature for Hub now. (force to disable MTT)\n")); -+ DEBUG ((DEBUG_ERROR, "XHCI: Don't support multi-TT feature for Hub now. (force to disable MTT)\n")); - } else { - MTT = 0; - } -@@ -825,7 +825,7 @@ XhcPeiControlTransfer ( - ON_EXIT: - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - return Status; -@@ -911,7 +911,7 @@ XhcPeiBulkTransfer ( - Status = EFI_DEVICE_ERROR; - - if (XhcPeiIsHalt (Xhc) || XhcPeiIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiBulkTransfer: HC is halted or has system error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiBulkTransfer: HC is halted or has system error\n")); - goto ON_EXIT; - } - -@@ -942,7 +942,7 @@ XhcPeiBulkTransfer ( - ); - - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "XhcPeiBulkTransfer: failed to create URB\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiBulkTransfer: failed to create URB\n")); - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -@@ -958,7 +958,7 @@ XhcPeiBulkTransfer ( - // - RecoveryStatus = XhcPeiDequeueTrbFromEndpoint(Xhc, Urb); - if (EFI_ERROR(RecoveryStatus)) { -- DEBUG((EFI_D_ERROR, "XhcPeiBulkTransfer: XhcPeiDequeueTrbFromEndpoint failed\n")); -+ DEBUG((DEBUG_ERROR, "XhcPeiBulkTransfer: XhcPeiDequeueTrbFromEndpoint failed\n")); - } - } else { - if (*TransferResult == EFI_USB_NOERROR) { -@@ -966,7 +966,7 @@ XhcPeiBulkTransfer ( - } else if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) { - RecoveryStatus = XhcPeiRecoverHaltedEndpoint(Xhc, Urb); - if (EFI_ERROR (RecoveryStatus)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiBulkTransfer: XhcPeiRecoverHaltedEndpoint failed\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiBulkTransfer: XhcPeiRecoverHaltedEndpoint failed\n")); - } - Status = EFI_DEVICE_ERROR; - } -@@ -977,7 +977,7 @@ XhcPeiBulkTransfer ( - ON_EXIT: - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); - } - - return Status; -@@ -1011,7 +1011,7 @@ XhcPeiGetRootHubPortNumber ( - } - - *PortNumber = XhcDev->HcSParams1.Data.MaxPorts; -- DEBUG ((EFI_D_INFO, "XhcPeiGetRootHubPortNumber: PortNumber = %x\n", *PortNumber)); -+ DEBUG ((DEBUG_INFO, "XhcPeiGetRootHubPortNumber: PortNumber = %x\n", *PortNumber)); - return EFI_SUCCESS; - } - -@@ -1054,7 +1054,7 @@ XhcPeiClearRootHubPortFeature ( - - Offset = (UINT32) (XHC_PORTSC_OFFSET + (0x10 * PortNumber)); - State = XhcPeiReadOpReg (Xhc, Offset); -- DEBUG ((EFI_D_INFO, "XhcPeiClearRootHubPortFeature: Port: %x State: %x\n", PortNumber, State)); -+ DEBUG ((DEBUG_INFO, "XhcPeiClearRootHubPortFeature: Port: %x State: %x\n", PortNumber, State)); - - // - // Mask off the port status change bits, these bits are -@@ -1148,7 +1148,7 @@ XhcPeiClearRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcPeiClearRootHubPortFeature: PortFeature: %x Status = %r\n", PortFeature, Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiClearRootHubPortFeature: PortFeature: %x Status = %r\n", PortFeature, Status)); - return Status; - } - -@@ -1189,7 +1189,7 @@ XhcPeiSetRootHubPortFeature ( - - Offset = (UINT32) (XHC_PORTSC_OFFSET + (0x10 * PortNumber)); - State = XhcPeiReadOpReg (Xhc, Offset); -- DEBUG ((EFI_D_INFO, "XhcPeiSetRootHubPortFeature: Port: %x State: %x\n", PortNumber, State)); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetRootHubPortFeature: Port: %x State: %x\n", PortNumber, State)); - - // - // Mask off the port status change bits, these bits are -@@ -1256,7 +1256,7 @@ XhcPeiSetRootHubPortFeature ( - } - - ON_EXIT: -- DEBUG ((EFI_D_INFO, "XhcPeiSetRootHubPortFeature: PortFeature: %x Status = %r\n", PortFeature, Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetRootHubPortFeature: PortFeature: %x Status = %r\n", PortFeature, Status)); - return Status; - } - -@@ -1307,7 +1307,7 @@ XhcPeiGetRootHubPortStatus ( - - Offset = (UINT32) (XHC_PORTSC_OFFSET + (0x10 * PortNumber)); - State = XhcPeiReadOpReg (Xhc, Offset); -- DEBUG ((EFI_D_INFO, "XhcPeiGetRootHubPortStatus: Port: %x State: %x\n", PortNumber, State)); -+ DEBUG ((DEBUG_INFO, "XhcPeiGetRootHubPortStatus: Port: %x State: %x\n", PortNumber, State)); - - // - // According to XHCI 1.1 spec November 2017, -@@ -1371,7 +1371,7 @@ XhcPeiGetRootHubPortStatus ( - ParentRouteChart.Dword = 0; - XhcPeiPollPortStatusChange (Xhc, ParentRouteChart, PortNumber, PortStatus); - -- DEBUG ((EFI_D_INFO, "XhcPeiGetRootHubPortStatus: PortChangeStatus: %x PortStatus: %x\n", PortStatus->PortChangeStatus, PortStatus->PortStatus)); -+ DEBUG ((DEBUG_INFO, "XhcPeiGetRootHubPortStatus: PortChangeStatus: %x PortStatus: %x\n", PortStatus->PortChangeStatus, PortStatus->PortStatus)); - return EFI_SUCCESS; - } - -@@ -1501,14 +1501,14 @@ XhcPeimEntry ( - PageSize = XhcPeiReadOpReg (XhcDev, XHC_PAGESIZE_OFFSET) & XHC_PAGESIZE_MASK; - XhcDev->PageSize = 1 << (HighBitSet32 (PageSize) + 12); - -- DEBUG ((EFI_D_INFO, "XhciPei: UsbHostControllerBaseAddress: %x\n", XhcDev->UsbHostControllerBaseAddress)); -- DEBUG ((EFI_D_INFO, "XhciPei: CapLength: %x\n", XhcDev->CapLength)); -- DEBUG ((EFI_D_INFO, "XhciPei: HcSParams1: %x\n", XhcDev->HcSParams1.Dword)); -- DEBUG ((EFI_D_INFO, "XhciPei: HcSParams2: %x\n", XhcDev->HcSParams2.Dword)); -- DEBUG ((EFI_D_INFO, "XhciPei: HcCParams: %x\n", XhcDev->HcCParams.Dword)); -- DEBUG ((EFI_D_INFO, "XhciPei: DBOff: %x\n", XhcDev->DBOff)); -- DEBUG ((EFI_D_INFO, "XhciPei: RTSOff: %x\n", XhcDev->RTSOff)); -- DEBUG ((EFI_D_INFO, "XhciPei: PageSize: %x\n", XhcDev->PageSize)); -+ DEBUG ((DEBUG_INFO, "XhciPei: UsbHostControllerBaseAddress: %x\n", XhcDev->UsbHostControllerBaseAddress)); -+ DEBUG ((DEBUG_INFO, "XhciPei: CapLength: %x\n", XhcDev->CapLength)); -+ DEBUG ((DEBUG_INFO, "XhciPei: HcSParams1: %x\n", XhcDev->HcSParams1.Dword)); -+ DEBUG ((DEBUG_INFO, "XhciPei: HcSParams2: %x\n", XhcDev->HcSParams2.Dword)); -+ DEBUG ((DEBUG_INFO, "XhciPei: HcCParams: %x\n", XhcDev->HcCParams.Dword)); -+ DEBUG ((DEBUG_INFO, "XhciPei: DBOff: %x\n", XhcDev->DBOff)); -+ DEBUG ((DEBUG_INFO, "XhciPei: RTSOff: %x\n", XhcDev->RTSOff)); -+ DEBUG ((DEBUG_INFO, "XhciPei: PageSize: %x\n", XhcDev->PageSize)); - - XhcPeiResetHC (XhcDev, XHC_RESET_TIMEOUT); - ASSERT (XhcPeiIsHalt (XhcDev)); -@@ -1551,4 +1551,3 @@ XhcPeimEntry ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c -index 5b9892a1cb..1fc06aaa61 100644 ---- a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c -+++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c -@@ -81,7 +81,7 @@ XhcPeiCmdTransfer ( - Status = EFI_DEVICE_ERROR; - - if (XhcPeiIsHalt (Xhc) || XhcPeiIsSysError (Xhc)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiCmdTransfer: HC is halted or has system error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCmdTransfer: HC is halted or has system error\n")); - goto ON_EXIT; - } - -@@ -90,7 +90,7 @@ XhcPeiCmdTransfer ( - // - Urb = XhcPeiCreateCmdTrb (Xhc, CmdTrb); - if (Urb == NULL) { -- DEBUG ((EFI_D_ERROR, "XhcPeiCmdTransfer: failed to create URB\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCmdTransfer: failed to create URB\n")); - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -@@ -168,7 +168,7 @@ XhcPeiCreateUrb ( - - Status = XhcPeiCreateTransferTrb (Xhc, Urb); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiCreateUrb: XhcPeiCreateTransferTrb Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCreateUrb: XhcPeiCreateTransferTrb Failed, Status = %r\n", Status)); - FreePool (Urb); - Urb = NULL; - } -@@ -439,7 +439,7 @@ XhcPeiCreateTransferTrb ( - break; - - default: -- DEBUG ((EFI_D_INFO, "Not supported EPType 0x%x!\n",EPType)); -+ DEBUG ((DEBUG_INFO, "Not supported EPType 0x%x!\n",EPType)); - ASSERT (FALSE); - break; - } -@@ -478,14 +478,14 @@ XhcPeiRecoverHaltedEndpoint ( - } - Dci = XhcPeiEndpointToDci (Urb->Ep.EpAddr, (UINT8) (Urb->Ep.Direction)); - -- DEBUG ((EFI_D_INFO, "XhcPeiRecoverHaltedEndpoint: Recovery Halted Slot = %x, Dci = %x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcPeiRecoverHaltedEndpoint: Recovery Halted Slot = %x, Dci = %x\n", SlotId, Dci)); - - // - // 1) Send Reset endpoint command to transit from halt to stop state - // - Status = XhcPeiResetEndpoint (Xhc, SlotId, Dci); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiRecoverHaltedEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiRecoverHaltedEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -494,7 +494,7 @@ XhcPeiRecoverHaltedEndpoint ( - // - Status = XhcPeiSetTrDequeuePointer (Xhc, SlotId, Dci, Urb); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiRecoverHaltedEndpoint: Set Dequeue Pointer Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiRecoverHaltedEndpoint: Set Dequeue Pointer Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -537,14 +537,14 @@ XhcPeiDequeueTrbFromEndpoint ( - } - Dci = XhcPeiEndpointToDci (Urb->Ep.EpAddr, (UINT8) (Urb->Ep.Direction)); - -- DEBUG ((EFI_D_INFO, "XhcPeiDequeueTrbFromEndpoint: Stop Slot = %x, Dci = %x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcPeiDequeueTrbFromEndpoint: Stop Slot = %x, Dci = %x\n", SlotId, Dci)); - - // - // 1) Send Stop endpoint command to stop endpoint. - // - Status = XhcPeiStopEndpoint (Xhc, SlotId, Dci); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDequeueTrbFromEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDequeueTrbFromEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -553,7 +553,7 @@ XhcPeiDequeueTrbFromEndpoint ( - // - Status = XhcPeiSetTrDequeuePointer (Xhc, SlotId, Dci, Urb); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDequeueTrbFromEndpoint: Set Dequeue Pointer Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDequeueTrbFromEndpoint: Set Dequeue Pointer Failed, Status = %r\n", Status)); - goto Done; - } - -@@ -683,31 +683,31 @@ XhcPeiCheckUrbResult ( - case TRB_COMPLETION_STALL_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_STALL; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcPeiCheckUrbResult: STALL_ERROR! Completecode = %x\n", EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCheckUrbResult: STALL_ERROR! Completecode = %x\n", EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_BABBLE_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_BABBLE; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcPeiCheckUrbResult: BABBLE_ERROR! Completecode = %x\n", EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCheckUrbResult: BABBLE_ERROR! Completecode = %x\n", EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_DATA_BUFFER_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_BUFFER; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcPeiCheckUrbResult: ERR_BUFFER! Completecode = %x\n", EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCheckUrbResult: ERR_BUFFER! Completecode = %x\n", EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_USB_TRANSACTION_ERROR: - CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT; - CheckedUrb->Finished = TRUE; -- DEBUG ((EFI_D_ERROR, "XhcPeiCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode)); - goto EXIT; - - case TRB_COMPLETION_SHORT_PACKET: - case TRB_COMPLETION_SUCCESS: - if (EvtTrb->Completecode == TRB_COMPLETION_SHORT_PACKET) { -- DEBUG ((EFI_D_VERBOSE, "XhcPeiCheckUrbResult: short packet happens!\n")); -+ DEBUG ((DEBUG_VERBOSE, "XhcPeiCheckUrbResult: short packet happens!\n")); - } - - TRBType = (UINT8) (TRBPtr->Type); -@@ -720,7 +720,7 @@ XhcPeiCheckUrbResult ( - break; - - default: -- DEBUG ((EFI_D_ERROR, "XhcPeiCheckUrbResult: Transfer Default Error Occur! Completecode = 0x%x!\n", EvtTrb->Completecode)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiCheckUrbResult: Transfer Default Error Occur! Completecode = 0x%x!\n", EvtTrb->Completecode)); - CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT; - CheckedUrb->Finished = TRUE; - goto EXIT; -@@ -859,7 +859,7 @@ XhcPeiPollPortStatusChange ( - UINT8 SlotId; - USB_DEV_ROUTE RouteChart; - -- DEBUG ((EFI_D_INFO, "XhcPeiPollPortStatusChange: PortChangeStatus: %x PortStatus: %x\n", PortState->PortChangeStatus, PortState->PortStatus)); -+ DEBUG ((DEBUG_INFO, "XhcPeiPollPortStatusChange: PortChangeStatus: %x PortStatus: %x\n", PortState->PortChangeStatus, PortState->PortStatus)); - - Status = EFI_SUCCESS; - -@@ -1081,11 +1081,11 @@ XhcPeiInitializeDeviceSlot ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiInitializeDeviceSlot: Enable Slot Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiInitializeDeviceSlot: Enable Slot Failed, Status = %r\n", Status)); - return Status; - } - ASSERT (EvtTrb->SlotId <= Xhc->MaxSlotsEn); -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot: Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot: Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); - SlotId = (UINT8) EvtTrb->SlotId; - ASSERT (SlotId != 0); - -@@ -1238,11 +1238,11 @@ XhcPeiInitializeDeviceSlot ( - ); - if (!EFI_ERROR (Status)) { - DeviceAddress = (UINT8) OutputContext->Slot.DeviceAddress; -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot: Address %d assigned successfully\n", DeviceAddress)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot: Address %d assigned successfully\n", DeviceAddress)); - Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; - } - -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot: Enable Slot, Status = %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot: Enable Slot, Status = %r\n", Status)); - return Status; - } - -@@ -1292,11 +1292,11 @@ XhcPeiInitializeDeviceSlot64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiInitializeDeviceSlot64: Enable Slot Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiInitializeDeviceSlot64: Enable Slot Failed, Status = %r\n", Status)); - return Status; - } - ASSERT (EvtTrb->SlotId <= Xhc->MaxSlotsEn); -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot64: Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot64: Enable Slot Successfully, The Slot ID = 0x%x\n", EvtTrb->SlotId)); - SlotId = (UINT8)EvtTrb->SlotId; - ASSERT (SlotId != 0); - -@@ -1449,11 +1449,11 @@ XhcPeiInitializeDeviceSlot64 ( - ); - if (!EFI_ERROR (Status)) { - DeviceAddress = (UINT8) OutputContext->Slot.DeviceAddress; -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot64: Address %d assigned successfully\n", DeviceAddress)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot64: Address %d assigned successfully\n", DeviceAddress)); - Xhc->UsbDevContext[SlotId].XhciDevAddr = DeviceAddress; - } - -- DEBUG ((EFI_D_INFO, "XhcPeiInitializeDeviceSlot64: Enable Slot, Status = %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitializeDeviceSlot64: Enable Slot, Status = %r\n", Status)); - return Status; - } - -@@ -1493,7 +1493,7 @@ XhcPeiDisableSlotCmd ( - Status = XhcPeiDisableSlotCmd (Xhc, Xhc->UsbDevContext[Index + 1].SlotId); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDisableSlotCmd: failed to disable child, ignore error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDisableSlotCmd: failed to disable child, ignore error\n")); - Xhc->UsbDevContext[Index + 1].SlotId = 0; - } - } -@@ -1501,7 +1501,7 @@ XhcPeiDisableSlotCmd ( - // - // Construct the disable slot command - // -- DEBUG ((EFI_D_INFO, "XhcPeiDisableSlotCmd: Disable device slot %d!\n", SlotId)); -+ DEBUG ((DEBUG_INFO, "XhcPeiDisableSlotCmd: Disable device slot %d!\n", SlotId)); - - ZeroMem (&CmdTrbDisSlot, sizeof (CmdTrbDisSlot)); - CmdTrbDisSlot.CycleBit = 1; -@@ -1514,7 +1514,7 @@ XhcPeiDisableSlotCmd ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDisableSlotCmd: Disable Slot Command Failed, Status = %r\n", Status)); - return Status; - } - // -@@ -1557,7 +1557,7 @@ XhcPeiDisableSlotCmd ( - Xhc->UsbDevContext[SlotId].Enabled = FALSE; - Xhc->UsbDevContext[SlotId].SlotId = 0; - -- DEBUG ((EFI_D_INFO, "XhcPeiDisableSlotCmd: Disable Slot Command, Status = %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiDisableSlotCmd: Disable Slot Command, Status = %r\n", Status)); - return Status; - } - -@@ -1596,7 +1596,7 @@ XhcPeiDisableSlotCmd64 ( - Status = XhcPeiDisableSlotCmd64 (Xhc, Xhc->UsbDevContext[Index + 1].SlotId); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDisableSlotCmd64: failed to disable child, ignore error\n")); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDisableSlotCmd64: failed to disable child, ignore error\n")); - Xhc->UsbDevContext[Index + 1].SlotId = 0; - } - } -@@ -1604,7 +1604,7 @@ XhcPeiDisableSlotCmd64 ( - // - // Construct the disable slot command - // -- DEBUG ((EFI_D_INFO, "XhcPeiDisableSlotCmd64: Disable device slot %d!\n", SlotId)); -+ DEBUG ((DEBUG_INFO, "XhcPeiDisableSlotCmd64: Disable device slot %d!\n", SlotId)); - - ZeroMem (&CmdTrbDisSlot, sizeof (CmdTrbDisSlot)); - CmdTrbDisSlot.CycleBit = 1; -@@ -1617,7 +1617,7 @@ XhcPeiDisableSlotCmd64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiDisableSlotCmd64: Disable Slot Command Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiDisableSlotCmd64: Disable Slot Command Failed, Status = %r\n", Status)); - return Status; - } - // -@@ -1660,7 +1660,7 @@ XhcPeiDisableSlotCmd64 ( - Xhc->UsbDevContext[SlotId].Enabled = FALSE; - Xhc->UsbDevContext[SlotId].SlotId = 0; - -- DEBUG ((EFI_D_INFO, "XhcPeiDisableSlotCmd64: Disable Slot Command, Status = %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "XhcPeiDisableSlotCmd64: Disable Slot Command, Status = %r\n", Status)); - return Status; - } - -@@ -1790,7 +1790,7 @@ XhcPeiSetConfigCmd ( - // - // Do not support isochronous transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd: Unsupport ISO EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd: Unsupport ISO EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - case USB_ENDPOINT_INTERRUPT: -@@ -1833,9 +1833,9 @@ XhcPeiSetConfigCmd ( - // - // Do not support control transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd: Unsupport Control EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd: Unsupport Control EP found, Transfer ring is not allocated.\n")); - default: -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd: Unknown EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd: Unknown EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - } -@@ -1867,7 +1867,7 @@ XhcPeiSetConfigCmd ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "XhcSetConfigCmd: Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "XhcSetConfigCmd: Configure Endpoint\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -1875,7 +1875,7 @@ XhcPeiSetConfigCmd ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSetConfigCmd: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcSetConfigCmd: Config Endpoint Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -2007,7 +2007,7 @@ XhcPeiSetConfigCmd64 ( - // - // Do not support isochronous transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd64: Unsupport ISO EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd64: Unsupport ISO EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - case USB_ENDPOINT_INTERRUPT: -@@ -2050,9 +2050,9 @@ XhcPeiSetConfigCmd64 ( - // - // Do not support control transfer now. - // -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd64: Unsupport Control EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd64: Unsupport Control EP found, Transfer ring is not allocated.\n")); - default: -- DEBUG ((EFI_D_INFO, "XhcPeiSetConfigCmd64: Unknown EP found, Transfer ring is not allocated.\n")); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetConfigCmd64: Unknown EP found, Transfer ring is not allocated.\n")); - EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length); - continue; - } -@@ -2086,7 +2086,7 @@ XhcPeiSetConfigCmd64 ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "XhcSetConfigCmd64: Configure Endpoint\n")); -+ DEBUG ((DEBUG_INFO, "XhcSetConfigCmd64: Configure Endpoint\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -2094,7 +2094,7 @@ XhcPeiSetConfigCmd64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcSetConfigCmd64: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcSetConfigCmd64: Config Endpoint Failed, Status = %r\n", Status)); - } - - return Status; -@@ -2142,7 +2142,7 @@ XhcPeiEvaluateContext ( - CmdTrbEvalu.CycleBit = 1; - CmdTrbEvalu.Type = TRB_TYPE_EVALU_CONTXT; - CmdTrbEvalu.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "XhcEvaluateContext: Evaluate context\n")); -+ DEBUG ((DEBUG_INFO, "XhcEvaluateContext: Evaluate context\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbEvalu, -@@ -2150,7 +2150,7 @@ XhcPeiEvaluateContext ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcEvaluateContext: Evaluate Context Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcEvaluateContext: Evaluate Context Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -2196,7 +2196,7 @@ XhcPeiEvaluateContext64 ( - CmdTrbEvalu.CycleBit = 1; - CmdTrbEvalu.Type = TRB_TYPE_EVALU_CONTXT; - CmdTrbEvalu.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "XhcEvaluateContext64: Evaluate context 64\n")); -+ DEBUG ((DEBUG_INFO, "XhcEvaluateContext64: Evaluate context 64\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbEvalu, -@@ -2204,7 +2204,7 @@ XhcPeiEvaluateContext64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcEvaluateContext64: Evaluate Context Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcEvaluateContext64: Evaluate Context Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -2264,7 +2264,7 @@ XhcPeiConfigHubContext ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Hub Slot Context\n")); -+ DEBUG ((DEBUG_INFO, "Configure Hub Slot Context\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -2272,7 +2272,7 @@ XhcPeiConfigHubContext ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcConfigHubContext: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcConfigHubContext: Config Endpoint Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -2332,7 +2332,7 @@ XhcPeiConfigHubContext64 ( - CmdTrbCfgEP.CycleBit = 1; - CmdTrbCfgEP.Type = TRB_TYPE_CON_ENDPOINT; - CmdTrbCfgEP.SlotId = Xhc->UsbDevContext[SlotId].SlotId; -- DEBUG ((EFI_D_INFO, "Configure Hub Slot Context 64\n")); -+ DEBUG ((DEBUG_INFO, "Configure Hub Slot Context 64\n")); - Status = XhcPeiCmdTransfer ( - Xhc, - (TRB_TEMPLATE *) (UINTN) &CmdTrbCfgEP, -@@ -2340,7 +2340,7 @@ XhcPeiConfigHubContext64 ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "XhcConfigHubContext64: Config Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcConfigHubContext64: Config Endpoint Failed, Status = %r\n", Status)); - } - return Status; - } -@@ -2368,7 +2368,7 @@ XhcPeiStopEndpoint ( - EVT_TRB_COMMAND_COMPLETION *EvtTrb; - CMD_TRB_STOP_ENDPOINT CmdTrbStopED; - -- DEBUG ((EFI_D_INFO, "XhcPeiStopEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcPeiStopEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); - - // - // Send stop endpoint command to transit Endpoint from running to stop state -@@ -2385,7 +2385,7 @@ XhcPeiStopEndpoint ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiStopEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiStopEndpoint: Stop Endpoint Failed, Status = %r\n", Status)); - } - - return Status; -@@ -2414,7 +2414,7 @@ XhcPeiResetEndpoint ( - EVT_TRB_COMMAND_COMPLETION *EvtTrb; - CMD_TRB_RESET_ENDPOINT CmdTrbResetED; - -- DEBUG ((EFI_D_INFO, "XhcPeiResetEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); -+ DEBUG ((DEBUG_INFO, "XhcPeiResetEndpoint: Slot = 0x%x, Dci = 0x%x\n", SlotId, Dci)); - - // - // Send stop endpoint command to transit Endpoint from running to stop state -@@ -2431,7 +2431,7 @@ XhcPeiResetEndpoint ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiResetEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiResetEndpoint: Reset Endpoint Failed, Status = %r\n", Status)); - } - - return Status; -@@ -2464,7 +2464,7 @@ XhcPeiSetTrDequeuePointer ( - CMD_SET_TR_DEQ_POINTER CmdSetTRDeq; - EFI_PHYSICAL_ADDRESS PhyAddr; - -- DEBUG ((EFI_D_INFO, "XhcPeiSetTrDequeuePointer: Slot = 0x%x, Dci = 0x%x, Urb = 0x%x\n", SlotId, Dci, Urb)); -+ DEBUG ((DEBUG_INFO, "XhcPeiSetTrDequeuePointer: Slot = 0x%x, Dci = 0x%x, Urb = 0x%x\n", SlotId, Dci, Urb)); - - // - // Send stop endpoint command to transit Endpoint from running to stop state -@@ -2484,7 +2484,7 @@ XhcPeiSetTrDequeuePointer ( - (TRB_TEMPLATE **) (UINTN) &EvtTrb - ); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "XhcPeiSetTrDequeuePointer: Set TR Dequeue Pointer Failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "XhcPeiSetTrDequeuePointer: Set TR Dequeue Pointer Failed, Status = %r\n", Status)); - } - - return Status; -@@ -2938,7 +2938,7 @@ XhcPeiInitSched ( - XhcPeiWriteOpReg (Xhc, XHC_DCBAAP_OFFSET, XHC_LOW_32BIT (DcbaaPhy)); - XhcPeiWriteOpReg (Xhc, XHC_DCBAAP_OFFSET + 4, XHC_HIGH_32BIT (DcbaaPhy)); - -- DEBUG ((EFI_D_INFO, "XhcPeiInitSched:DCBAA=0x%x\n", Xhc->DCBAA)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitSched:DCBAA=0x%x\n", Xhc->DCBAA)); - - // - // Define the Command Ring Dequeue Pointer by programming the Command Ring Control Register -@@ -2962,7 +2962,7 @@ XhcPeiInitSched ( - XhcPeiWriteOpReg (Xhc, XHC_CRCR_OFFSET, XHC_LOW_32BIT (CmdRingPhy)); - XhcPeiWriteOpReg (Xhc, XHC_CRCR_OFFSET + 4, XHC_HIGH_32BIT (CmdRingPhy)); - -- DEBUG ((EFI_D_INFO, "XhcPeiInitSched:XHC_CRCR=0x%x\n", Xhc->CmdRing.RingSeg0)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitSched:XHC_CRCR=0x%x\n", Xhc->CmdRing.RingSeg0)); - - // - // Disable the 'interrupter enable' bit in USB_CMD -@@ -2978,7 +2978,7 @@ XhcPeiInitSched ( - // Allocate EventRing for Cmd, Ctrl, Bulk, Interrupt, AsynInterrupt transfer - // - XhcPeiCreateEventRing (Xhc, &Xhc->EventRing); -- DEBUG ((EFI_D_INFO, "XhcPeiInitSched:XHC_EVENTRING=0x%x\n", Xhc->EventRing.EventRingSeg0)); -+ DEBUG ((DEBUG_INFO, "XhcPeiInitSched:XHC_EVENTRING=0x%x\n", Xhc->EventRing.EventRingSeg0)); - } - - /** -@@ -3031,4 +3031,3 @@ XhcPeiFreeSched ( - Xhc->MemPool = NULL; - } - } -- -diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c -index c80e78fa8a..b35d92fcd7 100644 ---- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c -+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c -@@ -1420,7 +1420,7 @@ ScsiDiskAsyncUnmapNotify ( - Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus); - if (EFI_ERROR(Status)) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "ScsiDiskAsyncUnmapNotify: Host adapter indicating error status 0x%x.\n", - CommandPacket->HostAdapterStatus - )); -@@ -1432,7 +1432,7 @@ ScsiDiskAsyncUnmapNotify ( - Status = CheckTargetStatus (CommandPacket->TargetStatus); - if (EFI_ERROR(Status)) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "ScsiDiskAsyncUnmapNotify: Target indicating error status 0x%x.\n", - CommandPacket->HostAdapterStatus - )); -@@ -1614,7 +1614,7 @@ ScsiDiskUnmap ( - Status = CheckHostAdapterStatus (CommandPacket->HostAdapterStatus); - if (EFI_ERROR(Status)) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "ScsiDiskUnmap: Host adapter indicating error status 0x%x.\n", - CommandPacket->HostAdapterStatus - )); -@@ -1626,7 +1626,7 @@ ScsiDiskUnmap ( - Status = CheckTargetStatus (CommandPacket->TargetStatus); - if (EFI_ERROR(Status)) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "ScsiDiskUnmap: Target indicating error status 0x%x.\n", - CommandPacket->HostAdapterStatus - )); -@@ -2510,7 +2510,7 @@ ScsiDiskInquiryDevice ( - // Sanity checks for coping with broken devices - // - if (PageLength > sizeof SupportedVpdPages->SupportedVpdPageList) { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "%a: invalid PageLength (%u) in Supported VPD Pages page\n", - __FUNCTION__, (UINT32)PageLength)); - PageLength = 0; -@@ -2519,7 +2519,7 @@ ScsiDiskInquiryDevice ( - if ((PageLength > 0) && - (SupportedVpdPages->SupportedVpdPageList[0] != - EFI_SCSI_PAGE_CODE_SUPPORTED_VPD)) { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "%a: Supported VPD Pages page doesn't start with code 0x%02x\n", - __FUNCTION__, EFI_SCSI_PAGE_CODE_SUPPORTED_VPD)); - PageLength = 0; -@@ -2535,7 +2535,7 @@ ScsiDiskInquiryDevice ( - if ((Index > 0) && - (SupportedVpdPages->SupportedVpdPageList[Index] <= - SupportedVpdPages->SupportedVpdPageList[Index - 1])) { -- DEBUG ((EFI_D_WARN, -+ DEBUG ((DEBUG_WARN, - "%a: non-ascending code in Supported VPD Pages page @ %u\n", - __FUNCTION__, Index)); - Index = 0; -@@ -2861,30 +2861,30 @@ DetectMediaParsingSenseKeys ( - ScsiDiskDevice->BlkIo.Media->MediaPresent = FALSE; - ScsiDiskDevice->BlkIo.Media->LastBlock = 0; - *Action = ACTION_NO_ACTION; -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskIsNoMedia\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsNoMedia\n")); - return EFI_SUCCESS; - } - - if (ScsiDiskIsMediaChange (SenseData, NumberOfSenseKeys)) { - ScsiDiskDevice->BlkIo.Media->MediaId++; -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskIsMediaChange!\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsMediaChange!\n")); - return EFI_SUCCESS; - } - - if (ScsiDiskIsResetBefore (SenseData, NumberOfSenseKeys)) { - *Action = ACTION_RETRY_COMMAND_LATER; -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskIsResetBefore!\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsResetBefore!\n")); - return EFI_SUCCESS; - } - - if (ScsiDiskIsMediaError (SenseData, NumberOfSenseKeys)) { -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskIsMediaError\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsMediaError\n")); - *Action = ACTION_RETRY_WITH_BACKOFF_ALGO; - return EFI_DEVICE_ERROR; - } - - if (ScsiDiskIsHardwareError (SenseData, NumberOfSenseKeys)) { -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskIsHardwareError\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskIsHardwareError\n")); - *Action = ACTION_RETRY_WITH_BACKOFF_ALGO; - return EFI_DEVICE_ERROR; - } -@@ -2892,7 +2892,7 @@ DetectMediaParsingSenseKeys ( - if (!ScsiDiskIsDriveReady (SenseData, NumberOfSenseKeys, &RetryLater)) { - if (RetryLater) { - *Action = ACTION_RETRY_COMMAND_LATER; -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: ScsiDiskDriveNotReady!\n")); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: ScsiDiskDriveNotReady!\n")); - return EFI_SUCCESS; - } - *Action = ACTION_NO_ACTION; -@@ -2900,7 +2900,7 @@ DetectMediaParsingSenseKeys ( - } - - *Action = ACTION_RETRY_WITH_BACKOFF_ALGO; -- DEBUG ((EFI_D_VERBOSE, "ScsiDisk: Sense Key = 0x%x ASC = 0x%x!\n", SenseData->Sense_Key, SenseData->Addnl_Sense_Code)); -+ DEBUG ((DEBUG_VERBOSE, "ScsiDisk: Sense Key = 0x%x ASC = 0x%x!\n", SenseData->Sense_Key, SenseData->Addnl_Sense_Code)); - return EFI_SUCCESS; - } - -@@ -4206,7 +4206,7 @@ BackOff: - } - - if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) { -- DEBUG ((EFI_D_ERROR, "ScsiDiskRead10: Check Condition happened!\n")); -+ DEBUG ((DEBUG_ERROR, "ScsiDiskRead10: Check Condition happened!\n")); - Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action); - if (Action == ACTION_RETRY_COMMAND_LATER) { - *NeedRetry = TRUE; -@@ -4330,7 +4330,7 @@ BackOff: - } - - if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) { -- DEBUG ((EFI_D_ERROR, "ScsiDiskWrite10: Check Condition happened!\n")); -+ DEBUG ((DEBUG_ERROR, "ScsiDiskWrite10: Check Condition happened!\n")); - Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action); - if (Action == ACTION_RETRY_COMMAND_LATER) { - *NeedRetry = TRUE; -@@ -4453,7 +4453,7 @@ BackOff: - } - - if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) { -- DEBUG ((EFI_D_ERROR, "ScsiDiskRead16: Check Condition happened!\n")); -+ DEBUG ((DEBUG_ERROR, "ScsiDiskRead16: Check Condition happened!\n")); - Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action); - if (Action == ACTION_RETRY_COMMAND_LATER) { - *NeedRetry = TRUE; -@@ -4577,7 +4577,7 @@ BackOff: - } - - if ((TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) || (EFI_ERROR (ReturnStatus))) { -- DEBUG ((EFI_D_ERROR, "ScsiDiskWrite16: Check Condition happened!\n")); -+ DEBUG ((DEBUG_ERROR, "ScsiDiskWrite16: Check Condition happened!\n")); - Status = DetectMediaParsingSenseKeys (ScsiDiskDevice, ScsiDiskDevice->SenseData, SenseDataLength / sizeof (EFI_SCSI_SENSE_DATA), &Action); - if (Action == ACTION_RETRY_COMMAND_LATER) { - *NeedRetry = TRUE; -@@ -4686,7 +4686,7 @@ ScsiDiskNotify ( - } - - if (Request->TargetStatus == EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION) { -- DEBUG ((EFI_D_ERROR, "ScsiDiskNotify: Check Condition happened!\n")); -+ DEBUG ((DEBUG_ERROR, "ScsiDiskNotify: Check Condition happened!\n")); - - Status = DetectMediaParsingSenseKeys ( - ScsiDiskDevice, -@@ -5948,7 +5948,7 @@ DetermineInstallEraseBlock ( - if (((CapacityData16->LowestAlignLogic2 & BIT7) == 0) || - ((CapacityData16->LowestAlignLogic2 & BIT6) == 0)) { - DEBUG (( -- EFI_D_VERBOSE, -+ DEBUG_VERBOSE, - "ScsiDisk EraseBlock: Either TPE or TPRZ is not set: 0x%x.\n", - CapacityData16->LowestAlignLogic2 - )); -@@ -5958,7 +5958,7 @@ DetermineInstallEraseBlock ( - } - } else { - DEBUG (( -- EFI_D_VERBOSE, -+ DEBUG_VERBOSE, - "ScsiDisk EraseBlock: ReadCapacity16 failed with status %r.\n", - CommandStatus - )); -@@ -5973,7 +5973,7 @@ DetermineInstallEraseBlock ( - if ((ScsiDiskDevice->UnmapInfo.MaxLbaCnt == 0) || - (ScsiDiskDevice->UnmapInfo.MaxBlkDespCnt == 0)) { - DEBUG (( -- EFI_D_VERBOSE, -+ DEBUG_VERBOSE, - "ScsiDisk EraseBlock: The device server does not implement the UNMAP command.\n" - )); - -diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c -index 267db4a89d..bf4498df55 100644 ---- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c -+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c -@@ -741,7 +741,7 @@ InitializeEmmcBlockIoPeim ( - continue; - } - if (Capability.SlotType != 0x1) { -- DEBUG ((EFI_D_INFO, "The slot at 0x%x is not embedded slot type\n", MmioBase[Index])); -+ DEBUG ((DEBUG_INFO, "The slot at 0x%x is not embedded slot type\n", MmioBase[Index])); - Status = EFI_UNSUPPORTED; - continue; - } -@@ -773,12 +773,12 @@ InitializeEmmcBlockIoPeim ( - - ExtCsd = &Slot->ExtCsd; - if (ExtCsd->ExtCsdRev < 5) { -- DEBUG ((EFI_D_ERROR, "The EMMC device version is too low, we don't support!!!\n")); -+ DEBUG ((DEBUG_ERROR, "The EMMC device version is too low, we don't support!!!\n")); - Status = EFI_UNSUPPORTED; - continue; - } - if ((ExtCsd->PartitioningSupport & BIT0) != BIT0) { -- DEBUG ((EFI_D_ERROR, "The EMMC device doesn't support Partition Feature!!!\n")); -+ DEBUG ((DEBUG_ERROR, "The EMMC device doesn't support Partition Feature!!!\n")); - Status = EFI_UNSUPPORTED; - continue; - } -diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c -index 287a10266a..d7f9e107c4 100644 ---- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c -+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c -@@ -304,7 +304,7 @@ EmmcPeimHcReset ( - Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_SW_RST, FALSE, sizeof (SwReset), &SwReset); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimHcReset: write full 1 fails: %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimHcReset: write full 1 fails: %r\n", Status)); - return Status; - } - -@@ -316,7 +316,7 @@ EmmcPeimHcReset ( - EMMC_TIMEOUT - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "EmmcPeimHcReset: reset done with %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "EmmcPeimHcReset: reset done with %r\n", Status)); - return Status; - } - // -@@ -556,7 +556,7 @@ EmmcPeimHcClockSupply ( - } - } - -- DEBUG ((EFI_D_INFO, "BaseClkFreq %dMHz Divisor %d ClockFreq %dKhz\n", BaseClkFreq, Divisor, ClockFreq)); -+ DEBUG ((DEBUG_INFO, "BaseClkFreq %dMHz Divisor %d ClockFreq %dKhz\n", BaseClkFreq, Divisor, ClockFreq)); - - Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_CTRL_VER, TRUE, sizeof (ControllerVer), &ControllerVer); - if (EFI_ERROR (Status)) { -@@ -578,7 +578,7 @@ EmmcPeimHcClockSupply ( - ASSERT (Divisor <= 0x80); - ClockCtrl = (Divisor & 0xFF) << 8; - } else { -- DEBUG ((EFI_D_ERROR, "Unknown SD Host Controller Spec version [0x%x]!!!\n", ControllerVer)); -+ DEBUG ((DEBUG_ERROR, "Unknown SD Host Controller Spec version [0x%x]!!!\n", ControllerVer)); - return EFI_UNSUPPORTED; - } - -@@ -596,7 +596,7 @@ EmmcPeimHcClockSupply ( - ClockCtrl |= BIT0; - Status = EmmcPeimHcRwMmio (Bar + EMMC_HC_CLOCK_CTRL, FALSE, sizeof (ClockCtrl), &ClockCtrl); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set SDCLK Frequency Select and Internal Clock Enable fields fails\n")); -+ DEBUG ((DEBUG_ERROR, "Set SDCLK Frequency Select and Internal Clock Enable fields fails\n")); - return Status; - } - -@@ -936,7 +936,7 @@ BuildAdmaDescTable ( - // for 32-bit address descriptor table. - // - if ((Data & (BIT0 | BIT1)) != 0) { -- DEBUG ((EFI_D_INFO, "The buffer [0x%x] to construct ADMA desc is not aligned to 4 bytes boundary!\n", Data)); -+ DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is not aligned to 4 bytes boundary!\n", Data)); - } - - Entries = DivU64x32 ((DataLen + ADMA_MAX_DATA_PER_LINE - 1), ADMA_MAX_DATA_PER_LINE); -@@ -2330,7 +2330,7 @@ EmmcPeimTuningClkForHs200 ( - } - } while (++Retry < 40); - -- DEBUG ((EFI_D_ERROR, "EmmcPeimTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2)); - // - // Abort the tuning procedure and reset the tuning circuit. - // -@@ -2720,7 +2720,7 @@ EmmcPeimSetBusMode ( - - Status = EmmcPeimGetCsd (Slot, Rca, &Slot->Csd); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimSetBusMode: EmmcPeimGetCsd fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimSetBusMode: EmmcPeimGetCsd fails with %r\n", Status)); - return Status; - } - -@@ -2732,13 +2732,13 @@ EmmcPeimSetBusMode ( - - Status = EmmcPeimSelect (Slot, Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimSetBusMode: EmmcPeimSelect fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimSetBusMode: EmmcPeimSelect fails with %r\n", Status)); - return Status; - } - - Status = EmmcPeimHcGetCapability (Slot->EmmcHcBase, &Capability); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimSetBusMode: EmmcPeimHcGetCapability fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimSetBusMode: EmmcPeimHcGetCapability fails with %r\n", Status)); - return Status; - } - -@@ -2756,7 +2756,7 @@ EmmcPeimSetBusMode ( - // - Status = EmmcPeimGetExtCsd (Slot, &Slot->ExtCsd); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimSetBusMode: EmmcPeimGetExtCsd fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimSetBusMode: EmmcPeimGetExtCsd fails with %r\n", Status)); - return Status; - } - // -@@ -2802,7 +2802,7 @@ EmmcPeimSetBusMode ( - return EFI_SUCCESS; - } - -- DEBUG ((EFI_D_INFO, "HsTiming %d ClockFreq %d BusWidth %d Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE")); -+ DEBUG ((DEBUG_INFO, "HsTiming %d ClockFreq %d BusWidth %d Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE")); - - if (HsTiming == 3) { - // -@@ -2847,7 +2847,7 @@ EmmcPeimIdentification ( - - Status = EmmcPeimReset (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimReset fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimIdentification: EmmcPeimReset fails with %r\n", Status)); - return Status; - } - -@@ -2856,12 +2856,12 @@ EmmcPeimIdentification ( - do { - Status = EmmcPeimGetOcr (Slot, &Ocr); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails with %r\n", Status)); - return Status; - } - - if (Retry++ == 100) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails too many times\n")); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimIdentification: EmmcPeimGetOcr fails too many times\n")); - return EFI_DEVICE_ERROR; - } - MicroSecondDelay (10 * 1000); -@@ -2869,7 +2869,7 @@ EmmcPeimIdentification ( - - Status = EmmcPeimGetAllCid (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimGetAllCid fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimIdentification: EmmcPeimGetAllCid fails with %r\n", Status)); - return Status; - } - // -@@ -2879,16 +2879,15 @@ EmmcPeimIdentification ( - Rca = 1; - Status = EmmcPeimSetRca (Slot, Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EmmcPeimIdentification: EmmcPeimSetRca fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EmmcPeimIdentification: EmmcPeimSetRca fails with %r\n", Status)); - return Status; - } - // - // Enter Data Tranfer Mode. - // -- DEBUG ((EFI_D_INFO, "Found a EMMC device at slot [%d], RCA [%d]\n", Slot, Rca)); -+ DEBUG ((DEBUG_INFO, "Found a EMMC device at slot [%d], RCA [%d]\n", Slot, Rca)); - - Status = EmmcPeimSetBusMode (Slot, Rca); - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c -index afdc0a57ef..63d77a22fe 100644 ---- a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c -+++ b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c -@@ -34,7 +34,7 @@ AsyncIoCallback ( - Request = (EMMC_REQUEST *) Context; - - DEBUG_CODE_BEGIN (); -- DEBUG ((EFI_D_INFO, "Emmc Async Request: CmdIndex[%d] Arg[%08x] %r\n", -+ DEBUG ((DEBUG_INFO, "Emmc Async Request: CmdIndex[%d] Arg[%08x] %r\n", - Request->SdMmcCmdBlk.CommandIndex, Request->SdMmcCmdBlk.CommandArgument, - Request->Packet.TransactionStatus)); - DEBUG_CODE_END (); -@@ -2158,4 +2158,3 @@ EmmcEraseBlocks ( - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c -index e9095b904c..8dca9a6ee1 100644 ---- a/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c -+++ b/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c -@@ -314,12 +314,12 @@ DiscoverAllPartitions ( - DumpExtCsd (ExtCsd); - - if (ExtCsd->ExtCsdRev < 5) { -- DEBUG ((EFI_D_ERROR, "The EMMC device version is too low, we don't support!!!\n")); -+ DEBUG ((DEBUG_ERROR, "The EMMC device version is too low, we don't support!!!\n")); - return EFI_UNSUPPORTED; - } - - if ((ExtCsd->PartitioningSupport & BIT0) != BIT0) { -- DEBUG ((EFI_D_ERROR, "The EMMC device doesn't support Partition Feature!!!\n")); -+ DEBUG ((DEBUG_ERROR, "The EMMC device doesn't support Partition Feature!!!\n")); - return EFI_UNSUPPORTED; - } - -@@ -1202,4 +1202,3 @@ InitializeEmmcDxe ( - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c -index 1d53fcd23e..ddcd68bef7 100644 ---- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c -+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c -@@ -588,7 +588,7 @@ InitializeSdBlockIoPeim ( - continue; - } - if (Capability.SlotType != 0x1) { -- DEBUG ((EFI_D_INFO, "The slot at 0x%x is not embedded slot type\n", MmioBase[Index])); -+ DEBUG ((DEBUG_INFO, "The slot at 0x%x is not embedded slot type\n", MmioBase[Index])); - Status = EFI_UNSUPPORTED; - continue; - } -diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c -index 756c3063bb..7c8b548b9e 100644 ---- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c -+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c -@@ -304,7 +304,7 @@ SdPeimHcReset ( - Status = SdPeimHcRwMmio (Bar + SD_HC_SW_RST, FALSE, sizeof (SwReset), &SwReset); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimHcReset: write full 1 fails: %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimHcReset: write full 1 fails: %r\n", Status)); - return Status; - } - -@@ -316,7 +316,7 @@ SdPeimHcReset ( - SD_TIMEOUT - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "SdPeimHcReset: reset done with %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "SdPeimHcReset: reset done with %r\n", Status)); - return Status; - } - // -@@ -556,7 +556,7 @@ SdPeimHcClockSupply ( - } - } - -- DEBUG ((EFI_D_INFO, "BaseClkFreq %dMHz Divisor %d ClockFreq %dKhz\n", BaseClkFreq, Divisor, ClockFreq)); -+ DEBUG ((DEBUG_INFO, "BaseClkFreq %dMHz Divisor %d ClockFreq %dKhz\n", BaseClkFreq, Divisor, ClockFreq)); - - Status = SdPeimHcRwMmio (Bar + SD_HC_CTRL_VER, TRUE, sizeof (ControllerVer), &ControllerVer); - if (EFI_ERROR (Status)) { -@@ -578,7 +578,7 @@ SdPeimHcClockSupply ( - ASSERT (Divisor <= 0x80); - ClockCtrl = (Divisor & 0xFF) << 8; - } else { -- DEBUG ((EFI_D_ERROR, "Unknown SD Host Controller Spec version [0x%x]!!!\n", ControllerVer)); -+ DEBUG ((DEBUG_ERROR, "Unknown SD Host Controller Spec version [0x%x]!!!\n", ControllerVer)); - return EFI_UNSUPPORTED; - } - -@@ -596,7 +596,7 @@ SdPeimHcClockSupply ( - ClockCtrl |= BIT0; - Status = SdPeimHcRwMmio (Bar + SD_HC_CLOCK_CTRL, FALSE, sizeof (ClockCtrl), &ClockCtrl); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Set SDCLK Frequency Select and Internal Clock Enable fields fails\n")); -+ DEBUG ((DEBUG_ERROR, "Set SDCLK Frequency Select and Internal Clock Enable fields fails\n")); - return Status; - } - -@@ -936,7 +936,7 @@ BuildAdmaDescTable ( - // for 32-bit address descriptor table. - // - if ((Data & (BIT0 | BIT1)) != 0) { -- DEBUG ((EFI_D_INFO, "The buffer [0x%x] to construct ADMA desc is not aligned to 4 bytes boundary!\n", Data)); -+ DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is not aligned to 4 bytes boundary!\n", Data)); - } - - Entries = DivU64x32 ((DataLen + ADMA_MAX_DATA_PER_LINE - 1), ADMA_MAX_DATA_PER_LINE); -@@ -2549,7 +2549,7 @@ SdPeimTuningClock ( - } - } while (++Retry < 40); - -- DEBUG ((EFI_D_ERROR, "SdPeimTuningClock: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2)); -+ DEBUG ((DEBUG_ERROR, "SdPeimTuningClock: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2)); - // - // Abort the tuning procedure and reset the tuning circuit. - // -@@ -2638,7 +2638,7 @@ SdPeimSetBusMode ( - - Status = SdPeimGetCsd (Slot, Rca, &Slot->Csd); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimGetCsd fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimGetCsd fails with %r\n", Status)); - return Status; - } - -@@ -2649,14 +2649,14 @@ SdPeimSetBusMode ( - - Status = SdPeimSelect (Slot, Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimSelect fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimSelect fails with %r\n", Status)); - return Status; - } - - BusWidth = 4; - Status = SdPeimSwitchBusWidth (Slot, Rca, BusWidth); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimSwitchBusWidth fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimSwitchBusWidth fails with %r\n", Status)); - return Status; - } - -@@ -2689,16 +2689,16 @@ SdPeimSetBusMode ( - AccessMode = 0; - } - -- DEBUG ((EFI_D_INFO, "SdPeimSetBusMode: AccessMode %d ClockFreq %d BusWidth %d\n", AccessMode, ClockFreq, BusWidth)); -+ DEBUG ((DEBUG_INFO, "SdPeimSetBusMode: AccessMode %d ClockFreq %d BusWidth %d\n", AccessMode, ClockFreq, BusWidth)); - - Status = SdPeimSwitch (Slot, AccessMode, 0xF, 0xF, 0xF, TRUE, SwitchResp); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimSwitch fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimSwitch fails with %r\n", Status)); - return Status; - } - - if ((SwitchResp[16] & 0xF) != AccessMode) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimSwitch to AccessMode %d ClockFreq %d BusWidth %d fails! The Switch response is 0x%1x\n", AccessMode, ClockFreq, BusWidth, SwitchResp[16] & 0xF)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimSwitch to AccessMode %d ClockFreq %d BusWidth %d fails! The Switch response is 0x%1x\n", AccessMode, ClockFreq, BusWidth, SwitchResp[16] & 0xF)); - return EFI_DEVICE_ERROR; - } - // -@@ -2725,19 +2725,19 @@ SdPeimSetBusMode ( - - Status = SdPeimHcClockSupply (Slot->SdHcBase, ClockFreq * 1000); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimHcClockSupply %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimHcClockSupply %r\n", Status)); - return Status; - } - - if ((AccessMode == 3) || ((AccessMode == 2) && (Capability.TuningSDR50 != 0))) { - Status = SdPeimTuningClock (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimSetBusMode: SdPeimTuningClock fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimSetBusMode: SdPeimTuningClock fails with %r\n", Status)); - return Status; - } - } - -- DEBUG ((EFI_D_INFO, "SdPeimSetBusMode: SdPeimSetBusMode %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "SdPeimSetBusMode: SdPeimSetBusMode %r\n", Status)); - - return Status; - } -@@ -2776,7 +2776,7 @@ SdPeimIdentification ( - // - Status = SdPeimReset (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing Cmd0 fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing Cmd0 fails with %r\n", Status)); - return Status; - } - // -@@ -2784,7 +2784,7 @@ SdPeimIdentification ( - // - Status = SdPeimVoltageCheck (Slot, 0x1, 0xFF); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing Cmd8 fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing Cmd8 fails with %r\n", Status)); - return Status; - } - // -@@ -2792,7 +2792,7 @@ SdPeimIdentification ( - // - Status = SdioSendOpCond (Slot, 0, FALSE); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Found SDIO device, ignore it as we don't support\n")); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Found SDIO device, ignore it as we don't support\n")); - return EFI_DEVICE_ERROR; - } - // -@@ -2800,7 +2800,7 @@ SdPeimIdentification ( - // - Status = SdPeimSendOpCond (Slot, 0, 0, FALSE, FALSE, FALSE, &Ocr); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing SdPeimSendOpCond fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing SdPeimSendOpCond fails with %r\n", Status)); - return EFI_DEVICE_ERROR; - } - -@@ -2863,12 +2863,12 @@ SdPeimIdentification ( - do { - Status = SdPeimSendOpCond (Slot, 0, Ocr, S18r, Xpc, TRUE, &Ocr); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: SdPeimSendOpCond fails with %r Ocr %x, S18r %x, Xpc %x\n", Status, Ocr, S18r, Xpc)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: SdPeimSendOpCond fails with %r Ocr %x, S18r %x, Xpc %x\n", Status, Ocr, S18r, Xpc)); - return EFI_DEVICE_ERROR; - } - - if (Retry++ == 100) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: SdPeimSendOpCond fails too many times\n")); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: SdPeimSendOpCond fails too many times\n")); - return EFI_DEVICE_ERROR; - } - MicroSecondDelay (10 * 1000); -@@ -2885,7 +2885,7 @@ SdPeimIdentification ( - ((Ocr & BIT24) != 0)) { - Status = SdPeimVoltageSwitch (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing SdPeimVoltageSwitch fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing SdPeimVoltageSwitch fails with %r\n", Status)); - Status = EFI_DEVICE_ERROR; - goto Error; - } else { -@@ -2897,7 +2897,7 @@ SdPeimIdentification ( - - SdPeimHcRwMmio (Slot->SdHcBase + SD_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState); - if (((PresentState >> 20) & 0xF) != 0) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: SwitchVoltage fails with PresentState = 0x%x\n", PresentState)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: SwitchVoltage fails with PresentState = 0x%x\n", PresentState)); - Status = EFI_DEVICE_ERROR; - goto Error; - } -@@ -2908,7 +2908,7 @@ SdPeimIdentification ( - - SdPeimHcRwMmio (Slot->SdHcBase + SD_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2); - if ((HostCtrl2 & BIT3) == 0) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: SwitchVoltage fails with HostCtrl2 = 0x%x\n", HostCtrl2)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: SwitchVoltage fails with HostCtrl2 = 0x%x\n", HostCtrl2)); - Status = EFI_DEVICE_ERROR; - goto Error; - } -@@ -2919,29 +2919,29 @@ SdPeimIdentification ( - - SdPeimHcRwMmio (Slot->SdHcBase + SD_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState); - if (((PresentState >> 20) & 0xF) != 0xF) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: SwitchVoltage fails with PresentState = 0x%x, It should be 0xF\n", PresentState)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: SwitchVoltage fails with PresentState = 0x%x, It should be 0xF\n", PresentState)); - Status = EFI_DEVICE_ERROR; - goto Error; - } - } -- DEBUG ((EFI_D_INFO, "SdPeimIdentification: Switch to 1.8v signal voltage success\n")); -+ DEBUG ((DEBUG_INFO, "SdPeimIdentification: Switch to 1.8v signal voltage success\n")); - } - - Status = SdPeimAllSendCid (Slot); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing SdPeimAllSendCid fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing SdPeimAllSendCid fails with %r\n", Status)); - return Status; - } - - Status = SdPeimSetRca (Slot, &Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SdPeimIdentification: Executing SdPeimSetRca fails with %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "SdPeimIdentification: Executing SdPeimSetRca fails with %r\n", Status)); - return Status; - } - // - // Enter Data Tranfer Mode. - // -- DEBUG ((EFI_D_INFO, "Found a SD device at slot [%d]\n", Slot)); -+ DEBUG ((DEBUG_INFO, "Found a SD device at slot [%d]\n", Slot)); - - Status = SdPeimSetBusMode (Slot, Rca, ((Ocr & BIT24) != 0)); - -diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c -index 721f264377..5a041d3618 100644 ---- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c -+++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c -@@ -30,7 +30,7 @@ AsyncIoCallback ( - Request = (SD_REQUEST *) Context; - - DEBUG_CODE_BEGIN (); -- DEBUG ((EFI_D_INFO, "Sd Async Request: CmdIndex[%d] Arg[%08x] %r\n", -+ DEBUG ((DEBUG_INFO, "Sd Async Request: CmdIndex[%d] Arg[%08x] %r\n", - Request->SdMmcCmdBlk.CommandIndex, Request->SdMmcCmdBlk.CommandArgument, - Request->Packet.TransactionStatus)); - DEBUG_CODE_END (); -@@ -86,7 +86,7 @@ SdSetRca ( - - Status = PassThru->PassThru (PassThru, Device->Slot, &Packet, NULL); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Set RCA succeeds with Resp0 = 0x%x\n", SdMmcStatusBlk.Resp0)); -+ DEBUG ((DEBUG_INFO, "Set RCA succeeds with Resp0 = 0x%x\n", SdMmcStatusBlk.Resp0)); - *Rca = (UINT16)(SdMmcStatusBlk.Resp0 >> 16); - } - -@@ -1378,4 +1378,3 @@ SdEraseBlocks ( - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c b/MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c -index 73bcc181c1..4ca374990d 100644 ---- a/MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c -+++ b/MdeModulePkg/Bus/Sd/SdDxe/SdDxe.c -@@ -201,7 +201,7 @@ DiscoverUserArea ( - - Status = SdSetRca (Device, &Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "DiscoverUserArea(): Assign new Rca = 0x%x fails with %r\n", Rca, Status)); -+ DEBUG ((DEBUG_ERROR, "DiscoverUserArea(): Assign new Rca = 0x%x fails with %r\n", Rca, Status)); - return Status; - } - -@@ -221,7 +221,7 @@ DiscoverUserArea ( - - Status = SdSelect (Device, Rca); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "DiscoverUserArea(): Reselect the device 0x%x fails with %r\n", Rca, Status)); -+ DEBUG ((DEBUG_ERROR, "DiscoverUserArea(): Reselect the device 0x%x fails with %r\n", Rca, Status)); - return Status; - } - -@@ -905,4 +905,3 @@ InitializeSdDxe ( - - return Status; - } -- -diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c -index d79ca3904b..2538f22f42 100644 ---- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c -+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c -@@ -441,21 +441,21 @@ UfsPeimParsingSenseKeys ( - (SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_NO_MEDIA)) { - Media->MediaPresent = FALSE; - *NeedRetry = FALSE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Is No Media\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Is No Media\n")); - return EFI_DEVICE_ERROR; - } - - if ((SenseData->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) && - (SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_CHANGE)) { - *NeedRetry = TRUE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Is Media Change\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Is Media Change\n")); - return EFI_SUCCESS; - } - - if ((SenseData->Sense_Key == EFI_SCSI_SK_UNIT_ATTENTION) && - (SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_RESET)) { - *NeedRetry = TRUE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Was Reset Before\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Was Reset Before\n")); - return EFI_SUCCESS; - } - -@@ -463,13 +463,13 @@ UfsPeimParsingSenseKeys ( - ((SenseData->Sense_Key == EFI_SCSI_SK_NOT_READY) && - (SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN))) { - *NeedRetry = FALSE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Media Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Media Error\n")); - return EFI_DEVICE_ERROR; - } - - if (SenseData->Sense_Key == EFI_SCSI_SK_HARDWARE_ERROR) { - *NeedRetry = FALSE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Hardware Error\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Hardware Error\n")); - return EFI_DEVICE_ERROR; - } - -@@ -477,12 +477,12 @@ UfsPeimParsingSenseKeys ( - (SenseData->Addnl_Sense_Code == EFI_SCSI_ASC_NOT_READY) && - (SenseData->Addnl_Sense_Code_Qualifier == EFI_SCSI_ASCQ_IN_PROGRESS)) { - *NeedRetry = TRUE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Was Reset Before\n")); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Was Reset Before\n")); - return EFI_SUCCESS; - } - - *NeedRetry = FALSE; -- DEBUG ((EFI_D_VERBOSE, "UfsBlockIoPei: Sense Key = 0x%x ASC = 0x%x!\n", SenseData->Sense_Key, SenseData->Addnl_Sense_Code)); -+ DEBUG ((DEBUG_VERBOSE, "UfsBlockIoPei: Sense Key = 0x%x ASC = 0x%x!\n", SenseData->Sense_Key, SenseData->Addnl_Sense_Code)); - return EFI_DEVICE_ERROR; - } - -@@ -1097,7 +1097,7 @@ InitializeUfsBlockIoPeim ( - // - Status = UfsControllerInit (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UfsDevicePei: Host Controller Initialization Error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UfsDevicePei: Host Controller Initialization Error, Status = %r\n", Status)); - Controller++; - continue; - } -@@ -1109,7 +1109,7 @@ InitializeUfsBlockIoPeim ( - // - Status = UfsExecNopCmds (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ufs Sending NOP IN command Error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ufs Sending NOP IN command Error, Status = %r\n", Status)); - Controller++; - continue; - } -@@ -1119,7 +1119,7 @@ InitializeUfsBlockIoPeim ( - // - Status = UfsSetFlag (Private, UfsFlagDevInit); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ufs Set fDeviceInit Flag Error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ufs Set fDeviceInit Flag Error, Status = %r\n", Status)); - Controller++; - continue; - } -@@ -1129,7 +1129,7 @@ InitializeUfsBlockIoPeim ( - // - Status = UfsRwDeviceDesc (Private, TRUE, UfsConfigDesc, 0, 0, &Config, sizeof (UFS_CONFIG_DESC)); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ufs Get Configuration Descriptor Error, Status = %r\n", Status)); - Controller++; - continue; - } -@@ -1137,7 +1137,7 @@ InitializeUfsBlockIoPeim ( - for (Index = 0; Index < UFS_PEIM_MAX_LUNS; Index++) { - if (Config.UnitDescConfParams[Index].LunEn != 0) { - Private->Luns.BitMask |= (BIT0 << Index); -- DEBUG ((EFI_D_INFO, "Ufs %d Lun %d is enabled\n", Controller, Index)); -+ DEBUG ((DEBUG_INFO, "Ufs %d Lun %d is enabled\n", Controller, Index)); - } - } - -diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c -index e450f6f49d..1e47eb7eaa 100644 ---- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c -+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c -@@ -80,34 +80,34 @@ DumpUicCmdExecResult ( - case 0x00: - break; - case 0x01: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - INVALID_MIB_ATTRIBUTE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - INVALID_MIB_ATTRIBUTE\n")); - break; - case 0x02: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - INVALID_MIB_ATTRIBUTE_VALUE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - INVALID_MIB_ATTRIBUTE_VALUE\n")); - break; - case 0x03: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - READ_ONLY_MIB_ATTRIBUTE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - READ_ONLY_MIB_ATTRIBUTE\n")); - break; - case 0x04: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - WRITE_ONLY_MIB_ATTRIBUTE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - WRITE_ONLY_MIB_ATTRIBUTE\n")); - break; - case 0x05: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BAD_INDEX\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BAD_INDEX\n")); - break; - case 0x06: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - LOCKED_MIB_ATTRIBUTE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - LOCKED_MIB_ATTRIBUTE\n")); - break; - case 0x07: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BAD_TEST_FEATURE_INDEX\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BAD_TEST_FEATURE_INDEX\n")); - break; - case 0x08: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - PEER_COMMUNICATION_FAILURE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - PEER_COMMUNICATION_FAILURE\n")); - break; - case 0x09: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - BUSY\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - BUSY\n")); - break; - case 0x0A: -- DEBUG ((EFI_D_VERBOSE, "UIC configuration command fails - DME_FAILURE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC configuration command fails - DME_FAILURE\n")); - break; - default : - ASSERT (FALSE); -@@ -118,7 +118,7 @@ DumpUicCmdExecResult ( - case 0x00: - break; - case 0x01: -- DEBUG ((EFI_D_VERBOSE, "UIC control command fails - FAILURE\n")); -+ DEBUG ((DEBUG_VERBOSE, "UIC control command fails - FAILURE\n")); - break; - default : - ASSERT (FALSE); -@@ -140,34 +140,34 @@ DumpQueryResponseResult ( - { - switch (Result) { - case 0xF6: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Not Readable\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Not Readable\n")); - break; - case 0xF7: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Not Writeable\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Not Writeable\n")); - break; - case 0xF8: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Parameter Already Written\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Parameter Already Written\n")); - break; - case 0xF9: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Length\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Length\n")); - break; - case 0xFA: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Value\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Value\n")); - break; - case 0xFB: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Selector\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Selector\n")); - break; - case 0xFC: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Index\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Index\n")); - break; - case 0xFD: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Idn\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Idn\n")); - break; - case 0xFE: -- DEBUG ((EFI_D_VERBOSE, "Query Response with Invalid Opcode\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with Invalid Opcode\n")); - break; - case 0xFF: -- DEBUG ((EFI_D_VERBOSE, "Query Response with General Failure\n")); -+ DEBUG ((DEBUG_VERBOSE, "Query Response with General Failure\n")); - break; - default : - ASSERT (FALSE); -@@ -325,7 +325,7 @@ UfsInitUtpPrdt ( - - if ((BufferSize & (BIT0 | BIT1)) != 0) { - BufferSize &= ~(BIT0 | BIT1); -- DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-aligned!\n", BufferSize)); -+ DEBUG ((DEBUG_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-aligned!\n", BufferSize)); - } - - if (BufferSize == 0) { -@@ -1190,7 +1190,7 @@ UfsExecScsiCmds ( - // Check the transfer request result. - // - if (Response->Response != 0) { -- DEBUG ((EFI_D_ERROR, "UfsExecScsiCmds() fails with Target Failure\n")); -+ DEBUG ((DEBUG_ERROR, "UfsExecScsiCmds() fails with Target Failure\n")); - Status = EFI_DEVICE_ERROR; - goto Exit; - } -@@ -1324,7 +1324,7 @@ UfsExecUicCommands ( - return EFI_NOT_FOUND; - } - -- DEBUG ((EFI_D_INFO, "UfsblockioPei: found a attached UFS device\n")); -+ DEBUG ((DEBUG_INFO, "UfsblockioPei: found a attached UFS device\n")); - - return EFI_SUCCESS; - } -@@ -1577,25 +1577,25 @@ UfsControllerInit ( - - Status = UfsEnableHostController (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UfsDevicePei: Enable Host Controller Fails, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UfsDevicePei: Enable Host Controller Fails, Status = %r\n", Status)); - return Status; - } - - Status = UfsDeviceDetection (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UfsDevicePei: Device Detection Fails, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UfsDevicePei: Device Detection Fails, Status = %r\n", Status)); - return Status; - } - - Status = UfsInitTaskManagementRequestList (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UfsDevicePei: Task management list initialization Fails, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UfsDevicePei: Task management list initialization Fails, Status = %r\n", Status)); - return Status; - } - - Status = UfsInitTransferRequestList (Private); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UfsDevicePei: Transfer list initialization Fails, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UfsDevicePei: Transfer list initialization Fails, Status = %r\n", Status)); - - if (Private->TmrlMapping != NULL) { - IoMmuFreeBuffer ( -@@ -1609,7 +1609,7 @@ UfsControllerInit ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "UfsDevicePei Finished\n")); -+ DEBUG ((DEBUG_INFO, "UfsDevicePei Finished\n")); - return EFI_SUCCESS; - } - -@@ -1661,8 +1661,7 @@ UfsControllerStop ( - return EFI_DEVICE_ERROR; - } - -- DEBUG ((EFI_D_INFO, "UfsDevicePei: Stop the UFS Host Controller\n")); -+ DEBUG ((DEBUG_INFO, "UfsDevicePei: Stop the UFS Host Controller\n")); - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c -index 41f782a78b..c5ba307e75 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c -+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c -@@ -270,7 +270,7 @@ PeiUsbReadCapacity ( - LastBlock = ((UINT32) Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0; - - if (LastBlock == 0xFFFFFFFF) { -- DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n")); -+ DEBUG ((DEBUG_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n")); - } - - PeiBotDevice->Media.LastBlock = LastBlock; -@@ -341,7 +341,7 @@ PeiUsbReadFormattedCapacity ( - } else { - LastBlock = ((UINT32) FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0; - if (LastBlock == 0xFFFFFFFF) { -- DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n")); -+ DEBUG ((DEBUG_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n")); - } - - PeiBotDevice->Media.LastBlock = LastBlock; -diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c -index 4b4915c019..76b3737032 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c -@@ -168,7 +168,7 @@ UsbIoControlTransfer ( - - goto ON_EXIT; - } -- DEBUG ((EFI_D_INFO, "UsbIoControlTransfer: configure changed!!! Do NOT use old UsbIo!!!\n")); -+ DEBUG ((DEBUG_INFO, "UsbIoControlTransfer: configure changed!!! Do NOT use old UsbIo!!!\n")); - - if (Dev->ActiveConfig != NULL) { - UsbRemoveConfig (Dev); -@@ -837,7 +837,7 @@ UsbIoPortReset ( - Status = HubIf->HubApi->ResetPort (HubIf, Dev->ParentPort); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to reset hub port %d@hub %d, %r \n", -+ DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to reset hub port %d@hub %d, %r \n", - Dev->ParentPort, Dev->ParentAddr, Status)); - - goto ON_EXIT; -@@ -861,13 +861,13 @@ UsbIoPortReset ( - // - // It may fail due to device disconnection or other reasons. - // -- DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n", -+ DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to set address for device %d - %r\n", - Dev->Address, Status)); - - goto ON_EXIT; - } - -- DEBUG (( EFI_D_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address)); -+ DEBUG (( DEBUG_INFO, "UsbIoPortReset: device is now ADDRESSED at %d\n", Dev->Address)); - - // - // Reset the current active configure, after this device -@@ -877,7 +877,7 @@ UsbIoPortReset ( - Status = UsbSetConfig (Dev, Dev->ActiveConfig->Desc.ConfigurationValue); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n", -+ DEBUG (( DEBUG_ERROR, "UsbIoPortReset: failed to set configure for device %d - %r\n", - Dev->Address, Status)); - } - } -@@ -934,7 +934,7 @@ UsbBusBuildProtocol ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to open device path %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to open device path %r\n", Status)); - - FreePool (UsbBus); - return Status; -@@ -967,7 +967,7 @@ UsbBusBuildProtocol ( - ); - - if (EFI_ERROR (Status) && EFI_ERROR (Status2)) { -- DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to open USB_HC/USB2_HC %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to open USB_HC/USB2_HC %r\n", Status)); - - Status = EFI_DEVICE_ERROR; - goto CLOSE_HC; -@@ -995,7 +995,7 @@ UsbBusBuildProtocol ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to install bus protocol %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to install bus protocol %r\n", Status)); - goto CLOSE_HC; - } - -@@ -1043,13 +1043,13 @@ UsbBusBuildProtocol ( - Status = mUsbRootHubApi.Init (RootIf); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to init root hub %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to init root hub %r\n", Status)); - goto FREE_ROOTHUB; - } - - UsbBus->Devices[0] = RootHub; - -- DEBUG ((EFI_D_INFO, "UsbBusStart: usb bus started on %p, root hub %p\n", Controller, RootIf)); -+ DEBUG ((DEBUG_INFO, "UsbBusStart: usb bus started on %p, root hub %p\n", Controller, RootIf)); - return EFI_SUCCESS; - - FREE_ROOTHUB: -@@ -1088,7 +1088,7 @@ CLOSE_HC: - ); - FreePool (UsbBus); - -- DEBUG ((EFI_D_ERROR, "UsbBusStart: Failed to start bus driver %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBusStart: Failed to start bus driver %r\n", Status)); - return Status; - } - -@@ -1448,7 +1448,7 @@ UsbBusControllerDriverStop ( - return ReturnStatus; - } - -- DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller)); -+ DEBUG (( DEBUG_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller)); - - // - // Locate USB_BUS for the current host controller -diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c -index b08188b1bc..4e602228fb 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.c -@@ -272,7 +272,7 @@ UsbParseInterfaceDesc ( - Setting = UsbCreateDesc (DescBuf, Len, USB_DESC_TYPE_INTERFACE, &Used); - - if (Setting == NULL) { -- DEBUG (( EFI_D_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n")); -+ DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n")); - return NULL; - } - -@@ -283,7 +283,7 @@ UsbParseInterfaceDesc ( - // - NumEp = Setting->Desc.NumEndpoints; - -- DEBUG (( EFI_D_INFO, "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n", -+ DEBUG (( DEBUG_INFO, "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n", - Setting->Desc.InterfaceNumber, Setting->Desc.AlternateSetting, (UINT32)NumEp)); - - if (NumEp == 0) { -@@ -303,7 +303,7 @@ UsbParseInterfaceDesc ( - Ep = UsbCreateDesc (DescBuf + Offset, Len - Offset, USB_DESC_TYPE_ENDPOINT, &Used); - - if (Ep == NULL) { -- DEBUG (( EFI_D_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index)); -+ DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index)); - goto ON_ERROR; - } - -@@ -362,7 +362,7 @@ UsbParseConfigDesc ( - goto ON_ERROR; - } - -- DEBUG (( EFI_D_INFO, "UsbParseConfigDesc: config %d has %d interfaces\n", -+ DEBUG (( DEBUG_INFO, "UsbParseConfigDesc: config %d has %d interfaces\n", - Config->Desc.ConfigurationValue, (UINT32)NumIf)); - - for (Index = 0; Index < NumIf; Index++) { -@@ -394,7 +394,7 @@ UsbParseConfigDesc ( - Setting = UsbParseInterfaceDesc (DescBuf, Len, &Consumed); - - if (Setting == NULL) { -- DEBUG (( EFI_D_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n")); -+ DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n")); - break; - - } else if (Setting->Desc.InterfaceNumber >= NumIf) { -@@ -765,13 +765,13 @@ UsbGetOneConfig ( - Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, &Desc, 8); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbGetOneConfig: failed to get descript length(%d) %r\n", -+ DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get descript length(%d) %r\n", - Desc.TotalLength, Status)); - - return NULL; - } - -- DEBUG (( EFI_D_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength)); -+ DEBUG (( DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength)); - - // - // Reject if TotalLength even cannot cover itself. -@@ -789,7 +789,7 @@ UsbGetOneConfig ( - Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, Buf, Desc.TotalLength); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status)); -+ DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status)); - - FreePool (Buf); - return NULL; -@@ -829,7 +829,7 @@ UsbBuildDescTable ( - Status = UsbGetDevDesc (UsbDev); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status)); -+ DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status)); - return Status; - } - -@@ -844,7 +844,7 @@ UsbBuildDescTable ( - return EFI_OUT_OF_RESOURCES; - } - -- DEBUG (( EFI_D_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig)); -+ DEBUG (( DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig)); - - // - // Read each configurations, then parse them -@@ -853,7 +853,7 @@ UsbBuildDescTable ( - Config = UsbGetOneConfig (UsbDev, Index); - - if (Config == NULL) { -- DEBUG (( EFI_D_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index)); -+ DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index)); - - // - // If we can get the default descriptor, it is likely that the -@@ -871,7 +871,7 @@ UsbBuildDescTable ( - FreePool (Config); - - if (ConfigDesc == NULL) { -- DEBUG (( EFI_D_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index)); -+ DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index)); - - // - // If we can get the default descriptor, it is likely that the -@@ -894,7 +894,7 @@ UsbBuildDescTable ( - Status = UsbBuildLangTable (UsbDev); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_INFO, "UsbBuildDescTable: get language ID table %r\n", Status)); -+ DEBUG (( DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status)); - } - - return EFI_SUCCESS; -diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c -index d3e0cfa626..500978a9de 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c -@@ -132,7 +132,7 @@ UsbCreateInterface ( - UsbIf->DevicePath = AppendDevicePathNode (HubIf->DevicePath, &UsbNode.Header); - - if (UsbIf->DevicePath == NULL) { -- DEBUG ((EFI_D_ERROR, "UsbCreateInterface: failed to create device path\n")); -+ DEBUG ((DEBUG_ERROR, "UsbCreateInterface: failed to create device path\n")); - - Status = EFI_OUT_OF_RESOURCES; - goto ON_ERROR; -@@ -148,7 +148,7 @@ UsbCreateInterface ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbCreateInterface: failed to install UsbIo - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbCreateInterface: failed to install UsbIo - %r\n", Status)); - goto ON_ERROR; - } - -@@ -167,7 +167,7 @@ UsbCreateInterface ( - NULL - ); - -- DEBUG ((EFI_D_ERROR, "UsbCreateInterface: failed to open host for child - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbCreateInterface: failed to open host for child - %r\n", Status)); - goto ON_ERROR; - } - -@@ -262,7 +262,7 @@ UsbConnectDriver ( - // connect drivers with this interface - // - if (UsbIsHubInterface (UsbIf)) { -- DEBUG ((EFI_D_INFO, "UsbConnectDriver: found a hub device\n")); -+ DEBUG ((DEBUG_INFO, "UsbConnectDriver: found a hub device\n")); - Status = mUsbHubApi.Init (UsbIf); - - } else { -@@ -279,14 +279,14 @@ UsbConnectDriver ( - // - if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) { - OldTpl = UsbGetCurrentTpl (); -- DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); -+ DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); - - gBS->RestoreTPL (TPL_CALLBACK); - - Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE); - UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status); - -- DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl())); -+ DEBUG ((DEBUG_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl())); - ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK); - - gBS->RaiseTPL (OldTpl); -@@ -340,7 +340,7 @@ UsbSelectSetting ( - IfDesc->ActiveIndex = Index; - - ASSERT (Setting != NULL); -- DEBUG ((EFI_D_INFO, "UsbSelectSetting: setting %d selected for interface %d\n", -+ DEBUG ((DEBUG_INFO, "UsbSelectSetting: setting %d selected for interface %d\n", - Alternate, Setting->Desc.InterfaceNumber)); - - // -@@ -399,7 +399,7 @@ UsbSelectConfig ( - - Device->ActiveConfig = ConfigDesc; - -- DEBUG ((EFI_D_INFO, "UsbSelectConfig: config %d selected for device %d\n", -+ DEBUG ((DEBUG_INFO, "UsbSelectConfig: config %d selected for device %d\n", - ConfigValue, Device->Address)); - - // -@@ -479,7 +479,7 @@ UsbDisconnectDriver ( - // or disconnect at CALLBACK. - // - OldTpl = UsbGetCurrentTpl (); -- DEBUG ((EFI_D_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); -+ DEBUG ((DEBUG_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); - - gBS->RestoreTPL (TPL_CALLBACK); - -@@ -488,7 +488,7 @@ UsbDisconnectDriver ( - UsbIf->IsManaged = FALSE; - } - -- DEBUG (( EFI_D_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status)); -+ DEBUG (( DEBUG_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status)); - ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK); - - gBS->RaiseTPL (OldTpl); -@@ -586,7 +586,7 @@ UsbRemoveDevice ( - } else { - Bus->Devices[Index]->DisconnectFail = TRUE; - ReturnStatus = Status; -- DEBUG ((EFI_D_INFO, "UsbRemoveDevice: failed to remove child %p at parent %p\n", Child, Device)); -+ DEBUG ((DEBUG_INFO, "UsbRemoveDevice: failed to remove child %p at parent %p\n", Child, Device)); - } - } - -@@ -597,7 +597,7 @@ UsbRemoveDevice ( - Status = UsbRemoveConfig (Device); - - if (!EFI_ERROR (Status)) { -- DEBUG (( EFI_D_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address)); -+ DEBUG (( DEBUG_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address)); - - ASSERT (Device->Address < Bus->MaxDevices); - Bus->Devices[Device->Address] = NULL; -@@ -691,13 +691,13 @@ UsbEnumerateNewDev ( - if (ResetIsNeeded) { - Status = HubApi->ResetPort (HubIf, Port); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port, Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port, Status)); - - return Status; - } -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port)); -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port)); - } else { -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port)); -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port)); - } - - Child = UsbCreateDevice (HubIf, Port); -@@ -713,12 +713,12 @@ UsbEnumerateNewDev ( - Status = HubApi->GetPortStatus (HubIf, Port, &PortState); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to get speed of port %d\n", Port)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to get speed of port %d\n", Port)); - goto ON_ERROR; - } - - if (!USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_CONNECTION)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: No device present at port %d\n", Port)); - Status = EFI_NOT_FOUND; - goto ON_ERROR; - } else if (USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_SUPER_SPEED)){ -@@ -735,7 +735,7 @@ UsbEnumerateNewDev ( - Child->MaxPacket0 = 8; - } - -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed)); -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device is of %d speed\n", Child->Speed)); - - if (((Child->Speed == EFI_USB_SPEED_LOW) || (Child->Speed == EFI_USB_SPEED_FULL)) && - (Parent->Speed == EFI_USB_SPEED_HIGH)) { -@@ -751,7 +751,7 @@ UsbEnumerateNewDev ( - } else { - Child->Translator = Parent->Translator; - } -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: device uses translator (%d, %d)\n", -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device uses translator (%d, %d)\n", - Child->Translator.TranslatorHubAddress, - Child->Translator.TranslatorPortNumber)); - -@@ -775,7 +775,7 @@ UsbEnumerateNewDev ( - } - - if (Address >= Bus->MaxDevices) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: address pool is full for port %d\n", Port)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: address pool is full for port %d\n", Port)); - - Status = EFI_ACCESS_DENIED; - goto ON_ERROR; -@@ -786,13 +786,13 @@ UsbEnumerateNewDev ( - Bus->Devices[Address] = Child; - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to set device address - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to set device address - %r\n", Status)); - goto ON_ERROR; - } - - gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL); - -- DEBUG ((EFI_D_INFO, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address)); -+ DEBUG ((DEBUG_INFO, "UsbEnumerateNewDev: device is now ADDRESSED at %d\n", Address)); - - // - // Host sends a Get_Descriptor request to learn the max packet -@@ -801,11 +801,11 @@ UsbEnumerateNewDev ( - Status = UsbGetMaxPacketSize0 (Child); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to get max packet for EP 0 - %r\n", Status)); - goto ON_ERROR; - } - -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0)); -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: max packet size for EP 0 is %d\n", Child->MaxPacket0)); - - // - // Host learns about the device's abilities by requesting device's -@@ -814,7 +814,7 @@ UsbEnumerateNewDev ( - Status = UsbBuildDescTable (Child); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to build descriptor table - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to build descriptor table - %r\n", Status)); - goto ON_ERROR; - } - -@@ -826,11 +826,11 @@ UsbEnumerateNewDev ( - Status = UsbSetConfig (Child, Config); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to set configure %d - %r\n", Config, Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to set configure %d - %r\n", Config, Status)); - goto ON_ERROR; - } - -- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address)); -+ DEBUG (( DEBUG_INFO, "UsbEnumerateNewDev: device %d is now in CONFIGED state\n", Address)); - - // - // Host assigns and loads a device driver. -@@ -838,7 +838,7 @@ UsbEnumerateNewDev ( - Status = UsbSelectConfig (Child, Config); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to create interfaces - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumerateNewDev: failed to create interfaces - %r\n", Status)); - goto ON_ERROR; - } - -@@ -902,7 +902,7 @@ UsbEnumeratePort ( - Status = HubApi->GetPortStatus (HubIf, Port, &PortState); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbEnumeratePort: failed to get state of port %d\n", Port)); -+ DEBUG ((DEBUG_ERROR, "UsbEnumeratePort: failed to get state of port %d\n", Port)); - return Status; - } - -@@ -914,7 +914,7 @@ UsbEnumeratePort ( - return EFI_SUCCESS; - } - -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n", -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: port %d state - %02x, change - %02x on %p\n", - Port, PortState.PortStatus, PortState.PortChangeStatus, HubIf)); - - // -@@ -932,7 +932,7 @@ UsbEnumeratePort ( - // which probably is caused by short circuit. It has to wait system hardware - // to perform recovery. - // -- DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: Critical Over Current\n", Port)); - return EFI_DEVICE_ERROR; - - } -@@ -942,7 +942,7 @@ UsbEnumeratePort ( - // over current. As a result, all ports are nearly power-off, so - // it's necessary to detach and enumerate all ports again. - // -- DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 2.0 device Recovery Over Current\n", Port)); - } - - if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_ENABLE)) { -@@ -952,7 +952,7 @@ UsbEnumeratePort ( - // on 2.0 roothub does. When over-current has influence on 1.1 device, the port - // would be disabled, so it's also necessary to detach and enumerate again. - // -- DEBUG (( EFI_D_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbEnumeratePort: 1.1 device Recovery Over Current\n", Port)); - } - - if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_CONNECTION)) { -@@ -960,7 +960,7 @@ UsbEnumeratePort ( - // Case4: - // Device connected or disconnected normally. - // -- DEBUG ((EFI_D_INFO, "UsbEnumeratePort: Device Connect/Disconnect Normally\n", Port)); -+ DEBUG ((DEBUG_INFO, "UsbEnumeratePort: Device Connect/Disconnect Normally\n", Port)); - } - - // -@@ -969,7 +969,7 @@ UsbEnumeratePort ( - Child = UsbFindChild (HubIf, Port); - - if (Child != NULL) { -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf)); -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf)); - UsbRemoveDevice (Child); - } - -@@ -977,7 +977,7 @@ UsbEnumeratePort ( - // - // Now, new device connected, enumerate and configure the device - // -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port)); -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port)); - if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) { - Status = UsbEnumerateNewDev (HubIf, Port, FALSE); - } else { -@@ -985,7 +985,7 @@ UsbEnumeratePort ( - } - - } else { -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port)); -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port)); - } - - HubApi->ClearPortChange (HubIf, Port); -@@ -1020,7 +1020,7 @@ UsbHubEnumeration ( - for (Index = 0; Index < HubIf->NumOfPort; Index++) { - Child = UsbFindChild (HubIf, Index); - if ((Child != NULL) && (Child->DisconnectFail == TRUE)) { -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf)); -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from hub %p, try again\n", Index, HubIf)); - UsbRemoveDevice (Child); - } - } -@@ -1074,7 +1074,7 @@ UsbRootHubEnumeration ( - for (Index = 0; Index < RootHub->NumOfPort; Index++) { - Child = UsbFindChild (RootHub, Index); - if ((Child != NULL) && (Child->DisconnectFail == TRUE)) { -- DEBUG (( EFI_D_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub)); -+ DEBUG (( DEBUG_INFO, "UsbEnumeratePort: The device disconnect fails at port %d from root hub %p, try again\n", Index, RootHub)); - UsbRemoveDevice (Child); - } - -diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c -index c5bd112511..022bab5fc1 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c -@@ -516,7 +516,7 @@ UsbOnHubInterrupt ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status)); -+ DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to remove async transfer - %r\n", Status)); - return Status; - } - -@@ -531,7 +531,7 @@ UsbOnHubInterrupt ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status)); -+ DEBUG (( DEBUG_ERROR, "UsbOnHubInterrupt: failed to submit new async transfer - %r\n", Status)); - } - - return Status; -@@ -608,7 +608,7 @@ UsbHubInit ( - } - - if (Index == NumEndpoints) { -- DEBUG (( EFI_D_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address)); -+ DEBUG (( DEBUG_ERROR, "UsbHubInit: no interrupt endpoint found for hub %d\n", HubDev->Address)); - return EFI_DEVICE_ERROR; - } - -@@ -620,13 +620,13 @@ UsbHubInit ( - Status = UsbHubReadDesc (HubDev, HubDesc); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status)); -+ DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to read HUB descriptor %r\n", Status)); - return Status; - } - - HubIf->NumOfPort = HubDesc->NumPorts; - -- DEBUG (( EFI_D_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address,HubIf->NumOfPort)); -+ DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d has %d ports\n", HubDev->Address,HubIf->NumOfPort)); - - // - // OK, set IsHub to TRUE. Now usb bus can handle this device -@@ -640,7 +640,7 @@ UsbHubInit ( - - if (HubIf->Device->Speed == EFI_USB_SPEED_SUPER) { - Depth = (UINT16)(HubIf->Device->Tier - 1); -- DEBUG ((EFI_D_INFO, "UsbHubInit: Set Hub Depth as 0x%x\n", Depth)); -+ DEBUG ((DEBUG_INFO, "UsbHubInit: Set Hub Depth as 0x%x\n", Depth)); - UsbHubCtrlSetHubDepth (HubIf->Device, Depth); - - for (Index = 0; Index < HubDesc->NumPorts; Index++) { -@@ -676,7 +676,7 @@ UsbHubInit ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to create signal for hub %d - %r\n", -+ DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to create signal for hub %d - %r\n", - HubDev->Address, Status)); - - return Status; -@@ -701,7 +701,7 @@ UsbHubInit ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n", -+ DEBUG (( DEBUG_ERROR, "UsbHubInit: failed to queue interrupt transfer for hub %d - %r\n", - HubDev->Address, Status)); - - gBS->CloseEvent (HubIf->HubNotify); -@@ -710,7 +710,7 @@ UsbHubInit ( - return Status; - } - -- DEBUG (( EFI_D_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address)); -+ DEBUG (( DEBUG_INFO, "UsbHubInit: hub %d initialized\n", HubDev->Address)); - return Status; - } - -@@ -935,7 +935,7 @@ UsbHubRelease ( - HubIf->HubEp = NULL; - HubIf->HubNotify = NULL; - -- DEBUG (( EFI_D_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address)); -+ DEBUG (( DEBUG_INFO, "UsbHubRelease: hub device %d released\n", HubIf->Device->Address)); - return EFI_SUCCESS; - } - -@@ -966,7 +966,7 @@ UsbRootHubInit ( - return Status; - } - -- DEBUG (( EFI_D_INFO, "UsbRootHubInit: root hub %p - max speed %d, %d ports\n", -+ DEBUG (( DEBUG_INFO, "UsbRootHubInit: root hub %p - max speed %d, %d ports\n", - HubIf, MaxSpeed, NumOfPort)); - - HubIf->IsHub = TRUE; -@@ -1168,7 +1168,7 @@ UsbRootHubResetPort ( - Status = UsbHcSetRootHubPortFeature (Bus, Port, EfiUsbPortReset); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to start reset on port %d\n", Port)); - return Status; - } - -@@ -1181,7 +1181,7 @@ UsbRootHubResetPort ( - Status = UsbHcClearRootHubPortFeature (Bus, Port, EfiUsbPortReset); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to clear reset on port %d\n", Port)); - return Status; - } - -@@ -1208,7 +1208,7 @@ UsbRootHubResetPort ( - } - - if (Index == USB_WAIT_PORT_STS_CHANGE_LOOP) { -- DEBUG ((EFI_D_ERROR, "UsbRootHubResetPort: reset not finished in time on port %d\n", Port)); -+ DEBUG ((DEBUG_ERROR, "UsbRootHubResetPort: reset not finished in time on port %d\n", Port)); - return EFI_TIMEOUT; - } - -@@ -1220,7 +1220,7 @@ UsbRootHubResetPort ( - // automatically enable the port, we need to enable it manually. - // - if (RootIf->MaxSpeed == EFI_USB_SPEED_HIGH) { -- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: release low/full speed device (%d) to UHCI\n", Port)); - - UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortOwner); - return EFI_NOT_FOUND; -@@ -1230,7 +1230,7 @@ UsbRootHubResetPort ( - Status = UsbRootHubSetPortFeature (RootIf, Port, EfiUsbPortEnable); - - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port)); -+ DEBUG (( DEBUG_ERROR, "UsbRootHubResetPort: failed to enable port %d for UHCI\n", Port)); - return Status; - } - -@@ -1256,7 +1256,7 @@ UsbRootHubRelease ( - IN USB_INTERFACE *HubIf - ) - { -- DEBUG (( EFI_D_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf)); -+ DEBUG (( DEBUG_INFO, "UsbRootHubRelease: root hub released for hub %p\n", HubIf)); - - gBS->SetTimer (HubIf->HubNotify, TimerCancel, USB_ROOTHUB_POLL_INTERVAL); - gBS->CloseEvent (HubIf->HubNotify); -diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c -index 7529e03e85..4441466d80 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c -@@ -1212,10 +1212,10 @@ UsbBusRecursivelyConnectWantedUsbIo ( - // - // Recursively connect the wanted Usb Io handle - // -- DEBUG ((EFI_D_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ())); -+ DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ())); - Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE); - UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status); -- DEBUG ((EFI_D_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl())); -+ DEBUG ((DEBUG_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl())); - } - } - } -@@ -1224,4 +1224,3 @@ UsbBusRecursivelyConnectWantedUsbIo ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c -index c44c403890..ce6db0b048 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c -@@ -409,7 +409,7 @@ PeiDoHubConfig ( - PeiUsbDevice->DownStreamPortNo = HubDescriptor->NbrPorts; - - if (PeiUsbDevice->DeviceSpeed == EFI_USB_SPEED_SUPER) { -- DEBUG ((EFI_D_INFO, "PeiDoHubConfig: Set Hub Depth as 0x%x\n", PeiUsbDevice->Tier)); -+ DEBUG ((DEBUG_INFO, "PeiDoHubConfig: Set Hub Depth as 0x%x\n", PeiUsbDevice->Tier)); - PeiUsbHubCtrlSetHubDepth ( - PeiServices, - PeiUsbDevice, -@@ -427,12 +427,12 @@ PeiDoHubConfig ( - EfiUsbPortPower - ); - if (EFI_ERROR (Status)) { -- DEBUG (( EFI_D_ERROR, "PeiDoHubConfig: PeiHubSetPortFeature EfiUsbPortPower failed %x\n", Index)); -+ DEBUG (( DEBUG_ERROR, "PeiDoHubConfig: PeiHubSetPortFeature EfiUsbPortPower failed %x\n", Index)); - continue; - } - } - -- DEBUG (( EFI_D_INFO, "PeiDoHubConfig: HubDescriptor.PwrOn2PwrGood: 0x%x\n", HubDescriptor->PwrOn2PwrGood)); -+ DEBUG (( DEBUG_INFO, "PeiDoHubConfig: HubDescriptor.PwrOn2PwrGood: 0x%x\n", HubDescriptor->PwrOn2PwrGood)); - if (HubDescriptor->PwrOn2PwrGood > 0) { - MicroSecondDelay (HubDescriptor->PwrOn2PwrGood * USB_SET_PORT_POWER_STALL); - } -@@ -536,7 +536,7 @@ PeiResetHubPort ( - } - - if (Index == USB_WAIT_PORT_STS_CHANGE_LOOP) { -- DEBUG ((EFI_D_ERROR, "PeiResetHubPort: reset not finished in time on port %d\n", PortNum)); -+ DEBUG ((DEBUG_ERROR, "PeiResetHubPort: reset not finished in time on port %d\n", PortNum)); - return; - } - -diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c -index fc04f834a5..01b4b8b11e 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c -@@ -119,7 +119,7 @@ PeiUsbControlTransfer ( - } - } - -- DEBUG ((EFI_D_INFO, "PeiUsbControlTransfer: %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PeiUsbControlTransfer: %r\n", Status)); - return Status; - } - -@@ -232,7 +232,7 @@ PeiUsbBulkTransfer ( - PeiUsbDev->DataToggle = (UINT16) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex)); - } - -- DEBUG ((EFI_D_INFO, "PeiUsbBulkTransfer: %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "PeiUsbBulkTransfer: %r\n", Status)); - return Status; - } - -diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c -index 45e48f472e..12dc975e88 100644 ---- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c -+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c -@@ -221,7 +221,7 @@ PeiHubEnumeration ( - - UsbIoPpi = &PeiUsbDevice->UsbIoPpi; - -- DEBUG ((EFI_D_INFO, "PeiHubEnumeration: DownStreamPortNo: %x\n", PeiUsbDevice->DownStreamPortNo)); -+ DEBUG ((DEBUG_INFO, "PeiHubEnumeration: DownStreamPortNo: %x\n", PeiUsbDevice->DownStreamPortNo)); - - for (Index = 0; Index < PeiUsbDevice->DownStreamPortNo; Index++) { - -@@ -236,7 +236,7 @@ PeiHubEnumeration ( - continue; - } - -- DEBUG ((EFI_D_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus)); -+ DEBUG ((DEBUG_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus)); - // - // Only handle connection/enable/overcurrent/reset change. - // -@@ -305,7 +305,7 @@ PeiHubEnumeration ( - } - - NewPeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus); -- DEBUG ((EFI_D_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed)); -+ DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed)); - - if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){ - NewPeiUsbDevice->MaxPacketSize0 = 512; -@@ -339,7 +339,7 @@ PeiHubEnumeration ( - if (EFI_ERROR (Status)) { - continue; - } -- DEBUG ((EFI_D_INFO, "PeiHubEnumeration: PeiConfigureUsbDevice Success\n")); -+ DEBUG ((DEBUG_INFO, "PeiHubEnumeration: PeiConfigureUsbDevice Success\n")); - - Status = PeiServicesInstallPpi (&NewPeiUsbDevice->UsbIoPpiList); - -@@ -445,7 +445,7 @@ PeiUsbEnumeration ( - return EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_INFO, "PeiUsbEnumeration: NumOfRootPort: %x\n", NumOfRootPort)); -+ DEBUG ((DEBUG_INFO, "PeiUsbEnumeration: NumOfRootPort: %x\n", NumOfRootPort)); - - for (Index = 0; Index < NumOfRootPort; Index++) { - // -@@ -466,7 +466,7 @@ PeiUsbEnumeration ( - &PortStatus - ); - } -- DEBUG ((EFI_D_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus)); -+ DEBUG ((DEBUG_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus)); - // - // Only handle connection/enable/overcurrent/reset change. - // -@@ -555,7 +555,7 @@ PeiUsbEnumeration ( - } - - PeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus); -- DEBUG ((EFI_D_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed)); -+ DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed)); - - if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){ - PeiUsbDevice->MaxPacketSize0 = 512; -@@ -580,7 +580,7 @@ PeiUsbEnumeration ( - if (EFI_ERROR (Status)) { - continue; - } -- DEBUG ((EFI_D_INFO, "PeiUsbEnumeration: PeiConfigureUsbDevice Success\n")); -+ DEBUG ((DEBUG_INFO, "PeiUsbEnumeration: PeiConfigureUsbDevice Success\n")); - - Status = PeiServicesInstallPpi (&PeiUsbDevice->UsbIoPpiList); - -@@ -685,13 +685,13 @@ PeiConfigureUsbDevice ( - ); - - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "PeiUsbGet Device Descriptor the %d time Success\n", Retry)); -+ DEBUG ((DEBUG_INFO, "PeiUsbGet Device Descriptor the %d time Success\n", Retry)); - break; - } - } - - if (Retry == 3) { -- DEBUG ((EFI_D_ERROR, "PeiUsbGet Device Descriptor fail: %x %r\n", Retry, Status)); -+ DEBUG ((DEBUG_ERROR, "PeiUsbGet Device Descriptor fail: %x %r\n", Retry, Status)); - return Status; - } - -@@ -710,7 +710,7 @@ PeiConfigureUsbDevice ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "PeiUsbSetDeviceAddress Failed: %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "PeiUsbSetDeviceAddress Failed: %r\n", Status)); - return Status; - } - MicroSecondDelay (USB_SET_DEVICE_ADDRESS_STALL); -@@ -730,7 +730,7 @@ PeiConfigureUsbDevice ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "PeiUsbGetDescriptor First Failed\n")); -+ DEBUG ((DEBUG_ERROR, "PeiUsbGetDescriptor First Failed\n")); - return Status; - } - -@@ -801,7 +801,7 @@ PeiUsbGetAllConfiguration ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "PeiUsbGet Config Descriptor First Failed\n")); -+ DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor First Failed\n")); - return Status; - } - MicroSecondDelay (USB_GET_CONFIG_DESCRIPTOR_STALL); -@@ -836,7 +836,7 @@ PeiUsbGetAllConfiguration ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "PeiUsbGet Config Descriptor all Failed\n")); -+ DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor all Failed\n")); - return Status; - } - // -@@ -1046,7 +1046,7 @@ ResetRootPort ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n")); -+ DEBUG ((DEBUG_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n")); - return; - } - -@@ -1067,7 +1067,7 @@ ResetRootPort ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n")); -+ DEBUG ((DEBUG_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n")); - return; - } - -@@ -1098,7 +1098,7 @@ ResetRootPort ( - } - - if (Index == USB_WAIT_PORT_STS_CHANGE_LOOP) { -- DEBUG ((EFI_D_ERROR, "ResetRootPort: reset not finished in time on port %d\n", PortNum)); -+ DEBUG ((DEBUG_ERROR, "ResetRootPort: reset not finished in time on port %d\n", PortNum)); - return; - } - -@@ -1148,7 +1148,7 @@ ResetRootPort ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n")); -+ DEBUG ((DEBUG_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n")); - return; - } - -@@ -1169,7 +1169,7 @@ ResetRootPort ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n")); -+ DEBUG ((DEBUG_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n")); - return; - } - -@@ -1200,7 +1200,7 @@ ResetRootPort ( - } - - if (Index == USB_WAIT_PORT_STS_CHANGE_LOOP) { -- DEBUG ((EFI_D_ERROR, "ResetRootPort: reset not finished in time on port %d\n", PortNum)); -+ DEBUG ((DEBUG_ERROR, "ResetRootPort: reset not finished in time on port %d\n", PortNum)); - return; - } - -@@ -1239,5 +1239,3 @@ ResetRootPort ( - } - return; - } -- -- -diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c -index aab4061e18..7b29bc81fe 100644 ---- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c -+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBoot.c -@@ -58,7 +58,7 @@ UsbBootRequestSense ( - &CmdResult - ); - if (EFI_ERROR (Status) || CmdResult != USB_MASS_CMD_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult)); -+ DEBUG ((DEBUG_ERROR, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult)); - if (!EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; - } -@@ -131,7 +131,7 @@ UsbBootRequestSense ( - break; - } - -- DEBUG ((EFI_D_INFO, "UsbBootRequestSense: (%r) with error code (%x) sense key %x/%x/%x\n", -+ DEBUG ((DEBUG_INFO, "UsbBootRequestSense: (%r) with error code (%x) sense key %x/%x/%x\n", - Status, - SenseData.ErrorCode, - USB_BOOT_SENSE_KEY (SenseData.SenseKey), -@@ -191,7 +191,7 @@ UsbBootExecCmd ( - ); - - if (Status == EFI_TIMEOUT) { -- DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd\n", Status, *(UINT8 *)Cmd)); -+ DEBUG ((DEBUG_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd\n", Status, *(UINT8 *)Cmd)); - return EFI_TIMEOUT; - } - -@@ -206,7 +206,7 @@ UsbBootExecCmd ( - // - // If command execution failed, then retrieve error info via sense request. - // -- DEBUG ((EFI_D_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd (Result = %x)\n", Status, *(UINT8 *)Cmd, CmdResult)); -+ DEBUG ((DEBUG_ERROR, "UsbBootExecCmd: %r to Exec 0x%x Cmd (Result = %x)\n", Status, *(UINT8 *)Cmd, CmdResult)); - return UsbBootRequestSense (UsbMass); - } - -@@ -631,7 +631,7 @@ UsbBootGetParams ( - - Status = UsbBootInquiry (UsbMass); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status)); - return Status; - } - -@@ -643,7 +643,7 @@ UsbBootGetParams ( - (UsbMass->Pdt != USB_PDT_CDROM) && - (UsbMass->Pdt != USB_PDT_OPTICAL) && - (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) { -- DEBUG ((EFI_D_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt)); -+ DEBUG ((DEBUG_ERROR, "UsbBootGetParams: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt)); - return EFI_UNSUPPORTED; - } - -@@ -695,7 +695,7 @@ UsbBootDetectMedia ( - - Status = UsbBootIsUnitReady (UsbMass); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootIsUnitReady (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBootDetectMedia: UsbBootIsUnitReady (%r)\n", Status)); - } - - // -@@ -719,7 +719,7 @@ UsbBootDetectMedia ( - - Status = UsbBootReadCapacity (UsbMass); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n", Status)); - } - } - -diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c -index 1e878a1bdd..ce252e60fc 100644 ---- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c -+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c -@@ -266,13 +266,13 @@ UsbBotDataTransfer ( - ); - if (EFI_ERROR (Status)) { - if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) { -- DEBUG ((EFI_D_INFO, "UsbBotDataTransfer: (%r)\n", Status)); -- DEBUG ((EFI_D_INFO, "UsbBotDataTransfer: DataIn Stall\n")); -+ DEBUG ((DEBUG_INFO, "UsbBotDataTransfer: (%r)\n", Status)); -+ DEBUG ((DEBUG_INFO, "UsbBotDataTransfer: DataIn Stall\n")); - UsbClearEndpointStall (UsbBot->UsbIo, Endpoint->EndpointAddress); - } else if (USB_IS_ERROR (Result, EFI_USB_ERR_NAK)) { - Status = EFI_NOT_READY; - } else { -- DEBUG ((EFI_D_ERROR, "UsbBotDataTransfer: (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBotDataTransfer: (%r)\n", Status)); - } - if(Status == EFI_TIMEOUT){ - UsbBotResetDevice(UsbBot, FALSE); -@@ -416,7 +416,7 @@ UsbBotExecCommand ( - // - Status = UsbBotSendCommand (UsbBot, Cmd, CmdLen, DataDir, DataLen, Lun); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotSendCommand (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBotExecCommand: UsbBotSendCommand (%r)\n", Status)); - return Status; - } - -@@ -433,7 +433,7 @@ UsbBotExecCommand ( - // - Status = UsbBotGetStatus (UsbBot, DataLen, &Result); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotGetStatus (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbBotExecCommand: UsbBotGetStatus (%r)\n", Status)); - return Status; - } - -@@ -604,4 +604,3 @@ UsbBotCleanUp ( - FreePool (Context); - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c -index 477f0536d6..423104f504 100644 ---- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c -+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassCbi.c -@@ -451,7 +451,7 @@ UsbCbiExecCommand ( - Status = UsbCbiSendCommand (UsbCbi, Cmd, CmdLen, Timeout); - if (EFI_ERROR (Status)) { - gBS->Stall(10 * USB_MASS_1_MILLISECOND); -- DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status)); -+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status)); - return Status; - } - -@@ -463,7 +463,7 @@ UsbCbiExecCommand ( - - Status = UsbCbiDataTransfer (UsbCbi, DataDir, Data, &TransLen, Timeout); - if (UsbCbi->InterruptEndpoint == NULL) { -- DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n",Status)); -+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n",Status)); - return Status; - } - -@@ -472,7 +472,7 @@ UsbCbiExecCommand ( - // - Status = UsbCbiGetStatus (UsbCbi, Timeout, &Result); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n",Status)); -+ DEBUG ((DEBUG_ERROR, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n",Status)); - return Status; - } - -diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c -index bbd19e0447..de9c5f0632 100644 ---- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c -+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c -@@ -172,7 +172,7 @@ UsbMassReadBlocks ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbMassReadBlocks: UsbBootReadBlocks (%r) -> Reset\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassReadBlocks: UsbBootReadBlocks (%r) -> Reset\n", Status)); - UsbMassReset (This, TRUE); - } - -@@ -292,7 +292,7 @@ UsbMassWriteBlocks ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbMassWriteBlocks: UsbBootWriteBlocks (%r) -> Reset\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassWriteBlocks: UsbBootWriteBlocks (%r) -> Reset\n", Status)); - UsbMassReset (This, TRUE); - } - -@@ -491,7 +491,7 @@ UsbMassInitMultiLun ( - - for (Index = 0; Index <= MaxLun; Index++) { - -- DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Start to initialize No.%d logic unit\n", Index)); -+ DEBUG ((DEBUG_INFO, "UsbMassInitMultiLun: Start to initialize No.%d logic unit\n", Index)); - - UsbIo = NULL; - UsbMass = AllocateZeroPool (sizeof (USB_MASS_DEVICE)); -@@ -514,7 +514,7 @@ UsbMassInitMultiLun ( - // - Status = UsbMassInitMedia (UsbMass); - if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: UsbMassInitMedia (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitMultiLun: UsbMassInitMedia (%r)\n", Status)); - FreePool (UsbMass); - continue; - } -@@ -531,7 +531,7 @@ UsbMassInitMultiLun ( - UsbMass->DevicePath = AppendDevicePathNode (DevicePath, &LunNode.Header); - - if (UsbMass->DevicePath == NULL) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: failed to create device logic unit device path\n")); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitMultiLun: failed to create device logic unit device path\n")); - Status = EFI_OUT_OF_RESOURCES; - FreePool (UsbMass); - continue; -@@ -554,7 +554,7 @@ UsbMassInitMultiLun ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: InstallMultipleProtocolInterfaces (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitMultiLun: InstallMultipleProtocolInterfaces (%r)\n", Status)); - FreePool (UsbMass->DevicePath); - FreePool (UsbMass); - continue; -@@ -573,7 +573,7 @@ UsbMassInitMultiLun ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitMultiLun: OpenUsbIoProtocol By Child (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitMultiLun: OpenUsbIoProtocol By Child (%r)\n", Status)); - gBS->UninstallMultipleProtocolInterfaces ( - UsbMass->Controller, - &gEfiDevicePathProtocolGuid, -@@ -589,7 +589,7 @@ UsbMassInitMultiLun ( - continue; - } - ReturnStatus = EFI_SUCCESS; -- DEBUG ((EFI_D_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index)); -+ DEBUG ((DEBUG_INFO, "UsbMassInitMultiLun: Success to initialize No.%d logic unit\n", Index)); - } - - return ReturnStatus; -@@ -633,7 +633,7 @@ UsbMassInitNonLun ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: OpenUsbIoProtocol By Driver (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitNonLun: OpenUsbIoProtocol By Driver (%r)\n", Status)); - goto ON_ERROR; - } - -@@ -654,7 +654,7 @@ UsbMassInitNonLun ( - // - Status = UsbMassInitMedia (UsbMass); - if ((EFI_ERROR (Status)) && (Status != EFI_NO_MEDIA)) { -- DEBUG ((EFI_D_ERROR, "UsbMassInitNonLun: UsbMassInitMedia (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "UsbMassInitNonLun: UsbMassInitMedia (%r)\n", Status)); - goto ON_ERROR; - } - -@@ -810,7 +810,7 @@ USBMassDriverBindingStart ( - Status = UsbMassInitTransport (This, Controller, &Transport, &Context, &MaxLun); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitTransport (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: UsbMassInitTransport (%r)\n", Status)); - goto Exit; - } - if (MaxLun == 0) { -@@ -819,7 +819,7 @@ USBMassDriverBindingStart ( - // - Status = UsbMassInitNonLun (This, Controller, Transport, Context); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitNonLun (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: UsbMassInitNonLun (%r)\n", Status)); - } - } else { - // -@@ -835,7 +835,7 @@ USBMassDriverBindingStart ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenDevicePathProtocol By Driver (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: OpenDevicePathProtocol By Driver (%r)\n", Status)); - goto Exit; - } - -@@ -849,7 +849,7 @@ USBMassDriverBindingStart ( - ); - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenUsbIoProtocol By Driver (%r)\n", Status)); -+ DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: OpenUsbIoProtocol By Driver (%r)\n", Status)); - gBS->CloseProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, -@@ -877,7 +877,7 @@ USBMassDriverBindingStart ( - This->DriverBindingHandle, - Controller - ); -- DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitMultiLun (%r) with Maxlun=%d\n", Status, MaxLun)); -+ DEBUG ((DEBUG_ERROR, "USBMassDriverBindingStart: UsbMassInitMultiLun (%r) with Maxlun=%d\n", Status, MaxLun)); - } - } - Exit: -@@ -953,7 +953,7 @@ USBMassDriverBindingStop ( - This->DriverBindingHandle, - Controller - ); -- DEBUG ((EFI_D_INFO, "Success to stop multi-lun root handle\n")); -+ DEBUG ((DEBUG_INFO, "Success to stop multi-lun root handle\n")); - return EFI_SUCCESS; - } - -@@ -989,7 +989,7 @@ USBMassDriverBindingStop ( - UsbMass->Transport->CleanUp (UsbMass->Context); - FreePool (UsbMass); - -- DEBUG ((EFI_D_INFO, "Success to stop non-multi-lun root handle\n")); -+ DEBUG ((DEBUG_INFO, "Success to stop non-multi-lun root handle\n")); - return EFI_SUCCESS; - } - -@@ -1012,7 +1012,7 @@ USBMassDriverBindingStop ( - ); - if (EFI_ERROR (Status)) { - AllChildrenStopped = FALSE; -- DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when opening blockio\n", (UINT32)Index)); -+ DEBUG ((DEBUG_ERROR, "Fail to stop No.%d multi-lun child handle when opening blockio\n", (UINT32)Index)); - continue; - } - -@@ -1041,7 +1041,7 @@ USBMassDriverBindingStop ( - // Fail to uninstall Block I/O Protocol and Device Path Protocol, so re-open USB I/O Protocol by child. - // - AllChildrenStopped = FALSE; -- DEBUG ((EFI_D_ERROR, "Fail to stop No.%d multi-lun child handle when uninstalling blockio and devicepath\n", (UINT32)Index)); -+ DEBUG ((DEBUG_ERROR, "Fail to stop No.%d multi-lun child handle when uninstalling blockio and devicepath\n", (UINT32)Index)); - - gBS->OpenProtocol ( - Controller, -@@ -1066,7 +1066,7 @@ USBMassDriverBindingStop ( - return EFI_DEVICE_ERROR; - } - -- DEBUG ((EFI_D_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32) NumberOfChildren)); -+ DEBUG ((DEBUG_INFO, "Success to stop all %d multi-lun children handles\n", (UINT32) NumberOfChildren)); - return EFI_SUCCESS; - } - -diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c -index fed60c4882..3605605e91 100644 ---- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c -+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c -@@ -769,7 +769,7 @@ FvIsBeingProcessed ( - for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) { - KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE); - if (CompareGuid (&FvNameGuid, &KnownHandle->FvNameGuid)) { -- DEBUG ((EFI_D_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, &FvNameGuid)); -+ DEBUG ((DEBUG_ERROR, "FvImage on FvHandle %p and %p has the same FvNameGuid %g.\n", FvHandle, KnownHandle->Handle, &FvNameGuid)); - return NULL; - } - } -diff --git a/MdeModulePkg/Core/Dxe/Event/Tpl.c b/MdeModulePkg/Core/Dxe/Event/Tpl.c -index 5ff8eb55ba..8b5928df00 100644 ---- a/MdeModulePkg/Core/Dxe/Event/Tpl.c -+++ b/MdeModulePkg/Core/Dxe/Event/Tpl.c -@@ -60,7 +60,7 @@ CoreRaiseTpl ( - - OldTpl = gEfiCurrentTpl; - if (OldTpl > NewTpl) { -- DEBUG ((EFI_D_ERROR, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl, NewTpl)); -+ DEBUG ((DEBUG_ERROR, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl, NewTpl)); - ASSERT (FALSE); - } - ASSERT (VALID_TPL (NewTpl)); -@@ -101,7 +101,7 @@ CoreRestoreTpl ( - - OldTpl = gEfiCurrentTpl; - if (NewTpl > OldTpl) { -- DEBUG ((EFI_D_ERROR, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl, OldTpl)); -+ DEBUG ((DEBUG_ERROR, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl, OldTpl)); - ASSERT (FALSE); - } - ASSERT (VALID_TPL (NewTpl)); -diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c -index cbf5c1c7b9..0059b0f2d9 100644 ---- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c -+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c -@@ -463,7 +463,7 @@ FvCheck ( - (FileState == EFI_FILE_HEADER_CONSTRUCTION)) { - if (IS_FFS_FILE2 (FfsHeader)) { - if (!FvDevice->IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsHeader->Name)); - } - FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + sizeof (EFI_FFS_FILE_HEADER2)); - } else { -@@ -508,7 +508,7 @@ FvCheck ( - if (IS_FFS_FILE2 (CacheFfsHeader)) { - ASSERT (FFS_FILE2_SIZE (CacheFfsHeader) > 0x00FFFFFF); - if (!FvDevice->IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &CacheFfsHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &CacheFfsHeader->Name)); - FfsHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsHeader + FFS_FILE2_SIZE (CacheFfsHeader)); - // - // Adjust pointer to the next 8-byte aligned boundary. -@@ -725,5 +725,3 @@ FwVolDriverInit ( - ); - return EFI_SUCCESS; - } -- -- -diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c -index 51b082b7e7..6518921516 100644 ---- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c -+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c -@@ -2384,8 +2384,8 @@ CoreInitializeMemoryServices ( - } - } - -- DEBUG ((EFI_D_INFO, "CoreInitializeMemoryServices:\n")); -- DEBUG ((EFI_D_INFO, " BaseAddress - 0x%lx Length - 0x%lx MinimalMemorySizeNeeded - 0x%lx\n", BaseAddress, Length, MinimalMemorySizeNeeded)); -+ DEBUG ((DEBUG_INFO, "CoreInitializeMemoryServices:\n")); -+ DEBUG ((DEBUG_INFO, " BaseAddress - 0x%lx Length - 0x%lx MinimalMemorySizeNeeded - 0x%lx\n", BaseAddress, Length, MinimalMemorySizeNeeded)); - - // - // If no memory regions are found that are big enough to initialize the DXE core, then ASSERT(). -diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c -index 641a5715b1..44b7f105a2 100644 ---- a/MdeModulePkg/Core/Dxe/Image/Image.c -+++ b/MdeModulePkg/Core/Dxe/Image/Image.c -@@ -485,7 +485,7 @@ GetPeCoffImageFixLoadingAssignedAddress( - } - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status = %r \n", (VOID *)(UINTN)(ImageContext->ImageAddress), Status)); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status = %r \n", (VOID *)(UINTN)(ImageContext->ImageAddress), Status)); - return Status; - } - -@@ -648,7 +648,7 @@ CoreLoadPeImage ( - // - // If the code memory is not ready, invoke CoreAllocatePage with AllocateAnyPages to load the driver. - // -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since specified memory is not available.\n")); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Loading module at fixed address failed since specified memory is not available.\n")); - - Status = CoreAllocatePages ( - AllocateAnyPages, -@@ -1587,8 +1587,8 @@ CoreStartImage ( - // Do not ASSERT here, because image might be loaded via EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED - // But it can not be started. - // -- DEBUG ((EFI_D_ERROR, "Image type %s can't be started ", GetMachineTypeName(Image->Machine))); -- DEBUG ((EFI_D_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCoreImageMachineType))); -+ DEBUG ((DEBUG_ERROR, "Image type %s can't be started ", GetMachineTypeName(Image->Machine))); -+ DEBUG ((DEBUG_ERROR, "on %s UEFI system.\n", GetMachineTypeName(mDxeCoreImageMachineType))); - return EFI_UNSUPPORTED; - } - -diff --git a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c -index 2ca0417b07..62bbe3cdc8 100644 ---- a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c -+++ b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c -@@ -611,7 +611,7 @@ MemoryProfileInit ( - - RegisterDxeCore (HobStart, &mMemoryProfileContext); - -- DEBUG ((EFI_D_INFO, "MemoryProfileInit MemoryProfileContext - 0x%x\n", &mMemoryProfileContext)); -+ DEBUG ((DEBUG_INFO, "MemoryProfileInit MemoryProfileContext - 0x%x\n", &mMemoryProfileContext)); - } - - /** -diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c -index a75d415828..c637e35076 100644 ---- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c -+++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c -@@ -66,7 +66,7 @@ CoreInitializeDebugImageInfoTable ( - ); - if (EFI_ERROR (Status)) { - if (PcdGet64 (PcdMaxEfiSystemTablePointerAddress) != 0) { -- DEBUG ((EFI_D_INFO, "Allocate memory for EFI_SYSTEM_TABLE_POINTER below PcdMaxEfiSystemTablePointerAddress failed. \ -+ DEBUG ((DEBUG_INFO, "Allocate memory for EFI_SYSTEM_TABLE_POINTER below PcdMaxEfiSystemTablePointerAddress failed. \ - Retry to allocate memroy as close to the top of memory as feasible.\n")); - } - // -@@ -278,5 +278,3 @@ CoreRemoveDebugImageInfoEntry ( - } - mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; - } -- -- -diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c -index 45356130bc..02a67cafa9 100644 ---- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c -+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c -@@ -120,7 +120,7 @@ InstallMemoryAttributesTable ( - - if (!mMemoryAttributesTableEnable) { - DEBUG ((DEBUG_VERBOSE, "Cannot install Memory Attributes Table ")); -- DEBUG ((EFI_D_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); -+ DEBUG ((DEBUG_VERBOSE, "because Runtime Driver Section Alignment is not %dK.\n", RUNTIME_PAGE_ALLOCATION_GRANULARITY >> 10)); - return ; - } - -@@ -182,10 +182,10 @@ InstallMemoryAttributesTable ( - MemoryAttributesTable->NumberOfEntries = RuntimeEntryCount; - MemoryAttributesTable->DescriptorSize = (UINT32)DescriptorSize; - MemoryAttributesTable->Reserved = 0; -- DEBUG ((EFI_D_VERBOSE, "MemoryAttributesTable:\n")); -- DEBUG ((EFI_D_VERBOSE, " Version - 0x%08x\n", MemoryAttributesTable->Version)); -- DEBUG ((EFI_D_VERBOSE, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries)); -- DEBUG ((EFI_D_VERBOSE, " DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize)); -+ DEBUG ((DEBUG_VERBOSE, "MemoryAttributesTable:\n")); -+ DEBUG ((DEBUG_VERBOSE, " Version - 0x%08x\n", MemoryAttributesTable->Version)); -+ DEBUG ((DEBUG_VERBOSE, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries)); -+ DEBUG ((DEBUG_VERBOSE, " DescriptorSize - 0x%08x\n", MemoryAttributesTable->DescriptorSize)); - MemoryAttributesEntry = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1); - MemoryMap = MemoryMapStart; - for (Index = 0; Index < MemoryMapSize/DescriptorSize; Index++) { -@@ -194,12 +194,12 @@ InstallMemoryAttributesTable ( - case EfiRuntimeServicesData: - CopyMem (MemoryAttributesEntry, MemoryMap, DescriptorSize); - MemoryAttributesEntry->Attribute &= (EFI_MEMORY_RO|EFI_MEMORY_XP|EFI_MEMORY_RUNTIME); -- DEBUG ((EFI_D_VERBOSE, "Entry (0x%x)\n", MemoryAttributesEntry)); -- DEBUG ((EFI_D_VERBOSE, " Type - 0x%x\n", MemoryAttributesEntry->Type)); -- DEBUG ((EFI_D_VERBOSE, " PhysicalStart - 0x%016lx\n", MemoryAttributesEntry->PhysicalStart)); -- DEBUG ((EFI_D_VERBOSE, " VirtualStart - 0x%016lx\n", MemoryAttributesEntry->VirtualStart)); -- DEBUG ((EFI_D_VERBOSE, " NumberOfPages - 0x%016lx\n", MemoryAttributesEntry->NumberOfPages)); -- DEBUG ((EFI_D_VERBOSE, " Attribute - 0x%016lx\n", MemoryAttributesEntry->Attribute)); -+ DEBUG ((DEBUG_VERBOSE, "Entry (0x%x)\n", MemoryAttributesEntry)); -+ DEBUG ((DEBUG_VERBOSE, " Type - 0x%x\n", MemoryAttributesEntry->Type)); -+ DEBUG ((DEBUG_VERBOSE, " PhysicalStart - 0x%016lx\n", MemoryAttributesEntry->PhysicalStart)); -+ DEBUG ((DEBUG_VERBOSE, " VirtualStart - 0x%016lx\n", MemoryAttributesEntry->VirtualStart)); -+ DEBUG ((DEBUG_VERBOSE, " NumberOfPages - 0x%016lx\n", MemoryAttributesEntry->NumberOfPages)); -+ DEBUG ((DEBUG_VERBOSE, " Attribute - 0x%016lx\n", MemoryAttributesEntry->Attribute)); - MemoryAttributesEntry = NEXT_MEMORY_DESCRIPTOR(MemoryAttributesEntry, DescriptorSize); - break; - } -diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c -index 284b34818c..b65b01c9e5 100644 ---- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c -+++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c -@@ -378,7 +378,7 @@ HandOffToDxeCore ( - (VOID **)&VectorHandoffInfoPpi - ); - if (Status == EFI_SUCCESS) { -- DEBUG ((EFI_D_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n")); -+ DEBUG ((DEBUG_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n")); - VectorInfo = VectorHandoffInfoPpi->Info; - Index = 1; - while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) { -@@ -462,4 +462,3 @@ HandOffToDxeCore ( - } - } - } -- -diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c -index 156a477d84..813445b1ef 100644 ---- a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c -+++ b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c -@@ -56,7 +56,7 @@ HandOffToDxeCore ( - (VOID **)&VectorHandoffInfoPpi - ); - if (Status == EFI_SUCCESS) { -- DEBUG ((EFI_D_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n")); -+ DEBUG ((DEBUG_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n")); - VectorInfo = VectorHandoffInfoPpi->Info; - Index = 1; - while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) { -diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c -index f6bb906f38..7d959b36ea 100644 ---- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c -+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c -@@ -302,10 +302,10 @@ PeiLoadFixAddressHook( - // - TotalReservedMemorySize += PeiMemorySize; - -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressRuntimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber))); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressBootTimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber))); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressPeiCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressPeiCodePageNumber))); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Total Reserved Memory Size = 0x%lx.\n", TotalReservedMemorySize)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressRuntimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber))); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressBootTimeCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber))); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: PcdLoadFixAddressPeiCodePageNumber= 0x%x.\n", PcdGet32(PcdLoadFixAddressPeiCodePageNumber))); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: Total Reserved Memory Size = 0x%lx.\n", TotalReservedMemorySize)); - // - // Loop through the system memory typed HOB to merge the adjacent memory range - // -@@ -433,12 +433,12 @@ PeiLoadFixAddressHook( - // The LMFA feature is enabled as load module at fixed absolute address. - // - TopLoadingAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64(PcdLoadModuleAtFixAddressEnable); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Loading module at fixed absolute address.\n")); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: Loading module at fixed absolute address.\n")); - // - // validate the Address. Loop the resource descriptor HOB to make sure the address is in valid memory range - // - if ((TopLoadingAddress & EFI_PAGE_MASK) != 0) { -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid since top address should be page align. \n", TopLoadingAddress)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid since top address should be page align. \n", TopLoadingAddress)); - ASSERT (FALSE); - } - // -@@ -470,11 +470,11 @@ PeiLoadFixAddressHook( - } - } - if (CurrentResourceHob != NULL) { -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO:Top Address 0x%lx is valid \n", TopLoadingAddress)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO:Top Address 0x%lx is valid \n", TopLoadingAddress)); - TopLoadingAddress += MINIMUM_INITIAL_MEMORY_SIZE; - } else { -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid \n", TopLoadingAddress)); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The recommended Top Address for the platform is: \n")); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR:Top Address 0x%lx is invalid \n", TopLoadingAddress)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR:The recommended Top Address for the platform is: \n")); - // - // Print the recommended Top address range. - // -@@ -494,7 +494,7 @@ PeiLoadFixAddressHook( - // See if Top address specified by user is valid. - // - if (ResourceHob->ResourceLength > TotalReservedMemorySize && PeiLoadFixAddressIsMemoryRangeAvailable(PrivateData, ResourceHob)) { -- DEBUG ((EFI_D_INFO, "(0x%lx, 0x%lx)\n", -+ DEBUG ((DEBUG_INFO, "(0x%lx, 0x%lx)\n", - (ResourceHob->PhysicalStart + TotalReservedMemorySize -MINIMUM_INITIAL_MEMORY_SIZE), - (ResourceHob->PhysicalStart + ResourceHob->ResourceLength -MINIMUM_INITIAL_MEMORY_SIZE) - )); -@@ -541,7 +541,7 @@ PeiLoadFixAddressHook( - } - } - if (CurrentResourceHob == NULL) { -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR:The System Memory is too small\n")); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR:The System Memory is too small\n")); - // - // Assert here - // -@@ -613,7 +613,7 @@ PeiLoadFixAddressHook( - // Cache the top address for Loading Module at Fixed Address feature - // - PrivateData->LoadModuleAtFixAddressTopAddress = TopLoadingAddress - MINIMUM_INITIAL_MEMORY_SIZE; -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: Top address = 0x%lx\n", PrivateData->LoadModuleAtFixAddressTopAddress)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: Top address = 0x%lx\n", PrivateData->LoadModuleAtFixAddressTopAddress)); - // - // reinstall the PEI memory relative to TopLoadingAddress - // -@@ -732,7 +732,7 @@ PeiCheckAndSwitchStack ( - // If Loading Module at Fixed Address is enabled, Allocating memory range for Pei code range. - // - LoadFixPeiCodeBegin = AllocatePages((UINTN)PcdGet32(PcdLoadFixAddressPeiCodePageNumber)); -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: PeiCodeBegin = 0x%lX, PeiCodeTop= 0x%lX\n", (UINT64)(UINTN)LoadFixPeiCodeBegin, (UINT64)((UINTN)LoadFixPeiCodeBegin + PcdGet32(PcdLoadFixAddressPeiCodePageNumber) * EFI_PAGE_SIZE))); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: PeiCodeBegin = 0x%lX, PeiCodeTop= 0x%lX\n", (UINT64)(UINTN)LoadFixPeiCodeBegin, (UINT64)((UINTN)LoadFixPeiCodeBegin + PcdGet32(PcdLoadFixAddressPeiCodePageNumber) * EFI_PAGE_SIZE))); - } - - // -@@ -746,7 +746,7 @@ PeiCheckAndSwitchStack ( - NewStackSize = RShiftU64 (Private->PhysicalMemoryLength, 1); - NewStackSize = ALIGN_VALUE (NewStackSize, EFI_PAGE_SIZE); - NewStackSize = MIN (PcdGet32(PcdPeiCoreMaxPeiStackSize), NewStackSize); -- DEBUG ((EFI_D_INFO, "Old Stack size %d, New stack size %d\n", (UINT32)SecCoreData->StackSize, (UINT32)NewStackSize)); -+ DEBUG ((DEBUG_INFO, "Old Stack size %d, New stack size %d\n", (UINT32)SecCoreData->StackSize, (UINT32)NewStackSize)); - ASSERT (NewStackSize >= SecCoreData->StackSize); - - // -@@ -768,7 +768,7 @@ PeiCheckAndSwitchStack ( - // - // Build Stack HOB that describes the permanent memory stack - // -- DEBUG ((EFI_D_INFO, "Stack Hob: BaseAddress=0x%lX Length=0x%lX\n", TopOfNewStack - NewStackSize, NewStackSize)); -+ DEBUG ((DEBUG_INFO, "Stack Hob: BaseAddress=0x%lX Length=0x%lX\n", TopOfNewStack - NewStackSize, NewStackSize)); - BuildStackHob (TopOfNewStack - NewStackSize, NewStackSize); - - // -@@ -803,7 +803,7 @@ PeiCheckAndSwitchStack ( - Private->HeapOffset = (UINTN)((UINTN)SecCoreData->PeiTemporaryRamBase - BaseOfNewHeap); - } - -- DEBUG ((EFI_D_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (UINT64) Private->HeapOffset, (UINT64) Private->StackOffset)); -+ 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 -@@ -871,7 +871,7 @@ PeiCheckAndSwitchStack ( - Private->HeapOffset = (UINTN)((UINTN)SecCoreData->PeiTemporaryRamBase - BaseOfNewHeap); - } - -- DEBUG ((EFI_D_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (UINT64) Private->HeapOffset, (UINT64) Private->StackOffset)); -+ DEBUG ((DEBUG_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (UINT64) Private->HeapOffset, (UINT64) Private->StackOffset)); - - // - // Migrate Heap -@@ -1730,6 +1730,3 @@ PeiRegisterForShadow ( - - return EFI_SUCCESS; - } -- -- -- -diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c -index fa1a3d3acc..bf8dbd3763 100644 ---- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c -+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c -@@ -317,7 +317,7 @@ FindFileEx ( - } else { - if (IS_FFS_FILE2 (*FileHeader)) { - if (!IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &(*FileHeader)->Name)); -+ DEBUG ((DEBUG_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &(*FileHeader)->Name)); - } - FileLength = FFS_FILE2_SIZE (*FileHeader); - ASSERT (FileLength > 0x00FFFFFF); -@@ -345,7 +345,7 @@ FindFileEx ( - case EFI_FILE_HEADER_INVALID: - if (IS_FFS_FILE2 (FfsFileHeader)) { - if (!IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); - } - FileOffset += sizeof (EFI_FFS_FILE_HEADER2); - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER2)); -@@ -368,7 +368,7 @@ FindFileEx ( - ASSERT (FileLength > 0x00FFFFFF); - FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8); - if (!IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); - FileOffset += FileOccupiedSize; - FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize); - break; -@@ -424,7 +424,7 @@ FindFileEx ( - case EFI_FILE_DELETED: - if (IS_FFS_FILE2 (FfsFileHeader)) { - if (!IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); - } - FileLength = FFS_FILE2_SIZE (FfsFileHeader); - ASSERT (FileLength > 0x00FFFFFF); -@@ -509,7 +509,7 @@ PeiInitializeFv ( - PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle; - PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = 0; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", - (UINT32) PrivateData->FvCount, - (VOID *) BfvHeader, -@@ -607,7 +607,7 @@ FirmwareVolumeInfoPpiNotifyCallback ( - // - Status = FvPpi->ProcessVolume (FvPpi, FvInfo2Ppi.FvInfo, FvInfo2Ppi.FvInfoSize, &FvHandle); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to process new found FV, FV may be corrupted!\n")); -+ DEBUG ((DEBUG_ERROR, "Fail to process new found FV, FV may be corrupted!\n")); - return Status; - } - -@@ -618,7 +618,7 @@ FirmwareVolumeInfoPpiNotifyCallback ( - if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) { - if (IsFvInfo2 && (FvInfo2Ppi.AuthenticationStatus != PrivateData->Fv[FvIndex].AuthenticationStatus)) { - PrivateData->Fv[FvIndex].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus; -- DEBUG ((EFI_D_INFO, "Update AuthenticationStatus of the %dth FV to 0x%x!\n", FvIndex, FvInfo2Ppi.AuthenticationStatus)); -+ DEBUG ((DEBUG_INFO, "Update AuthenticationStatus of the %dth FV to 0x%x!\n", FvIndex, FvInfo2Ppi.AuthenticationStatus)); - } - DEBUG ((DEBUG_INFO, "The FV %p has already been processed!\n", FvInfo2Ppi.FvInfo)); - return EFI_SUCCESS; -@@ -651,7 +651,7 @@ FirmwareVolumeInfoPpiNotifyCallback ( - PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus; - CurFvCount = PrivateData->FvCount; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", - (UINT32) CurFvCount, - (VOID *) FvInfo2Ppi.FvInfo, -@@ -687,12 +687,12 @@ FirmwareVolumeInfoPpiNotifyCallback ( - } - } - -- DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle)); -+ DEBUG ((DEBUG_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle)); - ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle); - } - } while (FileHandle != NULL); - } else { -- DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfo2Ppi.FvInfo)); -+ DEBUG ((DEBUG_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfo2Ppi.FvInfo)); - - AddUnknownFormatFvInfo (PrivateData, &FvInfo2Ppi); - } -@@ -808,7 +808,7 @@ ProcessSection ( - if (IS_SECTION2 (Section)) { - ASSERT (SECTION2_SIZE (Section) > 0x00FFFFFF); - if (!IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "Found a FFS3 formatted section in a non-FFS3 formatted FV.\n")); -+ DEBUG ((DEBUG_ERROR, "Found a FFS3 formatted section in a non-FFS3 formatted FV.\n")); - SectionLength = SECTION2_SIZE (Section); - // - // SectionLength is adjusted it is 4 byte aligned. -@@ -1404,7 +1404,7 @@ ProcessFvFile ( - // - // this FILE has been dispatched, it will not be dispatched again. - // -- DEBUG ((EFI_D_INFO, "FV file %p has been dispatched!\r\n", ParentFvFileHandle)); -+ DEBUG ((DEBUG_INFO, "FV file %p has been dispatched!\r\n", ParentFvFileHandle)); - return EFI_SUCCESS; - } - HobPtr.Raw = GET_NEXT_HOB (HobPtr); -@@ -1628,7 +1628,7 @@ PeiFfsFvPpiProcessVolume ( - // - Status = VerifyFv ((EFI_FIRMWARE_VOLUME_HEADER*) Buffer); - if (EFI_ERROR(Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to verify FV which address is 0x%11p", Buffer)); -+ DEBUG ((DEBUG_ERROR, "Fail to verify FV which address is 0x%11p", Buffer)); - return EFI_VOLUME_CORRUPTED; - } - -@@ -1810,7 +1810,7 @@ PeiFfsFvPpiGetFileInfo ( - if (IS_FFS_FILE2 (FileHeader)) { - ASSERT (FFS_FILE2_SIZE (FileHeader) > 0x00FFFFFF); - if (!FwVolInstance->IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FileHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FileHeader->Name)); - return EFI_INVALID_PARAMETER; - } - FileInfo->BufferSize = FFS_FILE2_SIZE (FileHeader) - sizeof (EFI_FFS_FILE_HEADER2); -@@ -2029,7 +2029,7 @@ PeiFfsFvPpiFindSectionByType2 ( - if (IS_FFS_FILE2 (FfsFileHeader)) { - ASSERT (FFS_FILE2_SIZE (FfsFileHeader) > 0x00FFFFFF); - if (!FwVolInstance->IsFfs3Fv) { -- DEBUG ((EFI_D_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); -+ DEBUG ((DEBUG_ERROR, "It is a FFS3 formatted file: %g in a non-FFS3 formatted FV.\n", &FfsFileHeader->Name)); - return EFI_NOT_FOUND; - } - Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER2)); -@@ -2344,7 +2344,7 @@ ThirdPartyFvPpiNotifyCallback ( - // - Status = FvPpi->ProcessVolume (FvPpi, FvInfo, FvInfoSize, &FvHandle); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to process the FV 0x%p, FV may be corrupted!\n", FvInfo)); -+ DEBUG ((DEBUG_ERROR, "Fail to process the FV 0x%p, FV may be corrupted!\n", FvInfo)); - continue; - } - -@@ -2390,7 +2390,7 @@ ThirdPartyFvPpiNotifyCallback ( - PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = AuthenticationStatus; - CurFvCount = PrivateData->FvCount; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", - (UINT32) CurFvCount, - (VOID *) FvInfo, -@@ -2426,7 +2426,7 @@ ThirdPartyFvPpiNotifyCallback ( - } - } - -- DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle)); -+ DEBUG ((DEBUG_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle)); - ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle); - } - } while (FileHandle != NULL); -diff --git a/MdeModulePkg/Core/Pei/Hob/Hob.c b/MdeModulePkg/Core/Pei/Hob/Hob.c -index 4d8db2e7a5..d36b61417e 100644 ---- a/MdeModulePkg/Core/Pei/Hob/Hob.c -+++ b/MdeModulePkg/Core/Pei/Hob/Hob.c -@@ -95,9 +95,9 @@ PeiCreateHob ( - HandOffHob->EfiFreeMemoryBottom; - - if (FreeMemory < Length) { -- DEBUG ((EFI_D_ERROR, "PeiCreateHob fail: Length - 0x%08x\n", (UINTN)Length)); -- DEBUG ((EFI_D_ERROR, " FreeMemoryTop - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryTop)); -- DEBUG ((EFI_D_ERROR, " FreeMemoryBottom - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryBottom)); -+ DEBUG ((DEBUG_ERROR, "PeiCreateHob fail: Length - 0x%08x\n", (UINTN)Length)); -+ DEBUG ((DEBUG_ERROR, " FreeMemoryTop - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryTop)); -+ DEBUG ((DEBUG_ERROR, " FreeMemoryBottom - 0x%08x\n", (UINTN)HandOffHob->EfiFreeMemoryBottom)); - return EFI_OUT_OF_RESOURCES; - } - -diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c -index 5af3895191..92fe798cd6 100644 ---- a/MdeModulePkg/Core/Pei/Image/Image.c -+++ b/MdeModulePkg/Core/Pei/Image/Image.c -@@ -235,7 +235,7 @@ GetPeCoffImageFixLoadingAssignedAddress( - } - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status= %r \n", (VOID *)(UINTN)FixLoadingAddress, Status)); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status= %r \n", (VOID *)(UINTN)FixLoadingAddress, Status)); - return Status; - } - /** -@@ -333,7 +333,7 @@ LoadAndRelocatePeCoffImage ( - (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) || - (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot))) - ) { -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data)); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data)); - } - - // -@@ -367,7 +367,7 @@ LoadAndRelocatePeCoffImage ( - if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) { - Status = GetPeCoffImageFixLoadingAssignedAddress(&ImageContext, Private); - if (EFI_ERROR (Status)){ -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n")); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n")); - // - // The PEIM is not assigned valid address, try to allocate page to load it. - // -@@ -697,12 +697,12 @@ PeiLoadImageLoadImage ( - // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi - // - if (Machine != EFI_IMAGE_MACHINE_IA64) { -- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint)); -+ DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint)); - } else { - // - // For IPF Image, the real entry point should be print. - // -- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint))); -+ DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint))); - } - - // -@@ -741,12 +741,12 @@ PeiLoadImageLoadImage ( - EfiFileName[Index] = 0; - } - -- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a", EfiFileName)); -+ DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); - } - - DEBUG_CODE_END (); - -- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n")); -+ DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n")); - - return EFI_SUCCESS; - -@@ -961,7 +961,3 @@ InitializeImageServices ( - PeiServicesReInstallPpi (PrivateData->XipLoadFile, &gPpiLoadFilePpiList); - } - } -- -- -- -- -diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c -index 9d933f0393..53c9eaceb0 100644 ---- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c -+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c -@@ -80,7 +80,7 @@ PeiInstallPeiMemory ( - { - PEI_CORE_INSTANCE *PrivateData; - -- DEBUG ((EFI_D_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength)); -+ DEBUG ((DEBUG_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength)); - PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); - - // -@@ -89,7 +89,7 @@ PeiInstallPeiMemory ( - // simply return EFI_SUCCESS in release tip to ignore it. - // - if (PrivateData->PeiMemoryInstalled) { -- DEBUG ((EFI_D_ERROR, "ERROR: PeiInstallPeiMemory is called more than once!\n")); -+ DEBUG ((DEBUG_ERROR, "ERROR: PeiInstallPeiMemory is called more than once!\n")); - ASSERT (FALSE); - return EFI_SUCCESS; - } -@@ -676,8 +676,8 @@ PeiAllocatePages ( - if (!EFI_ERROR (Status)) { - return Status; - } -- DEBUG ((EFI_D_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64) Pages)); -- DEBUG ((EFI_D_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64) RemainingPages)); -+ DEBUG ((DEBUG_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64) Pages)); -+ DEBUG ((DEBUG_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64) RemainingPages)); - return EFI_OUT_OF_RESOURCES; - } else { - // -diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c -index 2ad08878d9..a72d07c4be 100644 ---- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c -+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c -@@ -508,7 +508,7 @@ PeiCore ( - // - // Enter DxeIpl to load Dxe core. - // -- DEBUG ((EFI_D_INFO, "DXE IPL Entry\n")); -+ DEBUG ((DEBUG_INFO, "DXE IPL Entry\n")); - Status = TempPtr.DxeIpl->Entry ( - TempPtr.DxeIpl, - &PrivateData.Ps, -diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c -index 0ad71d116f..2e339e2522 100644 ---- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c -+++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c -@@ -474,7 +474,7 @@ InternalPeiInstallPpi ( - // - if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) { - PpiListPointer->CurrentCount = LastCount; -- DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi)); -+ DEBUG((DEBUG_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi)); - return EFI_INVALID_PARAMETER; - } - -@@ -495,7 +495,7 @@ InternalPeiInstallPpi ( - PpiListPointer->MaxCount = PpiListPointer->MaxCount + PPI_GROWTH_STEP; - } - -- DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid)); -+ DEBUG((DEBUG_INFO, "Install PPI: %g\n", PpiList->Guid)); - PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList; - Index++; - PpiListPointer->CurrentCount++; -@@ -613,7 +613,7 @@ PeiReInstallPpi ( - // - // Replace the old PPI with the new one. - // -- DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); -+ DEBUG((DEBUG_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); - PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi; - - // -@@ -807,7 +807,7 @@ InternalPeiNotifyPpi ( - DispatchNotifyListPointer->CurrentCount++; - } - -- DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid)); -+ DEBUG((DEBUG_INFO, "Register PPI Notify: %g\n", NotifyList->Guid)); - - if (Single) { - // -@@ -978,7 +978,7 @@ ProcessNotify ( - (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) && - (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) && - (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) { -- DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n", -+ DEBUG ((DEBUG_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n", - SearchGuid, - NotifyDescriptor->Notify - )); -@@ -1115,4 +1115,3 @@ ConvertPeiCorePpiPointers ( - ConvertPpiPointersFv (PrivateData, (UINTN) OrgImageBase, (UINTN) MigratedImageBase, PeiCoreModuleSize); - } - } -- -diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c -index 76ee9e0b89..6d669bd1be 100644 ---- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c -+++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c -@@ -283,7 +283,7 @@ GetPeCoffImageFixLoadingAssignedAddress( - } - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n", FixLoadingAddress, Status)); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n", FixLoadingAddress, Status)); - return Status; - } - /** -@@ -464,7 +464,7 @@ SmmLoadImage ( - PageCount = 0; - DstBuffer = (UINTN)gLoadModuleAtFixAddressSmramBase; - } else { -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n")); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n")); - // - // allocate the memory to load the SMM driver - // -diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c -index cfa9922cbd..c460805148 100644 ---- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c -+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c -@@ -439,7 +439,7 @@ SmmEndOfDxeHandler ( - EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext; - EFI_HANDLE S3EntryHandle; - -- DEBUG ((EFI_D_INFO, "SmmEndOfDxeHandler\n")); -+ DEBUG ((DEBUG_INFO, "SmmEndOfDxeHandler\n")); - - // - // Install SMM EndOfDxe protocol -diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c -index 599a0cd01d..e8e25c6c91 100644 ---- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c -+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c -@@ -991,7 +991,7 @@ GetPeCoffImageFixLoadingAssignedAddress( - } - SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER); - } -- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status)); -+ DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status)); - return Status; - } - /** -@@ -1068,7 +1068,7 @@ ExecuteSmmCoreFromSmram ( - // - gSmmCorePrivate->SmramRangeCount --; - } else { -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n")); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n")); - // - // Allocate memory for the image being loaded from the EFI_SRAM_DESCRIPTOR - // specified by SmramRange -@@ -1749,7 +1749,7 @@ SmmIplEntry ( - // - // Print the SMRAM base - // -- DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", mLMFAConfigurationTable->SmramBase)); -+ DEBUG ((DEBUG_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", mLMFAConfigurationTable->SmramBase)); - } - - // -diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c -index 9d6e3bf27a..5b8ce55347 100644 ---- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c -+++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c -@@ -676,7 +676,7 @@ SmramProfileInit ( - - RegisterSmmCore (&mSmramProfileContext); - -- DEBUG ((EFI_D_INFO, "SmramProfileInit SmramProfileContext - 0x%x\n", &mSmramProfileContext)); -+ DEBUG ((DEBUG_INFO, "SmramProfileInit SmramProfileContext - 0x%x\n", &mSmramProfileContext)); - } - - /** -@@ -1530,7 +1530,7 @@ SmramProfileReadyToLock ( - return; - } - -- DEBUG ((EFI_D_INFO, "SmramProfileReadyToLock\n")); -+ DEBUG ((DEBUG_INFO, "SmramProfileReadyToLock\n")); - mSmramReadyToLock = TRUE; - } - -@@ -2168,7 +2168,7 @@ SmramProfileHandlerGetData ( - // Sanity check - // - if (!SmmIsBufferOutsideSmmValid ((UINTN) SmramProfileGetData.ProfileBuffer, (UINTN) ProfileSize)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetData: SMM ProfileBuffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetData: SMM ProfileBuffer in SMRAM or overflow!\n")); - SmramProfileParameterGetData->ProfileSize = ProfileSize; - SmramProfileParameterGetData->Header.ReturnStatus = (UINT64) (INT64) (INTN) EFI_ACCESS_DENIED; - goto Done; -@@ -2219,7 +2219,7 @@ SmramProfileHandlerGetDataByOffset ( - // Sanity check - // - if (!SmmIsBufferOutsideSmmValid ((UINTN) SmramProfileGetDataByOffset.ProfileBuffer, (UINTN) SmramProfileGetDataByOffset.ProfileSize)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetDataByOffset: SMM ProfileBuffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetDataByOffset: SMM ProfileBuffer in SMRAM or overflow!\n")); - SmramProfileParameterGetDataByOffset->Header.ReturnStatus = (UINT64) (INT64) (INTN) EFI_ACCESS_DENIED; - goto Done; - } -@@ -2261,7 +2261,7 @@ SmramProfileHandler ( - UINTN TempCommBufferSize; - SMRAM_PROFILE_PARAMETER_RECORDING_STATE *ParameterRecordingState; - -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler Enter\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler Enter\n")); - - // - // If input is invalid, stop processing this SMI -@@ -2273,12 +2273,12 @@ SmramProfileHandler ( - TempCommBufferSize = *CommBufferSize; - - if (TempCommBufferSize < sizeof (SMRAM_PROFILE_PARAMETER_HEADER)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - - if (mSmramReadyToLock && !SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer in SMRAM or overflow!\n")); - return EFI_SUCCESS; - } - -@@ -2293,33 +2293,33 @@ SmramProfileHandler ( - - switch (SmramProfileParameterHeader->Command) { - case SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO: -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetInfo\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetInfo\n")); - if (TempCommBufferSize != sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmramProfileHandlerGetInfo ((SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *) (UINTN) CommBuffer); - break; - case SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA: -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetData\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetData\n")); - if (TempCommBufferSize != sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmramProfileHandlerGetData ((SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA *) (UINTN) CommBuffer); - break; - case SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA_BY_OFFSET: -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetDataByOffset\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetDataByOffset\n")); - if (TempCommBufferSize != sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmramProfileHandlerGetDataByOffset ((SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET *) (UINTN) CommBuffer); - break; - case SMRAM_PROFILE_COMMAND_GET_RECORDING_STATE: -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerGetRecordingState\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerGetRecordingState\n")); - if (TempCommBufferSize != sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - ParameterRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *) (UINTN) CommBuffer; -@@ -2327,9 +2327,9 @@ SmramProfileHandler ( - ParameterRecordingState->Header.ReturnStatus = 0; - break; - case SMRAM_PROFILE_COMMAND_SET_RECORDING_STATE: -- DEBUG ((EFI_D_ERROR, "SmramProfileHandlerSetRecordingState\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandlerSetRecordingState\n")); - if (TempCommBufferSize != sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE)) { -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - ParameterRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *) (UINTN) CommBuffer; -@@ -2350,7 +2350,7 @@ SmramProfileHandler ( - break; - } - -- DEBUG ((EFI_D_ERROR, "SmramProfileHandler Exit\n")); -+ DEBUG ((DEBUG_ERROR, "SmramProfileHandler Exit\n")); - - return EFI_SUCCESS; - } -@@ -2402,20 +2402,20 @@ DumpSmramRange ( - SmramProfileGettingStatus = mSmramProfileGettingStatus; - mSmramProfileGettingStatus = TRUE; - -- DEBUG ((EFI_D_INFO, "FullSmramRange address - 0x%08x\n", mFullSmramRanges)); -+ DEBUG ((DEBUG_INFO, "FullSmramRange address - 0x%08x\n", mFullSmramRanges)); - -- DEBUG ((EFI_D_INFO, "======= SmramProfile begin =======\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile begin =======\n")); - -- DEBUG ((EFI_D_INFO, "FullSmramRange:\n")); -+ DEBUG ((DEBUG_INFO, "FullSmramRange:\n")); - for (Index = 0; Index < mFullSmramRangeCount; Index++) { -- DEBUG ((EFI_D_INFO, " FullSmramRange (0x%x)\n", Index)); -- DEBUG ((EFI_D_INFO, " PhysicalStart - 0x%016lx\n", mFullSmramRanges[Index].PhysicalStart)); -- DEBUG ((EFI_D_INFO, " CpuStart - 0x%016lx\n", mFullSmramRanges[Index].CpuStart)); -- DEBUG ((EFI_D_INFO, " PhysicalSize - 0x%016lx\n", mFullSmramRanges[Index].PhysicalSize)); -- DEBUG ((EFI_D_INFO, " RegionState - 0x%016lx\n", mFullSmramRanges[Index].RegionState)); -+ DEBUG ((DEBUG_INFO, " FullSmramRange (0x%x)\n", Index)); -+ DEBUG ((DEBUG_INFO, " PhysicalStart - 0x%016lx\n", mFullSmramRanges[Index].PhysicalStart)); -+ DEBUG ((DEBUG_INFO, " CpuStart - 0x%016lx\n", mFullSmramRanges[Index].CpuStart)); -+ DEBUG ((DEBUG_INFO, " PhysicalSize - 0x%016lx\n", mFullSmramRanges[Index].PhysicalSize)); -+ DEBUG ((DEBUG_INFO, " RegionState - 0x%016lx\n", mFullSmramRanges[Index].RegionState)); - } - -- DEBUG ((EFI_D_INFO, "======= SmramProfile end =======\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile end =======\n")); - - mSmramProfileGettingStatus = SmramProfileGettingStatus; - } -@@ -2444,20 +2444,20 @@ DumpFreePagesList ( - SmramProfileGettingStatus = mSmramProfileGettingStatus; - mSmramProfileGettingStatus = TRUE; - -- DEBUG ((EFI_D_INFO, "======= SmramProfile begin =======\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile begin =======\n")); - -- DEBUG ((EFI_D_INFO, "FreePagesList:\n")); -+ DEBUG ((DEBUG_INFO, "FreePagesList:\n")); - FreePageList = &mSmmMemoryMap; - for (Node = FreePageList->BackLink, Index = 0; - Node != FreePageList; - Node = Node->BackLink, Index++) { - Pages = BASE_CR (Node, FREE_PAGE_LIST, Link); -- DEBUG ((EFI_D_INFO, " Index - 0x%x\n", Index)); -- DEBUG ((EFI_D_INFO, " PhysicalStart - 0x%016lx\n", (PHYSICAL_ADDRESS) (UINTN) Pages)); -- DEBUG ((EFI_D_INFO, " NumberOfPages - 0x%08x\n", Pages->NumberOfPages)); -+ DEBUG ((DEBUG_INFO, " Index - 0x%x\n", Index)); -+ DEBUG ((DEBUG_INFO, " PhysicalStart - 0x%016lx\n", (PHYSICAL_ADDRESS) (UINTN) Pages)); -+ DEBUG ((DEBUG_INFO, " NumberOfPages - 0x%08x\n", Pages->NumberOfPages)); - } - -- DEBUG ((EFI_D_INFO, "======= SmramProfile end =======\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile end =======\n")); - - mSmramProfileGettingStatus = SmramProfileGettingStatus; - } -@@ -2646,21 +2646,21 @@ DumpSmramProfile ( - mSmramProfileGettingStatus = TRUE; - - Context = &ContextData->Context; -- DEBUG ((EFI_D_INFO, "======= SmramProfile begin =======\n")); -- DEBUG ((EFI_D_INFO, "MEMORY_PROFILE_CONTEXT\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile begin =======\n")); -+ DEBUG ((DEBUG_INFO, "MEMORY_PROFILE_CONTEXT\n")); - -- DEBUG ((EFI_D_INFO, " CurrentTotalUsage - 0x%016lx\n", Context->CurrentTotalUsage)); -- DEBUG ((EFI_D_INFO, " PeakTotalUsage - 0x%016lx\n", Context->PeakTotalUsage)); -+ DEBUG ((DEBUG_INFO, " CurrentTotalUsage - 0x%016lx\n", Context->CurrentTotalUsage)); -+ DEBUG ((DEBUG_INFO, " PeakTotalUsage - 0x%016lx\n", Context->PeakTotalUsage)); - for (TypeIndex = 0; TypeIndex < sizeof (Context->CurrentTotalUsageByType) / sizeof (Context->CurrentTotalUsageByType[0]); TypeIndex++) { - if ((Context->CurrentTotalUsageByType[TypeIndex] != 0) || - (Context->PeakTotalUsageByType[TypeIndex] != 0)) { -- DEBUG ((EFI_D_INFO, " CurrentTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -- DEBUG ((EFI_D_INFO, " PeakTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->PeakTotalUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -+ DEBUG ((DEBUG_INFO, " CurrentTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -+ DEBUG ((DEBUG_INFO, " PeakTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->PeakTotalUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); - } - } -- DEBUG ((EFI_D_INFO, " TotalImageSize - 0x%016lx\n", Context->TotalImageSize)); -- DEBUG ((EFI_D_INFO, " ImageCount - 0x%08x\n", Context->ImageCount)); -- DEBUG ((EFI_D_INFO, " SequenceCount - 0x%08x\n", Context->SequenceCount)); -+ DEBUG ((DEBUG_INFO, " TotalImageSize - 0x%016lx\n", Context->TotalImageSize)); -+ DEBUG ((DEBUG_INFO, " ImageCount - 0x%08x\n", Context->ImageCount)); -+ DEBUG ((DEBUG_INFO, " SequenceCount - 0x%08x\n", Context->SequenceCount)); - - SmramDriverInfoList = ContextData->DriverInfoList; - for (DriverLink = SmramDriverInfoList->ForwardLink, DriverIndex = 0; -@@ -2673,23 +2673,23 @@ DumpSmramProfile ( - MEMORY_PROFILE_DRIVER_INFO_SIGNATURE - ); - DriverInfo = &DriverInfoData->DriverInfo; -- DEBUG ((EFI_D_INFO, " MEMORY_PROFILE_DRIVER_INFO (0x%x)\n", DriverIndex)); -- DEBUG ((EFI_D_INFO, " FileName - %g\n", &DriverInfo->FileName)); -- DEBUG ((EFI_D_INFO, " ImageBase - 0x%016lx\n", DriverInfo->ImageBase)); -- DEBUG ((EFI_D_INFO, " ImageSize - 0x%016lx\n", DriverInfo->ImageSize)); -- DEBUG ((EFI_D_INFO, " EntryPoint - 0x%016lx\n", DriverInfo->EntryPoint)); -- DEBUG ((EFI_D_INFO, " ImageSubsystem - 0x%04x\n", DriverInfo->ImageSubsystem)); -- DEBUG ((EFI_D_INFO, " FileType - 0x%02x\n", DriverInfo->FileType)); -- DEBUG ((EFI_D_INFO, " CurrentUsage - 0x%016lx\n", DriverInfo->CurrentUsage)); -- DEBUG ((EFI_D_INFO, " PeakUsage - 0x%016lx\n", DriverInfo->PeakUsage)); -+ DEBUG ((DEBUG_INFO, " MEMORY_PROFILE_DRIVER_INFO (0x%x)\n", DriverIndex)); -+ DEBUG ((DEBUG_INFO, " FileName - %g\n", &DriverInfo->FileName)); -+ DEBUG ((DEBUG_INFO, " ImageBase - 0x%016lx\n", DriverInfo->ImageBase)); -+ DEBUG ((DEBUG_INFO, " ImageSize - 0x%016lx\n", DriverInfo->ImageSize)); -+ DEBUG ((DEBUG_INFO, " EntryPoint - 0x%016lx\n", DriverInfo->EntryPoint)); -+ DEBUG ((DEBUG_INFO, " ImageSubsystem - 0x%04x\n", DriverInfo->ImageSubsystem)); -+ DEBUG ((DEBUG_INFO, " FileType - 0x%02x\n", DriverInfo->FileType)); -+ DEBUG ((DEBUG_INFO, " CurrentUsage - 0x%016lx\n", DriverInfo->CurrentUsage)); -+ DEBUG ((DEBUG_INFO, " PeakUsage - 0x%016lx\n", DriverInfo->PeakUsage)); - for (TypeIndex = 0; TypeIndex < sizeof (DriverInfo->CurrentUsageByType) / sizeof (DriverInfo->CurrentUsageByType[0]); TypeIndex++) { - if ((DriverInfo->CurrentUsageByType[TypeIndex] != 0) || - (DriverInfo->PeakUsageByType[TypeIndex] != 0)) { -- DEBUG ((EFI_D_INFO, " CurrentUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -- DEBUG ((EFI_D_INFO, " PeakUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->PeakUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -+ DEBUG ((DEBUG_INFO, " CurrentUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); -+ DEBUG ((DEBUG_INFO, " PeakUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->PeakUsageByType[TypeIndex], ProfileMemoryTypeToStr (TypeIndex))); - } - } -- DEBUG ((EFI_D_INFO, " AllocRecordCount - 0x%08x\n", DriverInfo->AllocRecordCount)); -+ DEBUG ((DEBUG_INFO, " AllocRecordCount - 0x%08x\n", DriverInfo->AllocRecordCount)); - - AllocInfoList = DriverInfoData->AllocInfoList; - for (AllocLink = AllocInfoList->ForwardLink, AllocIndex = 0; -@@ -2702,25 +2702,25 @@ DumpSmramProfile ( - MEMORY_PROFILE_ALLOC_INFO_SIGNATURE - ); - AllocInfo = &AllocInfoData->AllocInfo; -- DEBUG ((EFI_D_INFO, " MEMORY_PROFILE_ALLOC_INFO (0x%x)\n", AllocIndex)); -- DEBUG ((EFI_D_INFO, " CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, AllocInfo->CallerAddress - DriverInfo->ImageBase)); -- DEBUG ((EFI_D_INFO, " SequenceId - 0x%08x\n", AllocInfo->SequenceId)); -+ DEBUG ((DEBUG_INFO, " MEMORY_PROFILE_ALLOC_INFO (0x%x)\n", AllocIndex)); -+ DEBUG ((DEBUG_INFO, " CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, AllocInfo->CallerAddress - DriverInfo->ImageBase)); -+ DEBUG ((DEBUG_INFO, " SequenceId - 0x%08x\n", AllocInfo->SequenceId)); - if ((AllocInfo->Action & MEMORY_PROFILE_ACTION_USER_DEFINED_MASK) != 0) { - if (AllocInfoData->ActionString != NULL) { -- DEBUG ((EFI_D_INFO, " Action - 0x%08x (%a)\n", AllocInfo->Action, AllocInfoData->ActionString)); -+ DEBUG ((DEBUG_INFO, " Action - 0x%08x (%a)\n", AllocInfo->Action, AllocInfoData->ActionString)); - } else { -- DEBUG ((EFI_D_INFO, " Action - 0x%08x (UserDefined-0x%08x)\n", AllocInfo->Action, AllocInfo->Action)); -+ DEBUG ((DEBUG_INFO, " Action - 0x%08x (UserDefined-0x%08x)\n", AllocInfo->Action, AllocInfo->Action)); - } - } else { -- DEBUG ((EFI_D_INFO, " Action - 0x%08x (%a)\n", AllocInfo->Action, ProfileActionToStr (AllocInfo->Action))); -+ DEBUG ((DEBUG_INFO, " Action - 0x%08x (%a)\n", AllocInfo->Action, ProfileActionToStr (AllocInfo->Action))); - } -- DEBUG ((EFI_D_INFO, " MemoryType - 0x%08x (%a)\n", AllocInfo->MemoryType, ProfileMemoryTypeToStr (AllocInfo->MemoryType))); -- DEBUG ((EFI_D_INFO, " Buffer - 0x%016lx\n", AllocInfo->Buffer)); -- DEBUG ((EFI_D_INFO, " Size - 0x%016lx\n", AllocInfo->Size)); -+ DEBUG ((DEBUG_INFO, " MemoryType - 0x%08x (%a)\n", AllocInfo->MemoryType, ProfileMemoryTypeToStr (AllocInfo->MemoryType))); -+ DEBUG ((DEBUG_INFO, " Buffer - 0x%016lx\n", AllocInfo->Buffer)); -+ DEBUG ((DEBUG_INFO, " Size - 0x%016lx\n", AllocInfo->Size)); - } - } - -- DEBUG ((EFI_D_INFO, "======= SmramProfile end =======\n")); -+ DEBUG ((DEBUG_INFO, "======= SmramProfile end =======\n")); - - mSmramProfileGettingStatus = SmramProfileGettingStatus; - } -@@ -2743,4 +2743,3 @@ DumpSmramInfo ( - } - ); - } -- -diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c -index 53f0ef3d19..45d0fbb8a1 100644 ---- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c -+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c -@@ -611,7 +611,7 @@ BOpt_GetOptionNumber ( - continue; - } - UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN) OptionNumber); -- DEBUG((EFI_D_ERROR,"Option = %s\n", StrTemp)); -+ DEBUG((DEBUG_ERROR,"Option = %s\n", StrTemp)); - GetEfiGlobalVariable2 (StrTemp, (VOID **) &OptionBuffer, &OptionSize); - if (NULL == OptionBuffer) { - // -@@ -1002,4 +1002,3 @@ CreateDriverOptionFromFile ( - { - return ReSendForm(FilePath, FORM_DRV_ADD_FILE_ID); - } -- -diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c -index 4b2c4c77a1..e378ac52b5 100644 ---- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c -+++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c -@@ -380,7 +380,7 @@ GroupMultipleLegacyBootOption4SameType ( - // - // Legacy Boot Option - // -- DEBUG ((EFI_D_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index)); -+ DEBUG ((DEBUG_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index)); - ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex)); - NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF]; - -@@ -926,4 +926,3 @@ BootManagerUiLibDestructor ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c b/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c -index 22b96b05da..0ee7095aba 100644 ---- a/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c -+++ b/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c -@@ -54,7 +54,7 @@ IpmiSubmitCommand ( - // - // Dxe Ipmi Protocol is not installed. So, IPMI device is not present. - // -- DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand in Dxe Phase under SMS Status - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand in Dxe Phase under SMS Status - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c -index ff7979c962..a71221d7de 100644 ---- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c -+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c -@@ -209,17 +209,17 @@ FrameBufferBltLibVideoFill ( - // BltBuffer to Video: Source is BltBuffer, destination is Video - // - if (DestinationY + Height > Configure->Height) { -- DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (Y)\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill: Past screen (Y)\n")); - return RETURN_INVALID_PARAMETER; - } - - if (DestinationX + Width > Configure->Width) { -- DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (X)\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill: Past screen (X)\n")); - return RETURN_INVALID_PARAMETER; - } - - if (Width == 0 || Height == 0) { -- DEBUG ((EFI_D_VERBOSE, "VideoFill: Width or Height is 0\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill: Width or Height is 0\n")); - return RETURN_INVALID_PARAMETER; - } - -@@ -235,7 +235,7 @@ FrameBufferBltLibVideoFill ( - (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) & - Configure->PixelMasks.BlueMask) - ); -- DEBUG ((EFI_D_VERBOSE, "VideoFill: color=0x%x, wide-fill=0x%x\n", -+ DEBUG ((DEBUG_VERBOSE, "VideoFill: color=0x%x, wide-fill=0x%x\n", - Uint32, WideFill)); - - // -@@ -267,7 +267,7 @@ FrameBufferBltLibVideoFill ( - } - - if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) { -- DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill (wide, one-shot)\n")); - Offset = DestinationY * Configure->PixelsPerScanLine; - Offset = Configure->BytesPerPixel * Offset; - Destination = Configure->FrameBuffer + Offset; -@@ -288,7 +288,7 @@ FrameBufferBltLibVideoFill ( - Destination = Configure->FrameBuffer + Offset; - - if (UseWideFill && (((UINTN) Destination & 7) == 0)) { -- DEBUG ((EFI_D_VERBOSE, "VideoFill (wide)\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill (wide)\n")); - SizeInBytes = WidthInBytes; - if (SizeInBytes >= 8) { - SetMem64 (Destination, SizeInBytes & ~7, WideFill); -@@ -299,7 +299,7 @@ FrameBufferBltLibVideoFill ( - CopyMem (Destination, &WideFill, SizeInBytes); - } - } else { -- DEBUG ((EFI_D_VERBOSE, "VideoFill (not wide)\n")); -+ DEBUG ((DEBUG_VERBOSE, "VideoFill (not wide)\n")); - if (!LineBufferReady) { - CopyMem (Configure->LineBuffer, &WideFill, Configure->BytesPerPixel); - for (IndexX = 1; IndexX < Width; ) { -diff --git a/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c b/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c -index 0bf07e3492..0b86ef3ad5 100644 ---- a/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c -+++ b/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c -@@ -73,24 +73,24 @@ PciHostBridgeResourceConflict ( - { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; - UINTN RootBridgeIndex; -- DEBUG ((EFI_D_ERROR, "PciHostBridge: Resource conflict happens!\n")); -+ DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n")); - - RootBridgeIndex = 0; - Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; - while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) { -- DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); -+ DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); - for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) { - ASSERT (Descriptor->ResType < - (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) / - sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0]) - ) - ); -- DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n", -+ DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n", - mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType], - Descriptor->AddrLen, Descriptor->AddrRangeMax - )); - if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) { -- DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n", -+ DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n", - Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, - ((Descriptor->SpecificFlag & - EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE -diff --git a/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c b/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c -index fa6b30905f..648af08761 100644 ---- a/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c -+++ b/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c -@@ -55,7 +55,7 @@ IpmiSubmitCommand ( - // - // Ipmi Ppi is not installed. So, IPMI device is not present. - // -- DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand in Pei Phase under SMS Status - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand in Pei Phase under SMS Status - %r\n", Status)); - return EFI_NOT_FOUND; - } - -diff --git a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c -index 5ea2760dd5..43b4d49d30 100644 ---- a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c -+++ b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c -@@ -468,7 +468,7 @@ ReportStatusCodeEx ( - // The local variable Buffer not large enough to hold the extended data associated - // with the status code being reported. - // -- DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n")); -+ DEBUG ((DEBUG_ERROR, "Status code extended data is too large to be reported!\n")); - return EFI_OUT_OF_RESOURCES; - } - StatusCodeData = (EFI_STATUS_CODE_DATA *) Buffer; -diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c -index 038dd20b90..f7fb787cd5 100644 ---- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c -+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c -@@ -62,51 +62,51 @@ InternalSmbusExecute ( - - switch (Operation) { - case EfiSmbusQuickRead: -- DEBUG ((EFI_D_INFO, "EfiSmbusQuickRead - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusQuickRead - 0x%08x\n", SmbusAddress)); - SmBusQuickRead (SmbusAddress, &Status); - break; - case EfiSmbusQuickWrite: -- DEBUG ((EFI_D_INFO, "EfiSmbusQuickWrite - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusQuickWrite - 0x%08x\n", SmbusAddress)); - SmBusQuickWrite (SmbusAddress, &Status); - break; - case EfiSmbusReceiveByte: -- DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusReceiveByte - 0x%08x\n", SmbusAddress)); - SmBusReceiveByte (SmbusAddress, &Status); - break; - case EfiSmbusSendByte: -- DEBUG ((EFI_D_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer)); - SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status); - break; - case EfiSmbusReadByte: -- DEBUG ((EFI_D_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress)); - SmBusReadDataByte (SmbusAddress, &Status); - break; - case EfiSmbusWriteByte: -- DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer)); - SmBusWriteDataByte (SmbusAddress, *(UINT8 *) Buffer, &Status); - break; - case EfiSmbusReadWord: -- DEBUG ((EFI_D_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress)); - SmBusReadDataWord (SmbusAddress, &Status); - break; - case EfiSmbusWriteWord: -- DEBUG ((EFI_D_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer)); - SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status); - break; - case EfiSmbusProcessCall: -- DEBUG ((EFI_D_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer)); - SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status); - break; - case EfiSmbusReadBlock: -- DEBUG ((EFI_D_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress)); - SmBusReadBlock (SmbusAddress, WorkBuffer, &Status); - break; - case EfiSmbusWriteBlock: -- DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteBlock - 0x%08x\n", SmbusAddress)); - SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, &Status); - break; - case EfiSmbusBWBRProcessCall: -- DEBUG ((EFI_D_INFO, "EfiSmbusBWBRProcessCall - 0x%08x\n", SmbusAddress)); -+ DEBUG ((DEBUG_INFO, "EfiSmbusBWBRProcessCall - 0x%08x\n", SmbusAddress)); - SmBusBlockProcessCall ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, WorkBuffer, &Status); - break; - default: -@@ -206,54 +206,54 @@ ScriptIoRead ( - switch (Width) { - - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address)); - *Out.Uint8 = IoRead8 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address)); - *Out.Uint8 = IoRead8 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address)); - *Out.Uint8 = IoRead8 ((UINTN) Address); - break; - - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address)); - *Out.Uint16 = IoRead16 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address)); - *Out.Uint16 = IoRead16 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address)); - *Out.Uint16 = IoRead16 ((UINTN) Address); - break; - - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address)); - *Out.Uint32 = IoRead32 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address)); - *Out.Uint32 = IoRead32 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address)); - *Out.Uint32 = IoRead32 ((UINTN) Address); - break; - - case S3BootScriptWidthUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address)); - *Out.Uint64 = IoRead64 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address)); - *Out.Uint64 = IoRead64 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address)); - *Out.Uint64 = IoRead64 ((UINTN) Address); - break; - -@@ -313,51 +313,51 @@ ScriptIoWrite ( - for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) { - switch (Width) { - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8)); - IoWrite8 ((UINTN) Address, *In.Uint8); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8)); - IoWrite8 ((UINTN) OriginalAddress, *In.Uint8); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8)); - IoWrite8 ((UINTN) Address, *OriginalIn.Uint8); - break; - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16)); - IoWrite16 ((UINTN) Address, *In.Uint16); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16)); - IoWrite16 ((UINTN) OriginalAddress, *In.Uint16); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16)); - IoWrite16 ((UINTN) Address, *OriginalIn.Uint16); - break; - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32)); - IoWrite32 ((UINTN) Address, *In.Uint32); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32)); - IoWrite32 ((UINTN) OriginalAddress, *In.Uint32); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32)); - IoWrite32 ((UINTN) Address, *OriginalIn.Uint32); - break; - case S3BootScriptWidthUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64)); - IoWrite64 ((UINTN) Address, *In.Uint64); - break; - case S3BootScriptWidthFifoUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64)); - IoWrite64 ((UINTN) OriginalAddress, *In.Uint64); - break; - case S3BootScriptWidthFillUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64)); - IoWrite64 ((UINTN) Address, *OriginalIn.Uint64); - break; - default: -@@ -397,7 +397,7 @@ BootScriptExecuteIoWrite ( - Count = IoWrite.Count; - Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteIoWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteIoWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width)); - return ScriptIoWrite(Width, Address, Count, Buffer); - } - /** -@@ -441,54 +441,54 @@ ScriptMemoryRead ( - for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) { - switch (Width) { - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address)); - *Out.Uint8 = MmioRead8 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address)); - *Out.Uint8 = MmioRead8 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address)); - *Out.Uint8 = MmioRead8 ((UINTN) Address); - break; - - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address)); - *Out.Uint16 = MmioRead16 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address)); - *Out.Uint16 = MmioRead16 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address)); - *Out.Uint16 = MmioRead16 ((UINTN) Address); - break; - - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address)); - *Out.Uint32 = MmioRead32 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address)); - *Out.Uint32 = MmioRead32 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address)); - *Out.Uint32 = MmioRead32 ((UINTN) Address); - break; - - case S3BootScriptWidthUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address)); - *Out.Uint64 = MmioRead64 ((UINTN) Address); - break; - case S3BootScriptWidthFifoUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address)); - *Out.Uint64 = MmioRead64 ((UINTN) Address); - break; - case S3BootScriptWidthFillUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address)); - *Out.Uint64 = MmioRead64 ((UINTN) Address); - break; - -@@ -544,51 +544,51 @@ ScriptMemoryWrite ( - for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) { - switch (Width) { - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8)); - MmioWrite8 ((UINTN) Address, *In.Uint8); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8)); - MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8)); - MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8); - break; - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16)); - MmioWrite16 ((UINTN) Address, *In.Uint16); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16)); - MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16)); - MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16); - break; - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32)); - MmioWrite32 ((UINTN) Address, *In.Uint32); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32)); - MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32)); - MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32); - break; - case S3BootScriptWidthUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64)); - MmioWrite64 ((UINTN) Address, *In.Uint64); - break; - case S3BootScriptWidthFifoUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64)); - MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64); - break; - case S3BootScriptWidthFillUint64: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64)); - MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64); - break; - default: -@@ -627,7 +627,7 @@ BootScriptExecuteMemoryWrite ( - Count = MemWrite.Count; - Buffer = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width)); - return ScriptMemoryWrite (Width,Address, Count, Buffer); - - } -@@ -674,41 +674,41 @@ ScriptPciCfg2Read ( - for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) { - switch (Width) { - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress)); - *Out.Uint8 = PciSegmentRead8 (PciAddress); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress)); - *Out.Uint8 = PciSegmentRead8 (PciAddress); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress)); - *Out.Uint8 = PciSegmentRead8 (PciAddress); - break; - - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress)); - *Out.Uint16 = PciSegmentRead16 (PciAddress); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress)); - *Out.Uint16 = PciSegmentRead16 (PciAddress); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress)); - *Out.Uint16 = PciSegmentRead16 (PciAddress); - break; - - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress)); - *Out.Uint32 = PciSegmentRead32 (PciAddress); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress)); - *Out.Uint32 = PciSegmentRead32 (PciAddress); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress)); - *Out.Uint32 = PciSegmentRead32 (PciAddress); - break; - -@@ -766,39 +766,39 @@ ScriptPciCfg2Write ( - for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) { - switch (Width) { - case S3BootScriptWidthUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8)); - PciSegmentWrite8 (PciAddress, *In.Uint8); - break; - case S3BootScriptWidthFifoUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8)); - PciSegmentWrite8 (OriginalPciAddress, *In.Uint8); - break; - case S3BootScriptWidthFillUint8: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8)); - PciSegmentWrite8 (PciAddress, *OriginalIn.Uint8); - break; - case S3BootScriptWidthUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*In.Uint16)); - PciSegmentWrite16 (PciAddress, *In.Uint16); - break; - case S3BootScriptWidthFifoUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16)); - PciSegmentWrite16 (OriginalPciAddress, *In.Uint16); - break; - case S3BootScriptWidthFillUint16: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16)); - PciSegmentWrite16 (PciAddress, *OriginalIn.Uint16); - break; - case S3BootScriptWidthUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", PciAddress, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", PciAddress, (UINTN)*In.Uint32)); - PciSegmentWrite32 (PciAddress, *In.Uint32); - break; - case S3BootScriptWidthFifoUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32)); - PciSegmentWrite32 (OriginalPciAddress, *In.Uint32); - break; - case S3BootScriptWidthFillUint32: -- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32)); - PciSegmentWrite32 (PciAddress, *OriginalIn.Uint32); - break; - default: -@@ -883,7 +883,7 @@ BootScriptExecutePciCfgWrite ( - Count = PciCfgWrite.Count; - Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE); - -- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width)); - return ScriptPciCfgWrite (Width, Address, Count, Buffer); - } - /** -@@ -911,7 +911,7 @@ BootScriptExecuteIoReadWrite ( - - CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask)); - - Status = ScriptIoRead ( - (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width, -@@ -955,7 +955,7 @@ BootScriptExecuteMemoryReadWrite ( - - CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask)); - - Status = ScriptMemoryRead ( - (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width, -@@ -999,7 +999,7 @@ BootScriptExecutePciCfgReadWrite ( - - CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgReadWrite.Address), AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfgReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgReadWrite.Address), AndMask, OrMask)); - - Status = ScriptPciCfgRead ( - (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width, -@@ -1042,7 +1042,7 @@ BootScriptExecuteSmbusExecute ( - - CopyMem ((VOID*)&SmbusExecuteEntry, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_SMBUS_EXECUTE )); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation)); - - SmBusAddress = (UINTN)SmbusExecuteEntry.SmBusAddress; - DataSize = (UINTN) SmbusExecuteEntry.DataSize; -@@ -1069,7 +1069,7 @@ BootScriptExecuteStall ( - - CopyMem ((VOID*)&Stall, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_STALL)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration)); - - MicroSecondDelay ((UINTN) Stall.Duration); - return EFI_SUCCESS; -@@ -1092,7 +1092,7 @@ BootScriptExecuteDispatch ( - CopyMem ((VOID*)&ScriptDispatch, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH)); - EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch.EntryPoint); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteDispatch - 0x%08x\n", (UINTN)ScriptDispatch.EntryPoint)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch - 0x%08x\n", (UINTN)ScriptDispatch.EntryPoint)); - - Status = EntryFunc (NULL, NULL); - -@@ -1115,7 +1115,7 @@ BootScriptExecuteDispatch2 ( - - CopyMem ((VOID*)&ScriptDispatch2, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH_2)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context)); - - EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch2.EntryPoint); - -@@ -1149,7 +1149,7 @@ BootScriptExecuteMemPoll ( - - CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask)); - - Data = 0; - Status = ScriptMemoryRead ( -@@ -1203,13 +1203,13 @@ BootScriptExecuteInformation ( - CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION)); - - InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION); -- DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData)); - -- DEBUG ((EFI_D_INFO, "BootScriptInformation: ")); -+ DEBUG ((DEBUG_INFO, "BootScriptInformation: ")); - for (Index = 0; Index < Information.InformationLength; Index++) { -- DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index])); -+ DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index])); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - - /** -@@ -1231,13 +1231,13 @@ BootScriptExecuteLabel ( - CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION)); - - InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION); -- DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData)); - -- DEBUG ((EFI_D_INFO, "BootScriptLabel: ")); -+ DEBUG ((DEBUG_INFO, "BootScriptLabel: ")); - for (Index = 0; Index < Information.InformationLength; Index++) { -- DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index])); -+ DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index])); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - - /** -@@ -1349,7 +1349,7 @@ BootScriptExecuteIoPoll ( - - CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask)); - - Data = 0; - Status = ScriptIoRead ( -@@ -1409,7 +1409,7 @@ BootScriptExecutePciCfg2Write ( - Count = PciCfg2Write.Count; - Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE); - -- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width)); - return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer); - } - -@@ -1439,7 +1439,7 @@ BootScriptExecutePciCfg2ReadWrite ( - - CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)); - -- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Segment, PciCfg2ReadWrite.Address), AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Segment, PciCfg2ReadWrite.Address), AndMask, OrMask)); - - Status = ScriptPciCfg2Read ( - (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width, -@@ -1486,7 +1486,7 @@ BootScriptPciCfgPoll ( - EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll; - CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)); - -- DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask)); - - Data = 0; - Status = ScriptPciCfgRead ( -@@ -1548,7 +1548,7 @@ BootScriptPciCfg2Poll ( - Data = 0; - CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)); - -- DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2Poll.Segment, PciCfg2Poll.Address), AndMask, OrMask)); -+ DEBUG ((DEBUG_INFO, "BootScriptPciCfg2Poll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2Poll.Segment, PciCfg2Poll.Address), AndMask, OrMask)); - - Status = ScriptPciCfg2Read ( - (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width, -@@ -1613,12 +1613,12 @@ S3BootScriptExecute ( - return EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_INFO, "S3BootScriptExecute:\n")); -+ DEBUG ((DEBUG_INFO, "S3BootScriptExecute:\n")); - if (TableHeader.OpCode != S3_BOOT_SCRIPT_LIB_TABLE_OPCODE) { - return EFI_UNSUPPORTED; - } - -- DEBUG ((EFI_D_INFO, "TableHeader - 0x%08x\n", Script)); -+ DEBUG ((DEBUG_INFO, "TableHeader - 0x%08x\n", Script)); - - StartAddress = (UINTN) Script; - TableLength = TableHeader.TableLength; -@@ -1627,22 +1627,22 @@ S3BootScriptExecute ( - AndMask = 0; - OrMask = 0; - -- DEBUG ((EFI_D_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version)); -- DEBUG ((EFI_D_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength)); -+ DEBUG ((DEBUG_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version)); -+ DEBUG ((DEBUG_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength)); - - while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) { -- DEBUG ((EFI_D_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script)); -+ DEBUG ((DEBUG_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script)); - - CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER)); - switch (ScriptHeader.OpCode) { - - case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n")); - Status = BootScriptExecuteMemoryWrite (Script); - break; - - case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecuteMemoryReadWrite ( - Script, -@@ -1652,17 +1652,17 @@ S3BootScriptExecute ( - break; - - case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n")); - Status = BootScriptExecuteIoWrite (Script); - break; - - case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n")); - Status = BootScriptExecutePciCfgWrite (Script); - break; - - case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecutePciCfgReadWrite ( - Script, -@@ -1671,12 +1671,12 @@ S3BootScriptExecute ( - ); - break; - case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n")); - Status = BootScriptExecutePciCfg2Write (Script); - break; - - case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecutePciCfg2ReadWrite ( - Script, -@@ -1685,27 +1685,27 @@ S3BootScriptExecute ( - ); - break; - case EFI_BOOT_SCRIPT_DISPATCH_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n")); - Status = BootScriptExecuteDispatch (Script); - break; - - case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n")); - Status = BootScriptExecuteDispatch2 (Script); - break; - - case EFI_BOOT_SCRIPT_INFORMATION_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n")); - BootScriptExecuteInformation (Script); - break; - - case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE: -- DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n")); -- DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS)); -+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS)); - return EFI_SUCCESS; - - case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecuteIoReadWrite ( - Script, -@@ -1715,36 +1715,36 @@ S3BootScriptExecute ( - break; - - case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n")); - Status = BootScriptExecuteSmbusExecute (Script); - break; - - case EFI_BOOT_SCRIPT_STALL_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n")); - Status = BootScriptExecuteStall (Script); - break; - - case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask); - - break; - - case EFI_BOOT_SCRIPT_IO_POLL_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask); - break; - - case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptPciCfgPoll (Script, AndMask, OrMask); - break; - - case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE: -- DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n")); - CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script); - Status = BootScriptPciCfg2Poll (Script, AndMask, OrMask); - break; -@@ -1753,24 +1753,23 @@ S3BootScriptExecute ( - // - // For label - // -- DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n")); -+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n")); - BootScriptExecuteLabel (Script); - break; - default: -- DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED)); - return EFI_UNSUPPORTED; - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", Status)); - return Status; - } - - Script = Script + ScriptHeader.Length; - } - -- DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", Status)); - - return Status; - } -- -diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c -index 9cdf475521..20378502c8 100644 ---- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c -+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c -@@ -573,7 +573,7 @@ S3BootScriptLibDeinitialize ( - return RETURN_SUCCESS; - } - -- DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName)); -+ DEBUG ((DEBUG_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName)); - - if (mEventDxeSmmReadyToLock != NULL) { - // -@@ -834,7 +834,7 @@ S3BootScriptGetEntryAddAddress ( - // Add DEBUG ERROR, so that we can find it after SmmReadyToLock. - // Do not use ASSERT, because we may have test to invoke this interface. - // -- DEBUG ((EFI_D_ERROR, "FATAL ERROR: Set boot script outside SMM after SmmReadyToLock!!!\n")); -+ DEBUG ((DEBUG_ERROR, "FATAL ERROR: Set boot script outside SMM after SmmReadyToLock!!!\n")); - return NULL; - } - -diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c -index 3875d614bb..0633f8197f 100644 ---- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c -+++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c -@@ -71,7 +71,7 @@ InternalGetVarErrorFlag ( - &ErrorFlag - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "%s - not found\n", VAR_ERROR_FLAG_NAME)); -+ DEBUG ((DEBUG_INFO, "%s - not found\n", VAR_ERROR_FLAG_NAME)); - return VAR_ERROR_FLAG_NO_ERROR; - } - return ErrorFlag; -@@ -115,16 +115,16 @@ IsUserVariable ( - // - // No property, it is user variable. - // -- DEBUG ((EFI_D_INFO, "PlatformVarCleanup - User variable: %g:%s\n", Guid, Name)); -+ DEBUG ((DEBUG_INFO, "PlatformVarCleanup - User variable: %g:%s\n", Guid, Name)); - return TRUE; - } - --// DEBUG ((EFI_D_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name)); --// DEBUG ((EFI_D_INFO, " Revision - 0x%04x\n", Property.Revision)); --// DEBUG ((EFI_D_INFO, " Property - 0x%04x\n", Property.Property)); --// DEBUG ((EFI_D_INFO, " Attribute - 0x%08x\n", Property.Attributes)); --// DEBUG ((EFI_D_INFO, " MinSize - 0x%x\n", Property.MinSize)); --// DEBUG ((EFI_D_INFO, " MaxSize - 0x%x\n", Property.MaxSize)); -+// DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name)); -+// DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", Property.Revision)); -+// DEBUG ((DEBUG_INFO, " Property - 0x%04x\n", Property.Property)); -+// DEBUG ((DEBUG_INFO, " Attribute - 0x%08x\n", Property.Attributes)); -+// DEBUG ((DEBUG_INFO, " MinSize - 0x%x\n", Property.MinSize)); -+// DEBUG ((DEBUG_INFO, " MaxSize - 0x%x\n", Property.MaxSize)); - - return FALSE; - } -@@ -276,7 +276,7 @@ CreateUserVariableNode ( - - mUserVariableCount = Index; - ASSERT (mUserVariableCount <= MAX_USER_VARIABLE_COUNT); -- DEBUG ((EFI_D_INFO, "PlatformVarCleanup - User variable count: 0x%04x\n", mUserVariableCount)); -+ DEBUG ((DEBUG_INFO, "PlatformVarCleanup - User variable count: 0x%04x\n", mUserVariableCount)); - - FreePool (VarName); - FreePool (Data); -@@ -515,7 +515,7 @@ DeleteUserVariable ( - UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink); - - if (!UserVariableNameNode->Deleted && (DeleteAll || ((VariableCleanupData != NULL) && (VariableCleanupData->UserVariable[UserVariableNameNode->Index] == TRUE)))) { -- DEBUG ((EFI_D_INFO, "PlatformVarCleanup - Delete variable: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name)); -+ DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Delete variable: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name)); - if ((UserVariableNameNode->Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) { - DataSize = 0; - Data = NULL; -@@ -538,7 +538,7 @@ DeleteUserVariable ( - if (!EFI_ERROR (Status)) { - UserVariableNameNode->Deleted = TRUE; - } else { -- DEBUG ((EFI_D_INFO, "PlatformVarCleanup - Delete variable fail: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name)); -+ DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Delete variable fail: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name)); - } - } - } -@@ -1052,8 +1052,8 @@ PlatformVarCleanup ( - // - // This sample does not support system variables cleanup. - // -- DEBUG ((EFI_D_ERROR, "NOTICE - VAR_ERROR_FLAG_SYSTEM_ERROR\n")); -- DEBUG ((EFI_D_ERROR, "Platform should have mechanism to reset system to manufacture mode\n")); -+ DEBUG ((DEBUG_ERROR, "NOTICE - VAR_ERROR_FLAG_SYSTEM_ERROR\n")); -+ DEBUG ((DEBUG_ERROR, "Platform should have mechanism to reset system to manufacture mode\n")); - return EFI_UNSUPPORTED; - } - -@@ -1232,7 +1232,7 @@ PlatformVarCleanupLibConstructor ( - EFI_STATUS Status; - - mLastVarErrorFlag = InternalGetVarErrorFlag (); -- DEBUG ((EFI_D_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag)); -+ DEBUG ((DEBUG_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag)); - - // - // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. -diff --git a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c -index 0af2fab296..e06944d833 100644 ---- a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c -+++ b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c -@@ -55,7 +55,7 @@ IpmiSubmitCommand ( - // - // Smm Ipmi Protocol is not installed. So, IPMI device is not present. - // -- DEBUG ((EFI_D_ERROR, "IpmiSubmitCommand for SMM Status - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "IpmiSubmitCommand for SMM Status - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c -index 95d185b639..a862e04a89 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c -@@ -1807,7 +1807,7 @@ EfiBootManagerBoot ( - } - - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[Bds] Failed to create Boot#### for a temporary boot - %r!\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[Bds] Failed to create Boot#### for a temporary boot - %r!\n", Status)); - BootOption->Status = Status; - return ; - } -@@ -1830,7 +1830,7 @@ EfiBootManagerBoot ( - // the boot option. - // - if (BmIsBootManagerMenuFilePath (BootOption->FilePath)) { -- DEBUG ((EFI_D_INFO, "[Bds] Booting Boot Manager Menu.\n")); -+ DEBUG ((DEBUG_INFO, "[Bds] Booting Boot Manager Menu.\n")); - BmStopHotkeyService (NULL, NULL); - } else { - EfiSignalEventReadyToBoot(); -@@ -2440,7 +2440,7 @@ BmRegisterBootManagerMenu ( - &DevicePath - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n")); -+ DEBUG ((DEBUG_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n")); - return EFI_NOT_FOUND; - } - ASSERT (DevicePath != NULL); -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c -index d89331784c..bdbb9a8770 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c -@@ -199,7 +199,7 @@ EfiBootManagerGetGopDevicePath ( - // - // Recursively look for GOP child in this frame buffer handle - // -- DEBUG ((EFI_D_INFO, "[Bds] Looking for GOP child deeper ... \n")); -+ DEBUG ((DEBUG_INFO, "[Bds] Looking for GOP child deeper ... \n")); - TempDevicePath = GopPool; - ReturnDevicePath = EfiBootManagerGetGopDevicePath (OpenInfoBuffer[Index].ControllerHandle); - GopPool = AppendDevicePathInstance (GopPool, ReturnDevicePath); -@@ -340,7 +340,7 @@ BmUpdateSystemTableConsole ( - // - Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize); - if (Instance == NULL) { -- DEBUG ((EFI_D_ERROR, "[Bds] No valid console instance is found for %s!\n", VarName)); -+ DEBUG ((DEBUG_ERROR, "[Bds] No valid console instance is found for %s!\n", VarName)); - // We should not ASSERT when all the console devices are removed. - // ASSERT_EFI_ERROR (EFI_NOT_FOUND); - FreePool (FullDevicePath); -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c -index fa1fd87d15..332a967d37 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c -@@ -129,7 +129,7 @@ BmDisplayMessages ( - DriverHealthInfo->ChildHandle - ); - -- DEBUG ((EFI_D_INFO, "Controller: %s\n", ControllerName)); -+ DEBUG ((DEBUG_INFO, "Controller: %s\n", ControllerName)); - Print (L"Controller: %s\n", ControllerName); - for (Index = 0; DriverHealthInfo->MessageList[Index].HiiHandle != NULL; Index++) { - String = HiiGetString ( -@@ -139,7 +139,7 @@ BmDisplayMessages ( - ); - if (String != NULL) { - Print (L" %s\n", String); -- DEBUG ((EFI_D_INFO, " %s\n", String)); -+ DEBUG ((DEBUG_INFO, " %s\n", String)); - FreePool (String); - } - } -@@ -167,7 +167,7 @@ BmRepairNotify ( - IN UINTN Limit - ) - { -- DEBUG ((EFI_D_INFO, "[BDS]RepairNotify: %d/%d\n", Value, Limit)); -+ DEBUG ((DEBUG_INFO, "[BDS]RepairNotify: %d/%d\n", Value, Limit)); - Print (L"[BDS]RepairNotify: %d/%d\n", Value, Limit); - - return EFI_SUCCESS; -@@ -556,7 +556,7 @@ BmRepairAllControllers ( - DriverHealthInfo[Index].ChildHandle - ); - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "%02d: %s - %s\n", - Index, - ControllerName, -@@ -579,7 +579,7 @@ BmRepairAllControllers ( - } - - if (RebootRequired) { -- DEBUG ((EFI_D_INFO, "[BDS] One of the Driver Health instances requires rebooting.\n")); -+ DEBUG ((DEBUG_INFO, "[BDS] One of the Driver Health instances requires rebooting.\n")); - gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); - } - } -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c -index c2d1447f59..25da95b669 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c -@@ -353,7 +353,7 @@ BmHotkeyCallback ( - return EFI_SUCCESS; - } - -- DEBUG ((EFI_D_INFO, "[Bds]BmHotkeyCallback: %04x:%04x\n", KeyData->Key.ScanCode, KeyData->Key.UnicodeChar)); -+ DEBUG ((DEBUG_INFO, "[Bds]BmHotkeyCallback: %04x:%04x\n", KeyData->Key.ScanCode, KeyData->Key.UnicodeChar)); - - EfiAcquireLock (&mBmHotkeyLock); - for ( Link = GetFirstNode (&mBmHotkeyList) -@@ -399,12 +399,12 @@ BmHotkeyCallback ( - mBmLoadOptionName[LoadOptionTypeBoot], Hotkey->BootOption - ); - Status = EfiBootManagerVariableToLoadOption (OptionName, &mBmHotkeyBootOption); -- DEBUG ((EFI_D_INFO, "[Bds]Hotkey for %s pressed - %r\n", OptionName, Status)); -+ DEBUG ((DEBUG_INFO, "[Bds]Hotkey for %s pressed - %r\n", OptionName, Status)); - if (EFI_ERROR (Status)) { - mBmHotkeyBootOption.OptionNumber = LoadOptionNumberUnassigned; - } - } else { -- DEBUG ((EFI_D_INFO, "[Bds]Continue key pressed!\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]Continue key pressed!\n")); - } - } - } else { -@@ -503,7 +503,7 @@ BmUnregisterHotkeyNotify ( - ); - if (!EFI_ERROR (Status)) { - Status = TxtInEx->UnregisterKeyNotify (TxtInEx, NotifyHandle); -- DEBUG ((EFI_D_INFO, "[Bds]UnregisterKeyNotify: %04x/%04x %r\n", Hotkey->KeyData[KeyIndex].Key.ScanCode, Hotkey->KeyData[KeyIndex].Key.UnicodeChar, Status)); -+ DEBUG ((DEBUG_INFO, "[Bds]UnregisterKeyNotify: %04x/%04x %r\n", Hotkey->KeyData[KeyIndex].Key.ScanCode, Hotkey->KeyData[KeyIndex].Key.UnicodeChar, Status)); - } - } - } -@@ -542,7 +542,7 @@ BmRegisterHotkeyNotify ( - &NotifyHandle - ); - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "[Bds]RegisterKeyNotify: %04x/%04x %08x/%02x %r\n", - Hotkey->KeyData[Index].Key.ScanCode, - Hotkey->KeyData[Index].Key.UnicodeChar, -@@ -830,7 +830,7 @@ BmStopHotkeyService ( - LIST_ENTRY *Link; - BM_HOTKEY *Hotkey; - -- DEBUG ((EFI_D_INFO, "[Bds]Stop Hotkey Service!\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]Stop Hotkey Service!\n")); - gBS->CloseEvent (Event); - - EfiAcquireLock (&mBmHotkeyLock); -@@ -873,7 +873,7 @@ EfiBootManagerStartHotkeyService ( - } - - if (mBmHotkeySupportCount == 0) { -- DEBUG ((EFI_D_INFO, "Bds: BootOptionSupport NV variable forbids starting the hotkey service.\n")); -+ DEBUG ((DEBUG_INFO, "Bds: BootOptionSupport NV variable forbids starting the hotkey service.\n")); - return EFI_UNSUPPORTED; - } - -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c -index 89372b3b97..30a6c840aa 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c -@@ -1081,7 +1081,7 @@ EfiBootManagerGetLoadOptions ( - - Status = EfiBootManagerVariableToLoadOption (OptionName, &Options[OptionIndex]); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "[Bds] %s doesn't exist - Update ****Order variable to remove the reference!!", OptionName)); -+ DEBUG ((DEBUG_INFO, "[Bds] %s doesn't exist - Update ****Order variable to remove the reference!!", OptionName)); - EfiBootManagerDeleteLoadOptionVariable (OptionNumber, LoadOptionType); - } else { - ASSERT (Options[OptionIndex].OptionNumber == OptionNumber); -diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c -index 89595747af..6e7af3e3d9 100644 ---- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c -+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c -@@ -208,9 +208,9 @@ BmSetMemoryTypeInformationVariable ( - // - // Use a heuristic to adjust the Memory Type Information for the next boot - // -- DEBUG ((EFI_D_INFO, "Memory Previous Current Next \n")); -- DEBUG ((EFI_D_INFO, " Type Pages Pages Pages \n")); -- DEBUG ((EFI_D_INFO, "====== ======== ======== ========\n")); -+ DEBUG ((DEBUG_INFO, "Memory Previous Current Next \n")); -+ DEBUG ((DEBUG_INFO, " Type Pages Pages Pages \n")); -+ DEBUG ((DEBUG_INFO, "====== ======== ======== ========\n")); - - for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) { - -@@ -253,7 +253,7 @@ BmSetMemoryTypeInformationVariable ( - MemoryTypeInformationModified = TRUE; - } - -- DEBUG ((EFI_D_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next)); -+ DEBUG ((DEBUG_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next)); - } - - // -@@ -276,14 +276,14 @@ BmSetMemoryTypeInformationVariable ( - // entry/resume cycle will not fail. - // - if (MemoryTypeInformationModified) { -- DEBUG ((EFI_D_INFO, "Memory Type Information settings change.\n")); -+ DEBUG ((DEBUG_INFO, "Memory Type Information settings change.\n")); - if (Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) { -- DEBUG ((EFI_D_INFO, "...Warm Reset!!!\n")); -+ DEBUG ((DEBUG_INFO, "...Warm Reset!!!\n")); - gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL); - } - } - } else { -- DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n")); -+ DEBUG ((DEBUG_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n")); - } - } - FreePool (PreviousMemoryTypeInformation); -@@ -385,7 +385,7 @@ BmPrintDp ( - CHAR16 *Str; - - Str = ConvertDevicePathToText (DevicePath, FALSE, FALSE); -- DEBUG ((EFI_D_INFO, "%s", Str)); -+ DEBUG ((DEBUG_INFO, "%s", Str)); - if (Str != NULL) { - FreePool (Str); - } -diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c -index 9596d760e9..e7cc76a7f0 100644 ---- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c -+++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c -@@ -280,7 +280,7 @@ VarCheckLibRegisterEndOfDxeCallback ( - (UINTN) Callback - ); - -- DEBUG ((EFI_D_INFO, "VarCheckLibRegisterEndOfDxeCallback - 0x%x %r\n", Callback, Status)); -+ DEBUG ((DEBUG_INFO, "VarCheckLibRegisterEndOfDxeCallback - 0x%x %r\n", Callback, Status)); - - return Status; - } -@@ -412,7 +412,7 @@ VarCheckLibRegisterAddressPointer ( - (UINTN) AddressPointer - ); - -- DEBUG ((EFI_D_INFO, "VarCheckLibRegisterAddressPointer - 0x%x %r\n", AddressPointer, Status)); -+ DEBUG ((DEBUG_INFO, "VarCheckLibRegisterAddressPointer - 0x%x %r\n", AddressPointer, Status)); - - return Status; - } -@@ -454,7 +454,7 @@ VarCheckLibRegisterSetVariableCheckHandler ( - (UINTN) Handler - ); - -- DEBUG ((EFI_D_INFO, "VarCheckLibRegisterSetVariableCheckHandler - 0x%x %r\n", Handler, Status)); -+ DEBUG ((DEBUG_INFO, "VarCheckLibRegisterSetVariableCheckHandler - 0x%x %r\n", Handler, Status)); - - return Status; - } -@@ -627,7 +627,7 @@ VarCheckLibSetVariableCheck ( - // - if ((Property != NULL) && (Property->Revision == VAR_CHECK_VARIABLE_PROPERTY_REVISION)) { - if ((RequestSource != VarCheckFromTrusted) && ((Property->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0)) { -- DEBUG ((EFI_D_INFO, "Variable Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "Variable Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName)); - return EFI_WRITE_PROTECTED; - } - if (!((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0))) { -@@ -635,12 +635,12 @@ VarCheckLibSetVariableCheck ( - // Not to delete variable. - // - if ((Property->Attributes != 0) && ((Attributes & (~EFI_VARIABLE_APPEND_WRITE)) != Property->Attributes)) { -- DEBUG ((EFI_D_INFO, "Variable Check Attributes(0x%08x to 0x%08x) fail %r - %g:%s\n", Property->Attributes, Attributes, EFI_INVALID_PARAMETER, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "Variable Check Attributes(0x%08x to 0x%08x) fail %r - %g:%s\n", Property->Attributes, Attributes, EFI_INVALID_PARAMETER, VendorGuid, VariableName)); - return EFI_INVALID_PARAMETER; - } - if (DataSize != 0) { - if ((DataSize < Property->MinSize) || (DataSize > Property->MaxSize)) { -- DEBUG ((EFI_D_INFO, "Variable Check DataSize fail(0x%x not in 0x%x - 0x%x) %r - %g:%s\n", DataSize, Property->MinSize, Property->MaxSize, EFI_INVALID_PARAMETER, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "Variable Check DataSize fail(0x%x not in 0x%x - 0x%x) %r - %g:%s\n", DataSize, Property->MinSize, Property->MaxSize, EFI_INVALID_PARAMETER, VendorGuid, VariableName)); - return EFI_INVALID_PARAMETER; - } - } -@@ -663,7 +663,7 @@ VarCheckLibSetVariableCheck ( - continue; - } - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Variable Check handler fail %r - %g:%s\n", Status, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "Variable Check handler fail %r - %g:%s\n", Status, VendorGuid, VariableName)); - return Status; - } - } -diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c -index 9a3f9187c4..31efa69148 100644 ---- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c -+++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c -@@ -63,7 +63,7 @@ VarCheckPcdInternalDumpHex ( - - Val[Index * 3] = 0; - Str[Index] = 0; -- DEBUG ((EFI_D_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str)); -+ DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str)); - - Data += Size; - Offset += Size; -@@ -116,7 +116,7 @@ VarCheckPcdValidData ( - // - // No match - // -- DEBUG ((EFI_D_INFO, "VarCheckPcdValidData fail: ValidList mismatch (0x%lx)\n", OneData)); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidList mismatch (0x%lx)\n", OneData)); - DEBUG_CODE (VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *) PcdValidData);); - return FALSE; - } -@@ -136,7 +136,7 @@ VarCheckPcdValidData ( - return TRUE; - } - } -- DEBUG ((EFI_D_INFO, "VarCheckPcdValidData fail: ValidRange mismatch (0x%lx)\n", OneData)); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidRange mismatch (0x%lx)\n", OneData)); - DEBUG_CODE (VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *) PcdValidData);); - return FALSE; - break; -@@ -199,14 +199,14 @@ SetVariableCheckHandlerPcd ( - // - // Found the Pcd Variable that could be used to do check. - // -- DEBUG ((EFI_D_INFO, "VarCheckPcdVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize)); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize)); - if ((PcdVariable->Attributes != 0) && PcdVariable->Attributes != Attributes) { -- DEBUG ((EFI_D_INFO, "VarCheckPcdVariable fail for Attributes - 0x%08x\n", PcdVariable->Attributes)); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdVariable fail for Attributes - 0x%08x\n", PcdVariable->Attributes)); - return EFI_SECURITY_VIOLATION; - } - - if (DataSize == 0) { -- DEBUG ((EFI_D_INFO, "VarCheckPcdVariable - CHECK PASS with DataSize == 0 !\n")); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdVariable - CHECK PASS with DataSize == 0 !\n")); - return EFI_SUCCESS; - } - -@@ -227,7 +227,7 @@ SetVariableCheckHandlerPcd ( - PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *) HEADER_ALIGN (((UINTN) PcdValidData + PcdValidData->Length)); - } - -- DEBUG ((EFI_D_INFO, "VarCheckPcdVariable - ALL CHECK PASS!\n")); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdVariable - ALL CHECK PASS!\n")); - return EFI_SUCCESS; - } - // -@@ -257,11 +257,11 @@ DumpPcdValidData ( - UINT64 OneValue; - UINT8 *Ptr; - -- DEBUG ((EFI_D_INFO, " VAR_CHECK_PCD_VALID_DATA_HEADER\n")); -- DEBUG ((EFI_D_INFO, " Type - 0x%02x\n", PcdValidData->Type)); -- DEBUG ((EFI_D_INFO, " Length - 0x%02x\n", PcdValidData->Length)); -- DEBUG ((EFI_D_INFO, " VarOffset - 0x%04x\n", PcdValidData->VarOffset)); -- DEBUG ((EFI_D_INFO, " StorageWidth - 0x%02x\n", PcdValidData->StorageWidth)); -+ DEBUG ((DEBUG_INFO, " VAR_CHECK_PCD_VALID_DATA_HEADER\n")); -+ DEBUG ((DEBUG_INFO, " Type - 0x%02x\n", PcdValidData->Type)); -+ DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", PcdValidData->Length)); -+ DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x\n", PcdValidData->VarOffset)); -+ DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x\n", PcdValidData->StorageWidth)); - - switch (PcdValidData->Type) { - case VarCheckPcdValidList: -@@ -271,16 +271,16 @@ DumpPcdValidData ( - CopyMem (&OneValue, Ptr, PcdValidData->StorageWidth); - switch (PcdValidData->StorageWidth) { - case sizeof (UINT8): -- DEBUG ((EFI_D_INFO, " ValidList - 0x%02x\n", OneValue)); -+ DEBUG ((DEBUG_INFO, " ValidList - 0x%02x\n", OneValue)); - break; - case sizeof (UINT16): -- DEBUG ((EFI_D_INFO, " ValidList - 0x%04x\n", OneValue)); -+ DEBUG ((DEBUG_INFO, " ValidList - 0x%04x\n", OneValue)); - break; - case sizeof (UINT32): -- DEBUG ((EFI_D_INFO, " ValidList - 0x%08x\n", OneValue)); -+ DEBUG ((DEBUG_INFO, " ValidList - 0x%08x\n", OneValue)); - break; - case sizeof (UINT64): -- DEBUG ((EFI_D_INFO, " ValidList - 0x%016lx\n", OneValue)); -+ DEBUG ((DEBUG_INFO, " ValidList - 0x%016lx\n", OneValue)); - break; - default: - ASSERT (FALSE); -@@ -302,20 +302,20 @@ DumpPcdValidData ( - - switch (PcdValidData->StorageWidth) { - case sizeof (UINT8): -- DEBUG ((EFI_D_INFO, " Minimum - 0x%02x\n", Minimum)); -- DEBUG ((EFI_D_INFO, " Maximum - 0x%02x\n", Maximum)); -+ DEBUG ((DEBUG_INFO, " Minimum - 0x%02x\n", Minimum)); -+ DEBUG ((DEBUG_INFO, " Maximum - 0x%02x\n", Maximum)); - break; - case sizeof (UINT16): -- DEBUG ((EFI_D_INFO, " Minimum - 0x%04x\n", Minimum)); -- DEBUG ((EFI_D_INFO, " Maximum - 0x%04x\n", Maximum)); -+ DEBUG ((DEBUG_INFO, " Minimum - 0x%04x\n", Minimum)); -+ DEBUG ((DEBUG_INFO, " Maximum - 0x%04x\n", Maximum)); - break; - case sizeof (UINT32): -- DEBUG ((EFI_D_INFO, " Minimum - 0x%08x\n", Minimum)); -- DEBUG ((EFI_D_INFO, " Maximum - 0x%08x\n", Maximum)); -+ DEBUG ((DEBUG_INFO, " Minimum - 0x%08x\n", Minimum)); -+ DEBUG ((DEBUG_INFO, " Maximum - 0x%08x\n", Maximum)); - break; - case sizeof (UINT64): -- DEBUG ((EFI_D_INFO, " Minimum - 0x%016lx\n", Minimum)); -- DEBUG ((EFI_D_INFO, " Maximum - 0x%016lx\n", Maximum)); -+ DEBUG ((DEBUG_INFO, " Minimum - 0x%016lx\n", Minimum)); -+ DEBUG ((DEBUG_INFO, " Maximum - 0x%016lx\n", Maximum)); - break; - default: - ASSERT (FALSE); -@@ -343,14 +343,14 @@ DumpPcdVariable ( - { - VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData; - -- DEBUG ((EFI_D_INFO, "VAR_CHECK_PCD_VARIABLE_HEADER\n")); -- DEBUG ((EFI_D_INFO, " Revision - 0x%04x\n", PcdVariable->Revision)); -- DEBUG ((EFI_D_INFO, " HeaderLength - 0x%04x\n", PcdVariable->HeaderLength)); -- DEBUG ((EFI_D_INFO, " Length - 0x%08x\n", PcdVariable->Length)); -- DEBUG ((EFI_D_INFO, " Type - 0x%02x\n", PcdVariable->Type)); -- DEBUG ((EFI_D_INFO, " Attributes - 0x%08x\n", PcdVariable->Attributes)); -- DEBUG ((EFI_D_INFO, " Guid - %g\n", &PcdVariable->Guid)); -- DEBUG ((EFI_D_INFO, " Name - %s\n", PcdVariable + 1)); -+ DEBUG ((DEBUG_INFO, "VAR_CHECK_PCD_VARIABLE_HEADER\n")); -+ DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", PcdVariable->Revision)); -+ DEBUG ((DEBUG_INFO, " HeaderLength - 0x%04x\n", PcdVariable->HeaderLength)); -+ DEBUG ((DEBUG_INFO, " Length - 0x%08x\n", PcdVariable->Length)); -+ DEBUG ((DEBUG_INFO, " Type - 0x%02x\n", PcdVariable->Type)); -+ DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", PcdVariable->Attributes)); -+ DEBUG ((DEBUG_INFO, " Guid - %g\n", &PcdVariable->Guid)); -+ DEBUG ((DEBUG_INFO, " Name - %s\n", PcdVariable + 1)); - - // - // For Pcd ValidData header align. -@@ -383,7 +383,7 @@ DumpVarCheckPcd ( - { - VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable; - -- DEBUG ((EFI_D_INFO, "DumpVarCheckPcd\n")); -+ DEBUG ((DEBUG_INFO, "DumpVarCheckPcd\n")); - - // - // For Pcd Variable header align. -@@ -436,7 +436,7 @@ LocateVarCheckPcdBin ( - mVarCheckPcdBinSize = VarCheckPcdBinSize; - FreePool (VarCheckPcdBin); - -- DEBUG ((EFI_D_INFO, "VarCheckPcdBin - at 0x%x size = 0x%x\n", mVarCheckPcdBin, mVarCheckPcdBinSize)); -+ DEBUG ((DEBUG_INFO, "VarCheckPcdBin - at 0x%x size = 0x%x\n", mVarCheckPcdBin, mVarCheckPcdBinSize)); - - #ifdef DUMP_VAR_CHECK_PCD - DEBUG_CODE ( -@@ -444,7 +444,7 @@ LocateVarCheckPcdBin ( - ); - #endif - } else { -- DEBUG ((EFI_D_INFO, "[VarCheckPcd] No VarCheckPcdBin found at the first RAW section\n")); -+ DEBUG ((DEBUG_INFO, "[VarCheckPcd] No VarCheckPcdBin found at the first RAW section\n")); - } - } - -diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c -index e3bf04a54f..5767213224 100644 ---- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c -+++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c -@@ -836,7 +836,7 @@ SetVariableCheckHandlerUefiDefined ( - // only permit the creation of variables with a UEFI Specification-defined - // VendorGuid when these variables are documented in the UEFI Specification. - // -- DEBUG ((EFI_D_INFO, "UEFI Variable Check fail %r - %s not in %g namespace\n", EFI_INVALID_PARAMETER, VariableName, VendorGuid)); -+ DEBUG ((DEBUG_INFO, "UEFI Variable Check fail %r - %s not in %g namespace\n", EFI_INVALID_PARAMETER, VariableName, VendorGuid)); - return EFI_INVALID_PARAMETER; - } - } -@@ -855,7 +855,7 @@ SetVariableCheckHandlerUefiDefined ( - Data - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "UEFI Variable Check function fail %r - %g:%s\n", Status, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "UEFI Variable Check function fail %r - %g:%s\n", Status, VendorGuid, VariableName)); - return Status; - } - } -diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c -index d98573d613..5019b49afe 100644 ---- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c -+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiSdt.c -@@ -1048,9 +1048,9 @@ FindPath ( - } - - DEBUG_CODE_BEGIN (); -- DEBUG ((EFI_D_ERROR, "AcpiSdt: FindPath - ")); -+ DEBUG ((DEBUG_ERROR, "AcpiSdt: FindPath - ")); - AmlPrintNameString (AmlPath); -- DEBUG ((EFI_D_ERROR, "\n")); -+ DEBUG ((DEBUG_ERROR, "\n")); - DEBUG_CODE_END (); - - if (AmlHandle->Signature == EFI_AML_ROOT_HANDLE_SIGNATURE) { -diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlNamespace.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlNamespace.c -index 8139f3ab44..d5d48f9455 100644 ---- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlNamespace.c -+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlNamespace.c -@@ -263,9 +263,9 @@ AmlInsertNodeToTree ( - // - // Oops!!!, There must be something wrong. - // -- DEBUG ((EFI_D_ERROR, "AML: Override Happen - %a!\n", NameString)); -- DEBUG ((EFI_D_ERROR, "AML: Existing Node - %x\n", AmlNodeList->Buffer)); -- DEBUG ((EFI_D_ERROR, "AML: New Buffer - %x\n", Buffer)); -+ DEBUG ((DEBUG_ERROR, "AML: Override Happen - %a!\n", NameString)); -+ DEBUG ((DEBUG_ERROR, "AML: Existing Node - %x\n", AmlNodeList->Buffer)); -+ DEBUG ((DEBUG_ERROR, "AML: New Buffer - %x\n", Buffer)); - - return NULL; - } -@@ -476,14 +476,14 @@ AmlDumpNodeInfo ( - CurrentLink = AmlParentNodeList->Children.ForwardLink; - - if (Level == 0) { -- DEBUG ((EFI_D_ERROR, "\\")); -+ DEBUG ((DEBUG_ERROR, "\\")); - } else { - for (Index = 0; Index < Level; Index++) { -- DEBUG ((EFI_D_ERROR, " ")); -+ DEBUG ((DEBUG_ERROR, " ")); - } - AmlPrintNameSeg (AmlParentNodeList->Name); - } -- DEBUG ((EFI_D_ERROR, "\n")); -+ DEBUG ((DEBUG_ERROR, "\n")); - - while (CurrentLink != &AmlParentNodeList->Children) { - CurrentAmlNodeList = EFI_AML_NODE_LIST_FROM_LINK (CurrentLink); -@@ -543,7 +543,7 @@ AmlFindPath ( - } - - DEBUG_CODE_BEGIN (); -- DEBUG ((EFI_D_ERROR, "AcpiSdt: NameSpace:\n")); -+ DEBUG ((DEBUG_ERROR, "AcpiSdt: NameSpace:\n")); - AmlDumpNodeInfo (AmlRootNodeList, 0); - DEBUG_CODE_END (); - -@@ -579,9 +579,9 @@ AmlFindPath ( - // - if (CurrentAmlNodeList != NULL) { - DEBUG_CODE_BEGIN (); -- DEBUG ((EFI_D_ERROR, "AcpiSdt: Search from: \\")); -+ DEBUG ((DEBUG_ERROR, "AcpiSdt: Search from: \\")); - AmlPrintNameSeg (CurrentAmlNodeList->Name); -- DEBUG ((EFI_D_ERROR, "\n")); -+ DEBUG ((DEBUG_ERROR, "\n")); - DEBUG_CODE_END (); - AmlNodeList = AmlFindNodeInTheTree ( - AmlPath, -diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlString.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlString.c -index d0b8b0d0f4..96341b7fec 100644 ---- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlString.c -+++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AmlString.c -@@ -457,19 +457,19 @@ AmlPrintNameSeg ( - IN UINT8 *Buffer - ) - { -- DEBUG ((EFI_D_ERROR, "%c", Buffer[0])); -+ DEBUG ((DEBUG_ERROR, "%c", Buffer[0])); - if ((Buffer[1] == '_') && (Buffer[2] == '_') && (Buffer[3] == '_')) { - return ; - } -- DEBUG ((EFI_D_ERROR, "%c", Buffer[1])); -+ DEBUG ((DEBUG_ERROR, "%c", Buffer[1])); - if ((Buffer[2] == '_') && (Buffer[3] == '_')) { - return ; - } -- DEBUG ((EFI_D_ERROR, "%c", Buffer[2])); -+ DEBUG ((DEBUG_ERROR, "%c", Buffer[2])); - if (Buffer[3] == '_') { - return ; - } -- DEBUG ((EFI_D_ERROR, "%c", Buffer[3])); -+ DEBUG ((DEBUG_ERROR, "%c", Buffer[3])); - return ; - } - -@@ -491,14 +491,14 @@ AmlPrintNameString ( - // RootChar - // - Buffer ++; -- DEBUG ((EFI_D_ERROR, "\\")); -+ DEBUG ((DEBUG_ERROR, "\\")); - } else if (*Buffer == AML_PARENT_PREFIX_CHAR) { - // - // ParentPrefixChar - // - do { - Buffer ++; -- DEBUG ((EFI_D_ERROR, "^")); -+ DEBUG ((DEBUG_ERROR, "^")); - } while (*Buffer == AML_PARENT_PREFIX_CHAR); - } - -@@ -530,7 +530,7 @@ AmlPrintNameString ( - AmlPrintNameSeg (Buffer); - Buffer += AML_NAME_SEG_SIZE; - for (Index = 0; Index < SegCount - 1; Index++) { -- DEBUG ((EFI_D_ERROR, ".")); -+ DEBUG ((DEBUG_ERROR, ".")); - AmlPrintNameSeg (Buffer); - Buffer += AML_NAME_SEG_SIZE; - } -diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c -index b2ae9ec3a4..4ed23979bd 100644 ---- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c -+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c -@@ -164,7 +164,7 @@ S3BootScriptExecutorEntryFunction ( - ); - } else { - // Unsupported for 32bit DXE, 64bit OS vector -- DEBUG (( EFI_D_ERROR, "Unsupported for 32bit DXE transfer to 64bit OS waking vector!\r\n")); -+ DEBUG (( DEBUG_ERROR, "Unsupported for 32bit DXE transfer to 64bit OS waking vector!\r\n")); - ASSERT (FALSE); - } - } else { -@@ -494,4 +494,3 @@ BootScriptExecutorEntryPoint ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c -index 68755554ad..5c20002077 100644 ---- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c -+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c -@@ -248,7 +248,7 @@ FpdtAllocateS3PerformanceTableMemory ( - EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)) - ); - } -- DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable)); -+ DEBUG ((DEBUG_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable)); - if (mAcpiS3PerformanceTable != NULL) { - CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate)); - } -@@ -526,11 +526,11 @@ FpdtStatusCodeListenerDxe ( - // - // Dump FPDT Boot Performance record. - // -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n")); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n")); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit = 0\n")); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n")); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n")); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesExit = 0\n")); - } else if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { - // - // Get the Boot performance table and then install it to ACPI table. -@@ -615,10 +615,10 @@ FpdtExitBootServicesEventNotify ( - // - // Dump FPDT Boot Performance record. - // -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart)); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); -- DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); -+ DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry)); - // - // ExitBootServicesExit will be updated later, so don't dump it here. - // -diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -index 493d09c785..6881466201 100644 ---- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -@@ -100,7 +100,7 @@ FpdtStatusCodeListenerPei ( - AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) S3PerformanceTablePointer; - ASSERT (AcpiS3PerformanceTable != NULL); - if (AcpiS3PerformanceTable->Header.Signature != EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE) { -- DEBUG ((EFI_D_ERROR, "FPDT S3 performance data in ACPI memory get corrupted\n")); -+ DEBUG ((DEBUG_ERROR, "FPDT S3 performance data in ACPI memory get corrupted\n")); - return EFI_ABORTED; - } - AcpiS3ResumeRecord = &AcpiS3PerformanceTable->S3Resume; -@@ -112,9 +112,9 @@ FpdtStatusCodeListenerPei ( - AcpiS3ResumeRecord->ResumeCount++; - AcpiS3ResumeRecord->AverageResume = DivU64x32 (S3ResumeTotal + AcpiS3ResumeRecord->FullResume, AcpiS3ResumeRecord->ResumeCount); - -- DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - ResumeCount = %d\n", AcpiS3ResumeRecord->ResumeCount)); -- DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - FullResume = %ld\n", AcpiS3ResumeRecord->FullResume)); -- DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - AverageResume = %ld\n", AcpiS3ResumeRecord->AverageResume)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - ResumeCount = %d\n", AcpiS3ResumeRecord->ResumeCount)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - FullResume = %ld\n", AcpiS3ResumeRecord->FullResume)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - AverageResume = %ld\n", AcpiS3ResumeRecord->AverageResume)); - - // - // Update S3 Suspend Performance Record. -@@ -132,8 +132,8 @@ FpdtStatusCodeListenerPei ( - AcpiS3SuspendRecord->SuspendStart = S3SuspendRecord.SuspendStart; - AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; - -- DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); -- DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); - - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, -diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c -index e7cd2a12a0..8df9d73a96 100644 ---- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c -+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/AcpiS3ContextSave.c -@@ -236,11 +236,11 @@ AcpiS3ContextSaveOnEndOfDxe ( - EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs; - VOID *Interface; - -- DEBUG ((EFI_D_INFO, "AcpiS3ContextSave!\n")); -+ DEBUG ((DEBUG_INFO, "AcpiS3ContextSave!\n")); - - Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO | EFI_D_WARN, "ACPI S3 context can't be saved without LockBox!\n")); -+ DEBUG ((DEBUG_INFO | DEBUG_WARN, "ACPI S3 context can't be saved without LockBox!\n")); - goto Done; - } - -@@ -291,12 +291,12 @@ AcpiS3ContextSaveOnEndOfDxe ( - AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateMemoryBelow4G (EfiReservedMemoryType, EFI_PAGE_SIZE); - SetMem ((VOID *)(UINTN)AcpiS3Context->S3DebugBufferAddress, EFI_PAGE_SIZE, 0xff); - -- DEBUG((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable)); -- DEBUG((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile)); -- DEBUG((EFI_D_INFO, "AcpiS3Context: S3NvsPageTableAddress is 0x%8x\n", AcpiS3Context->S3NvsPageTableAddress)); -- DEBUG((EFI_D_INFO, "AcpiS3Context: S3DebugBufferAddress is 0x%8x\n", AcpiS3Context->S3DebugBufferAddress)); -- DEBUG((EFI_D_INFO, "AcpiS3Context: BootScriptStackBase is 0x%8x\n", AcpiS3Context->BootScriptStackBase)); -- DEBUG((EFI_D_INFO, "AcpiS3Context: BootScriptStackSize is 0x%8x\n", AcpiS3Context->BootScriptStackSize)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: S3NvsPageTableAddress is 0x%8x\n", AcpiS3Context->S3NvsPageTableAddress)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: S3DebugBufferAddress is 0x%8x\n", AcpiS3Context->S3DebugBufferAddress)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: BootScriptStackBase is 0x%8x\n", AcpiS3Context->BootScriptStackBase)); -+ DEBUG((DEBUG_INFO, "AcpiS3Context: BootScriptStackSize is 0x%8x\n", AcpiS3Context->BootScriptStackSize)); - - Status = SaveLockBox ( - &gEfiAcpiVariableGuid, -@@ -322,4 +322,3 @@ Done: - Status = gBS->CloseEvent (Event); - ASSERT_EFI_ERROR (Status); - } -- -diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c -index 13c10bdc5b..4b10567eb3 100644 ---- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c -+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c -@@ -78,7 +78,7 @@ BdsDxeOnConnectConInCallBack ( - // Should not enter this case, if enter, the keyboard will not work. - // May need platfrom policy to connect keyboard. - // -- DEBUG ((EFI_D_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status)); -+ DEBUG ((DEBUG_WARN, "[Bds] Connect ConIn failed - %r!!!\n", Status)); - } - } - /** -@@ -315,11 +315,11 @@ BdsWait ( - EFI_STATUS Status; - UINT16 TimeoutRemain; - -- DEBUG ((EFI_D_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n")); - - TimeoutRemain = PcdGet16 (PcdPlatformBootTimeOut); - while (TimeoutRemain != 0) { -- DEBUG ((EFI_D_INFO, "[Bds]BdsWait(%d)..Zzzz...\n", (UINTN) TimeoutRemain)); -+ DEBUG ((DEBUG_INFO, "[Bds]BdsWait(%d)..Zzzz...\n", (UINTN) TimeoutRemain)); - PlatformBootManagerWaitCallback (TimeoutRemain); - - BdsReadKeys (); // BUGBUG: Only reading can signal HotkeyTriggered -@@ -353,7 +353,7 @@ BdsWait ( - if (PcdGet16 (PcdPlatformBootTimeOut) != 0 && TimeoutRemain == 0) { - PlatformBootManagerWaitCallback (0); - } -- DEBUG ((EFI_D_INFO, "[Bds]Exit the waiting!\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]Exit the waiting!\n")); - } - - /** -@@ -610,7 +610,7 @@ BdsFormalizeOSIndicationVariable ( - (Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)) - ){ - -- DEBUG ((EFI_D_ERROR, "[Bds] Unformalized OsIndications variable exists. Delete it\n")); -+ DEBUG ((DEBUG_ERROR, "[Bds] Unformalized OsIndications variable exists. Delete it\n")); - Status = gRT->SetVariable ( - EFI_OS_INDICATIONS_VARIABLE_NAME, - &gEfiGlobalVariableGuid, -@@ -693,7 +693,7 @@ BdsEntry ( - // - PERF_CROSSMODULE_END("DXE"); - PERF_CROSSMODULE_BEGIN("BDS"); -- DEBUG ((EFI_D_INFO, "[Bds] Entry...\n")); -+ DEBUG ((DEBUG_INFO, "[Bds] Entry...\n")); - - // - // Fill in FirmwareVendor and FirmwareRevision from PCDs -@@ -943,17 +943,17 @@ BdsEntry ( - - DEBUG_CODE ( - EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType; -- DEBUG ((EFI_D_INFO, "[Bds]OsIndication: %016x\n", OsIndication)); -- DEBUG ((EFI_D_INFO, "[Bds]=============Begin Load Options Dumping ...=============\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]OsIndication: %016x\n", OsIndication)); -+ DEBUG ((DEBUG_INFO, "[Bds]=============Begin Load Options Dumping ...=============\n")); - for (LoadOptionType = 0; LoadOptionType < LoadOptionTypeMax; LoadOptionType++) { - DEBUG (( -- EFI_D_INFO, " %s Options:\n", -+ DEBUG_INFO, " %s Options:\n", - mBdsLoadOptionName[LoadOptionType] - )); - LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionType); - for (Index = 0; Index < LoadOptionCount; Index++) { - DEBUG (( -- EFI_D_INFO, " %s%04x: %s \t\t 0x%04x\n", -+ DEBUG_INFO, " %s%04x: %s \t\t 0x%04x\n", - mBdsLoadOptionName[LoadOptionType], - LoadOptions[Index].OptionNumber, - LoadOptions[Index].Description, -@@ -962,7 +962,7 @@ BdsEntry ( - } - EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); - } -- DEBUG ((EFI_D_INFO, "[Bds]=============End Load Options Dumping=============\n")); -+ DEBUG ((DEBUG_INFO, "[Bds]=============End Load Options Dumping=============\n")); - ); - - // -@@ -1092,7 +1092,7 @@ BdsEntry ( - } - EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption); - -- DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n")); -+ DEBUG ((DEBUG_ERROR, "[Bds] Unable to boot!\n")); - PlatformBootManagerUnableToBoot (); - CpuDeadLoop (); - } -diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c -index 4a0567fa76..22704910dd 100644 ---- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c -+++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c -@@ -168,7 +168,7 @@ PageFaultHandler ( - AddressEncMask = PageFaultContext->AddressEncMask; - - PFAddress = AsmReadCr2 (); -- DEBUG ((EFI_D_ERROR, "CapsuleX64 - PageFaultHandler: Cr2 - %lx\n", PFAddress)); -+ DEBUG ((DEBUG_ERROR, "CapsuleX64 - PageFaultHandler: Cr2 - %lx\n", PFAddress)); - - if (PFAddress >= PhyMask + SIZE_4KB) { - return PageFaultContext->OriginalHandler; -diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/X64/SaveLongModeContext.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/X64/SaveLongModeContext.c -index d80d4ed3ac..eab24e4da0 100644 ---- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/X64/SaveLongModeContext.c -+++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/X64/SaveLongModeContext.c -@@ -186,7 +186,7 @@ PrepareContextForCapsulePei ( - &Registration - ); - } else { -- DEBUG ((EFI_D_ERROR, "FATAL ERROR: CapsuleLongModeBuffer cannot be saved: %r. Capsule in PEI may fail!\n", Status)); -+ DEBUG ((DEBUG_ERROR, "FATAL ERROR: CapsuleLongModeBuffer cannot be saved: %r. Capsule in PEI may fail!\n", Status)); - gBS->FreePages (LongModeBuffer.StackBaseAddress, EFI_SIZE_TO_PAGES (LongModeBuffer.StackSize)); - } - } -diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c -index e8cd4ce120..114c46addd 100644 ---- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c -+++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c -@@ -330,7 +330,7 @@ ToggleStateSyncKeyNotify ( - ); - } - mConIn.PhysicalKeyToggleState = KeyData->KeyState.KeyToggleState; -- DEBUG ((EFI_D_INFO, "Current toggle state is 0x%02x\n", mConIn.PhysicalKeyToggleState)); -+ DEBUG ((DEBUG_INFO, "Current toggle state is 0x%02x\n", mConIn.PhysicalKeyToggleState)); - } - - return EFI_SUCCESS; -@@ -3615,7 +3615,7 @@ ConSplitterTextInReadKeyStroke ( - // Signal ConnectConIn event on first call in Lazy ConIn mode - // - if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) { -- DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); -+ DEBUG ((DEBUG_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); - gBS->SignalEvent (Private->ConnectConInEvent); - mConInIsConnect = TRUE; - } -@@ -3809,7 +3809,7 @@ ConSplitterTextInReadKeyStrokeEx ( - // Signal ConnectConIn event on first call in Lazy ConIn mode - // - if (!mConInIsConnect && PcdGetBool (PcdConInConnectOnDemand)) { -- DEBUG ((EFI_D_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); -+ DEBUG ((DEBUG_INFO, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n")); - gBS->SignalEvent (Private->ConnectConInEvent); - mConInIsConnect = TRUE; - } -diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c -index d6d8db51d5..838c3337c7 100644 ---- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c -+++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c -@@ -337,7 +337,7 @@ InitializeGraphicsConsoleTextMode ( - - DEBUG_CODE ( - for (Index = 0; Index < ValidCount; Index++) { -- DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", -+ DEBUG ((DEBUG_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", - Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows)); - } - ); -@@ -551,7 +551,7 @@ GraphicsConsoleControllerDriverStart ( - } - } - -- DEBUG ((EFI_D_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution)); -+ DEBUG ((DEBUG_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution)); - - // - // Initialize the mode which GraphicsConsole supports. -@@ -2132,5 +2132,3 @@ InitializeGraphicsConsole ( - - return Status; - } -- -- -diff --git a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c -index 99a76aa55c..ef82daebed 100644 ---- a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c -+++ b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c -@@ -323,10 +323,10 @@ GraphicsOutputDriverBindingStart ( - // Use default device infomation when the device info HOB doesn't exist - // - DeviceInfo = &mDefaultGraphicsDeviceInfo; -- DEBUG ((EFI_D_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName)); -+ DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName)); - } else { - DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) (GET_GUID_HOB_DATA (HobStart)); -- DEBUG ((EFI_D_INFO, "[%a]: GraphicsDeviceInfo HOB:\n" -+ DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB:\n" - " VendorId = %04x, DeviceId = %04x,\n" - " RevisionId = %02x, BarIndex = %x,\n" - " SubsystemVendorId = %04x, SubsystemId = %04x\n", -@@ -395,7 +395,7 @@ GraphicsOutputDriverBindingStart ( - } - Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID**) &Resources); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "[%a]: BAR[%d]: Base = %lx, Length = %lx\n", -+ DEBUG ((DEBUG_INFO, "[%a]: BAR[%d]: Base = %lx, Length = %lx\n", - gEfiCallerBaseName, Index, Resources->AddrRangeMin, Resources->AddrLen)); - if ((Resources->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) && - (Resources->Len == (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3)) && -@@ -403,7 +403,7 @@ GraphicsOutputDriverBindingStart ( - (Resources->AddrLen >= GraphicsInfo->FrameBufferSize) - ) { - FrameBufferBase = Resources->AddrRangeMin; -- DEBUG ((EFI_D_INFO, "[%a]: ... matched!\n", gEfiCallerBaseName)); -+ DEBUG ((DEBUG_INFO, "[%a]: ... matched!\n", gEfiCallerBaseName)); - break; - } - } -diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c -index f8c71f95c1..4d6ede4c9f 100644 ---- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c -+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c -@@ -2025,7 +2025,7 @@ UnicodeToEfiKey ( - continue; - } - else { -- DEBUG ((EFI_D_ERROR, "Unexpected state in escape2\n")); -+ DEBUG ((DEBUG_ERROR, "Unexpected state in escape2\n")); - } - } - TerminalDevice->ResetState = RESET_STATE_DEFAULT; -diff --git a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c -index fd34f07eec..242dbf8eb1 100644 ---- a/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c -+++ b/MdeModulePkg/Universal/Disk/CdExpressPei/PeiCdExpress.c -@@ -231,9 +231,9 @@ UpdateBlocksAndVolumes ( - ) { - continue; - } -- DEBUG ((EFI_D_INFO, "PeiCdExpress InterfaceType is %d\n", Media2.InterfaceType)); -- DEBUG ((EFI_D_INFO, "PeiCdExpress MediaPresent is %d\n", Media2.MediaPresent)); -- DEBUG ((EFI_D_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media2.BlockSize)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress InterfaceType is %d\n", Media2.InterfaceType)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress MediaPresent is %d\n", Media2.MediaPresent)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media2.BlockSize)); - } else { - Status = BlockIoPpi->GetBlockDeviceMediaInfo ( - PeiServices, -@@ -248,14 +248,14 @@ UpdateBlocksAndVolumes ( - ) { - continue; - } -- DEBUG ((EFI_D_INFO, "PeiCdExpress DeviceType is %d\n", Media.DeviceType)); -- DEBUG ((EFI_D_INFO, "PeiCdExpress MediaPresent is %d\n", Media.MediaPresent)); -- DEBUG ((EFI_D_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media.BlockSize)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress DeviceType is %d\n", Media.DeviceType)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress MediaPresent is %d\n", Media.MediaPresent)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress BlockSize is 0x%x\n", Media.BlockSize)); - } - -- DEBUG ((EFI_D_INFO, "PeiCdExpress Status is %d\n", Status)); -+ DEBUG ((DEBUG_INFO, "PeiCdExpress Status is %d\n", Status)); - -- DEBUG ((EFI_D_INFO, "IndexBlockDevice is %d\n", IndexBlockDevice)); -+ DEBUG ((DEBUG_INFO, "IndexBlockDevice is %d\n", IndexBlockDevice)); - PrivateData->CapsuleData[PrivateData->CapsuleCount].IndexBlock = IndexBlockDevice; - if (BlockIo2) { - PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo2 = BlockIo2Ppi; -@@ -263,7 +263,7 @@ UpdateBlocksAndVolumes ( - PrivateData->CapsuleData[PrivateData->CapsuleCount].BlockIo = BlockIoPpi; - } - Status = FindRecoveryCapsules (PrivateData); -- DEBUG ((EFI_D_INFO, "Status is %d\n", Status)); -+ DEBUG ((DEBUG_INFO, "Status is %d\n", Status)); - - if (EFI_ERROR (Status)) { - continue; -diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c -index e19466bd26..235db92969 100644 ---- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c -+++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c -@@ -492,7 +492,7 @@ DiskIoCreateSubtask ( - } - } - DEBUG (( -- EFI_D_BLKIO, -+ DEBUG_BLKIO, - " %c:Lba/Offset/Length/WorkingBuffer/Buffer = %016lx/%08x/%08x/%08x/%08x\n", - Write ? 'W': 'R', Lba, Offset, Length, WorkingBuffer, Buffer - )); -@@ -540,7 +540,7 @@ DiskIoCreateSubtaskList ( - VOID *WorkingBuffer; - LIST_ENTRY *Link; - -- DEBUG ((EFI_D_BLKIO, "DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = %016lx/%08x/%08x\n", Offset, BufferSize, Buffer)); -+ DEBUG ((DEBUG_BLKIO, "DiskIo: Create subtasks for task: Offset/BufferSize/Buffer = %016lx/%08x/%08x\n", Offset, BufferSize, Buffer)); - - BlockSize = Instance->BlockIo->Media->BlockSize; - IoAlign = Instance->BlockIo->Media->IoAlign; -@@ -668,7 +668,7 @@ DiskIoCreateSubtaskList ( - // - // If there is not enough memory, downgrade to blocking access - // -- DEBUG ((EFI_D_VERBOSE, "DiskIo: No enough memory so downgrade to blocking access\n")); -+ DEBUG ((DEBUG_VERBOSE, "DiskIo: No enough memory so downgrade to blocking access\n")); - if (!DiskIoCreateSubtaskList (Instance, Write, Offset, BufferSize, BufferPtr, TRUE, SharedWorkingBuffer, Subtasks)) { - goto Done; - } -@@ -970,7 +970,7 @@ DiskIo2ReadWriteDisk ( - // Task->Token should be set to NULL by the DiskIo2OnReadWriteComplete - // It it's not, that means the non-blocking request was downgraded to blocking request. - // -- DEBUG ((EFI_D_VERBOSE, "DiskIo: Non-blocking request was downgraded to blocking request, signal event directly.\n")); -+ DEBUG ((DEBUG_VERBOSE, "DiskIo: Non-blocking request was downgraded to blocking request, signal event directly.\n")); - Task->Token->TransactionStatus = Status; - gBS->SignalEvent (Task->Token->Event); - } -diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c -index 3d2ff3bc29..e2b028f733 100644 ---- a/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c -+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/ElTorito.c -@@ -141,7 +141,7 @@ PartitionInstallElToritoChildHandles ( - Catalog - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "EltCheckDevice: error reading catalog %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "EltCheckDevice: error reading catalog %r\n", Status)); - continue; - } - // -@@ -149,7 +149,7 @@ PartitionInstallElToritoChildHandles ( - // to make sure it looks like a Catalog header - // - if (Catalog->Catalog.Indicator != ELTORITO_ID_CATALOG || Catalog->Catalog.Id55AA != 0xAA55) { -- DEBUG ((EFI_D_ERROR, "EltCheckBootCatalog: El Torito boot catalog header IDs not correct\n")); -+ DEBUG ((DEBUG_ERROR, "EltCheckBootCatalog: El Torito boot catalog header IDs not correct\n")); - continue; - } - -@@ -160,7 +160,7 @@ PartitionInstallElToritoChildHandles ( - } - - if ((Check & 0xFFFF) != 0) { -- DEBUG ((EFI_D_ERROR, "EltCheckBootCatalog: El Torito boot catalog header checksum failed\n")); -+ DEBUG ((DEBUG_ERROR, "EltCheckBootCatalog: El Torito boot catalog header checksum failed\n")); - continue; - } - -@@ -203,7 +203,7 @@ PartitionInstallElToritoChildHandles ( - break; - - default: -- DEBUG ((EFI_D_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType)); -+ DEBUG ((DEBUG_INIT, "EltCheckDevice: unsupported El Torito boot media type %x\n", Catalog->Boot.MediaType)); - SectorCount = 0; - SubBlockSize = Media->BlockSize; - break; -diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c -index efaff5e080..e985bd2c44 100644 ---- a/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c -+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c -@@ -225,8 +225,8 @@ PartitionInstallGptChildHandles ( - LastBlock = BlockIo->Media->LastBlock; - MediaId = BlockIo->Media->MediaId; - -- DEBUG ((EFI_D_INFO, " BlockSize : %d \n", BlockSize)); -- DEBUG ((EFI_D_INFO, " LastBlock : %lx \n", LastBlock)); -+ DEBUG ((DEBUG_INFO, " BlockSize : %d \n", BlockSize)); -+ DEBUG ((DEBUG_INFO, " LastBlock : %lx \n", LastBlock)); - - GptValidStatus = EFI_NOT_FOUND; - -@@ -291,43 +291,43 @@ PartitionInstallGptChildHandles ( - // Check primary and backup partition tables - // - if (!PartitionValidGptTable (BlockIo, DiskIo, PRIMARY_PART_HEADER_LBA, PrimaryHeader)) { -- DEBUG ((EFI_D_INFO, " Not Valid primary partition table\n")); -+ DEBUG ((DEBUG_INFO, " Not Valid primary partition table\n")); - - if (!PartitionValidGptTable (BlockIo, DiskIo, LastBlock, BackupHeader)) { -- DEBUG ((EFI_D_INFO, " Not Valid backup partition table\n")); -+ DEBUG ((DEBUG_INFO, " Not Valid backup partition table\n")); - goto Done; - } else { -- DEBUG ((EFI_D_INFO, " Valid backup partition table\n")); -- DEBUG ((EFI_D_INFO, " Restore primary partition table by the backup\n")); -+ DEBUG ((DEBUG_INFO, " Valid backup partition table\n")); -+ DEBUG ((DEBUG_INFO, " Restore primary partition table by the backup\n")); - if (!PartitionRestoreGptTable (BlockIo, DiskIo, BackupHeader)) { -- DEBUG ((EFI_D_INFO, " Restore primary partition table error\n")); -+ DEBUG ((DEBUG_INFO, " Restore primary partition table error\n")); - } - - if (PartitionValidGptTable (BlockIo, DiskIo, BackupHeader->AlternateLBA, PrimaryHeader)) { -- DEBUG ((EFI_D_INFO, " Restore backup partition table success\n")); -+ DEBUG ((DEBUG_INFO, " Restore backup partition table success\n")); - } - } - } else if (!PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) { -- DEBUG ((EFI_D_INFO, " Valid primary and !Valid backup partition table\n")); -- DEBUG ((EFI_D_INFO, " Restore backup partition table by the primary\n")); -+ DEBUG ((DEBUG_INFO, " Valid primary and !Valid backup partition table\n")); -+ DEBUG ((DEBUG_INFO, " Restore backup partition table by the primary\n")); - if (!PartitionRestoreGptTable (BlockIo, DiskIo, PrimaryHeader)) { -- DEBUG ((EFI_D_INFO, " Restore backup partition table error\n")); -+ DEBUG ((DEBUG_INFO, " Restore backup partition table error\n")); - } - - if (PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) { -- DEBUG ((EFI_D_INFO, " Restore backup partition table success\n")); -+ DEBUG ((DEBUG_INFO, " Restore backup partition table success\n")); - } - - } - -- DEBUG ((EFI_D_INFO, " Valid primary and Valid backup partition table\n")); -+ DEBUG ((DEBUG_INFO, " Valid primary and Valid backup partition table\n")); - - // - // Read the EFI Partition Entries - // - PartEntry = AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry); - if (PartEntry == NULL) { -- DEBUG ((EFI_D_ERROR, "Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, "Allocate pool error\n")); - goto Done; - } - -@@ -340,17 +340,17 @@ PartitionInstallGptChildHandles ( - ); - if (EFI_ERROR (Status)) { - GptValidStatus = Status; -- DEBUG ((EFI_D_ERROR, " Partition Entry ReadDisk error\n")); -+ DEBUG ((DEBUG_ERROR, " Partition Entry ReadDisk error\n")); - goto Done; - } - -- DEBUG ((EFI_D_INFO, " Partition entries read block success\n")); -+ DEBUG ((DEBUG_INFO, " Partition entries read block success\n")); - -- DEBUG ((EFI_D_INFO, " Number of partition entries: %d\n", PrimaryHeader->NumberOfPartitionEntries)); -+ DEBUG ((DEBUG_INFO, " Number of partition entries: %d\n", PrimaryHeader->NumberOfPartitionEntries)); - - PEntryStatus = AllocateZeroPool (PrimaryHeader->NumberOfPartitionEntries * sizeof (EFI_PARTITION_ENTRY_STATUS)); - if (PEntryStatus == NULL) { -- DEBUG ((EFI_D_ERROR, "Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, "Allocate pool error\n")); - goto Done; - } - -@@ -401,12 +401,12 @@ PartitionInstallGptChildHandles ( - } - CopyMem (&PartitionInfo.Info.Gpt, Entry, sizeof (EFI_PARTITION_ENTRY)); - -- DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index)); -- DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart)); -- DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA)); -- DEBUG ((EFI_D_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize)); -- DEBUG ((EFI_D_INFO, " Start : %lx", MultU64x32 (Entry->StartingLBA, BlockSize))); -- DEBUG ((EFI_D_INFO, " End : %lx\n", MultU64x32 (Entry->EndingLBA, BlockSize))); -+ DEBUG ((DEBUG_INFO, " Index : %d\n", (UINT32) Index)); -+ DEBUG ((DEBUG_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart)); -+ DEBUG ((DEBUG_INFO, " End LBA : %lx\n", (UINT64) Entry->EndingLBA)); -+ DEBUG ((DEBUG_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize)); -+ DEBUG ((DEBUG_INFO, " Start : %lx", MultU64x32 (Entry->StartingLBA, BlockSize))); -+ DEBUG ((DEBUG_INFO, " End : %lx\n", MultU64x32 (Entry->EndingLBA, BlockSize))); - - Status = PartitionInstallChildHandle ( - This, -@@ -425,7 +425,7 @@ PartitionInstallGptChildHandles ( - ); - } - -- DEBUG ((EFI_D_INFO, "Prepare to Free Pool\n")); -+ DEBUG ((DEBUG_INFO, "Prepare to Free Pool\n")); - - Done: - if (ProtectiveMbr != NULL) { -@@ -481,7 +481,7 @@ PartitionValidGptTable ( - PartHdr = AllocateZeroPool (BlockSize); - - if (PartHdr == NULL) { -- DEBUG ((EFI_D_ERROR, "Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, "Allocate pool error\n")); - return FALSE; - } - // -@@ -504,7 +504,7 @@ PartitionValidGptTable ( - PartHdr->MyLBA != Lba || - (PartHdr->SizeOfPartitionEntry < sizeof (EFI_PARTITION_ENTRY)) - ) { -- DEBUG ((EFI_D_INFO, "Invalid efi partition table header\n")); -+ DEBUG ((DEBUG_INFO, "Invalid efi partition table header\n")); - FreePool (PartHdr); - return FALSE; - } -@@ -523,7 +523,7 @@ PartitionValidGptTable ( - return FALSE; - } - -- DEBUG ((EFI_D_INFO, " Valid efi partition table header\n")); -+ DEBUG ((DEBUG_INFO, " Valid efi partition table header\n")); - FreePool (PartHdr); - return TRUE; - } -@@ -557,7 +557,7 @@ PartitionCheckGptEntryArrayCRC ( - // - Ptr = AllocatePool (PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry); - if (Ptr == NULL) { -- DEBUG ((EFI_D_ERROR, " Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, " Allocate pool error\n")); - return FALSE; - } - -@@ -577,7 +577,7 @@ PartitionCheckGptEntryArrayCRC ( - - Status = gBS->CalculateCrc32 (Ptr, Size, &Crc); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "CheckPEntryArrayCRC: Crc calculation failed\n")); -+ DEBUG ((DEBUG_ERROR, "CheckPEntryArrayCRC: Crc calculation failed\n")); - FreePool (Ptr); - return FALSE; - } -@@ -623,7 +623,7 @@ PartitionRestoreGptTable ( - PartHdr = AllocateZeroPool (BlockSize); - - if (PartHdr == NULL) { -- DEBUG ((EFI_D_ERROR, "Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, "Allocate pool error\n")); - return FALSE; - } - -@@ -651,7 +651,7 @@ PartitionRestoreGptTable ( - - Ptr = AllocatePool (PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry); - if (Ptr == NULL) { -- DEBUG ((EFI_D_ERROR, " Allocate pool error\n")); -+ DEBUG ((DEBUG_ERROR, " Allocate pool error\n")); - Status = EFI_OUT_OF_RESOURCES; - goto Done; - } -@@ -715,7 +715,7 @@ PartitionCheckGptEntry ( - UINTN Index1; - UINTN Index2; - -- DEBUG ((EFI_D_INFO, " start check partition entries\n")); -+ DEBUG ((DEBUG_INFO, " start check partition entries\n")); - for (Index1 = 0; Index1 < PartHeader->NumberOfPartitionEntries; Index1++) { - Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index1 * PartHeader->SizeOfPartitionEntry); - if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid)) { -@@ -758,7 +758,7 @@ PartitionCheckGptEntry ( - } - } - -- DEBUG ((EFI_D_INFO, " End check partition entries\n")); -+ DEBUG ((DEBUG_INFO, " End check partition entries\n")); - } - - -@@ -850,7 +850,7 @@ PartitionCheckCrcAltSize ( - } - - if ((MaxSize != 0) && (Size > MaxSize)) { -- DEBUG ((EFI_D_ERROR, "CheckCrc32: Size > MaxSize\n")); -+ DEBUG ((DEBUG_ERROR, "CheckCrc32: Size > MaxSize\n")); - return FALSE; - } - // -@@ -861,7 +861,7 @@ PartitionCheckCrcAltSize ( - - Status = gBS->CalculateCrc32 ((UINT8 *) Hdr, Size, &Crc); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc calculation failed\n")); -+ DEBUG ((DEBUG_ERROR, "CheckCrc32: Crc calculation failed\n")); - return FALSE; - } - // -@@ -874,7 +874,7 @@ PartitionCheckCrcAltSize ( - // - DEBUG_CODE_BEGIN (); - if (OrgCrc != Crc) { -- DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc check failed\n")); -+ DEBUG ((DEBUG_ERROR, "CheckCrc32: Crc check failed\n")); - } - DEBUG_CODE_END (); - -diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c -index f0c92aa09a..df25a93f85 100644 ---- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c -+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c -@@ -71,7 +71,7 @@ PartitionValidMbr ( - // with INT 13h - // - -- DEBUG((EFI_D_INFO, "PartitionValidMbr: Bad MBR partition size EndingLBA(%1x) > LastLBA(%1x)\n", EndingLBA, LastLba)); -+ DEBUG((DEBUG_INFO, "PartitionValidMbr: Bad MBR partition size EndingLBA(%1x) > LastLBA(%1x)\n", EndingLBA, LastLba)); - - return FALSE; - } -diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c -index 473e091320..aebc8a1dac 100644 ---- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c -+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c -@@ -417,7 +417,7 @@ PartitionDriverBindingStop ( - // bus driver. Hence, additional check is needed here. - // - if (HasChildren (ControllerHandle)) { -- DEBUG((EFI_D_ERROR, "PartitionDriverBindingStop: Still has child.\n")); -+ DEBUG((DEBUG_ERROR, "PartitionDriverBindingStop: Still has child.\n")); - return EFI_DEVICE_ERROR; - } - -@@ -486,7 +486,7 @@ PartitionDriverBindingStop ( - - if (BlockIo2 != NULL) { - Status = BlockIo2->FlushBlocksEx (BlockIo2, NULL); -- DEBUG((EFI_D_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status)); -+ DEBUG((DEBUG_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status)); - } else { - Status = EFI_SUCCESS; - } -@@ -1372,4 +1372,3 @@ HasChildren ( - - return (BOOLEAN) (Index < EntryCount); - } -- -diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c -index 13e2aed87c..1ecf8da1d3 100644 ---- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c -+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDriver.c -@@ -68,7 +68,7 @@ RamDiskAcpiCheck ( - ); - if (EFI_ERROR (Status)) { - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "RamDiskAcpiCheck: Cannot locate the EFI ACPI Table Protocol, " - "unable to publish RAM disks to NFIT.\n" - )); -@@ -85,7 +85,7 @@ RamDiskAcpiCheck ( - ); - if (EFI_ERROR (Status)) { - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "RamDiskAcpiCheck: Cannot locate the EFI ACPI Sdt Protocol, " - "unable to publish RAM disks to NFIT.\n" - )); -@@ -134,7 +134,7 @@ RamDiskDxeEntryPoint ( - &DummyInterface - ); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Driver already started!\n")); -+ DEBUG ((DEBUG_INFO, "Driver already started!\n")); - return EFI_ALREADY_STARTED; - } - -diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c -index a45a55c823..329de17ff9 100644 ---- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c -+++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskProtocol.c -@@ -194,7 +194,7 @@ RamDiskPublishNfit ( - >= PrivateData->StartingAddr + PrivateData->Size)) { - MemoryFound = TRUE; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "RamDiskPublishNfit: RAM disk with reserved memory type, will publish to NFIT.\n" - )); - break; -@@ -237,7 +237,7 @@ RamDiskPublishNfit ( - // A NFIT is already in the ACPI table. - // - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "RamDiskPublishNfit: A NFIT is already exist in the ACPI Table.\n" - )); - -@@ -300,7 +300,7 @@ RamDiskPublishNfit ( - // No NFIT is in the ACPI table, we will create one here. - // - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "RamDiskPublishNfit: No NFIT is in the ACPI Table, will create one.\n" - )); - -diff --git a/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c b/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c -index 92c738a3f6..a873f0ae2f 100644 ---- a/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c -+++ b/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c -@@ -523,7 +523,7 @@ DriverHealthManagerRepairNotify ( - IN UINTN Limit - ) - { -- DEBUG ((EFI_D_INFO, "[DriverHealthManagement]RepairNotify: %d/%d\n", Value, Limit)); -+ DEBUG ((DEBUG_INFO, "[DriverHealthManagement]RepairNotify: %d/%d\n", Value, Limit)); - return EFI_SUCCESS; - } - -@@ -958,7 +958,7 @@ DriverHealthManagerCallback ( - return EFI_INVALID_PARAMETER; - } - -- DEBUG ((EFI_D_ERROR, "QuestionId = %x\n", QuestionId)); -+ DEBUG ((DEBUG_ERROR, "QuestionId = %x\n", QuestionId)); - - // - // We will have returned from processing a callback - user either hit ESC to exit, or selected -@@ -983,5 +983,3 @@ DriverHealthManagerCallback ( - - return EFI_SUCCESS; - } -- -- -diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.c b/MdeModulePkg/Universal/EbcDxe/EbcInt.c -index eced1d5c7f..a255b4acc3 100644 ---- a/MdeModulePkg/Universal/EbcDxe/EbcInt.c -+++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.c -@@ -988,51 +988,51 @@ CommonEbcExceptionHandler ( - // We print debug information to let user know what happen. - // - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "EBC Interrupter Version - 0x%016lx\n", - (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF))) - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "Exception Type - 0x%016lx\n", - (UINT64)(UINTN)InterruptType - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " R0 - 0x%016lx, R1 - 0x%016lx\n", - SystemContext.SystemContextEbc->R0, - SystemContext.SystemContextEbc->R1 - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " R2 - 0x%016lx, R3 - 0x%016lx\n", - SystemContext.SystemContextEbc->R2, - SystemContext.SystemContextEbc->R3 - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " R4 - 0x%016lx, R5 - 0x%016lx\n", - SystemContext.SystemContextEbc->R4, - SystemContext.SystemContextEbc->R5 - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " R6 - 0x%016lx, R7 - 0x%016lx\n", - SystemContext.SystemContextEbc->R6, - SystemContext.SystemContextEbc->R7 - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " Flags - 0x%016lx\n", - SystemContext.SystemContextEbc->Flags - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " ControlFlags - 0x%016lx\n", - SystemContext.SystemContextEbc->ControlFlags - )); - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - " Ip - 0x%016lx\n\n", - SystemContext.SystemContextEbc->Ip - )); -diff --git a/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.c b/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.c -index a386a97705..83deb14749 100644 ---- a/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.c -+++ b/MdeModulePkg/Universal/EsrtDxe/EsrtDxe.c -@@ -485,10 +485,10 @@ EsrtDxeLockEsrtRepository( - Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock); - if (!EFI_ERROR (Status)) { - Status = VariableLock->RequestToLock (VariableLock, EFI_ESRT_FMP_VARIABLE_NAME, &gEfiCallerIdGuid); -- DEBUG((EFI_D_INFO, "EsrtDxe Lock EsrtFmp Variable Status 0x%x", Status)); -+ DEBUG((DEBUG_INFO, "EsrtDxe Lock EsrtFmp Variable Status 0x%x", Status)); - - Status = VariableLock->RequestToLock (VariableLock, EFI_ESRT_NONFMP_VARIABLE_NAME, &gEfiCallerIdGuid); -- DEBUG((EFI_D_INFO, "EsrtDxe Lock EsrtNonFmp Variable Status 0x%x", Status)); -+ DEBUG((DEBUG_INFO, "EsrtDxe Lock EsrtNonFmp Variable Status 0x%x", Status)); - } - - return Status; -@@ -539,7 +539,7 @@ EsrtReadyToBootEventNotify ( - } - - if (NonFmpRepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY) != 0) { -- DEBUG((EFI_D_ERROR, "NonFmp Repository Corrupt. Need to rebuild NonFmp Repository.\n")); -+ DEBUG((DEBUG_ERROR, "NonFmp Repository Corrupt. Need to rebuild NonFmp Repository.\n")); - NonFmpRepositorySize = 0; - } - -@@ -558,7 +558,7 @@ EsrtReadyToBootEventNotify ( - } - - if (FmpRepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY) != 0) { -- DEBUG((EFI_D_ERROR, "Fmp Repository Corrupt. Need to rebuild Fmp Repository.\n")); -+ DEBUG((DEBUG_ERROR, "Fmp Repository Corrupt. Need to rebuild Fmp Repository.\n")); - FmpRepositorySize = 0; - } - -@@ -573,7 +573,7 @@ EsrtReadyToBootEventNotify ( - - EsrtTable = AllocatePool(sizeof(EFI_SYSTEM_RESOURCE_TABLE) + NonFmpRepositorySize + FmpRepositorySize); - if (EsrtTable == NULL) { -- DEBUG ((EFI_D_ERROR, "Esrt table memory allocation failure\n")); -+ DEBUG ((DEBUG_ERROR, "Esrt table memory allocation failure\n")); - goto EXIT; - } - -diff --git a/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c b/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c -index fff17b98fa..0fa8c2ee99 100644 ---- a/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c -+++ b/MdeModulePkg/Universal/EsrtDxe/EsrtImpl.c -@@ -56,7 +56,7 @@ GetEsrtEntry ( - } - - if (RepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY) != 0) { -- DEBUG((EFI_D_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); -+ DEBUG((DEBUG_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); - Status = EFI_ABORTED; - goto EXIT; - } -@@ -137,7 +137,7 @@ InsertEsrtEntry( - // if exist, update Esrt cache repository - // - if (RepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY) != 0) { -- DEBUG((EFI_D_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); -+ DEBUG((DEBUG_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); - // - // Repository is corrupt. Clear Repository before insert new entry - // -@@ -245,7 +245,7 @@ DeleteEsrtEntry( - } - - if ((RepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY)) != 0) { -- DEBUG((EFI_D_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); -+ DEBUG((DEBUG_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); - // - // Repository is corrupt. Clear Repository before insert new entry - // -@@ -347,7 +347,7 @@ UpdateEsrtEntry( - // if exist, update Esrt cache repository - // - if (RepositorySize % sizeof(EFI_SYSTEM_RESOURCE_ENTRY) != 0) { -- DEBUG((EFI_D_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); -+ DEBUG((DEBUG_ERROR, "Repository Corrupt. Need to rebuild Repository.\n")); - // - // Repository is corrupt. Clear Repository before insert new entry - // -diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c -index 484763225f..dbe5c00ba5 100644 ---- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c -+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.c -@@ -89,7 +89,7 @@ FtwAllocate ( - // Check if there is enough space for the coming allocation - // - if (FTW_WRITE_TOTAL_SIZE (NumberOfWrites, PrivateDataSize) > FtwDevice->FtwWorkSpaceHeader->WriteQueueSize) { -- DEBUG ((EFI_D_ERROR, "Ftw: Allocate() request exceed Workspace, Caller: %g\n", CallerId)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Allocate() request exceed Workspace, Caller: %g\n", CallerId)); - return EFI_BUFFER_TOO_SMALL; - } - // -@@ -153,7 +153,7 @@ FtwAllocate ( - } - - DEBUG ( -- (EFI_D_INFO, -+ (DEBUG_INFO, - "Ftw: Allocate() success, Caller:%g, # %d\n", - CallerId, - NumberOfWrites) -@@ -358,8 +358,8 @@ FtwWrite ( - // Ftw Write Header is not allocated - // Additional private data is not NULL, the private data size can't be determined. - // -- DEBUG ((EFI_D_ERROR, "Ftw: no allocates space for write record!\n")); -- DEBUG ((EFI_D_ERROR, "Ftw: Allocate service should be called before Write service!\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: no allocates space for write record!\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Allocate service should be called before Write service!\n")); - return EFI_NOT_READY; - } - } -@@ -396,7 +396,7 @@ FtwWrite ( - - Status = Fvb->GetPhysicalAddress (Fvb, &FvbPhysicalAddress); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Write(), Get FVB physical address - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Write(), Get FVB physical address - %r\n", Status)); - return EFI_ABORTED; - } - -@@ -405,12 +405,12 @@ FtwWrite ( - // - Status = Fvb->GetBlockSize (Fvb, 0, &BlockSize, &NumberOfBlocks); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Write(), Get block size - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Write(), Get block size - %r\n", Status)); - return EFI_ABORTED; - } - - NumberOfWriteBlocks = FTW_BLOCKS (Offset + Length, BlockSize); -- DEBUG ((EFI_D_INFO, "Ftw: Write(), BlockSize - 0x%x, NumberOfWriteBlock - 0x%x\n", BlockSize, NumberOfWriteBlocks)); -+ DEBUG ((DEBUG_INFO, "Ftw: Write(), BlockSize - 0x%x, NumberOfWriteBlock - 0x%x\n", BlockSize, NumberOfWriteBlocks)); - WriteLength = NumberOfWriteBlocks * BlockSize; - - // -@@ -611,7 +611,7 @@ FtwWrite ( - FreePool (SpareBuffer); - - DEBUG ( -- (EFI_D_INFO, -+ (DEBUG_INFO, - "Ftw: Write() success, (Lba:Offset)=(%lx:0x%x), Length: 0x%x\n", - Lba, - Offset, -@@ -674,7 +674,7 @@ FtwRestart ( - // - Status = Fvb->GetBlockSize (Fvb, 0, &BlockSize, &NumberOfBlocks); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Restart(), Get block size - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Restart(), Get block size - %r\n", Status)); - return EFI_ABORTED; - } - -@@ -714,7 +714,7 @@ FtwRestart ( - return EFI_ABORTED; - } - -- DEBUG ((EFI_D_INFO, "%a(): success\n", __FUNCTION__)); -+ DEBUG ((DEBUG_INFO, "%a(): success\n", __FUNCTION__)); - return EFI_SUCCESS; - } - -@@ -769,7 +769,7 @@ FtwAbort ( - - FtwDevice->FtwLastWriteHeader->Complete = FTW_VALID_STATE; - -- DEBUG ((EFI_D_INFO, "%a(): success\n", __FUNCTION__)); -+ DEBUG ((DEBUG_INFO, "%a(): success\n", __FUNCTION__)); - return EFI_SUCCESS; - } - -@@ -880,8 +880,7 @@ FtwGetLastWrite ( - Status = EFI_SUCCESS; - } - -- DEBUG ((EFI_D_INFO, "%a(): success\n", __FUNCTION__)); -+ DEBUG ((DEBUG_INFO, "%a(): success\n", __FUNCTION__)); - - return Status; - } -- -diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c -index 9612b39486..de7544e0ac 100644 ---- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c -+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c -@@ -324,13 +324,13 @@ SmmFaultTolerantWriteHandler ( - TempCommBufferSize = *CommBufferSize; - - if (TempCommBufferSize < SMM_FTW_COMMUNICATE_HEADER_SIZE) { -- DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmFtwHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE; - - if (!FtwSmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) { -- DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n")); - return EFI_SUCCESS; - } - -@@ -340,7 +340,7 @@ SmmFaultTolerantWriteHandler ( - // - // It will be not safe to expose the operations after End Of Dxe. - // -- DEBUG ((EFI_D_ERROR, "SmmFtwHandler: Not safe to do the operation: %x after End Of Dxe, so access denied!\n", SmmFtwFunctionHeader->Function)); -+ DEBUG ((DEBUG_ERROR, "SmmFtwHandler: Not safe to do the operation: %x after End Of Dxe, so access denied!\n", SmmFtwFunctionHeader->Function)); - SmmFtwFunctionHeader->ReturnStatus = EFI_ACCESS_DENIED; - return EFI_SUCCESS; - } -@@ -348,7 +348,7 @@ SmmFaultTolerantWriteHandler ( - switch (SmmFtwFunctionHeader->Function) { - case FTW_FUNCTION_GET_MAX_BLOCK_SIZE: - if (CommBufferPayloadSize < sizeof (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "GetMaxBlockSize: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "GetMaxBlockSize: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmmGetMaxBlockSizeHeader = (SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER *) SmmFtwFunctionHeader->Data; -@@ -361,7 +361,7 @@ SmmFaultTolerantWriteHandler ( - - case FTW_FUNCTION_ALLOCATE: - if (CommBufferPayloadSize < sizeof (SMM_FTW_ALLOCATE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Allocate: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "Allocate: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmmFtwAllocateHeader = (SMM_FTW_ALLOCATE_HEADER *) SmmFtwFunctionHeader->Data; -@@ -375,7 +375,7 @@ SmmFaultTolerantWriteHandler ( - - case FTW_FUNCTION_WRITE: - if (CommBufferPayloadSize < OFFSET_OF (SMM_FTW_WRITE_HEADER, Data)) { -- DEBUG ((EFI_D_ERROR, "Write: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "Write: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmmFtwWriteHeader = (SMM_FTW_WRITE_HEADER *) SmmFtwFunctionHeader->Data; -@@ -395,7 +395,7 @@ SmmFaultTolerantWriteHandler ( - // SMRAM range check already covered before - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "Write: Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "Write: Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - break; - } -@@ -431,7 +431,7 @@ SmmFaultTolerantWriteHandler ( - - case FTW_FUNCTION_RESTART: - if (CommBufferPayloadSize < sizeof (SMM_FTW_RESTART_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Restart: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "Restart: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmmFtwRestartHeader = (SMM_FTW_RESTART_HEADER *) SmmFtwFunctionHeader->Data; -@@ -451,7 +451,7 @@ SmmFaultTolerantWriteHandler ( - - case FTW_FUNCTION_GET_LAST_WRITE: - if (CommBufferPayloadSize < OFFSET_OF (SMM_FTW_GET_LAST_WRITE_HEADER, Data)) { -- DEBUG ((EFI_D_ERROR, "GetLastWrite: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "GetLastWrite: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - SmmFtwGetLastWriteHeader = (SMM_FTW_GET_LAST_WRITE_HEADER *) SmmFtwFunctionHeader->Data; -@@ -469,7 +469,7 @@ SmmFaultTolerantWriteHandler ( - // SMRAM range check already covered before - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - break; - } -diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c -index ed73f887aa..dce50e81ab 100644 ---- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c -+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c -@@ -340,7 +340,7 @@ FlushSpareBlockToBootBlock ( - // - Status = SarProtocol->GetSwapState (SarProtocol, &TopSwap); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Get Top Swapped status - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Get Top Swapped status - %r\n", Status)); - FreePool (Buffer); - return EFI_ABORTED; - } -@@ -427,7 +427,7 @@ FlushSpareBlockToBootBlock ( - Ptr - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: FVB Write boot block - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: FVB Write boot block - %r\n", Status)); - FreePool (Buffer); - return Status; - } -@@ -526,7 +526,7 @@ FlushSpareBlockToTargetBlock ( - Count = BlockSize; - Status = FvBlock->Write (FvBlock, Lba + Index, 0, &Count, Ptr); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: FVB Write block - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: FVB Write block - %r\n", Status)); - FreePool (Buffer); - return Status; - } -@@ -667,7 +667,7 @@ FlushSpareBlockToWorkingBlock ( - Ptr - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: FVB Write block - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: FVB Write block - %r\n", Status)); - FreePool (Buffer); - return Status; - } -@@ -984,7 +984,7 @@ InitFtwDevice ( - FtwDevice->WorkSpaceLength = (UINTN) PcdGet32 (PcdFlashNvStorageFtwWorkingSize); - FtwDevice->SpareAreaLength = (UINTN) PcdGet32 (PcdFlashNvStorageFtwSpareSize); - if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Workspace or Spare block does not exist!\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Workspace or Spare block does not exist!\n")); - FreePool (FtwDevice); - return EFI_INVALID_PARAMETER; - } -@@ -1103,13 +1103,13 @@ FindFvbForFtw ( - // - if (((FtwDevice->WorkSpaceAddress & (FtwDevice->WorkBlockSize - 1)) != 0) || - ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - 1)) != 0)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Work space address or length is not block size aligned when work space size is larger than one block size\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Work space address or length is not block size aligned when work space size is larger than one block size\n")); - FreePool (HandleBuffer); - ASSERT (FALSE); - return EFI_ABORTED; - } - } else if ((FtwDevice->FtwWorkSpaceBase + FtwDevice->FtwWorkSpaceSize) > FtwDevice->WorkBlockSize) { -- DEBUG ((EFI_D_ERROR, "Ftw: The work space range should not span blocks when work space size is less than one block size\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: The work space range should not span blocks when work space size is less than one block size\n")); - FreePool (HandleBuffer); - ASSERT (FALSE); - return EFI_ABORTED; -@@ -1138,7 +1138,7 @@ FindFvbForFtw ( - // Check the range of spare area to make sure that it's in FV range - // - if ((FtwDevice->FtwSpareLba + FtwDevice->NumberOfSpareBlock) > NumberOfBlocks) { -- DEBUG ((EFI_D_ERROR, "Ftw: Spare area is out of FV range\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Spare area is out of FV range\n")); - FreePool (HandleBuffer); - ASSERT (FALSE); - return EFI_ABORTED; -@@ -1148,7 +1148,7 @@ FindFvbForFtw ( - // - if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize - 1)) != 0) || - ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Spare area address or length is not block size aligned\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not block size aligned\n")); - FreePool (HandleBuffer); - // - // Report Status Code EFI_SW_EC_ABORTED. -@@ -1168,8 +1168,8 @@ FindFvbForFtw ( - (FtwDevice->FtwWorkSpaceLba == (EFI_LBA) (-1)) || (FtwDevice->FtwSpareLba == (EFI_LBA) (-1))) { - return EFI_ABORTED; - } -- DEBUG ((EFI_D_INFO, "Ftw: FtwWorkSpaceLba - 0x%lx, WorkBlockSize - 0x%x, FtwWorkSpaceBase - 0x%x\n", FtwDevice->FtwWorkSpaceLba, FtwDevice->WorkBlockSize, FtwDevice->FtwWorkSpaceBase)); -- DEBUG ((EFI_D_INFO, "Ftw: FtwSpareLba - 0x%lx, SpareBlockSize - 0x%x\n", FtwDevice->FtwSpareLba, FtwDevice->SpareBlockSize)); -+ DEBUG ((DEBUG_INFO, "Ftw: FtwWorkSpaceLba - 0x%lx, WorkBlockSize - 0x%x, FtwWorkSpaceBase - 0x%x\n", FtwDevice->FtwWorkSpaceLba, FtwDevice->WorkBlockSize, FtwDevice->FtwWorkSpaceBase)); -+ DEBUG ((DEBUG_INFO, "Ftw: FtwSpareLba - 0x%lx, SpareBlockSize - 0x%x\n", FtwDevice->FtwSpareLba, FtwDevice->SpareBlockSize)); - - return EFI_SUCCESS; - } -@@ -1225,7 +1225,7 @@ InitFtwProtocol ( - } - } - FtwDevice->FtwWorkBlockLba = FtwDevice->FtwWorkSpaceLba + FtwDevice->NumberOfWorkSpaceBlock - FtwDevice->NumberOfWorkBlock; -- DEBUG ((EFI_D_INFO, "Ftw: NumberOfWorkBlock - 0x%x, FtwWorkBlockLba - 0x%lx\n", FtwDevice->NumberOfWorkBlock, FtwDevice->FtwWorkBlockLba)); -+ DEBUG ((DEBUG_INFO, "Ftw: NumberOfWorkBlock - 0x%x, FtwWorkBlockLba - 0x%lx\n", FtwDevice->NumberOfWorkBlock, FtwDevice->FtwWorkBlockLba)); - - // - // Calcualte the LBA and base of work space in spare block. -@@ -1234,7 +1234,7 @@ InitFtwProtocol ( - WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba; - FtwDevice->FtwWorkSpaceLbaInSpare = (EFI_LBA) (((UINTN) WorkSpaceLbaOffset * FtwDevice->WorkBlockSize + FtwDevice->FtwWorkSpaceBase) / FtwDevice->SpareBlockSize); - FtwDevice->FtwWorkSpaceBaseInSpare = ((UINTN) WorkSpaceLbaOffset * FtwDevice->WorkBlockSize + FtwDevice->FtwWorkSpaceBase) % FtwDevice->SpareBlockSize; -- DEBUG ((EFI_D_INFO, "Ftw: WorkSpaceLbaInSpare - 0x%lx, WorkSpaceBaseInSpare - 0x%x\n", FtwDevice->FtwWorkSpaceLbaInSpare, FtwDevice->FtwWorkSpaceBaseInSpare)); -+ DEBUG ((DEBUG_INFO, "Ftw: WorkSpaceLbaInSpare - 0x%lx, WorkSpaceBaseInSpare - 0x%x\n", FtwDevice->FtwWorkSpaceLbaInSpare, FtwDevice->FtwWorkSpaceBaseInSpare)); - - // - // Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE. -@@ -1274,7 +1274,7 @@ InitFtwProtocol ( - // - if (IsValidWorkSpace (FtwDevice->FtwWorkSpaceHeader)) { - Status = FlushSpareBlockToWorkingBlock (FtwDevice); -- DEBUG ((EFI_D_INFO, "Ftw: Restart working block update in %a() - %r\n", -+ DEBUG ((DEBUG_INFO, "Ftw: Restart working block update in %a() - %r\n", - __FUNCTION__, Status)); - FtwAbort (&FtwDevice->FtwInstance); - // -@@ -1283,7 +1283,7 @@ InitFtwProtocol ( - Status = WorkSpaceRefresh (FtwDevice); - ASSERT_EFI_ERROR (Status); - } else { -- DEBUG ((EFI_D_INFO, -+ DEBUG ((DEBUG_INFO, - "Ftw: Both working and spare blocks are invalid, init workspace\n")); - // - // If both are invalid, then initialize work space. -@@ -1309,7 +1309,7 @@ InitFtwProtocol ( - (FtwDevice->FtwLastWriteRecord->SpareComplete != FTW_VALID_STATE) && - IsFirstRecordOfWrites (FtwDevice->FtwLastWriteHeader, FtwDevice->FtwLastWriteRecord) - ) { -- DEBUG ((EFI_D_ERROR, "Ftw: Init.. find first record not SpareCompleted, abort()\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Init.. find first record not SpareCompleted, abort()\n")); - FtwAbort (&FtwDevice->FtwInstance); - } - // -@@ -1320,7 +1320,7 @@ InitFtwProtocol ( - (FtwDevice->FtwLastWriteRecord->DestinationComplete == FTW_VALID_STATE) && - IsLastRecordOfWrites (FtwDevice->FtwLastWriteHeader, FtwDevice->FtwLastWriteRecord) - ) { -- DEBUG ((EFI_D_ERROR, "Ftw: Init.. find last record completed but header not, abort()\n")); -+ DEBUG ((DEBUG_ERROR, "Ftw: Init.. find last record completed but header not, abort()\n")); - FtwAbort (&FtwDevice->FtwInstance); - } - // -@@ -1346,7 +1346,7 @@ InitFtwProtocol ( - ) { - if (FtwDevice->FtwLastWriteRecord->BootBlockUpdate == FTW_VALID_STATE) { - Status = FlushSpareBlockToBootBlock (FtwDevice); -- DEBUG ((EFI_D_ERROR, "Ftw: Restart boot block update - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Restart boot block update - %r\n", Status)); - ASSERT_EFI_ERROR (Status); - FtwAbort (&FtwDevice->FtwInstance); - } else { -@@ -1357,7 +1357,7 @@ InitFtwProtocol ( - FvbHandle = GetFvbByAddress ((EFI_PHYSICAL_ADDRESS) (UINTN) ((INT64) FtwDevice->SpareAreaAddress + FtwDevice->FtwLastWriteRecord->RelativeOffset), &Fvb); - if (FvbHandle != NULL) { - Status = FtwRestart (&FtwDevice->FtwInstance, FvbHandle); -- DEBUG ((EFI_D_ERROR, "Ftw: Restart last write - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Restart last write - %r\n", Status)); - ASSERT_EFI_ERROR (Status); - } - FtwAbort (&FtwDevice->FtwInstance); -@@ -1375,4 +1375,3 @@ InitFtwProtocol ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c -index 04cb38afd5..703da6d330 100644 ---- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c -+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c -@@ -86,7 +86,7 @@ IsValidWorkSpace ( - return TRUE; - } - -- DEBUG ((EFI_D_INFO, "Ftw: Work block header check mismatch\n")); -+ DEBUG ((DEBUG_INFO, "Ftw: Work block header check mismatch\n")); - return FALSE; - } - -@@ -287,7 +287,7 @@ WorkSpaceRefresh ( - &FtwDevice->FtwLastWriteHeader - ); - RemainingSpaceSize = FtwDevice->FtwWorkSpaceSize - ((UINTN) FtwDevice->FtwLastWriteHeader - (UINTN) FtwDevice->FtwWorkSpace); -- DEBUG ((EFI_D_INFO, "Ftw: Remaining work space size - %x\n", RemainingSpaceSize)); -+ DEBUG ((DEBUG_INFO, "Ftw: Remaining work space size - %x\n", RemainingSpaceSize)); - // - // If FtwGetLastWriteHeader() returns error, or the remaining space size is even not enough to contain - // one EFI_FAULT_TOLERANT_WRITE_HEADER + one EFI_FAULT_TOLERANT_WRITE_RECORD(It will cause that the header -@@ -300,7 +300,7 @@ WorkSpaceRefresh ( - // - Status = FtwReclaimWorkSpace (FtwDevice, TRUE); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Ftw: Reclaim workspace - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Ftw: Reclaim workspace - %r\n", Status)); - return EFI_ABORTED; - } - // -@@ -370,7 +370,7 @@ FtwReclaimWorkSpace ( - UINT8 *Ptr; - EFI_LBA WorkSpaceLbaOffset; - -- DEBUG ((EFI_D_INFO, "Ftw: start to reclaim work space\n")); -+ DEBUG ((DEBUG_INFO, "Ftw: start to reclaim work space\n")); - - WorkSpaceLbaOffset = FtwDevice->FtwWorkSpaceLba - FtwDevice->FtwWorkBlockLba; - -@@ -601,7 +601,7 @@ FtwReclaimWorkSpace ( - - FreePool (SpareBuffer); - -- DEBUG ((EFI_D_INFO, "Ftw: reclaim work space successfully\n")); -+ DEBUG ((DEBUG_INFO, "Ftw: reclaim work space successfully\n")); - - return EFI_SUCCESS; - } -diff --git a/MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c b/MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c -index 439d5b01e6..ca5d5b4a22 100644 ---- a/MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c -+++ b/MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c -@@ -152,12 +152,12 @@ IsValidWorkSpace ( - } - - if ((WorkingHeader->WorkingBlockValid != FTW_VALID_STATE) || (WorkingHeader->WorkingBlockInvalid == FTW_VALID_STATE)) { -- DEBUG ((EFI_D_ERROR, "FtwPei: Work block header valid bit check error\n")); -+ DEBUG ((DEBUG_ERROR, "FtwPei: Work block header valid bit check error\n")); - return FALSE; - } - - if (WorkingHeader->WriteQueueSize != (WorkingLength - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER))) { -- DEBUG ((EFI_D_ERROR, "FtwPei: Work block header WriteQueueSize check error\n")); -+ DEBUG ((DEBUG_ERROR, "FtwPei: Work block header WriteQueueSize check error\n")); - return FALSE; - } - -@@ -165,7 +165,7 @@ IsValidWorkSpace ( - // Check signature with gEdkiiWorkingBlockSignatureGuid - // - if (!CompareGuid (&gEdkiiWorkingBlockSignatureGuid, &WorkingHeader->Signature)) { -- DEBUG ((EFI_D_ERROR, "FtwPei: Work block header signature check error, it should be gEdkiiWorkingBlockSignatureGuid\n")); -+ DEBUG ((DEBUG_ERROR, "FtwPei: Work block header signature check error, it should be gEdkiiWorkingBlockSignatureGuid\n")); - // - // To be compatible with old signature gEfiSystemNvDataFvGuid. - // -@@ -174,7 +174,7 @@ IsValidWorkSpace ( - } else { - Data = *(UINT8 *) (WorkingHeader + 1); - if (Data != 0xff) { -- DEBUG ((EFI_D_ERROR, "FtwPei: Old format FTW structure can't be handled\n")); -+ DEBUG ((DEBUG_ERROR, "FtwPei: Old format FTW structure can't be handled\n")); - ASSERT (FALSE); - return FALSE; - } -@@ -261,7 +261,7 @@ PeimFaultTolerantWriteInitialize ( - FtwLastWrite.SpareAddress = SpareAreaAddress; - FtwLastWrite.Length = SpareAreaLength; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "FtwPei last write data: TargetAddress - 0x%x SpareAddress - 0x%x Length - 0x%x\n", - (UINTN) FtwLastWrite.TargetAddress, - (UINTN) FtwLastWrite.SpareAddress, -@@ -280,7 +280,7 @@ PeimFaultTolerantWriteInitialize ( - // - // Found the workspace. - // -- DEBUG ((EFI_D_INFO, "FtwPei: workspace in spare block is at 0x%x.\n", (UINTN) WorkSpaceInSpareArea)); -+ DEBUG ((DEBUG_INFO, "FtwPei: workspace in spare block is at 0x%x.\n", (UINTN) WorkSpaceInSpareArea)); - FtwWorkingBlockHeader = (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *) (UINTN) WorkSpaceInSpareArea; - break; - } -@@ -294,7 +294,7 @@ PeimFaultTolerantWriteInitialize ( - FtwLastWrite.SpareAddress = SpareAreaAddress; - FtwLastWrite.Length = SpareAreaLength; - DEBUG (( -- EFI_D_INFO, -+ DEBUG_INFO, - "FtwPei last write data: TargetAddress - 0x%x SpareAddress - 0x%x Length - 0x%x\n", - (UINTN) FtwLastWrite.TargetAddress, - (UINTN) FtwLastWrite.SpareAddress, -@@ -304,7 +304,7 @@ PeimFaultTolerantWriteInitialize ( - // - // Both are invalid. - // -- DEBUG ((EFI_D_ERROR, "FtwPei: Both working and spare block are invalid.\n")); -+ DEBUG ((DEBUG_ERROR, "FtwPei: Both working and spare block are invalid.\n")); - } - } - -diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c -index 5ee866fb9e..3dfa8bf41f 100644 ---- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c -+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c -@@ -2046,7 +2046,7 @@ ExtractConfigRequest ( - // Header->VarStoreId == 0 means no storage for this question. - // - ASSERT (Header->VarStoreId != 0); -- DEBUG ((EFI_D_INFO, "Varstore Id: 0x%x\n", Header->VarStoreId)); -+ DEBUG ((DEBUG_INFO, "Varstore Id: 0x%x\n", Header->VarStoreId)); - - Storage = FindStorageFromVarId (FormPackage, Header->VarStoreId); - ASSERT (Storage != NULL); -@@ -2149,7 +2149,7 @@ ExtractConfigResp ( - // Header->VarStoreId == 0 means no storage for this question. - // - ASSERT (Header->VarStoreId != 0); -- DEBUG ((EFI_D_INFO, "Varstore Id: 0x%x\n", Header->VarStoreId)); -+ DEBUG ((DEBUG_INFO, "Varstore Id: 0x%x\n", Header->VarStoreId)); - - Storage = FindStorageFromVarId (FormPackage, Header->VarStoreId); - ASSERT (Storage != NULL); -diff --git a/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c b/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c -index f11c3a17ef..e4659c149f 100644 ---- a/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c -+++ b/MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c -@@ -54,7 +54,7 @@ SmmLockBoxSave ( - // Sanity check - // - if (mLocked) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Locked!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Locked!\n")); - LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -65,7 +65,7 @@ SmmLockBoxSave ( - // Sanity check - // - if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterSave.Buffer, (UINTN)TempLockBoxParameterSave.Length)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Save address in SMRAM or buffer overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Save address in SMRAM or buffer overflow!\n")); - LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -104,7 +104,7 @@ SmmLockBoxSetAttributes ( - // Sanity check - // - if (mLocked) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Locked!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Locked!\n")); - LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -143,7 +143,7 @@ SmmLockBoxUpdate ( - // Sanity check - // - if (mLocked) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Locked!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Locked!\n")); - LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -154,7 +154,7 @@ SmmLockBoxUpdate ( - // Sanity check - // - if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterUpdate.Buffer, (UINTN)TempLockBoxParameterUpdate.Length)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Update address in SMRAM or buffer overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Update address in SMRAM or buffer overflow!\n")); - LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -200,7 +200,7 @@ SmmLockBoxRestore ( - // Sanity check - // - if (!SmmIsBufferOutsideSmmValid ((UINTN)TempLockBoxParameterRestore.Buffer, (UINTN)TempLockBoxParameterRestore.Length)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Restore address in SMRAM or buffer overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Restore address in SMRAM or buffer overflow!\n")); - LockBoxParameterRestore->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED; - return ; - } -@@ -291,11 +291,11 @@ SmmLockBoxHandler ( - // Sanity check - // - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_HEADER)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size invalid!\n")); - return EFI_SUCCESS; - } - if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer in SMRAM or overflow!\n")); - return EFI_SUCCESS; - } - -@@ -310,41 +310,41 @@ SmmLockBoxHandler ( - switch (LockBoxParameterHeader->Command) { - case EFI_SMM_LOCK_BOX_COMMAND_SAVE: - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for SAVE invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size for SAVE invalid!\n")); - break; - } - SmmLockBoxSave ((EFI_SMM_LOCK_BOX_PARAMETER_SAVE *)(UINTN)LockBoxParameterHeader); - break; - case EFI_SMM_LOCK_BOX_COMMAND_UPDATE: - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for UPDATE invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size for UPDATE invalid!\n")); - break; - } - SmmLockBoxUpdate ((EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *)(UINTN)LockBoxParameterHeader); - break; - case EFI_SMM_LOCK_BOX_COMMAND_RESTORE: - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for RESTORE invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size for RESTORE invalid!\n")); - break; - } - SmmLockBoxRestore ((EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)(UINTN)LockBoxParameterHeader); - break; - case EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES: - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for SET_ATTRIBUTES invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size for SET_ATTRIBUTES invalid!\n")); - break; - } - SmmLockBoxSetAttributes ((EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)(UINTN)LockBoxParameterHeader); - break; - case EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE: - if (TempCommBufferSize < sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)) { -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command Buffer Size for RESTORE_ALL_IN_PLACE invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command Buffer Size for RESTORE_ALL_IN_PLACE invalid!\n")); - break; - } - SmmLockBoxRestoreAllInPlace ((EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)(UINTN)LockBoxParameterHeader); - break; - default: -- DEBUG ((EFI_D_ERROR, "SmmLockBox Command invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmLockBox Command invalid!\n")); - break; - } - -diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c -index 400b0fa578..04c3dd34b1 100644 ---- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c -+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c -@@ -426,10 +426,10 @@ SmbiosAdd ( - // - if ((EntryPointStructure != NULL) && - (EntryPointStructure->TableLength + StructureSize > SMBIOS_TABLE_MAX_LENGTH)) { -- DEBUG ((EFI_D_INFO, "SmbiosAdd: Total length exceeds max 32-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize)); -+ DEBUG ((DEBUG_INFO, "SmbiosAdd: Total length exceeds max 32-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize)); - } else { - Smbios32BitTable = TRUE; -- DEBUG ((EFI_D_INFO, "SmbiosAdd: Smbios type %d with size 0x%x is added to 32-bit table\n", Record->Type, StructureSize)); -+ DEBUG ((DEBUG_INFO, "SmbiosAdd: Smbios type %d with size 0x%x is added to 32-bit table\n", Record->Type, StructureSize)); - } - } - -@@ -443,9 +443,9 @@ SmbiosAdd ( - // - if ((Smbios30EntryPointStructure != NULL) && - (Smbios30EntryPointStructure->TableMaximumSize + StructureSize > SMBIOS_3_0_TABLE_MAX_LENGTH)) { -- DEBUG ((EFI_D_INFO, "SmbiosAdd: Total length exceeds max 64-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize)); -+ DEBUG ((DEBUG_INFO, "SmbiosAdd: Total length exceeds max 64-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize)); - } else { -- DEBUG ((EFI_D_INFO, "SmbiosAdd: Smbios type %d with size 0x%x is added to 64-bit table\n", Record->Type, StructureSize)); -+ DEBUG ((DEBUG_INFO, "SmbiosAdd: Smbios type %d with size 0x%x is added to 64-bit table\n", Record->Type, StructureSize)); - Smbios64BitTable = TRUE; - } - } -@@ -691,9 +691,9 @@ SmbiosUpdateString ( - // in the Structure Table Length field of the SMBIOS Structure Table Entry Point, - // which is a WORD field limited to 65,535 bytes. - // -- DEBUG ((EFI_D_INFO, "SmbiosUpdateString: Total length exceeds max 32-bit table length\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosUpdateString: Total length exceeds max 32-bit table length\n")); - } else { -- DEBUG ((EFI_D_INFO, "SmbiosUpdateString: New smbios record add to 32-bit table\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosUpdateString: New smbios record add to 32-bit table\n")); - SmbiosEntry->Smbios32BitTable = TRUE; - } - } -@@ -704,9 +704,9 @@ SmbiosUpdateString ( - // - if ((Smbios30EntryPointStructure != NULL) && - (Smbios30EntryPointStructure->TableMaximumSize + InputStrLen - TargetStrLen > SMBIOS_3_0_TABLE_MAX_LENGTH)) { -- DEBUG ((EFI_D_INFO, "SmbiosUpdateString: Total length exceeds max 64-bit table length\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosUpdateString: Total length exceeds max 64-bit table length\n")); - } else { -- DEBUG ((EFI_D_INFO, "SmbiosUpdateString: New smbios record add to 64-bit table\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosUpdateString: New smbios record add to 64-bit table\n")); - SmbiosEntry->Smbios64BitTable = TRUE; - } - } -@@ -852,10 +852,10 @@ SmbiosRemove ( - // configuration table without depending on PI SMBIOS protocol. - // - if (SmbiosEntry->Smbios32BitTable) { -- DEBUG ((EFI_D_INFO, "SmbiosRemove: remove from 32-bit table\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosRemove: remove from 32-bit table\n")); - } - if (SmbiosEntry->Smbios64BitTable) { -- DEBUG ((EFI_D_INFO, "SmbiosRemove: remove from 64-bit table\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosRemove: remove from 64-bit table\n")); - } - // - // Update the whole SMBIOS table again based on which table the removed SMBIOS record is in. -@@ -1058,7 +1058,7 @@ SmbiosCreateTable ( - // It should be done only once. - // Allocate memory (below 4GB). - // -- DEBUG ((EFI_D_INFO, "SmbiosCreateTable: Initialize 32-bit entry point structure\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosCreateTable: Initialize 32-bit entry point structure\n")); - EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion; - EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion; - EntryPointStructureData.SmbiosBcdRevision = (UINT8) ((PcdGet16 (PcdSmbiosVersion) >> 4) & 0xf0) | (UINT8) (PcdGet16 (PcdSmbiosVersion) & 0x0f); -@@ -1070,7 +1070,7 @@ SmbiosCreateTable ( - &PhysicalAddress - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmbiosCreateTable () could not allocate EntryPointStructure < 4GB\n")); -+ DEBUG ((DEBUG_ERROR, "SmbiosCreateTable () could not allocate EntryPointStructure < 4GB\n")); - Status = gBS->AllocatePages ( - AllocateAnyPages, - EfiRuntimeServicesData, -@@ -1143,7 +1143,7 @@ SmbiosCreateTable ( - // If new SMBIOS table size exceeds the previous allocated page, - // it is time to re-allocate memory (below 4GB). - // -- DEBUG ((EFI_D_INFO, "%a() re-allocate SMBIOS 32-bit table\n", -+ DEBUG ((DEBUG_INFO, "%a() re-allocate SMBIOS 32-bit table\n", - __FUNCTION__)); - if (EntryPointStructure->TableAddress != 0) { - // -@@ -1165,7 +1165,7 @@ SmbiosCreateTable ( - &PhysicalAddress - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n")); -+ DEBUG ((DEBUG_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n")); - EntryPointStructure->TableAddress = 0; - return EFI_OUT_OF_RESOURCES; - } else { -@@ -1250,7 +1250,7 @@ SmbiosCreate64BitTable ( - // It should be done only once. - // Allocate memory at any address. - // -- DEBUG ((EFI_D_INFO, "SmbiosCreateTable: Initialize 64-bit entry point structure\n")); -+ DEBUG ((DEBUG_INFO, "SmbiosCreateTable: Initialize 64-bit entry point structure\n")); - Smbios30EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion; - Smbios30EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion; - Smbios30EntryPointStructureData.DocRev = PcdGet8 (PcdSmbiosDocRev); -@@ -1261,7 +1261,7 @@ SmbiosCreate64BitTable ( - &PhysicalAddress - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmbiosCreate64BitTable() could not allocate Smbios30EntryPointStructure\n")); -+ DEBUG ((DEBUG_ERROR, "SmbiosCreate64BitTable() could not allocate Smbios30EntryPointStructure\n")); - return EFI_OUT_OF_RESOURCES; - } - -@@ -1312,7 +1312,7 @@ SmbiosCreate64BitTable ( - // If new SMBIOS table size exceeds the previous allocated page, - // it is time to re-allocate memory at anywhere. - // -- DEBUG ((EFI_D_INFO, "%a() re-allocate SMBIOS 64-bit table\n", -+ DEBUG ((DEBUG_INFO, "%a() re-allocate SMBIOS 64-bit table\n", - __FUNCTION__)); - if (Smbios30EntryPointStructure->TableAddress != 0) { - // -@@ -1333,7 +1333,7 @@ SmbiosCreate64BitTable ( - &PhysicalAddress - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "SmbiosCreateTable() could not allocate SMBIOS 64-bit table\n")); -+ DEBUG ((DEBUG_ERROR, "SmbiosCreateTable() could not allocate SMBIOS 64-bit table\n")); - Smbios30EntryPointStructure->TableAddress = 0; - return EFI_OUT_OF_RESOURCES; - } else { -diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c -index 1050c9b17b..98788ead9a 100644 ---- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c -+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c -@@ -137,7 +137,7 @@ InternalDumpData ( - { - UINTN Index; - for (Index = 0; Index < Size; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x", (UINTN)Data[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x", (UINTN)Data[Index])); - } - } - -@@ -164,15 +164,15 @@ InternalDumpHex ( - Count = Size / COLUME_SIZE; - Left = Size % COLUME_SIZE; - for (Index = 0; Index < Count; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%04x: ", Index * COLUME_SIZE)); -+ DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE)); - InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE); -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - } - - if (Left != 0) { -- DEBUG ((EFI_D_VERBOSE, "%04x: ", Index * COLUME_SIZE)); -+ DEBUG ((DEBUG_VERBOSE, "%04x: ", Index * COLUME_SIZE)); - InternalDumpData (Data + Index * COLUME_SIZE, Left); -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - } - } - -@@ -282,7 +282,7 @@ FilterSmbiosEntry ( - CHAR8 *String; - UINTN StringLen; - -- DEBUG ((EFI_D_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type)); -+ DEBUG ((DEBUG_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type)); - DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize);); - - // -@@ -310,7 +310,7 @@ FilterSmbiosEntry ( - // set ' ' for string field - String = GetSmbiosStringById (TableEntry, StringId, &StringLen); - ASSERT (String != NULL); -- //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen)); -+ //DEBUG ((DEBUG_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen)); - SetMem (String, StringLen, ' '); - } - } -@@ -322,7 +322,7 @@ FilterSmbiosEntry ( - } - } - -- DEBUG ((EFI_D_INFO, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type)); -+ DEBUG ((DEBUG_INFO, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type)); - DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize);); - } - -@@ -494,22 +494,22 @@ MeasureSmbiosTable ( - (VOID **) &Smbios3Table - ); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Smbios3Table:\n")); -- DEBUG ((EFI_D_INFO, " AnchorString - '%c%c%c%c%c'\n", -+ DEBUG ((DEBUG_INFO, "Smbios3Table:\n")); -+ DEBUG ((DEBUG_INFO, " AnchorString - '%c%c%c%c%c'\n", - Smbios3Table->AnchorString[0], - Smbios3Table->AnchorString[1], - Smbios3Table->AnchorString[2], - Smbios3Table->AnchorString[3], - Smbios3Table->AnchorString[4] - )); -- DEBUG ((EFI_D_INFO, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table->EntryPointStructureChecksum)); -- DEBUG ((EFI_D_INFO, " EntryPointLength - 0x%02x\n", Smbios3Table->EntryPointLength)); -- DEBUG ((EFI_D_INFO, " MajorVersion - 0x%02x\n", Smbios3Table->MajorVersion)); -- DEBUG ((EFI_D_INFO, " MinorVersion - 0x%02x\n", Smbios3Table->MinorVersion)); -- DEBUG ((EFI_D_INFO, " DocRev - 0x%02x\n", Smbios3Table->DocRev)); -- DEBUG ((EFI_D_INFO, " EntryPointRevision - 0x%02x\n", Smbios3Table->EntryPointRevision)); -- DEBUG ((EFI_D_INFO, " TableMaximumSize - 0x%08x\n", Smbios3Table->TableMaximumSize)); -- DEBUG ((EFI_D_INFO, " TableAddress - 0x%016lx\n", Smbios3Table->TableAddress)); -+ DEBUG ((DEBUG_INFO, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table->EntryPointStructureChecksum)); -+ DEBUG ((DEBUG_INFO, " EntryPointLength - 0x%02x\n", Smbios3Table->EntryPointLength)); -+ DEBUG ((DEBUG_INFO, " MajorVersion - 0x%02x\n", Smbios3Table->MajorVersion)); -+ DEBUG ((DEBUG_INFO, " MinorVersion - 0x%02x\n", Smbios3Table->MinorVersion)); -+ DEBUG ((DEBUG_INFO, " DocRev - 0x%02x\n", Smbios3Table->DocRev)); -+ DEBUG ((DEBUG_INFO, " EntryPointRevision - 0x%02x\n", Smbios3Table->EntryPointRevision)); -+ DEBUG ((DEBUG_INFO, " TableMaximumSize - 0x%08x\n", Smbios3Table->TableMaximumSize)); -+ DEBUG ((DEBUG_INFO, " TableAddress - 0x%016lx\n", Smbios3Table->TableAddress)); - } - } - -@@ -519,38 +519,38 @@ MeasureSmbiosTable ( - (VOID **) &SmbiosTable - ); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "SmbiosTable:\n")); -- DEBUG ((EFI_D_INFO, " AnchorString - '%c%c%c%c'\n", -+ DEBUG ((DEBUG_INFO, "SmbiosTable:\n")); -+ DEBUG ((DEBUG_INFO, " AnchorString - '%c%c%c%c'\n", - SmbiosTable->AnchorString[0], - SmbiosTable->AnchorString[1], - SmbiosTable->AnchorString[2], - SmbiosTable->AnchorString[3] - )); -- DEBUG ((EFI_D_INFO, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable->EntryPointStructureChecksum)); -- DEBUG ((EFI_D_INFO, " EntryPointLength - 0x%02x\n", SmbiosTable->EntryPointLength)); -- DEBUG ((EFI_D_INFO, " MajorVersion - 0x%02x\n", SmbiosTable->MajorVersion)); -- DEBUG ((EFI_D_INFO, " MinorVersion - 0x%02x\n", SmbiosTable->MinorVersion)); -- DEBUG ((EFI_D_INFO, " MaxStructureSize - 0x%08x\n", SmbiosTable->MaxStructureSize)); -- DEBUG ((EFI_D_INFO, " EntryPointRevision - 0x%02x\n", SmbiosTable->EntryPointRevision)); -- DEBUG ((EFI_D_INFO, " FormattedArea - '%c%c%c%c%c'\n", -+ DEBUG ((DEBUG_INFO, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable->EntryPointStructureChecksum)); -+ DEBUG ((DEBUG_INFO, " EntryPointLength - 0x%02x\n", SmbiosTable->EntryPointLength)); -+ DEBUG ((DEBUG_INFO, " MajorVersion - 0x%02x\n", SmbiosTable->MajorVersion)); -+ DEBUG ((DEBUG_INFO, " MinorVersion - 0x%02x\n", SmbiosTable->MinorVersion)); -+ DEBUG ((DEBUG_INFO, " MaxStructureSize - 0x%08x\n", SmbiosTable->MaxStructureSize)); -+ DEBUG ((DEBUG_INFO, " EntryPointRevision - 0x%02x\n", SmbiosTable->EntryPointRevision)); -+ DEBUG ((DEBUG_INFO, " FormattedArea - '%c%c%c%c%c'\n", - SmbiosTable->FormattedArea[0], - SmbiosTable->FormattedArea[1], - SmbiosTable->FormattedArea[2], - SmbiosTable->FormattedArea[3], - SmbiosTable->FormattedArea[4] - )); -- DEBUG ((EFI_D_INFO, " IntermediateAnchorString - '%c%c%c%c%c'\n", -+ DEBUG ((DEBUG_INFO, " IntermediateAnchorString - '%c%c%c%c%c'\n", - SmbiosTable->IntermediateAnchorString[0], - SmbiosTable->IntermediateAnchorString[1], - SmbiosTable->IntermediateAnchorString[2], - SmbiosTable->IntermediateAnchorString[3], - SmbiosTable->IntermediateAnchorString[4] - )); -- DEBUG ((EFI_D_INFO, " IntermediateChecksum - 0x%02x\n", SmbiosTable->IntermediateChecksum)); -- DEBUG ((EFI_D_INFO, " TableLength - 0x%04x\n", SmbiosTable->TableLength)); -- DEBUG ((EFI_D_INFO, " TableAddress - 0x%08x\n", SmbiosTable->TableAddress)); -- DEBUG ((EFI_D_INFO, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable->NumberOfSmbiosStructures)); -- DEBUG ((EFI_D_INFO, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable->SmbiosBcdRevision)); -+ DEBUG ((DEBUG_INFO, " IntermediateChecksum - 0x%02x\n", SmbiosTable->IntermediateChecksum)); -+ DEBUG ((DEBUG_INFO, " TableLength - 0x%04x\n", SmbiosTable->TableLength)); -+ DEBUG ((DEBUG_INFO, " TableAddress - 0x%08x\n", SmbiosTable->TableAddress)); -+ DEBUG ((DEBUG_INFO, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable->NumberOfSmbiosStructures)); -+ DEBUG ((DEBUG_INFO, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable->SmbiosBcdRevision)); - } - } - -diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c -index 9a5dbb2720..a2434908a8 100644 ---- a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c -+++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c -@@ -71,16 +71,16 @@ SmmCommunicationBufferEntryPoint ( - Entry->NumberOfPages = DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES; - Entry->Attribute = 0; - -- DEBUG ((EFI_D_INFO, "PiSmmCommunicationRegionTable:(0x%x)\n", PiSmmCommunicationRegionTable)); -- DEBUG ((EFI_D_INFO, " Version - 0x%x\n", PiSmmCommunicationRegionTable->Version)); -- DEBUG ((EFI_D_INFO, " NumberOfEntries - 0x%x\n", PiSmmCommunicationRegionTable->NumberOfEntries)); -- DEBUG ((EFI_D_INFO, " DescriptorSize - 0x%x\n", PiSmmCommunicationRegionTable->DescriptorSize)); -- DEBUG ((EFI_D_INFO, "Entry:(0x%x)\n", Entry)); -- DEBUG ((EFI_D_INFO, " Type - 0x%x\n", Entry->Type)); -- DEBUG ((EFI_D_INFO, " PhysicalStart - 0x%lx\n", Entry->PhysicalStart)); -- DEBUG ((EFI_D_INFO, " VirtualStart - 0x%lx\n", Entry->VirtualStart)); -- DEBUG ((EFI_D_INFO, " NumberOfPages - 0x%lx\n", Entry->NumberOfPages)); -- DEBUG ((EFI_D_INFO, " Attribute - 0x%lx\n", Entry->Attribute)); -+ DEBUG ((DEBUG_INFO, "PiSmmCommunicationRegionTable:(0x%x)\n", PiSmmCommunicationRegionTable)); -+ DEBUG ((DEBUG_INFO, " Version - 0x%x\n", PiSmmCommunicationRegionTable->Version)); -+ DEBUG ((DEBUG_INFO, " NumberOfEntries - 0x%x\n", PiSmmCommunicationRegionTable->NumberOfEntries)); -+ DEBUG ((DEBUG_INFO, " DescriptorSize - 0x%x\n", PiSmmCommunicationRegionTable->DescriptorSize)); -+ DEBUG ((DEBUG_INFO, "Entry:(0x%x)\n", Entry)); -+ DEBUG ((DEBUG_INFO, " Type - 0x%x\n", Entry->Type)); -+ DEBUG ((DEBUG_INFO, " PhysicalStart - 0x%lx\n", Entry->PhysicalStart)); -+ DEBUG ((DEBUG_INFO, " VirtualStart - 0x%lx\n", Entry->VirtualStart)); -+ DEBUG ((DEBUG_INFO, " NumberOfPages - 0x%lx\n", Entry->NumberOfPages)); -+ DEBUG ((DEBUG_INFO, " Attribute - 0x%lx\n", Entry->Attribute)); - - // - // Publish this table, so that other driver can use the buffer. -diff --git a/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c -index 2ca4ae5cd2..a318ae00b5 100644 ---- a/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c -+++ b/MdeModulePkg/Universal/TimestampDxe/TimestampDxe.c -@@ -142,7 +142,7 @@ TimestampDriverInitialize ( - mTimestampProperties.EndValue = mTimerLibStartValue - mTimerLibEndValue; - } - -- DEBUG ((EFI_D_INFO, "TimerFrequency:0x%lx, TimerLibStartTime:0x%lx, TimerLibEndtime:0x%lx\n", mTimestampProperties.Frequency, mTimerLibStartValue, mTimerLibEndValue)); -+ DEBUG ((DEBUG_INFO, "TimerFrequency:0x%lx, TimerLibStartTime:0x%lx, TimerLibEndtime:0x%lx\n", mTimestampProperties.Frequency, mTimerLibStartValue, mTimerLibEndValue)); - - // - // Install the Timestamp Protocol onto a new handle -diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c -index f420b58165..468b73215b 100644 ---- a/MdeModulePkg/Universal/Variable/Pei/Variable.c -+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c -@@ -608,14 +608,14 @@ GetVariableStore ( - // Let FvHeader point to spare block. - // - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FtwLastWriteData->SpareAddress; -- DEBUG ((EFI_D_INFO, "PeiVariable: NV storage is backed up in spare block: 0x%x\n", (UINTN) FtwLastWriteData->SpareAddress)); -+ DEBUG ((DEBUG_INFO, "PeiVariable: NV storage is backed up in spare block: 0x%x\n", (UINTN) FtwLastWriteData->SpareAddress)); - } else if ((FtwLastWriteData->TargetAddress > NvStorageBase) && (FtwLastWriteData->TargetAddress < (NvStorageBase + NvStorageSize))) { - StoreInfo->FtwLastWriteData = FtwLastWriteData; - // - // Flash NV storage from the offset is backed up in spare block. - // - BackUpOffset = (UINT32) (FtwLastWriteData->TargetAddress - NvStorageBase); -- DEBUG ((EFI_D_INFO, "PeiVariable: High partial NV storage from offset: %x is backed up in spare block: 0x%x\n", BackUpOffset, (UINTN) FtwLastWriteData->SpareAddress)); -+ DEBUG ((DEBUG_INFO, "PeiVariable: High partial NV storage from offset: %x is backed up in spare block: 0x%x\n", BackUpOffset, (UINTN) FtwLastWriteData->SpareAddress)); - // - // At least one block data in flash NV storage is still valid, so still leave FvHeader point to NV storage base. - // -@@ -626,7 +626,7 @@ GetVariableStore ( - // Check if the Firmware Volume is not corrupted - // - if ((FvHeader->Signature != EFI_FVH_SIGNATURE) || (!CompareGuid (&gEfiSystemNvDataFvGuid, &FvHeader->FileSystemGuid))) { -- DEBUG ((EFI_D_ERROR, "Firmware Volume for Variable Store is corrupted\n")); -+ DEBUG ((DEBUG_ERROR, "Firmware Volume for Variable Store is corrupted\n")); - break; - } - -diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Measurement.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Measurement.c -index 75350ca2ef..6f459e9549 100644 ---- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Measurement.c -+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Measurement.c -@@ -121,8 +121,8 @@ MeasureVariable ( - ); - } - -- DEBUG ((EFI_D_INFO, "VariableDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_DRIVER_CONFIG)); -- DEBUG ((EFI_D_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); -+ DEBUG ((DEBUG_INFO, "VariableDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_DRIVER_CONFIG)); -+ DEBUG ((DEBUG_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); - - Status = TpmMeasureAndLogData ( - 7, -@@ -257,7 +257,7 @@ SecureBootHook ( - VariableData, - VariableDataSize - ); -- DEBUG ((EFI_D_INFO, "MeasureBootPolicyVariable - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "MeasureBootPolicyVariable - %r\n", Status)); - - if (VariableData != NULL) { - FreePool (VariableData); -diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c -index 41f8ff4ceb..5115bcf816 100644 ---- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c -+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c -@@ -281,15 +281,15 @@ RecordVarErrorFlag ( - VAR_ERROR_FLAG TempFlag; - - DEBUG_CODE ( -- DEBUG ((EFI_D_ERROR, "RecordVarErrorFlag (0x%02x) %s:%g - 0x%08x - 0x%x\n", Flag, VariableName, VendorGuid, Attributes, VariableSize)); -+ DEBUG ((DEBUG_ERROR, "RecordVarErrorFlag (0x%02x) %s:%g - 0x%08x - 0x%x\n", Flag, VariableName, VendorGuid, Attributes, VariableSize)); - if (Flag == VAR_ERROR_FLAG_SYSTEM_ERROR) { - if (AtRuntime ()) { -- DEBUG ((EFI_D_ERROR, "CommonRuntimeVariableSpace = 0x%x - CommonVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonRuntimeVariableSpace, mVariableModuleGlobal->CommonVariableTotalSize)); -+ DEBUG ((DEBUG_ERROR, "CommonRuntimeVariableSpace = 0x%x - CommonVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonRuntimeVariableSpace, mVariableModuleGlobal->CommonVariableTotalSize)); - } else { -- DEBUG ((EFI_D_ERROR, "CommonVariableSpace = 0x%x - CommonVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonVariableSpace, mVariableModuleGlobal->CommonVariableTotalSize)); -+ DEBUG ((DEBUG_ERROR, "CommonVariableSpace = 0x%x - CommonVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonVariableSpace, mVariableModuleGlobal->CommonVariableTotalSize)); - } - } else { -- DEBUG ((EFI_D_ERROR, "CommonMaxUserVariableSpace = 0x%x - CommonUserVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonMaxUserVariableSpace, mVariableModuleGlobal->CommonUserVariableTotalSize)); -+ DEBUG ((DEBUG_ERROR, "CommonMaxUserVariableSpace = 0x%x - CommonUserVariableTotalSize = 0x%x\n", mVariableModuleGlobal->CommonMaxUserVariableSpace, mVariableModuleGlobal->CommonUserVariableTotalSize)); - } - ); - -@@ -369,7 +369,7 @@ InitializeVarErrorFlag ( - } - - Flag = mCurrentBootVarErrFlag; -- DEBUG ((EFI_D_INFO, "Initialize variable error flag (%02x)\n", Flag)); -+ DEBUG ((DEBUG_INFO, "Initialize variable error flag (%02x)\n", Flag)); - - Status = FindVariable ( - VAR_ERROR_FLAG_NAME, -@@ -1532,7 +1532,7 @@ AutoUpdateLangVariable ( - ISO_639_2_ENTRY_SIZE + 1, Attributes, 0, 0, &Variable, NULL); - } - -- DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a Status: %r\n", BestPlatformLang, BestLang, Status)); -+ DEBUG ((DEBUG_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a Status: %r\n", BestPlatformLang, BestLang, Status)); - } - } - -@@ -1581,7 +1581,7 @@ AutoUpdateLangVariable ( - AsciiStrSize (BestPlatformLang), Attributes, 0, 0, &Variable, NULL); - } - -- DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a Status: %r\n", BestLang, BestPlatformLang, Status)); -+ DEBUG ((DEBUG_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a Status: %r\n", BestLang, BestPlatformLang, Status)); - } - } - } -@@ -1659,14 +1659,14 @@ UpdateVariable ( - // - // Trying to update NV variable prior to the installation of EFI_VARIABLE_WRITE_ARCH_PROTOCOL - // -- DEBUG ((EFI_D_ERROR, "Update NV variable before EFI_VARIABLE_WRITE_ARCH_PROTOCOL ready - %r\n", EFI_NOT_AVAILABLE_YET)); -+ DEBUG ((DEBUG_ERROR, "Update NV variable before EFI_VARIABLE_WRITE_ARCH_PROTOCOL ready - %r\n", EFI_NOT_AVAILABLE_YET)); - return EFI_NOT_AVAILABLE_YET; - } else if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) { - // - // Trying to update volatile authenticated variable prior to the installation of EFI_VARIABLE_WRITE_ARCH_PROTOCOL - // The authenticated variable perhaps is not initialized, just return here. - // -- DEBUG ((EFI_D_ERROR, "Update AUTH variable before EFI_VARIABLE_WRITE_ARCH_PROTOCOL ready - %r\n", EFI_NOT_AVAILABLE_YET)); -+ DEBUG ((DEBUG_ERROR, "Update AUTH variable before EFI_VARIABLE_WRITE_ARCH_PROTOCOL ready - %r\n", EFI_NOT_AVAILABLE_YET)); - return EFI_NOT_AVAILABLE_YET; - } - } -@@ -2764,7 +2764,7 @@ VariableServiceSetVariable ( - // 2. The only attribute differing is EFI_VARIABLE_APPEND_WRITE - // - Status = EFI_INVALID_PARAMETER; -- DEBUG ((EFI_D_INFO, "[Variable]: Rewritten a preexisting variable(0x%08x) with different attributes(0x%08x) - %g:%s\n", Variable.CurrPtr->Attributes, Attributes, VendorGuid, VariableName)); -+ DEBUG ((DEBUG_INFO, "[Variable]: Rewritten a preexisting variable(0x%08x) with different attributes(0x%08x) - %g:%s\n", Variable.CurrPtr->Attributes, Attributes, VendorGuid, VariableName)); - goto Done; - } - } -@@ -3264,7 +3264,7 @@ FlushHobVariableToFlash ( - // - // All HOB variables have been flushed in flash. - // -- DEBUG ((EFI_D_INFO, "Variable driver: all HOB variables have been flushed in flash.\n")); -+ DEBUG ((DEBUG_INFO, "Variable driver: all HOB variables have been flushed in flash.\n")); - if (mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.HobFlushComplete != NULL) { - *(mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.HobFlushComplete) = TRUE; - } -@@ -3333,7 +3333,7 @@ VariableWriteServiceInitialize ( - GetVariableHeaderSize (mVariableModuleGlobal->VariableGlobal.AuthFormat); - Status = AuthVariableLibInitialize (&mAuthContextIn, &mAuthContextOut); - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Variable driver will work with auth variable support!\n")); -+ DEBUG ((DEBUG_INFO, "Variable driver will work with auth variable support!\n")); - mVariableModuleGlobal->VariableGlobal.AuthSupport = TRUE; - if (mAuthContextOut.AuthVarEntry != NULL) { - for (Index = 0; Index < mAuthContextOut.AuthVarEntryCount; Index++) { -@@ -3347,8 +3347,8 @@ VariableWriteServiceInitialize ( - } - } - } else if (Status == EFI_UNSUPPORTED) { -- DEBUG ((EFI_D_INFO, "NOTICE - AuthVariableLibInitialize() returns %r!\n", Status)); -- DEBUG ((EFI_D_INFO, "Variable driver will continue to work without auth variable support!\n")); -+ DEBUG ((DEBUG_INFO, "NOTICE - AuthVariableLibInitialize() returns %r!\n", Status)); -+ DEBUG ((DEBUG_INFO, "Variable driver will continue to work without auth variable support!\n")); - mVariableModuleGlobal->VariableGlobal.AuthSupport = FALSE; - Status = EFI_SUCCESS; - } -@@ -3550,7 +3550,7 @@ GetHobVariableStore ( - return EFI_OUT_OF_RESOURCES; - } - } else { -- DEBUG ((EFI_D_ERROR, "HOB Variable Store header is corrupted!\n")); -+ DEBUG ((DEBUG_ERROR, "HOB Variable Store header is corrupted!\n")); - } - } - -@@ -3598,14 +3598,14 @@ VariableCommonInitialize ( - // has been initialized in InitNonVolatileVariableStore(). - // - if (mVariableModuleGlobal->VariableGlobal.AuthFormat) { -- DEBUG ((EFI_D_INFO, "Variable driver will work with auth variable format!\n")); -+ DEBUG ((DEBUG_INFO, "Variable driver will work with auth variable format!\n")); - // - // Set AuthSupport to FALSE first, VariableWriteServiceInitialize() will initialize it. - // - mVariableModuleGlobal->VariableGlobal.AuthSupport = FALSE; - VariableGuid = &gEfiAuthenticatedVariableGuid; - } else { -- DEBUG ((EFI_D_INFO, "Variable driver will work without auth variable support!\n")); -+ DEBUG ((DEBUG_INFO, "Variable driver will work without auth variable support!\n")); - mVariableModuleGlobal->VariableGlobal.AuthSupport = FALSE; - VariableGuid = &gEfiVariableGuid; - } -@@ -3750,4 +3750,3 @@ GetFvbInfoByAddress ( - - return Status; - } -- -diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c -index 0fca0bb2a9..9f19d73dd6 100644 ---- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c -+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c -@@ -345,7 +345,7 @@ OnEndOfDxe ( - { - EFI_STATUS Status; - -- DEBUG ((EFI_D_INFO, "[Variable]END_OF_DXE is signaled\n")); -+ DEBUG ((DEBUG_INFO, "[Variable]END_OF_DXE is signaled\n")); - MorLockInitAtEndOfDxe (); - Status = LockVariablePolicy (); - ASSERT_EFI_ERROR (Status); -@@ -638,4 +638,3 @@ VariableServiceInitialize ( - - return EFI_SUCCESS; - } -- -diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c -index 014aa79850..1ee6d2194e 100644 ---- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c -+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c -@@ -489,17 +489,17 @@ SmmVariableHandler ( - TempCommBufferSize = *CommBufferSize; - - if (TempCommBufferSize < SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) { -- DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmVariableHandler: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - CommBufferPayloadSize = TempCommBufferSize - SMM_VARIABLE_COMMUNICATE_HEADER_SIZE; - if (CommBufferPayloadSize > mVariableBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer payload size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmVariableHandler: SMM communication buffer payload size invalid!\n")); - return EFI_SUCCESS; - } - - if (!VariableSmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) { -- DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n")); -+ DEBUG ((DEBUG_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n")); - return EFI_SUCCESS; - } - -@@ -507,7 +507,7 @@ SmmVariableHandler ( - switch (SmmVariableFunctionHeader->Function) { - case SMM_VARIABLE_FUNCTION_GET_VARIABLE: - if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) { -- DEBUG ((EFI_D_ERROR, "GetVariable: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "GetVariable: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - // -@@ -530,7 +530,7 @@ SmmVariableHandler ( - // SMRAM range check already covered before - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "GetVariable: Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "GetVariable: Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - goto EXIT; - } -@@ -561,7 +561,7 @@ SmmVariableHandler ( - - case SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME: - if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME, Name)) { -- DEBUG ((EFI_D_ERROR, "GetNextVariableName: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "GetNextVariableName: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - // -@@ -582,7 +582,7 @@ SmmVariableHandler ( - // SMRAM range check already covered before - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "GetNextVariableName: Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "GetNextVariableName: Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - goto EXIT; - } -@@ -606,7 +606,7 @@ SmmVariableHandler ( - - case SMM_VARIABLE_FUNCTION_SET_VARIABLE: - if (CommBufferPayloadSize < OFFSET_OF(SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE, Name)) { -- DEBUG ((EFI_D_ERROR, "SetVariable: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "SetVariable: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - // -@@ -630,7 +630,7 @@ SmmVariableHandler ( - // Data buffer should not contain SMM range - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "SetVariable: Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "SetVariable: Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - goto EXIT; - } -@@ -660,7 +660,7 @@ SmmVariableHandler ( - - case SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO: - if (CommBufferPayloadSize < sizeof (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) { -- DEBUG ((EFI_D_ERROR, "QueryVariableInfo: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "QueryVariableInfo: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - QueryVariableInfo = (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *) SmmVariableFunctionHeader->Data; -@@ -675,7 +675,7 @@ SmmVariableHandler ( - - case SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE: - if (CommBufferPayloadSize < sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE)) { -- DEBUG ((EFI_D_ERROR, "GetPayloadSize: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "GetPayloadSize: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - GetPayloadSize = (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *) SmmVariableFunctionHeader->Data; -@@ -752,7 +752,7 @@ SmmVariableHandler ( - break; - case SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET: - if (CommBufferPayloadSize < OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name)) { -- DEBUG ((EFI_D_ERROR, "VarCheckVariablePropertyGet: SMM communication buffer size invalid!\n")); -+ DEBUG ((DEBUG_ERROR, "VarCheckVariablePropertyGet: SMM communication buffer size invalid!\n")); - return EFI_SUCCESS; - } - // -@@ -773,7 +773,7 @@ SmmVariableHandler ( - // SMRAM range check already covered before - // - if (InfoSize > CommBufferPayloadSize) { -- DEBUG ((EFI_D_ERROR, "VarCheckVariablePropertyGet: Data size exceed communication buffer size limit!\n")); -+ DEBUG ((DEBUG_ERROR, "VarCheckVariablePropertyGet: Data size exceed communication buffer size limit!\n")); - Status = EFI_ACCESS_DENIED; - goto EXIT; - } -@@ -979,7 +979,7 @@ SmmEndOfDxeCallback ( - { - EFI_STATUS Status; - -- DEBUG ((EFI_D_INFO, "[Variable]SMM_END_OF_DXE is signaled\n")); -+ DEBUG ((DEBUG_INFO, "[Variable]SMM_END_OF_DXE is signaled\n")); - MorLockInitAtEndOfDxe (); - Status = LockVariablePolicy (); - ASSERT_EFI_ERROR (Status); -@@ -1191,5 +1191,3 @@ MmVariableServiceInitialize ( - - return EFI_SUCCESS; - } -- -- -diff --git a/MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.c b/MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.c -index f72b4df80a..2403e1a1cd 100644 ---- a/MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.c -+++ b/MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.c -@@ -69,7 +69,7 @@ WatchdogTimerDriverExpires ( - mWatchdogTimerNotifyFunction (mWatchdogTimerPeriod); - } - -- DEBUG ((EFI_D_ERROR, "Watchdog Timer resetting system\n")); -+ DEBUG ((DEBUG_ERROR, "Watchdog Timer resetting system\n")); - - // - // Reset the platform --- -2.39.3 - diff --git a/SOURCES/edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch b/SOURCES/edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch deleted file mode 100644 index 8f6d306..0000000 --- a/SOURCES/edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch +++ /dev/null @@ -1,2255 +0,0 @@ -From a653b017b8d7222e95106eabb835c33a9dcb8f69 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 15:31:15 -0400 -Subject: [PATCH 15/31] MdeModulePkg: Duplicate BaseRngLibTimerLib to - MdeModulePkg - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [15/31] dd75e7846edc2449229c32d5c4fc5fef0133069f - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 2f981bddcbd6adde5f682caf0d3812ba92bc0f73 -Author: Pierre Gondois -Date: Fri Aug 11 16:33:02 2023 +0200 - - MdeModulePkg: Duplicate BaseRngLibTimerLib to MdeModulePkg - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4504 - - The BaseRngLibTimerLib allows to generate number based on a timer. - This mechanism allows to have a basic non-secure implementation - for non-production platforms. - To bind and identify Random Number Generators implementations with - a GUID, an unsafe GUID should be added. This GUID cannot be added - to the MdePkg unless it is also added to a specification. - - To keep the MdePkg self-contained, copy the BaseRngLibTimerLib to - the MdeModulePkg. This will allow to define an unsafe Rng GUID - in a later patch in the MdeModulePkg. - - The MdePkg implementation will be removed later. This allows to give - some time to platform owners to switch to the MdeModulePkg - implementation. - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - ArmVirtPkg/ArmVirt.dsc.inc | 2 +- - EmulatorPkg/EmulatorPkg.dsc | 2 +- - .../BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 36 + - .../BaseRngLibTimerLib/BaseRngLibTimerLib.uni | 15 + - .../Library/BaseRngLibTimerLib/RngLibTimer.c | 192 ++++ - MdeModulePkg/MdeModulePkg.dsc | 1 + - NetworkPkg/NetworkPkg.dsc | 4 +- - OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +- - OvmfPkg/Bhyve/BhyveX64.dsc | 2 +- - OvmfPkg/CloudHv/CloudHvX64.dsc | 949 ++++++++++++++++++ - OvmfPkg/IntelTdx/IntelTdxX64.dsc | 779 ++++++++++++++ - OvmfPkg/Microvm/MicrovmX64.dsc | 2 +- - OvmfPkg/OvmfPkgIa32.dsc | 2 +- - OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- - OvmfPkg/OvmfPkgX64.dsc | 2 +- - OvmfPkg/OvmfXen.dsc | 2 +- - SecurityPkg/SecurityPkg.dsc | 4 +- - SignedCapsulePkg/SignedCapsulePkg.dsc | 4 +- - 18 files changed, 1987 insertions(+), 15 deletions(-) - create mode 100644 MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - create mode 100644 MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni - create mode 100644 MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c - create mode 100644 OvmfPkg/CloudHv/CloudHvX64.dsc - create mode 100644 OvmfPkg/IntelTdx/IntelTdxX64.dsc - -diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc -index 5a1598d90c..584affa836 100644 ---- a/ArmVirtPkg/ArmVirt.dsc.inc -+++ b/ArmVirtPkg/ArmVirt.dsc.inc -@@ -161,7 +161,7 @@ - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif - BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - # - # Secure Boot dependencies -diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc -index 554c13ddb5..4168837b67 100644 ---- a/EmulatorPkg/EmulatorPkg.dsc -+++ b/EmulatorPkg/EmulatorPkg.dsc -@@ -127,7 +127,7 @@ - FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf - - !if $(SECURE_BOOT_ENABLE) == TRUE -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -new file mode 100644 -index 0000000000..f857290e82 ---- /dev/null -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -@@ -0,0 +1,36 @@ -+## @file -+# Instance of RNG (Random Number Generator) Library. -+# -+# BaseRng Library that uses the TimerLib to provide reasonably random numbers. -+# Do NOT use this on a production system as this uses the system performance -+# counter rather than a true source of random in addition to having a weak -+# random algorithm. This is provided primarily as a source of entropy for -+# OpenSSL for platforms that do not have a good built in RngLib as this -+# emulates what was done before (though it isn't perfect). -+# -+# Copyright (c) Microsoft Corporation. All rights reserved.
-+# -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+# -+## -+ -+[Defines] -+ INF_VERSION = 1.27 -+ BASE_NAME = BaseRngLibTimerLib -+ MODULE_UNI_FILE = BaseRngLibTimerLib.uni -+ FILE_GUID = 74950C45-10FC-4AB5-B114-49C87C17409B -+ MODULE_TYPE = BASE -+ VERSION_STRING = 1.0 -+ LIBRARY_CLASS = RngLib -+ -+[Sources] -+ RngLibTimer.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ -+[LibraryClasses] -+ BaseLib -+ DebugLib -+ TimerLib -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni -new file mode 100644 -index 0000000000..fde24b9f01 ---- /dev/null -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni -@@ -0,0 +1,15 @@ -+// @file -+// Instance of RNG (Random Number Generator) Library. -+// -+// RngLib that uses TimerLib's performance counter to provide random numbers. -+// -+// Copyright (c) Microsoft Corporation. -+// -+// SPDX-License-Identifier: BSD-2-Clause-Patent -+// -+ -+ -+#string STR_MODULE_ABSTRACT #language en-US "Instance of RNG Library" -+ -+#string STR_MODULE_DESCRIPTION #language en-US "BaseRng Library that uses the TimerLib to provide low-entropy random numbers" -+ -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c b/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -new file mode 100644 -index 0000000000..980854d67b ---- /dev/null -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -@@ -0,0 +1,192 @@ -+/** @file -+ BaseRng Library that uses the TimerLib to provide reasonably random numbers. -+ Do not use this on a production system. -+ -+ Copyright (c) Microsoft Corporation. -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+#include -+ -+#define DEFAULT_DELAY_TIME_IN_MICROSECONDS 10 -+ -+/** -+ Using the TimerLib GetPerformanceCounterProperties() we delay -+ for enough time for the PerformanceCounter to increment. -+ -+ If the return value from GetPerformanceCounterProperties (TimerLib) -+ is zero, this function will return 10 and attempt to assert. -+ **/ -+STATIC -+UINT32 -+CalculateMinimumDecentDelayInMicroseconds ( -+ VOID -+ ) -+{ -+ UINT64 CounterHz; -+ -+ // Get the counter properties -+ CounterHz = GetPerformanceCounterProperties (NULL, NULL); -+ // Make sure we won't divide by zero -+ if (CounterHz == 0) { -+ ASSERT (CounterHz != 0); // Assert so the developer knows something is wrong -+ return DEFAULT_DELAY_TIME_IN_MICROSECONDS; -+ } -+ -+ // Calculate the minimum delay based on 1.5 microseconds divided by the hertz. -+ // We calculate the length of a cycle (1/CounterHz) and multiply it by 1.5 microseconds -+ // This ensures that the performance counter has increased by at least one -+ return (UINT32)(MAX (DivU64x64Remainder (1500000, CounterHz, NULL), 1)); -+} -+ -+/** -+ Generates a 16-bit random number. -+ -+ if Rand is NULL, then ASSERT(). -+ -+ @param[out] Rand Buffer pointer to store the 16-bit random value. -+ -+ @retval TRUE Random number generated successfully. -+ @retval FALSE Failed to generate the random number. -+ -+**/ -+BOOLEAN -+EFIAPI -+GetRandomNumber16 ( -+ OUT UINT16 *Rand -+ ) -+{ -+ UINT32 Index; -+ UINT8 *RandPtr; -+ UINT32 DelayInMicroSeconds; -+ -+ ASSERT (Rand != NULL); -+ -+ if (Rand == NULL) { -+ return FALSE; -+ } -+ -+ DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds (); -+ RandPtr = (UINT8 *)Rand; -+ // Get 2 bytes of random ish data -+ for (Index = 0; Index < sizeof (UINT16); Index++) { -+ *RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF); -+ // Delay to give the performance counter a chance to change -+ MicroSecondDelay (DelayInMicroSeconds); -+ RandPtr++; -+ } -+ -+ return TRUE; -+} -+ -+/** -+ Generates a 32-bit random number. -+ -+ if Rand is NULL, then ASSERT(). -+ -+ @param[out] Rand Buffer pointer to store the 32-bit random value. -+ -+ @retval TRUE Random number generated successfully. -+ @retval FALSE Failed to generate the random number. -+ -+**/ -+BOOLEAN -+EFIAPI -+GetRandomNumber32 ( -+ OUT UINT32 *Rand -+ ) -+{ -+ UINT32 Index; -+ UINT8 *RandPtr; -+ UINT32 DelayInMicroSeconds; -+ -+ ASSERT (Rand != NULL); -+ -+ if (NULL == Rand) { -+ return FALSE; -+ } -+ -+ RandPtr = (UINT8 *)Rand; -+ DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds (); -+ // Get 4 bytes of random ish data -+ for (Index = 0; Index < sizeof (UINT32); Index++) { -+ *RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF); -+ // Delay to give the performance counter a chance to change -+ MicroSecondDelay (DelayInMicroSeconds); -+ RandPtr++; -+ } -+ -+ return TRUE; -+} -+ -+/** -+ Generates a 64-bit random number. -+ -+ if Rand is NULL, then ASSERT(). -+ -+ @param[out] Rand Buffer pointer to store the 64-bit random value. -+ -+ @retval TRUE Random number generated successfully. -+ @retval FALSE Failed to generate the random number. -+ -+**/ -+BOOLEAN -+EFIAPI -+GetRandomNumber64 ( -+ OUT UINT64 *Rand -+ ) -+{ -+ UINT32 Index; -+ UINT8 *RandPtr; -+ UINT32 DelayInMicroSeconds; -+ -+ ASSERT (Rand != NULL); -+ -+ if (NULL == Rand) { -+ return FALSE; -+ } -+ -+ RandPtr = (UINT8 *)Rand; -+ DelayInMicroSeconds = CalculateMinimumDecentDelayInMicroseconds (); -+ // Get 8 bytes of random ish data -+ for (Index = 0; Index < sizeof (UINT64); Index++) { -+ *RandPtr = (UINT8)(GetPerformanceCounter () & 0xFF); -+ // Delay to give the performance counter a chance to change -+ MicroSecondDelay (DelayInMicroSeconds); -+ RandPtr++; -+ } -+ -+ return TRUE; -+} -+ -+/** -+ Generates a 128-bit random number. -+ -+ if Rand is NULL, then ASSERT(). -+ -+ @param[out] Rand Buffer pointer to store the 128-bit random value. -+ -+ @retval TRUE Random number generated successfully. -+ @retval FALSE Failed to generate the random number. -+ -+**/ -+BOOLEAN -+EFIAPI -+GetRandomNumber128 ( -+ OUT UINT64 *Rand -+ ) -+{ -+ ASSERT (Rand != NULL); -+ // This should take around 80ms -+ -+ // Read first 64 bits -+ if (!GetRandomNumber64 (Rand)) { -+ return FALSE; -+ } -+ -+ // Read second 64 bits -+ return GetRandomNumber64 (++Rand); -+} -diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc -index b1d8346186..a0f32431c2 100644 ---- a/MdeModulePkg/MdeModulePkg.dsc -+++ b/MdeModulePkg/MdeModulePkg.dsc -@@ -336,6 +336,7 @@ - MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf - MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf - MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf -+ MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf - MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf -diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc -index 8691a0f5d0..8362aef07e 100644 ---- a/NetworkPkg/NetworkPkg.dsc -+++ b/NetworkPkg/NetworkPkg.dsc -@@ -80,10 +80,10 @@ - ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf - - [LibraryClasses.ARM] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [LibraryClasses.RISCV64] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [PcdsFeatureFlag] - gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|TRUE -diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index ccdf9b8ce0..a1a6897bc2 100644 ---- a/OvmfPkg/AmdSev/AmdSevX64.dsc -+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -188,7 +188,7 @@ - - IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf -diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc -index d8fe607d1c..1f710a0a04 100644 ---- a/OvmfPkg/Bhyve/BhyveX64.dsc -+++ b/OvmfPkg/Bhyve/BhyveX64.dsc -@@ -192,7 +192,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - !if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Bhyve/Library/PlatformSecureLib/PlatformSecureLib.inf -diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc -new file mode 100644 -index 0000000000..d76da20784 ---- /dev/null -+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc -@@ -0,0 +1,949 @@ -+## @file -+# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -+# -+# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
-+# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-+# Copyright (c) Microsoft Corporation. -+# -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+## -+ -+################################################################################ -+# -+# Defines Section - statements that will be processed to create a Makefile. -+# -+################################################################################ -+[Defines] -+ PLATFORM_NAME = CloudHv -+ PLATFORM_GUID = 97bb49d2-9814-4bea-8311-f8b9ac231e11 -+ PLATFORM_VERSION = 0.1 -+ DSC_SPECIFICATION = 0x00010005 -+ OUTPUT_DIRECTORY = Build/CloudHvX64 -+ SUPPORTED_ARCHITECTURES = X64 -+ BUILD_TARGETS = NOOPT|DEBUG|RELEASE -+ SKUID_IDENTIFIER = DEFAULT -+ FLASH_DEFINITION = OvmfPkg/CloudHv/CloudHvX64.fdf -+ -+ # -+ # Defines for default states. These can be changed on the command line. -+ # -D FLAG=VALUE -+ # -+ DEFINE SECURE_BOOT_ENABLE = FALSE -+ DEFINE SMM_REQUIRE = FALSE -+ DEFINE SOURCE_DEBUG_ENABLE = FALSE -+ -+!include OvmfPkg/OvmfTpmDefines.dsc.inc -+ -+ # -+ # Network definition -+ # -+ DEFINE NETWORK_TLS_ENABLE = FALSE -+ DEFINE NETWORK_IP6_ENABLE = FALSE -+ DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE -+ DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE -+ DEFINE NETWORK_ISCSI_ENABLE = TRUE -+ -+!include NetworkPkg/NetworkDefines.dsc.inc -+ -+ # -+ # Device drivers -+ # -+ DEFINE PVSCSI_ENABLE = FALSE -+ DEFINE MPT_SCSI_ENABLE = FALSE -+ DEFINE LSI_SCSI_ENABLE = FALSE -+ -+ # -+ # Flash size selection. Setting FD_SIZE_IN_KB on the command line directly to -+ # one of the supported values, in place of any of the convenience macros, is -+ # permitted. -+ # -+!ifdef $(FD_SIZE_1MB) -+ DEFINE FD_SIZE_IN_KB = 1024 -+!else -+!ifdef $(FD_SIZE_2MB) -+ DEFINE FD_SIZE_IN_KB = 2048 -+!else -+!ifdef $(FD_SIZE_4MB) -+ DEFINE FD_SIZE_IN_KB = 4096 -+!else -+ DEFINE FD_SIZE_IN_KB = 4096 -+!endif -+!endif -+!endif -+ -+[BuildOptions] -+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -+!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANGPDB" -+ GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse -+!endif -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ MSFT:*_*_X64_GENFW_FLAGS = --keepexceptiontable -+ GCC:*_*_X64_GENFW_FLAGS = --keepexceptiontable -+ INTEL:*_*_X64_GENFW_FLAGS = --keepexceptiontable -+!endif -+ RELEASE_*_*_GENFW_FLAGS = --zero -+ -+ # -+ # Disable deprecated APIs. -+ # -+ MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES -+ INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES -+ GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES -+ -+ # -+ # SECURE_BOOT_FEATURE_ENABLED -+ # -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED -+ INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED -+ GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED -+!endif -+ -+!include NetworkPkg/NetworkBuildOptions.dsc.inc -+ -+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] -+ GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -+ XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000 -+ XCODE:*_*_*_MTOC_FLAGS = -align 0x1000 -+ CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096 -+ -+# Force PE/COFF sections to be aligned at 4KB boundaries to support page level -+# protection of DXE_SMM_DRIVER/SMM_CORE modules -+[BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] -+ GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -+ XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000 -+ XCODE:*_*_*_MTOC_FLAGS = -align 0x1000 -+ CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096 -+ -+################################################################################ -+# -+# SKU Identification section - list of all SKU IDs supported by this Platform. -+# -+################################################################################ -+[SkuIds] -+ 0|DEFAULT -+ -+################################################################################ -+# -+# Library Class section - list of all Library Classes needed by this Platform. -+# -+################################################################################ -+ -+!include MdePkg/MdeLibs.dsc.inc -+ -+[LibraryClasses] -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/BaseResetSystemLib.inf -+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -+ BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf -+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf -+ SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf -+ TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf -+ BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf -+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf -+ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf -+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf -+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf -+ CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf -+ UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf -+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf -+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf -+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf -+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf -+ BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf -+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf -+ CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf -+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf -+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf -+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf -+ PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf -+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf -+ PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf -+ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf -+ PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf -+ PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf -+ CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf -+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf -+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf -+ SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf -+ MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf -+ MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf -+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf -+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf -+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf -+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf -+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf -+ DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf -+ NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf -+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf -+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf -+ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf -+ SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf -+ QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf -+ QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParserLib.inf -+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf -+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf -+ MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf -+ PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf -+ DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf -+!if $(SMM_REQUIRE) == FALSE -+ LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf -+!endif -+ CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf -+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf -+ MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf -+ -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf -+ DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf -+!else -+ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf -+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf -+!endif -+ -+ LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf -+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf -+ -+ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -+!if $(NETWORK_TLS_ENABLE) == TRUE -+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -+!else -+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -+!endif -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -+ AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -+ SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf -+ PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf -+ SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf -+!else -+ AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -+!endif -+ VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf -+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf -+ VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf -+ VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf -+ -+ -+ # -+ # Network libraries -+ # -+!include NetworkPkg/NetworkLibs.dsc.inc -+ -+!if $(NETWORK_TLS_ENABLE) == TRUE -+ TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf -+!endif -+ -+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf -+ ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf -+ S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf -+ SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf -+ OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf -+ -+!include OvmfPkg/OvmfTpmLibs.dsc.inc -+ -+[LibraryClasses.common] -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf -+ CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf -+ TdxLib|MdePkg/Library/TdxLib/TdxLib.inf -+ -+[LibraryClasses.common.SEC] -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf -+!endif -+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf -+ ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -+!endif -+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf -+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf -+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf -+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf -+!if $(TOOL_CHAIN_TAG) == "XCODE5" -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf -+!else -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf -+!endif -+ CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf -+ MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf -+ -+[LibraryClasses.common.PEI_CORE] -+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf -+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf -+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf -+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf -+ PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf -+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf -+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf -+ -+[LibraryClasses.common.PEIM] -+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf -+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf -+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf -+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf -+ PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf -+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf -+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf -+ ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf -+ ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf -+!endif -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf -+ MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf -+ QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf -+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf -+ QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf -+ -+ MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf -+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf -+ -+[LibraryClasses.common.DXE_CORE] -+ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -+!endif -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ -+[LibraryClasses.common.DXE_RUNTIME_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf -+!if $(SMM_REQUIRE) == TRUE -+ MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf -+!endif -+ -+[LibraryClasses.common.UEFI_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+[LibraryClasses.common.DXE_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf -+ PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf -+ QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -+!if $(SMM_REQUIRE) == TRUE -+ LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf -+!else -+ LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf -+!endif -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf -+!endif -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf -+ QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf -+ QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf -+ -+[LibraryClasses.common.UEFI_APPLICATION] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+[LibraryClasses.common.DXE_SMM_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf -+ MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf -+ SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf -+!endif -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf -+ -+[LibraryClasses.common.SMM_CORE] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf -+ MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf -+ SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+################################################################################ -+# -+# Pcd Section - list of all EDK II PCD Entries defined by this Platform. -+# -+################################################################################ -+[PcdsFeatureFlag] -+ gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE -+!if $(SMM_REQUIRE) == TRUE -+ gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport|TRUE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE -+!endif -+ -+[PcdsFixedAtBuild] -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 -+!if $(SMM_REQUIRE) == FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE -+!endif -+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 -+ gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 -+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048) -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 -+!if $(NETWORK_TLS_ENABLE) == FALSE -+ # match PcdFlashNvStorageVariableSize purely for convenience -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000 -+!endif -+!endif -+!if $(FD_SIZE_IN_KB) == 4096 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x8400 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x8400 -+!if $(NETWORK_TLS_ENABLE) == FALSE -+ # match PcdFlashNvStorageVariableSize purely for convenience -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x40000 -+!endif -+!endif -+!if $(NETWORK_TLS_ENABLE) == TRUE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x80000 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize|0x40000 -+!endif -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE -+ -+ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 -+ -+ # DEBUG_INIT 0x00000001 // Initialization -+ # DEBUG_WARN 0x00000002 // Warnings -+ # DEBUG_LOAD 0x00000004 // Load events -+ # DEBUG_FS 0x00000008 // EFI File system -+ # DEBUG_POOL 0x00000010 // Alloc & Free (pool) -+ # DEBUG_PAGE 0x00000020 // Alloc & Free (page) -+ # DEBUG_INFO 0x00000040 // Informational debug messages -+ # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers -+ # DEBUG_VARIABLE 0x00000100 // Variable -+ # DEBUG_BM 0x00000400 // Boot Manager -+ # DEBUG_BLKIO 0x00001000 // BlkIo Driver -+ # DEBUG_NET 0x00004000 // SNP Driver -+ # DEBUG_UNDI 0x00010000 // UNDI Driver -+ # DEBUG_LOADFILE 0x00020000 // LoadFile -+ # DEBUG_EVENT 0x00080000 // Event messages -+ # DEBUG_GCD 0x00100000 // Global Coherency Database changes -+ # DEBUG_CACHE 0x00200000 // Memory range cachability changes -+ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may -+ # // significantly impact boot performance -+ # DEBUG_ERROR 0x80000000 // Error -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 -+!else -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F -+!endif -+ -+!if $(SOURCE_DEBUG_ENABLE) == TRUE -+ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 -+!endif -+ -+ # -+ # The NumberOfPages values below are ad-hoc. They are updated sporadically at -+ # best (please refer to git-blame for past updates). The values capture a set -+ # of BIN hints that made sense at a particular time, for some (now likely -+ # unknown) workloads / boot paths. -+ # -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x80 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x10 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x80 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x100 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0x100 -+ -+ # -+ # Network Pcds -+ # -+!include NetworkPkg/NetworkPcds.dsc.inc -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 -+ -+!if $(SMM_REQUIRE) == TRUE -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000 -+!endif -+ -+ # 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 } -+ -+################################################################################ -+# -+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -+# -+################################################################################ -+ -+[PcdsDynamicDefault] -+ # only set when -+ # ($(SMM_REQUIRE) == FALSE) -+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE -+!if $(SMM_REQUIRE) == FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 -+!endif -+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE -+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000 -+ -+ gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000 -+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE -+ -+ # Noexec settings for DXE. -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE -+ -+ # UefiCpuPkg PCDs related to initial AP bringup and general AP management. -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0 -+ -+ # Set memory encryption mask -+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 -+ -+ # Set Tdx shared bit mask -+ gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 -+ -+ # Set SEV-ES defaults -+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 -+ gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 -+ -+!if $(SMM_REQUIRE) == TRUE -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 -+!endif -+ -+ gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 -+ -+!include OvmfPkg/OvmfTpmPcds.dsc.inc -+ -+ # IPv4 and IPv6 PXE Boot support. -+ gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01 -+ gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01 -+ -+ # Set ConfidentialComputing defaults -+ gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0 -+ -+[PcdsDynamicHii] -+!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc -+ -+################################################################################ -+# -+# Components Section - list of all EDK II Modules needed by this Platform. -+# -+################################################################################ -+[Components] -+ OvmfPkg/XenResetVector/XenResetVector.inf -+ -+ # -+ # SEC Phase modules -+ # -+ OvmfPkg/Sec/SecMain.inf { -+ -+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf -+ } -+ -+ # -+ # PEI Phase modules -+ # -+ MdeModulePkg/Core/Pei/PeiMain.inf -+ MdeModulePkg/Universal/PCD/Pei/Pcd.inf { -+ -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf { -+ -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf { -+ -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -+ -+ OvmfPkg/PlatformPei/PlatformPei.inf -+ UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf { -+ -+!if $(SMM_REQUIRE) == TRUE -+ LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf -+!endif -+ } -+!if $(SMM_REQUIRE) == TRUE -+ MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf -+ MdeModulePkg/Universal/Variable/Pei/VariablePei.inf -+ OvmfPkg/SmmAccess/SmmAccessPei.inf -+!endif -+ UefiCpuPkg/CpuMpPei/CpuMpPei.inf -+ -+!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc -+ -+ # -+ # DXE Phase modules -+ # -+ MdeModulePkg/Core/Dxe/DxeMain.inf { -+ -+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf -+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf -+ } -+ -+ MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -+ MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -+ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { -+ -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ -+ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -+ -+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf -+!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc -+!endif -+ } -+ -+ MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -+ UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf -+ UefiCpuPkg/CpuDxe/CpuDxe.inf -+ OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf -+ OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf -+ OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf -+ MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { -+ -+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf -+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf -+ NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf -+ } -+ MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { -+ -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ } -+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -+ MdeModulePkg/Universal/Metronome/Metronome.inf -+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf -+ MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -+ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { -+ -+ XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf -+ } -+ MdeModulePkg/Logo/LogoDxe.inf -+ MdeModulePkg/Application/UiApp/UiApp.inf { -+ -+ NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf -+ NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf -+ NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf -+ } -+ OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf { -+ -+ NULL|OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierLibNull.inf -+ } -+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf -+ OvmfPkg/Virtio10Dxe/Virtio10.inf -+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf -+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -+ OvmfPkg/VirtioRngDxe/VirtioRng.inf -+!if $(PVSCSI_ENABLE) == TRUE -+ OvmfPkg/PvScsiDxe/PvScsiDxe.inf -+!endif -+!if $(MPT_SCSI_ENABLE) == TRUE -+ OvmfPkg/MptScsiDxe/MptScsiDxe.inf -+!endif -+!if $(LSI_SCSI_ENABLE) == TRUE -+ OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf -+!endif -+ MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -+ MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -+ MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -+ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -+ MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -+ MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { -+ -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ } -+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -+ MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { -+ -+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -+ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -+ MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf -+ MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -+ FatPkg/EnhancedFatDxe/Fat.inf -+ MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf -+ OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf -+ MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -+ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -+ OvmfPkg/SataControllerDxe/SataControllerDxe.inf -+ MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf -+ MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf -+ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -+ MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -+ MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf -+ -+ # -+ # Serial Support -+ # -+ MdeModulePkg/Universal/SerialDxe/SerialDxe.inf -+ -+ # -+ # SMBIOS Support -+ # -+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { -+ -+ NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf -+ } -+ OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf -+ -+ # -+ # ACPI Support -+ # -+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf -+ OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf -+ MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf -+ MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+ MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf -+ -+ # -+ # Network Support -+ # -+!include NetworkPkg/NetworkComponents.dsc.inc -+!include OvmfPkg/NetworkComponents.dsc.inc -+ -+ OvmfPkg/VirtioNetDxe/VirtioNet.inf -+ -+!if $(TOOL_CHAIN_TAG) != "XCODE5" -+ ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ } -+ ShellPkg/DynamicCommand/HttpDynamicCommand/HttpDynamicCommand.inf { -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ } -+ OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf { -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ } -+!endif -+ ShellPkg/Application/Shell/Shell.inf { -+ -+ ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf -+!if $(NETWORK_IP6_ENABLE) == TRUE -+ NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf -+!endif -+ HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf -+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -+ BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf -+ -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 -+ } -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -+ OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.inf -+!endif -+ -+ OvmfPkg/PlatformDxe/Platform.inf -+ OvmfPkg/AmdSevDxe/AmdSevDxe.inf { -+ -+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf -+ } -+ OvmfPkg/IoMmuDxe/IoMmuDxe.inf -+ -+!if $(SMM_REQUIRE) == TRUE -+ OvmfPkg/SmmAccess/SmmAccess2Dxe.inf -+ OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf -+ OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf -+ -+ # -+ # SMM Initial Program Load (a DXE_RUNTIME_DRIVER) -+ # -+ MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf -+ -+ # -+ # SMM_CORE -+ # -+ MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf -+ -+ # -+ # Privileged drivers (DXE_SMM_DRIVER modules) -+ # -+ OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf -+ UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf -+ MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf { -+ -+ LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf -+ } -+ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { -+ -+ SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf -+ SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf -+ } -+ -+ # -+ # Variable driver stack (SMM) -+ # -+ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf { -+ -+ CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf -+ } -+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf -+ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf { -+ -+ NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf -+ NULL|MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.inf -+ } -+ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf -+ -+!else -+ -+ # -+ # Variable driver stack (non-SMM) -+ # -+ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -+ OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { -+ -+ PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf -+ } -+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -+ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { -+ -+ NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf -+ } -+!endif -+ -+ # -+ # TPM support -+ # -+!include OvmfPkg/OvmfTpmComponentsDxe.dsc.inc -diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc -new file mode 100644 -index 0000000000..d08b77ff25 ---- /dev/null -+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc -@@ -0,0 +1,779 @@ -+## @file -+# EFI/Framework Open Virtual Machine Firmware (OVMF) platform -+# -+# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
-+# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
-+# Copyright (c) Microsoft Corporation. -+# -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+## -+ -+################################################################################ -+# -+# Defines Section - statements that will be processed to create a Makefile. -+# -+################################################################################ -+[Defines] -+ PLATFORM_NAME = Ovmf -+ PLATFORM_GUID = 5a9e7754-d81b-49ea-85ad-69eaa7b1539b -+ PLATFORM_VERSION = 0.1 -+ DSC_SPECIFICATION = 0x00010005 -+ OUTPUT_DIRECTORY = Build/IntelTdx -+ SUPPORTED_ARCHITECTURES = X64 -+ BUILD_TARGETS = NOOPT|DEBUG|RELEASE -+ SKUID_IDENTIFIER = DEFAULT -+ FLASH_DEFINITION = OvmfPkg/IntelTdx/IntelTdxX64.fdf -+ -+ # -+ # Defines for default states. These can be changed on the command line. -+ # -D FLAG=VALUE -+ # -+ DEFINE SECURE_BOOT_ENABLE = FALSE -+ -+ # -+ # Device drivers -+ # -+ DEFINE PVSCSI_ENABLE = FALSE -+ DEFINE MPT_SCSI_ENABLE = FALSE -+ DEFINE LSI_SCSI_ENABLE = FALSE -+ -+ # -+ # Flash size selection. Setting FD_SIZE_IN_KB on the command line directly to -+ # one of the supported values, in place of any of the convenience macros, is -+ # permitted. -+ # -+!ifdef $(FD_SIZE_1MB) -+ DEFINE FD_SIZE_IN_KB = 1024 -+!else -+!ifdef $(FD_SIZE_2MB) -+ DEFINE FD_SIZE_IN_KB = 2048 -+!else -+!ifdef $(FD_SIZE_4MB) -+ DEFINE FD_SIZE_IN_KB = 4096 -+!else -+ DEFINE FD_SIZE_IN_KB = 4096 -+!endif -+!endif -+!endif -+ -+ # -+ # Define the FILE_GUID of CpuDxe for unique-processor version. -+ # -+ DEFINE UP_CPU_DXE_GUID = 6490f1c5-ebcc-4665-8892-0075b9bb49b7 -+ -+[BuildOptions] -+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -+!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANGPDB" -+ GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse -+!endif -+ RELEASE_*_*_GENFW_FLAGS = --zero -+ -+ # -+ # Disable deprecated APIs. -+ # -+ MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES -+ INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES -+ GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES -+ -+ # -+ # Add TDX_PEI_LESS_BOOT -+ # -+ MSFT:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT -+ INTEL:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT -+ GCC:*_*_*_CC_FLAGS = -D TDX_PEI_LESS_BOOT -+ -+ # -+ # SECURE_BOOT_FEATURE_ENABLED -+ # -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED -+ INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED -+ GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED -+!endif -+ -+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] -+ GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -+ XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000 -+ XCODE:*_*_*_MTOC_FLAGS = -align 0x1000 -+ CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096 -+ -+################################################################################ -+# -+# SKU Identification section - list of all SKU IDs supported by this Platform. -+# -+################################################################################ -+[SkuIds] -+ 0|DEFAULT -+ -+################################################################################ -+# -+# Library Class section - list of all Library Classes needed by this Platform. -+# -+################################################################################ -+ -+!include MdePkg/MdeLibs.dsc.inc -+ -+[LibraryClasses] -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/BaseResetSystemLib.inf -+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -+ BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf -+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf -+ SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf -+ TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf -+ BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf -+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf -+ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf -+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf -+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf -+ CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf -+ UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf -+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf -+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf -+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf -+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf -+ BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf -+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf -+ CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf -+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf -+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf -+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf -+ PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf -+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf -+ PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf -+ PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf -+ PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf -+ PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf -+ CcProbeLib|OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.inf -+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf -+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf -+ SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf -+ MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf -+ MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf -+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf -+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf -+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf -+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf -+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf -+ DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf -+ NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf -+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf -+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf -+ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf -+ UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf -+ SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf -+ QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf -+ QemuFwCfgSimpleParserLib|OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParserLib.inf -+ VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf -+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf -+ MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf -+ MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf -+ PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf -+ DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf -+ -+ LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf -+ CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf -+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf -+ -+ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf -+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf -+ -+ LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf -+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf -+ -+ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -+ AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf -+ SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf -+ PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf -+ SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf -+!else -+ AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf -+!endif -+ VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf -+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf -+ VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf -+ VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf -+ -+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf -+ ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf -+ S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf -+ SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf -+ OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf -+ -+ Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf -+ TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf -+ -+[LibraryClasses.common] -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf -+ CcExitLib|OvmfPkg/Library/CcExitLib/CcExitLib.inf -+ TdxLib|MdePkg/Library/TdxLib/TdxLib.inf -+ TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf -+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf -+ -+[LibraryClasses.common.SEC] -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf -+ QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgSecLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf -+!endif -+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf -+ ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf -+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf -+ MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf -+!if $(TOOL_CHAIN_TAG) == "XCODE5" -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf -+!else -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf -+!endif -+ CcExitLib|OvmfPkg/Library/CcExitLib/SecCcExitLib.inf -+ MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/SecMemEncryptSevLib.inf -+ PrePiHobListPointerLib|OvmfPkg/IntelTdx/PrePiHobListPointerLibTdx/PrePiHobListPointerLibTdx.inf -+ HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf -+ PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf -+ PeilessStartupLib|OvmfPkg/Library/PeilessStartupLib/PeilessStartupLib.inf -+ CcProbeLib|OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf -+ -+[LibraryClasses.common.DXE_CORE] -+ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ -+[LibraryClasses.common.DXE_RUNTIME_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf -+ VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf -+ -+[LibraryClasses.common.UEFI_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+[LibraryClasses.common.DXE_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf -+ PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf -+ QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf -+ LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf -+ QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf -+ QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf -+ -+[LibraryClasses.common.UEFI_APPLICATION] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+[LibraryClasses.common.DXE_SMM_DRIVER] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf -+ MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf -+ SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+[LibraryClasses.common.SMM_CORE] -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ TimerLib|OvmfPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf -+ ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf -+ SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.inf -+ MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf -+ SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/PiSmmCoreSmmServicesTableLib.inf -+!ifdef $(DEBUG_ON_SERIAL_PORT) -+ DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -+!else -+ DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf -+!endif -+ PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf -+ -+################################################################################ -+# -+# Pcd Section - list of all EDK II PCD Entries defined by this Platform. -+# -+################################################################################ -+[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 -+!endif -+ -+[PcdsFixedAtBuild] -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE -+ gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10 -+ gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0 -+!if ($(FD_SIZE_IN_KB) == 1024) || ($(FD_SIZE_IN_KB) == 2048) -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800 -+ # match PcdFlashNvStorageVariableSize purely for convenience -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0xe000 -+!endif -+!if $(FD_SIZE_IN_KB) == 4096 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x8400 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x8400 -+ # match PcdFlashNvStorageVariableSize purely for convenience -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x40000 -+!endif -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE -+ -+ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 -+ -+ # DEBUG_INIT 0x00000001 // Initialization -+ # DEBUG_WARN 0x00000002 // Warnings -+ # DEBUG_LOAD 0x00000004 // Load events -+ # DEBUG_FS 0x00000008 // EFI File system -+ # DEBUG_POOL 0x00000010 // Alloc & Free (pool) -+ # DEBUG_PAGE 0x00000020 // Alloc & Free (page) -+ # DEBUG_INFO 0x00000040 // Informational debug messages -+ # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers -+ # DEBUG_VARIABLE 0x00000100 // Variable -+ # DEBUG_BM 0x00000400 // Boot Manager -+ # DEBUG_BLKIO 0x00001000 // BlkIo Driver -+ # DEBUG_NET 0x00004000 // SNP Driver -+ # DEBUG_UNDI 0x00010000 // UNDI Driver -+ # DEBUG_LOADFILE 0x00020000 // LoadFile -+ # DEBUG_EVENT 0x00080000 // Event messages -+ # DEBUG_GCD 0x00100000 // Global Coherency Database changes -+ # DEBUG_CACHE 0x00200000 // Memory range cachability changes -+ # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may -+ # // significantly impact boot performance -+ # DEBUG_ERROR 0x80000000 // Error -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F -+ -+ # This PCD is used to set the base address of the PCI express hierarchy. It -+ # is only consulted when OVMF runs on Q35. In that case it is programmed into -+ # the PCIEXBAR register. -+ # -+ # On Q35 machine types that QEMU intends to support in the long term, QEMU -+ # never lets the RAM below 4 GB exceed 2816 MB. -+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 -+ -+ # -+ # The NumberOfPages values below are ad-hoc. They are updated sporadically at -+ # best (please refer to git-blame for past updates). The values capture a set -+ # of BIN hints that made sense at a particular time, for some (now likely -+ # unknown) workloads / boot paths. -+ # -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x80 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x10 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0x80 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|0x100 -+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|0x100 -+ -+ # -+ # TDX need 1G PageTable support -+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000 -+ -+ # IRQs 5, 9, 10, 11 are level-triggered -+ gUefiOvmfPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel|0x0E20 -+ -+ # 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 } -+ -+################################################################################ -+# -+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform -+# -+################################################################################ -+ -+[PcdsDynamicDefault] -+ # only set when -+ # ($(SMM_REQUIRE) == FALSE) -+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE -+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000 -+ -+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 -+ -+ # Set video resolution for text setup. -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480 -+ -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 -+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE -+ -+ # Noexec settings for DXE. -+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE -+ -+ # UefiCpuPkg PCDs related to initial AP bringup and general AP management. -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 -+ gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0 -+ -+ # Set memory encryption mask -+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 -+ -+ # Set Tdx shared bit mask -+ gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 -+ -+ # Set SEV-ES defaults -+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 -+ gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 -+ -+ gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 -+ -+ # Set ConfidentialComputing defaults -+ gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0 -+ -+ gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000 -+ -+################################################################################ -+# -+# Components Section - list of all EDK II Modules needed by this Platform. -+# -+################################################################################ -+[Components] -+ OvmfPkg/ResetVector/ResetVector.inf -+ -+ # -+ # SEC Phase modules -+ # -+ OvmfPkg/IntelTdx/Sec/SecMain.inf { -+ -+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf -+ TpmMeasurementLib|SecurityPkg/Library/SecTpmMeasurementLib/SecTpmMeasurementLibTdx.inf -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf -+ HashLib|SecurityPkg/Library/HashLibTdx/HashLibTdx.inf -+ NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf -+ } -+ -+ # -+ # DXE Phase modules -+ # -+ MdeModulePkg/Core/Dxe/DxeMain.inf { -+ -+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf -+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf -+ } -+ -+ MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf -+ MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf -+ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf { -+ -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ -+ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf -+ -+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf -+!endif -+ NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -+ } -+ -+ MdeModulePkg/Universal/EbcDxe/EbcDxe.inf -+ UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf -+ -+ UefiCpuPkg/CpuDxe/CpuDxe.inf { -+ -+ # -+ # Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which -+ # checks the Protocol of gEfiMpInitLibMpDepProtocolGuid. -+ # -+ MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf -+ NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibMpDepLib.inf -+ } -+ -+ UefiCpuPkg/CpuDxe/CpuDxe.inf { -+ -+ FILE_GUID = $(UP_CPU_DXE_GUID) -+ -+ -+ # -+ # Directly use MpInitLibUp. It depends on DxeMpInitLibUpDepLib which -+ # checks the Protocol of gEfiMpInitLibUpDepProtocolGuid. -+ # -+ MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf -+ NULL|OvmfPkg/Library/MpInitLibDepLib/DxeMpInitLibUpDepLib.inf -+ } -+ -+ OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf -+ OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf -+ OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf -+ MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { -+ -+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf -+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf -+ NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf -+ } -+ MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { -+ -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ } -+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf -+ MdeModulePkg/Universal/Metronome/Metronome.inf -+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf -+ MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf -+ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf { -+ -+ XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf -+ } -+ MdeModulePkg/Logo/LogoDxe.inf -+ MdeModulePkg/Application/UiApp/UiApp.inf { -+ -+ NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf -+ NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf -+ NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf -+ } -+ OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf { -+ -+ NULL|OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierLibNull.inf -+ } -+ OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf -+ OvmfPkg/Virtio10Dxe/Virtio10.inf -+ OvmfPkg/VirtioBlkDxe/VirtioBlk.inf -+ OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -+ OvmfPkg/VirtioRngDxe/VirtioRng.inf -+!if $(PVSCSI_ENABLE) == TRUE -+ OvmfPkg/PvScsiDxe/PvScsiDxe.inf -+!endif -+!if $(MPT_SCSI_ENABLE) == TRUE -+ OvmfPkg/MptScsiDxe/MptScsiDxe.inf -+!endif -+!if $(LSI_SCSI_ENABLE) == TRUE -+ OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf -+!endif -+ MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf -+ MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -+ MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -+ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf -+ MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf -+ MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf { -+ -+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf -+ } -+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf -+ MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf { -+ -+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ } -+ -+ MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -+ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -+ MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf -+ MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -+ FatPkg/EnhancedFatDxe/Fat.inf -+ MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf -+ OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf -+ MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf -+ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf -+ OvmfPkg/SataControllerDxe/SataControllerDxe.inf -+ MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf -+ MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf -+ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf -+ MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf -+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf -+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf -+ MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf -+ -+!ifndef $(CSM_ENABLE) -+ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf -+!endif -+ OvmfPkg/QemuRamfbDxe/QemuRamfbDxe.inf -+ OvmfPkg/VirtioGpuDxe/VirtioGpu.inf -+ -+ # -+ # ISA Support -+ # -+ OvmfPkg/SioBusDxe/SioBusDxe.inf -+ MdeModulePkg/Bus/Pci/PciSioSerialDxe/PciSioSerialDxe.inf -+ MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.inf -+ -+ # -+ # SMBIOS Support -+ # -+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf { -+ -+ NULL|OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf -+ } -+ OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf -+ -+ # -+ # ACPI Support -+ # -+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf -+ OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf -+ MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf -+ MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf -+ MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf -+ -+ # -+ # Usb Support -+ # -+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf -+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf -+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf -+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf -+ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf -+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf -+ -+!if $(TOOL_CHAIN_TAG) != "XCODE5" -+ OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf { -+ -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ } -+!endif -+ ShellPkg/Application/Shell/Shell.inf { -+ -+ ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf -+ NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf -+ HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf -+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -+ BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf -+ -+ -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF -+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE -+ gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 -+ } -+ -+!if $(SECURE_BOOT_ENABLE) == TRUE -+ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -+ OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.inf -+!endif -+ -+ OvmfPkg/PlatformDxe/Platform.inf -+ OvmfPkg/IoMmuDxe/IoMmuDxe.inf -+ -+ OvmfPkg/TdxDxe/TdxDxe.inf -+ -+ # -+ # Variable driver stack (non-SMM) -+ # -+ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf -+ OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { -+ -+ PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf -+ } -+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf -+ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { -+ -+ NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf -+ } -+ -+ # -+ # Cc Measurement Protocol for Td guest -+ # -+ OvmfPkg/IntelTdx/TdTcg2Dxe/TdTcg2Dxe.inf { -+ -+ HashLib|SecurityPkg/Library/HashLibTdx/HashLibTdx.inf -+ NULL|SecurityPkg/Library/HashInstanceLibSha384/HashInstanceLibSha384.inf -+ } -diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc -index 617f925395..afd4bf3e98 100644 ---- a/OvmfPkg/Microvm/MicrovmX64.dsc -+++ b/OvmfPkg/Microvm/MicrovmX64.dsc -@@ -201,7 +201,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf -diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index a0666930d6..47426c5cd2 100644 ---- a/OvmfPkg/OvmfPkgIa32.dsc -+++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -199,7 +199,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - !if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 5efeb42bf3..d4b30e8133 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.dsc -+++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -203,7 +203,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - !if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 10fb7d7069..5b0f6c8747 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -203,7 +203,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - !if $(SECURE_BOOT_ENABLE) == TRUE - PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc -index a31519e356..e7c36d1b80 100644 ---- a/OvmfPkg/OvmfXen.dsc -+++ b/OvmfPkg/OvmfXen.dsc -@@ -188,7 +188,7 @@ - !else - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf - !endif -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf -diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc -index 36493f04ee..3daf9e5462 100644 ---- a/SecurityPkg/SecurityPkg.dsc -+++ b/SecurityPkg/SecurityPkg.dsc -@@ -91,10 +91,10 @@ - ArmTrngLib|MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf - - [LibraryClasses.ARM] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [LibraryClasses.RISCV64] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [LibraryClasses.common.PEIM] - PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf -diff --git a/SignedCapsulePkg/SignedCapsulePkg.dsc b/SignedCapsulePkg/SignedCapsulePkg.dsc -index 8a27207a6f..4c656666e9 100644 ---- a/SignedCapsulePkg/SignedCapsulePkg.dsc -+++ b/SignedCapsulePkg/SignedCapsulePkg.dsc -@@ -110,10 +110,10 @@ - NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf - - [LibraryClasses.ARM] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [LibraryClasses.RISCV64] -- RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - - [LibraryClasses.common.PEI_CORE] - HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf --- -2.39.3 - diff --git a/SOURCES/edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch b/SOURCES/edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch deleted file mode 100644 index 2729b1f..0000000 --- a/SOURCES/edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 2e4b2b8fce40cf93f35e052102f37fee07b2e64a Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Mon, 10 Jun 2024 18:13:29 -0400 -Subject: [PATCH 02/31] MdeModulePkg: Potential UINT32 overflow in S3 - ResumeCount - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [2/31] a3592c3437041cbd33a6c11feb3d0999e122c8c0 - -JIRA: https://issues.redhat.com/browse/RHEL-40099 -CVE: CVE-2024-1298 -Upstream: Merged - -commit 284dbac43da752ee34825c8b3f6f9e8281cb5a19 -Author: Shanmugavel Pakkirisamy -Date: Mon May 6 17:53:09 2024 +0800 - - MdeModulePkg: Potential UINT32 overflow in S3 ResumeCount - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4677 - - Attacker able to modify physical memory and ResumeCount. - System will crash/DoS when ResumeCount reaches its MAX_UINT32. - - Cc: Zhiguang Liu - Cc: Dandan Bi - Cc: Liming Gao - - Signed-off-by: Pakkirisamy ShanmugavelX - Reviewed-by: Liming Gao - -Signed-off-by: Jon Maloy ---- - .../FirmwarePerformancePei.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -index 6881466201..54b3bc3c54 100644 ---- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -+++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c -@@ -110,11 +110,15 @@ FpdtStatusCodeListenerPei ( - // - S3ResumeTotal = MultU64x32 (AcpiS3ResumeRecord->AverageResume, AcpiS3ResumeRecord->ResumeCount); - AcpiS3ResumeRecord->ResumeCount++; -- AcpiS3ResumeRecord->AverageResume = DivU64x32 (S3ResumeTotal + AcpiS3ResumeRecord->FullResume, AcpiS3ResumeRecord->ResumeCount); -+ if (AcpiS3ResumeRecord->ResumeCount > 0) { -+ AcpiS3ResumeRecord->AverageResume = DivU64x32 (S3ResumeTotal + AcpiS3ResumeRecord->FullResume, AcpiS3ResumeRecord->ResumeCount); -+ DEBUG ((DEBUG_INFO, "\nFPDT: S3 Resume Performance - AverageResume = 0x%x\n", AcpiS3ResumeRecord->AverageResume)); -+ } else { -+ DEBUG ((DEBUG_ERROR, "\nFPDT: S3 ResumeCount reaches the MAX_UINT32 value. S3 ResumeCount record reset to Zero.")); -+ } - -- DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - ResumeCount = %d\n", AcpiS3ResumeRecord->ResumeCount)); -- DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - FullResume = %ld\n", AcpiS3ResumeRecord->FullResume)); -- DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - AverageResume = %ld\n", AcpiS3ResumeRecord->AverageResume)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - ResumeCount = 0x%x\n", AcpiS3ResumeRecord->ResumeCount)); -+ DEBUG ((DEBUG_INFO, "FPDT: S3 Resume Performance - FullResume = 0x%x\n", AcpiS3ResumeRecord->FullResume)); - - // - // Update S3 Suspend Performance Record. --- -2.39.3 - diff --git a/SOURCES/edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch b/SOURCES/edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch deleted file mode 100644 index 9959d96..0000000 --- a/SOURCES/edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 5ba444af245d59e3208260478aa710d4f143f259 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:06:25 -0400 -Subject: [PATCH 20/31] MdeModulePkg/Rng: Add GUID to describe unsafe Rng - algorithms - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [20/31] d0e553560d60122f2fe5f33923b5b943c138a18d - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 414c0f20896f3dec412135fa4260f8aad8bef246 -Author: Pierre Gondois -Date: Fri Aug 11 16:33:07 2023 +0200 - - MdeModulePkg/Rng: Add GUID to describe unsafe Rng algorithms - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4441 - - The EFI_RNG_PROTOCOL can rely on the RngLib. The RngLib has multiple - implementations, some of them are unsafe (e.g. BaseRngLibTimerLib). - To allow the RngDxe to detect when such implementation is used, - a GetRngGuid() function is added in a following patch. - - Prepare GetRngGuid() return values and add a gEdkiiRngAlgorithmUnSafe - to describe an unsafe implementation, cf. the BaseRngLibTimerLib. - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - MdeModulePkg/Include/Guid/RngAlgorithm.h | 23 +++++++++++++++++++++++ - MdeModulePkg/MdeModulePkg.dec | 3 +++ - 2 files changed, 26 insertions(+) - create mode 100644 MdeModulePkg/Include/Guid/RngAlgorithm.h - -diff --git a/MdeModulePkg/Include/Guid/RngAlgorithm.h b/MdeModulePkg/Include/Guid/RngAlgorithm.h -new file mode 100644 -index 0000000000..e2ac2ba3e5 ---- /dev/null -+++ b/MdeModulePkg/Include/Guid/RngAlgorithm.h -@@ -0,0 +1,23 @@ -+/** @file -+ Rng Algorithm -+ -+ Copyright (c) 2023, Arm Limited. All rights reserved.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#ifndef RNG_ALGORITHM_GUID_H_ -+#define RNG_ALGORITHM_GUID_H_ -+ -+/// -+/// The implementation of a Random Number Generator might be unsafe, when using -+/// a dummy implementation for instance. Allow identifying such implementation -+/// with this GUID. -+/// -+#define EDKII_RNG_ALGORITHM_UNSAFE \ -+ { \ -+ 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 } \ -+ } -+ -+extern EFI_GUID gEdkiiRngAlgorithmUnSafe; -+ -+#endif // #ifndef RNG_ALGORITHM_GUID_H_ -diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec -index 08d59dfb3e..3513a9678a 100644 ---- a/MdeModulePkg/MdeModulePkg.dec -+++ b/MdeModulePkg/MdeModulePkg.dec -@@ -401,6 +401,9 @@ - ## Include/Guid/MigratedFvInfo.h - gEdkiiMigratedFvInfoGuid = { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4, 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } - -+ ## Include/Guid/RngAlgorithm.h -+ gEdkiiRngAlgorithmUnSafe = { 0x869f728c, 0x409d, 0x4ab4, {0xac, 0x03, 0x71, 0xd3, 0x09, 0xc1, 0xb3, 0xf4 }} -+ - # - # GUID defined in UniversalPayload - # --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch b/SOURCES/edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch deleted file mode 100644 index 925fcf1..0000000 --- a/SOURCES/edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 3800b9ee5d6d4c05c7e27f949c3b32c422c78f2d Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:02:31 -0400 -Subject: [PATCH 16/31] MdePkg: Add deprecated warning to BaseRngLibTimer - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [16/31] 6e199344d083e90f60cbe01dfb3c2a3719e3177d - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit e93468442b7da7bc80e00014e854c0c8a0a7184b -Author: Pierre Gondois -Date: Fri Aug 11 16:33:03 2023 +0200 - - MdePkg: Add deprecated warning to BaseRngLibTimer - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4504 - - To keep the MdePkg self-contained and avoid dependencies on GUIDs - defined in other packages, the BaseRngLibTimer was moved to the - MdePkg. - Add a constructor to warn and request to use the MdeModulePkg - implementation. - - Signed-off-by: Pierre Gondois - Reviewed-by: Liming Gao - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - .../BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 1 + - .../Library/BaseRngLibTimerLib/RngLibTimer.c | 22 +++++++++++++++++++ - 2 files changed, 23 insertions(+) - -diff --git a/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -index f857290e82..96c90db63f 100644 ---- a/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+++ b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -@@ -23,6 +23,7 @@ - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = RngLib -+ CONSTRUCTOR = BaseRngLibTimerConstructor - - [Sources] - RngLibTimer.c -diff --git a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -index 54d29d96f3..6b8392162b 100644 ---- a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -+++ b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -@@ -13,6 +13,28 @@ - - #define DEFAULT_DELAY_TIME_IN_MICROSECONDS 10 - -+/** -+ This implementation is to be replaced by its MdeModulePkg copy. -+ The cause being that some GUIDs (gEdkiiRngAlgorithmUnSafe) cannot -+ be defined in the MdePkg. -+ -+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. -+**/ -+RETURN_STATUS -+EFIAPI -+BaseRngLibTimerConstructor ( -+ VOID -+ ) -+{ -+ DEBUG (( -+ DEBUG_WARN, -+ "Warning: This BaseRngTimerLib implementation will be deprecated. " -+ "Please use the MdeModulePkg implementation equivalent.\n" -+ )); -+ -+ return RETURN_SUCCESS; -+} -+ - /** - Using the TimerLib GetPerformanceCounterProperties() we delay - for enough time for the PerformanceCounter to increment. --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-Apply-uncrustify-changes.patch b/SOURCES/edk2-MdePkg-Apply-uncrustify-changes.patch deleted file mode 100644 index e5409de..0000000 --- a/SOURCES/edk2-MdePkg-Apply-uncrustify-changes.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 1198bceefa4834c09e1edc1c558aeffe4930d1f5 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 11 Jun 2024 21:32:26 -0400 -Subject: [PATCH 03/31] MdePkg: Apply uncrustify changes - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [3/31] 422d94b837bf0e65164968272a358c2656f59838 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -This is a subset of the whitespace changes in the corresponding upstream -commit. It is needed for the next commits in this series to apply with -less fewer conflicts. - -commit 2f88bd3a1296c522317f1c21377876de63de5be7 -Author: Michael Kubacki -Date: Sun Dec 5 14:54:05 2021 -0800 - - MdePkg: Apply uncrustify changes - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 - - Apply uncrustify changes to .c/.h files in the MdePkg package - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael D Kinney - Signed-off-by: Michael Kubacki - Reviewed-by: Liming Gao - -Signed-off-by: Jon Maloy ---- - MdePkg/Include/Protocol/Rng.h | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -diff --git a/MdePkg/Include/Protocol/Rng.h b/MdePkg/Include/Protocol/Rng.h -index a0a05d1661..baf425587b 100644 ---- a/MdePkg/Include/Protocol/Rng.h -+++ b/MdePkg/Include/Protocol/Rng.h -@@ -93,7 +93,7 @@ typedef EFI_GUID EFI_RNG_ALGORITHM; - **/ - typedef - EFI_STATUS --(EFIAPI *EFI_RNG_GET_INFO) ( -+(EFIAPI *EFI_RNG_GET_INFO)( - IN EFI_RNG_PROTOCOL *This, - IN OUT UINTN *RNGAlgorithmListSize, - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList -@@ -123,9 +123,9 @@ EFI_STATUS - **/ - typedef - EFI_STATUS --(EFIAPI *EFI_RNG_GET_RNG) ( -+(EFIAPI *EFI_RNG_GET_RNG)( - IN EFI_RNG_PROTOCOL *This, -- IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL -+ IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, - IN UINTN RNGValueLength, - OUT UINT8 *RNGValue - ); -@@ -135,16 +135,16 @@ EFI_STATUS - /// applications, or entropy for seeding other random number generators. - /// - struct _EFI_RNG_PROTOCOL { -- EFI_RNG_GET_INFO GetInfo; -- EFI_RNG_GET_RNG GetRNG; -+ EFI_RNG_GET_INFO GetInfo; -+ EFI_RNG_GET_RNG GetRNG; - }; - --extern EFI_GUID gEfiRngProtocolGuid; --extern EFI_GUID gEfiRngAlgorithmSp80090Hash256Guid; --extern EFI_GUID gEfiRngAlgorithmSp80090Hmac256Guid; --extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid; --extern EFI_GUID gEfiRngAlgorithmX9313DesGuid; --extern EFI_GUID gEfiRngAlgorithmX931AesGuid; --extern EFI_GUID gEfiRngAlgorithmRaw; -+extern EFI_GUID gEfiRngProtocolGuid; -+extern EFI_GUID gEfiRngAlgorithmSp80090Hash256Guid; -+extern EFI_GUID gEfiRngAlgorithmSp80090Hmac256Guid; -+extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid; -+extern EFI_GUID gEfiRngAlgorithmX9313DesGuid; -+extern EFI_GUID gEfiRngAlgorithmX931AesGuid; -+extern EFI_GUID gEfiRngAlgorithmRaw; - - #endif --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch b/SOURCES/edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch deleted file mode 100644 index ca73c6b..0000000 --- a/SOURCES/edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 3351bd0ba07cc490c344d2dc54b86833993ca5a2 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 15:58:58 -0400 -Subject: [PATCH 18/31] MdePkg/DxeRngLib: Request raw algorithm instead of - default - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [18/31] fa2da700127ae713aa578638c2390673fc49522d - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit bd1f0eecc1dfe51ba20161bef8860d12392006bd -Author: Pierre Gondois -Date: Fri Aug 11 16:33:05 2023 +0200 - - MdePkg/DxeRngLib: Request raw algorithm instead of default - - The DxeRngLib tries to generate a random number using the 3 NIST - SP 800-90 compliant DRBG algorithms, i.e. 256-bits CTR, HASH and HMAC. - If none of the call is successful, the fallback option is the default - RNG algorithm of the EFI_RNG_PROTOCOL. This default algorithm might - be an unsafe implementation. - - Try requesting the Raw algorithm before requesting the default one. - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Reviewed-by: Liming Gao - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - MdePkg/Library/DxeRngLib/DxeRngLib.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c -index 9c3d67b5a6..4b2fc1cde5 100644 ---- a/MdePkg/Library/DxeRngLib/DxeRngLib.c -+++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c -@@ -64,9 +64,16 @@ GenerateRandomNumberViaNist800Algorithm ( - if (!EFI_ERROR (Status)) { - return Status; - } -+ -+ Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmRaw, BufferSize, Buffer); -+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Raw - Status = %r\n", __func__, Status)); -+ if (!EFI_ERROR (Status)) { -+ return Status; -+ } -+ - // If all the other methods have failed, use the default method from the RngProtocol - Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer); -- DEBUG((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status)); -+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm default - Status = %r\n", __func__, Status)); - if (!EFI_ERROR (Status)) { - return Status; - } --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-Introduce-CcMeasurementProtocol-for-CC-Guest-.patch b/SOURCES/edk2-MdePkg-Introduce-CcMeasurementProtocol-for-CC-Guest-.patch deleted file mode 100644 index df008db..0000000 --- a/SOURCES/edk2-MdePkg-Introduce-CcMeasurementProtocol-for-CC-Guest-.patch +++ /dev/null @@ -1,390 +0,0 @@ -From b8261ac422ba284249cd4f341d78d058e79960f5 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 7 Feb 2024 11:56:37 -0500 -Subject: [PATCH 03/17] MdePkg: Introduce CcMeasurementProtocol for CC Guest - firmware - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [3/13] 6bf304f8e3bc875024c8fb0a4cd5d2c944f69480 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged - -commit e193584da60550008722498442c62ddb77bf27d5 -Author: Min Xu -Date: Sat Dec 11 21:08:40 2021 +0800 - - MdePkg: Introduce CcMeasurementProtocol for CC Guest firmware - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3625 - - CC guest is a Confidential Computing guest. If CC Guest firmware - supports measurement and an event is created, CC Guest firmware - is designed to report the event log with the same data structure - in TCG-Platform-Firmware-Profile specification with - EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format. - - The CC Guest firmware supports measurement. It is designed to - produce EFI_CC_MEASUREMENT_PROTOCOL with new GUID - EFI_CC_MEASUREMENT_PROTOCOL_GUID to report event log and provides - hash capability. - - Cc: Michael D Kinney - Cc: Liming Gao - Cc: Zhiguang Liu - Cc: Jiewen Yao - Cc: Jian J Wang - Cc: Ken Lu - Cc: Sami Mujawar - Cc: Gerd Hoffmann - Reviewed-by: Liming Gao - Reviewed-by: Sami Mujawar - Reviewed-by: Jiewen Yao - Signed-off-by: Min Xu - -Signed-off-by: Jon Maloy ---- - MdePkg/Include/Protocol/CcMeasurement.h | 302 ++++++++++++++++++++++++ - MdePkg/MdePkg.dec | 6 + - 2 files changed, 308 insertions(+) - create mode 100644 MdePkg/Include/Protocol/CcMeasurement.h - -diff --git a/MdePkg/Include/Protocol/CcMeasurement.h b/MdePkg/Include/Protocol/CcMeasurement.h -new file mode 100644 -index 0000000000..68029e977f ---- /dev/null -+++ b/MdePkg/Include/Protocol/CcMeasurement.h -@@ -0,0 +1,302 @@ -+/** @file -+ If CC Guest firmware supports measurement and an event is created, -+ CC Guest firmware is designed to report the event log with the same -+ data structure in TCG-Platform-Firmware-Profile specification with -+ EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format. -+ -+ The CC Guest firmware supports measurement, the CC Guest Firmware is -+ designed to produce EFI_CC_MEASUREMENT_PROTOCOL with new GUID -+ EFI_CC_MEASUREMENT_PROTOCOL_GUID to report event log and provides hash -+ capability. -+ -+Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.
-+SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#ifndef CC_MEASUREMENT_PROTOCOL_H_ -+#define CC_MEASUREMENT_PROTOCOL_H_ -+ -+#include -+ -+#define EFI_CC_MEASUREMENT_PROTOCOL_GUID \ -+ { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b }} -+extern EFI_GUID gEfiCcMeasurementProtocolGuid; -+ -+typedef struct _EFI_CC_MEASUREMENT_PROTOCOL EFI_CC_MEASUREMENT_PROTOCOL; -+ -+typedef struct { -+ UINT8 Major; -+ UINT8 Minor; -+} EFI_CC_VERSION; -+ -+// -+// EFI_CC Type/SubType definition -+// -+#define EFI_CC_TYPE_NONE 0 -+#define EFI_CC_TYPE_SEV 1 -+#define EFI_CC_TYPE_TDX 2 -+ -+typedef struct { -+ UINT8 Type; -+ UINT8 SubType; -+} EFI_CC_TYPE; -+ -+typedef UINT32 EFI_CC_EVENT_LOG_BITMAP; -+typedef UINT32 EFI_CC_EVENT_LOG_FORMAT; -+typedef UINT32 EFI_CC_EVENT_ALGORITHM_BITMAP; -+typedef UINT32 EFI_CC_MR_INDEX; -+ -+// -+// Intel TDX measure register index -+// -+#define TDX_MR_INDEX_MRTD 0 -+#define TDX_MR_INDEX_RTMR0 1 -+#define TDX_MR_INDEX_RTMR1 2 -+#define TDX_MR_INDEX_RTMR2 3 -+#define TDX_MR_INDEX_RTMR3 4 -+ -+#define EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002 -+#define EFI_CC_BOOT_HASH_ALG_SHA384 0x00000004 -+ -+// -+// This bit is shall be set when an event shall be extended but not logged. -+// -+#define EFI_CC_FLAG_EXTEND_ONLY 0x0000000000000001 -+// -+// This bit shall be set when the intent is to measure a PE/COFF image. -+// -+#define EFI_CC_FLAG_PE_COFF_IMAGE 0x0000000000000010 -+ -+#pragma pack (1) -+ -+#define EFI_CC_EVENT_HEADER_VERSION 1 -+ -+typedef struct { -+ // -+ // Size of the event header itself (sizeof(EFI_CC_EVENT_HEADER)). -+ // -+ UINT32 HeaderSize; -+ // -+ // Header version. For this version of this specification, the value shall be 1. -+ // -+ UINT16 HeaderVersion; -+ // -+ // Index of the MR (measurement register) that shall be extended. -+ // -+ EFI_CC_MR_INDEX MrIndex; -+ // -+ // Type of the event that shall be extended (and optionally logged). -+ // -+ UINT32 EventType; -+} EFI_CC_EVENT_HEADER; -+ -+typedef struct { -+ // -+ // Total size of the event including the Size component, the header and the Event data. -+ // -+ UINT32 Size; -+ EFI_CC_EVENT_HEADER Header; -+ UINT8 Event[1]; -+} EFI_CC_EVENT; -+ -+#pragma pack() -+ -+typedef struct { -+ // -+ // Allocated size of the structure -+ // -+ UINT8 Size; -+ // -+ // Version of the EFI_CC_BOOT_SERVICE_CAPABILITY structure itself. -+ // For this version of the protocol, the Major version shall be set to 1 -+ // and the Minor version shall be set to 0. -+ // -+ EFI_CC_VERSION StructureVersion; -+ // -+ // Version of the EFI CC Measurement protocol. -+ // For this version of the protocol, the Major version shall be set to 1 -+ // and the Minor version shall be set to 0. -+ // -+ EFI_CC_VERSION ProtocolVersion; -+ // -+ // Supported hash algorithms -+ // -+ EFI_CC_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; -+ // -+ // Bitmap of supported event log formats -+ // -+ EFI_CC_EVENT_LOG_BITMAP SupportedEventLogs; -+ -+ // -+ // Indicates the CC type -+ // -+ EFI_CC_TYPE CcType; -+} EFI_CC_BOOT_SERVICE_CAPABILITY; -+ -+/** -+ The EFI_CC_MEASUREMENT_PROTOCOL GetCapability function call provides protocol -+ capability information and state information. -+ -+ @param[in] This Indicates the calling context -+ @param[in, out] ProtocolCapability The caller allocates memory for a EFI_CC_BOOT_SERVICE_CAPABILITY -+ structure and sets the size field to the size of the structure allocated. -+ The callee fills in the fields with the EFI CC BOOT Service capability -+ information and the current CC information. -+ -+ @retval EFI_SUCCESS Operation completed successfully. -+ @retval EFI_DEVICE_ERROR The command was unsuccessful. -+ The ProtocolCapability variable will not be populated. -+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. -+ The ProtocolCapability variable will not be populated. -+ @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response. -+ It will be partially populated (required Size field will be set). -+**/ -+typedef -+EFI_STATUS -+(EFIAPI *EFI_CC_GET_CAPABILITY)( -+ IN EFI_CC_MEASUREMENT_PROTOCOL *This, -+ IN OUT EFI_CC_BOOT_SERVICE_CAPABILITY *ProtocolCapability -+ ); -+ -+/** -+ The EFI_CC_MEASUREMENT_PROTOCOL Get Event Log function call allows a caller to -+ retrieve the address of a given event log and its last entry. -+ -+ @param[in] This Indicates the calling context -+ @param[in] EventLogFormat The type of the event log for which the information is requested. -+ @param[out] EventLogLocation A pointer to the memory address of the event log. -+ @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the -+ address of the start of the last entry in the event log in memory. -+ @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would -+ have exceeded the area allocated for events, this value is set to TRUE. -+ Otherwise, the value will be FALSE and the Event Log will be complete. -+ -+ @retval EFI_SUCCESS Operation completed successfully. -+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect -+ (e.g. asking for an event log whose format is not supported). -+**/ -+typedef -+EFI_STATUS -+(EFIAPI *EFI_CC_GET_EVENT_LOG)( -+ IN EFI_CC_MEASUREMENT_PROTOCOL *This, -+ IN EFI_CC_EVENT_LOG_FORMAT EventLogFormat, -+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, -+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry, -+ OUT BOOLEAN *EventLogTruncated -+ ); -+ -+/** -+ The EFI_CC_MEASUREMENT_PROTOCOL HashLogExtendEvent function call provides -+ callers with an opportunity to extend and optionally log events without requiring -+ knowledge of actual CC commands. -+ The extend operation will occur even if this function cannot create an event -+ log entry (e.g. due to the event log being full). -+ -+ @param[in] This Indicates the calling context -+ @param[in] Flags Bitmap providing additional information. -+ @param[in] DataToHash Physical address of the start of the data buffer to be hashed. -+ @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash. -+ @param[in] EfiCcEvent Pointer to data buffer containing information about the event. -+ -+ @retval EFI_SUCCESS Operation completed successfully. -+ @retval EFI_DEVICE_ERROR The command was unsuccessful. -+ @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs. -+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. -+ @retval EFI_UNSUPPORTED The PE/COFF image type is not supported. -+**/ -+typedef -+EFI_STATUS -+(EFIAPI *EFI_CC_HASH_LOG_EXTEND_EVENT)( -+ IN EFI_CC_MEASUREMENT_PROTOCOL *This, -+ IN UINT64 Flags, -+ IN EFI_PHYSICAL_ADDRESS DataToHash, -+ IN UINT64 DataToHashLen, -+ IN EFI_CC_EVENT *EfiCcEvent -+ ); -+ -+/** -+ The EFI_CC_MEASUREMENT_PROTOCOL MapPcrToMrIndex function call provides callers -+ the info on TPM PCR <-> CC MR mapping information. -+ -+ @param[in] This Indicates the calling context -+ @param[in] PcrIndex TPM PCR index. -+ @param[out] MrIndex CC MR index. -+ -+ @retval EFI_SUCCESS The MrIndex is returned. -+ @retval EFI_INVALID_PARAMETER The MrIndex is NULL. -+ @retval EFI_UNSUPPORTED The PcrIndex is invalid. -+**/ -+typedef -+EFI_STATUS -+(EFIAPI *EFI_CC_MAP_PCR_TO_MR_INDEX)( -+ IN EFI_CC_MEASUREMENT_PROTOCOL *This, -+ IN TCG_PCRINDEX PcrIndex, -+ OUT EFI_CC_MR_INDEX *MrIndex -+ ); -+ -+struct _EFI_CC_MEASUREMENT_PROTOCOL { -+ EFI_CC_GET_CAPABILITY GetCapability; -+ EFI_CC_GET_EVENT_LOG GetEventLog; -+ EFI_CC_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; -+ EFI_CC_MAP_PCR_TO_MR_INDEX MapPcrToMrIndex; -+}; -+ -+// -+// CC event log -+// -+ -+#pragma pack(1) -+ -+// -+// Crypto Agile Log Entry Format. -+// It is similar with TCG_PCR_EVENT2 except the field of MrIndex and PCRIndex. -+// -+typedef struct { -+ EFI_CC_MR_INDEX MrIndex; -+ UINT32 EventType; -+ TPML_DIGEST_VALUES Digests; -+ UINT32 EventSize; -+ UINT8 Event[1]; -+} CC_EVENT; -+ -+// -+// EFI CC Event Header -+// It is similar with TCG_PCR_EVENT2_HDR except the field of MrIndex and PCRIndex -+// -+typedef struct { -+ EFI_CC_MR_INDEX MrIndex; -+ UINT32 EventType; -+ TPML_DIGEST_VALUES Digests; -+ UINT32 EventSize; -+} CC_EVENT_HDR; -+ -+#pragma pack() -+ -+// -+// Log entries after Get Event Log service -+// -+ -+#define EFI_CC_FINAL_EVENTS_TABLE_VERSION 1 -+ -+typedef struct { -+ // -+ // The version of this structure. It shall be set to 1. -+ // -+ UINT64 Version; -+ // -+ // Number of events recorded after invocation of GetEventLog API -+ // -+ UINT64 NumberOfEvents; -+ // -+ // List of events of type CC_EVENT. -+ // -+ // CC_EVENT Event[1]; -+} EFI_CC_FINAL_EVENTS_TABLE; -+ -+#define EFI_CC_FINAL_EVENTS_TABLE_GUID \ -+ {0xdd4a4648, 0x2de7, 0x4665, {0x96, 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4, 0x46}} -+ -+extern EFI_GUID gEfiCcFinalEventsTableGuid; -+ -+#endif -diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec -index 8b18415b10..6389a48338 100644 ---- a/MdePkg/MdePkg.dec -+++ b/MdePkg/MdePkg.dec -@@ -823,6 +823,9 @@ - # - gLinuxEfiInitrdMediaGuid = {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}} - -+ ## Include/Protocol/CcMeasurement.h -+ gEfiCcFinalEventsTableGuid = { 0xdd4a4648, 0x2de7, 0x4665, { 0x96, 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4, 0x46 }} -+ - [Guids.IA32, Guids.X64] - ## Include/Guid/Cper.h - gEfiIa32X64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, { 0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }} -@@ -1011,6 +1014,9 @@ - ## Include/Protocol/PcdInfo.h - gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf, 0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } } - -+ ## Include/Protocol/CcMeasurement.h -+ gEfiCcMeasurementProtocolGuid = { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b }} -+ - # - # Protocols defined in PI1.0. - # --- -2.41.0 - diff --git a/SOURCES/edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch b/SOURCES/edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch deleted file mode 100644 index a2bbc6e..0000000 --- a/SOURCES/edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 2a01056c29542a10941cb32929032b80df091a17 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:04:48 -0400 -Subject: [PATCH 19/31] MdePkg/Rng: Add GUID to describe Arm Rndr Rng - algorithms - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [19/31] 58b0f069c74b00eb6476427dd84a50a86aceb598 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit cf07238e5fa4f8b1138ac1c9e80530b4d4e59f1c -Author: Pierre Gondois -Date: Fri Aug 11 16:33:06 2023 +0200 - - MdePkg/Rng: Add GUID to describe Arm Rndr Rng algorithms - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4441 - - The EFI_RNG_PROTOCOL can rely on the RngLib. The RngLib has multiple - implementations, some of them are unsafe (e.g. BaseRngLibTimerLib). - To allow the RngDxe to detect when such implementation is used, - a GetRngGuid() function is added in a following patch. - - Prepare GetRngGuid() return values and add a gEfiRngAlgorithmArmRndr - to describe a Rng algorithm accessed through Arm's RNDR instruction. - [1] states that the implementation of this algorithm should be - compliant to NIST SP900-80. The compliance is not guaranteed. - - [1] Arm Architecture Reference Manual Armv8, for A-profile architecture - sK12.1 'Properties of the generated random number' - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Reviewed-by: Liming Gao - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - MdePkg/Include/Protocol/Rng.h | 10 ++++++++++ - MdePkg/MdePkg.dec | 1 + - 2 files changed, 11 insertions(+) - -diff --git a/MdePkg/Include/Protocol/Rng.h b/MdePkg/Include/Protocol/Rng.h -index baf425587b..38bde53240 100644 ---- a/MdePkg/Include/Protocol/Rng.h -+++ b/MdePkg/Include/Protocol/Rng.h -@@ -67,6 +67,15 @@ typedef EFI_GUID EFI_RNG_ALGORITHM; - { \ - 0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } \ - } -+/// -+/// The Arm Architecture states the RNDR that the DRBG algorithm should be compliant -+/// with NIST SP800-90A, while not mandating a particular algorithm, so as to be -+/// inclusive of different geographies. -+/// -+#define EFI_RNG_ALGORITHM_ARM_RNDR \ -+ { \ -+ 0x43d2fde3, 0x9d4e, 0x4d79, {0x02, 0x96, 0xa8, 0x9b, 0xca, 0x78, 0x08, 0x41} \ -+ } - - /** - Returns information about the random number generation implementation. -@@ -146,5 +155,6 @@ extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid; - extern EFI_GUID gEfiRngAlgorithmX9313DesGuid; - extern EFI_GUID gEfiRngAlgorithmX931AesGuid; - extern EFI_GUID gEfiRngAlgorithmRaw; -+extern EFI_GUID gEfiRngAlgorithmArmRndr; - - #endif -diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec -index 8f05e822ac..36501e8bb9 100644 ---- a/MdePkg/MdePkg.dec -+++ b/MdePkg/MdePkg.dec -@@ -594,6 +594,7 @@ - gEfiRngAlgorithmX9313DesGuid = { 0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46 }} - gEfiRngAlgorithmX931AesGuid = { 0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9 }} - gEfiRngAlgorithmRaw = { 0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 }} -+ gEfiRngAlgorithmArmRndr = { 0x43d2fde3, 0x9d4e, 0x4d79, {0x02, 0x96, 0xa8, 0x9b, 0xca, 0x78, 0x08, 0x41 }} - - ## Include/Protocol/AdapterInformation.h - gEfiAdapterInfoMediaStateGuid = { 0xD7C74207, 0xA831, 0x4A26, {0xB1, 0xF5, 0xD1, 0x93, 0x06, 0x5C, 0xE8, 0xB6 }} --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch b/SOURCES/edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch deleted file mode 100644 index 7369548..0000000 --- a/SOURCES/edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch +++ /dev/null @@ -1,409 +0,0 @@ -From b466e2545e25ebb2004ae9b9f95c6c2f60d1f168 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:08:28 -0400 -Subject: [PATCH 21/31] MdePkg/Rng: Add GetRngGuid() to RngLib - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [21/31] 54783ad88ba101c620240aa463c5d758fa416c31 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 5443c2dc310d2c8eb15fb8eefd5057342e78cd0d -Author: Pierre Gondois -Date: Fri Aug 11 16:33:08 2023 +0200 - - MdePkg/Rng: Add GetRngGuid() to RngLib - - The EFI_RNG_PROTOCOL can use the RngLib. The RngLib has multiple - implementations, some of them are unsafe (e.g. BaseRngLibTimerLib). - To allow the RngDxe to detect when such implementation is used, - add a GetRngGuid() function to the RngLib. - - Signed-off-by: Pierre Gondois - Reviewed-by: Liming Gao - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - .../BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 4 ++ - .../Library/BaseRngLibTimerLib/RngLibTimer.c | 28 +++++++++++++ - MdePkg/Include/Library/RngLib.h | 19 ++++++++- - MdePkg/Library/BaseRngLib/AArch64/Rndr.c | 42 +++++++++++++++++++ - MdePkg/Library/BaseRngLib/BaseRngLib.inf | 10 +++++ - MdePkg/Library/BaseRngLib/Rand/RdRand.c | 26 ++++++++++++ - .../Library/BaseRngLibNull/BaseRngLibNull.c | 22 ++++++++++ - .../Library/BaseRngLibTimerLib/RngLibTimer.c | 23 ++++++++++ - MdePkg/Library/DxeRngLib/DxeRngLib.c | 28 +++++++++++++ - 9 files changed, 201 insertions(+), 1 deletion(-) - -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -index f729001060..8461260cc8 100644 ---- a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -@@ -29,6 +29,10 @@ - - [Packages] - MdePkg/MdePkg.dec -+ MdeModulePkg/MdeModulePkg.dec -+ -+[Guids] -+ gEdkiiRngAlgorithmUnSafe - - [LibraryClasses] - BaseLib -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c b/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -index 980854d67b..28ff46c71f 100644 ---- a/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -@@ -2,14 +2,18 @@ - BaseRng Library that uses the TimerLib to provide reasonably random numbers. - Do not use this on a production system. - -+ Copyright (c) 2023, Arm Limited. All rights reserved. - Copyright (c) Microsoft Corporation. - SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - - #include -+#include - #include -+#include - #include - #include -+#include - - #define DEFAULT_DELAY_TIME_IN_MICROSECONDS 10 - -@@ -190,3 +194,27 @@ GetRandomNumber128 ( - // Read second 64 bits - return GetRandomNumber64 (++Rand); - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ if (RngGuid == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ CopyMem (RngGuid, &gEdkiiRngAlgorithmUnSafe, sizeof (*RngGuid)); -+ return EFI_SUCCESS; -+} -diff --git a/MdePkg/Include/Library/RngLib.h b/MdePkg/Include/Library/RngLib.h -index 05e513022e..801aa6d5bd 100644 ---- a/MdePkg/Include/Library/RngLib.h -+++ b/MdePkg/Include/Library/RngLib.h -@@ -1,6 +1,7 @@ - /** @file - Provides random number generator services. - -+Copyright (c) 2023, Arm Limited. All rights reserved.
- Copyright (c) 2015, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -77,4 +78,20 @@ GetRandomNumber128 ( - OUT UINT64 *Rand - ); - --#endif // __RNG_LIB_H__ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ); -+ -+#endif // __RNG_LIB_H__ -diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c -index c9f8c813ed..7641314a54 100644 ---- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c -+++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c -@@ -2,6 +2,7 @@ - Random number generator service that uses the RNDR instruction - to provide pseudorandom numbers. - -+ Copyright (c) 2023, Arm Limited. All rights reserved.
- Copyright (c) 2021, NUVIA Inc. All rights reserved.
- Copyright (c) 2015, Intel Corporation. All rights reserved.
- -@@ -11,6 +12,7 @@ - - #include - #include -+#include - #include - #include - -@@ -137,3 +139,43 @@ ArchIsRngSupported ( - { - return mRndrSupported; - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ GUID *RngLibGuid; -+ -+ if (RngGuid == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (!mRndrSupported) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ // -+ // If the platform advertises the algorithm behind RNDR instruction, -+ // use it. Otherwise use gEfiRngAlgorithmArmRndr. -+ // -+ RngLibGuid = PcdGetPtr (PcdCpuRngSupportedAlgorithm); -+ if (!IsZeroGuid (RngLibGuid)) { -+ CopyMem (RngGuid, RngLibGuid, sizeof (*RngGuid)); -+ } else { -+ CopyMem (RngGuid, &gEfiRngAlgorithmArmRndr, sizeof (*RngGuid)); -+ } -+ -+ return EFI_SUCCESS; -+} -diff --git a/MdePkg/Library/BaseRngLib/BaseRngLib.inf b/MdePkg/Library/BaseRngLib/BaseRngLib.inf -index 1fcceb9414..49503b139b 100644 ---- a/MdePkg/Library/BaseRngLib/BaseRngLib.inf -+++ b/MdePkg/Library/BaseRngLib/BaseRngLib.inf -@@ -4,6 +4,7 @@ - # BaseRng Library that uses CPU RNG instructions (e.g. RdRand) to - # provide random numbers. - # -+# Copyright (c) 2023, Arm Limited. All rights reserved.
- # Copyright (c) 2021, NUVIA Inc. All rights reserved.
- # Copyright (c) 2015, Intel Corporation. All rights reserved.
- # -@@ -43,9 +44,18 @@ - AArch64/ArmReadIdIsar0.asm | MSFT - AArch64/ArmRng.asm | MSFT - -+[Guids.AARCH64] -+ gEfiRngAlgorithmArmRndr -+ -+[Guids.Ia32, Guids.X64] -+ gEfiRngAlgorithmSp80090Ctr256Guid -+ - [Packages] - MdePkg/MdePkg.dec - -+[Pcd.AARCH64] -+ gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm -+ - [LibraryClasses] - BaseLib - DebugLib -diff --git a/MdePkg/Library/BaseRngLib/Rand/RdRand.c b/MdePkg/Library/BaseRngLib/Rand/RdRand.c -index 09fb875ac3..aee8ea04e8 100644 ---- a/MdePkg/Library/BaseRngLib/Rand/RdRand.c -+++ b/MdePkg/Library/BaseRngLib/Rand/RdRand.c -@@ -2,6 +2,7 @@ - Random number generator services that uses RdRand instruction access - to provide high-quality random numbers. - -+Copyright (c) 2023, Arm Limited. All rights reserved.
- Copyright (c) 2021, NUVIA Inc. All rights reserved.
- Copyright (c) 2015, Intel Corporation. All rights reserved.
- -@@ -11,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - #include - #include -+#include - #include - - #include "BaseRngLibInternals.h" -@@ -129,3 +131,27 @@ ArchIsRngSupported ( - */ - return TRUE; - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ if (RngGuid == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ CopyMem (RngGuid, &gEfiRngAlgorithmSp80090Ctr256Guid, sizeof (*RngGuid)); -+ return EFI_SUCCESS; -+} -diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c -index cad30599ea..34a18e6a4d 100644 ---- a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c -+++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c -@@ -1,13 +1,16 @@ - /** @file - Null version of Random number generator services. - -+Copyright (c) 2023, Arm Limited. All rights reserved.
- Copyright (c) 2019, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ - -+#include - #include - #include -+#include - - /** - Generates a 16-bit random number. -@@ -92,3 +95,22 @@ GetRandomNumber128 ( - ASSERT (FALSE); - return FALSE; - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ return EFI_UNSUPPORTED; -+} -diff --git a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -index 6b8392162b..7337500fec 100644 ---- a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -+++ b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c -@@ -209,3 +209,26 @@ GetRandomNumber128 ( - // Read second 64 bits - return GetRandomNumber64 (++Rand); - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+RETURN_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ /* This implementation is to be replaced by its MdeModulePkg copy. -+ * The cause being that some GUIDs (gEdkiiRngAlgorithmUnSafe) cannot -+ * be defined in the MdePkg. -+ */ -+ return RETURN_UNSUPPORTED; -+} -diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c -index 4b2fc1cde5..20248b4107 100644 ---- a/MdePkg/Library/DxeRngLib/DxeRngLib.c -+++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c -@@ -1,6 +1,7 @@ - /** @file - Provides an implementation of the library class RngLib that uses the Rng protocol. - -+ Copyright (c) 2023, Arm Limited. All rights reserved. - Copyright (c) Microsoft Corporation. All rights reserved. - SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -204,3 +205,30 @@ GetRandomNumber128 ( - } - return TRUE; - } -+ -+/** -+ Get a GUID identifying the RNG algorithm implementation. -+ -+ @param [out] RngGuid If success, contains the GUID identifying -+ the RNG algorithm implementation. -+ -+ @retval EFI_SUCCESS Success. -+ @retval EFI_UNSUPPORTED Not supported. -+ @retval EFI_INVALID_PARAMETER Invalid parameter. -+**/ -+EFI_STATUS -+EFIAPI -+GetRngGuid ( -+ GUID *RngGuid -+ ) -+{ -+ /* It is not possible to know beforehand which Rng algorithm will -+ * be used by this library. -+ * This API is mainly used by RngDxe. RngDxe relies on the RngLib. -+ * The RngLib|DxeRngLib.inf implementation locates and uses an installed -+ * EFI_RNG_PROTOCOL. -+ * It is thus not possible to have both RngDxe and RngLib|DxeRngLib.inf. -+ * and it is ok not to support this API. -+ */ -+ return EFI_UNSUPPORTED; -+} --- -2.39.3 - diff --git a/SOURCES/edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch b/SOURCES/edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch deleted file mode 100644 index fffb448..0000000 --- a/SOURCES/edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 634ee7a8cef2eac9f41cff4b42859d9d54b204bf Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 10:35:27 -0400 -Subject: [PATCH 29/31] MdePkg/X86UnitTestHost: set rdrand cpuid bit - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [29/31] 60851c6253df6f0114dc2c5598e0dde139d56c4c - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 5e776299a2604b336a947e68593012ab2cc16eb4 -Author: Gerd Hoffmann -Date: Fri Jun 14 11:45:53 2024 +0200 - - MdePkg/X86UnitTestHost: set rdrand cpuid bit - - Set the rdrand feature bit when faking cpuid for host test cases. - Needed to make the CryptoPkg test cases work. - - Signed-off-by: Gerd Hoffmann - -Signed-off-by: Jon Maloy ---- - MdePkg/Library/BaseLib/X86UnitTestHost.c | 11 ++++++++++- - 1 file changed, 10 insertions(+), 1 deletion(-) - -diff --git a/MdePkg/Library/BaseLib/X86UnitTestHost.c b/MdePkg/Library/BaseLib/X86UnitTestHost.c -index d0e428457e..abc092a990 100644 ---- a/MdePkg/Library/BaseLib/X86UnitTestHost.c -+++ b/MdePkg/Library/BaseLib/X86UnitTestHost.c -@@ -66,6 +66,15 @@ UnitTestHostBaseLibAsmCpuid ( - OUT UINT32 *Edx OPTIONAL - ) - { -+ UINT32 RetEcx; -+ -+ RetEcx = 0; -+ switch (Index) { -+ case 1: -+ RetEcx |= BIT30; /* RdRand */ -+ break; -+ } -+ - if (Eax != NULL) { - *Eax = 0; - } -@@ -73,7 +82,7 @@ UnitTestHostBaseLibAsmCpuid ( - *Ebx = 0; - } - if (Ecx != NULL) { -- *Ecx = 0; -+ *Ecx = RetEcx; - } - if (Edx != NULL) { - *Edx = 0; --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Add-Unit-tests-to-CI-and-create-Host-Test.patch b/SOURCES/edk2-NetworkPkg-Add-Unit-tests-to-CI-and-create-Host-Test.patch deleted file mode 100644 index b984c70..0000000 --- a/SOURCES/edk2-NetworkPkg-Add-Unit-tests-to-CI-and-create-Host-Test.patch +++ /dev/null @@ -1,169 +0,0 @@ -From aa66757951e9880df4e21e191142400480aa3908 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 8 Feb 2024 10:35:14 -0500 -Subject: [PATCH 15/17] NetworkPkg: : Add Unit tests to CI and create Host Test - DSC - -RH-Author: Jon Maloy -RH-MergeRequest: 50: CVE-2023-45230 and CVE-2023-45229 -RH-Jira: RHEL-21840 RHEL-21842 -RH-Acked-by: Oliver Steffen -RH-Commit: [2/4] 6669306e2dbb5aa3e7691d57f4a61685b7cd57b2 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21842 -CVE: CVE-2023-45230 -Upstream: Merged - -commit 8014ac2d7bbbc503f5562b51af46bb20ae3d22ff -Author: Doug Flick via groups.io -Date: Fri Jan 26 05:54:44 2024 +0800 - - NetworkPkg: : Add Unit tests to CI and create Host Test DSC - - Adds Host Based testing to the NetworkPkg - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/NetworkPkg.ci.yaml | 7 +- - NetworkPkg/Test/NetworkPkgHostTest.dsc | 98 ++++++++++++++++++++++++++ - 2 files changed, 104 insertions(+), 1 deletion(-) - create mode 100644 NetworkPkg/Test/NetworkPkgHostTest.dsc - -diff --git a/NetworkPkg/NetworkPkg.ci.yaml b/NetworkPkg/NetworkPkg.ci.yaml -index 07dc7abd69..076424eb60 100644 ---- a/NetworkPkg/NetworkPkg.ci.yaml -+++ b/NetworkPkg/NetworkPkg.ci.yaml -@@ -24,6 +24,9 @@ - "CompilerPlugin": { - "DscPath": "NetworkPkg.dsc" - }, -+ "HostUnitTestCompilerPlugin": { -+ "DscPath": "Test/NetworkPkgHostTest.dsc" -+ }, - "CharEncodingCheck": { - "IgnoreFiles": [] - }, -@@ -35,7 +38,9 @@ - "CryptoPkg/CryptoPkg.dec" - ], - # For host based unit tests -- "AcceptableDependencies-HOST_APPLICATION":[], -+ "AcceptableDependencies-HOST_APPLICATION":[ -+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec -+ ], - # For UEFI shell based apps - "AcceptableDependencies-UEFI_APPLICATION":[ - "ShellPkg/ShellPkg.dec" -diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/NetworkPkgHostTest.dsc -new file mode 100644 -index 0000000000..1aeca5c5b3 ---- /dev/null -+++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc -@@ -0,0 +1,98 @@ -+## @file -+# NetworkPkgHostTest DSC file used to build host-based unit tests. -+# -+# Copyright (c) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+## -+[Defines] -+ PLATFORM_NAME = NetworkPkgHostTest -+ PLATFORM_GUID = 3b68324e-fc07-4d49-9520-9347ede65879 -+ PLATFORM_VERSION = 0.1 -+ DSC_SPECIFICATION = 0x00010005 -+ OUTPUT_DIRECTORY = Build/NetworkPkg/HostTest -+ SUPPORTED_ARCHITECTURES = IA32|X64|AARCH64 -+ BUILD_TARGETS = NOOPT -+ SKUID_IDENTIFIER = DEFAULT -+ -+!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc -+[Packages] -+ MdePkg/MdePkg.dec -+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec -+ -+[Components] -+ # -+ # Build HOST_APPLICATION that tests NetworkPkg -+ # -+ -+# Despite these library classes being listed in [LibraryClasses] below, they are not needed for the host-based unit tests. -+[LibraryClasses] -+ NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf -+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf -+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf -+ BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf -+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf -+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf -+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf -+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf -+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf -+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf -+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf -+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf -+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf -+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf -+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf -+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf -+ TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf -+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf -+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf -+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf -+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf -+ SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf -+ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf -+ VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf -+!ifdef CONTINUOUS_INTEGRATION -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf -+ TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf -+!else -+ BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf -+ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf -+ TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf -+!endif -+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf -+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf -+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf -+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf -+ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf -+ -+!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022 -+[LibraryClasses.X64] -+ # Provide StackCookie support lib so that we can link to /GS exports for VS builds -+ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf -+!endif -+ -+[LibraryClasses.common.UEFI_DRIVER] -+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf -+ DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf -+[LibraryClasses.common.UEFI_APPLICATION] -+ DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf -+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf -+[LibraryClasses.ARM, LibraryClasses.AARCH64] -+ # -+ # It is not possible to prevent ARM compiler calls to generic intrinsic functions. -+ # This library provides the instrinsic functions generated by a given compiler. -+ # [LibraryClasses.ARM] and NULL mean link this library into all ARM images. -+ # -+!if $(TOOL_CHAIN_TAG) != VS2017 and $(TOOL_CHAIN_TAG) != VS2015 and $(TOOL_CHAIN_TAG) != VS2019 -+ NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf -+!endif -+ NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf -+[LibraryClasses.ARM] -+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+[LibraryClasses.RISCV64] -+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+ -+[PcdsFixedAtBuild] -+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2 -+ gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType|0x4 --- -2.41.0 - diff --git a/SOURCES/edk2-NetworkPkg-Adds-a-SecurityFix.yaml-file.patch b/SOURCES/edk2-NetworkPkg-Adds-a-SecurityFix.yaml-file.patch deleted file mode 100644 index 2c0ae8b..0000000 --- a/SOURCES/edk2-NetworkPkg-Adds-a-SecurityFix.yaml-file.patch +++ /dev/null @@ -1,170 +0,0 @@ -From ffa1202da2f55c1f540240e8267db9a7ec8d6a60 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 11/15] NetworkPkg: : Adds a SecurityFix.yaml file - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [11/15] 8a46b763887843d00293997bdd7d50ea120104d9 - -JIRA: https://issues.redhat.com/browse/RHEL-21852 -CVE: CVE-2022-45235 -Upstream: Merged - -commit 1d0b95f6457d225c5108302a9da74b4ed7aa5a38 -Author: Doug Flick via groups.io -Date: Fri Jan 26 05:54:57 2024 +0800 - - NetworkPkg: : Adds a SecurityFix.yaml file - - This creates / adds a security file that tracks the security fixes - found in this package and can be used to find the fixes that were - applied. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/SecurityFixes.yaml | 123 ++++++++++++++++++++++++++++++++++ - 1 file changed, 123 insertions(+) - create mode 100644 NetworkPkg/SecurityFixes.yaml - -diff --git a/NetworkPkg/SecurityFixes.yaml b/NetworkPkg/SecurityFixes.yaml -new file mode 100644 -index 0000000000..7e900483fe ---- /dev/null -+++ b/NetworkPkg/SecurityFixes.yaml -@@ -0,0 +1,123 @@ -+## @file -+# Security Fixes for SecurityPkg -+# -+# Copyright (c) Microsoft Corporation -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+CVE_2023_45229: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Unit Tests" -+ cve: CVE-2023-45229 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 01 - edk2/NetworkPkg: Out-of-bounds read when processing IA_NA/IA_TA options in a DHCPv6 Advertise message" -+ note: -+ files_impacted: -+ - NetworkPkg\Dhcp6Dxe\Dhcp6Io.c -+ - NetworkPkg\Dhcp6Dxe\Dhcp6Impl.h -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4534 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45229 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45230: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Unit Tests" -+ cve: CVE-2023-45230 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 02 - edk2/NetworkPkg: Buffer overflow in the DHCPv6 client via a long Server ID option" -+ note: -+ files_impacted: -+ - NetworkPkg\Dhcp6Dxe\Dhcp6Io.c -+ - NetworkPkg\Dhcp6Dxe\Dhcp6Impl.h -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4535 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45230 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45231: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45231 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45231 Unit Tests" -+ cve: CVE-2023-45231 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 03 - edk2/NetworkPkg: Out-of-bounds read when handling a ND Redirect message with truncated options" -+ note: -+ files_impacted: -+ - NetworkPkg/Ip6Dxe/Ip6Option.c -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4536 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45231 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45232: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45232 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45232 Unit Tests" -+ cve: CVE-2023-45232 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 04 - edk2/NetworkPkg: Infinite loop when parsing unknown options in the Destination Options header" -+ note: -+ files_impacted: -+ - NetworkPkg/Ip6Dxe/Ip6Option.c -+ - NetworkPkg/Ip6Dxe/Ip6Option.h -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4537 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45232 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45233: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45232 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45232 Unit Tests" -+ cve: CVE-2023-45233 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 05 - edk2/NetworkPkg: Infinite loop when parsing a PadN option in the Destination Options header " -+ note: This was fixed along with CVE-2023-45233 -+ files_impacted: -+ - NetworkPkg/Ip6Dxe/Ip6Option.c -+ - NetworkPkg/Ip6Dxe/Ip6Option.h -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4538 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45233 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45234: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45234 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45234 Unit Tests" -+ cve: CVE-2023-45234 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 06 - edk2/NetworkPkg: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message" -+ note: -+ files_impacted: -+ - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4539 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45234 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html -+CVE_2023_45235: -+ commit_titles: -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45235 Patch" -+ - "NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45235 Unit Tests" -+ cve: CVE-2023-45235 -+ date_reported: 2023-08-28 13:56 UTC -+ description: "Bug 07 - edk2/NetworkPkg: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message" -+ note: -+ files_impacted: -+ - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+ - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4540 -+ - https://nvd.nist.gov/vuln/detail/CVE-2023-45235 -+ - http://www.openwall.com/lists/oss-security/2024/01/16/2 -+ - http://packetstormsecurity.com/files/176574/PixieFail-Proof-Of-Concepts.html -+ - https://blog.quarkslab.com/pixiefail-nine-vulnerabilities-in-tianocores-edk-ii-ipv6-network-stack.html --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes-p2.patch b/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes-p2.patch deleted file mode 100644 index d51d127..0000000 --- a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes-p2.patch +++ /dev/null @@ -1,2054 +0,0 @@ -From f7e6d9e61173d76ab9827e1af62dc9966a21e14c Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 17:28:51 -0500 -Subject: [PATCH 12/15] NetworkPkg: Apply uncrustify changes - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [12/15] 880596c246c87181f19fcb0a7a21f4e32d234c13 - -JIRA: https://issues.redhat.com/browse/RHEL-21840 -CVE: CVE-2022-45229 -Upstream: Merged -Conflicts: There has already been added two commits after the point where - this commit was added upstream, so we cannot apply that commit, - or even parts of it, directly. Instead, we only introduce the - whitespace changes needed to make future commits touching - the file NetworkPkg/Dhcp6Dxe/Dhcp6Io.c apply cleanly. - -commit d1050b9dff1cace252aff86630bfdb59dff5f507 -Author: Michael Kubacki -Date: Sun Dec 5 14:54:07 2021 -0800 - - NetworkPkg: Apply uncrustify changes - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 - - Apply uncrustify changes to .c/.h files in the NetworkPkg package - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael D Kinney - Signed-off-by: Michael Kubacki - Reviewed-by: Maciej Rabeda - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Io.c | 1091 ++++++++++++++++----------------- - 1 file changed, 529 insertions(+), 562 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -index d680febbf1..3b8feb4a20 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -@@ -10,7 +10,6 @@ - - #include "Dhcp6Impl.h" - -- - /** - Enqueue the packet into the retry list in case of timeout. - -@@ -34,8 +33,8 @@ Dhcp6EnqueueRetry ( - IN EFI_DHCP6_RETRANSMISSION *RetryCtl OPTIONAL - ) - { -- DHCP6_TX_CB *TxCb; -- DHCP6_IA_CB *IaCb; -+ DHCP6_TX_CB *TxCb; -+ DHCP6_IA_CB *IaCb; - - ASSERT (Packet != NULL); - -@@ -55,156 +54,156 @@ Dhcp6EnqueueRetry ( - // - // Save pointer to elapsed-time value so we can update it on retransmits. - // -- TxCb->Elapsed = Elapsed; -+ TxCb->Elapsed = Elapsed; - - // - // Calculate the retransmission according to the message type. - // - switch (Packet->Dhcp6.Header.MessageType) { -- case Dhcp6MsgSolicit: -- // -- // Calculate the retransmission threshold value for solicit packet. -- // Use the default value by rfc-3315 if user doesn't configure. -- // -- if (RetryCtl == NULL) { -- TxCb->RetryCtl.Irt = DHCP6_SOL_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_SOL_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_SOL_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_SOL_MRD; -- } else { -- TxCb->RetryCtl.Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_SOL_IRT; -- TxCb->RetryCtl.Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_SOL_MRC; -- TxCb->RetryCtl.Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_SOL_MRT; -- TxCb->RetryCtl.Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_SOL_MRD; -- } -+ case Dhcp6MsgSolicit: -+ // -+ // Calculate the retransmission threshold value for solicit packet. -+ // Use the default value by rfc-3315 if user doesn't configure. -+ // -+ if (RetryCtl == NULL) { -+ TxCb->RetryCtl.Irt = DHCP6_SOL_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_SOL_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_SOL_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_SOL_MRD; -+ } else { -+ TxCb->RetryCtl.Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_SOL_IRT; -+ TxCb->RetryCtl.Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_SOL_MRC; -+ TxCb->RetryCtl.Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_SOL_MRT; -+ TxCb->RetryCtl.Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_SOL_MRD; -+ } -+ -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ FALSE -+ ); -+ break; - -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ case Dhcp6MsgRequest: -+ // -+ // Calculate the retransmission threshold value for request packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_REQ_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_REQ_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_REQ_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_REQ_MRD; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( - TxCb->RetryCtl.Irt, - TRUE, -- FALSE -+ TRUE - ); -- break; -- -- case Dhcp6MsgRequest: -- // -- // Calculate the retransmission threshold value for request packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_REQ_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_REQ_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_REQ_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_REQ_MRD; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -- -- case Dhcp6MsgConfirm: -- // -- // Calculate the retransmission threshold value for confirm packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_CNF_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_CNF_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_CNF_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_CNF_MRD; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -- -- case Dhcp6MsgRenew: -- // -- // Calculate the retransmission threshold value for renew packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_REB_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_REB_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_REB_MRT; -- TxCb->RetryCtl.Mrd = IaCb->T2 - IaCb->T1; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -+ break; - -- case Dhcp6MsgRebind: -- // -- // Calculate the retransmission threshold value for rebind packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_REN_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_REN_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_REN_MRT; -- TxCb->RetryCtl.Mrd = IaCb->AllExpireTime - IaCb->T2; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -+ case Dhcp6MsgConfirm: -+ // -+ // Calculate the retransmission threshold value for confirm packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_CNF_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_CNF_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_CNF_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_CNF_MRD; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ TRUE -+ ); -+ break; - -- case Dhcp6MsgDecline: -- // -- // Calculate the retransmission threshold value for decline packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_DEC_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_DEC_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_DEC_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_DEC_MRD; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -+ case Dhcp6MsgRenew: -+ // -+ // Calculate the retransmission threshold value for renew packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_REB_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_REB_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_REB_MRT; -+ TxCb->RetryCtl.Mrd = IaCb->T2 - IaCb->T1; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ TRUE -+ ); -+ break; - -- case Dhcp6MsgRelease: -- // -- // Calculate the retransmission threshold value for release packet. -- // -- TxCb->RetryCtl.Irt = DHCP6_REL_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_REL_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_REL_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_REL_MRD; -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -- TxCb->RetryCtl.Irt, -- TRUE, -- TRUE -- ); -- break; -+ case Dhcp6MsgRebind: -+ // -+ // Calculate the retransmission threshold value for rebind packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_REN_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_REN_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_REN_MRT; -+ TxCb->RetryCtl.Mrd = IaCb->AllExpireTime - IaCb->T2; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ TRUE -+ ); -+ break; - -- case Dhcp6MsgInfoRequest: -- // -- // Calculate the retransmission threshold value for info-request packet. -- // Use the default value by rfc-3315 if user doesn't configure. -- // -- if (RetryCtl == NULL) { -- TxCb->RetryCtl.Irt = DHCP6_INF_IRT; -- TxCb->RetryCtl.Mrc = DHCP6_INF_MRC; -- TxCb->RetryCtl.Mrt = DHCP6_INF_MRT; -- TxCb->RetryCtl.Mrd = DHCP6_INF_MRD; -- } else { -- TxCb->RetryCtl.Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_INF_IRT; -- TxCb->RetryCtl.Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_INF_MRC; -- TxCb->RetryCtl.Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_INF_MRT; -- TxCb->RetryCtl.Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_INF_MRD; -- } -+ case Dhcp6MsgDecline: -+ // -+ // Calculate the retransmission threshold value for decline packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_DEC_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_DEC_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_DEC_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_DEC_MRD; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ TRUE -+ ); -+ break; - -- TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ case Dhcp6MsgRelease: -+ // -+ // Calculate the retransmission threshold value for release packet. -+ // -+ TxCb->RetryCtl.Irt = DHCP6_REL_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_REL_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_REL_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_REL_MRD; -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( - TxCb->RetryCtl.Irt, - TRUE, - TRUE - ); -- break; -+ break; - -- default: -- // -- // Unexpected message type. -- // -- FreePool(TxCb); -- return EFI_DEVICE_ERROR; -+ case Dhcp6MsgInfoRequest: -+ // -+ // Calculate the retransmission threshold value for info-request packet. -+ // Use the default value by rfc-3315 if user doesn't configure. -+ // -+ if (RetryCtl == NULL) { -+ TxCb->RetryCtl.Irt = DHCP6_INF_IRT; -+ TxCb->RetryCtl.Mrc = DHCP6_INF_MRC; -+ TxCb->RetryCtl.Mrt = DHCP6_INF_MRT; -+ TxCb->RetryCtl.Mrd = DHCP6_INF_MRD; -+ } else { -+ TxCb->RetryCtl.Irt = (RetryCtl->Irt != 0) ? RetryCtl->Irt : DHCP6_INF_IRT; -+ TxCb->RetryCtl.Mrc = (RetryCtl->Mrc != 0) ? RetryCtl->Mrc : DHCP6_INF_MRC; -+ TxCb->RetryCtl.Mrt = (RetryCtl->Mrt != 0) ? RetryCtl->Mrt : DHCP6_INF_MRT; -+ TxCb->RetryCtl.Mrd = (RetryCtl->Mrd != 0) ? RetryCtl->Mrd : DHCP6_INF_MRD; -+ } -+ -+ TxCb->RetryExp = Dhcp6CalculateExpireTime ( -+ TxCb->RetryCtl.Irt, -+ TRUE, -+ TRUE -+ ); -+ break; -+ -+ default: -+ // -+ // Unexpected message type. -+ // -+ FreePool (TxCb); -+ return EFI_DEVICE_ERROR; - } - - // -@@ -215,7 +214,6 @@ Dhcp6EnqueueRetry ( - return EFI_SUCCESS; - } - -- - /** - Dequeue the packet from retry list if reply received or timeout at last. - -@@ -230,40 +228,36 @@ Dhcp6EnqueueRetry ( - **/ - EFI_STATUS - Dhcp6DequeueRetry ( -- IN DHCP6_INSTANCE *Instance, -- IN UINT32 PacketXid, -- IN BOOLEAN NeedSignal -+ IN DHCP6_INSTANCE *Instance, -+ IN UINT32 PacketXid, -+ IN BOOLEAN NeedSignal - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *NextEntry; -- DHCP6_TX_CB *TxCb; -- DHCP6_INF_CB *InfCb; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *NextEntry; -+ DHCP6_TX_CB *TxCb; -+ DHCP6_INF_CB *InfCb; - - // - // Seek the retransmit node in the retransmit list by packet xid. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { -- - TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); -- ASSERT(TxCb->TxPacket); -+ ASSERT (TxCb->TxPacket); - - if (TxCb->Xid == PacketXid) { -- - if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { -- - // - // Seek the info-request node in the info-request list by packet xid. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) { -- - InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link); - - if (InfCb->Xid == PacketXid) { - // - // Remove the info-request node, and signal the event if timeout. - // -- if (InfCb->TimeoutEvent != NULL && NeedSignal) { -+ if ((InfCb->TimeoutEvent != NULL) && NeedSignal) { - gBS->SignalEvent (InfCb->TimeoutEvent); - } - -@@ -272,11 +266,12 @@ Dhcp6DequeueRetry ( - } - } - } -+ - // - // Remove the retransmit node. - // - RemoveEntryList (&TxCb->Link); -- ASSERT(TxCb->TxPacket); -+ ASSERT (TxCb->TxPacket); - FreePool (TxCb->TxPacket); - FreePool (TxCb); - return EFI_SUCCESS; -@@ -286,7 +281,6 @@ Dhcp6DequeueRetry ( - return EFI_NOT_FOUND; - } - -- - /** - Clean up the specific nodes in the retry list. - -@@ -296,24 +290,22 @@ Dhcp6DequeueRetry ( - **/ - VOID - Dhcp6CleanupRetry ( -- IN DHCP6_INSTANCE *Instance, -- IN UINT32 Scope -+ IN DHCP6_INSTANCE *Instance, -+ IN UINT32 Scope - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *NextEntry; -- DHCP6_TX_CB *TxCb; -- DHCP6_INF_CB *InfCb; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *NextEntry; -+ DHCP6_TX_CB *TxCb; -+ DHCP6_INF_CB *InfCb; - - // - // Clean up all the stateful messages from the retransmit list. - // -- if (Scope == DHCP6_PACKET_STATEFUL || Scope == DHCP6_PACKET_ALL) { -- -+ if ((Scope == DHCP6_PACKET_STATEFUL) || (Scope == DHCP6_PACKET_ALL)) { - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { -- - TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); -- ASSERT(TxCb->TxPacket); -+ ASSERT (TxCb->TxPacket); - - if (TxCb->TxPacket->Dhcp6.Header.MessageType != Dhcp6MsgInfoRequest) { - RemoveEntryList (&TxCb->Link); -@@ -326,15 +318,13 @@ Dhcp6CleanupRetry ( - // - // Clean up all the stateless messages from the retransmit list. - // -- if (Scope == DHCP6_PACKET_STATELESS || Scope == DHCP6_PACKET_ALL) { -- -+ if ((Scope == DHCP6_PACKET_STATELESS) || (Scope == DHCP6_PACKET_ALL)) { - // - // Clean up all the retransmit list for stateless messages. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { -- - TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); -- ASSERT(TxCb->TxPacket); -+ ASSERT (TxCb->TxPacket); - - if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { - RemoveEntryList (&TxCb->Link); -@@ -347,12 +337,12 @@ Dhcp6CleanupRetry ( - // Clean up all the info-request messages list. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->InfList) { -- - InfCb = NET_LIST_USER_STRUCT (Entry, DHCP6_INF_CB, Link); - - if (InfCb->TimeoutEvent != NULL) { - gBS->SignalEvent (InfCb->TimeoutEvent); - } -+ - RemoveEntryList (&InfCb->Link); - FreePool (InfCb); - } -@@ -371,11 +361,11 @@ Dhcp6CleanupRetry ( - **/ - BOOLEAN - Dhcp6IsValidTxCb ( -- IN DHCP6_INSTANCE *Instance, -- IN DHCP6_TX_CB *TxCb -+ IN DHCP6_INSTANCE *Instance, -+ IN DHCP6_TX_CB *TxCb - ) - { -- LIST_ENTRY *Entry; -+ LIST_ENTRY *Entry; - - NET_LIST_FOR_EACH (Entry, &Instance->TxList) { - if (TxCb == NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link)) { -@@ -395,15 +385,15 @@ Dhcp6IsValidTxCb ( - **/ - VOID - Dhcp6CleanupSession ( -- IN OUT DHCP6_INSTANCE *Instance, -- IN EFI_STATUS Status -+ IN OUT DHCP6_INSTANCE *Instance, -+ IN EFI_STATUS Status - ) - { -- UINTN Index; -- EFI_DHCP6_IA *Ia; -+ UINTN Index; -+ EFI_DHCP6_IA *Ia; - -- ASSERT(Instance->Config); -- ASSERT(Instance->IaCb.Ia); -+ ASSERT (Instance->Config); -+ ASSERT (Instance->IaCb.Ia); - - // - // Clean up the retransmit list for stateful messages. -@@ -425,23 +415,23 @@ Dhcp6CleanupSession ( - // - // Reinitialize the Ia fields of the instance. - // -- Instance->UdpSts = Status; -- Instance->AdSelect = NULL; -- Instance->AdPref = 0; -- Instance->Unicast = NULL; -- Instance->IaCb.T1 = 0; -- Instance->IaCb.T2 = 0; -- Instance->IaCb.AllExpireTime = 0; -- Instance->IaCb.LeaseTime = 0; -+ Instance->UdpSts = Status; -+ Instance->AdSelect = NULL; -+ Instance->AdPref = 0; -+ Instance->Unicast = NULL; -+ Instance->IaCb.T1 = 0; -+ Instance->IaCb.T2 = 0; -+ Instance->IaCb.AllExpireTime = 0; -+ Instance->IaCb.LeaseTime = 0; - - // - // Clear start time - // -- Instance->StartTime = 0; -+ Instance->StartTime = 0; - -- Ia = Instance->IaCb.Ia; -- Ia->State = Dhcp6Init; -- Ia->ReplyPacket = NULL; -+ Ia = Instance->IaCb.Ia; -+ Ia->State = Dhcp6Init; -+ Ia->ReplyPacket = NULL; - - // - // Set the addresses as zero lifetime, and then the notify -@@ -461,7 +451,6 @@ Dhcp6CleanupSession ( - } - } - -- - /** - Callback to user when Dhcp6 transmit/receive occurs. - -@@ -477,15 +466,15 @@ Dhcp6CleanupSession ( - EFI_STATUS - EFIAPI - Dhcp6CallbackUser ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_EVENT Event, -- IN OUT EFI_DHCP6_PACKET **Packet -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_EVENT Event, -+ IN OUT EFI_DHCP6_PACKET **Packet - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *NewPacket; -- EFI_DHCP6_CALLBACK Callback; -- VOID *Context; -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *NewPacket; -+ EFI_DHCP6_CALLBACK Callback; -+ VOID *Context; - - ASSERT (Packet != NULL); - ASSERT (Instance->Config != NULL); -@@ -500,7 +489,6 @@ Dhcp6CallbackUser ( - // Callback to user with the new message if has. - // - if (Callback != NULL) { -- - Status = Callback ( - &Instance->Dhcp6, - Context, -@@ -522,7 +510,6 @@ Dhcp6CallbackUser ( - return Status; - } - -- - /** - Update Ia according to the new reply message. - -@@ -535,17 +522,17 @@ Dhcp6CallbackUser ( - **/ - EFI_STATUS - Dhcp6UpdateIaInfo ( -- IN OUT DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet -+ IN OUT DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- UINT8 *Option; -- UINT8 *IaInnerOpt; -- UINT16 IaInnerLen; -- UINT16 StsCode; -- UINT32 T1; -- UINT32 T2; -+ EFI_STATUS Status; -+ UINT8 *Option; -+ UINT8 *IaInnerOpt; -+ UINT16 IaInnerLen; -+ UINT16 StsCode; -+ UINT32 T1; -+ UINT32 T2; - - ASSERT (Instance->Config != NULL); - // -@@ -618,9 +605,10 @@ Dhcp6UpdateIaInfo ( - // and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes - // the remainder of the message as though the server had not included the invalid IA_NA option. - // -- if (T1 > T2 && T2 > 0) { -+ if ((T1 > T2) && (T2 > 0)) { - return EFI_DEVICE_ERROR; - } -+ - IaInnerOpt = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option); - IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))) - DHCP6_SIZE_OF_COMBINED_IAID_T1_T2); - } else { -@@ -674,8 +662,6 @@ Dhcp6UpdateIaInfo ( - return Status; - } - -- -- - /** - Seeks the Inner Options from a DHCP6 Option - -@@ -772,9 +758,9 @@ Dhcp6SeekInnerOptionSafe ( - **/ - EFI_STATUS - Dhcp6SeekStsOption ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet, -- OUT UINT8 **Option -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet, -+ OUT UINT8 **Option - ) - { - UINT8 *IaInnerOpt; -@@ -830,7 +816,7 @@ Dhcp6SeekStsOption ( - // IA option to the end of the DHCP6 option area, thus subtract the space - // up until this option - // -- OptionLen = OptionLen - (*Option - Packet->Dhcp6.Option); -+ OptionLen = OptionLen - (UINT32)(*Option - Packet->Dhcp6.Option); - - // - // Seek the inner option -@@ -867,7 +853,7 @@ Dhcp6SeekStsOption ( - // - // sizeof (option-code + option-len) = 4 - // -- *Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); -+ *Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); - if (*Option != NULL) { - StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (*Option))))); - if (StsCode != Dhcp6StsSuccess) { -@@ -878,7 +864,6 @@ Dhcp6SeekStsOption ( - return EFI_SUCCESS; - } - -- - /** - Transmit Dhcp6 message by udpio. - -@@ -893,23 +878,23 @@ Dhcp6SeekStsOption ( - **/ - EFI_STATUS - Dhcp6TransmitPacket ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet, -- IN UINT16 *Elapsed -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet, -+ IN UINT16 *Elapsed - ) - { -- EFI_STATUS Status; -- NET_BUF *Wrap; -- NET_FRAGMENT Frag; -- UDP_END_POINT EndPt; -- DHCP6_SERVICE *Service; -+ EFI_STATUS Status; -+ NET_BUF *Wrap; -+ NET_FRAGMENT Frag; -+ UDP_END_POINT EndPt; -+ DHCP6_SERVICE *Service; - - Service = Instance->Service; - - // - // Wrap it into a netbuf then send it. - // -- Frag.Bulk = (UINT8 *) &Packet->Dhcp6.Header; -+ Frag.Bulk = (UINT8 *)&Packet->Dhcp6.Header; - Frag.Len = Packet->Length; - - // -@@ -970,7 +955,6 @@ Dhcp6TransmitPacket ( - return EFI_SUCCESS; - } - -- - /** - Create the solicit message and send it. - -@@ -983,19 +967,19 @@ Dhcp6TransmitPacket ( - **/ - EFI_STATUS - Dhcp6SendSolicitMsg ( -- IN DHCP6_INSTANCE *Instance -+ IN DHCP6_INSTANCE *Instance - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET_OPTION *UserOpt; -- EFI_DHCP6_DUID *ClientId; -- DHCP6_SERVICE *Service; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT32 UserLen; -- UINTN Index; -- UINT16 Length; -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET_OPTION *UserOpt; -+ EFI_DHCP6_DUID *ClientId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT32 UserLen; -+ UINTN Index; -+ UINT16 Length; - - Service = Instance->Service; - ClientId = Service->ClientId; -@@ -1069,7 +1053,6 @@ Dhcp6SendSolicitMsg ( - // Append user-defined when configurate Dhcp6 service. - // - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { -- - UserOpt = Instance->Config->OptionList[Index]; - Status = Dhcp6AppendOption ( - Packet, -@@ -1139,17 +1122,16 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6InitSolicitMsg ( -- IN DHCP6_INSTANCE *Instance -+ IN DHCP6_INSTANCE *Instance - ) - { -- Instance->IaCb.T1 = 0; -- Instance->IaCb.T2 = 0; -+ Instance->IaCb.T1 = 0; -+ Instance->IaCb.T2 = 0; - Instance->IaCb.Ia->IaAddressCount = 0; - - return Dhcp6SendSolicitMsg (Instance); - } - -- - /** - Create the request message and send it. - -@@ -1163,31 +1145,31 @@ Dhcp6InitSolicitMsg ( - **/ - EFI_STATUS - Dhcp6SendRequestMsg ( -- IN DHCP6_INSTANCE *Instance -+ IN DHCP6_INSTANCE *Instance - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET_OPTION *UserOpt; -- EFI_DHCP6_DUID *ClientId; -- EFI_DHCP6_DUID *ServerId; -- DHCP6_SERVICE *Service; -- UINT8 *Option; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT32 UserLen; -- UINTN Index; -- UINT16 Length; -- -- ASSERT(Instance->AdSelect != NULL); -- ASSERT(Instance->Config != NULL); -- ASSERT(Instance->IaCb.Ia != NULL); -- ASSERT(Instance->Service != NULL); -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET_OPTION *UserOpt; -+ EFI_DHCP6_DUID *ClientId; -+ EFI_DHCP6_DUID *ServerId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Option; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT32 UserLen; -+ UINTN Index; -+ UINT16 Length; -+ -+ ASSERT (Instance->AdSelect != NULL); -+ ASSERT (Instance->Config != NULL); -+ ASSERT (Instance->IaCb.Ia != NULL); -+ ASSERT (Instance->Service != NULL); - - Service = Instance->Service; - ClientId = Service->ClientId; - -- ASSERT(ClientId != NULL); -+ ASSERT (ClientId != NULL); - - // - // Get the server Id from the selected advertisement message. -@@ -1201,7 +1183,7 @@ Dhcp6SendRequestMsg ( - return EFI_DEVICE_ERROR; - } - -- ServerId = (EFI_DHCP6_DUID *) (Option + 2); -+ ServerId = (EFI_DHCP6_DUID *)(Option + 2); - - // - // Calculate the added length of customized option list. -@@ -1279,7 +1261,6 @@ Dhcp6SendRequestMsg ( - // Append user-defined when configurate Dhcp6 service. - // - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { -- - UserOpt = Instance->Config->OptionList[Index]; - Status = Dhcp6AppendOption ( - Packet, -@@ -1334,7 +1315,6 @@ ON_ERROR: - return Status; - } - -- - /** - Create the decline message and send it. - -@@ -1349,20 +1329,20 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6SendDeclineMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_IA *DecIa -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_IA *DecIa - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET *LastReply; -- EFI_DHCP6_DUID *ClientId; -- EFI_DHCP6_DUID *ServerId; -- DHCP6_SERVICE *Service; -- UINT8 *Option; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT16 Length; -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET *LastReply; -+ EFI_DHCP6_DUID *ClientId; -+ EFI_DHCP6_DUID *ServerId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Option; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT16 Length; - - ASSERT (Instance->Config != NULL); - ASSERT (Instance->IaCb.Ia != NULL); -@@ -1390,7 +1370,7 @@ Dhcp6SendDeclineMsg ( - // - // EFI_DHCP6_DUID contains a length field of 2 bytes. - // -- ServerId = (EFI_DHCP6_DUID *) (Option + 2); -+ ServerId = (EFI_DHCP6_DUID *)(Option + 2); - - // - // Create the Dhcp6 packet and initialize common fields. -@@ -1495,7 +1475,6 @@ ON_ERROR: - return Status; - } - -- - /** - Create the release message and send it. - -@@ -1510,30 +1489,30 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6SendReleaseMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_IA *RelIa -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_IA *RelIa - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET *LastReply; -- EFI_DHCP6_DUID *ClientId; -- EFI_DHCP6_DUID *ServerId; -- DHCP6_SERVICE *Service; -- UINT8 *Option; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT16 Length; -- -- ASSERT(Instance->Config); -- ASSERT(Instance->IaCb.Ia); -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET *LastReply; -+ EFI_DHCP6_DUID *ClientId; -+ EFI_DHCP6_DUID *ServerId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Option; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT16 Length; -+ -+ ASSERT (Instance->Config); -+ ASSERT (Instance->IaCb.Ia); - - Service = Instance->Service; - ClientId = Service->ClientId; - LastReply = Instance->IaCb.Ia->ReplyPacket; - -- ASSERT(ClientId); -- ASSERT(LastReply); -+ ASSERT (ClientId); -+ ASSERT (LastReply); - - // - // Get the server Id from the last reply message. -@@ -1547,7 +1526,7 @@ Dhcp6SendReleaseMsg ( - return EFI_DEVICE_ERROR; - } - -- ServerId = (EFI_DHCP6_DUID *) (Option + 2); -+ ServerId = (EFI_DHCP6_DUID *)(Option + 2); - - // - // Create the Dhcp6 packet and initialize common fields. -@@ -1651,7 +1630,6 @@ ON_ERROR: - return Status; - } - -- - /** - Create the renew/rebind message and send it. - -@@ -1667,33 +1645,33 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6SendRenewRebindMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN BOOLEAN RebindRequest -+ IN DHCP6_INSTANCE *Instance, -+ IN BOOLEAN RebindRequest - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET *LastReply; -- EFI_DHCP6_PACKET_OPTION *UserOpt; -- EFI_DHCP6_DUID *ClientId; -- EFI_DHCP6_DUID *ServerId; -- EFI_DHCP6_STATE State; -- EFI_DHCP6_EVENT Event; -- DHCP6_SERVICE *Service; -- UINT8 *Option; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT32 UserLen; -- UINTN Index; -- UINT16 Length; -- -- ASSERT(Instance->Config); -- ASSERT(Instance->IaCb.Ia); -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET *LastReply; -+ EFI_DHCP6_PACKET_OPTION *UserOpt; -+ EFI_DHCP6_DUID *ClientId; -+ EFI_DHCP6_DUID *ServerId; -+ EFI_DHCP6_STATE State; -+ EFI_DHCP6_EVENT Event; -+ DHCP6_SERVICE *Service; -+ UINT8 *Option; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT32 UserLen; -+ UINTN Index; -+ UINT16 Length; - -- Service = Instance->Service; -- ClientId = Service->ClientId; -+ ASSERT (Instance->Config); -+ ASSERT (Instance->IaCb.Ia); - -- ASSERT(ClientId); -+ Service = Instance->Service; -+ ClientId = Service->ClientId; -+ -+ ASSERT (ClientId); - - // - // Calculate the added length of customized option list. -@@ -1774,7 +1752,7 @@ Dhcp6SendRenewRebindMsg ( - goto ON_ERROR; - } - -- ServerId = (EFI_DHCP6_DUID *) (Option + 2); -+ ServerId = (EFI_DHCP6_DUID *)(Option + 2); - - Status = Dhcp6AppendOption ( - Packet, -@@ -1792,7 +1770,6 @@ Dhcp6SendRenewRebindMsg ( - // Append user-defined when configurate Dhcp6 service. - // - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { -- - UserOpt = Instance->Config->OptionList[Index]; - Status = Dhcp6AppendOption ( - Packet, -@@ -1811,8 +1788,8 @@ Dhcp6SendRenewRebindMsg ( - // - // Callback to user with the packet to be sent and check the user's feedback. - // -- State = (RebindRequest) ? Dhcp6Rebinding : Dhcp6Renewing; -- Event = (RebindRequest) ? Dhcp6EnterRebinding : Dhcp6EnterRenewing; -+ State = (RebindRequest) ? Dhcp6Rebinding : Dhcp6Renewing; -+ Event = (RebindRequest) ? Dhcp6EnterRebinding : Dhcp6EnterRenewing; - - Status = Dhcp6CallbackUser (Instance, Event, &Packet); - if (EFI_ERROR (Status)) { -@@ -1885,19 +1862,19 @@ Dhcp6StartInfoRequest ( - IN VOID *CallbackContext OPTIONAL - ) - { -- EFI_STATUS Status; -- DHCP6_INF_CB *InfCb; -- DHCP6_SERVICE *Service; -- EFI_TPL OldTpl; -+ EFI_STATUS Status; -+ DHCP6_INF_CB *InfCb; -+ DHCP6_SERVICE *Service; -+ EFI_TPL OldTpl; - -- Service = Instance->Service; -+ Service = Instance->Service; - -- OldTpl = gBS->RaiseTPL (TPL_CALLBACK); -+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - Instance->UdpSts = EFI_ALREADY_STARTED; - // - // Create and initialize the control block for the info-request. - // -- InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB)); -+ InfCb = AllocateZeroPool (sizeof (DHCP6_INF_CB)); - - if (InfCb == NULL) { - gBS->RestoreTPL (OldTpl); -@@ -1930,7 +1907,7 @@ Dhcp6StartInfoRequest ( - // - // Register receive callback for the stateless exchange process. - // -- Status = UdpIoRecvDatagram( -+ Status = UdpIoRecvDatagram ( - Service->UdpIo, - Dhcp6ReceivePacket, - Service, -@@ -1981,24 +1958,24 @@ Dhcp6SendInfoRequestMsg ( - IN EFI_DHCP6_RETRANSMISSION *Retransmission - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET_OPTION *UserOpt; -- EFI_DHCP6_DUID *ClientId; -- DHCP6_SERVICE *Service; -- UINT8 *Cursor; -- UINT16 *Elapsed; -- UINT32 UserLen; -- UINTN Index; -- UINT16 Length; -- -- ASSERT(OptionRequest); -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET_OPTION *UserOpt; -+ EFI_DHCP6_DUID *ClientId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Cursor; -+ UINT16 *Elapsed; -+ UINT32 UserLen; -+ UINTN Index; -+ UINT16 Length; -+ -+ ASSERT (OptionRequest); - - Service = Instance->Service; - ClientId = Service->ClientId; - UserLen = NTOHS (OptionRequest->OpLen) + 4; - -- ASSERT(ClientId); -+ ASSERT (ClientId); - - // - // Calculate the added length of customized option list. -@@ -2021,7 +1998,7 @@ Dhcp6SendInfoRequestMsg ( - Packet->Dhcp6.Header.MessageType = Dhcp6MsgInfoRequest; - Packet->Dhcp6.Header.TransactionId = Service->Xid++; - -- InfCb->Xid = Packet->Dhcp6.Header.TransactionId; -+ InfCb->Xid = Packet->Dhcp6.Header.TransactionId; - - // - // Assembly Dhcp6 options for info-request message. -@@ -2067,7 +2044,6 @@ Dhcp6SendInfoRequestMsg ( - // Append user-defined when configurate Dhcp6 service. - // - for (Index = 0; Index < OptionCount; Index++) { -- - UserOpt = OptionList[Index]; - Status = Dhcp6AppendOption ( - Packet, -@@ -2110,7 +2086,6 @@ ON_ERROR: - return Status; - } - -- - /** - Create the Confirm message and send it. - -@@ -2124,19 +2099,19 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6SendConfirmMsg ( -- IN DHCP6_INSTANCE *Instance -+ IN DHCP6_INSTANCE *Instance - ) - { -- UINT8 *Cursor; -- UINTN Index; -- UINT16 Length; -- UINT32 UserLen; -- EFI_STATUS Status; -- DHCP6_SERVICE *Service; -- EFI_DHCP6_DUID *ClientId; -- EFI_DHCP6_PACKET *Packet; -- EFI_DHCP6_PACKET_OPTION *UserOpt; -- UINT16 *Elapsed; -+ UINT8 *Cursor; -+ UINTN Index; -+ UINT16 Length; -+ UINT32 UserLen; -+ EFI_STATUS Status; -+ DHCP6_SERVICE *Service; -+ EFI_DHCP6_DUID *ClientId; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_PACKET_OPTION *UserOpt; -+ UINT16 *Elapsed; - - ASSERT (Instance->Config != NULL); - ASSERT (Instance->IaCb.Ia != NULL); -@@ -2263,8 +2238,6 @@ ON_ERROR: - return Status; - } - -- -- - /** - Handle with the Dhcp6 reply message. - -@@ -2279,13 +2252,13 @@ ON_ERROR: - **/ - EFI_STATUS - Dhcp6HandleReplyMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- UINT8 *Option; -- UINT16 StsCode; -+ EFI_STATUS Status; -+ UINT8 *Option; -+ UINT16 StsCode; - - ASSERT (Instance->Config != NULL); - ASSERT (Instance->IaCb.Ia != NULL); -@@ -2310,7 +2283,7 @@ Dhcp6HandleReplyMsg ( - Dhcp6OptRapidCommit - ); - -- if ((Option != NULL && !Instance->Config->RapidCommit) || (Option == NULL && Instance->Config->RapidCommit)) { -+ if (((Option != NULL) && !Instance->Config->RapidCommit) || ((Option == NULL) && Instance->Config->RapidCommit)) { - return EFI_DEVICE_ERROR; - } - -@@ -2318,11 +2291,11 @@ Dhcp6HandleReplyMsg ( - // As to a valid reply packet in response to a request/renew/rebind packet, - // ignore the packet if not contains the Ia option - // -- if (Instance->IaCb.Ia->State == Dhcp6Requesting || -- Instance->IaCb.Ia->State == Dhcp6Renewing || -- Instance->IaCb.Ia->State == Dhcp6Rebinding -- ) { -- -+ if ((Instance->IaCb.Ia->State == Dhcp6Requesting) || -+ (Instance->IaCb.Ia->State == Dhcp6Renewing) || -+ (Instance->IaCb.Ia->State == Dhcp6Rebinding) -+ ) -+ { - Option = Dhcp6SeekIaOption ( - Packet->Dhcp6.Option, - Packet->Length, -@@ -2347,10 +2320,9 @@ Dhcp6HandleReplyMsg ( - // the client considers the decline/release event completed regardless of the - // status code. - // -- if (Instance->IaCb.Ia->State == Dhcp6Declining || Instance->IaCb.Ia->State == Dhcp6Releasing) { -- -+ if ((Instance->IaCb.Ia->State == Dhcp6Declining) || (Instance->IaCb.Ia->State == Dhcp6Releasing)) { - if (Instance->IaCb.Ia->IaAddressCount != 0) { -- Instance->IaCb.Ia->State = Dhcp6Bound; -+ Instance->IaCb.Ia->State = Dhcp6Bound; - } else { - ASSERT (Instance->IaCb.Ia->ReplyPacket); - FreePool (Instance->IaCb.Ia->ReplyPacket); -@@ -2373,7 +2345,7 @@ Dhcp6HandleReplyMsg ( - // - // Reset start time for next exchange. - // -- Instance->StartTime = 0; -+ Instance->StartTime = 0; - - Status = EFI_SUCCESS; - goto ON_EXIT; -@@ -2400,7 +2372,7 @@ Dhcp6HandleReplyMsg ( - // - // Reset start time for next exchange. - // -- Instance->StartTime = 0; -+ Instance->StartTime = 0; - - // - // Set bound state and store the reply packet. -@@ -2423,7 +2395,7 @@ Dhcp6HandleReplyMsg ( - // - // For sync, set the success flag out of polling in start/renewrebind. - // -- Instance->UdpSts = EFI_SUCCESS; -+ Instance->UdpSts = EFI_SUCCESS; - - // - // Maybe this is a new round DHCP process due to some reason, such as NotOnLink -@@ -2449,70 +2421,72 @@ Dhcp6HandleReplyMsg ( - } - - goto ON_EXIT; -- - } else if (Option != NULL) { - // - // Any error status code option is found. - // - StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (Option))))); - switch (StsCode) { -- case Dhcp6StsUnspecFail: -- // -- // It indicates the server is unable to process the message due to an -- // unspecified failure condition, so just retry if possible. -- // -- break; -- -- case Dhcp6StsUseMulticast: -- // -- // It indicates the server receives a message via unicast from a client -- // to which the server has not sent a unicast option, so retry it by -- // multi-cast address. -- // -- if (Instance->Unicast != NULL) { -- FreePool (Instance->Unicast); -- Instance->Unicast = NULL; -- } -- break; -- -- case Dhcp6StsNotOnLink: -- if (Instance->IaCb.Ia->State == Dhcp6Confirming) { -+ case Dhcp6StsUnspecFail: - // -- // Before initiate new round DHCP, cache the current IA. -+ // It indicates the server is unable to process the message due to an -+ // unspecified failure condition, so just retry if possible. - // -- Status = Dhcp6CacheIa (Instance); -- if (EFI_ERROR (Status)) { -- return Status; -- } -+ break; - -+ case Dhcp6StsUseMulticast: - // -- // Restart S.A.R.R process to acquire new address. -+ // It indicates the server receives a message via unicast from a client -+ // to which the server has not sent a unicast option, so retry it by -+ // multi-cast address. - // -- Status = Dhcp6InitSolicitMsg (Instance); -- if (EFI_ERROR (Status)) { -- return Status; -+ if (Instance->Unicast != NULL) { -+ FreePool (Instance->Unicast); -+ Instance->Unicast = NULL; - } -- } -- break; - -- case Dhcp6StsNoBinding: -- if (Instance->IaCb.Ia->State == Dhcp6Renewing || Instance->IaCb.Ia->State == Dhcp6Rebinding) { -- // -- // Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, the client -- // sends a Request message if the IA contained a Status Code option with the NoBinding status. -- // -- Status = Dhcp6SendRequestMsg(Instance); -- if (EFI_ERROR (Status)) { -- return Status; -+ break; -+ -+ case Dhcp6StsNotOnLink: -+ if (Instance->IaCb.Ia->State == Dhcp6Confirming) { -+ // -+ // Before initiate new round DHCP, cache the current IA. -+ // -+ Status = Dhcp6CacheIa (Instance); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ // -+ // Restart S.A.R.R process to acquire new address. -+ // -+ Status = Dhcp6InitSolicitMsg (Instance); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } - } -- } -- break; - -- default: -- // -- // The other status code, just restart solicitation. -- // -- break; -+ break; -+ -+ case Dhcp6StsNoBinding: -+ if ((Instance->IaCb.Ia->State == Dhcp6Renewing) || (Instance->IaCb.Ia->State == Dhcp6Rebinding)) { -+ // -+ // Refer to RFC3315 Chapter 18.1.8, for each IA in the original Renew or Rebind message, the client -+ // sends a Request message if the IA contained a Status Code option with the NoBinding status. -+ // -+ Status = Dhcp6SendRequestMsg (Instance); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ } -+ -+ break; -+ -+ default: -+ // -+ // The other status code, just restart solicitation. -+ // -+ break; - } - } - -@@ -2520,7 +2494,7 @@ Dhcp6HandleReplyMsg ( - - ON_EXIT: - -- if (!EFI_ERROR(Status)) { -+ if (!EFI_ERROR (Status)) { - Status = Dhcp6DequeueRetry ( - Instance, - Packet->Dhcp6.Header.TransactionId, -@@ -2531,7 +2505,6 @@ ON_EXIT: - return Status; - } - -- - /** - Select the appointed Dhcp6 advertisement message. - -@@ -2545,12 +2518,12 @@ ON_EXIT: - **/ - EFI_STATUS - Dhcp6SelectAdvertiseMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *AdSelect -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *AdSelect - ) - { -- EFI_STATUS Status; -- UINT8 *Option; -+ EFI_STATUS Status; -+ UINT8 *Option; - - ASSERT (AdSelect != NULL); - -@@ -2575,7 +2548,7 @@ Dhcp6SelectAdvertiseMsg ( - FALSE - ); - -- if (EFI_ERROR(Status)) { -+ if (EFI_ERROR (Status)) { - return Status; - } - -@@ -2583,15 +2556,14 @@ Dhcp6SelectAdvertiseMsg ( - // Check whether there is server unicast option in the selected advertise - // packet, and update it. - // -- Option = Dhcp6SeekOption( -+ Option = Dhcp6SeekOption ( - AdSelect->Dhcp6.Option, - AdSelect->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerUnicast - ); - - if (Option != NULL) { -- -- Instance->Unicast = AllocateZeroPool (sizeof(EFI_IPv6_ADDRESS)); -+ Instance->Unicast = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS)); - - if (Instance->Unicast == NULL) { - return EFI_OUT_OF_RESOURCES; -@@ -2615,7 +2587,6 @@ Dhcp6SelectAdvertiseMsg ( - return Dhcp6SendRequestMsg (Instance); - } - -- - /** - Handle with the Dhcp6 advertisement message. - -@@ -2630,16 +2601,16 @@ Dhcp6SelectAdvertiseMsg ( - **/ - EFI_STATUS - Dhcp6HandleAdvertiseMsg ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- UINT8 *Option; -- BOOLEAN Timeout; -+ EFI_STATUS Status; -+ UINT8 *Option; -+ BOOLEAN Timeout; - -- ASSERT(Instance->Config); -- ASSERT(Instance->IaCb.Ia); -+ ASSERT (Instance->Config); -+ ASSERT (Instance->IaCb.Ia); - - Timeout = FALSE; - -@@ -2649,14 +2620,13 @@ Dhcp6HandleAdvertiseMsg ( - // this reply message. Or else, process the advertise messages as normal. - // See details in the section-17.1.4 of rfc-3315. - // -- Option = Dhcp6SeekOption( -+ Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, - Packet->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptRapidCommit - ); - -- if (Option != NULL && Instance->Config->RapidCommit && Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply) { -- -+ if ((Option != NULL) && Instance->Config->RapidCommit && (Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply)) { - return Dhcp6HandleReplyMsg (Instance, Packet); - } - -@@ -2704,12 +2674,11 @@ Dhcp6HandleAdvertiseMsg ( - CopyMem (Instance->AdSelect, Packet, Packet->Size); - - Instance->AdPref = 0xff; -- - } else if (Status == EFI_NOT_READY) { - // - // Not_ready means user wants to continue to receive more advertise packets. - // -- if (Instance->AdPref == 0xff && Instance->AdSelect == NULL) { -+ if ((Instance->AdPref == 0xff) && (Instance->AdSelect == NULL)) { - // - // It's a tricky point. The timer routine set adpref as 0xff if the first - // rt timeout and no advertisement received, which means any advertisement -@@ -2722,13 +2691,13 @@ Dhcp6HandleAdvertiseMsg ( - // Check whether the current packet has a 255 preference option or not. - // Take non-preference option as 0 value. - // -- Option = Dhcp6SeekOption( -+ Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, - Packet->Length - 4, - Dhcp6OptPreference - ); - -- if (Instance->AdSelect == NULL || (Option != NULL && *(Option + 4) > Instance->AdPref)) { -+ if ((Instance->AdSelect == NULL) || ((Option != NULL) && (*(Option + 4) > Instance->AdPref))) { - // - // No advertisements received before or preference is more than other - // advertisements received before. Then store the new packet and the -@@ -2755,7 +2724,6 @@ Dhcp6HandleAdvertiseMsg ( - // preference is less than other advertisements received before. - // Leave the packet alone. - } -- - } else { - // - // Other error status means termination. -@@ -2768,14 +2736,13 @@ Dhcp6HandleAdvertiseMsg ( - // RT has elapsed, or get a highest preference 255 advertise. - // See details in the section-17.1.2 of rfc-3315. - // -- if (Instance->AdPref == 0xff || Timeout) { -+ if ((Instance->AdPref == 0xff) || Timeout) { - Status = Dhcp6SelectAdvertiseMsg (Instance, Instance->AdSelect); - } - - return Status; - } - -- - /** - The Dhcp6 stateful exchange process routine. - -@@ -2785,14 +2752,14 @@ Dhcp6HandleAdvertiseMsg ( - **/ - VOID - Dhcp6HandleStateful ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_DUID *ClientId; -- DHCP6_SERVICE *Service; -- UINT8 *Option; -+ EFI_STATUS Status; -+ EFI_DHCP6_DUID *ClientId; -+ DHCP6_SERVICE *Service; -+ UINT8 *Option; - - Service = Instance->Service; - ClientId = Service->ClientId; -@@ -2809,14 +2776,14 @@ Dhcp6HandleStateful ( - // - // Discard the packet if not advertisement or reply packet. - // -- if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise && Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) { -+ if ((Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise) && (Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply)) { - goto ON_CONTINUE; - } - - // - // Check whether include client Id or not. - // -- Option = Dhcp6SeekOption( -+ Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, - Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN, - Dhcp6OptClientId -@@ -2829,7 +2796,7 @@ Dhcp6HandleStateful ( - // - // Check whether include server Id or not. - // -- Option = Dhcp6SeekOption( -+ Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, - Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN, - Dhcp6OptServerId -@@ -2840,35 +2807,36 @@ Dhcp6HandleStateful ( - } - - switch (Instance->IaCb.Ia->State) { -- case Dhcp6Selecting: -- // -- // Handle the advertisement message when in the Dhcp6Selecting state. -- // Do not need check return status, if failed, just continue to the next. -- // -- Dhcp6HandleAdvertiseMsg (Instance, Packet); -- break; -- -- case Dhcp6Requesting: -- case Dhcp6Confirming: -- case Dhcp6Renewing: -- case Dhcp6Rebinding: -- case Dhcp6Releasing: -- case Dhcp6Declining: -- // -- // Handle the reply message when in the Dhcp6Requesting, Dhcp6Renewing -- // Dhcp6Rebinding, Dhcp6Releasing and Dhcp6Declining state. -- // If failed here, it should reset the current session. -- // -- Status = Dhcp6HandleReplyMsg (Instance, Packet); -- if (EFI_ERROR (Status)) { -- goto ON_EXIT; -- } -- break; -- default: -- // -- // Other state has not supported yet. -- // -- break; -+ case Dhcp6Selecting: -+ // -+ // Handle the advertisement message when in the Dhcp6Selecting state. -+ // Do not need check return status, if failed, just continue to the next. -+ // -+ Dhcp6HandleAdvertiseMsg (Instance, Packet); -+ break; -+ -+ case Dhcp6Requesting: -+ case Dhcp6Confirming: -+ case Dhcp6Renewing: -+ case Dhcp6Rebinding: -+ case Dhcp6Releasing: -+ case Dhcp6Declining: -+ // -+ // Handle the reply message when in the Dhcp6Requesting, Dhcp6Renewing -+ // Dhcp6Rebinding, Dhcp6Releasing and Dhcp6Declining state. -+ // If failed here, it should reset the current session. -+ // -+ Status = Dhcp6HandleReplyMsg (Instance, Packet); -+ if (EFI_ERROR (Status)) { -+ goto ON_EXIT; -+ } -+ -+ break; -+ default: -+ // -+ // Other state has not supported yet. -+ // -+ break; - } - - ON_CONTINUE: -@@ -2887,7 +2855,6 @@ ON_EXIT: - } - } - -- - /** - The Dhcp6 stateless exchange process routine. - -@@ -2897,15 +2864,15 @@ ON_EXIT: - **/ - VOID - Dhcp6HandleStateless ( -- IN DHCP6_INSTANCE *Instance, -- IN EFI_DHCP6_PACKET *Packet -+ IN DHCP6_INSTANCE *Instance, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- DHCP6_SERVICE *Service; -- DHCP6_INF_CB *InfCb; -- UINT8 *Option; -- BOOLEAN IsMatched; -+ EFI_STATUS Status; -+ DHCP6_SERVICE *Service; -+ DHCP6_INF_CB *InfCb; -+ UINT8 *Option; -+ BOOLEAN IsMatched; - - Service = Instance->Service; - Status = EFI_SUCCESS; -@@ -2990,7 +2957,6 @@ ON_EXIT: - } - } - -- - /** - The receive callback function for Dhcp6 exchange process. - -@@ -3003,37 +2969,37 @@ ON_EXIT: - VOID - EFIAPI - Dhcp6ReceivePacket ( -- IN NET_BUF *Udp6Wrap, -- IN UDP_END_POINT *EndPoint, -- IN EFI_STATUS IoStatus, -- IN VOID *Context -+ IN NET_BUF *Udp6Wrap, -+ IN UDP_END_POINT *EndPoint, -+ IN EFI_STATUS IoStatus, -+ IN VOID *Context - ) - { -- EFI_DHCP6_HEADER *Head; -- EFI_DHCP6_PACKET *Packet; -- DHCP6_SERVICE *Service; -- DHCP6_INSTANCE *Instance; -- DHCP6_TX_CB *TxCb; -- UINT32 Size; -- BOOLEAN IsDispatched; -- BOOLEAN IsStateless; -- LIST_ENTRY *Entry1; -- LIST_ENTRY *Next1; -- LIST_ENTRY *Entry2; -- LIST_ENTRY *Next2; -- EFI_STATUS Status; -+ EFI_DHCP6_HEADER *Head; -+ EFI_DHCP6_PACKET *Packet; -+ DHCP6_SERVICE *Service; -+ DHCP6_INSTANCE *Instance; -+ DHCP6_TX_CB *TxCb; -+ UINT32 Size; -+ BOOLEAN IsDispatched; -+ BOOLEAN IsStateless; -+ LIST_ENTRY *Entry1; -+ LIST_ENTRY *Next1; -+ LIST_ENTRY *Entry2; -+ LIST_ENTRY *Next2; -+ EFI_STATUS Status; - - ASSERT (Udp6Wrap != NULL); - ASSERT (Context != NULL); - -- Service = (DHCP6_SERVICE *) Context; -+ Service = (DHCP6_SERVICE *)Context; - Instance = NULL; - Packet = NULL; - IsDispatched = FALSE; - IsStateless = FALSE; - - if (EFI_ERROR (IoStatus)) { -- return ; -+ return; - } - - if (Udp6Wrap->TotalSize < sizeof (EFI_DHCP6_HEADER)) { -@@ -3044,7 +3010,7 @@ Dhcp6ReceivePacket ( - // Copy the net buffer received from upd6 to a Dhcp6 packet. - // - Size = sizeof (EFI_DHCP6_PACKET) + Udp6Wrap->TotalSize; -- Packet = (EFI_DHCP6_PACKET *) AllocateZeroPool (Size); -+ Packet = (EFI_DHCP6_PACKET *)AllocateZeroPool (Size); - - if (Packet == NULL) { - goto ON_CONTINUE; -@@ -3052,7 +3018,7 @@ Dhcp6ReceivePacket ( - - Packet->Size = Size; - Head = &Packet->Dhcp6.Header; -- Packet->Length = NetbufCopy (Udp6Wrap, 0, Udp6Wrap->TotalSize, (UINT8 *) Head); -+ Packet->Length = NetbufCopy (Udp6Wrap, 0, Udp6Wrap->TotalSize, (UINT8 *)Head); - - if (Packet->Length == 0) { - goto ON_CONTINUE; -@@ -3062,11 +3028,9 @@ Dhcp6ReceivePacket ( - // Dispatch packet to right instance by transaction id. - // - NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) { -- - Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link); - - NET_LIST_FOR_EACH_SAFE (Entry2, Next2, &Instance->TxList) { -- - TxCb = NET_LIST_USER_STRUCT (Entry2, DHCP6_TX_CB, Link); - - if (Packet->Dhcp6.Header.TransactionId == TxCb->Xid) { -@@ -3077,7 +3041,8 @@ Dhcp6ReceivePacket ( - if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { - IsStateless = TRUE; - } -- IsDispatched = TRUE; -+ -+ IsDispatched = TRUE; - break; - } - } -@@ -3107,11 +3072,11 @@ ON_CONTINUE: - - if (!IsDispatched) { - Status = UdpIoRecvDatagram ( -- Service->UdpIo, -- Dhcp6ReceivePacket, -- Service, -- 0 -- ); -+ Service->UdpIo, -+ Dhcp6ReceivePacket, -+ Service, -+ 0 -+ ); - if (EFI_ERROR (Status)) { - NET_LIST_FOR_EACH_SAFE (Entry1, Next1, &Service->Child) { - Instance = NET_LIST_USER_STRUCT (Entry1, DHCP6_INSTANCE, Link); -@@ -3143,7 +3108,7 @@ ON_CONTINUE: - **/ - BOOLEAN - Dhcp6LinkMovDetect ( -- IN DHCP6_INSTANCE *Instance -+ IN DHCP6_INSTANCE *Instance - ) - { - UINT32 InterruptStatus; -@@ -3152,7 +3117,7 @@ Dhcp6LinkMovDetect ( - EFI_SIMPLE_NETWORK_PROTOCOL *Snp; - - ASSERT (Instance != NULL); -- Snp = Instance->Service->Snp; -+ Snp = Instance->Service->Snp; - MediaPresent = Instance->MediaPresent; - - // -@@ -3177,10 +3142,10 @@ Dhcp6LinkMovDetect ( - if (!MediaPresent && Instance->MediaPresent) { - return TRUE; - } -+ - return FALSE; - } - -- - /** - The timer routine of the Dhcp6 instance for each second. - -@@ -3191,28 +3156,27 @@ Dhcp6LinkMovDetect ( - VOID - EFIAPI - Dhcp6OnTimerTick ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *NextEntry; -- DHCP6_INSTANCE *Instance; -- DHCP6_TX_CB *TxCb; -- DHCP6_IA_CB *IaCb; -- UINT32 LossTime; -- EFI_STATUS Status; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *NextEntry; -+ DHCP6_INSTANCE *Instance; -+ DHCP6_TX_CB *TxCb; -+ DHCP6_IA_CB *IaCb; -+ UINT32 LossTime; -+ EFI_STATUS Status; - - ASSERT (Context != NULL); - -- Instance = (DHCP6_INSTANCE *) Context; -+ Instance = (DHCP6_INSTANCE *)Context; - - // - // 1. Loop the tx list, count live time of every tx packet to check whether - // need re-transmit or not. - // - NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->TxList) { -- - TxCb = NET_LIST_USER_STRUCT (Entry, DHCP6_TX_CB, Link); - - TxCb->TickTime++; -@@ -3221,7 +3185,7 @@ Dhcp6OnTimerTick ( - // - // Handle the first rt in the transmission of solicit specially. - // -- if ((TxCb->RetryCnt == 0 || TxCb->SolicitRetry) && TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgSolicit) { -+ if (((TxCb->RetryCnt == 0) || TxCb->SolicitRetry) && (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgSolicit)) { - if (Instance->AdSelect == NULL) { - // - // Set adpref as 0xff here to indicate select any advertisement -@@ -3238,9 +3202,11 @@ Dhcp6OnTimerTick ( - } else if (EFI_ERROR (Status)) { - TxCb->RetryCnt++; - } -+ - return; - } - } -+ - // - // Increase the retry count for the packet and add up the total loss time. - // -@@ -3250,7 +3216,7 @@ Dhcp6OnTimerTick ( - // - // Check whether overflow the max retry count limit for this packet - // -- if (TxCb->RetryCtl.Mrc != 0 && TxCb->RetryCtl.Mrc < TxCb->RetryCnt) { -+ if ((TxCb->RetryCtl.Mrc != 0) && (TxCb->RetryCtl.Mrc < TxCb->RetryCnt)) { - Status = EFI_NO_RESPONSE; - goto ON_CLOSE; - } -@@ -3258,7 +3224,7 @@ Dhcp6OnTimerTick ( - // - // Check whether overflow the max retry duration for this packet - // -- if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd <= TxCb->RetryLos) { -+ if ((TxCb->RetryCtl.Mrd != 0) && (TxCb->RetryCtl.Mrd <= TxCb->RetryLos)) { - Status = EFI_NO_RESPONSE; - goto ON_CLOSE; - } -@@ -3275,7 +3241,7 @@ Dhcp6OnTimerTick ( - TRUE - ); - -- if (TxCb->RetryCtl.Mrt != 0 && TxCb->RetryCtl.Mrt < TxCb->RetryExp) { -+ if ((TxCb->RetryCtl.Mrt != 0) && (TxCb->RetryCtl.Mrt < TxCb->RetryExp)) { - TxCb->RetryExp = Dhcp6CalculateExpireTime ( - TxCb->RetryCtl.Mrt, - TRUE, -@@ -3288,7 +3254,7 @@ Dhcp6OnTimerTick ( - // duration time. - // - LossTime = TxCb->RetryLos + TxCb->RetryExp; -- if (TxCb->RetryCtl.Mrd != 0 && TxCb->RetryCtl.Mrd < LossTime) { -+ if ((TxCb->RetryCtl.Mrd != 0) && (TxCb->RetryCtl.Mrd < LossTime)) { - TxCb->RetryExp = TxCb->RetryCtl.Mrd - TxCb->RetryLos; - } - -@@ -3314,22 +3280,19 @@ Dhcp6OnTimerTick ( - // - IaCb = &Instance->IaCb; - -- if (Instance->Config == NULL || IaCb->Ia == NULL) { -+ if ((Instance->Config == NULL) || (IaCb->Ia == NULL)) { - return; - } - -- if (IaCb->Ia->State == Dhcp6Bound || IaCb->Ia->State == Dhcp6Renewing || IaCb->Ia->State == Dhcp6Rebinding) { -- -+ if ((IaCb->Ia->State == Dhcp6Bound) || (IaCb->Ia->State == Dhcp6Renewing) || (IaCb->Ia->State == Dhcp6Rebinding)) { - IaCb->LeaseTime++; - -- if (IaCb->LeaseTime > IaCb->T2 && IaCb->Ia->State == Dhcp6Bound) { -+ if ((IaCb->LeaseTime > IaCb->T2) && (IaCb->Ia->State == Dhcp6Bound)) { - // - // Exceed t2, send rebind packet to extend the Ia lease. - // - Dhcp6SendRenewRebindMsg (Instance, TRUE); -- -- } else if (IaCb->LeaseTime > IaCb->T1 && IaCb->Ia->State == Dhcp6Bound) { -- -+ } else if ((IaCb->LeaseTime > IaCb->T1) && (IaCb->Ia->State == Dhcp6Bound)) { - // - // Exceed t1, send renew packet to extend the Ia lease. - // -@@ -3347,28 +3310,32 @@ Dhcp6OnTimerTick ( - - return; - -- ON_CLOSE: -+ON_CLOSE: - - if (Dhcp6IsValidTxCb (Instance, TxCb) && -- TxCb->TxPacket != NULL && -- (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest || -- TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew || -- TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm) -- ) { -+ (TxCb->TxPacket != NULL) && -+ ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) || -+ (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) || -+ (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)) -+ ) -+ { - // - // The failure of renew/Confirm will still switch to the bound state. - // - if ((TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgRenew) || -- (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)) { -+ (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgConfirm)) -+ { - ASSERT (Instance->IaCb.Ia); - Instance->IaCb.Ia->State = Dhcp6Bound; - } -+ - // - // The failure of info-request will return no response. - // - if (TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgInfoRequest) { - Instance->UdpSts = EFI_NO_RESPONSE; - } -+ - Dhcp6DequeueRetry ( - Instance, - TxCb->Xid, --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch b/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch deleted file mode 100644 index a7ca769..0000000 --- a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch +++ /dev/null @@ -1,16641 +0,0 @@ -From 1a92cf063c3d77f3706a7d9d57fafa9364317554 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 12 Jun 2024 18:16:26 -0400 -Subject: [PATCH 04/31] NetworkPkg: Apply uncrustify changes - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [4/31] a42ad4b2dd705cb3492d99cbd00378581207ad65 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -This upstream commit makes it very hard to backport more recent changes -from upstream, since it always causes numerous whitespace conflicts. In -order to make application of the next commits in this series cleaner, -and hopefully to save ourselves some future work, we apply parts of the -commit on some files which will be affected by the next commits. - -This commit only contains whitespace changes. - -commit d1050b9dff1cace252aff86630bfdb59dff5f507 -Author: Michael Kubacki -Date: Sun Dec 5 14:54:07 2021 -0800 - - NetworkPkg: Apply uncrustify changes - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 - - Apply uncrustify changes to .c/.h files in the NetworkPkg package - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael D Kinney - Signed-off-by: Michael Kubacki - Reviewed-by: Maciej Rabeda - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c | 175 ++- - NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c | 149 +-- - NetworkPkg/DnsDxe/DnsDhcp.c | 187 ++- - NetworkPkg/DnsDxe/DnsImpl.c | 819 ++++++------ - NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 438 +++--- - NetworkPkg/IScsiDxe/IScsiCHAP.c | 634 ++++----- - NetworkPkg/IScsiDxe/IScsiMisc.c | 779 +++++------ - NetworkPkg/Include/Library/NetLib.h | 700 +++++----- - NetworkPkg/Ip4Dxe/Ip4Driver.c | 158 ++- - NetworkPkg/Ip6Dxe/Ip6If.c | 210 ++- - NetworkPkg/Ip6Dxe/Ip6Mld.c | 232 ++-- - NetworkPkg/Ip6Dxe/Ip6Nd.c | 1554 +++++++++++----------- - NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 877 ++++++------ - NetworkPkg/TcpDxe/TcpDriver.c | 107 +- - NetworkPkg/TcpDxe/TcpMain.h | 150 +-- - NetworkPkg/TcpDxe/TcpMisc.c | 436 +++--- - NetworkPkg/Udp4Dxe/Udp4Driver.c | 52 +- - NetworkPkg/Udp6Dxe/Udp6Driver.c | 85 +- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 46 +- - NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 365 +++-- - 20 files changed, 4062 insertions(+), 4091 deletions(-) - -diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -index 970141abfe..8c37e93be3 100644 ---- a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include "Dhcp4Impl.h" - #include "Dhcp4Driver.h" - --EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = { - Dhcp4DriverBindingSupported, - Dhcp4DriverBindingStart, - Dhcp4DriverBindingStop, -@@ -17,7 +17,7 @@ EFI_DRIVER_BINDING_PROTOCOL gDhcp4DriverBinding = { - NULL - }; - --EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = { -+EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = { - Dhcp4ServiceBindingCreateChild, - Dhcp4ServiceBindingDestroyChild - }; -@@ -39,8 +39,8 @@ EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplate = { - EFI_STATUS - EFIAPI - Dhcp4DriverEntryPoint ( -- IN EFI_HANDLE ImageHandle, -- IN EFI_SYSTEM_TABLE *SystemTable -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable - ) - { - return EfiLibInstallDriverBindingComponentName2 ( -@@ -53,7 +53,6 @@ Dhcp4DriverEntryPoint ( - ); - } - -- - /** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In -@@ -94,8 +93,6 @@ Dhcp4DriverBindingSupported ( - return Status; - } - -- -- - /** - Configure the default UDP child to receive all the DHCP traffics - on this network interface. -@@ -110,35 +107,33 @@ Dhcp4DriverBindingSupported ( - EFI_STATUS - EFIAPI - DhcpConfigUdpIo ( -- IN UDP_IO *UdpIo, -- IN VOID *Context -+ IN UDP_IO *UdpIo, -+ IN VOID *Context - ) - { -- EFI_UDP4_CONFIG_DATA UdpConfigData; -- -- UdpConfigData.AcceptBroadcast = TRUE; -- UdpConfigData.AcceptPromiscuous = FALSE; -- UdpConfigData.AcceptAnyPort = FALSE; -- UdpConfigData.AllowDuplicatePort = TRUE; -- UdpConfigData.TypeOfService = 0; -- UdpConfigData.TimeToLive = 64; -- UdpConfigData.DoNotFragment = FALSE; -- UdpConfigData.ReceiveTimeout = 0; -- UdpConfigData.TransmitTimeout = 0; -- -- UdpConfigData.UseDefaultAddress = FALSE; -- UdpConfigData.StationPort = DHCP_CLIENT_PORT; -- UdpConfigData.RemotePort = DHCP_SERVER_PORT; -+ EFI_UDP4_CONFIG_DATA UdpConfigData; -+ -+ UdpConfigData.AcceptBroadcast = TRUE; -+ UdpConfigData.AcceptPromiscuous = FALSE; -+ UdpConfigData.AcceptAnyPort = FALSE; -+ UdpConfigData.AllowDuplicatePort = TRUE; -+ UdpConfigData.TypeOfService = 0; -+ UdpConfigData.TimeToLive = 64; -+ UdpConfigData.DoNotFragment = FALSE; -+ UdpConfigData.ReceiveTimeout = 0; -+ UdpConfigData.TransmitTimeout = 0; -+ -+ UdpConfigData.UseDefaultAddress = FALSE; -+ UdpConfigData.StationPort = DHCP_CLIENT_PORT; -+ UdpConfigData.RemotePort = DHCP_SERVER_PORT; - - ZeroMem (&UdpConfigData.StationAddress, sizeof (EFI_IPv4_ADDRESS)); - ZeroMem (&UdpConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - ZeroMem (&UdpConfigData.RemoteAddress, sizeof (EFI_IPv4_ADDRESS)); - -- return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData);; -+ return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData); - } - -- -- - /** - Destroy the DHCP service. The Dhcp4 service may be partly initialized, - or partly destroyed. If a resource is destroyed, it is marked as so in -@@ -151,7 +146,7 @@ DhcpConfigUdpIo ( - **/ - EFI_STATUS - Dhcp4CloseService ( -- IN DHCP_SERVICE *DhcpSb -+ IN DHCP_SERVICE *DhcpSb - ) - { - DhcpCleanLease (DhcpSb); -@@ -171,8 +166,6 @@ Dhcp4CloseService ( - return EFI_SUCCESS; - } - -- -- - /** - Create a new DHCP service binding instance for the controller. - -@@ -189,28 +182,28 @@ Dhcp4CloseService ( - **/ - EFI_STATUS - Dhcp4CreateService ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE ImageHandle, -- OUT DHCP_SERVICE **Service -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE ImageHandle, -+ OUT DHCP_SERVICE **Service - ) - { -- DHCP_SERVICE *DhcpSb; -- EFI_STATUS Status; -+ DHCP_SERVICE *DhcpSb; -+ EFI_STATUS Status; - -- *Service = NULL; -- DhcpSb = AllocateZeroPool (sizeof (DHCP_SERVICE)); -+ *Service = NULL; -+ DhcpSb = AllocateZeroPool (sizeof (DHCP_SERVICE)); - - if (DhcpSb == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- DhcpSb->Signature = DHCP_SERVICE_SIGNATURE; -- DhcpSb->ServiceState = DHCP_UNCONFIGED; -- DhcpSb->Controller = Controller; -- DhcpSb->Image = ImageHandle; -+ DhcpSb->Signature = DHCP_SERVICE_SIGNATURE; -+ DhcpSb->ServiceState = DHCP_UNCONFIGED; -+ DhcpSb->Controller = Controller; -+ DhcpSb->Image = ImageHandle; - InitializeListHead (&DhcpSb->Children); -- DhcpSb->DhcpState = Dhcp4Stopped; -- DhcpSb->Xid = NET_RANDOM (NetRandomInitSeed ()); -+ DhcpSb->DhcpState = Dhcp4Stopped; -+ DhcpSb->Xid = NET_RANDOM (NetRandomInitSeed ()); - CopyMem ( - &DhcpSb->ServiceBinding, - &mDhcp4ServiceBindingTemplate, -@@ -244,11 +237,11 @@ Dhcp4CreateService ( - goto ON_ERROR; - } - -- DhcpSb->HwLen = (UINT8) DhcpSb->UdpIo->SnpMode.HwAddressSize; -+ DhcpSb->HwLen = (UINT8)DhcpSb->UdpIo->SnpMode.HwAddressSize; - DhcpSb->HwType = DhcpSb->UdpIo->SnpMode.IfType; - CopyMem (&DhcpSb->Mac, &DhcpSb->UdpIo->SnpMode.CurrentAddress, sizeof (DhcpSb->Mac)); - -- *Service = DhcpSb; -+ *Service = DhcpSb; - return EFI_SUCCESS; - - ON_ERROR: -@@ -258,7 +251,6 @@ ON_ERROR: - return Status; - } - -- - /** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make -@@ -285,8 +277,8 @@ Dhcp4DriverBindingStart ( - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) - { -- DHCP_SERVICE *DhcpSb; -- EFI_STATUS Status; -+ DHCP_SERVICE *DhcpSb; -+ EFI_STATUS Status; - - // - // First: test for the DHCP4 Protocol -@@ -309,6 +301,7 @@ Dhcp4DriverBindingStart ( - if (EFI_ERROR (Status)) { - return Status; - } -+ - ASSERT (DhcpSb != NULL); - - // -@@ -319,6 +312,7 @@ Dhcp4DriverBindingStart ( - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } -+ - Status = gBS->SetTimer (DhcpSb->Timer, TimerPeriodic, TICKS_PER_SECOND); - - if (EFI_ERROR (Status)) { -@@ -360,24 +354,23 @@ ON_ERROR: - EFI_STATUS - EFIAPI - Dhcp4DestroyChildEntry ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { -- DHCP_PROTOCOL *Instance; -- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -+ DHCP_PROTOCOL *Instance; -+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE); -- ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; -+ Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP_PROTOCOL, Link, DHCP_PROTOCOL_SIGNATURE); -+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context; - - return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); - } - -- - /** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to -@@ -422,10 +415,10 @@ Dhcp4DriverBindingStop ( - return EFI_SUCCESS; - } - -- Status = gBS->OpenProtocol ( -+ Status = gBS->OpenProtocol ( - NicHandle, - &gEfiDhcp4ServiceBindingProtocolGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - This->DriverBindingHandle, - NicHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -440,23 +433,23 @@ Dhcp4DriverBindingStop ( - // - // Destroy all the children instances before destroy the service. - // -- List = &DhcpSb->Children; -+ List = &DhcpSb->Children; - Status = NetDestroyLinkList ( - List, - Dhcp4DestroyChildEntry, - ServiceBinding, - &ListLength - ); -- if (EFI_ERROR (Status) || ListLength != 0) { -+ if (EFI_ERROR (Status) || (ListLength != 0)) { - Status = EFI_DEVICE_ERROR; - } - } - -- if (NumberOfChildren == 0 && !IsListEmpty (&DhcpSb->Children)) { -+ if ((NumberOfChildren == 0) && !IsListEmpty (&DhcpSb->Children)) { - Status = EFI_DEVICE_ERROR; - } - -- if (NumberOfChildren == 0 && IsListEmpty (&DhcpSb->Children)) { -+ if ((NumberOfChildren == 0) && IsListEmpty (&DhcpSb->Children)) { - // - // Destroy the service itself if no child instance left. - // -@@ -474,6 +467,7 @@ Dhcp4DriverBindingStop ( - FreeUnicodeStringTable (gDhcpControllerNameTable); - gDhcpControllerNameTable = NULL; - } -+ - FreePool (DhcpSb); - - Status = EFI_SUCCESS; -@@ -482,7 +476,6 @@ Dhcp4DriverBindingStop ( - return Status; - } - -- - /** - Initialize a new DHCP instance. - -@@ -492,25 +485,24 @@ Dhcp4DriverBindingStop ( - **/ - VOID - DhcpInitProtocol ( -- IN DHCP_SERVICE *DhcpSb, -- IN OUT DHCP_PROTOCOL *Instance -+ IN DHCP_SERVICE *DhcpSb, -+ IN OUT DHCP_PROTOCOL *Instance - ) - { -- Instance->Signature = DHCP_PROTOCOL_SIGNATURE; -+ Instance->Signature = DHCP_PROTOCOL_SIGNATURE; - CopyMem (&Instance->Dhcp4Protocol, &mDhcp4ProtocolTemplate, sizeof (Instance->Dhcp4Protocol)); - InitializeListHead (&Instance->Link); -- Instance->Handle = NULL; -- Instance->Service = DhcpSb; -- Instance->InDestroy = FALSE; -- Instance->CompletionEvent = NULL; -- Instance->RenewRebindEvent = NULL; -- Instance->Token = NULL; -- Instance->UdpIo = NULL; -- Instance->ElaspedTime = 0; -+ Instance->Handle = NULL; -+ Instance->Service = DhcpSb; -+ Instance->InDestroy = FALSE; -+ Instance->CompletionEvent = NULL; -+ Instance->RenewRebindEvent = NULL; -+ Instance->Token = NULL; -+ Instance->UdpIo = NULL; -+ Instance->ElaspedTime = 0; - NetbufQueInit (&Instance->ResponseQueue); - } - -- - /** - Creates a child handle and installs a protocol. - -@@ -537,11 +529,11 @@ Dhcp4ServiceBindingCreateChild ( - IN EFI_HANDLE *ChildHandle - ) - { -- DHCP_SERVICE *DhcpSb; -- DHCP_PROTOCOL *Instance; -- EFI_STATUS Status; -- EFI_TPL OldTpl; -- VOID *Udp4; -+ DHCP_SERVICE *DhcpSb; -+ DHCP_PROTOCOL *Instance; -+ EFI_STATUS Status; -+ EFI_TPL OldTpl; -+ VOID *Udp4; - - if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -571,7 +563,7 @@ Dhcp4ServiceBindingCreateChild ( - return Status; - } - -- Instance->Handle = *ChildHandle; -+ Instance->Handle = *ChildHandle; - - // - // Open the Udp4 protocol BY_CHILD. -@@ -579,7 +571,7 @@ Dhcp4ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - DhcpSb->UdpIo->UdpHandle, - &gEfiUdp4ProtocolGuid, -- (VOID **) &Udp4, -+ (VOID **)&Udp4, - gDhcp4DriverBinding.DriverBindingHandle, - Instance->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -606,7 +598,6 @@ Dhcp4ServiceBindingCreateChild ( - return EFI_SUCCESS; - } - -- - /** - Destroys a child handle with a protocol installed on it. - -@@ -632,11 +623,11 @@ Dhcp4ServiceBindingDestroyChild ( - IN EFI_HANDLE ChildHandle - ) - { -- DHCP_SERVICE *DhcpSb; -- DHCP_PROTOCOL *Instance; -- EFI_DHCP4_PROTOCOL *Dhcp; -- EFI_TPL OldTpl; -- EFI_STATUS Status; -+ DHCP_SERVICE *DhcpSb; -+ DHCP_PROTOCOL *Instance; -+ EFI_DHCP4_PROTOCOL *Dhcp; -+ EFI_TPL OldTpl; -+ EFI_STATUS Status; - - if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -648,7 +639,7 @@ Dhcp4ServiceBindingDestroyChild ( - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiDhcp4ProtocolGuid, -- (VOID **) &Dhcp, -+ (VOID **)&Dhcp, - gDhcp4DriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -658,8 +649,8 @@ Dhcp4ServiceBindingDestroyChild ( - return EFI_UNSUPPORTED; - } - -- Instance = DHCP_INSTANCE_FROM_THIS (Dhcp); -- DhcpSb = DHCP_SERVICE_FROM_THIS (This); -+ Instance = DHCP_INSTANCE_FROM_THIS (Dhcp); -+ DhcpSb = DHCP_SERVICE_FROM_THIS (This); - - if (Instance->Service != DhcpSb) { - return EFI_INVALID_PARAMETER; -@@ -675,7 +666,7 @@ Dhcp4ServiceBindingDestroyChild ( - return EFI_SUCCESS; - } - -- OldTpl = gBS->RaiseTPL (TPL_CALLBACK); -+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - Instance->InDestroy = TRUE; - - // -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -index f0b236835f..b591a4605b 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -@@ -10,8 +10,7 @@ - - #include "Dhcp6Impl.h" - -- --EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = { - Dhcp6DriverBindingSupported, - Dhcp6DriverBindingStart, - Dhcp6DriverBindingStop, -@@ -20,7 +19,7 @@ EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = { - NULL - }; - --EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = { -+EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = { - Dhcp6ServiceBindingCreateChild, - Dhcp6ServiceBindingDestroyChild - }; -@@ -39,12 +38,12 @@ EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = { - EFI_STATUS - EFIAPI - Dhcp6ConfigureUdpIo ( -- IN UDP_IO *UdpIo, -- IN VOID *Context -+ IN UDP_IO *UdpIo, -+ IN VOID *Context - ) - { -- EFI_UDP6_PROTOCOL *Udp6; -- EFI_UDP6_CONFIG_DATA *Config; -+ EFI_UDP6_PROTOCOL *Udp6; -+ EFI_UDP6_CONFIG_DATA *Config; - - Udp6 = UdpIo->Protocol.Udp6; - Config = &(UdpIo->Config.Udp6); -@@ -67,13 +66,12 @@ Dhcp6ConfigureUdpIo ( - // will be overridden later. Note that we MUST not limit RemotePort. - // More details, refer to RFC 3315 section 5.2. - // -- Config->StationPort = DHCP6_PORT_CLIENT; -- Config->RemotePort = 0; -+ Config->StationPort = DHCP6_PORT_CLIENT; -+ Config->RemotePort = 0; - -- return Udp6->Configure (Udp6, Config);; -+ return Udp6->Configure (Udp6, Config); - } - -- - /** - Destroy the Dhcp6 service. The Dhcp6 service may be partly initialized, - or partly destroyed. If a resource is destroyed, it is marked as such in -@@ -84,7 +82,7 @@ Dhcp6ConfigureUdpIo ( - **/ - VOID - Dhcp6DestroyService ( -- IN OUT DHCP6_SERVICE *Service -+ IN OUT DHCP6_SERVICE *Service - ) - { - // -@@ -103,7 +101,6 @@ Dhcp6DestroyService ( - FreePool (Service); - } - -- - /** - Create a new Dhcp6 service for the Nic controller. - -@@ -119,13 +116,13 @@ Dhcp6DestroyService ( - **/ - EFI_STATUS - Dhcp6CreateService ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE ImageHandle, -- OUT DHCP6_SERVICE **Service -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE ImageHandle, -+ OUT DHCP6_SERVICE **Service - ) - { -- DHCP6_SERVICE *Dhcp6Srv; -- EFI_STATUS Status; -+ DHCP6_SERVICE *Dhcp6Srv; -+ EFI_STATUS Status; - - *Service = NULL; - Dhcp6Srv = AllocateZeroPool (sizeof (DHCP6_SERVICE)); -@@ -147,10 +144,10 @@ Dhcp6CreateService ( - // - // Initialize the fields of the new Dhcp6 service. - // -- Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE; -- Dhcp6Srv->Controller = Controller; -- Dhcp6Srv->Image = ImageHandle; -- Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ())); -+ Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE; -+ Dhcp6Srv->Controller = Controller; -+ Dhcp6Srv->Image = ImageHandle; -+ Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ())); - - CopyMem ( - &Dhcp6Srv->ServiceBinding, -@@ -164,7 +161,7 @@ Dhcp6CreateService ( - Status = gBS->HandleProtocol ( - Controller, - &gEfiIp6ConfigProtocolGuid, -- (VOID **) &Dhcp6Srv->Ip6Cfg -+ (VOID **)&Dhcp6Srv->Ip6Cfg - ); - if (EFI_ERROR (Status)) { - FreePool (Dhcp6Srv); -@@ -175,7 +172,7 @@ Dhcp6CreateService ( - // Generate client Duid: If SMBIOS system UUID is located, generate DUID in DUID-UUID format. - // Otherwise, in DUID-LLT format. - // -- Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode); -+ Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode); - - if (Dhcp6Srv->ClientId == NULL) { - FreePool (Dhcp6Srv); -@@ -206,7 +203,6 @@ Dhcp6CreateService ( - return EFI_SUCCESS; - } - -- - /** - Destroy the Dhcp6 instance and recycle the resources. - -@@ -215,7 +211,7 @@ Dhcp6CreateService ( - **/ - VOID - Dhcp6DestroyInstance ( -- IN OUT DHCP6_INSTANCE *Instance -+ IN OUT DHCP6_INSTANCE *Instance - ) - { - // -@@ -239,6 +235,7 @@ Dhcp6DestroyInstance ( - if (Instance->IaCb.Ia->ReplyPacket != NULL) { - FreePool (Instance->IaCb.Ia->ReplyPacket); - } -+ - FreePool (Instance->IaCb.Ia); - } - -@@ -253,7 +250,6 @@ Dhcp6DestroyInstance ( - FreePool (Instance); - } - -- - /** - Create the Dhcp6 instance and initialize it. - -@@ -266,12 +262,12 @@ Dhcp6DestroyInstance ( - **/ - EFI_STATUS - Dhcp6CreateInstance ( -- IN DHCP6_SERVICE *Service, -- OUT DHCP6_INSTANCE **Instance -+ IN DHCP6_SERVICE *Service, -+ OUT DHCP6_INSTANCE **Instance - ) - { -- EFI_STATUS Status; -- DHCP6_INSTANCE *Dhcp6Ins; -+ EFI_STATUS Status; -+ DHCP6_INSTANCE *Dhcp6Ins; - - *Instance = NULL; - Dhcp6Ins = AllocateZeroPool (sizeof (DHCP6_INSTANCE)); -@@ -283,11 +279,11 @@ Dhcp6CreateInstance ( - // - // Initialize the fields of the new Dhcp6 instance. - // -- Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE; -- Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED; -- Dhcp6Ins->Service = Service; -- Dhcp6Ins->InDestroy = FALSE; -- Dhcp6Ins->MediaPresent = TRUE; -+ Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE; -+ Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED; -+ Dhcp6Ins->Service = Service; -+ Dhcp6Ins->InDestroy = FALSE; -+ Dhcp6Ins->MediaPresent = TRUE; - - CopyMem ( - &Dhcp6Ins->Dhcp6, -@@ -333,24 +329,23 @@ Dhcp6CreateInstance ( - EFI_STATUS - EFIAPI - Dhcp6DestroyChildEntry ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { -- DHCP6_INSTANCE *Instance; -- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -+ DHCP6_INSTANCE *Instance; -+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE); -- ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context; -+ Instance = NET_LIST_USER_STRUCT_S (Entry, DHCP6_INSTANCE, Link, DHCP6_INSTANCE_SIGNATURE); -+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context; - - return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); - } - -- - /** - Entry point of the DHCP6 driver to install various protocols. - -@@ -364,8 +359,8 @@ Dhcp6DestroyChildEntry ( - EFI_STATUS - EFIAPI - Dhcp6DriverEntryPoint ( -- IN EFI_HANDLE ImageHandle, -- IN EFI_SYSTEM_TABLE *SystemTable -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable - ) - { - return EfiLibInstallDriverBindingComponentName2 ( -@@ -378,7 +373,6 @@ Dhcp6DriverEntryPoint ( - ); - } - -- - /** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In -@@ -414,7 +408,6 @@ Dhcp6DriverBindingSupported ( - ); - } - -- - /** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make -@@ -441,8 +434,8 @@ Dhcp6DriverBindingStart ( - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) - { -- EFI_STATUS Status; -- DHCP6_SERVICE *Service; -+ EFI_STATUS Status; -+ DHCP6_SERVICE *Service; - - // - // Check the Dhcp6 service whether already started. -@@ -490,7 +483,6 @@ Dhcp6DriverBindingStart ( - return EFI_SUCCESS; - } - -- - /** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to -@@ -519,12 +511,12 @@ Dhcp6DriverBindingStop ( - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) - { -- EFI_STATUS Status; -- EFI_HANDLE NicHandle; -- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -- DHCP6_SERVICE *Service; -- LIST_ENTRY *List; -- UINTN ListLength; -+ EFI_STATUS Status; -+ EFI_HANDLE NicHandle; -+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -+ DHCP6_SERVICE *Service; -+ LIST_ENTRY *List; -+ UINTN ListLength; - - // - // Find and check the Nic handle by the controller handle. -@@ -538,7 +530,7 @@ Dhcp6DriverBindingStop ( - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiDhcp6ServiceBindingProtocolGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - This->DriverBindingHandle, - NicHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -553,23 +545,23 @@ Dhcp6DriverBindingStop ( - // - // Destroy all the children instances before destroy the service. - // -- List = &Service->Child; -+ List = &Service->Child; - Status = NetDestroyLinkList ( - List, - Dhcp6DestroyChildEntry, - ServiceBinding, - &ListLength - ); -- if (EFI_ERROR (Status) || ListLength != 0) { -+ if (EFI_ERROR (Status) || (ListLength != 0)) { - Status = EFI_DEVICE_ERROR; - } - } - -- if (NumberOfChildren == 0 && !IsListEmpty (&Service->Child)) { -+ if ((NumberOfChildren == 0) && !IsListEmpty (&Service->Child)) { - Status = EFI_DEVICE_ERROR; - } - -- if (NumberOfChildren == 0 && IsListEmpty (&Service->Child)) { -+ if ((NumberOfChildren == 0) && IsListEmpty (&Service->Child)) { - // - // Destroy the service itself if no child instance left. - // -@@ -590,7 +582,6 @@ ON_EXIT: - return Status; - } - -- - /** - Creates a child handle and installs a protocol. - -@@ -615,19 +606,19 @@ Dhcp6ServiceBindingCreateChild ( - IN OUT EFI_HANDLE *ChildHandle - ) - { -- EFI_STATUS Status; -- EFI_TPL OldTpl; -- DHCP6_SERVICE *Service; -- DHCP6_INSTANCE *Instance; -- VOID *Udp6; -+ EFI_STATUS Status; -+ EFI_TPL OldTpl; -+ DHCP6_SERVICE *Service; -+ DHCP6_INSTANCE *Instance; -+ VOID *Udp6; - -- if (This == NULL || ChildHandle == NULL) { -+ if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; - } - - Service = DHCP6_SERVICE_FROM_THIS (This); - -- Status = Dhcp6CreateInstance (Service, &Instance); -+ Status = Dhcp6CreateInstance (Service, &Instance); - - if (EFI_ERROR (Status)) { - return Status; -@@ -670,14 +661,13 @@ Dhcp6ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - Service->UdpIo->UdpHandle, - &gEfiUdp6ProtocolGuid, -- (VOID **) &Udp6, -+ (VOID **)&Udp6, - gDhcp6DriverBinding.DriverBindingHandle, - Instance->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - - if (EFI_ERROR (Status)) { -- - gBS->UninstallMultipleProtocolInterfaces ( - Instance->Handle, - &gEfiDhcp6ProtocolGuid, -@@ -704,7 +694,6 @@ ON_ERROR: - return Status; - } - -- - /** - Destroys a child handle with a protocol installed on it. - -@@ -730,13 +719,13 @@ Dhcp6ServiceBindingDestroyChild ( - IN EFI_HANDLE ChildHandle - ) - { -- EFI_STATUS Status; -- EFI_TPL OldTpl; -- EFI_DHCP6_PROTOCOL *Dhcp6; -- DHCP6_SERVICE *Service; -- DHCP6_INSTANCE *Instance; -+ EFI_STATUS Status; -+ EFI_TPL OldTpl; -+ EFI_DHCP6_PROTOCOL *Dhcp6; -+ DHCP6_SERVICE *Service; -+ DHCP6_INSTANCE *Instance; - -- if (This == NULL || ChildHandle == NULL) { -+ if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; - } - -@@ -746,7 +735,7 @@ Dhcp6ServiceBindingDestroyChild ( - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiDhcp6ProtocolGuid, -- (VOID **) &Dhcp6, -+ (VOID **)&Dhcp6, - gDhcp6DriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c -index 8f8b2aab1e..933565a32d 100644 ---- a/NetworkPkg/DnsDxe/DnsDhcp.c -+++ b/NetworkPkg/DnsDxe/DnsDhcp.c -@@ -19,22 +19,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - VOID - DnsInitSeedPacket ( -- OUT EFI_DHCP4_PACKET *Seed, -- IN EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo -+ OUT EFI_DHCP4_PACKET *Seed, -+ IN EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo - ) - { -- EFI_DHCP4_HEADER *Header; -+ EFI_DHCP4_HEADER *Header; - - // - // Get IfType and HwAddressSize from SNP mode data. - // -- Seed->Size = sizeof (EFI_DHCP4_PACKET); -- Seed->Length = sizeof (Seed->Dhcp4); -- Header = &Seed->Dhcp4.Header; -+ Seed->Size = sizeof (EFI_DHCP4_PACKET); -+ Seed->Length = sizeof (Seed->Dhcp4); -+ Header = &Seed->Dhcp4.Header; - ZeroMem (Header, sizeof (EFI_DHCP4_HEADER)); -- Header->OpCode = DHCP4_OPCODE_REQUEST; -- Header->HwType = InterfaceInfo->IfType; -- Header->HwAddrLen = (UINT8) InterfaceInfo->HwAddressSize; -+ Header->OpCode = DHCP4_OPCODE_REQUEST; -+ Header->HwType = InterfaceInfo->IfType; -+ Header->HwAddrLen = (UINT8)InterfaceInfo->HwAddressSize; - CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen); - - Seed->Dhcp4.Magik = DHCP4_MAGIC; -@@ -56,10 +56,10 @@ DhcpCommonNotify ( - ) - { - if ((Event == NULL) || (Context == NULL)) { -- return ; -+ return; - } - -- *((BOOLEAN *) Context) = TRUE; -+ *((BOOLEAN *)Context) = TRUE; - } - - /** -@@ -77,26 +77,26 @@ DhcpCommonNotify ( - **/ - EFI_STATUS - ParseDhcp4Ack ( -- IN EFI_DHCP4_PROTOCOL *Dhcp4, -- IN EFI_DHCP4_PACKET *Packet, -- IN DNS4_SERVER_INFOR *DnsServerInfor -+ IN EFI_DHCP4_PROTOCOL *Dhcp4, -+ IN EFI_DHCP4_PACKET *Packet, -+ IN DNS4_SERVER_INFOR *DnsServerInfor - ) - { -- EFI_STATUS Status; -- UINT32 OptionCount; -- EFI_DHCP4_PACKET_OPTION **OptionList; -- UINT32 ServerCount; -- EFI_IPv4_ADDRESS *ServerList; -- UINT32 Index; -- UINT32 Count; -+ EFI_STATUS Status; -+ UINT32 OptionCount; -+ EFI_DHCP4_PACKET_OPTION **OptionList; -+ UINT32 ServerCount; -+ EFI_IPv4_ADDRESS *ServerList; -+ UINT32 Index; -+ UINT32 Count; - - ServerCount = 0; -- ServerList = NULL; -+ ServerList = NULL; - - OptionCount = 0; - OptionList = NULL; - -- Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList); -+ Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList); - if (Status != EFI_BUFFER_TOO_SMALL) { - return EFI_DEVICE_ERROR; - } -@@ -119,19 +119,18 @@ ParseDhcp4Ack ( - // Get DNS server addresses - // - if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) { -- - if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) { - Status = EFI_DEVICE_ERROR; - break; - } - - ServerCount = OptionList[Index]->Length/4; -- ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv4_ADDRESS)); -+ ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv4_ADDRESS)); - if (ServerList == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- for (Count=0; Count < ServerCount; Count++) { -+ for (Count = 0; Count < ServerCount; Count++) { - CopyMem (ServerList + Count, &OptionList[Index]->Data[4 * Count], sizeof (EFI_IPv4_ADDRESS)); - } - -@@ -167,25 +166,25 @@ ParseDhcp4Ack ( - EFI_STATUS - EFIAPI - ParseDhcp6Ack ( -- IN EFI_DHCP6_PROTOCOL *This, -- IN VOID *Context, -- IN EFI_DHCP6_PACKET *Packet -+ IN EFI_DHCP6_PROTOCOL *This, -+ IN VOID *Context, -+ IN EFI_DHCP6_PACKET *Packet - ) - { -- EFI_STATUS Status; -- UINT32 OptionCount; -- EFI_DHCP6_PACKET_OPTION **OptionList; -- DNS6_SERVER_INFOR *DnsServerInfor; -- UINT32 ServerCount; -- EFI_IPv6_ADDRESS *ServerList; -- UINT32 Index; -- UINT32 Count; -+ EFI_STATUS Status; -+ UINT32 OptionCount; -+ EFI_DHCP6_PACKET_OPTION **OptionList; -+ DNS6_SERVER_INFOR *DnsServerInfor; -+ UINT32 ServerCount; -+ EFI_IPv6_ADDRESS *ServerList; -+ UINT32 Index; -+ UINT32 Count; - - OptionCount = 0; - ServerCount = 0; - ServerList = NULL; - -- Status = This->Parse (This, Packet, &OptionCount, NULL); -+ Status = This->Parse (This, Packet, &OptionCount, NULL); - if (Status != EFI_BUFFER_TOO_SMALL) { - return EFI_DEVICE_ERROR; - } -@@ -201,7 +200,7 @@ ParseDhcp6Ack ( - return EFI_DEVICE_ERROR; - } - -- DnsServerInfor = (DNS6_SERVER_INFOR *) Context; -+ DnsServerInfor = (DNS6_SERVER_INFOR *)Context; - - for (Index = 0; Index < OptionCount; Index++) { - OptionList[Index]->OpCode = NTOHS (OptionList[Index]->OpCode); -@@ -211,7 +210,6 @@ ParseDhcp6Ack ( - // Get DNS server addresses from this reply packet. - // - if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) { -- - if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) { - Status = EFI_DEVICE_ERROR; - gBS->FreePool (OptionList); -@@ -219,13 +217,13 @@ ParseDhcp6Ack ( - } - - ServerCount = OptionList[Index]->OpLen/16; -- ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv6_ADDRESS)); -+ ServerList = AllocatePool (ServerCount * sizeof (EFI_IPv6_ADDRESS)); - if (ServerList == NULL) { - gBS->FreePool (OptionList); - return EFI_OUT_OF_RESOURCES; - } - -- for (Count=0; Count < ServerCount; Count++) { -+ for (Count = 0; Count < ServerCount; Count++) { - CopyMem (ServerList + Count, &OptionList[Index]->Data[16 * Count], sizeof (EFI_IPv6_ADDRESS)); - } - -@@ -237,7 +235,6 @@ ParseDhcp6Ack ( - gBS->FreePool (OptionList); - - return Status; -- - } - - /** -@@ -255,47 +252,47 @@ ParseDhcp6Ack ( - **/ - EFI_STATUS - GetDns4ServerFromDhcp4 ( -- IN DNS_INSTANCE *Instance, -- OUT UINT32 *DnsServerCount, -- OUT EFI_IPv4_ADDRESS **DnsServerList -+ IN DNS_INSTANCE *Instance, -+ OUT UINT32 *DnsServerCount, -+ OUT EFI_IPv4_ADDRESS **DnsServerList - ) - { -- EFI_STATUS Status; -- EFI_HANDLE Image; -- EFI_HANDLE Controller; -- EFI_STATUS MediaStatus; -- EFI_HANDLE MnpChildHandle; -- EFI_MANAGED_NETWORK_PROTOCOL *Mnp; -- EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; -- EFI_HANDLE Dhcp4Handle; -- EFI_DHCP4_PROTOCOL *Dhcp4; -- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; -- UINTN DataSize; -- VOID *Data; -- EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo; -- EFI_DHCP4_PACKET SeedPacket; -- EFI_DHCP4_PACKET_OPTION *ParaList[2]; -- DNS4_SERVER_INFOR DnsServerInfor; -- -- EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token; -- BOOLEAN IsDone; -- UINTN Index; -- -- Image = Instance->Service->ImageHandle; -- Controller = Instance->Service->ControllerHandle; -- -- MnpChildHandle = NULL; -- Mnp = NULL; -- -- Dhcp4Handle = NULL; -- Dhcp4 = NULL; -- -- Ip4Config2 = NULL; -- DataSize = 0; -- Data = NULL; -- InterfaceInfo = NULL; -- -- ZeroMem ((UINT8 *) ParaList, sizeof (ParaList)); -+ EFI_STATUS Status; -+ EFI_HANDLE Image; -+ EFI_HANDLE Controller; -+ EFI_STATUS MediaStatus; -+ EFI_HANDLE MnpChildHandle; -+ EFI_MANAGED_NETWORK_PROTOCOL *Mnp; -+ EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData; -+ EFI_HANDLE Dhcp4Handle; -+ EFI_DHCP4_PROTOCOL *Dhcp4; -+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; -+ UINTN DataSize; -+ VOID *Data; -+ EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo; -+ EFI_DHCP4_PACKET SeedPacket; -+ EFI_DHCP4_PACKET_OPTION *ParaList[2]; -+ DNS4_SERVER_INFOR DnsServerInfor; -+ -+ EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token; -+ BOOLEAN IsDone; -+ UINTN Index; -+ -+ Image = Instance->Service->ImageHandle; -+ Controller = Instance->Service->ControllerHandle; -+ -+ MnpChildHandle = NULL; -+ Mnp = NULL; -+ -+ Dhcp4Handle = NULL; -+ Dhcp4 = NULL; -+ -+ Ip4Config2 = NULL; -+ DataSize = 0; -+ Data = NULL; -+ InterfaceInfo = NULL; -+ -+ ZeroMem ((UINT8 *)ParaList, sizeof (ParaList)); - - ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA)); - -@@ -332,7 +329,7 @@ GetDns4ServerFromDhcp4 ( - Status = gBS->OpenProtocol ( - MnpChildHandle, - &gEfiManagedNetworkProtocolGuid, -- (VOID **) &Mnp, -+ (VOID **)&Mnp, - Image, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -352,7 +349,7 @@ GetDns4ServerFromDhcp4 ( - MnpConfigData.EnableReceiveTimestamps = FALSE; - MnpConfigData.DisableBackgroundPolling = FALSE; - -- Status = Mnp->Configure(Mnp, &MnpConfigData); -+ Status = Mnp->Configure (Mnp, &MnpConfigData); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } -@@ -373,7 +370,7 @@ GetDns4ServerFromDhcp4 ( - Status = gBS->OpenProtocol ( - Dhcp4Handle, - &gEfiDhcp4ProtocolGuid, -- (VOID **) &Dhcp4, -+ (VOID **)&Dhcp4, - Image, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -385,13 +382,13 @@ GetDns4ServerFromDhcp4 ( - // - // Get Ip4Config2 instance info. - // -- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); -+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeInterfaceInfo, &DataSize, Data); -- if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) { -+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) { - goto ON_EXIT; - } - -@@ -470,7 +467,7 @@ GetDns4ServerFromDhcp4 ( - - Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0, NULL, 2, ParaList, &Token.Packet); - -- Token.Packet->Dhcp4.Header.Xid = HTONL(NET_RANDOM (NetRandomInitSeed ())); -+ Token.Packet->Dhcp4.Header.Xid = HTONL (NET_RANDOM (NetRandomInitSeed ())); - - Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)0x8000); - -@@ -601,10 +598,10 @@ ON_EXIT: - **/ - EFI_STATUS - GetDns6ServerFromDhcp6 ( -- IN EFI_HANDLE Image, -- IN EFI_HANDLE Controller, -- OUT UINT32 *DnsServerCount, -- OUT EFI_IPv6_ADDRESS **DnsServerList -+ IN EFI_HANDLE Image, -+ IN EFI_HANDLE Controller, -+ OUT UINT32 *DnsServerCount, -+ OUT EFI_IPv6_ADDRESS **DnsServerList - ) - { - EFI_HANDLE Dhcp6Handle; -@@ -651,7 +648,7 @@ GetDns6ServerFromDhcp6 ( - Status = gBS->OpenProtocol ( - Dhcp6Handle, - &gEfiDhcp6ProtocolGuid, -- (VOID **) &Dhcp6, -+ (VOID **)&Dhcp6, - Image, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -724,7 +721,7 @@ GetDns6ServerFromDhcp6 ( - } while (TimerStatus == EFI_NOT_READY); - } - -- *DnsServerList = DnsServerInfor.ServerList; -+ *DnsServerList = DnsServerInfor.ServerList; - - ON_EXIT: - -@@ -753,6 +750,4 @@ ON_EXIT: - ); - - return Status; -- - } -- -diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c -index 78a56f2b56..d311812800 100644 ---- a/NetworkPkg/DnsDxe/DnsImpl.c -+++ b/NetworkPkg/DnsDxe/DnsImpl.c -@@ -20,8 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - EFI_STATUS - Dns4RemoveTokenEntry ( -- IN NET_MAP *TokenMap, -- IN DNS4_TOKEN_ENTRY *TokenEntry -+ IN NET_MAP *TokenMap, -+ IN DNS4_TOKEN_ENTRY *TokenEntry - ) - { - NET_MAP_ITEM *Item; -@@ -29,7 +29,7 @@ Dns4RemoveTokenEntry ( - // - // Find the TokenEntry first. - // -- Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry); -+ Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry); - - if (Item != NULL) { - // -@@ -55,8 +55,8 @@ Dns4RemoveTokenEntry ( - **/ - EFI_STATUS - Dns6RemoveTokenEntry ( -- IN NET_MAP *TokenMap, -- IN DNS6_TOKEN_ENTRY *TokenEntry -+ IN NET_MAP *TokenMap, -+ IN DNS6_TOKEN_ENTRY *TokenEntry - ) - { - NET_MAP_ITEM *Item; -@@ -64,7 +64,7 @@ Dns6RemoveTokenEntry ( - // - // Find the TokenEntry first. - // -- Item = NetMapFindKey (TokenMap, (VOID *) TokenEntry); -+ Item = NetMapFindKey (TokenMap, (VOID *)TokenEntry); - - if (Item != NULL) { - // -@@ -102,9 +102,9 @@ Dns4CancelTokens ( - IN VOID *Arg OPTIONAL - ) - { -- DNS4_TOKEN_ENTRY *TokenEntry; -- NET_BUF *Packet; -- UDP_IO *UdpIo; -+ DNS4_TOKEN_ENTRY *TokenEntry; -+ NET_BUF *Packet; -+ UDP_IO *UdpIo; - - if ((Arg != NULL) && (Item->Key != Arg)) { - return EFI_SUCCESS; -@@ -115,8 +115,8 @@ Dns4CancelTokens ( - // If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in - // Item->Value. - // -- Packet = (NET_BUF *) (Item->Value); -- UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0])); -+ Packet = (NET_BUF *)(Item->Value); -+ UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0])); - - UdpIoCancelSentDatagram (UdpIo, Packet); - } -@@ -124,7 +124,7 @@ Dns4CancelTokens ( - // - // Remove TokenEntry from Dns4TxTokens. - // -- TokenEntry = (DNS4_TOKEN_ENTRY *) Item->Key; -+ TokenEntry = (DNS4_TOKEN_ENTRY *)Item->Key; - if (Dns4RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) { - TokenEntry->Token->Status = EFI_ABORTED; - gBS->SignalEvent (TokenEntry->Token->Event); -@@ -162,9 +162,9 @@ Dns6CancelTokens ( - IN VOID *Arg OPTIONAL - ) - { -- DNS6_TOKEN_ENTRY *TokenEntry; -- NET_BUF *Packet; -- UDP_IO *UdpIo; -+ DNS6_TOKEN_ENTRY *TokenEntry; -+ NET_BUF *Packet; -+ UDP_IO *UdpIo; - - if ((Arg != NULL) && (Item->Key != Arg)) { - return EFI_SUCCESS; -@@ -175,8 +175,8 @@ Dns6CancelTokens ( - // If the TokenEntry is a transmit TokenEntry, the corresponding Packet is recorded in - // Item->Value. - // -- Packet = (NET_BUF *) (Item->Value); -- UdpIo = (UDP_IO *) (*((UINTN *) &Packet->ProtoData[0])); -+ Packet = (NET_BUF *)(Item->Value); -+ UdpIo = (UDP_IO *)(*((UINTN *)&Packet->ProtoData[0])); - - UdpIoCancelSentDatagram (UdpIo, Packet); - } -@@ -184,7 +184,7 @@ Dns6CancelTokens ( - // - // Remove TokenEntry from Dns6TxTokens. - // -- TokenEntry = (DNS6_TOKEN_ENTRY *) Item->Key; -+ TokenEntry = (DNS6_TOKEN_ENTRY *)Item->Key; - if (Dns6RemoveTokenEntry (Map, TokenEntry) == EFI_SUCCESS) { - TokenEntry->Token->Status = EFI_ABORTED; - gBS->SignalEvent (TokenEntry->Token->Event); -@@ -212,18 +212,18 @@ Dns6CancelTokens ( - EFI_STATUS - EFIAPI - GetDns4TokenEntry ( -- IN NET_MAP *TokensMap, -- IN EFI_DNS4_COMPLETION_TOKEN *Token, -- OUT DNS4_TOKEN_ENTRY **TokenEntry -+ IN NET_MAP *TokensMap, -+ IN EFI_DNS4_COMPLETION_TOKEN *Token, -+ OUT DNS4_TOKEN_ENTRY **TokenEntry - ) - { -- LIST_ENTRY *Entry; -+ LIST_ENTRY *Entry; - -- NET_MAP_ITEM *Item; -+ NET_MAP_ITEM *Item; - - NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { -- Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -- *TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key); -+ Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -+ *TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key); - if ((*TokenEntry)->Token == Token) { - return EFI_SUCCESS; - } -@@ -248,24 +248,24 @@ GetDns4TokenEntry ( - EFI_STATUS - EFIAPI - GetDns6TokenEntry ( -- IN NET_MAP *TokensMap, -- IN EFI_DNS6_COMPLETION_TOKEN *Token, -- OUT DNS6_TOKEN_ENTRY **TokenEntry -+ IN NET_MAP *TokensMap, -+ IN EFI_DNS6_COMPLETION_TOKEN *Token, -+ OUT DNS6_TOKEN_ENTRY **TokenEntry - ) - { -- LIST_ENTRY *Entry; -+ LIST_ENTRY *Entry; - -- NET_MAP_ITEM *Item; -+ NET_MAP_ITEM *Item; - - NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { -- Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -- *TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key); -+ Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -+ *TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key); - if ((*TokenEntry)->Token == Token) { - return EFI_SUCCESS; - } - } - -- *TokenEntry =NULL; -+ *TokenEntry = NULL; - - return EFI_NOT_FOUND; - } -@@ -293,7 +293,7 @@ Dns4InstanceCancelToken ( - - TokenEntry = NULL; - -- if(Token != NULL ) { -+ if (Token != NULL ) { - Status = GetDns4TokenEntry (&Instance->Dns4TxTokens, Token, &TokenEntry); - if (EFI_ERROR (Status)) { - return Status; -@@ -313,8 +313,9 @@ Dns4InstanceCancelToken ( - // the Dns4TxTokens and returns success. - // - if (NetMapIsEmpty (&Instance->Dns4TxTokens)) { -- Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4); -+ Instance->UdpIo->Protocol.Udp4->Cancel (Instance->UdpIo->Protocol.Udp4, &Instance->UdpIo->RecvRequest->Token.Udp4); - } -+ - return EFI_SUCCESS; - } - -@@ -350,7 +351,7 @@ Dns6InstanceCancelToken ( - - TokenEntry = NULL; - -- if(Token != NULL ) { -+ if (Token != NULL ) { - Status = GetDns6TokenEntry (&Instance->Dns6TxTokens, Token, &TokenEntry); - if (EFI_ERROR (Status)) { - return Status; -@@ -370,8 +371,9 @@ Dns6InstanceCancelToken ( - // the Dns6TxTokens and returns success. - // - if (NetMapIsEmpty (&Instance->Dns6TxTokens)) { -- Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6); -+ Instance->UdpIo->Protocol.Udp6->Cancel (Instance->UdpIo->Protocol.Udp6, &Instance->UdpIo->RecvRequest->Token.Udp6); - } -+ - return EFI_SUCCESS; - } - -@@ -437,8 +439,8 @@ Dns4CopyConfigure ( - IN EFI_DNS4_CONFIG_DATA *Src - ) - { -- UINTN Len; -- UINT32 Index; -+ UINTN Len; -+ UINT32 Index; - - CopyMem (Dst, Src, sizeof (*Dst)); - Dst->DnsServerList = NULL; -@@ -479,8 +481,8 @@ Dns6CopyConfigure ( - IN EFI_DNS6_CONFIG_DATA *Src - ) - { -- UINTN Len; -- UINT32 Index; -+ UINTN Len; -+ UINT32 Index; - - CopyMem (Dst, Src, sizeof (*Dst)); - Dst->DnsServerList = NULL; -@@ -513,7 +515,7 @@ Dns6CopyConfigure ( - VOID - EFIAPI - DnsDummyExtFree ( -- IN VOID *Arg -+ IN VOID *Arg - ) - { - } -@@ -535,15 +537,15 @@ DnsDummyExtFree ( - **/ - BOOLEAN - Dns4GetMapping ( -- IN DNS_INSTANCE *Instance, -- IN UDP_IO *UdpIo, -- IN EFI_UDP4_CONFIG_DATA *UdpCfgData -+ IN DNS_INSTANCE *Instance, -+ IN UDP_IO *UdpIo, -+ IN EFI_UDP4_CONFIG_DATA *UdpCfgData - ) - { -- DNS_SERVICE *Service; -- EFI_IP4_MODE_DATA Ip4Mode; -- EFI_UDP4_PROTOCOL *Udp; -- EFI_STATUS Status; -+ DNS_SERVICE *Service; -+ EFI_IP4_MODE_DATA Ip4Mode; -+ EFI_UDP4_PROTOCOL *Udp; -+ EFI_STATUS Status; - - ASSERT (Instance->Dns4CfgData.UseDefaultSetting); - -@@ -563,10 +565,10 @@ Dns4GetMapping ( - Udp->Poll (Udp); - - if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) && -- Ip4Mode.IsConfigured) { -- -+ Ip4Mode.IsConfigured) -+ { - Udp->Configure (Udp, NULL); -- return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS); -+ return (BOOLEAN)(Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS); - } - } - -@@ -587,15 +589,15 @@ Dns4GetMapping ( - **/ - BOOLEAN - Dns6GetMapping ( -- IN DNS_INSTANCE *Instance, -- IN UDP_IO *UdpIo, -- IN EFI_UDP6_CONFIG_DATA *UdpCfgData -+ IN DNS_INSTANCE *Instance, -+ IN UDP_IO *UdpIo, -+ IN EFI_UDP6_CONFIG_DATA *UdpCfgData - ) - { -- DNS_SERVICE *Service; -- EFI_IP6_MODE_DATA Ip6Mode; -- EFI_UDP6_PROTOCOL *Udp; -- EFI_STATUS Status; -+ DNS_SERVICE *Service; -+ EFI_IP6_MODE_DATA Ip6Mode; -+ EFI_UDP6_PROTOCOL *Udp; -+ EFI_STATUS Status; - - Service = Instance->Service; - Udp = UdpIo->Protocol.Udp6; -@@ -661,13 +663,13 @@ Dns6GetMapping ( - **/ - EFI_STATUS - Dns4ConfigUdp ( -- IN DNS_INSTANCE *Instance, -- IN UDP_IO *UdpIo -+ IN DNS_INSTANCE *Instance, -+ IN UDP_IO *UdpIo - ) - { -- EFI_DNS4_CONFIG_DATA *Config; -- EFI_UDP4_CONFIG_DATA UdpConfig; -- EFI_STATUS Status; -+ EFI_DNS4_CONFIG_DATA *Config; -+ EFI_UDP4_CONFIG_DATA UdpConfig; -+ EFI_STATUS Status; - - Config = &Instance->Dns4CfgData; - -@@ -709,13 +711,13 @@ Dns4ConfigUdp ( - **/ - EFI_STATUS - Dns6ConfigUdp ( -- IN DNS_INSTANCE *Instance, -- IN UDP_IO *UdpIo -+ IN DNS_INSTANCE *Instance, -+ IN UDP_IO *UdpIo - ) - { -- EFI_DNS6_CONFIG_DATA *Config; -- EFI_UDP6_CONFIG_DATA UdpConfig; -- EFI_STATUS Status; -+ EFI_DNS6_CONFIG_DATA *Config; -+ EFI_UDP6_CONFIG_DATA UdpConfig; -+ EFI_STATUS Status; - - Config = &Instance->Dns6CfgData; - -@@ -757,16 +759,16 @@ Dns6ConfigUdp ( - EFI_STATUS - EFIAPI - UpdateDns4Cache ( -- IN LIST_ENTRY *Dns4CacheList, -- IN BOOLEAN DeleteFlag, -- IN BOOLEAN Override, -- IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry -+ IN LIST_ENTRY *Dns4CacheList, -+ IN BOOLEAN DeleteFlag, -+ IN BOOLEAN Override, -+ IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry - ) - { -- DNS4_CACHE *NewDnsCache; -- DNS4_CACHE *Item; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ DNS4_CACHE *NewDnsCache; -+ DNS4_CACHE *Item; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - - NewDnsCache = NULL; - Item = NULL; -@@ -776,8 +778,9 @@ UpdateDns4Cache ( - // - NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns4CacheList) { - Item = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink); -- if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \ -- CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0) { -+ if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \ -+ (CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv4_ADDRESS)) == 0)) -+ { - // - // This is the Dns cache entry - // -@@ -855,16 +858,16 @@ UpdateDns4Cache ( - EFI_STATUS - EFIAPI - UpdateDns6Cache ( -- IN LIST_ENTRY *Dns6CacheList, -- IN BOOLEAN DeleteFlag, -- IN BOOLEAN Override, -- IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry -+ IN LIST_ENTRY *Dns6CacheList, -+ IN BOOLEAN DeleteFlag, -+ IN BOOLEAN Override, -+ IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry - ) - { -- DNS6_CACHE *NewDnsCache; -- DNS6_CACHE *Item; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ DNS6_CACHE *NewDnsCache; -+ DNS6_CACHE *Item; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - - NewDnsCache = NULL; - Item = NULL; -@@ -874,8 +877,9 @@ UpdateDns6Cache ( - // - NET_LIST_FOR_EACH_SAFE (Entry, Next, Dns6CacheList) { - Item = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink); -- if (StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0 && \ -- CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0) { -+ if ((StrCmp (DnsCacheEntry.HostName, Item->DnsCache.HostName) == 0) && \ -+ (CompareMem (DnsCacheEntry.IpAddress, Item->DnsCache.IpAddress, sizeof (EFI_IPv6_ADDRESS)) == 0)) -+ { - // - // This is the Dns cache entry - // -@@ -950,14 +954,14 @@ UpdateDns6Cache ( - EFI_STATUS - EFIAPI - AddDns4ServerIp ( -- IN LIST_ENTRY *Dns4ServerList, -- IN EFI_IPv4_ADDRESS ServerIp -+ IN LIST_ENTRY *Dns4ServerList, -+ IN EFI_IPv4_ADDRESS ServerIp - ) - { -- DNS4_SERVER_IP *NewServerIp; -- DNS4_SERVER_IP *Item; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ DNS4_SERVER_IP *NewServerIp; -+ DNS4_SERVER_IP *Item; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - - NewServerIp = NULL; - Item = NULL; -@@ -1005,14 +1009,14 @@ AddDns4ServerIp ( - EFI_STATUS - EFIAPI - AddDns6ServerIp ( -- IN LIST_ENTRY *Dns6ServerList, -- IN EFI_IPv6_ADDRESS ServerIp -+ IN LIST_ENTRY *Dns6ServerList, -+ IN EFI_IPv6_ADDRESS ServerIp - ) - { -- DNS6_SERVER_IP *NewServerIp; -- DNS6_SERVER_IP *Item; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ DNS6_SERVER_IP *NewServerIp; -+ DNS6_SERVER_IP *Item; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - - NewServerIp = NULL; - Item = NULL; -@@ -1062,37 +1066,37 @@ AddDns6ServerIp ( - **/ - BOOLEAN - IsValidDnsResponse ( -- IN NET_MAP *TokensMap, -- IN UINT16 Identification, -- IN UINT16 Type, -- IN UINT16 Class, -- OUT NET_MAP_ITEM **Item -+ IN NET_MAP *TokensMap, -+ IN UINT16 Identification, -+ IN UINT16 Type, -+ IN UINT16 Class, -+ OUT NET_MAP_ITEM **Item - ) - { -- LIST_ENTRY *Entry; -+ LIST_ENTRY *Entry; - -- NET_BUF *Packet; -- UINT8 *TxString; -- DNS_HEADER *DnsHeader; -- CHAR8 *QueryName; -- DNS_QUERY_SECTION *QuerySection; -+ NET_BUF *Packet; -+ UINT8 *TxString; -+ DNS_HEADER *DnsHeader; -+ CHAR8 *QueryName; -+ DNS_QUERY_SECTION *QuerySection; - - NET_LIST_FOR_EACH (Entry, &TokensMap->Used) { -- *Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -- Packet = (NET_BUF *) ((*Item)->Value); -+ *Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); -+ Packet = (NET_BUF *)((*Item)->Value); - if (Packet == NULL) { -- - continue; - } else { - TxString = NetbufGetByte (Packet, 0, NULL); - ASSERT (TxString != NULL); -- DnsHeader = (DNS_HEADER *) TxString; -- QueryName = (CHAR8 *) (TxString + sizeof (*DnsHeader)); -- QuerySection = (DNS_QUERY_SECTION *) (QueryName + AsciiStrLen (QueryName) + 1); -- -- if (NTOHS (DnsHeader->Identification) == Identification && -- NTOHS (QuerySection->Type) == Type && -- NTOHS (QuerySection->Class) == Class) { -+ DnsHeader = (DNS_HEADER *)TxString; -+ QueryName = (CHAR8 *)(TxString + sizeof (*DnsHeader)); -+ QuerySection = (DNS_QUERY_SECTION *)(QueryName + AsciiStrLen (QueryName) + 1); -+ -+ if ((NTOHS (DnsHeader->Identification) == Identification) && -+ (NTOHS (QuerySection->Type) == Type) && -+ (NTOHS (QuerySection->Class) == Class)) -+ { - return TRUE; - } - } -@@ -1117,33 +1121,33 @@ IsValidDnsResponse ( - **/ - EFI_STATUS - ParseDnsResponse ( -- IN OUT DNS_INSTANCE *Instance, -- IN UINT8 *RxString, -- IN UINT32 Length, -- OUT BOOLEAN *Completed -+ IN OUT DNS_INSTANCE *Instance, -+ IN UINT8 *RxString, -+ IN UINT32 Length, -+ OUT BOOLEAN *Completed - ) - { -- DNS_HEADER *DnsHeader; -+ DNS_HEADER *DnsHeader; - -- CHAR8 *QueryName; -- UINT32 QueryNameLen; -- DNS_QUERY_SECTION *QuerySection; -+ CHAR8 *QueryName; -+ UINT32 QueryNameLen; -+ DNS_QUERY_SECTION *QuerySection; - -- CHAR8 *AnswerName; -- DNS_ANSWER_SECTION *AnswerSection; -- UINT8 *AnswerData; -+ CHAR8 *AnswerName; -+ DNS_ANSWER_SECTION *AnswerSection; -+ UINT8 *AnswerData; - -- NET_MAP_ITEM *Item; -- DNS4_TOKEN_ENTRY *Dns4TokenEntry; -- DNS6_TOKEN_ENTRY *Dns6TokenEntry; -+ NET_MAP_ITEM *Item; -+ DNS4_TOKEN_ENTRY *Dns4TokenEntry; -+ DNS6_TOKEN_ENTRY *Dns6TokenEntry; - -- UINT32 IpCount; -- UINT32 RRCount; -- UINT32 AnswerSectionNum; -- UINT32 CNameTtl; -+ UINT32 IpCount; -+ UINT32 RRCount; -+ UINT32 AnswerSectionNum; -+ UINT32 CNameTtl; - -- EFI_IPv4_ADDRESS *HostAddr4; -- EFI_IPv6_ADDRESS *HostAddr6; -+ EFI_IPv4_ADDRESS *HostAddr4; -+ EFI_IPv6_ADDRESS *HostAddr6; - - EFI_DNS4_CACHE_ENTRY *Dns4CacheEntry; - EFI_DNS6_CACHE_ENTRY *Dns6CacheEntry; -@@ -1151,32 +1155,32 @@ ParseDnsResponse ( - DNS_RESOURCE_RECORD *Dns4RR; - DNS6_RESOURCE_RECORD *Dns6RR; - -- EFI_STATUS Status; -- UINT32 RemainingLength; -+ EFI_STATUS Status; -+ UINT32 RemainingLength; - -- EFI_TPL OldTpl; -+ EFI_TPL OldTpl; - -- Item = NULL; -- Dns4TokenEntry = NULL; -- Dns6TokenEntry = NULL; -+ Item = NULL; -+ Dns4TokenEntry = NULL; -+ Dns6TokenEntry = NULL; - - IpCount = 0; - RRCount = 0; - AnswerSectionNum = 0; - CNameTtl = 0; - -- HostAddr4 = NULL; -- HostAddr6 = NULL; -+ HostAddr4 = NULL; -+ HostAddr6 = NULL; - -- Dns4CacheEntry = NULL; -- Dns6CacheEntry = NULL; -+ Dns4CacheEntry = NULL; -+ Dns6CacheEntry = NULL; - -- Dns4RR = NULL; -- Dns6RR = NULL; -+ Dns4RR = NULL; -+ Dns6RR = NULL; - -- *Completed = TRUE; -- Status = EFI_SUCCESS; -- RemainingLength = Length; -+ *Completed = TRUE; -+ Status = EFI_SUCCESS; -+ RemainingLength = Length; - - // - // Check whether the remaining packet length is available or not. -@@ -1191,14 +1195,14 @@ ParseDnsResponse ( - // - // Get header - // -- DnsHeader = (DNS_HEADER *) RxString; -+ DnsHeader = (DNS_HEADER *)RxString; - - DnsHeader->Identification = NTOHS (DnsHeader->Identification); -- DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16); -- DnsHeader->QuestionsNum = NTOHS (DnsHeader->QuestionsNum); -- DnsHeader->AnswersNum = NTOHS (DnsHeader->AnswersNum); -- DnsHeader->AuthorityNum = NTOHS (DnsHeader->AuthorityNum); -- DnsHeader->AditionalNum = NTOHS (DnsHeader->AditionalNum); -+ DnsHeader->Flags.Uint16 = NTOHS (DnsHeader->Flags.Uint16); -+ DnsHeader->QuestionsNum = NTOHS (DnsHeader->QuestionsNum); -+ DnsHeader->AnswersNum = NTOHS (DnsHeader->AnswersNum); -+ DnsHeader->AuthorityNum = NTOHS (DnsHeader->AuthorityNum); -+ DnsHeader->AditionalNum = NTOHS (DnsHeader->AditionalNum); - - // - // There is always one QuestionsNum in DNS message. The capability to handle more -@@ -1212,9 +1216,9 @@ ParseDnsResponse ( - // - // Get Query name - // -- QueryName = (CHAR8 *) (RxString + sizeof (*DnsHeader)); -+ QueryName = (CHAR8 *)(RxString + sizeof (*DnsHeader)); - -- QueryNameLen = (UINT32) AsciiStrLen (QueryName) + 1; -+ QueryNameLen = (UINT32)AsciiStrLen (QueryName) + 1; - - // - // Check whether the remaining packet length is available or not. -@@ -1229,8 +1233,8 @@ ParseDnsResponse ( - // - // Get query section - // -- QuerySection = (DNS_QUERY_SECTION *) (QueryName + QueryNameLen); -- QuerySection->Type = NTOHS (QuerySection->Type); -+ QuerySection = (DNS_QUERY_SECTION *)(QueryName + QueryNameLen); -+ QuerySection->Type = NTOHS (QuerySection->Type); - QuerySection->Class = NTOHS (QuerySection->Class); - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); -@@ -1245,13 +1249,15 @@ ParseDnsResponse ( - QuerySection->Type, - QuerySection->Class, - &Item -- )) { -+ )) -+ { - *Completed = FALSE; -- Status = EFI_ABORTED; -+ Status = EFI_ABORTED; - goto ON_EXIT; - } -+ - ASSERT (Item != NULL); -- Dns4TokenEntry = (DNS4_TOKEN_ENTRY *) (Item->Key); -+ Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(Item->Key); - } else { - if (!IsValidDnsResponse ( - &Instance->Dns6TxTokens, -@@ -1259,20 +1265,23 @@ ParseDnsResponse ( - QuerySection->Type, - QuerySection->Class, - &Item -- )) { -+ )) -+ { - *Completed = FALSE; -- Status = EFI_ABORTED; -+ Status = EFI_ABORTED; - goto ON_EXIT; - } -+ - ASSERT (Item != NULL); -- Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (Item->Key); -+ Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(Item->Key); - } - - // - // Continue Check Some Errors. - // -- if (DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR || DnsHeader->AnswersNum < 1 || \ -- DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE) { -+ if ((DnsHeader->Flags.Bits.RCode != DNS_FLAGS_RCODE_NO_ERROR) || (DnsHeader->AnswersNum < 1) || \ -+ (DnsHeader->Flags.Bits.QR != DNS_FLAGS_QR_RESPONSE)) -+ { - // - // The domain name referenced in the query does not exist. - // -@@ -1300,6 +1309,7 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - Dns4TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD)); - if (Dns4TokenEntry->Token->RspData.GLookupData->RRList == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -1315,6 +1325,7 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - Dns4TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv4_ADDRESS)); - if (Dns4TokenEntry->Token->RspData.H2AData->IpList == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -1337,6 +1348,7 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - Dns6TokenEntry->Token->RspData.GLookupData->RRList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (DNS_RESOURCE_RECORD)); - if (Dns6TokenEntry->Token->RspData.GLookupData->RRList == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -1352,6 +1364,7 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - Dns6TokenEntry->Token->RspData.H2AData->IpList = AllocateZeroPool (DnsHeader->AnswersNum * sizeof (EFI_IPv6_ADDRESS)); - if (Dns6TokenEntry->Token->RspData.H2AData->IpList == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -1369,7 +1382,7 @@ ParseDnsResponse ( - // - // Get Answer name - // -- AnswerName = (CHAR8 *) QuerySection + sizeof (*QuerySection); -+ AnswerName = (CHAR8 *)QuerySection + sizeof (*QuerySection); - - // - // Processing AnswerSection. -@@ -1380,7 +1393,7 @@ ParseDnsResponse ( - // - if (RemainingLength <= sizeof (UINT16) + sizeof (DNS_ANSWER_SECTION)) { - *Completed = FALSE; -- Status = EFI_ABORTED; -+ Status = EFI_ABORTED; - goto ON_EXIT; - } else { - RemainingLength -= (sizeof (UINT16) + sizeof (DNS_ANSWER_SECTION)); -@@ -1389,7 +1402,7 @@ ParseDnsResponse ( - // - // Answer name should be PTR, else EFI_UNSUPPORTED returned. - // -- if ((*(UINT8 *) AnswerName & 0xC0) != 0xC0) { -+ if ((*(UINT8 *)AnswerName & 0xC0) != 0xC0) { - Status = EFI_UNSUPPORTED; - goto ON_EXIT; - } -@@ -1397,10 +1410,10 @@ ParseDnsResponse ( - // - // Get Answer section. - // -- AnswerSection = (DNS_ANSWER_SECTION *) (AnswerName + sizeof (UINT16)); -- AnswerSection->Type = NTOHS (AnswerSection->Type); -- AnswerSection->Class = NTOHS (AnswerSection->Class); -- AnswerSection->Ttl = NTOHL (AnswerSection->Ttl); -+ AnswerSection = (DNS_ANSWER_SECTION *)(AnswerName + sizeof (UINT16)); -+ AnswerSection->Type = NTOHS (AnswerSection->Type); -+ AnswerSection->Class = NTOHS (AnswerSection->Class); -+ AnswerSection->Ttl = NTOHL (AnswerSection->Ttl); - AnswerSection->DataLength = NTOHS (AnswerSection->DataLength); - - // -@@ -1408,7 +1421,7 @@ ParseDnsResponse ( - // - if (RemainingLength < AnswerSection->DataLength) { - *Completed = FALSE; -- Status = EFI_ABORTED; -+ Status = EFI_ABORTED; - goto ON_EXIT; - } else { - RemainingLength -= AnswerSection->DataLength; -@@ -1417,9 +1430,9 @@ ParseDnsResponse ( - // - // Check whether it's the GeneralLookUp querying. - // -- if (Instance->Service->IpVersion == IP_VERSION_4 && Dns4TokenEntry->GeneralLookUp) { -- Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList; -- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); -+ if ((Instance->Service->IpVersion == IP_VERSION_4) && Dns4TokenEntry->GeneralLookUp) { -+ Dns4RR = Dns4TokenEntry->Token->RspData.GLookupData->RRList; -+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection); - - // - // Fill the ResourceRecord. -@@ -1429,23 +1442,25 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - CopyMem (Dns4RR[RRCount].QName, QueryName, AsciiStrLen (QueryName)); -- Dns4RR[RRCount].QType = AnswerSection->Type; -- Dns4RR[RRCount].QClass = AnswerSection->Class; -- Dns4RR[RRCount].TTL = AnswerSection->Ttl; -+ Dns4RR[RRCount].QType = AnswerSection->Type; -+ Dns4RR[RRCount].QClass = AnswerSection->Class; -+ Dns4RR[RRCount].TTL = AnswerSection->Ttl; - Dns4RR[RRCount].DataLength = AnswerSection->DataLength; -- Dns4RR[RRCount].RData = AllocateZeroPool (Dns4RR[RRCount].DataLength); -+ Dns4RR[RRCount].RData = AllocateZeroPool (Dns4RR[RRCount].DataLength); - if (Dns4RR[RRCount].RData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - CopyMem (Dns4RR[RRCount].RData, AnswerData, Dns4RR[RRCount].DataLength); - -- RRCount ++; -+ RRCount++; - Status = EFI_SUCCESS; -- } else if (Instance->Service->IpVersion == IP_VERSION_6 && Dns6TokenEntry->GeneralLookUp) { -- Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList; -- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); -+ } else if ((Instance->Service->IpVersion == IP_VERSION_6) && Dns6TokenEntry->GeneralLookUp) { -+ Dns6RR = Dns6TokenEntry->Token->RspData.GLookupData->RRList; -+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection); - - // - // Fill the ResourceRecord. -@@ -1455,19 +1470,21 @@ ParseDnsResponse ( - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - CopyMem (Dns6RR[RRCount].QName, QueryName, AsciiStrLen (QueryName)); -- Dns6RR[RRCount].QType = AnswerSection->Type; -- Dns6RR[RRCount].QClass = AnswerSection->Class; -- Dns6RR[RRCount].TTL = AnswerSection->Ttl; -+ Dns6RR[RRCount].QType = AnswerSection->Type; -+ Dns6RR[RRCount].QClass = AnswerSection->Class; -+ Dns6RR[RRCount].TTL = AnswerSection->Ttl; - Dns6RR[RRCount].DataLength = AnswerSection->DataLength; -- Dns6RR[RRCount].RData = AllocateZeroPool (Dns6RR[RRCount].DataLength); -+ Dns6RR[RRCount].RData = AllocateZeroPool (Dns6RR[RRCount].DataLength); - if (Dns6RR[RRCount].RData == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } -+ - CopyMem (Dns6RR[RRCount].RData, AnswerData, Dns6RR[RRCount].DataLength); - -- RRCount ++; -+ RRCount++; - Status = EFI_SUCCESS; - } else { - // -@@ -1475,143 +1492,149 @@ ParseDnsResponse ( - // Check the Query type, parse the response packet. - // - switch (AnswerSection->Type) { -- case DNS_TYPE_A: -- // -- // This is address entry, get Data. -- // -- ASSERT (Dns4TokenEntry != NULL); -+ case DNS_TYPE_A: -+ // -+ // This is address entry, get Data. -+ // -+ ASSERT (Dns4TokenEntry != NULL); - -- if (AnswerSection->DataLength != 4) { -- Status = EFI_ABORTED; -- goto ON_EXIT; -- } -+ if (AnswerSection->DataLength != 4) { -+ Status = EFI_ABORTED; -+ goto ON_EXIT; -+ } - -- HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList; -- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); -- CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS)); -+ HostAddr4 = Dns4TokenEntry->Token->RspData.H2AData->IpList; -+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection); -+ CopyMem (&HostAddr4[IpCount], AnswerData, sizeof (EFI_IPv4_ADDRESS)); - -- // -- // Allocate new CacheEntry pool to update DNS cache dynamically. -- // -- Dns4CacheEntry = AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY)); -- if (Dns4CacheEntry == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns4TokenEntry->QueryHostName) + 1)); -- if (Dns4CacheEntry->HostName == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- CopyMem (Dns4CacheEntry->HostName, Dns4TokenEntry->QueryHostName, 2 * (StrLen(Dns4TokenEntry->QueryHostName) + 1)); -- Dns4CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS)); -- if (Dns4CacheEntry->IpAddress == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- CopyMem (Dns4CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv4_ADDRESS)); -+ // -+ // Allocate new CacheEntry pool to update DNS cache dynamically. -+ // -+ Dns4CacheEntry = AllocateZeroPool (sizeof (EFI_DNS4_CACHE_ENTRY)); -+ if (Dns4CacheEntry == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- if (CNameTtl != 0 && AnswerSection->Ttl != 0) { -- Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); -- } else { -- Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); -- } -+ Dns4CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1)); -+ if (Dns4CacheEntry->HostName == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry); -+ CopyMem (Dns4CacheEntry->HostName, Dns4TokenEntry->QueryHostName, 2 * (StrLen (Dns4TokenEntry->QueryHostName) + 1)); -+ Dns4CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv4_ADDRESS)); -+ if (Dns4CacheEntry->IpAddress == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- // -- // Free allocated CacheEntry pool. -- // -- FreePool (Dns4CacheEntry->HostName); -- Dns4CacheEntry->HostName = NULL; -+ CopyMem (Dns4CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv4_ADDRESS)); - -- FreePool (Dns4CacheEntry->IpAddress); -- Dns4CacheEntry->IpAddress = NULL; -+ if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) { -+ Dns4CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); -+ } else { -+ Dns4CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); -+ } - -- FreePool (Dns4CacheEntry); -- Dns4CacheEntry = NULL; -+ UpdateDns4Cache (&mDriverData->Dns4CacheList, FALSE, TRUE, *Dns4CacheEntry); - -- IpCount ++; -- Status = EFI_SUCCESS; -- break; -- case DNS_TYPE_AAAA: -- // -- // This is address entry, get Data. -- // -- ASSERT (Dns6TokenEntry != NULL); -+ // -+ // Free allocated CacheEntry pool. -+ // -+ FreePool (Dns4CacheEntry->HostName); -+ Dns4CacheEntry->HostName = NULL; - -- if (AnswerSection->DataLength != 16) { -- Status = EFI_ABORTED; -- goto ON_EXIT; -- } -+ FreePool (Dns4CacheEntry->IpAddress); -+ Dns4CacheEntry->IpAddress = NULL; - -- HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList; -- AnswerData = (UINT8 *) AnswerSection + sizeof (*AnswerSection); -- CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS)); -+ FreePool (Dns4CacheEntry); -+ Dns4CacheEntry = NULL; - -- // -- // Allocate new CacheEntry pool to update DNS cache dynamically. -- // -- Dns6CacheEntry = AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY)); -- if (Dns6CacheEntry == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen(Dns6TokenEntry->QueryHostName) + 1)); -- if (Dns6CacheEntry->HostName == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- CopyMem (Dns6CacheEntry->HostName, Dns6TokenEntry->QueryHostName, 2 * (StrLen(Dns6TokenEntry->QueryHostName) + 1)); -- Dns6CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS)); -- if (Dns6CacheEntry->IpAddress == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto ON_EXIT; -- } -- CopyMem (Dns6CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv6_ADDRESS)); -+ IpCount++; -+ Status = EFI_SUCCESS; -+ break; -+ case DNS_TYPE_AAAA: -+ // -+ // This is address entry, get Data. -+ // -+ ASSERT (Dns6TokenEntry != NULL); - -- if (CNameTtl != 0 && AnswerSection->Ttl != 0) { -- Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); -- } else { -- Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); -- } -+ if (AnswerSection->DataLength != 16) { -+ Status = EFI_ABORTED; -+ goto ON_EXIT; -+ } - -- UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry); -+ HostAddr6 = Dns6TokenEntry->Token->RspData.H2AData->IpList; -+ AnswerData = (UINT8 *)AnswerSection + sizeof (*AnswerSection); -+ CopyMem (&HostAddr6[IpCount], AnswerData, sizeof (EFI_IPv6_ADDRESS)); - -- // -- // Free allocated CacheEntry pool. -- // -- FreePool (Dns6CacheEntry->HostName); -- Dns6CacheEntry->HostName = NULL; -+ // -+ // Allocate new CacheEntry pool to update DNS cache dynamically. -+ // -+ Dns6CacheEntry = AllocateZeroPool (sizeof (EFI_DNS6_CACHE_ENTRY)); -+ if (Dns6CacheEntry == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- FreePool (Dns6CacheEntry->IpAddress); -- Dns6CacheEntry->IpAddress = NULL; -+ Dns6CacheEntry->HostName = AllocateZeroPool (2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1)); -+ if (Dns6CacheEntry->HostName == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- FreePool (Dns6CacheEntry); -- Dns6CacheEntry = NULL; -+ CopyMem (Dns6CacheEntry->HostName, Dns6TokenEntry->QueryHostName, 2 * (StrLen (Dns6TokenEntry->QueryHostName) + 1)); -+ Dns6CacheEntry->IpAddress = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS)); -+ if (Dns6CacheEntry->IpAddress == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_EXIT; -+ } - -- IpCount ++; -- Status = EFI_SUCCESS; -- break; -- case DNS_TYPE_CNAME: -- // -- // According RFC 1034 - 3.6.2, if the query name is an alias, the name server will include the CNAME -- // record in the response and restart the query at the domain name specified in the data field of the -- // CNAME record. So, just record the TTL value of the CNAME, then skip to parse the next record. -- // -- CNameTtl = AnswerSection->Ttl; -- break; -- default: -- Status = EFI_UNSUPPORTED; -- goto ON_EXIT; -+ CopyMem (Dns6CacheEntry->IpAddress, AnswerData, sizeof (EFI_IPv6_ADDRESS)); -+ -+ if ((CNameTtl != 0) && (AnswerSection->Ttl != 0)) { -+ Dns6CacheEntry->Timeout = MIN (CNameTtl, AnswerSection->Ttl); -+ } else { -+ Dns6CacheEntry->Timeout = MAX (CNameTtl, AnswerSection->Ttl); -+ } -+ -+ UpdateDns6Cache (&mDriverData->Dns6CacheList, FALSE, TRUE, *Dns6CacheEntry); -+ -+ // -+ // Free allocated CacheEntry pool. -+ // -+ FreePool (Dns6CacheEntry->HostName); -+ Dns6CacheEntry->HostName = NULL; -+ -+ FreePool (Dns6CacheEntry->IpAddress); -+ Dns6CacheEntry->IpAddress = NULL; -+ -+ FreePool (Dns6CacheEntry); -+ Dns6CacheEntry = NULL; -+ -+ IpCount++; -+ Status = EFI_SUCCESS; -+ break; -+ case DNS_TYPE_CNAME: -+ // -+ // According RFC 1034 - 3.6.2, if the query name is an alias, the name server will include the CNAME -+ // record in the response and restart the query at the domain name specified in the data field of the -+ // CNAME record. So, just record the TTL value of the CNAME, then skip to parse the next record. -+ // -+ CNameTtl = AnswerSection->Ttl; -+ break; -+ default: -+ Status = EFI_UNSUPPORTED; -+ goto ON_EXIT; - } - } - - // - // Find next one - // -- AnswerName = (CHAR8 *) AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength; -- AnswerSectionNum ++; -+ AnswerName = (CHAR8 *)AnswerSection + sizeof (*AnswerSection) + AnswerSection->DataLength; -+ AnswerSectionNum++; - } - - if (Instance->Service->IpVersion == IP_VERSION_4) { -@@ -1646,8 +1669,8 @@ ON_COMPLETE: - // - // Parsing is complete, free the sending packet and signal Event here. - // -- if (Item != NULL && Item->Value != NULL) { -- NetbufFree ((NET_BUF *) (Item->Value)); -+ if ((Item != NULL) && (Item->Value != NULL)) { -+ NetbufFree ((NET_BUF *)(Item->Value)); - } - - if (Instance->Service->IpVersion == IP_VERSION_4) { -@@ -1678,7 +1701,7 @@ ON_EXIT: - if (Dns4TokenEntry->Token->RspData.GLookupData != NULL) { - if (Dns4TokenEntry->Token->RspData.GLookupData->RRList != NULL) { - while (RRCount != 0) { -- RRCount --; -+ RRCount--; - if (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) { - FreePool (Dns4TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName); - } -@@ -1694,7 +1717,7 @@ ON_EXIT: - FreePool (Dns4TokenEntry->Token->RspData.GLookupData); - } - } else { -- if (QuerySection->Type == DNS_TYPE_A && Dns4TokenEntry->Token->RspData.H2AData != NULL) { -+ if ((QuerySection->Type == DNS_TYPE_A) && (Dns4TokenEntry->Token->RspData.H2AData != NULL)) { - if (Dns4TokenEntry->Token->RspData.H2AData->IpList != NULL) { - FreePool (Dns4TokenEntry->Token->RspData.H2AData->IpList); - } -@@ -1710,7 +1733,7 @@ ON_EXIT: - if (Dns6TokenEntry->Token->RspData.GLookupData != NULL) { - if (Dns6TokenEntry->Token->RspData.GLookupData->RRList != NULL) { - while (RRCount != 0) { -- RRCount --; -+ RRCount--; - if (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName != NULL) { - FreePool (Dns6TokenEntry->Token->RspData.GLookupData->RRList[RRCount].QName); - } -@@ -1726,7 +1749,7 @@ ON_EXIT: - FreePool (Dns6TokenEntry->Token->RspData.GLookupData); - } - } else { -- if (QuerySection->Type == DNS_TYPE_AAAA && Dns6TokenEntry->Token->RspData.H2AData != NULL) { -+ if ((QuerySection->Type == DNS_TYPE_AAAA) && (Dns6TokenEntry->Token->RspData.H2AData != NULL)) { - if (Dns6TokenEntry->Token->RspData.H2AData->IpList != NULL) { - FreePool (Dns6TokenEntry->Token->RspData.H2AData->IpList); - } -@@ -1778,20 +1801,20 @@ ON_EXIT: - VOID - EFIAPI - DnsOnPacketReceived ( -- NET_BUF *Packet, -- UDP_END_POINT *EndPoint, -- EFI_STATUS IoStatus, -- VOID *Context -+ NET_BUF *Packet, -+ UDP_END_POINT *EndPoint, -+ EFI_STATUS IoStatus, -+ VOID *Context - ) - { -- DNS_INSTANCE *Instance; -+ DNS_INSTANCE *Instance; - -- UINT8 *RcvString; -- UINT32 Len; -+ UINT8 *RcvString; -+ UINT32 Len; - -- BOOLEAN Completed; -+ BOOLEAN Completed; - -- Instance = (DNS_INSTANCE *) Context; -+ Instance = (DNS_INSTANCE *)Context; - NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE); - - RcvString = NULL; -@@ -1836,29 +1859,29 @@ ON_EXIT: - VOID - EFIAPI - DnsOnPacketSent ( -- NET_BUF *Packet, -- UDP_END_POINT *EndPoint, -- EFI_STATUS IoStatus, -- VOID *Context -+ NET_BUF *Packet, -+ UDP_END_POINT *EndPoint, -+ EFI_STATUS IoStatus, -+ VOID *Context - ) - { -- DNS_INSTANCE *Instance; -- LIST_ENTRY *Entry; -- NET_MAP_ITEM *Item; -- DNS4_TOKEN_ENTRY *Dns4TokenEntry; -- DNS6_TOKEN_ENTRY *Dns6TokenEntry; -+ DNS_INSTANCE *Instance; -+ LIST_ENTRY *Entry; -+ NET_MAP_ITEM *Item; -+ DNS4_TOKEN_ENTRY *Dns4TokenEntry; -+ DNS6_TOKEN_ENTRY *Dns6TokenEntry; - - Dns4TokenEntry = NULL; - Dns6TokenEntry = NULL; - -- Instance = (DNS_INSTANCE *) Context; -+ Instance = (DNS_INSTANCE *)Context; - NET_CHECK_SIGNATURE (Instance, DNS_INSTANCE_SIGNATURE); - - if (Instance->Service->IpVersion == IP_VERSION_4) { - NET_LIST_FOR_EACH (Entry, &Instance->Dns4TxTokens.Used) { - Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); - if (Packet == (NET_BUF *)(Item->Value)) { -- Dns4TokenEntry = ((DNS4_TOKEN_ENTRY *)Item->Key); -+ Dns4TokenEntry = ((DNS4_TOKEN_ENTRY *)Item->Key); - Dns4TokenEntry->PacketToLive = Dns4TokenEntry->Token->RetryInterval; - break; - } -@@ -1867,7 +1890,7 @@ DnsOnPacketSent ( - NET_LIST_FOR_EACH (Entry, &Instance->Dns6TxTokens.Used) { - Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link); - if (Packet == (NET_BUF *)(Item->Value)) { -- Dns6TokenEntry = ((DNS6_TOKEN_ENTRY *)Item->Key); -+ Dns6TokenEntry = ((DNS6_TOKEN_ENTRY *)Item->Key); - Dns6TokenEntry->PacketToLive = Dns6TokenEntry->Token->RetryInterval; - break; - } -@@ -1889,11 +1912,11 @@ DnsOnPacketSent ( - **/ - EFI_STATUS - DoDnsQuery ( -- IN DNS_INSTANCE *Instance, -- IN NET_BUF *Packet -+ IN DNS_INSTANCE *Instance, -+ IN NET_BUF *Packet - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - - // - // Ready to receive the DNS response. -@@ -1930,16 +1953,16 @@ DoDnsQuery ( - **/ - EFI_STATUS - ConstructDNSQuery ( -- IN DNS_INSTANCE *Instance, -- IN CHAR8 *QueryName, -- IN UINT16 Type, -- IN UINT16 Class, -- OUT NET_BUF **Packet -+ IN DNS_INSTANCE *Instance, -+ IN CHAR8 *QueryName, -+ IN UINT16 Type, -+ IN UINT16 Class, -+ OUT NET_BUF **Packet - ) - { -- NET_FRAGMENT Frag; -- DNS_HEADER *DnsHeader; -- DNS_QUERY_SECTION *DnsQuery; -+ NET_FRAGMENT Frag; -+ DNS_HEADER *DnsHeader; -+ DNS_QUERY_SECTION *DnsQuery; - - // - // Messages carried by UDP are restricted to 512 bytes (not counting the IP -@@ -1953,23 +1976,23 @@ ConstructDNSQuery ( - // - // Fill header - // -- DnsHeader = (DNS_HEADER *) Frag.Bulk; -- DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed()); -- DnsHeader->Flags.Uint16 = 0x0000; -- DnsHeader->Flags.Bits.RD = 1; -+ DnsHeader = (DNS_HEADER *)Frag.Bulk; -+ DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed ()); -+ DnsHeader->Flags.Uint16 = 0x0000; -+ DnsHeader->Flags.Bits.RD = 1; - DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD; -- DnsHeader->Flags.Bits.QR = DNS_FLAGS_QR_QUERY; -- DnsHeader->QuestionsNum = 1; -- DnsHeader->AnswersNum = 0; -- DnsHeader->AuthorityNum = 0; -- DnsHeader->AditionalNum = 0; -+ DnsHeader->Flags.Bits.QR = DNS_FLAGS_QR_QUERY; -+ DnsHeader->QuestionsNum = 1; -+ DnsHeader->AnswersNum = 0; -+ DnsHeader->AuthorityNum = 0; -+ DnsHeader->AditionalNum = 0; - - DnsHeader->Identification = HTONS (DnsHeader->Identification); -- DnsHeader->Flags.Uint16 = HTONS (DnsHeader->Flags.Uint16); -- DnsHeader->QuestionsNum = HTONS (DnsHeader->QuestionsNum); -- DnsHeader->AnswersNum = HTONS (DnsHeader->AnswersNum); -- DnsHeader->AuthorityNum = HTONS (DnsHeader->AuthorityNum); -- DnsHeader->AditionalNum = HTONS (DnsHeader->AditionalNum); -+ DnsHeader->Flags.Uint16 = HTONS (DnsHeader->Flags.Uint16); -+ DnsHeader->QuestionsNum = HTONS (DnsHeader->QuestionsNum); -+ DnsHeader->AnswersNum = HTONS (DnsHeader->AnswersNum); -+ DnsHeader->AuthorityNum = HTONS (DnsHeader->AuthorityNum); -+ DnsHeader->AditionalNum = HTONS (DnsHeader->AditionalNum); - - Frag.Len = sizeof (*DnsHeader); - -@@ -1977,16 +2000,16 @@ ConstructDNSQuery ( - // Fill Query name - // - CopyMem (Frag.Bulk + Frag.Len, QueryName, AsciiStrLen (QueryName)); -- Frag.Len = (UINT32) (Frag.Len + AsciiStrLen (QueryName)); -+ Frag.Len = (UINT32)(Frag.Len + AsciiStrLen (QueryName)); - *(Frag.Bulk + Frag.Len) = 0; -- Frag.Len ++; -+ Frag.Len++; - - // - // Rest query section - // -- DnsQuery = (DNS_QUERY_SECTION *) (Frag.Bulk + Frag.Len); -+ DnsQuery = (DNS_QUERY_SECTION *)(Frag.Bulk + Frag.Len); - -- DnsQuery->Type = HTONS (Type); -+ DnsQuery->Type = HTONS (Type); - DnsQuery->Class = HTONS (Class); - - Frag.Len += sizeof (*DnsQuery); -@@ -2003,7 +2026,7 @@ ConstructDNSQuery ( - // - // Store the UdpIo in ProtoData. - // -- *((UINTN *) &((*Packet)->ProtoData[0])) = (UINTN) (Instance->UdpIo); -+ *((UINTN *)&((*Packet)->ProtoData[0])) = (UINTN)(Instance->UdpIo); - - return EFI_SUCCESS; - } -@@ -2020,13 +2043,13 @@ ConstructDNSQuery ( - **/ - EFI_STATUS - DnsRetransmit ( -- IN DNS_INSTANCE *Instance, -- IN NET_BUF *Packet -+ IN DNS_INSTANCE *Instance, -+ IN NET_BUF *Packet - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - -- UINT8 *Buffer; -+ UINT8 *Buffer; - - ASSERT (Packet != NULL); - -@@ -2064,26 +2087,25 @@ DnsRetransmit ( - VOID - EFIAPI - DnsOnTimerRetransmit ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { -- DNS_SERVICE *Service; -+ DNS_SERVICE *Service; - -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - -- DNS_INSTANCE *Instance; -- LIST_ENTRY *EntryNetMap; -- NET_MAP_ITEM *ItemNetMap; -- DNS4_TOKEN_ENTRY *Dns4TokenEntry; -- DNS6_TOKEN_ENTRY *Dns6TokenEntry; -+ DNS_INSTANCE *Instance; -+ LIST_ENTRY *EntryNetMap; -+ NET_MAP_ITEM *ItemNetMap; -+ DNS4_TOKEN_ENTRY *Dns4TokenEntry; -+ DNS6_TOKEN_ENTRY *Dns6TokenEntry; - - Dns4TokenEntry = NULL; - Dns6TokenEntry = NULL; - -- Service = (DNS_SERVICE *) Context; -- -+ Service = (DNS_SERVICE *)Context; - - if (Service->IpVersion == IP_VERSION_4) { - // -@@ -2095,9 +2117,9 @@ DnsOnTimerRetransmit ( - - EntryNetMap = Instance->Dns4TxTokens.Used.ForwardLink; - while (EntryNetMap != &Instance->Dns4TxTokens.Used) { -- ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); -+ ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); - Dns4TokenEntry = (DNS4_TOKEN_ENTRY *)(ItemNetMap->Key); -- if (Dns4TokenEntry->PacketToLive == 0 || (--Dns4TokenEntry->PacketToLive > 0)) { -+ if ((Dns4TokenEntry->PacketToLive == 0) || (--Dns4TokenEntry->PacketToLive > 0)) { - EntryNetMap = EntryNetMap->ForwardLink; - continue; - } -@@ -2139,9 +2161,9 @@ DnsOnTimerRetransmit ( - - EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink; - while (EntryNetMap != &Instance->Dns6TxTokens.Used) { -- ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); -- Dns6TokenEntry = (DNS6_TOKEN_ENTRY *) (ItemNetMap->Key); -- if (Dns6TokenEntry->PacketToLive == 0 || (--Dns6TokenEntry->PacketToLive > 0)) { -+ ItemNetMap = NET_LIST_USER_STRUCT (EntryNetMap, NET_MAP_ITEM, Link); -+ Dns6TokenEntry = (DNS6_TOKEN_ENTRY *)(ItemNetMap->Key); -+ if ((Dns6TokenEntry->PacketToLive == 0) || (--Dns6TokenEntry->PacketToLive > 0)) { - EntryNetMap = EntryNetMap->ForwardLink; - continue; - } -@@ -2151,7 +2173,7 @@ DnsOnTimerRetransmit ( - // otherwise exit the transfer. - // - if (++Dns6TokenEntry->RetryCounting <= Dns6TokenEntry->Token->RetryCount) { -- DnsRetransmit (Instance, (NET_BUF *) ItemNetMap->Value); -+ DnsRetransmit (Instance, (NET_BUF *)ItemNetMap->Value); - EntryNetMap = EntryNetMap->ForwardLink; - } else { - // -@@ -2166,7 +2188,7 @@ DnsOnTimerRetransmit ( - // Free the sending packet. - // - if (ItemNetMap->Value != NULL) { -- NetbufFree ((NET_BUF *) (ItemNetMap->Value)); -+ NetbufFree ((NET_BUF *)(ItemNetMap->Value)); - } - - EntryNetMap = Instance->Dns6TxTokens.Used.ForwardLink; -@@ -2186,14 +2208,14 @@ DnsOnTimerRetransmit ( - VOID - EFIAPI - DnsOnTimerUpdate ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- DNS4_CACHE *Item4; -- DNS6_CACHE *Item6; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ DNS4_CACHE *Item4; -+ DNS6_CACHE *Item6; - - Item4 = NULL; - Item6 = NULL; -@@ -2242,4 +2264,3 @@ DnsOnTimerUpdate ( - } - } - } -- -diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -index 4905bca4ad..b22cef4ff5 100644 ---- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -@@ -20,70 +20,70 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - UINT32 - HttpBootBuildDhcp6Options ( -- IN HTTP_BOOT_PRIVATE_DATA *Private, -- OUT EFI_DHCP6_PACKET_OPTION **OptList, -- IN UINT8 *Buffer -+ IN HTTP_BOOT_PRIVATE_DATA *Private, -+ OUT EFI_DHCP6_PACKET_OPTION **OptList, -+ IN UINT8 *Buffer - ) - { -- HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt; -- UINT16 Value; -- UINT32 Index; -+ HTTP_BOOT_DHCP6_OPTION_ENTRY OptEnt; -+ UINT16 Value; -+ UINT32 Index; - - Index = 0; -- OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer; -+ OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer; - - // - // Append client option request option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); -- OptList[Index]->OpLen = HTONS (8); -- OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *) OptList[Index]->Data; -- OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL); -- OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM); -- OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS); -- OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS); -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); -+ OptList[Index]->OpLen = HTONS (8); -+ OptEnt.Oro = (HTTP_BOOT_DHCP6_OPTION_ORO *)OptList[Index]->Data; -+ OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL); -+ OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM); -+ OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS); -+ OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS); - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append client network device interface option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); -- OptList[Index]->OpLen = HTONS ((UINT16)3); -- OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *) OptList[Index]->Data; -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); -+ OptList[Index]->OpLen = HTONS ((UINT16)3); -+ OptEnt.Undi = (HTTP_BOOT_DHCP6_OPTION_UNDI *)OptList[Index]->Data; - - if (Private->Nii != NULL) { -- OptEnt.Undi->Type = Private->Nii->Type; -- OptEnt.Undi->MajorVer = Private->Nii->MajorVer; -- OptEnt.Undi->MinorVer = Private->Nii->MinorVer; -+ OptEnt.Undi->Type = Private->Nii->Type; -+ OptEnt.Undi->MajorVer = Private->Nii->MajorVer; -+ OptEnt.Undi->MinorVer = Private->Nii->MinorVer; - } else { -- OptEnt.Undi->Type = DEFAULT_UNDI_TYPE; -- OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR; -- OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR; -+ OptEnt.Undi->Type = DEFAULT_UNDI_TYPE; -+ OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR; -+ OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR; - } - - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append client system architecture option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); -- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH)); -- OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *) OptList[Index]->Data; -- Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE); -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); -+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_ARCH)); -+ OptEnt.Arch = (HTTP_BOOT_DHCP6_OPTION_ARCH *)OptList[Index]->Data; -+ Value = HTONS (EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE); - CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16)); - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append vendor class identify option. - // - OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS); -- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS)); -- OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data; -+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS)); -+ OptEnt.VendorClass = (HTTP_BOOT_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data; - OptEnt.VendorClass->Vendor = HTONL (HTTP_BOOT_DHCP6_ENTERPRISE_NUM); -- OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (HTTP_BOOT_CLASS_ID)); -+ OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (HTTP_BOOT_CLASS_ID)); - CopyMem ( - &OptEnt.VendorClass->ClassId, - DEFAULT_CLASS_ID_DATA, -@@ -131,33 +131,30 @@ HttpBootBuildDhcp6Options ( - **/ - EFI_DHCP6_PACKET_OPTION * - HttpBootParseDhcp6Options ( -- IN UINT8 *Buffer, -- IN UINT32 Length, -- IN UINT16 OptTag -+ IN UINT8 *Buffer, -+ IN UINT32 Length, -+ IN UINT16 OptTag - ) - { -- EFI_DHCP6_PACKET_OPTION *Option; -- UINT32 Offset; -+ EFI_DHCP6_PACKET_OPTION *Option; -+ UINT32 Offset; - -- Option = (EFI_DHCP6_PACKET_OPTION *) Buffer; -- Offset = 0; -+ Option = (EFI_DHCP6_PACKET_OPTION *)Buffer; -+ Offset = 0; - - // - // OpLen and OpCode here are both stored in network order. - // - while (Offset < Length) { -- - if (NTOHS (Option->OpCode) == OptTag) { -- - return Option; - } - -- Offset += (NTOHS(Option->OpLen) + 4); -- Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset); -+ Offset += (NTOHS (Option->OpLen) + 4); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset); - } - - return NULL; -- - } - - /** -@@ -171,40 +168,39 @@ HttpBootParseDhcp6Options ( - **/ - EFI_STATUS - HttpBootParseDhcp6Packet ( -- IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6 -+ IN HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6 - ) - { -- EFI_DHCP6_PACKET *Offer; -- EFI_DHCP6_PACKET_OPTION **Options; -- EFI_DHCP6_PACKET_OPTION *Option; -- HTTP_BOOT_OFFER_TYPE OfferType; -- EFI_IPv6_ADDRESS IpAddr; -- BOOLEAN IsProxyOffer; -- BOOLEAN IsHttpOffer; -- BOOLEAN IsDnsOffer; -- BOOLEAN IpExpressedUri; -- EFI_STATUS Status; -- UINT32 Offset; -- UINT32 Length; -+ EFI_DHCP6_PACKET *Offer; -+ EFI_DHCP6_PACKET_OPTION **Options; -+ EFI_DHCP6_PACKET_OPTION *Option; -+ HTTP_BOOT_OFFER_TYPE OfferType; -+ EFI_IPv6_ADDRESS IpAddr; -+ BOOLEAN IsProxyOffer; -+ BOOLEAN IsHttpOffer; -+ BOOLEAN IsDnsOffer; -+ BOOLEAN IpExpressedUri; -+ EFI_STATUS Status; -+ UINT32 Offset; -+ UINT32 Length; - - IsDnsOffer = FALSE; - IpExpressedUri = FALSE; - IsProxyOffer = TRUE; - IsHttpOffer = FALSE; -- Offer = &Cache6->Packet.Offer; -- Options = Cache6->OptList; -+ Offer = &Cache6->Packet.Offer; -+ Options = Cache6->OptList; - - ZeroMem (Cache6->OptList, sizeof (Cache6->OptList)); - -- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option); -- Offset = 0; -- Length = GET_DHCP6_OPTION_SIZE (Offer); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option); -+ Offset = 0; -+ Length = GET_DHCP6_OPTION_SIZE (Offer); - - // - // OpLen and OpCode here are both stored in network order, since they are from original packet. - // - while (Offset < Length) { -- - if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) { - Options[HTTP_BOOT_DHCP6_IDX_IA_NA] = Option; - } else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) { -@@ -221,8 +217,9 @@ HttpBootParseDhcp6Packet ( - } - - Offset += (NTOHS (Option->OpLen) + 4); -- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset); - } -+ - // - // The offer with assigned client address is NOT a proxy offer. - // An ia_na option, embedded with valid ia_addr option and a status_code of success. -@@ -234,7 +231,7 @@ HttpBootParseDhcp6Packet ( - NTOHS (Option->OpLen), - DHCP6_OPT_STATUS_CODE - ); -- if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) { -+ if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) { - IsProxyOffer = FALSE; - } - } -@@ -244,10 +241,11 @@ HttpBootParseDhcp6Packet ( - // - Option = Options[HTTP_BOOT_DHCP6_IDX_VENDOR_CLASS]; - -- if (Option != NULL && -- NTOHS(Option->OpLen) >= 16 && -- CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0) { -- IsHttpOffer = TRUE; -+ if ((Option != NULL) && -+ (NTOHS (Option->OpLen) >= 16) && -+ (CompareMem ((Option->Data + 6), DEFAULT_CLASS_ID_DATA, 10) == 0)) -+ { -+ IsHttpOffer = TRUE; - } - - // -@@ -261,7 +259,7 @@ HttpBootParseDhcp6Packet ( - // - // Http offer must have a boot URI. - // -- if (IsHttpOffer && Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL) { -+ if (IsHttpOffer && (Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL] == NULL)) { - return EFI_DEVICE_ERROR; - } - -@@ -270,8 +268,8 @@ HttpBootParseDhcp6Packet ( - // - if (IsHttpOffer) { - Status = HttpParseUrl ( -- (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, -- (UINT32) AsciiStrLen ((CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data), -+ (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, -+ (UINT32)AsciiStrLen ((CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data), - FALSE, - &Cache6->UriParser - ); -@@ -280,7 +278,7 @@ HttpBootParseDhcp6Packet ( - } - - Status = HttpUrlGetIp6 ( -- (CHAR8*) Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, -+ (CHAR8 *)Options[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data, - Cache6->UriParser, - &IpAddr - ); -@@ -304,7 +302,6 @@ HttpBootParseDhcp6Packet ( - OfferType = HttpOfferTypeProxyNameUri; - } - } -- - } else { - if (!IsProxyOffer) { - OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly; -@@ -329,8 +326,8 @@ HttpBootParseDhcp6Packet ( - **/ - EFI_STATUS - HttpBootCacheDhcp6Packet ( -- IN EFI_DHCP6_PACKET *Dst, -- IN EFI_DHCP6_PACKET *Src -+ IN EFI_DHCP6_PACKET *Dst, -+ IN EFI_DHCP6_PACKET *Src - ) - { - if (Dst->Size < Src->Length) { -@@ -359,10 +356,10 @@ HttpBootCacheDhcp6Offer ( - IN EFI_DHCP6_PACKET *RcvdOffer - ) - { -- HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6; -- EFI_DHCP6_PACKET *Offer; -- HTTP_BOOT_OFFER_TYPE OfferType; -- EFI_STATUS Status; -+ HTTP_BOOT_DHCP6_PACKET_CACHE *Cache6; -+ EFI_DHCP6_PACKET *Offer; -+ HTTP_BOOT_OFFER_TYPE OfferType; -+ EFI_STATUS Status; - - Cache6 = &Private->OfferBuffer[Private->OfferNum].Dhcp6; - Offer = &Cache6->Packet.Offer; -@@ -370,7 +367,7 @@ HttpBootCacheDhcp6Offer ( - // - // Cache the content of DHCPv6 packet firstly. - // -- Status = HttpBootCacheDhcp6Packet(Offer, RcvdOffer); -+ Status = HttpBootCacheDhcp6Packet (Offer, RcvdOffer); - if (EFI_ERROR (Status)) { - return Status; - } -@@ -417,86 +414,91 @@ HttpBootCacheDhcp6Offer ( - EFI_STATUS - EFIAPI - HttpBootDhcp6CallBack ( -- IN EFI_DHCP6_PROTOCOL *This, -- IN VOID *Context, -- IN EFI_DHCP6_STATE CurrentState, -- IN EFI_DHCP6_EVENT Dhcp6Event, -- IN EFI_DHCP6_PACKET *Packet, -- OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL -+ IN EFI_DHCP6_PROTOCOL *This, -+ IN VOID *Context, -+ IN EFI_DHCP6_STATE CurrentState, -+ IN EFI_DHCP6_EVENT Dhcp6Event, -+ IN EFI_DHCP6_PACKET *Packet, -+ OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL - ) - { -- HTTP_BOOT_PRIVATE_DATA *Private; -- EFI_DHCP6_PACKET *SelectAd; -- EFI_STATUS Status; -- BOOLEAN Received; -+ HTTP_BOOT_PRIVATE_DATA *Private; -+ EFI_DHCP6_PACKET *SelectAd; -+ EFI_STATUS Status; -+ BOOLEAN Received; - - if ((Dhcp6Event != Dhcp6SendSolicit) && -- (Dhcp6Event != Dhcp6RcvdAdvertise) && -- (Dhcp6Event != Dhcp6SendRequest) && -- (Dhcp6Event != Dhcp6RcvdReply) && -- (Dhcp6Event != Dhcp6SelectAdvertise)) { -+ (Dhcp6Event != Dhcp6RcvdAdvertise) && -+ (Dhcp6Event != Dhcp6SendRequest) && -+ (Dhcp6Event != Dhcp6RcvdReply) && -+ (Dhcp6Event != Dhcp6SelectAdvertise)) -+ { - return EFI_SUCCESS; - } - - ASSERT (Packet != NULL); - -- Private = (HTTP_BOOT_PRIVATE_DATA *) Context; -- Status = EFI_SUCCESS; -- if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) { -- Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply); -- Status = Private->HttpBootCallback->Callback ( -- Private->HttpBootCallback, -- HttpBootDhcp6, -- Received, -- Packet->Length, -- &Packet->Dhcp6 -- ); -+ Private = (HTTP_BOOT_PRIVATE_DATA *)Context; -+ Status = EFI_SUCCESS; -+ if ((Private->HttpBootCallback != NULL) && (Dhcp6Event != Dhcp6SelectAdvertise)) { -+ Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply); -+ Status = Private->HttpBootCallback->Callback ( -+ Private->HttpBootCallback, -+ HttpBootDhcp6, -+ Received, -+ Packet->Length, -+ &Packet->Dhcp6 -+ ); - if (EFI_ERROR (Status)) { - return EFI_ABORTED; - } - } -+ - switch (Dhcp6Event) { -+ case Dhcp6RcvdAdvertise: -+ Status = EFI_NOT_READY; -+ if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) { -+ // -+ // Ignore the incoming packets which exceed the maximum length. -+ // -+ break; -+ } -+ -+ if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) { -+ // -+ // Cache the dhcp offers to OfferBuffer[] for select later, and record -+ // the OfferIndex and OfferCount. -+ // If error happens, just ignore this packet and continue to wait more offer. -+ // -+ HttpBootCacheDhcp6Offer (Private, Packet); -+ } - -- case Dhcp6RcvdAdvertise: -- Status = EFI_NOT_READY; -- if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) { -- // -- // Ignore the incoming packets which exceed the maximum length. -- // - break; -- } -- if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) { -+ -+ case Dhcp6SelectAdvertise: - // -- // Cache the dhcp offers to OfferBuffer[] for select later, and record -- // the OfferIndex and OfferCount. -- // If error happens, just ignore this packet and continue to wait more offer. -+ // Select offer by the default policy or by order, and record the SelectIndex -+ // and SelectProxyType. - // -- HttpBootCacheDhcp6Offer (Private, Packet); -- } -- break; -- -- case Dhcp6SelectAdvertise: -- // -- // Select offer by the default policy or by order, and record the SelectIndex -- // and SelectProxyType. -- // -- HttpBootSelectDhcpOffer (Private); -+ HttpBootSelectDhcpOffer (Private); - -- if (Private->SelectIndex == 0) { -- Status = EFI_ABORTED; -- } else { -- ASSERT (NewPacket != NULL); -- SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer; -- *NewPacket = AllocateZeroPool (SelectAd->Size); -- if (*NewPacket == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ if (Private->SelectIndex == 0) { -+ Status = EFI_ABORTED; -+ } else { -+ ASSERT (NewPacket != NULL); -+ SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer; -+ *NewPacket = AllocateZeroPool (SelectAd->Size); -+ if (*NewPacket == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ CopyMem (*NewPacket, SelectAd, SelectAd->Size); - } -- CopyMem (*NewPacket, SelectAd, SelectAd->Size); -- } -- break; - -- default: -- break; -+ break; -+ -+ default: -+ break; - } - - return Status; -@@ -519,18 +521,18 @@ HttpBootDhcp6CallBack ( - **/ - EFI_STATUS - HttpBootCheckRouteTable ( -- IN HTTP_BOOT_PRIVATE_DATA *Private, -- IN UINTN TimeOutInSecond, -- OUT EFI_IPv6_ADDRESS *GatewayAddr -+ IN HTTP_BOOT_PRIVATE_DATA *Private, -+ IN UINTN TimeOutInSecond, -+ OUT EFI_IPv6_ADDRESS *GatewayAddr - ) - { -- EFI_STATUS Status; -- EFI_IP6_PROTOCOL *Ip6; -- EFI_IP6_MODE_DATA Ip6ModeData; -- UINTN Index; -- EFI_EVENT TimeOutEvt; -- UINTN RetryCount; -- BOOLEAN GatewayIsFound; -+ EFI_STATUS Status; -+ EFI_IP6_PROTOCOL *Ip6; -+ EFI_IP6_MODE_DATA Ip6ModeData; -+ UINTN Index; -+ EFI_EVENT TimeOutEvt; -+ UINTN RetryCount; -+ BOOLEAN GatewayIsFound; - - ASSERT (GatewayAddr != NULL); - ASSERT (Private != NULL); -@@ -562,23 +564,28 @@ HttpBootCheckRouteTable ( - if (Ip6ModeData.AddressList != NULL) { - FreePool (Ip6ModeData.AddressList); - } -+ - if (Ip6ModeData.GroupTable != NULL) { - FreePool (Ip6ModeData.GroupTable); - } -+ - if (Ip6ModeData.RouteTable != NULL) { - FreePool (Ip6ModeData.RouteTable); - } -+ - if (Ip6ModeData.NeighborCache != NULL) { - FreePool (Ip6ModeData.NeighborCache); - } -+ - if (Ip6ModeData.PrefixTable != NULL) { - FreePool (Ip6ModeData.PrefixTable); - } -+ - if (Ip6ModeData.IcmpTypeList != NULL) { - FreePool (Ip6ModeData.IcmpTypeList); - } - -- if (GatewayIsFound || RetryCount == TimeOutInSecond) { -+ if (GatewayIsFound || (RetryCount == TimeOutInSecond)) { - break; - } - -@@ -604,6 +611,7 @@ HttpBootCheckRouteTable ( - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } -+ - while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { - Ip6->Poll (Ip6); - } -@@ -634,16 +642,16 @@ ON_EXIT: - **/ - EFI_STATUS - HttpBootSetIp6Policy ( -- IN HTTP_BOOT_PRIVATE_DATA *Private -+ IN HTTP_BOOT_PRIVATE_DATA *Private - ) - { -- EFI_IP6_CONFIG_POLICY Policy; -- EFI_IP6_CONFIG_PROTOCOL *Ip6Config; -- EFI_STATUS Status; -- UINTN DataSize; -+ EFI_IP6_CONFIG_POLICY Policy; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config; -+ EFI_STATUS Status; -+ UINTN DataSize; - -- Ip6Config = Private->Ip6Config; -- DataSize = sizeof (EFI_IP6_CONFIG_POLICY); -+ Ip6Config = Private->Ip6Config; -+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY); - - // - // Get and store the current policy of IP6 driver. -@@ -663,13 +671,14 @@ HttpBootSetIp6Policy ( - Status = Ip6Config->SetData ( - Ip6Config, - Ip6ConfigDataTypePolicy, -- sizeof(EFI_IP6_CONFIG_POLICY), -+ sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - if (EFI_ERROR (Status)) { - return Status; - } - } -+ - return EFI_SUCCESS; - } - -@@ -687,12 +696,12 @@ HttpBootSetIp6Policy ( - **/ - EFI_STATUS - HttpBootSetIp6Dns ( -- IN HTTP_BOOT_PRIVATE_DATA *Private, -- IN UINTN DataLength, -- IN VOID *DnsServerData -+ IN HTTP_BOOT_PRIVATE_DATA *Private, -+ IN UINTN DataLength, -+ IN VOID *DnsServerData - ) - { -- EFI_IP6_CONFIG_PROTOCOL *Ip6Config; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config; - - ASSERT (Private->UsingIpv6); - -@@ -717,11 +726,11 @@ HttpBootSetIp6Dns ( - **/ - EFI_STATUS - HttpBootSetIp6Gateway ( -- IN HTTP_BOOT_PRIVATE_DATA *Private -+ IN HTTP_BOOT_PRIVATE_DATA *Private - ) - { -- EFI_IP6_CONFIG_PROTOCOL *Ip6Config; -- EFI_STATUS Status; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Config; -+ EFI_STATUS Status; - - ASSERT (Private->UsingIpv6); - Ip6Config = Private->Ip6Config; -@@ -736,7 +745,7 @@ HttpBootSetIp6Gateway ( - sizeof (EFI_IPv6_ADDRESS), - &Private->GatewayIp.v6 - ); -- if (EFI_ERROR(Status)) { -+ if (EFI_ERROR (Status)) { - return Status; - } - } -@@ -755,21 +764,21 @@ HttpBootSetIp6Gateway ( - **/ - EFI_STATUS - HttpBootSetIp6Address ( -- IN HTTP_BOOT_PRIVATE_DATA *Private --) -+ IN HTTP_BOOT_PRIVATE_DATA *Private -+ ) - { -- EFI_STATUS Status; -- EFI_IP6_PROTOCOL *Ip6; -- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -- EFI_IP6_CONFIG_POLICY Policy; -- EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr; -- EFI_IPv6_ADDRESS *Ip6Addr; -- EFI_IPv6_ADDRESS GatewayAddr; -- EFI_IP6_CONFIG_DATA Ip6CfgData; -- EFI_EVENT MappedEvt; -- UINTN DataSize; -- BOOLEAN IsAddressOk; -- UINTN Index; -+ EFI_STATUS Status; -+ EFI_IP6_PROTOCOL *Ip6; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -+ EFI_IP6_CONFIG_POLICY Policy; -+ EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr; -+ EFI_IPv6_ADDRESS *Ip6Addr; -+ EFI_IPv6_ADDRESS GatewayAddr; -+ EFI_IP6_CONFIG_DATA Ip6CfgData; -+ EFI_EVENT MappedEvt; -+ UINTN DataSize; -+ BOOLEAN IsAddressOk; -+ UINTN Index; - - ASSERT (Private->UsingIpv6); - -@@ -783,11 +792,11 @@ HttpBootSetIp6Address ( - CopyMem (&CfgAddr, &Private->StationIp.v6, sizeof (EFI_IPv6_ADDRESS)); - ZeroMem (&Ip6CfgData, sizeof (EFI_IP6_CONFIG_DATA)); - -- Ip6CfgData.AcceptIcmpErrors = TRUE; -- Ip6CfgData.DefaultProtocol = IP6_ICMP; -- Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT; -- Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME; -- Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME; -+ Ip6CfgData.AcceptIcmpErrors = TRUE; -+ Ip6CfgData.DefaultProtocol = IP6_ICMP; -+ Ip6CfgData.HopLimit = HTTP_BOOT_DEFAULT_HOPLIMIT; -+ Ip6CfgData.ReceiveTimeout = HTTP_BOOT_DEFAULT_LIFETIME; -+ Ip6CfgData.TransmitTimeout = HTTP_BOOT_DEFAULT_LIFETIME; - - Status = Ip6->Configure (Ip6, &Ip6CfgData); - if (EFI_ERROR (Status)) { -@@ -811,7 +820,7 @@ HttpBootSetIp6Address ( - Status = Ip6Cfg->SetData ( - Ip6Cfg, - Ip6ConfigDataTypePolicy, -- sizeof(EFI_IP6_CONFIG_POLICY), -+ sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - if (EFI_ERROR (Status)) { -@@ -840,7 +849,7 @@ HttpBootSetIp6Address ( - Ip6ConfigDataTypeManualAddress, - MappedEvt - ); -- if (EFI_ERROR(Status)) { -+ if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - -@@ -850,7 +859,7 @@ HttpBootSetIp6Address ( - sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS), - &CfgAddr - ); -- if (EFI_ERROR (Status) && Status != EFI_NOT_READY) { -+ if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) { - goto ON_EXIT; - } else if (Status == EFI_NOT_READY) { - // -@@ -859,17 +868,18 @@ HttpBootSetIp6Address ( - while (!IsAddressOk) { - Ip6->Poll (Ip6); - } -+ - // - // Check whether the Ip6 Address setting is successed. - // - DataSize = 0; -- Status = Ip6Cfg->GetData ( -- Ip6Cfg, -- Ip6ConfigDataTypeManualAddress, -- &DataSize, -- NULL -- ); -- if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) { -+ Status = Ip6Cfg->GetData ( -+ Ip6Cfg, -+ Ip6ConfigDataTypeManualAddress, -+ &DataSize, -+ NULL -+ ); -+ if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) { - Status = EFI_DEVICE_ERROR; - goto ON_EXIT; - } -@@ -878,22 +888,24 @@ HttpBootSetIp6Address ( - if (Ip6Addr == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeManualAddress, - &DataSize, -- (VOID *) Ip6Addr -+ (VOID *)Ip6Addr - ); - if (EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; - goto ON_EXIT; - } - -- for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index ++) { -+ for (Index = 0; Index < DataSize / sizeof (EFI_IPv6_ADDRESS); Index++) { - if (CompareMem (Ip6Addr + Index, &CfgAddr, sizeof (EFI_IPv6_ADDRESS)) == 0) { - break; - } - } -+ - if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) { - Status = EFI_ABORTED; - goto ON_EXIT; -@@ -928,17 +940,17 @@ ON_EXIT: - **/ - EFI_STATUS - HttpBootDhcp6Sarr ( -- IN HTTP_BOOT_PRIVATE_DATA *Private -+ IN HTTP_BOOT_PRIVATE_DATA *Private - ) - { -- EFI_DHCP6_PROTOCOL *Dhcp6; -- EFI_DHCP6_CONFIG_DATA Config; -- EFI_DHCP6_MODE_DATA Mode; -- EFI_DHCP6_RETRANSMISSION *Retransmit; -- EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM]; -- UINT32 OptCount; -- UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE]; -- EFI_STATUS Status; -+ EFI_DHCP6_PROTOCOL *Dhcp6; -+ EFI_DHCP6_CONFIG_DATA Config; -+ EFI_DHCP6_MODE_DATA Mode; -+ EFI_DHCP6_RETRANSMISSION *Retransmit; -+ EFI_DHCP6_PACKET_OPTION *OptList[HTTP_BOOT_DHCP6_OPTION_MAX_NUM]; -+ UINT32 OptCount; -+ UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE]; -+ EFI_STATUS Status; - - Dhcp6 = Private->Dhcp6; - ASSERT (Dhcp6 != NULL); -@@ -947,7 +959,7 @@ HttpBootDhcp6Sarr ( - // Build options list for the request packet. - // - OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer); -- ASSERT (OptCount >0); -+ ASSERT (OptCount > 0); - - Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION)); - if (Retransmit == NULL) { -@@ -980,11 +992,12 @@ HttpBootDhcp6Sarr ( - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } -+ - // - // Initialize the record fields for DHCPv6 offer in private data. - // -- Private->OfferNum = 0; -- Private->SelectIndex = 0; -+ Private->OfferNum = 0; -+ Private->SelectIndex = 0; - ZeroMem (Private->OfferCount, sizeof (Private->OfferCount)); - ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex)); - -@@ -1021,12 +1034,11 @@ ON_EXIT: - if (Mode.ClientId != NULL) { - FreePool (Mode.ClientId); - } -+ - if (Mode.Ia != NULL) { - FreePool (Mode.Ia); - } - } - - return Status; -- - } -- -diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.c b/NetworkPkg/IScsiDxe/IScsiCHAP.c -index 0491ef42db..b507f11cd4 100644 ---- a/NetworkPkg/IScsiDxe/IScsiCHAP.c -+++ b/NetworkPkg/IScsiDxe/IScsiCHAP.c -@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - // macros. CHAP_HASH structures at lower subscripts in the array are preferred - // by the initiator. - // --STATIC CONST CHAP_HASH mChapHash[] = { -+STATIC CONST CHAP_HASH mChapHash[] = { - { - ISCSI_CHAP_ALGORITHM_SHA256, - SHA256_DIGEST_SIZE, -@@ -23,7 +23,7 @@ STATIC CONST CHAP_HASH mChapHash[] = { - Sha256Update, - Sha256Final - }, --#ifdef ENABLE_MD5_DEPRECATED_INTERFACES -+ #ifdef ENABLE_MD5_DEPRECATED_INTERFACES - // - // Keep the deprecated MD5 entry at the end of the array (making MD5 the - // least preferred choice of the initiator). -@@ -36,7 +36,7 @@ STATIC CONST CHAP_HASH mChapHash[] = { - Md5Update, - Md5Final - }, --#endif // ENABLE_MD5_DEPRECATED_INTERFACES -+ #endif // ENABLE_MD5_DEPRECATED_INTERFACES - }; - - // -@@ -44,17 +44,17 @@ STATIC CONST CHAP_HASH mChapHash[] = { - // CHAP_A= value string, by the IScsiCHAPInitHashList() function. It - // is sent by the initiator in ISCSI_CHAP_STEP_ONE. - // --STATIC CHAR8 mChapHashListString[ -- 3 + // UINT8 identifier in -- // decimal -- (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for -- // entries after the -- // first -- 1 + // extra character for -- // AsciiSPrint() -- // truncation check -- 1 // terminating NUL -- ]; -+STATIC CHAR8 mChapHashListString[ -+ 3 + // UINT8 identifier in -+ // decimal -+ (1 + 3) * (ARRAY_SIZE (mChapHash) - 1) + // comma prepended for -+ // entries after the -+ // first -+ 1 + // extra character for -+ // AsciiSPrint() -+ // truncation check -+ 1 // terminating NUL -+]; - - /** - Initiator calculates its own expected hash value. -@@ -82,13 +82,13 @@ STATIC CHAR8 mChapHashListString[ - **/ - EFI_STATUS - IScsiCHAPCalculateResponse ( -- IN UINT32 ChapIdentifier, -- IN CHAR8 *ChapSecret, -- IN UINT32 SecretLength, -- IN UINT8 *ChapChallenge, -- IN UINT32 ChallengeLength, -- IN CONST CHAP_HASH *Hash, -- OUT UINT8 *ChapResponse -+ IN UINT32 ChapIdentifier, -+ IN CHAR8 *ChapSecret, -+ IN UINT32 SecretLength, -+ IN UINT8 *ChapChallenge, -+ IN UINT32 ChallengeLength, -+ IN CONST CHAP_HASH *Hash, -+ OUT UINT8 *ChapResponse - ) - { - UINTN ContextSize; -@@ -103,7 +103,7 @@ IScsiCHAPCalculateResponse ( - ASSERT (Hash != NULL); - - ContextSize = Hash->GetContextSize (); -- Ctx = AllocatePool (ContextSize); -+ Ctx = AllocatePool (ContextSize); - if (Ctx == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -117,7 +117,7 @@ IScsiCHAPCalculateResponse ( - // - // Hash Identifier - Only calculate 1 byte data (RFC1994) - // -- IdByte[0] = (CHAR8) ChapIdentifier; -+ IdByte[0] = (CHAR8)ChapIdentifier; - if (!Hash->Update (Ctx, IdByte, 1)) { - goto Exit; - } -@@ -170,9 +170,9 @@ IScsiCHAPAuthTarget ( - UINT8 VerifyRsp[ISCSI_CHAP_MAX_DIGEST_SIZE]; - INTN Mismatch; - -- Status = EFI_SUCCESS; -+ Status = EFI_SUCCESS; - -- SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret); -+ SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret); - - ASSERT (AuthData->Hash != NULL); - -@@ -198,7 +198,6 @@ IScsiCHAPAuthTarget ( - return Status; - } - -- - /** - This function checks the received iSCSI Login Response during the security - negotiation stage. -@@ -216,33 +215,34 @@ IScsiCHAPOnRspReceived ( - IN ISCSI_CONNECTION *Conn - ) - { -- EFI_STATUS Status; -- ISCSI_SESSION *Session; -- ISCSI_CHAP_AUTH_DATA *AuthData; -- CHAR8 *Value; -- UINT8 *Data; -- UINT32 Len; -- LIST_ENTRY *KeyValueList; -- UINTN Algorithm; -- CHAR8 *Identifier; -- CHAR8 *Challenge; -- CHAR8 *Name; -- CHAR8 *Response; -- UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE]; -- UINT32 RspLen; -- UINTN Result; -- UINTN HashIndex; -+ EFI_STATUS Status; -+ ISCSI_SESSION *Session; -+ ISCSI_CHAP_AUTH_DATA *AuthData; -+ CHAR8 *Value; -+ UINT8 *Data; -+ UINT32 Len; -+ LIST_ENTRY *KeyValueList; -+ UINTN Algorithm; -+ CHAR8 *Identifier; -+ CHAR8 *Challenge; -+ CHAR8 *Name; -+ CHAR8 *Response; -+ UINT8 TargetRsp[ISCSI_CHAP_MAX_DIGEST_SIZE]; -+ UINT32 RspLen; -+ UINTN Result; -+ UINTN HashIndex; - - ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION); - ASSERT (Conn->RspQue.BufNum != 0); - -- Session = Conn->Session; -- AuthData = &Session->AuthData.CHAP; -- Len = Conn->RspQue.BufSize; -- Data = AllocateZeroPool (Len); -+ Session = Conn->Session; -+ AuthData = &Session->AuthData.CHAP; -+ Len = Conn->RspQue.BufSize; -+ Data = AllocateZeroPool (Len); - if (Data == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - // - // Copy the data in case the data spans over multiple PDUs. - // -@@ -251,7 +251,7 @@ IScsiCHAPOnRspReceived ( - // - // Build the key-value list from the data segment of the Login Response. - // -- KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len); -+ KeyValueList = IScsiBuildKeyValueList ((CHAR8 *)Data, Len); - if (KeyValueList == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; -@@ -260,179 +260,184 @@ IScsiCHAPOnRspReceived ( - Status = EFI_PROTOCOL_ERROR; - - switch (Conn->AuthStep) { -- case ISCSI_AUTH_INITIAL: -- // -- // The first Login Response. -- // -- Value = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_TARGET_PORTAL_GROUP_TAG -- ); -- if (Value == NULL) { -- goto ON_EXIT; -- } -- -- Result = IScsiNetNtoi (Value); -- if (Result > 0xFFFF) { -- goto ON_EXIT; -- } -- -- Session->TargetPortalGroupTag = (UINT16) Result; -- -- Value = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_AUTH_METHOD -- ); -- if (Value == NULL) { -- goto ON_EXIT; -- } -- // -- // Initiator mandates CHAP authentication but target replies without -- // "CHAP", or initiator suggets "None" but target replies with some kind of -- // auth method. -- // -- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) { -- if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) { -+ case ISCSI_AUTH_INITIAL: -+ // -+ // The first Login Response. -+ // -+ Value = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_TARGET_PORTAL_GROUP_TAG -+ ); -+ if (Value == NULL) { - goto ON_EXIT; - } -- } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) { -- if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) { -+ -+ Result = IScsiNetNtoi (Value); -+ if (Result > 0xFFFF) { - goto ON_EXIT; - } -- } else { -- goto ON_EXIT; -- } - -- // -- // Transit to CHAP step one. -- // -- Conn->AuthStep = ISCSI_CHAP_STEP_ONE; -- Status = EFI_SUCCESS; -- break; -+ Session->TargetPortalGroupTag = (UINT16)Result; - -- case ISCSI_CHAP_STEP_TWO: -- // -- // The Target replies with CHAP_A= CHAP_I= CHAP_C= -- // -- Value = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_CHAP_ALGORITHM -- ); -- if (Value == NULL) { -- goto ON_EXIT; -- } -- -- Algorithm = IScsiNetNtoi (Value); -- for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) { -- if (Algorithm == mChapHash[HashIndex].Algorithm) { -- break; -+ Value = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_AUTH_METHOD -+ ); -+ if (Value == NULL) { -+ goto ON_EXIT; - } -- } -- if (HashIndex == ARRAY_SIZE (mChapHash)) { -+ - // -- // Unsupported algorithm is chosen by target. -+ // Initiator mandates CHAP authentication but target replies without -+ // "CHAP", or initiator suggets "None" but target replies with some kind of -+ // auth method. - // -- goto ON_EXIT; -- } -- // -- // Remember the target's chosen hash algorithm. -- // -- ASSERT (AuthData->Hash == NULL); -- AuthData->Hash = &mChapHash[HashIndex]; -+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) { -+ if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) { -+ goto ON_EXIT; -+ } -+ } else if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) { -+ if (AsciiStrCmp (Value, ISCSI_AUTH_METHOD_CHAP) != 0) { -+ goto ON_EXIT; -+ } -+ } else { -+ goto ON_EXIT; -+ } - -- Identifier = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_CHAP_IDENTIFIER -- ); -- if (Identifier == NULL) { -- goto ON_EXIT; -- } -- -- Challenge = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_CHAP_CHALLENGE -- ); -- if (Challenge == NULL) { -- goto ON_EXIT; -- } -- // -- // Process the CHAP identifier and CHAP Challenge from Target. -- // Calculate Response value. -- // -- Result = IScsiNetNtoi (Identifier); -- if (Result > 0xFF) { -- goto ON_EXIT; -- } -- -- AuthData->InIdentifier = (UINT32) Result; -- AuthData->InChallengeLength = (UINT32) sizeof (AuthData->InChallenge); -- Status = IScsiHexToBin ( -- (UINT8 *) AuthData->InChallenge, -- &AuthData->InChallengeLength, -- Challenge -- ); -- if (EFI_ERROR (Status)) { -- Status = EFI_PROTOCOL_ERROR; -- goto ON_EXIT; -- } -- Status = IScsiCHAPCalculateResponse ( -- AuthData->InIdentifier, -- AuthData->AuthConfig->CHAPSecret, -- (UINT32) AsciiStrLen (AuthData->AuthConfig->CHAPSecret), -- AuthData->InChallenge, -- AuthData->InChallengeLength, -- AuthData->Hash, -- AuthData->CHAPResponse -- ); -+ // -+ // Transit to CHAP step one. -+ // -+ Conn->AuthStep = ISCSI_CHAP_STEP_ONE; -+ Status = EFI_SUCCESS; -+ break; - -- // -- // Transit to next step. -- // -- Conn->AuthStep = ISCSI_CHAP_STEP_THREE; -- break; -+ case ISCSI_CHAP_STEP_TWO: -+ // -+ // The Target replies with CHAP_A= CHAP_I= CHAP_C= -+ // -+ Value = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_CHAP_ALGORITHM -+ ); -+ if (Value == NULL) { -+ goto ON_EXIT; -+ } - -- case ISCSI_CHAP_STEP_THREE: -- // -- // One way CHAP authentication and the target would like to -- // authenticate us. -- // -- Status = EFI_SUCCESS; -- break; -+ Algorithm = IScsiNetNtoi (Value); -+ for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) { -+ if (Algorithm == mChapHash[HashIndex].Algorithm) { -+ break; -+ } -+ } - -- case ISCSI_CHAP_STEP_FOUR: -- ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL); -- // -- // The forth step, CHAP_N= CHAP_R= is received from Target. -- // -- Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME); -- if (Name == NULL) { -- goto ON_EXIT; -- } -- -- Response = IScsiGetValueByKeyFromList ( -- KeyValueList, -- ISCSI_KEY_CHAP_RESPONSE -+ if (HashIndex == ARRAY_SIZE (mChapHash)) { -+ // -+ // Unsupported algorithm is chosen by target. -+ // -+ goto ON_EXIT; -+ } -+ -+ // -+ // Remember the target's chosen hash algorithm. -+ // -+ ASSERT (AuthData->Hash == NULL); -+ AuthData->Hash = &mChapHash[HashIndex]; -+ -+ Identifier = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_CHAP_IDENTIFIER -+ ); -+ if (Identifier == NULL) { -+ goto ON_EXIT; -+ } -+ -+ Challenge = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_CHAP_CHALLENGE -+ ); -+ if (Challenge == NULL) { -+ goto ON_EXIT; -+ } -+ -+ // -+ // Process the CHAP identifier and CHAP Challenge from Target. -+ // Calculate Response value. -+ // -+ Result = IScsiNetNtoi (Identifier); -+ if (Result > 0xFF) { -+ goto ON_EXIT; -+ } -+ -+ AuthData->InIdentifier = (UINT32)Result; -+ AuthData->InChallengeLength = (UINT32)sizeof (AuthData->InChallenge); -+ Status = IScsiHexToBin ( -+ (UINT8 *)AuthData->InChallenge, -+ &AuthData->InChallengeLength, -+ Challenge -+ ); -+ if (EFI_ERROR (Status)) { -+ Status = EFI_PROTOCOL_ERROR; -+ goto ON_EXIT; -+ } -+ -+ Status = IScsiCHAPCalculateResponse ( -+ AuthData->InIdentifier, -+ AuthData->AuthConfig->CHAPSecret, -+ (UINT32)AsciiStrLen (AuthData->AuthConfig->CHAPSecret), -+ AuthData->InChallenge, -+ AuthData->InChallengeLength, -+ AuthData->Hash, -+ AuthData->CHAPResponse - ); -- if (Response == NULL) { -- goto ON_EXIT; -- } -- -- ASSERT (AuthData->Hash != NULL); -- RspLen = AuthData->Hash->DigestSize; -- Status = IScsiHexToBin (TargetRsp, &RspLen, Response); -- if (EFI_ERROR (Status) || RspLen != AuthData->Hash->DigestSize) { -- Status = EFI_PROTOCOL_ERROR; -- goto ON_EXIT; -- } - -- // -- // Check the CHAP Name and Response replied by Target. -- // -- Status = IScsiCHAPAuthTarget (AuthData, TargetRsp); -- break; -+ // -+ // Transit to next step. -+ // -+ Conn->AuthStep = ISCSI_CHAP_STEP_THREE; -+ break; -+ -+ case ISCSI_CHAP_STEP_THREE: -+ // -+ // One way CHAP authentication and the target would like to -+ // authenticate us. -+ // -+ Status = EFI_SUCCESS; -+ break; -+ -+ case ISCSI_CHAP_STEP_FOUR: -+ ASSERT (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL); -+ // -+ // The forth step, CHAP_N= CHAP_R= is received from Target. -+ // -+ Name = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_NAME); -+ if (Name == NULL) { -+ goto ON_EXIT; -+ } -+ -+ Response = IScsiGetValueByKeyFromList ( -+ KeyValueList, -+ ISCSI_KEY_CHAP_RESPONSE -+ ); -+ if (Response == NULL) { -+ goto ON_EXIT; -+ } - -- default: -- break; -+ ASSERT (AuthData->Hash != NULL); -+ RspLen = AuthData->Hash->DigestSize; -+ Status = IScsiHexToBin (TargetRsp, &RspLen, Response); -+ if (EFI_ERROR (Status) || (RspLen != AuthData->Hash->DigestSize)) { -+ Status = EFI_PROTOCOL_ERROR; -+ goto ON_EXIT; -+ } -+ -+ // -+ // Check the CHAP Name and Response replied by Target. -+ // -+ Status = IScsiCHAPAuthTarget (AuthData, TargetRsp); -+ break; -+ -+ default: -+ break; - } - - ON_EXIT: -@@ -446,7 +451,6 @@ ON_EXIT: - return Status; - } - -- - /** - This function fills the CHAP authentication information into the login PDU - during the security negotiation stage in the iSCSI connection login. -@@ -467,140 +471,142 @@ IScsiCHAPToSendReq ( - IN OUT NET_BUF *Pdu - ) - { -- EFI_STATUS Status; -- ISCSI_SESSION *Session; -- ISCSI_LOGIN_REQUEST *LoginReq; -- ISCSI_CHAP_AUTH_DATA *AuthData; -- CHAR8 *Value; -- CHAR8 ValueStr[256]; -- CHAR8 *Response; -- UINT32 RspLen; -- CHAR8 *Challenge; -- UINT32 ChallengeLen; -- EFI_STATUS BinToHexStatus; -+ EFI_STATUS Status; -+ ISCSI_SESSION *Session; -+ ISCSI_LOGIN_REQUEST *LoginReq; -+ ISCSI_CHAP_AUTH_DATA *AuthData; -+ CHAR8 *Value; -+ CHAR8 ValueStr[256]; -+ CHAR8 *Response; -+ UINT32 RspLen; -+ CHAR8 *Challenge; -+ UINT32 ChallengeLen; -+ EFI_STATUS BinToHexStatus; - - ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION); - -- Session = Conn->Session; -- AuthData = &Session->AuthData.CHAP; -- LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0); -+ Session = Conn->Session; -+ AuthData = &Session->AuthData.CHAP; -+ LoginReq = (ISCSI_LOGIN_REQUEST *)NetbufGetByte (Pdu, 0, 0); - if (LoginReq == NULL) { - return EFI_PROTOCOL_ERROR; - } -- Status = EFI_SUCCESS; - -- RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3; -- Response = AllocateZeroPool (RspLen); -+ Status = EFI_SUCCESS; -+ -+ RspLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3; -+ Response = AllocateZeroPool (RspLen); - if (Response == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3; -- Challenge = AllocateZeroPool (ChallengeLen); -+ ChallengeLen = 2 * ISCSI_CHAP_MAX_DIGEST_SIZE + 3; -+ Challenge = AllocateZeroPool (ChallengeLen); - if (Challenge == NULL) { - FreePool (Response); - return EFI_OUT_OF_RESOURCES; - } - - switch (Conn->AuthStep) { -- case ISCSI_AUTH_INITIAL: -- // -- // It's the initial Login Request. Fill in the key=value pairs mandatory -- // for the initial Login Request. -- // -- IScsiAddKeyValuePair ( -- Pdu, -- ISCSI_KEY_INITIATOR_NAME, -- mPrivate->InitiatorName -- ); -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal"); -- IScsiAddKeyValuePair ( -- Pdu, -- ISCSI_KEY_TARGET_NAME, -- Session->ConfigData->SessionConfigData.TargetName -- ); -- -- if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) { -- Value = ISCSI_KEY_VALUE_NONE; -- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT); -- } else { -- Value = ISCSI_AUTH_METHOD_CHAP; -- } -- -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value); -+ case ISCSI_AUTH_INITIAL: -+ // -+ // It's the initial Login Request. Fill in the key=value pairs mandatory -+ // for the initial Login Request. -+ // -+ IScsiAddKeyValuePair ( -+ Pdu, -+ ISCSI_KEY_INITIATOR_NAME, -+ mPrivate->InitiatorName -+ ); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal"); -+ IScsiAddKeyValuePair ( -+ Pdu, -+ ISCSI_KEY_TARGET_NAME, -+ Session->ConfigData->SessionConfigData.TargetName -+ ); - -- break; -+ if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) { -+ Value = ISCSI_KEY_VALUE_NONE; -+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT); -+ } else { -+ Value = ISCSI_AUTH_METHOD_CHAP; -+ } - -- case ISCSI_CHAP_STEP_ONE: -- // -- // First step, send the Login Request with CHAP_A= key-value -- // pair. -- // -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_AUTH_METHOD, Value); - -- Conn->AuthStep = ISCSI_CHAP_STEP_TWO; -- break; -+ break; - -- case ISCSI_CHAP_STEP_THREE: -- // -- // Third step, send the Login Request with CHAP_N= CHAP_R= or -- // CHAP_N= CHAP_R= CHAP_I= CHAP_C= if target authentication is -- // required too. -- // -- // CHAP_N= -- // -- IScsiAddKeyValuePair ( -- Pdu, -- ISCSI_KEY_CHAP_NAME, -- (CHAR8 *) &AuthData->AuthConfig->CHAPName -- ); -- // -- // CHAP_R= -- // -- ASSERT (AuthData->Hash != NULL); -- BinToHexStatus = IScsiBinToHex ( -- (UINT8 *) AuthData->CHAPResponse, -- AuthData->Hash->DigestSize, -- Response, -- &RspLen -- ); -- ASSERT_EFI_ERROR (BinToHexStatus); -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response); -- -- if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) { -+ case ISCSI_CHAP_STEP_ONE: - // -- // CHAP_I= -+ // First step, send the Login Request with CHAP_A= key-value -+ // pair. - // -- IScsiGenRandom ((UINT8 *) &AuthData->OutIdentifier, 1); -- AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier); -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, mChapHashListString); -+ -+ Conn->AuthStep = ISCSI_CHAP_STEP_TWO; -+ break; -+ -+ case ISCSI_CHAP_STEP_THREE: - // -- // CHAP_C= -+ // Third step, send the Login Request with CHAP_N= CHAP_R= or -+ // CHAP_N= CHAP_R= CHAP_I= CHAP_C= if target authentication is -+ // required too. - // -- IScsiGenRandom ( -- (UINT8 *) AuthData->OutChallenge, -- AuthData->Hash->DigestSize -+ // CHAP_N= -+ // -+ IScsiAddKeyValuePair ( -+ Pdu, -+ ISCSI_KEY_CHAP_NAME, -+ (CHAR8 *)&AuthData->AuthConfig->CHAPName - ); -+ // -+ // CHAP_R= -+ // -+ ASSERT (AuthData->Hash != NULL); - BinToHexStatus = IScsiBinToHex ( -- (UINT8 *) AuthData->OutChallenge, -+ (UINT8 *)AuthData->CHAPResponse, - AuthData->Hash->DigestSize, -- Challenge, -- &ChallengeLen -+ Response, -+ &RspLen - ); - ASSERT_EFI_ERROR (BinToHexStatus); -- IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response); -+ -+ if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) { -+ // -+ // CHAP_I= -+ // -+ IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1); -+ AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr); -+ // -+ // CHAP_C= -+ // -+ IScsiGenRandom ( -+ (UINT8 *)AuthData->OutChallenge, -+ AuthData->Hash->DigestSize -+ ); -+ BinToHexStatus = IScsiBinToHex ( -+ (UINT8 *)AuthData->OutChallenge, -+ AuthData->Hash->DigestSize, -+ Challenge, -+ &ChallengeLen -+ ); -+ ASSERT_EFI_ERROR (BinToHexStatus); -+ IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge); -+ -+ Conn->AuthStep = ISCSI_CHAP_STEP_FOUR; -+ } - -- Conn->AuthStep = ISCSI_CHAP_STEP_FOUR; -- } -- // -- // Set the stage transition flag. -- // -- ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT); -- break; -+ // -+ // Set the stage transition flag. -+ // -+ ISCSI_SET_FLAG (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT); -+ break; - -- default: -- Status = EFI_PROTOCOL_ERROR; -- break; -+ default: -+ Status = EFI_PROTOCOL_ERROR; -+ break; - } - - FreePool (Response); -@@ -621,14 +627,14 @@ IScsiCHAPInitHashList ( - VOID - ) - { -- CHAR8 *Position; -- UINTN Left; -- UINTN HashIndex; -- CONST CHAP_HASH *Hash; -- UINTN Printed; -+ CHAR8 *Position; -+ UINTN Left; -+ UINTN HashIndex; -+ CONST CHAP_HASH *Hash; -+ UINTN Printed; - - Position = mChapHashListString; -- Left = sizeof (mChapHashListString); -+ Left = sizeof (mChapHashListString); - for (HashIndex = 0; HashIndex < ARRAY_SIZE (mChapHash); HashIndex++) { - Hash = &mChapHash[HashIndex]; - -@@ -657,7 +663,7 @@ IScsiCHAPInitHashList ( - ASSERT (Printed + 1 < Left); - - Position += Printed; -- Left -= Printed; -+ Left -= Printed; - - // - // Sanity-check the digest size for Hash. -diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c -index 4069547867..b3ea90158f 100644 ---- a/NetworkPkg/IScsiDxe/IScsiMisc.c -+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c -@@ -21,22 +21,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFa - **/ - VOID - IScsiStrTrim ( -- IN OUT CHAR16 *Str, -- IN CHAR16 CharC -+ IN OUT CHAR16 *Str, -+ IN CHAR16 CharC - ) - { - CHAR16 *Pointer1; - CHAR16 *Pointer2; - - if (*Str == 0) { -- return ; -+ return; - } - - // - // Trim off the leading and trailing characters c - // - for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) { -- ; - } - - Pointer2 = Str; -@@ -47,18 +46,18 @@ IScsiStrTrim ( - } - } else { - while (*Pointer1 != 0) { -- *Pointer2 = *Pointer1; -- Pointer1++; -- Pointer2++; -+ *Pointer2 = *Pointer1; -+ Pointer1++; -+ Pointer2++; - } -+ - *Pointer2 = 0; - } - -- -- for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) { -- ; -+ for (Pointer1 = Str + StrLen (Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) { - } -- if (Pointer1 != Str + StrLen(Str) - 1) { -+ -+ if (Pointer1 != Str + StrLen (Str) - 1) { - *(Pointer1 + 1) = 0; - } - } -@@ -101,10 +100,9 @@ IScsiGetSubnetMaskPrefixLength ( - Len++; - } - -- return (UINT8) (32 - Len); -+ return (UINT8)(32 - Len); - } - -- - /** - Convert the hexadecimal encoded LUN string into the 64-bit LUN. - -@@ -128,15 +126,15 @@ IScsiAsciiStrToLun ( - - ZeroMem (Lun, 8); - ZeroMem (TemStr, 2); -- ZeroMem ((UINT8 *) Value, sizeof (Value)); -+ ZeroMem ((UINT8 *)Value, sizeof (Value)); - SizeStr = AsciiStrLen (Str); - IndexValue = 0; - IndexNum = 0; - -- for (Index = 0; Index < SizeStr; Index ++) { -+ for (Index = 0; Index < SizeStr; Index++) { - TemStr[0] = Str[Index]; -- TemValue = (UINT8) AsciiStrHexToUint64 (TemStr); -- if (TemValue == 0 && TemStr[0] != '0') { -+ TemValue = (UINT8)AsciiStrHexToUint64 (TemStr); -+ if ((TemValue == 0) && (TemStr[0] != '0')) { - if ((TemStr[0] != '-') || (IndexNum == 0)) { - // - // Invalid Lun Char. -@@ -155,6 +153,7 @@ IScsiAsciiStrToLun ( - // - return EFI_INVALID_PARAMETER; - } -+ - // - // Restart str index for the next lun value. - // -@@ -172,11 +171,11 @@ IScsiAsciiStrToLun ( - // - // Combine UINT16 value. - // -- Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue); -+ Value[IndexValue] = (UINT16)((Value[IndexValue] << 4) + TemValue); - } - -- for (Index = 0; Index <= IndexValue; Index ++) { -- *((UINT16 *) &Lun[Index * 2]) = HTONS (Value[Index]); -+ for (Index = 0; Index <= IndexValue; Index++) { -+ *((UINT16 *)&Lun[Index * 2]) = HTONS (Value[Index]); - } - - return EFI_SUCCESS; -@@ -201,26 +200,26 @@ IScsiLunToUnicodeStr ( - TempStr = Str; - - for (Index = 0; Index < 4; Index++) { -- - if ((Lun[2 * Index] | Lun[2 * Index + 1]) == 0) { - CopyMem (TempStr, L"0-", sizeof (L"0-")); - } else { -- TempStr[0] = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4]; -- TempStr[1] = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F]; -- TempStr[2] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] >> 4]; -- TempStr[3] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0x0F]; -- TempStr[4] = L'-'; -- TempStr[5] = 0; -+ TempStr[0] = (CHAR16)IScsiHexString[Lun[2 * Index] >> 4]; -+ TempStr[1] = (CHAR16)IScsiHexString[Lun[2 * Index] & 0x0F]; -+ TempStr[2] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] >> 4]; -+ TempStr[3] = (CHAR16)IScsiHexString[Lun[2 * Index + 1] & 0x0F]; -+ TempStr[4] = L'-'; -+ TempStr[5] = 0; - - IScsiStrTrim (TempStr, L'0'); - } - - TempStr += StrLen (TempStr); - } -+ - // - // Remove the last '-' - // -- ASSERT (StrLen(Str) >= 1); -+ ASSERT (StrLen (Str) >= 1); - Str[StrLen (Str) - 1] = 0; - - for (Index = StrLen (Str) - 1; Index > 1; Index = Index - 2) { -@@ -246,26 +245,24 @@ IScsiLunToUnicodeStr ( - **/ - EFI_STATUS - IScsiAsciiStrToIp ( -- IN CHAR8 *Str, -- IN UINT8 IpMode, -- OUT EFI_IP_ADDRESS *Ip -+ IN CHAR8 *Str, -+ IN UINT8 IpMode, -+ OUT EFI_IP_ADDRESS *Ip - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - -- if (IpMode == IP_MODE_IP4 || IpMode == IP_MODE_AUTOCONFIG_IP4) { -+ if ((IpMode == IP_MODE_IP4) || (IpMode == IP_MODE_AUTOCONFIG_IP4)) { - return NetLibAsciiStrToIp4 (Str, &Ip->v4); -- -- } else if (IpMode == IP_MODE_IP6 || IpMode == IP_MODE_AUTOCONFIG_IP6) { -+ } else if ((IpMode == IP_MODE_IP6) || (IpMode == IP_MODE_AUTOCONFIG_IP6)) { - return NetLibAsciiStrToIp6 (Str, &Ip->v6); -- - } else if (IpMode == IP_MODE_AUTOCONFIG) { - Status = NetLibAsciiStrToIp4 (Str, &Ip->v4); - if (!EFI_ERROR (Status)) { - return Status; - } -- return NetLibAsciiStrToIp6 (Str, &Ip->v6); - -+ return NetLibAsciiStrToIp6 (Str, &Ip->v6); - } - - return EFI_INVALID_PARAMETER; -@@ -292,14 +289,14 @@ IScsiMacAddrToStr ( - CHAR16 *String; - - for (Index = 0; Index < Len; Index++) { -- Str[3 * Index] = (CHAR16) IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F]; -- Str[3 * Index + 1] = (CHAR16) IScsiHexString[Mac->Addr[Index] & 0x0F]; -- Str[3 * Index + 2] = L':'; -+ Str[3 * Index] = (CHAR16)IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F]; -+ Str[3 * Index + 1] = (CHAR16)IScsiHexString[Mac->Addr[Index] & 0x0F]; -+ Str[3 * Index + 2] = L':'; - } - -- String = &Str[3 * Index - 1] ; -+ String = &Str[3 * Index - 1]; - if (VlanId != 0) { -- String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN) VlanId); -+ String += UnicodeSPrint (String, 6 * sizeof (CHAR16), L"\\%04x", (UINTN)VlanId); - } - - *String = L'\0'; -@@ -322,15 +319,15 @@ IScsiMacAddrToStr ( - **/ - EFI_STATUS - IScsiBinToHex ( -- IN UINT8 *BinBuffer, -- IN UINT32 BinLength, -- IN OUT CHAR8 *HexStr, -- IN OUT UINT32 *HexLength -+ IN UINT8 *BinBuffer, -+ IN UINT32 BinLength, -+ IN OUT CHAR8 *HexStr, -+ IN OUT UINT32 *HexLength - ) - { -- UINT32 HexLengthMin; -- UINT32 HexLengthProvided; -- UINT32 Index; -+ UINT32 HexLengthMin; -+ UINT32 HexLengthProvided; -+ UINT32 Index; - - if ((HexStr == NULL) || (BinBuffer == NULL) || (BinLength == 0)) { - return EFI_INVALID_PARAMETER; -@@ -340,12 +337,13 @@ IScsiBinToHex ( - // Safely calculate: HexLengthMin := BinLength * 2 + 3. - // - if (RETURN_ERROR (SafeUint32Mult (BinLength, 2, &HexLengthMin)) || -- RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin))) { -+ RETURN_ERROR (SafeUint32Add (HexLengthMin, 3, &HexLengthMin))) -+ { - return EFI_BAD_BUFFER_SIZE; - } - - HexLengthProvided = *HexLength; -- *HexLength = HexLengthMin; -+ *HexLength = HexLengthMin; - if (HexLengthProvided < HexLengthMin) { - return EFI_BUFFER_TOO_SMALL; - } -@@ -366,7 +364,6 @@ IScsiBinToHex ( - return EFI_SUCCESS; - } - -- - /** - Convert the hexadecimal string into a binary encoded buffer. - -@@ -385,9 +382,9 @@ IScsiBinToHex ( - **/ - EFI_STATUS - IScsiHexToBin ( -- IN OUT UINT8 *BinBuffer, -- IN OUT UINT32 *BinLength, -- IN CHAR8 *HexStr -+ IN OUT UINT8 *BinBuffer, -+ IN OUT UINT32 *BinLength, -+ IN CHAR8 *HexStr - ) - { - UINTN BinLengthMin; -@@ -411,9 +408,10 @@ IScsiHexToBin ( - // - // Reject an empty hex string; reject a stray nibble. - // -- if (Length == 0 || Length % 2 != 0) { -+ if ((Length == 0) || (Length % 2 != 0)) { - return EFI_INVALID_PARAMETER; - } -+ - // - // Check if the caller provides enough room for the decoded blob. - // -@@ -421,31 +419,33 @@ IScsiHexToBin ( - if (BinLengthMin > MAX_UINT32) { - return EFI_BAD_BUFFER_SIZE; - } -+ - BinLengthProvided = *BinLength; -- *BinLength = (UINT32)BinLengthMin; -+ *BinLength = (UINT32)BinLengthMin; - if (BinLengthProvided < BinLengthMin) { - return EFI_BUFFER_TOO_SMALL; - } - -- for (Index = 0; Index < Length; Index ++) { -+ for (Index = 0; Index < Length; Index++) { - TemStr[0] = HexStr[Index]; -- Digit = (UINT8) AsciiStrHexToUint64 (TemStr); -- if (Digit == 0 && TemStr[0] != '0') { -+ Digit = (UINT8)AsciiStrHexToUint64 (TemStr); -+ if ((Digit == 0) && (TemStr[0] != '0')) { - // - // Invalid Hex Char. - // - return EFI_INVALID_PARAMETER; - } -+ - if ((Index & 1) == 0) { -- BinBuffer [Index/2] = Digit; -+ BinBuffer[Index/2] = Digit; - } else { -- BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit); -+ BinBuffer[Index/2] = (UINT8)((BinBuffer[Index/2] << 4) + Digit); - } - } -+ - return EFI_SUCCESS; - } - -- - /** - Convert the decimal-constant string or hex-constant string into a numerical value. - -@@ -468,7 +468,6 @@ IScsiNetNtoi ( - return AsciiStrDecimalToUintn (Str); - } - -- - /** - Generate random numbers. - -@@ -486,12 +485,11 @@ IScsiGenRandom ( - - while (RandLength > 0) { - Random = NET_RANDOM (NetRandomInitSeed ()); -- *Rand++ = (UINT8) (Random); -+ *Rand++ = (UINT8)(Random); - RandLength--; - } - } - -- - /** - Check whether UNDI protocol supports IPv6. - -@@ -505,22 +503,22 @@ IScsiGenRandom ( - **/ - EFI_STATUS - IScsiCheckIpv6Support ( -- IN EFI_HANDLE ControllerHandle, -- IN EFI_HANDLE Image, -- OUT BOOLEAN *Ipv6Support -+ IN EFI_HANDLE ControllerHandle, -+ IN EFI_HANDLE Image, -+ OUT BOOLEAN *Ipv6Support - ) - { -- EFI_HANDLE Handle; -- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; -- EFI_STATUS Status; -- EFI_GUID *InfoTypesBuffer; -- UINTN InfoTypeBufferCount; -- UINTN TypeIndex; -- BOOLEAN Supported; -- VOID *InfoBlock; -- UINTN InfoBlockSize; -- -- EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii; -+ EFI_HANDLE Handle; -+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; -+ EFI_STATUS Status; -+ EFI_GUID *InfoTypesBuffer; -+ UINTN InfoTypeBufferCount; -+ UINTN TypeIndex; -+ BOOLEAN Supported; -+ VOID *InfoBlock; -+ UINTN InfoBlockSize; -+ -+ EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii; - - ASSERT (Ipv6Support != NULL); - -@@ -530,7 +528,7 @@ IScsiCheckIpv6Support ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, -- (VOID **) &Nii, -+ (VOID **)&Nii, - Image, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -552,16 +550,16 @@ IScsiCheckIpv6Support ( - Status = gBS->HandleProtocol ( - Handle, - &gEfiAdapterInformationProtocolGuid, -- (VOID *) &Aip -+ (VOID *)&Aip - ); -- if (EFI_ERROR (Status) || Aip == NULL) { -+ if (EFI_ERROR (Status) || (Aip == NULL)) { - return EFI_NOT_FOUND; - } - - InfoTypesBuffer = NULL; - InfoTypeBufferCount = 0; -- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); -- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { -+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); -+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) { - FreePool (InfoTypesBuffer); - return EFI_NOT_FOUND; - } -@@ -584,13 +582,13 @@ IScsiCheckIpv6Support ( - // - InfoBlock = NULL; - InfoBlockSize = 0; -- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); -- if (EFI_ERROR (Status) || InfoBlock == NULL) { -+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); -+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) { - FreePool (InfoBlock); - return EFI_NOT_FOUND; - } - -- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support; -+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support; - FreePool (InfoBlock); - - return EFI_SUCCESS; -@@ -613,12 +611,12 @@ IScsiAddNic ( - IN EFI_HANDLE Image - ) - { -- EFI_STATUS Status; -- ISCSI_NIC_INFO *NicInfo; -- LIST_ENTRY *Entry; -- EFI_MAC_ADDRESS MacAddr; -- UINTN HwAddressSize; -- UINT16 VlanId; -+ EFI_STATUS Status; -+ ISCSI_NIC_INFO *NicInfo; -+ LIST_ENTRY *Entry; -+ EFI_MAC_ADDRESS MacAddr; -+ UINTN HwAddressSize; -+ UINT16 VlanId; - - // - // Get MAC address of this network device. -@@ -638,9 +636,10 @@ IScsiAddNic ( - // - NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { - NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); -- if (NicInfo->HwAddressSize == HwAddressSize && -- CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 && -- NicInfo->VlanId == VlanId) { -+ if ((NicInfo->HwAddressSize == HwAddressSize) && -+ (CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) && -+ (NicInfo->VlanId == VlanId)) -+ { - mPrivate->CurrentNic = NicInfo->NicIndex; - - // -@@ -672,10 +671,10 @@ IScsiAddNic ( - } - - CopyMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize); -- NicInfo->HwAddressSize = (UINT32) HwAddressSize; -- NicInfo->VlanId = VlanId; -- NicInfo->NicIndex = (UINT8) (mPrivate->MaxNic + 1); -- mPrivate->MaxNic = NicInfo->NicIndex; -+ NicInfo->HwAddressSize = (UINT32)HwAddressSize; -+ NicInfo->VlanId = VlanId; -+ NicInfo->NicIndex = (UINT8)(mPrivate->MaxNic + 1); -+ mPrivate->MaxNic = NicInfo->NicIndex; - - // - // Set IPv6 available flag. -@@ -706,7 +705,6 @@ IScsiAddNic ( - return EFI_SUCCESS; - } - -- - /** - Delete the recorded NIC info from global structure. Also delete corresponding - attempts. -@@ -722,15 +720,15 @@ IScsiRemoveNic ( - IN EFI_HANDLE Controller - ) - { -- EFI_STATUS Status; -- ISCSI_NIC_INFO *NicInfo; -- LIST_ENTRY *Entry; -- LIST_ENTRY *NextEntry; -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -- ISCSI_NIC_INFO *ThisNic; -- EFI_MAC_ADDRESS MacAddr; -- UINTN HwAddressSize; -- UINT16 VlanId; -+ EFI_STATUS Status; -+ ISCSI_NIC_INFO *NicInfo; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *NextEntry; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -+ ISCSI_NIC_INFO *ThisNic; -+ EFI_MAC_ADDRESS MacAddr; -+ UINTN HwAddressSize; -+ UINT16 VlanId; - - // - // Get MAC address of this network device. -@@ -752,10 +750,10 @@ IScsiRemoveNic ( - - NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { - NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); -- if (NicInfo->HwAddressSize == HwAddressSize && -- CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 && -- NicInfo->VlanId == VlanId) { -- -+ if ((NicInfo->HwAddressSize == HwAddressSize) && -+ (CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0) && -+ (NicInfo->VlanId == VlanId)) -+ { - ThisNic = NicInfo; - break; - } -@@ -780,16 +778,15 @@ IScsiRemoveNic ( - RemoveEntryList (&AttemptConfigData->Link); - mPrivate->AttemptCount--; - -- if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO && mPrivate->MpioCount > 0) { -+ if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) && (mPrivate->MpioCount > 0)) { - if (--mPrivate->MpioCount == 0) { - mPrivate->EnableMpio = FALSE; - } - -- if (AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB && mPrivate->Krb5MpioCount > 0) { -+ if ((AttemptConfigData->AuthenticationType == ISCSI_AUTH_TYPE_KRB) && (mPrivate->Krb5MpioCount > 0)) { - mPrivate->Krb5MpioCount--; - } -- -- } else if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED && mPrivate->SinglePathCount > 0) { -+ } else if ((AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED) && (mPrivate->SinglePathCount > 0)) { - mPrivate->SinglePathCount--; - - if (mPrivate->ValidSinglePathCount > 0) { -@@ -815,19 +812,19 @@ IScsiRemoveNic ( - **/ - EFI_STATUS - IScsiCreateAttempts ( -- IN UINTN AttemptNum --) -+ IN UINTN AttemptNum -+ ) - { -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -- ISCSI_SESSION_CONFIG_NVDATA *ConfigData; -- UINT8 *AttemptConfigOrder; -- UINTN AttemptConfigOrderSize; -- UINT8 *AttemptOrderTmp; -- UINTN TotalNumber; -- UINT8 Index; -- EFI_STATUS Status; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -+ ISCSI_SESSION_CONFIG_NVDATA *ConfigData; -+ UINT8 *AttemptConfigOrder; -+ UINTN AttemptConfigOrderSize; -+ UINT8 *AttemptOrderTmp; -+ UINTN TotalNumber; -+ UINT8 Index; -+ EFI_STATUS Status; - -- for (Index = 1; Index <= AttemptNum; Index ++) { -+ for (Index = 1; Index <= AttemptNum; Index++) { - // - // Get the initialized attempt order. This is used to essure creating attempts by order. - // -@@ -841,6 +838,7 @@ IScsiCreateAttempts ( - Status = EFI_SUCCESS; - break; - } -+ - TotalNumber++; - - // -@@ -851,6 +849,7 @@ IScsiCreateAttempts ( - if (AttemptConfigOrder != NULL) { - FreePool (AttemptConfigOrder); - } -+ - return EFI_OUT_OF_RESOURCES; - } - -@@ -872,10 +871,14 @@ IScsiCreateAttempts ( - ); - FreePool (AttemptConfigOrder); - if (EFI_ERROR (Status)) { -- DEBUG ((DEBUG_ERROR, -+ DEBUG (( -+ DEBUG_ERROR, - "%a: Failed to set 'InitialAttemptOrder' with Guid (%g): " - "%r\n", -- __FUNCTION__, &gIScsiConfigGuid, Status)); -+ __FUNCTION__, -+ &gIScsiConfigGuid, -+ Status -+ )); - return Status; - } - -@@ -886,6 +889,7 @@ IScsiCreateAttempts ( - if (AttemptConfigData == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - ConfigData = &AttemptConfigData->SessionConfigData; - ConfigData->TargetPort = ISCSI_WELL_KNOWN_PORT; - ConfigData->ConnectTimeout = CONNECT_DEFAULT_TIMEOUT; -@@ -903,9 +907,9 @@ IScsiCreateAttempts ( - // - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", -- (UINTN) AttemptConfigData->AttemptConfigIndex -+ (UINTN)AttemptConfigData->AttemptConfigIndex - ); - UnicodeStrToAsciiStrS (mPrivate->PortString, AttemptConfigData->AttemptName, ATTEMPT_NAME_SIZE); - -@@ -918,10 +922,14 @@ IScsiCreateAttempts ( - ); - FreePool (AttemptConfigData); - if (EFI_ERROR (Status)) { -- DEBUG ((DEBUG_ERROR, -- "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): " -- "%r\n", -- __FUNCTION__, &gEfiIScsiInitiatorNameProtocolGuid, Status)); -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: Failed to set variable (mPrivate->PortString) with Guid (%g): " -+ "%r\n", -+ __FUNCTION__, -+ &gEfiIScsiInitiatorNameProtocolGuid, -+ Status -+ )); - return Status; - } - } -@@ -941,18 +949,18 @@ IScsiCreateAttempts ( - **/ - EFI_STATUS - IScsiCreateKeywords ( -- IN UINTN KeywordNum --) -+ IN UINTN KeywordNum -+ ) - { -- VOID *StartOpCodeHandle; -- EFI_IFR_GUID_LABEL *StartLabel; -- VOID *EndOpCodeHandle; -- EFI_IFR_GUID_LABEL *EndLabel; -- UINTN Index; -- EFI_STRING_ID StringToken; -- CHAR16 StringId[64]; -- CHAR16 KeywordId[32]; -- EFI_STATUS Status; -+ VOID *StartOpCodeHandle; -+ EFI_IFR_GUID_LABEL *StartLabel; -+ VOID *EndOpCodeHandle; -+ EFI_IFR_GUID_LABEL *EndLabel; -+ UINTN Index; -+ EFI_STRING_ID StringToken; -+ CHAR16 StringId[64]; -+ CHAR16 KeywordId[32]; -+ EFI_STATUS Status; - - Status = IScsiCreateOpCode ( - KEYWORD_ENTRY_LABEL, -@@ -965,7 +973,7 @@ IScsiCreateKeywords ( - return EFI_OUT_OF_RESOURCES; - } - -- for (Index = 1; Index <= KeywordNum; Index ++) { -+ for (Index = 1; Index <= KeywordNum; Index++) { - // - // Create iSCSIAttemptName Keyword. - // -@@ -980,9 +988,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_ATTEMPT_NAME_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)), -+ (UINT16)(ATTEMPT_ATTEMPT_NAME_VAR_OFFSET + ATTEMPT_NAME_SIZE * (Index - 1) * sizeof (CHAR16)), - StringToken, - StringToken, - EFI_IFR_FLAG_READ_ONLY, -@@ -1006,9 +1014,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_BOOTENABLE_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)), -+ (UINT16)(ATTEMPT_BOOTENABLE_VAR_OFFSET + (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1033,9 +1041,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_ADDRESS_TYPE_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)), -+ (UINT16)(ATTEMPT_ADDRESS_TYPE_VAR_OFFSET + (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1060,9 +1068,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_RETRY_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)), -+ (UINT16)(ATTEMPT_CONNECT_RETRY_VAR_OFFSET + (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1087,9 +1095,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CONNECT_TIMEOUT_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)), -+ (UINT16)(ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET + 2 * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1114,9 +1122,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_ISID_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_ISID_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_ISID_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - STRING_TOKEN (STR_ISCSI_ISID_HELP), - 0, -@@ -1139,19 +1147,19 @@ IScsiCreateKeywords ( - UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIInitiatorInfoViaDHCP:%d", Index); - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( -- StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)), -- CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)), -- StringToken, -- StringToken, -- 0, -- 0, -- 0, -- 1, -- 0, -- NULL -- ); -+ StartOpCodeHandle, -+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_VIA_DHCP_QUESTION_ID + (Index - 1)), -+ CONFIGURATION_VARSTORE_ID, -+ (UINT16)(ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET + (Index - 1)), -+ StringToken, -+ StringToken, -+ 0, -+ 0, -+ 0, -+ 1, -+ 0, -+ NULL -+ ); - - // - // Create iSCSIInitiatorIpAddress Keyword. -@@ -1167,9 +1175,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_IP_ADDRESS_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_INITIATOR_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1193,9 +1201,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_NET_MASK_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_INITIATOR_NET_MASK_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1219,9 +1227,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_INITIATOR_GATE_WAY_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_INITIATOR_GATE_WAY_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1244,19 +1252,19 @@ IScsiCreateKeywords ( - UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSITargetInfoViaDHCP:%d", Index); - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( -- StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)), -- CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)), -- StringToken, -- StringToken, -- 0, -- 0, -- 0, -- 1, -- 0, -- NULL -- ); -+ StartOpCodeHandle, -+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_VIA_DHCP_QUESTION_ID + (Index - 1)), -+ CONFIGURATION_VARSTORE_ID, -+ (UINT16)(ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET + (Index - 1)), -+ StringToken, -+ StringToken, -+ 0, -+ 0, -+ 0, -+ 1, -+ 0, -+ NULL -+ ); - - // - // Create iSCSITargetTcpPort Keyword. -@@ -1272,9 +1280,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_TCP_PORT_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)), -+ (UINT16)(ATTEMPT_TARGET_TCP_PORT_VAR_OFFSET + 2 * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1299,9 +1307,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_NAME_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_TARGET_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1325,9 +1333,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_TARGET_IP_ADDRESS_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_TARGET_IP_ADDRESS_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1351,9 +1359,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_LUN_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_LUN_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_LUN_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1376,19 +1384,19 @@ IScsiCreateKeywords ( - UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIAuthenticationMethod:%d", Index); - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( -- StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)), -- CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)), -- StringToken, -- StringToken, -- 0, -- 0, -- 0, -- 1, -- 0, -- NULL -- ); -+ StartOpCodeHandle, -+ (EFI_QUESTION_ID)(ATTEMPT_AUTHENTICATION_METHOD_QUESTION_ID + (Index - 1)), -+ CONFIGURATION_VARSTORE_ID, -+ (UINT16)(ATTEMPT_AUTHENTICATION_METHOD_VAR_OFFSET + (Index - 1)), -+ StringToken, -+ StringToken, -+ 0, -+ 0, -+ 0, -+ 1, -+ 0, -+ NULL -+ ); - - // - // Create iSCSIChapType Keyword. -@@ -1403,19 +1411,19 @@ IScsiCreateKeywords ( - UnicodeSPrint (KeywordId, sizeof (KeywordId), L"iSCSIChapType:%d", Index); - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateNumericOpCode ( -- StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)), -- CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)), -- StringToken, -- StringToken, -- 0, -- 0, -- 0, -- 1, -- 0, -- NULL -- ); -+ StartOpCodeHandle, -+ (EFI_QUESTION_ID)(ATTEMPT_CHARTYPE_QUESTION_ID + (Index - 1)), -+ CONFIGURATION_VARSTORE_ID, -+ (UINT16)(ATTEMPT_CHARTYPE_VAR_OFFSET + (Index - 1)), -+ StringToken, -+ StringToken, -+ 0, -+ 0, -+ 0, -+ 1, -+ 0, -+ NULL -+ ); - - // - // Create iSCSIChapUsername Keyword. -@@ -1431,9 +1439,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_USER_NAME_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_CHAR_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1457,9 +1465,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_SECRET_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_CHAR_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1483,9 +1491,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_REVERSE_USER_NAME_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1509,9 +1517,9 @@ IScsiCreateKeywords ( - HiiSetString (mCallbackInfo->RegisteredHandle, StringToken, KeywordId, "x-UEFI-ns"); - HiiCreateStringOpCode ( - StartOpCodeHandle, -- (EFI_QUESTION_ID) (ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)), -+ (EFI_QUESTION_ID)(ATTEMPT_CHAR_REVERSE_SECRET_QUESTION_ID + (Index - 1)), - CONFIGURATION_VARSTORE_ID, -- (UINT16) (ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), -+ (UINT16)(ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET + sizeof (KEYWORD_STR) * (Index - 1)), - StringToken, - StringToken, - 0, -@@ -1544,12 +1552,12 @@ IScsiCreateKeywords ( - VOID - IScsiCleanAttemptVariable ( - IN VOID --) -+ ) - { -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -- UINT8 *AttemptConfigOrder; -- UINTN AttemptConfigOrderSize; -- UINTN Index; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -+ UINT8 *AttemptConfigOrder; -+ UINTN AttemptConfigOrderSize; -+ UINTN Index; - - // - // Get the initialized attempt order. -@@ -1559,14 +1567,14 @@ IScsiCleanAttemptVariable ( - &gIScsiConfigGuid, - &AttemptConfigOrderSize - ); -- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { -+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) { - return; - } - - for (Index = 1; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", - Index - ); -@@ -1574,7 +1582,7 @@ IScsiCleanAttemptVariable ( - GetVariable2 ( - mPrivate->PortString, - &gEfiIScsiInitiatorNameProtocolGuid, -- (VOID**)&AttemptConfigData, -+ (VOID **)&AttemptConfigData, - NULL - ); - -@@ -1588,6 +1596,7 @@ IScsiCleanAttemptVariable ( - ); - } - } -+ - return; - } - -@@ -1601,11 +1610,11 @@ IScsiCleanAttemptVariable ( - **/ - ISCSI_NIC_INFO * - IScsiGetNicInfoByIndex ( -- IN UINT8 NicIndex -+ IN UINT8 NicIndex - ) - { -- LIST_ENTRY *Entry; -- ISCSI_NIC_INFO *NicInfo; -+ LIST_ENTRY *Entry; -+ ISCSI_NIC_INFO *NicInfo; - - NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { - NicInfo = NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); -@@ -1617,7 +1626,6 @@ IScsiGetNicInfoByIndex ( - return NULL; - } - -- - /** - Get the NIC's PCI location and return it according to the composited - format defined in iSCSI Boot Firmware Table. -@@ -1647,7 +1655,7 @@ IScsiGetNICPciLocation ( - Status = gBS->HandleProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, -- (VOID **) &DevicePath -+ (VOID **)&DevicePath - ); - if (EFI_ERROR (Status)) { - return 0; -@@ -1662,7 +1670,7 @@ IScsiGetNICPciLocation ( - return 0; - } - -- Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo); -+ Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (VOID **)&PciIo); - if (EFI_ERROR (Status)) { - return 0; - } -@@ -1672,10 +1680,9 @@ IScsiGetNICPciLocation ( - return 0; - } - -- return (UINT16) ((*Bus << 8) | (*Device << 3) | *Function); -+ return (UINT16)((*Bus << 8) | (*Device << 3) | *Function); - } - -- - /** - Read the EFI variable (VendorGuid/Name) and return a dynamically allocated - buffer, and the size of the buffer. If failure, return NULL. -@@ -1691,9 +1698,9 @@ IScsiGetNICPciLocation ( - **/ - VOID * - IScsiGetVariableAndSize ( -- IN CHAR16 *Name, -- IN EFI_GUID *VendorGuid, -- OUT UINTN *VariableSize -+ IN CHAR16 *Name, -+ IN EFI_GUID *VendorGuid, -+ OUT UINTN *VariableSize - ) - { - EFI_STATUS Status; -@@ -1705,8 +1712,8 @@ IScsiGetVariableAndSize ( - // - // Pass in a zero size buffer to find the required buffer size. - // -- BufferSize = 0; -- Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer); -+ BufferSize = 0; -+ Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer); - if (Status == EFI_BUFFER_TOO_SMALL) { - // - // Allocate the buffer to return -@@ -1715,6 +1722,7 @@ IScsiGetVariableAndSize ( - if (Buffer == NULL) { - return NULL; - } -+ - // - // Read variable into the allocated buffer. - // -@@ -1728,7 +1736,6 @@ IScsiGetVariableAndSize ( - return Buffer; - } - -- - /** - Create the iSCSI driver data. - -@@ -1745,8 +1752,8 @@ IScsiCreateDriverData ( - IN EFI_HANDLE Controller - ) - { -- ISCSI_DRIVER_DATA *Private; -- EFI_STATUS Status; -+ ISCSI_DRIVER_DATA *Private; -+ EFI_STATUS Status; - - Private = AllocateZeroPool (sizeof (ISCSI_DRIVER_DATA)); - if (Private == NULL) { -@@ -1776,7 +1783,7 @@ IScsiCreateDriverData ( - } - - Private->ExtScsiPassThruHandle = NULL; -- CopyMem(&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof(EFI_EXT_SCSI_PASS_THRU_PROTOCOL)); -+ CopyMem (&Private->IScsiExtScsiPassThru, &gIScsiExtScsiPassThruProtocolTemplate, sizeof (EFI_EXT_SCSI_PASS_THRU_PROTOCOL)); - - // - // 0 is designated to the TargetId, so use another value for the AdapterId. -@@ -1789,7 +1796,6 @@ IScsiCreateDriverData ( - return Private; - } - -- - /** - Clean the iSCSI driver data. - -@@ -1804,7 +1810,7 @@ IScsiCleanDriverData ( - IN ISCSI_DRIVER_DATA *Private - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - - Status = EFI_SUCCESS; - -@@ -1859,24 +1865,24 @@ IScsiDhcpIsConfigured ( - IN UINT8 IpVersion - ) - { -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -- UINT8 *AttemptConfigOrder; -- UINTN AttemptConfigOrderSize; -- UINTN Index; -- EFI_STATUS Status; -- EFI_MAC_ADDRESS MacAddr; -- UINTN HwAddressSize; -- UINT16 VlanId; -- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -- CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -+ UINT8 *AttemptConfigOrder; -+ UINTN AttemptConfigOrderSize; -+ UINTN Index; -+ EFI_STATUS Status; -+ EFI_MAC_ADDRESS MacAddr; -+ UINTN HwAddressSize; -+ UINT16 VlanId; -+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -+ CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; - - AttemptConfigOrder = IScsiGetVariableAndSize ( - L"AttemptOrder", - &gIScsiConfigGuid, - &AttemptConfigOrderSize - ); -- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { -+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) { - return FALSE; - } - -@@ -1884,29 +1890,30 @@ IScsiDhcpIsConfigured ( - // Get MAC address of this network device. - // - Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize); -- if(EFI_ERROR (Status)) { -+ if (EFI_ERROR (Status)) { - return FALSE; - } -+ - // - // Get VLAN ID of this network device. - // - VlanId = NetLibGetVlanId (Controller); -- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString); -+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString); - - for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { - UnicodeSPrint ( - AttemptName, -- (UINTN) 128, -+ (UINTN)128, - L"Attempt %d", -- (UINTN) AttemptConfigOrder[Index] -+ (UINTN)AttemptConfigOrder[Index] - ); - Status = GetVariable2 ( - AttemptName, - &gEfiIScsiInitiatorNameProtocolGuid, -- (VOID**)&AttemptTmp, -+ (VOID **)&AttemptTmp, - NULL - ); -- if(AttemptTmp == NULL || EFI_ERROR (Status)) { -+ if ((AttemptTmp == NULL) || EFI_ERROR (Status)) { - continue; - } - -@@ -1917,21 +1924,23 @@ IScsiDhcpIsConfigured ( - continue; - } - -- if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG && -- AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) { -+ if ((AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG) && -+ (AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6))) -+ { - FreePool (AttemptTmp); - continue; - } - - AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); - -- if (AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED || StrCmp (MacString, AttemptMacString)) { -+ if ((AttemptTmp->Actived == ISCSI_ACTIVE_DISABLED) || StrCmp (MacString, AttemptMacString)) { - continue; - } - -- if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG || -- AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE || -- AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) { -+ if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) || -+ (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE) || -+ (AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE)) -+ { - FreePool (AttemptTmp); - FreePool (AttemptConfigOrder); - return TRUE; -@@ -1958,24 +1967,24 @@ IScsiDnsIsConfigured ( - IN EFI_HANDLE Controller - ) - { -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -- UINT8 *AttemptConfigOrder; -- UINTN AttemptConfigOrderSize; -- UINTN Index; -- EFI_STATUS Status; -- EFI_MAC_ADDRESS MacAddr; -- UINTN HwAddressSize; -- UINT16 VlanId; -- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -- CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -+ UINT8 *AttemptConfigOrder; -+ UINTN AttemptConfigOrderSize; -+ UINTN Index; -+ EFI_STATUS Status; -+ EFI_MAC_ADDRESS MacAddr; -+ UINTN HwAddressSize; -+ UINT16 VlanId; -+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -+ CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE]; - - AttemptConfigOrder = IScsiGetVariableAndSize ( - L"AttemptOrder", - &gIScsiConfigGuid, - &AttemptConfigOrderSize - ); -- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { -+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) { - return FALSE; - } - -@@ -1983,30 +1992,31 @@ IScsiDnsIsConfigured ( - // Get MAC address of this network device. - // - Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize); -- if(EFI_ERROR (Status)) { -+ if (EFI_ERROR (Status)) { - return FALSE; - } -+ - // - // Get VLAN ID of this network device. - // - VlanId = NetLibGetVlanId (Controller); -- IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString); -+ IScsiMacAddrToStr (&MacAddr, (UINT32)HwAddressSize, VlanId, MacString); - - for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { - UnicodeSPrint ( - AttemptName, -- (UINTN) 128, -+ (UINTN)128, - L"Attempt %d", -- (UINTN) AttemptConfigOrder[Index] -+ (UINTN)AttemptConfigOrder[Index] - ); - - Status = GetVariable2 ( - AttemptName, - &gEfiIScsiInitiatorNameProtocolGuid, -- (VOID**)&AttemptTmp, -+ (VOID **)&AttemptTmp, - NULL - ); -- if(AttemptTmp == NULL || EFI_ERROR (Status)) { -+ if ((AttemptTmp == NULL) || EFI_ERROR (Status)) { - continue; - } - -@@ -2014,7 +2024,7 @@ IScsiDnsIsConfigured ( - - AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); - -- if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED || StrCmp (MacString, AttemptMacString)) { -+ if ((AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) || StrCmp (MacString, AttemptMacString)) { - FreePool (AttemptTmp); - continue; - } -@@ -2027,12 +2037,10 @@ IScsiDnsIsConfigured ( - FreePool (AttemptTmp); - continue; - } -- - } - - FreePool (AttemptConfigOrder); - return FALSE; -- - } - - /** -@@ -2050,17 +2058,17 @@ IScsiGetConfigData ( - IN ISCSI_DRIVER_DATA *Private - ) - { -- EFI_STATUS Status; -- CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -- CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -- UINTN Index; -- ISCSI_NIC_INFO *NicInfo; -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -- ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -- UINT8 *AttemptConfigOrder; -- UINTN AttemptConfigOrderSize; -- CHAR16 IScsiMode[64]; -- CHAR16 IpMode[64]; -+ EFI_STATUS Status; -+ CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; -+ CHAR16 AttemptMacString[ISCSI_MAX_MAC_STRING_LEN]; -+ UINTN Index; -+ ISCSI_NIC_INFO *NicInfo; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData; -+ ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp; -+ UINT8 *AttemptConfigOrder; -+ UINTN AttemptConfigOrderSize; -+ CHAR16 IScsiMode[64]; -+ CHAR16 IpMode[64]; - - // - // There should be at least one attempt configured. -@@ -2070,19 +2078,19 @@ IScsiGetConfigData ( - &gIScsiConfigGuid, - &AttemptConfigOrderSize - ); -- if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) { -+ if ((AttemptConfigOrder == NULL) || (AttemptConfigOrderSize == 0)) { - return EFI_NOT_FOUND; - } - - // - // Get the iSCSI Initiator Name. - // -- mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE; -- Status = gIScsiInitiatorName.Get ( -- &gIScsiInitiatorName, -- &mPrivate->InitiatorNameLength, -- mPrivate->InitiatorName -- ); -+ mPrivate->InitiatorNameLength = ISCSI_NAME_MAX_SIZE; -+ Status = gIScsiInitiatorName.Get ( -+ &gIScsiInitiatorName, -+ &mPrivate->InitiatorNameLength, -+ mPrivate->InitiatorName -+ ); - if (EFI_ERROR (Status)) { - return Status; - } -@@ -2091,27 +2099,29 @@ IScsiGetConfigData ( - // Get the normal configuration. - // - for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) { -- - // - // Check whether the attempt exists in AttemptConfig. - // - AttemptTmp = IScsiConfigGetAttemptByConfigIndex (AttemptConfigOrder[Index]); -- if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) { -+ if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED)) { - continue; -- } else if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED) { -+ } else if ((AttemptTmp != NULL) && (AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED)) { - // - // Check the autoconfig path to see whether it should be retried. - // -- if (AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG && -- !AttemptTmp->AutoConfigureSuccess) { -+ if ((AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) && -+ !AttemptTmp->AutoConfigureSuccess) -+ { - if (mPrivate->Ipv6Flag && -- AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) { -+ (AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)) -+ { - // - // Autoconfigure for IP6 already attempted but failed. Do not try again. - // - continue; - } else if (!mPrivate->Ipv6Flag && -- AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) { -+ (AttemptTmp->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)) -+ { - // - // Autoconfigure for IP4 already attempted but failed. Do not try again. - // -@@ -2121,7 +2131,7 @@ IScsiGetConfigData ( - // Try another approach for this autoconfigure path. - // - AttemptTmp->AutoConfigureMode = -- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4); -+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4); - AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp = TRUE; - AttemptTmp->SessionConfigData.TargetInfoFromDhcp = TRUE; - AttemptTmp->DhcpSuccess = FALSE; -@@ -2146,9 +2156,9 @@ IScsiGetConfigData ( - // - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", -- (UINTN) AttemptTmp->AttemptConfigIndex -+ (UINTN)AttemptTmp->AttemptConfigIndex - ); - - gRT->SetVariable ( -@@ -2163,7 +2173,8 @@ IScsiGetConfigData ( - } - } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && - !AttemptTmp->ValidPath && -- AttemptTmp->NicIndex == mPrivate->CurrentNic) { -+ (AttemptTmp->NicIndex == mPrivate->CurrentNic)) -+ { - // - // If the attempt associates with the current NIC, we can - // get DHCP information for already added, but failed, attempt. -@@ -2186,9 +2197,9 @@ IScsiGetConfigData ( - // - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", -- (UINTN) AttemptTmp->AttemptConfigIndex -+ (UINTN)AttemptTmp->AttemptConfigIndex - ); - - gRT->SetVariable ( -@@ -2200,7 +2211,6 @@ IScsiGetConfigData ( - ); - - continue; -- - } else { - continue; - } -@@ -2215,21 +2225,22 @@ IScsiGetConfigData ( - IScsiMacAddrToStr (&NicInfo->PermanentAddress, NicInfo->HwAddressSize, NicInfo->VlanId, MacString); - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", -- (UINTN) AttemptConfigOrder[Index] -+ (UINTN)AttemptConfigOrder[Index] - ); - - GetVariable2 ( - mPrivate->PortString, - &gEfiIScsiInitiatorNameProtocolGuid, -- (VOID**)&AttemptConfigData, -+ (VOID **)&AttemptConfigData, - NULL - ); - AsciiStrToUnicodeStrS (AttemptConfigData->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0])); - -- if (AttemptConfigData == NULL || AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED || -- StrCmp (MacString, AttemptMacString)) { -+ if ((AttemptConfigData == NULL) || (AttemptConfigData->Actived == ISCSI_ACTIVE_DISABLED) || -+ StrCmp (MacString, AttemptMacString)) -+ { - continue; - } - -@@ -2237,7 +2248,7 @@ IScsiGetConfigData ( - - AttemptConfigData->NicIndex = NicInfo->NicIndex; - AttemptConfigData->DhcpSuccess = FALSE; -- AttemptConfigData->ValidiBFTPath = (BOOLEAN) (mPrivate->EnableMpio ? TRUE : FALSE); -+ AttemptConfigData->ValidiBFTPath = (BOOLEAN)(mPrivate->EnableMpio ? TRUE : FALSE); - AttemptConfigData->ValidPath = FALSE; - - if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) { -@@ -2245,26 +2256,28 @@ IScsiGetConfigData ( - AttemptConfigData->SessionConfigData.TargetInfoFromDhcp = TRUE; - - AttemptConfigData->AutoConfigureMode = -- (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4); -+ (UINT8)(mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4); - AttemptConfigData->AutoConfigureSuccess = FALSE; - } - - // - // Get some information from dhcp server. - // -- if (AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED && -- AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp) { -- -+ if ((AttemptConfigData->SessionConfigData.Enabled != ISCSI_DISABLED) && -+ AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp) -+ { - if (!mPrivate->Ipv6Flag && -- (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4 || -- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4)) { -+ ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) || -+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4))) -+ { - Status = IScsiDoDhcp (Private->Image, Private->Controller, AttemptConfigData); - if (!EFI_ERROR (Status)) { - AttemptConfigData->DhcpSuccess = TRUE; - } - } else if (mPrivate->Ipv6Flag && -- (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6 || -- AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6)) { -+ ((AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) || -+ (AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6))) -+ { - Status = IScsiDoDhcp6 (Private->Image, Private->Controller, AttemptConfigData); - if (!EFI_ERROR (Status)) { - AttemptConfigData->DhcpSuccess = TRUE; -@@ -2276,9 +2289,9 @@ IScsiGetConfigData ( - // - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"Attempt %d", -- (UINTN) AttemptConfigData->AttemptConfigIndex -+ (UINTN)AttemptConfigData->AttemptConfigIndex - ); - - gRT->SetVariable ( -@@ -2312,7 +2325,7 @@ IScsiGetConfigData ( - - UnicodeSPrint ( - mPrivate->PortString, -- (UINTN) ISCSI_NAME_IFR_MAX_SIZE, -+ (UINTN)ISCSI_NAME_IFR_MAX_SIZE, - L"MAC: %s, PFA: Bus %d | Dev %d | Func %d, iSCSI mode: %s, IP version: %s", - MacString, - NicInfo->BusNumber, -@@ -2377,13 +2390,13 @@ IScsiGetConfigData ( - if (mPrivate->SinglePathCount == 0) { - return EFI_NOT_FOUND; - } -+ - mPrivate->ValidSinglePathCount = mPrivate->SinglePathCount; - } - - return EFI_SUCCESS; - } - -- - /** - Get the device path of the iSCSI tcp connection and update it. - -@@ -2395,7 +2408,7 @@ IScsiGetConfigData ( - **/ - EFI_DEVICE_PATH_PROTOCOL * - IScsiGetTcpConnDevicePath ( -- IN ISCSI_SESSION *Session -+ IN ISCSI_SESSION *Session - ) - { - ISCSI_CONNECTION *Conn; -@@ -2418,28 +2431,29 @@ IScsiGetTcpConnDevicePath ( - Status = gBS->HandleProtocol ( - Conn->TcpIo.Handle, - &gEfiDevicePathProtocolGuid, -- (VOID **) &DevicePath -+ (VOID **)&DevicePath - ); - if (EFI_ERROR (Status)) { - return NULL; - } -+ - // - // Duplicate it. - // -- DevicePath = DuplicateDevicePath (DevicePath); -+ DevicePath = DuplicateDevicePath (DevicePath); - if (DevicePath == NULL) { - return NULL; - } - -- DPathNode = (EFI_DEV_PATH *) DevicePath; -+ DPathNode = (EFI_DEV_PATH *)DevicePath; - - while (!IsDevicePathEnd (&DPathNode->DevPath)) { - if (DevicePathType (&DPathNode->DevPath) == MESSAGING_DEVICE_PATH) { -- if (!Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP) { -- DPathNode->Ipv4.LocalPort = 0; -+ if (!Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP)) { -+ DPathNode->Ipv4.LocalPort = 0; - - DPathNode->Ipv4.StaticIpAddress = -- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); -+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); - - // - // Add a judgement here to support previous versions of IPv4_DEVICE_PATH. -@@ -2451,7 +2465,6 @@ IScsiGetTcpConnDevicePath ( - PathLen = DevicePathNodeLength (&DPathNode->Ipv4); - - if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) { -- - IP4_COPY_ADDRESS ( - &DPathNode->Ipv4.GatewayIpAddress, - &Session->ConfigData->SessionConfigData.Gateway -@@ -2464,8 +2477,8 @@ IScsiGetTcpConnDevicePath ( - } - - break; -- } else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) { -- DPathNode->Ipv6.LocalPort = 0; -+ } else if (Conn->Ipv6Flag && (DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP)) { -+ DPathNode->Ipv6.LocalPort = 0; - - // - // Add a judgement here to support previous versions of IPv6_DEVICE_PATH. -@@ -2478,32 +2491,28 @@ IScsiGetTcpConnDevicePath ( - PathLen = DevicePathNodeLength (&DPathNode->Ipv6); - - if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) { -- - DPathNode->Ipv6.IpAddressOrigin = 0; - DPathNode->Ipv6.PrefixLength = IP6_PREFIX_LENGTH; - ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS)); -- } -- else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) { -- -+ } else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) { - // - // StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new - // version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH. - // - *((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) = -- (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); -+ (BOOLEAN)(!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp); - } - - break; - } - } - -- DPathNode = (EFI_DEV_PATH *) NextDevicePathNode (&DPathNode->DevPath); -+ DPathNode = (EFI_DEV_PATH *)NextDevicePathNode (&DPathNode->DevPath); - } - - return DevicePath; - } - -- - /** - Abort the session when the transition from BS to RT is initiated. - -@@ -2518,9 +2527,9 @@ IScsiOnExitBootService ( - IN VOID *Context - ) - { -- ISCSI_DRIVER_DATA *Private; -+ ISCSI_DRIVER_DATA *Private; - -- Private = (ISCSI_DRIVER_DATA *) Context; -+ Private = (ISCSI_DRIVER_DATA *)Context; - - gBS->CloseEvent (Private->ExitBootServiceEvent); - Private->ExitBootServiceEvent = NULL; -@@ -2556,14 +2565,14 @@ IScsiOnExitBootService ( - EFI_STATUS - EFIAPI - IScsiTestManagedDevice ( -- IN EFI_HANDLE ControllerHandle, -- IN EFI_HANDLE DriverBindingHandle, -- IN EFI_GUID *ProtocolGuid -+ IN EFI_HANDLE ControllerHandle, -+ IN EFI_HANDLE DriverBindingHandle, -+ IN EFI_GUID *ProtocolGuid - ) - { -- EFI_STATUS Status; -- VOID *ManagedInterface; -- EFI_HANDLE NicControllerHandle; -+ EFI_STATUS Status; -+ VOID *ManagedInterface; -+ EFI_HANDLE NicControllerHandle; - - ASSERT (ProtocolGuid != NULL); - -@@ -2574,7 +2583,7 @@ IScsiTestManagedDevice ( - - Status = gBS->OpenProtocol ( - ControllerHandle, -- (EFI_GUID *) ProtocolGuid, -+ (EFI_GUID *)ProtocolGuid, - &ManagedInterface, - DriverBindingHandle, - NicControllerHandle, -@@ -2583,7 +2592,7 @@ IScsiTestManagedDevice ( - if (!EFI_ERROR (Status)) { - gBS->CloseProtocol ( - ControllerHandle, -- (EFI_GUID *) ProtocolGuid, -+ (EFI_GUID *)ProtocolGuid, - DriverBindingHandle, - NicControllerHandle - ); -diff --git a/NetworkPkg/Include/Library/NetLib.h b/NetworkPkg/Include/Library/NetLib.h -index 6c09248631..53495aa494 100644 ---- a/NetworkPkg/Include/Library/NetLib.h -+++ b/NetworkPkg/Include/Library/NetLib.h -@@ -15,16 +15,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - --typedef UINT32 IP4_ADDR; --typedef UINT32 TCP_SEQNO; --typedef UINT16 TCP_PORTNO; -+typedef UINT32 IP4_ADDR; -+typedef UINT32 TCP_SEQNO; -+typedef UINT16 TCP_PORTNO; - -+#define NET_ETHER_ADDR_LEN 6 -+#define NET_IFTYPE_ETHERNET 0x01 - --#define NET_ETHER_ADDR_LEN 6 --#define NET_IFTYPE_ETHERNET 0x01 -- --#define NET_VLAN_TAG_LEN 4 --#define ETHER_TYPE_VLAN 0x8100 -+#define NET_VLAN_TAG_LEN 4 -+#define ETHER_TYPE_VLAN 0x8100 - - #define EFI_IP_PROTO_UDP 0x11 - #define EFI_IP_PROTO_TCP 0x06 -@@ -37,73 +36,72 @@ typedef UINT16 TCP_PORTNO; - // - // The address classification - // --#define IP4_ADDR_CLASSA 1 // Deprecated --#define IP4_ADDR_CLASSB 2 // Deprecated --#define IP4_ADDR_CLASSC 3 // Deprecated --#define IP4_ADDR_CLASSD 4 --#define IP4_ADDR_CLASSE 5 -+#define IP4_ADDR_CLASSA 1 // Deprecated -+#define IP4_ADDR_CLASSB 2 // Deprecated -+#define IP4_ADDR_CLASSC 3 // Deprecated -+#define IP4_ADDR_CLASSD 4 -+#define IP4_ADDR_CLASSE 5 - --#define IP4_MASK_NUM 33 --#define IP6_PREFIX_NUM 129 -+#define IP4_MASK_NUM 33 -+#define IP6_PREFIX_NUM 129 - --#define IP4_MASK_MAX 32 --#define IP6_PREFIX_MAX 128 -+#define IP4_MASK_MAX 32 -+#define IP6_PREFIX_MAX 128 - --#define IP6_HOP_BY_HOP 0 --#define IP6_DESTINATION 60 --#define IP6_ROUTING 43 --#define IP6_FRAGMENT 44 --#define IP6_AH 51 --#define IP6_ESP 50 --#define IP6_NO_NEXT_HEADER 59 -+#define IP6_HOP_BY_HOP 0 -+#define IP6_DESTINATION 60 -+#define IP6_ROUTING 43 -+#define IP6_FRAGMENT 44 -+#define IP6_AH 51 -+#define IP6_ESP 50 -+#define IP6_NO_NEXT_HEADER 59 - --#define IP_VERSION_4 4 --#define IP_VERSION_6 6 -+#define IP_VERSION_4 4 -+#define IP_VERSION_6 6 - --#define IP6_PREFIX_LENGTH 64 -+#define IP6_PREFIX_LENGTH 64 - - // - // DNS QTYPE values - // --#define DNS_TYPE_A 1 --#define DNS_TYPE_NS 2 --#define DNS_TYPE_CNAME 5 --#define DNS_TYPE_SOA 6 --#define DNS_TYPE_WKS 11 --#define DNS_TYPE_PTR 12 --#define DNS_TYPE_HINFO 13 --#define DNS_TYPE_MINFO 14 --#define DNS_TYPE_MX 15 --#define DNS_TYPE_TXT 16 --#define DNS_TYPE_AAAA 28 --#define DNS_TYPE_SRV_RR 33 --#define DNS_TYPE_AXFR 252 --#define DNS_TYPE_MAILB 253 --#define DNS_TYPE_ANY 255 -+#define DNS_TYPE_A 1 -+#define DNS_TYPE_NS 2 -+#define DNS_TYPE_CNAME 5 -+#define DNS_TYPE_SOA 6 -+#define DNS_TYPE_WKS 11 -+#define DNS_TYPE_PTR 12 -+#define DNS_TYPE_HINFO 13 -+#define DNS_TYPE_MINFO 14 -+#define DNS_TYPE_MX 15 -+#define DNS_TYPE_TXT 16 -+#define DNS_TYPE_AAAA 28 -+#define DNS_TYPE_SRV_RR 33 -+#define DNS_TYPE_AXFR 252 -+#define DNS_TYPE_MAILB 253 -+#define DNS_TYPE_ANY 255 - - // - // DNS QCLASS values - // --#define DNS_CLASS_INET 1 --#define DNS_CLASS_CH 3 --#define DNS_CLASS_HS 4 --#define DNS_CLASS_ANY 255 -+#define DNS_CLASS_INET 1 -+#define DNS_CLASS_CH 3 -+#define DNS_CLASS_HS 4 -+#define DNS_CLASS_ANY 255 - - // - // Number of 100ns units time Interval for network media state detect - // - #define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U - -- - #pragma pack(1) - - // - // Ethernet head definition - // - typedef struct { -- UINT8 DstMac [NET_ETHER_ADDR_LEN]; -- UINT8 SrcMac [NET_ETHER_ADDR_LEN]; -- UINT16 EtherType; -+ UINT8 DstMac[NET_ETHER_ADDR_LEN]; -+ UINT8 SrcMac[NET_ETHER_ADDR_LEN]; -+ UINT16 EtherType; - } ETHER_HEAD; - - // -@@ -111,11 +109,11 @@ typedef struct { - // - typedef union { - struct { -- UINT16 Vid : 12; // Unique VLAN identifier (0 to 4094) -- UINT16 Cfi : 1; // Canonical Format Indicator -- UINT16 Priority : 3; // 802.1Q priority level (0 to 7) -+ UINT16 Vid : 12; // Unique VLAN identifier (0 to 4094) -+ UINT16 Cfi : 1; // Canonical Format Indicator -+ UINT16 Priority : 3; // 802.1Q priority level (0 to 7) - } Bits; -- UINT16 Uint16; -+ UINT16 Uint16; - } VLAN_TCI; - - #define VLAN_TCI_CFI_CANONICAL_MAC 0 -@@ -128,83 +126,82 @@ typedef union { - // directly. This is why there is an internal representation. - // - typedef struct { -- UINT8 HeadLen : 4; -- UINT8 Ver : 4; -- UINT8 Tos; -- UINT16 TotalLen; -- UINT16 Id; -- UINT16 Fragment; -- UINT8 Ttl; -- UINT8 Protocol; -- UINT16 Checksum; -- IP4_ADDR Src; -- IP4_ADDR Dst; -+ UINT8 HeadLen : 4; -+ UINT8 Ver : 4; -+ UINT8 Tos; -+ UINT16 TotalLen; -+ UINT16 Id; -+ UINT16 Fragment; -+ UINT8 Ttl; -+ UINT8 Protocol; -+ UINT16 Checksum; -+ IP4_ADDR Src; -+ IP4_ADDR Dst; - } IP4_HEAD; - -- - // - // ICMP head definition. Each ICMP message is categorized as either an error - // message or query message. Two message types have their own head format. - // - typedef struct { -- UINT8 Type; -- UINT8 Code; -- UINT16 Checksum; -+ UINT8 Type; -+ UINT8 Code; -+ UINT16 Checksum; - } IP4_ICMP_HEAD; - - typedef struct { -- IP4_ICMP_HEAD Head; -- UINT32 Fourth; // 4th filed of the head, it depends on Type. -- IP4_HEAD IpHead; -+ IP4_ICMP_HEAD Head; -+ UINT32 Fourth; // 4th filed of the head, it depends on Type. -+ IP4_HEAD IpHead; - } IP4_ICMP_ERROR_HEAD; - - typedef struct { -- IP4_ICMP_HEAD Head; -- UINT16 Id; -- UINT16 Seq; -+ IP4_ICMP_HEAD Head; -+ UINT16 Id; -+ UINT16 Seq; - } IP4_ICMP_QUERY_HEAD; - - typedef struct { -- UINT8 Type; -- UINT8 Code; -- UINT16 Checksum; -+ UINT8 Type; -+ UINT8 Code; -+ UINT16 Checksum; - } IP6_ICMP_HEAD; - - typedef struct { -- IP6_ICMP_HEAD Head; -- UINT32 Fourth; -- EFI_IP6_HEADER IpHead; -+ IP6_ICMP_HEAD Head; -+ UINT32 Fourth; -+ EFI_IP6_HEADER IpHead; - } IP6_ICMP_ERROR_HEAD; - - typedef struct { -- IP6_ICMP_HEAD Head; -- UINT32 Fourth; -+ IP6_ICMP_HEAD Head; -+ UINT32 Fourth; - } IP6_ICMP_INFORMATION_HEAD; - - // - // UDP header definition - // - typedef struct { -- UINT16 SrcPort; -- UINT16 DstPort; -- UINT16 Length; -- UINT16 Checksum; -+ UINT16 SrcPort; -+ UINT16 DstPort; -+ UINT16 Length; -+ UINT16 Checksum; - } EFI_UDP_HEADER; - - // - // TCP header definition - // - typedef struct { -- TCP_PORTNO SrcPort; -- TCP_PORTNO DstPort; -- TCP_SEQNO Seq; -- TCP_SEQNO Ack; -- UINT8 Res : 4; -- UINT8 HeadLen : 4; -- UINT8 Flag; -- UINT16 Wnd; -- UINT16 Checksum; -- UINT16 Urg; -+ TCP_PORTNO SrcPort; -+ TCP_PORTNO DstPort; -+ TCP_SEQNO Seq; -+ TCP_SEQNO Ack; -+ UINT8 Res : 4; -+ UINT8 HeadLen : 4; -+ UINT8 Flag; -+ UINT16 Wnd; -+ UINT16 Checksum; -+ UINT16 Urg; - } TCP_HEAD; - - #pragma pack() -@@ -221,11 +218,11 @@ typedef struct { - - #define NTOHS(x) SwapBytes16 (x) - --#define HTONS(x) NTOHS(x) --#define NTOHLL(x) SwapBytes64 (x) --#define HTONLL(x) NTOHLL(x) --#define NTOHLLL(x) Ip6Swap128 (x) --#define HTONLLL(x) NTOHLLL(x) -+#define HTONS(x) NTOHS(x) -+#define NTOHLL(x) SwapBytes64 (x) -+#define HTONLL(x) NTOHLL(x) -+#define NTOHLLL(x) Ip6Swap128 (x) -+#define HTONLLL(x) NTOHLLL(x) - - // - // Test the IP's attribute, All the IPs are in host byte order. -@@ -236,7 +233,7 @@ typedef struct { - #define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) == ((Ip2) & (NetMask))) - #define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != (IP4_MASK_MAX + 1)) - --#define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF) -+#define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF) - - // - // Convert the EFI_IP4_ADDRESS to plain UINT32 IP4 address. -@@ -247,17 +244,17 @@ typedef struct { - - #define EFI_IP6_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv6_ADDRESS)) == 0) - --#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS))) --#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS))) --#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS))) -+#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS))) -+#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS))) -+#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS))) - - // - // The debug level definition. This value is also used as the - // syslog's severity level. Don't change it. - // --#define NETDEBUG_LEVEL_TRACE 5 --#define NETDEBUG_LEVEL_WARNING 4 --#define NETDEBUG_LEVEL_ERROR 3 -+#define NETDEBUG_LEVEL_TRACE 5 -+#define NETDEBUG_LEVEL_WARNING 4 -+#define NETDEBUG_LEVEL_ERROR 3 - - // - // Network debug message is sent out as syslog packet. -@@ -326,7 +323,7 @@ typedef struct { - CHAR8 * - EFIAPI - NetDebugASPrint ( -- IN CHAR8 *Format, -+ IN CHAR8 *Format, - ... - ); - -@@ -350,14 +347,13 @@ NetDebugASPrint ( - EFI_STATUS - EFIAPI - NetDebugOutput ( -- IN UINT32 Level, -- IN UINT8 *Module, -- IN UINT8 *File, -- IN UINT32 Line, -- IN UINT8 *Message -+ IN UINT32 Level, -+ IN UINT8 *Module, -+ IN UINT8 *File, -+ IN UINT32 Line, -+ IN UINT8 *Message - ); - -- - /** - Return the length of the mask. - -@@ -373,7 +369,7 @@ NetDebugOutput ( - INTN - EFIAPI - NetGetMaskLength ( -- IN IP4_ADDR NetMask -+ IN IP4_ADDR NetMask - ); - - /** -@@ -405,7 +401,7 @@ NetGetMaskLength ( - INTN - EFIAPI - NetGetIpClass ( -- IN IP4_ADDR Addr -+ IN IP4_ADDR Addr - ); - - /** -@@ -428,8 +424,8 @@ NetGetIpClass ( - BOOLEAN - EFIAPI - NetIp4IsUnicast ( -- IN IP4_ADDR Ip, -- IN IP4_ADDR NetMask -+ IN IP4_ADDR Ip, -+ IN IP4_ADDR NetMask - ); - - /** -@@ -451,10 +447,9 @@ NetIp4IsUnicast ( - BOOLEAN - EFIAPI - NetIp6IsValidUnicast ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ); - -- - /** - Check whether the incoming Ipv6 address is the unspecified address or not. - -@@ -469,7 +464,7 @@ NetIp6IsValidUnicast ( - BOOLEAN - EFIAPI - NetIp6IsUnspecifiedAddr ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ); - - /** -@@ -486,7 +481,7 @@ NetIp6IsUnspecifiedAddr ( - BOOLEAN - EFIAPI - NetIp6IsLinkLocalAddr ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ); - - /** -@@ -506,9 +501,9 @@ NetIp6IsLinkLocalAddr ( - BOOLEAN - EFIAPI - NetIp6IsNetEqual ( -- EFI_IPv6_ADDRESS *Ip1, -- EFI_IPv6_ADDRESS *Ip2, -- UINT8 PrefixLength -+ EFI_IPv6_ADDRESS *Ip1, -+ EFI_IPv6_ADDRESS *Ip2, -+ UINT8 PrefixLength - ); - - /** -@@ -528,11 +523,10 @@ NetIp6IsNetEqual ( - EFI_IPv6_ADDRESS * - EFIAPI - Ip6Swap128 ( -- EFI_IPv6_ADDRESS *Ip6 -+ EFI_IPv6_ADDRESS *Ip6 - ); - --extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM]; -- -+extern IP4_ADDR gIp4AllMasks[IP4_MASK_NUM]; - - extern EFI_IPv4_ADDRESS mZeroIp4Addr; - -@@ -542,10 +536,10 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr; - #define NET_IS_LOWER_CASE_CHAR(Ch) (('a' <= (Ch)) && ((Ch) <= 'z')) - #define NET_IS_UPPER_CASE_CHAR(Ch) (('A' <= (Ch)) && ((Ch) <= 'Z')) - --#define TICKS_PER_MS 10000U --#define TICKS_PER_SECOND 10000000U -+#define TICKS_PER_MS 10000U -+#define TICKS_PER_SECOND 10000000U - --#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL) -+#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL) - - /** - Extract a UINT32 from a byte stream. -@@ -563,7 +557,7 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr; - UINT32 - EFIAPI - NetGetUint32 ( -- IN UINT8 *Buf -+ IN UINT8 *Buf - ); - - /** -@@ -581,8 +575,8 @@ NetGetUint32 ( - VOID - EFIAPI - NetPutUint32 ( -- IN OUT UINT8 *Buf, -- IN UINT32 Data -+ IN OUT UINT8 *Buf, -+ IN UINT32 Data - ); - - /** -@@ -601,7 +595,6 @@ NetRandomInitSeed ( - VOID - ); - -- - #define NET_LIST_USER_STRUCT(Entry, Type, Field) \ - BASE_CR(Entry, Type, Field) - -@@ -635,7 +628,6 @@ NetRandomInitSeed ( - #define NET_LIST_TAIL(ListHead, Type, Field) \ - NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field) - -- - /** - Remove the first node entry on the list, and return the removed node entry. - -@@ -657,7 +649,7 @@ NetRandomInitSeed ( - LIST_ENTRY * - EFIAPI - NetListRemoveHead ( -- IN OUT LIST_ENTRY *Head -+ IN OUT LIST_ENTRY *Head - ); - - /** -@@ -681,7 +673,7 @@ NetListRemoveHead ( - LIST_ENTRY * - EFIAPI - NetListRemoveTail ( -- IN OUT LIST_ENTRY *Head -+ IN OUT LIST_ENTRY *Head - ); - - /** -@@ -699,8 +691,8 @@ NetListRemoveTail ( - VOID - EFIAPI - NetListInsertAfter ( -- IN OUT LIST_ENTRY *PrevEntry, -- IN OUT LIST_ENTRY *NewEntry -+ IN OUT LIST_ENTRY *PrevEntry, -+ IN OUT LIST_ENTRY *NewEntry - ); - - /** -@@ -718,8 +710,8 @@ NetListInsertAfter ( - VOID - EFIAPI - NetListInsertBefore ( -- IN OUT LIST_ENTRY *PostEntry, -- IN OUT LIST_ENTRY *NewEntry -+ IN OUT LIST_ENTRY *PostEntry, -+ IN OUT LIST_ENTRY *NewEntry - ); - - /** -@@ -734,7 +726,7 @@ NetListInsertBefore ( - **/ - typedef - EFI_STATUS --(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK) ( -+(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK)( - IN LIST_ENTRY *Entry, - IN VOID *Context OPTIONAL - ); -@@ -785,9 +777,9 @@ NetDestroyLinkList ( - BOOLEAN - EFIAPI - NetIsInHandleBuffer ( -- IN EFI_HANDLE Handle, -- IN UINTN NumberOfChildren, -- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL -+ IN EFI_HANDLE Handle, -+ IN UINTN NumberOfChildren, -+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ); - - // -@@ -795,15 +787,15 @@ NetIsInHandleBuffer ( - // tokens. The drivers can share code to manage those objects. - // - typedef struct { -- LIST_ENTRY Link; -- VOID *Key; -- VOID *Value; -+ LIST_ENTRY Link; -+ VOID *Key; -+ VOID *Value; - } NET_MAP_ITEM; - - typedef struct { -- LIST_ENTRY Used; -- LIST_ENTRY Recycled; -- UINTN Count; -+ LIST_ENTRY Used; -+ LIST_ENTRY Recycled; -+ UINTN Count; - } NET_MAP; - - #define NET_MAP_INCREAMENT 64 -@@ -825,7 +817,7 @@ typedef struct { - VOID - EFIAPI - NetMapInit ( -- IN OUT NET_MAP *Map -+ IN OUT NET_MAP *Map - ); - - /** -@@ -843,7 +835,7 @@ NetMapInit ( - VOID - EFIAPI - NetMapClean ( -- IN OUT NET_MAP *Map -+ IN OUT NET_MAP *Map - ); - - /** -@@ -861,7 +853,7 @@ NetMapClean ( - BOOLEAN - EFIAPI - NetMapIsEmpty ( -- IN NET_MAP *Map -+ IN NET_MAP *Map - ); - - /** -@@ -877,7 +869,7 @@ NetMapIsEmpty ( - UINTN - EFIAPI - NetMapGetCount ( -- IN NET_MAP *Map -+ IN NET_MAP *Map - ); - - /** -@@ -901,9 +893,9 @@ NetMapGetCount ( - EFI_STATUS - EFIAPI - NetMapInsertHead ( -- IN OUT NET_MAP *Map, -- IN VOID *Key, -- IN VOID *Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN VOID *Key, -+ IN VOID *Value OPTIONAL - ); - - /** -@@ -927,9 +919,9 @@ NetMapInsertHead ( - EFI_STATUS - EFIAPI - NetMapInsertTail ( -- IN OUT NET_MAP *Map, -- IN VOID *Key, -- IN VOID *Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN VOID *Key, -+ IN VOID *Value OPTIONAL - ); - - /** -@@ -950,8 +942,8 @@ NetMapInsertTail ( - NET_MAP_ITEM * - EFIAPI - NetMapFindKey ( -- IN NET_MAP *Map, -- IN VOID *Key -+ IN NET_MAP *Map, -+ IN VOID *Key - ); - - /** -@@ -976,9 +968,9 @@ NetMapFindKey ( - VOID * - EFIAPI - NetMapRemoveItem ( -- IN OUT NET_MAP *Map, -- IN OUT NET_MAP_ITEM *Item, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN OUT NET_MAP_ITEM *Item, -+ OUT VOID **Value OPTIONAL - ); - - /** -@@ -1001,8 +993,8 @@ NetMapRemoveItem ( - VOID * - EFIAPI - NetMapRemoveHead ( -- IN OUT NET_MAP *Map, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ OUT VOID **Value OPTIONAL - ); - - /** -@@ -1025,13 +1017,13 @@ NetMapRemoveHead ( - VOID * - EFIAPI - NetMapRemoveTail ( -- IN OUT NET_MAP *Map, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ OUT VOID **Value OPTIONAL - ); - - typedef - EFI_STATUS --(EFIAPI *NET_MAP_CALLBACK) ( -+(EFIAPI *NET_MAP_CALLBACK)( - IN NET_MAP *Map, - IN NET_MAP_ITEM *Item, - IN VOID *Arg -@@ -1059,15 +1051,15 @@ EFI_STATUS - EFI_STATUS - EFIAPI - NetMapIterate ( -- IN NET_MAP *Map, -- IN NET_MAP_CALLBACK CallBack, -- IN VOID *Arg OPTIONAL -+ IN NET_MAP *Map, -+ IN NET_MAP_CALLBACK CallBack, -+ IN VOID *Arg OPTIONAL - ); - -- - // - // Helper functions to implement driver binding and service binding protocols. - // -+ - /** - Create a child of the service that is identified by ServiceBindingGuid. - -@@ -1088,10 +1080,10 @@ NetMapIterate ( - EFI_STATUS - EFIAPI - NetLibCreateServiceChild ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE Image, -- IN EFI_GUID *ServiceBindingGuid, -- IN OUT EFI_HANDLE *ChildHandle -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE Image, -+ IN EFI_GUID *ServiceBindingGuid, -+ IN OUT EFI_HANDLE *ChildHandle - ); - - /** -@@ -1113,10 +1105,10 @@ NetLibCreateServiceChild ( - EFI_STATUS - EFIAPI - NetLibDestroyServiceChild ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE Image, -- IN EFI_GUID *ServiceBindingGuid, -- IN EFI_HANDLE ChildHandle -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE Image, -+ IN EFI_GUID *ServiceBindingGuid, -+ IN EFI_HANDLE ChildHandle - ); - - /** -@@ -1138,8 +1130,8 @@ NetLibDestroyServiceChild ( - EFI_HANDLE - EFIAPI - NetLibGetSnpHandle ( -- IN EFI_HANDLE ServiceHandle, -- OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL -+ IN EFI_HANDLE ServiceHandle, -+ OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL - ); - - /** -@@ -1158,7 +1150,7 @@ NetLibGetSnpHandle ( - UINT16 - EFIAPI - NetLibGetVlanId ( -- IN EFI_HANDLE ServiceHandle -+ IN EFI_HANDLE ServiceHandle - ); - - /** -@@ -1178,8 +1170,8 @@ NetLibGetVlanId ( - EFI_HANDLE - EFIAPI - NetLibGetVlanHandle ( -- IN EFI_HANDLE ControllerHandle, -- IN UINT16 VlanId -+ IN EFI_HANDLE ControllerHandle, -+ IN UINT16 VlanId - ); - - /** -@@ -1204,9 +1196,9 @@ NetLibGetVlanHandle ( - EFI_STATUS - EFIAPI - NetLibGetMacAddress ( -- IN EFI_HANDLE ServiceHandle, -- OUT EFI_MAC_ADDRESS *MacAddress, -- OUT UINTN *AddressSize -+ IN EFI_HANDLE ServiceHandle, -+ OUT EFI_MAC_ADDRESS *MacAddress, -+ OUT UINTN *AddressSize - ); - - /** -@@ -1274,8 +1266,8 @@ NetLibGetMacString ( - EFI_STATUS - EFIAPI - NetLibDetectMedia ( -- IN EFI_HANDLE ServiceHandle, -- OUT BOOLEAN *MediaPresent -+ IN EFI_HANDLE ServiceHandle, -+ OUT BOOLEAN *MediaPresent - ); - - /** -@@ -1305,12 +1297,11 @@ NetLibDetectMedia ( - EFI_STATUS - EFIAPI - NetLibDetectMediaWaitTimeout ( -- IN EFI_HANDLE ServiceHandle, -- IN UINT64 Timeout, -- OUT EFI_STATUS *MediaState -+ IN EFI_HANDLE ServiceHandle, -+ IN UINT64 Timeout, -+ OUT EFI_STATUS *MediaState - ); - -- - /** - Create an IPv4 device path node. - -@@ -1377,7 +1368,6 @@ NetLibCreateIPv6DPathNode ( - IN UINT16 Protocol - ); - -- - /** - Find the UNDI/SNP handle from controller and protocol GUID. - -@@ -1400,8 +1390,8 @@ NetLibCreateIPv6DPathNode ( - EFI_HANDLE - EFIAPI - NetLibGetNicHandle ( -- IN EFI_HANDLE Controller, -- IN EFI_GUID *ProtocolGuid -+ IN EFI_HANDLE Controller, -+ IN EFI_GUID *ProtocolGuid - ); - - /** -@@ -1419,7 +1409,7 @@ NetLibGetNicHandle ( - EFI_STATUS - EFIAPI - NetLibDefaultUnload ( -- IN EFI_HANDLE ImageHandle -+ IN EFI_HANDLE ImageHandle - ); - - /** -@@ -1435,8 +1425,8 @@ NetLibDefaultUnload ( - EFI_STATUS - EFIAPI - NetLibAsciiStrToIp4 ( -- IN CONST CHAR8 *String, -- OUT EFI_IPv4_ADDRESS *Ip4Address -+ IN CONST CHAR8 *String, -+ OUT EFI_IPv4_ADDRESS *Ip4Address - ); - - /** -@@ -1453,8 +1443,8 @@ NetLibAsciiStrToIp4 ( - EFI_STATUS - EFIAPI - NetLibAsciiStrToIp6 ( -- IN CONST CHAR8 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address -+ IN CONST CHAR8 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address - ); - - /** -@@ -1470,8 +1460,8 @@ NetLibAsciiStrToIp6 ( - EFI_STATUS - EFIAPI - NetLibStrToIp4 ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv4_ADDRESS *Ip4Address -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv4_ADDRESS *Ip4Address - ); - - /** -@@ -1488,8 +1478,8 @@ NetLibStrToIp4 ( - EFI_STATUS - EFIAPI - NetLibStrToIp6 ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address - ); - - /** -@@ -1508,9 +1498,9 @@ NetLibStrToIp6 ( - EFI_STATUS - EFIAPI - NetLibStrToIp6andPrefix ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address, -- OUT UINT8 *PrefixLength -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address, -+ OUT UINT8 *PrefixLength - ); - - /** -@@ -1530,23 +1520,22 @@ NetLibStrToIp6andPrefix ( - EFI_STATUS - EFIAPI - NetLibIp6ToStr ( -- IN EFI_IPv6_ADDRESS *Ip6Address, -- OUT CHAR16 *String, -- IN UINTN StringSize -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ OUT CHAR16 *String, -+ IN UINTN StringSize - ); - - // - // Various signatures - // --#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f') --#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c') --#define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u') -- -+#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f') -+#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c') -+#define NET_QUE_SIGNATURE SIGNATURE_32 ('n', 'b', 'q', 'u') - --#define NET_PROTO_DATA 64 // Opaque buffer for protocols --#define NET_BUF_HEAD 1 // Trim or allocate space from head --#define NET_BUF_TAIL 0 // Trim or allocate space from tail --#define NET_VECTOR_OWN_FIRST 0x01 // We allocated the 1st block in the vector -+#define NET_PROTO_DATA 64 // Opaque buffer for protocols -+#define NET_BUF_HEAD 1 // Trim or allocate space from head -+#define NET_BUF_TAIL 0 // Trim or allocate space from tail -+#define NET_VECTOR_OWN_FIRST 0x01 // We allocated the 1st block in the vector - - #define NET_CHECK_SIGNATURE(PData, SIGNATURE) \ - ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE))) -@@ -1555,39 +1544,39 @@ NetLibIp6ToStr ( - // Single memory block in the vector. - // - typedef struct { -- UINT32 Len; // The block's length -- UINT8 *Bulk; // The block's Data -+ UINT32 Len; // The block's length -+ UINT8 *Bulk; // The block's Data - } NET_BLOCK; - --typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE) (VOID *Arg); -+typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE)(VOID *Arg); - - // --//NET_VECTOR contains several blocks to hold all packet's --//fragments and other house-keeping stuff for sharing. It --//doesn't specify the where actual packet fragment begins. -+// NET_VECTOR contains several blocks to hold all packet's -+// fragments and other house-keeping stuff for sharing. It -+// doesn't specify the where actual packet fragment begins. - // - typedef struct { -- UINT32 Signature; -- INTN RefCnt; // Reference count to share NET_VECTOR. -- NET_VECTOR_EXT_FREE Free; // external function to free NET_VECTOR -- VOID *Arg; // opaque argument to Free -- UINT32 Flag; // Flags, NET_VECTOR_OWN_FIRST -- UINT32 Len; // Total length of the associated BLOCKs -- -- UINT32 BlockNum; -- NET_BLOCK Block[1]; -+ UINT32 Signature; -+ INTN RefCnt; // Reference count to share NET_VECTOR. -+ NET_VECTOR_EXT_FREE Free; // external function to free NET_VECTOR -+ VOID *Arg; // opaque argument to Free -+ UINT32 Flag; // Flags, NET_VECTOR_OWN_FIRST -+ UINT32 Len; // Total length of the associated BLOCKs -+ -+ UINT32 BlockNum; -+ NET_BLOCK Block[1]; - } NET_VECTOR; - - // --//NET_BLOCK_OP operates on the NET_BLOCK. It specifies --//where the actual fragment begins and ends -+// NET_BLOCK_OP operates on the NET_BLOCK. It specifies -+// where the actual fragment begins and ends - // - typedef struct { -- UINT8 *BlockHead; // Block's head, or the smallest valid Head -- UINT8 *BlockTail; // Block's tail. BlockTail-BlockHead=block length -- UINT8 *Head; // 1st byte of the data in the block -- UINT8 *Tail; // Tail of the data in the block, Tail-Head=Size -- UINT32 Size; // The size of the data -+ UINT8 *BlockHead; // Block's head, or the smallest valid Head -+ UINT8 *BlockTail; // Block's tail. BlockTail-BlockHead=block length -+ UINT8 *Head; // 1st byte of the data in the block -+ UINT8 *Tail; // Tail of the data in the block, Tail-Head=Size -+ UINT32 Size; // The size of the data - } NET_BLOCK_OP; - - typedef union { -@@ -1596,44 +1585,44 @@ typedef union { - } NET_IP_HEAD; - - // --//NET_BUF is the buffer manage structure used by the --//network stack. Every network packet may be fragmented. The Vector points to --//memory blocks used by each fragment, and BlockOp --//specifies where each fragment begins and ends. -+// NET_BUF is the buffer manage structure used by the -+// network stack. Every network packet may be fragmented. The Vector points to -+// memory blocks used by each fragment, and BlockOp -+// specifies where each fragment begins and ends. - // --//It also contains an opaque area for the protocol to store --//per-packet information. Protocol must be careful not --//to overwrite the members after that. -+// It also contains an opaque area for the protocol to store -+// per-packet information. Protocol must be careful not -+// to overwrite the members after that. - // - typedef struct { -- UINT32 Signature; -- INTN RefCnt; -- LIST_ENTRY List; // The List this NET_BUF is on -+ UINT32 Signature; -+ INTN RefCnt; -+ LIST_ENTRY List; // The List this NET_BUF is on - -- NET_IP_HEAD Ip; // Network layer header, for fast access -- TCP_HEAD *Tcp; // Transport layer header, for fast access -- EFI_UDP_HEADER *Udp; // User Datagram Protocol header -- UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data -+ NET_IP_HEAD Ip; // Network layer header, for fast access -+ TCP_HEAD *Tcp; // Transport layer header, for fast access -+ EFI_UDP_HEADER *Udp; // User Datagram Protocol header -+ UINT8 ProtoData[NET_PROTO_DATA]; // Protocol specific data - -- NET_VECTOR *Vector; // The vector containing the packet -+ NET_VECTOR *Vector; // The vector containing the packet - -- UINT32 BlockOpNum; // Total number of BlockOp in the buffer -- UINT32 TotalSize; // Total size of the actual packet -- NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet -+ UINT32 BlockOpNum; // Total number of BlockOp in the buffer -+ UINT32 TotalSize; // Total size of the actual packet -+ NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet - } NET_BUF; - - // --//A queue of NET_BUFs. It is a thin extension of --//NET_BUF functions. -+// A queue of NET_BUFs. It is a thin extension of -+// NET_BUF functions. - // - typedef struct { -- UINT32 Signature; -- INTN RefCnt; -- LIST_ENTRY List; // The List this buffer queue is on -+ UINT32 Signature; -+ INTN RefCnt; -+ LIST_ENTRY List; // The List this buffer queue is on - -- LIST_ENTRY BufList; // list of queued buffers -- UINT32 BufSize; // total length of DATA in the buffers -- UINT32 BufNum; // total number of buffers on the chain -+ LIST_ENTRY BufList; // list of queued buffers -+ UINT32 BufSize; // total length of DATA in the buffers -+ UINT32 BufNum; // total number of buffers on the chain - } NET_BUF_QUEUE; - - // -@@ -1641,19 +1630,19 @@ typedef struct { - // - #pragma pack(1) - typedef struct { -- IP4_ADDR SrcIp; -- IP4_ADDR DstIp; -- UINT8 Reserved; -- UINT8 Protocol; -- UINT16 Len; -+ IP4_ADDR SrcIp; -+ IP4_ADDR DstIp; -+ UINT8 Reserved; -+ UINT8 Protocol; -+ UINT16 Len; - } NET_PSEUDO_HDR; - - typedef struct { - EFI_IPv6_ADDRESS SrcIp; - EFI_IPv6_ADDRESS DstIp; - UINT32 Len; -- UINT32 Reserved:24; -- UINT32 NextHeader:8; -+ UINT32 Reserved : 24; -+ UINT32 NextHeader : 8; - } NET_IP6_PSEUDO_HDR; - #pragma pack() - -@@ -1663,13 +1652,13 @@ typedef struct { - // the two in case that NET_BLOCK be enhanced later. - // - typedef struct { -- UINT32 Len; -- UINT8 *Bulk; -+ UINT32 Len; -+ UINT8 *Bulk; - } NET_FRAGMENT; - --#define NET_GET_REF(PData) ((PData)->RefCnt++) --#define NET_PUT_REF(PData) ((PData)->RefCnt--) --#define NETBUF_FROM_PROTODATA(Info) BASE_CR((Info), NET_BUF, ProtoData) -+#define NET_GET_REF(PData) ((PData)->RefCnt++) -+#define NET_PUT_REF(PData) ((PData)->RefCnt--) -+#define NETBUF_FROM_PROTODATA(Info) BASE_CR((Info), NET_BUF, ProtoData) - - #define NET_BUF_SHARED(Buf) \ - (((Buf)->RefCnt > 1) || ((Buf)->Vector->RefCnt > 1)) -@@ -1699,7 +1688,7 @@ typedef struct { - NET_BUF * - EFIAPI - NetbufAlloc ( -- IN UINT32 Len -+ IN UINT32 Len - ); - - /** -@@ -1717,7 +1706,7 @@ NetbufAlloc ( - VOID - EFIAPI - NetbufFree ( -- IN NET_BUF *Nbuf -+ IN NET_BUF *Nbuf - ); - - /** -@@ -1740,9 +1729,9 @@ NetbufFree ( - UINT8 * - EFIAPI - NetbufGetByte ( -- IN NET_BUF *Nbuf, -- IN UINT32 Offset, -- OUT UINT32 *Index OPTIONAL -+ IN NET_BUF *Nbuf, -+ IN UINT32 Offset, -+ OUT UINT32 *Index OPTIONAL - ); - - /** -@@ -1760,7 +1749,7 @@ NetbufGetByte ( - NET_BUF * - EFIAPI - NetbufClone ( -- IN NET_BUF *Nbuf -+ IN NET_BUF *Nbuf - ); - - /** -@@ -1782,9 +1771,9 @@ NetbufClone ( - NET_BUF * - EFIAPI - NetbufDuplicate ( -- IN NET_BUF *Nbuf, -- IN OUT NET_BUF *Duplicate OPTIONAL, -- IN UINT32 HeadSpace -+ IN NET_BUF *Nbuf, -+ IN OUT NET_BUF *Duplicate OPTIONAL, -+ IN UINT32 HeadSpace - ); - - /** -@@ -1807,10 +1796,10 @@ NetbufDuplicate ( - NET_BUF * - EFIAPI - NetbufGetFragment ( -- IN NET_BUF *Nbuf, -- IN UINT32 Offset, -- IN UINT32 Len, -- IN UINT32 HeadSpace -+ IN NET_BUF *Nbuf, -+ IN UINT32 Offset, -+ IN UINT32 Len, -+ IN UINT32 HeadSpace - ); - - /** -@@ -1828,8 +1817,8 @@ NetbufGetFragment ( - VOID - EFIAPI - NetbufReserve ( -- IN OUT NET_BUF *Nbuf, -- IN UINT32 Len -+ IN OUT NET_BUF *Nbuf, -+ IN UINT32 Len - ); - - /** -@@ -1844,12 +1833,12 @@ NetbufReserve ( - or NULL, if there is no sufficient space. - - **/ --UINT8* -+UINT8 * - EFIAPI - NetbufAllocSpace ( -- IN OUT NET_BUF *Nbuf, -- IN UINT32 Len, -- IN BOOLEAN FromHead -+ IN OUT NET_BUF *Nbuf, -+ IN UINT32 Len, -+ IN BOOLEAN FromHead - ); - - /** -@@ -1867,9 +1856,9 @@ NetbufAllocSpace ( - UINT32 - EFIAPI - NetbufTrim ( -- IN OUT NET_BUF *Nbuf, -- IN UINT32 Len, -- IN BOOLEAN FromHead -+ IN OUT NET_BUF *Nbuf, -+ IN UINT32 Len, -+ IN BOOLEAN FromHead - ); - - /** -@@ -1890,10 +1879,10 @@ NetbufTrim ( - UINT32 - EFIAPI - NetbufCopy ( -- IN NET_BUF *Nbuf, -- IN UINT32 Offset, -- IN UINT32 Len, -- IN UINT8 *Dest -+ IN NET_BUF *Nbuf, -+ IN UINT32 Offset, -+ IN UINT32 Len, -+ IN UINT8 *Dest - ); - - /** -@@ -1921,12 +1910,12 @@ NetbufCopy ( - NET_BUF * - EFIAPI - NetbufFromExt ( -- IN NET_FRAGMENT *ExtFragment, -- IN UINT32 ExtNum, -- IN UINT32 HeadSpace, -- IN UINT32 HeadLen, -- IN NET_VECTOR_EXT_FREE ExtFree, -- IN VOID *Arg OPTIONAL -+ IN NET_FRAGMENT *ExtFragment, -+ IN UINT32 ExtNum, -+ IN UINT32 HeadSpace, -+ IN UINT32 HeadLen, -+ IN NET_VECTOR_EXT_FREE ExtFree, -+ IN VOID *Arg OPTIONAL - ); - - /** -@@ -1945,9 +1934,9 @@ NetbufFromExt ( - EFI_STATUS - EFIAPI - NetbufBuildExt ( -- IN NET_BUF *Nbuf, -- IN OUT NET_FRAGMENT *ExtFragment, -- IN OUT UINT32 *ExtNum -+ IN NET_BUF *Nbuf, -+ IN OUT NET_FRAGMENT *ExtFragment, -+ IN OUT UINT32 *ExtNum - ); - - /** -@@ -1970,11 +1959,11 @@ NetbufBuildExt ( - NET_BUF * - EFIAPI - NetbufFromBufList ( -- IN LIST_ENTRY *BufList, -- IN UINT32 HeadSpace, -- IN UINT32 HeaderLen, -- IN NET_VECTOR_EXT_FREE ExtFree, -- IN VOID *Arg OPTIONAL -+ IN LIST_ENTRY *BufList, -+ IN UINT32 HeadSpace, -+ IN UINT32 HeaderLen, -+ IN NET_VECTOR_EXT_FREE ExtFree, -+ IN VOID *Arg OPTIONAL - ); - - /** -@@ -1986,7 +1975,7 @@ NetbufFromBufList ( - VOID - EFIAPI - NetbufFreeList ( -- IN OUT LIST_ENTRY *Head -+ IN OUT LIST_ENTRY *Head - ); - - /** -@@ -1998,7 +1987,7 @@ NetbufFreeList ( - VOID - EFIAPI - NetbufQueInit ( -- IN OUT NET_BUF_QUEUE *NbufQue -+ IN OUT NET_BUF_QUEUE *NbufQue - ); - - /** -@@ -2027,7 +2016,7 @@ NetbufQueAlloc ( - VOID - EFIAPI - NetbufQueFree ( -- IN NET_BUF_QUEUE *NbufQue -+ IN NET_BUF_QUEUE *NbufQue - ); - - /** -@@ -2042,7 +2031,7 @@ NetbufQueFree ( - NET_BUF * - EFIAPI - NetbufQueRemove ( -- IN OUT NET_BUF_QUEUE *NbufQue -+ IN OUT NET_BUF_QUEUE *NbufQue - ); - - /** -@@ -2055,8 +2044,8 @@ NetbufQueRemove ( - VOID - EFIAPI - NetbufQueAppend ( -- IN OUT NET_BUF_QUEUE *NbufQue, -- IN OUT NET_BUF *Nbuf -+ IN OUT NET_BUF_QUEUE *NbufQue, -+ IN OUT NET_BUF *Nbuf - ); - - /** -@@ -2078,10 +2067,10 @@ NetbufQueAppend ( - UINT32 - EFIAPI - NetbufQueCopy ( -- IN NET_BUF_QUEUE *NbufQue, -- IN UINT32 Offset, -- IN UINT32 Len, -- OUT UINT8 *Dest -+ IN NET_BUF_QUEUE *NbufQue, -+ IN UINT32 Offset, -+ IN UINT32 Len, -+ OUT UINT8 *Dest - ); - - /** -@@ -2100,11 +2089,10 @@ NetbufQueCopy ( - UINT32 - EFIAPI - NetbufQueTrim ( -- IN OUT NET_BUF_QUEUE *NbufQue, -- IN UINT32 Len -+ IN OUT NET_BUF_QUEUE *NbufQue, -+ IN UINT32 Len - ); - -- - /** - Flush the net buffer queue. - -@@ -2114,7 +2102,7 @@ NetbufQueTrim ( - VOID - EFIAPI - NetbufQueFlush ( -- IN OUT NET_BUF_QUEUE *NbufQue -+ IN OUT NET_BUF_QUEUE *NbufQue - ); - - /** -@@ -2129,8 +2117,8 @@ NetbufQueFlush ( - UINT16 - EFIAPI - NetblockChecksum ( -- IN UINT8 *Bulk, -- IN UINT32 Len -+ IN UINT8 *Bulk, -+ IN UINT32 Len - ); - - /** -@@ -2145,8 +2133,8 @@ NetblockChecksum ( - UINT16 - EFIAPI - NetAddChecksum ( -- IN UINT16 Checksum1, -- IN UINT16 Checksum2 -+ IN UINT16 Checksum1, -+ IN UINT16 Checksum2 - ); - - /** -@@ -2160,7 +2148,7 @@ NetAddChecksum ( - UINT16 - EFIAPI - NetbufChecksum ( -- IN NET_BUF *Nbuf -+ IN NET_BUF *Nbuf - ); - - /** -@@ -2179,10 +2167,10 @@ NetbufChecksum ( - UINT16 - EFIAPI - NetPseudoHeadChecksum ( -- IN IP4_ADDR Src, -- IN IP4_ADDR Dst, -- IN UINT8 Proto, -- IN UINT16 Len -+ IN IP4_ADDR Src, -+ IN IP4_ADDR Dst, -+ IN UINT8 Proto, -+ IN UINT16 Len - ); - - /** -@@ -2201,10 +2189,10 @@ NetPseudoHeadChecksum ( - UINT16 - EFIAPI - NetIp6PseudoHeadChecksum ( -- IN EFI_IPv6_ADDRESS *Src, -- IN EFI_IPv6_ADDRESS *Dst, -- IN UINT8 NextHeader, -- IN UINT32 Len -+ IN EFI_IPv6_ADDRESS *Src, -+ IN EFI_IPv6_ADDRESS *Dst, -+ IN UINT8 NextHeader, -+ IN UINT32 Len - ); - - /** -@@ -2220,7 +2208,7 @@ NetIp6PseudoHeadChecksum ( - **/ - VOID - NetIpSecNetbufFree ( -- NET_BUF *Nbuf -+ NET_BUF *Nbuf - ); - - /** -@@ -2237,7 +2225,7 @@ NetIpSecNetbufFree ( - EFI_STATUS - EFIAPI - NetLibGetSystemGuid ( -- OUT EFI_GUID *SystemGuid -+ OUT EFI_GUID *SystemGuid - ); - - /** -@@ -2260,7 +2248,7 @@ NetLibGetSystemGuid ( - CHAR8 * - EFIAPI - NetLibCreateDnsQName ( -- IN CHAR16 *DomainName -+ IN CHAR16 *DomainName - ); - - #endif -diff --git a/NetworkPkg/Ip4Dxe/Ip4Driver.c b/NetworkPkg/Ip4Dxe/Ip4Driver.c -index 7fed659ca1..ec483ff01f 100644 ---- a/NetworkPkg/Ip4Dxe/Ip4Driver.c -+++ b/NetworkPkg/Ip4Dxe/Ip4Driver.c -@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - #include "Ip4Impl.h" - --EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gIp4DriverBinding = { - Ip4DriverBindingSupported, - Ip4DriverBindingStart, - Ip4DriverBindingStop, -@@ -35,13 +35,14 @@ IpSec2InstalledCallback ( - IN VOID *Context - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; -+ - // - // Test if protocol was even found. - // Notification function will be called at least once. - // - Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec); -- if (Status == EFI_SUCCESS && mIpSec != NULL) { -+ if ((Status == EFI_SUCCESS) && (mIpSec != NULL)) { - // - // Close the event so it does not get called again. - // -@@ -69,11 +70,11 @@ IpSec2InstalledCallback ( - EFI_STATUS - EFIAPI - Ip4DriverEntryPoint ( -- IN EFI_HANDLE ImageHandle, -- IN EFI_SYSTEM_TABLE *SystemTable -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable - ) - { -- VOID *Registration; -+ VOID *Registration; - - EfiCreateProtocolNotifyEvent ( - &gEfiIpSec2ProtocolGuid, -@@ -114,12 +115,12 @@ Ip4DriverEntryPoint ( - EFI_STATUS - EFIAPI - Ip4DriverBindingSupported ( -- IN EFI_DRIVER_BINDING_PROTOCOL * This, -+ IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, -- IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL -+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - - // - // Test for the MNP service binding Protocol -@@ -167,10 +168,9 @@ Ip4DriverBindingSupported ( - **/ - EFI_STATUS - Ip4CleanService ( -- IN IP4_SERVICE *IpSb -+ IN IP4_SERVICE *IpSb - ); - -- - /** - Create a new IP4 driver service binding private instance. - -@@ -187,13 +187,13 @@ Ip4CleanService ( - **/ - EFI_STATUS - Ip4CreateService ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE ImageHandle, -- OUT IP4_SERVICE **Service -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE ImageHandle, -+ OUT IP4_SERVICE **Service - ) - { -- IP4_SERVICE *IpSb; -- EFI_STATUS Status; -+ IP4_SERVICE *IpSb; -+ EFI_STATUS Status; - - ASSERT (Service != NULL); - -@@ -215,23 +215,23 @@ Ip4CreateService ( - IpSb->ServiceBinding.DestroyChild = Ip4ServiceBindingDestroyChild; - IpSb->State = IP4_SERVICE_UNSTARTED; - -- IpSb->NumChildren = 0; -+ IpSb->NumChildren = 0; - InitializeListHead (&IpSb->Children); - - InitializeListHead (&IpSb->Interfaces); -- IpSb->DefaultInterface = NULL; -- IpSb->DefaultRouteTable = NULL; -+ IpSb->DefaultInterface = NULL; -+ IpSb->DefaultRouteTable = NULL; - - Ip4InitAssembleTable (&IpSb->Assemble); - -- IpSb->IgmpCtrl.Igmpv1QuerySeen = 0; -+ IpSb->IgmpCtrl.Igmpv1QuerySeen = 0; - InitializeListHead (&IpSb->IgmpCtrl.Groups); - -- IpSb->Image = ImageHandle; -- IpSb->Controller = Controller; -+ IpSb->Image = ImageHandle; -+ IpSb->Controller = Controller; - -- IpSb->MnpChildHandle = NULL; -- IpSb->Mnp = NULL; -+ IpSb->MnpChildHandle = NULL; -+ IpSb->Mnp = NULL; - - IpSb->MnpConfigData.ReceivedQueueTimeoutValue = 0; - IpSb->MnpConfigData.TransmitQueueTimeoutValue = 0; -@@ -246,7 +246,7 @@ Ip4CreateService ( - - ZeroMem (&IpSb->SnpMode, sizeof (EFI_SIMPLE_NETWORK_MODE)); - -- IpSb->Timer = NULL; -+ IpSb->Timer = NULL; - IpSb->ReconfigCheckTimer = NULL; - - IpSb->ReconfigEvent = NULL; -@@ -316,7 +316,7 @@ Ip4CreateService ( - Status = gBS->OpenProtocol ( - IpSb->MnpChildHandle, - &gEfiManagedNetworkProtocolGuid, -- (VOID **) &IpSb->Mnp, -+ (VOID **)&IpSb->Mnp, - ImageHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -345,7 +345,7 @@ Ip4CreateService ( - } - - IpSb->MacString = NULL; -- Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString); -+ Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &IpSb->MacString); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; -@@ -375,8 +375,9 @@ Ip4CreateService ( - // - IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN; - } -+ - IpSb->OldMaxPacketSize = IpSb->MaxPacketSize; -- *Service = IpSb; -+ *Service = IpSb; - - return EFI_SUCCESS; - -@@ -387,7 +388,6 @@ ON_ERROR: - return Status; - } - -- - /** - Clean up a IP4 service binding instance. It will release all - the resource allocated by the instance. The instance may be -@@ -403,12 +403,12 @@ ON_ERROR: - **/ - EFI_STATUS - Ip4CleanService ( -- IN IP4_SERVICE *IpSb -+ IN IP4_SERVICE *IpSb - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - -- IpSb->State = IP4_SERVICE_DESTROY; -+ IpSb->State = IP4_SERVICE_DESTROY; - - if (IpSb->Timer != NULL) { - gBS->SetTimer (IpSb->Timer, TimerCancel, 0); -@@ -493,8 +493,8 @@ Ip4CleanService ( - EFI_STATUS - EFIAPI - Ip4DestroyChildEntryInHandleBuffer ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { - IP4_PROTOCOL *IpInstance; -@@ -502,14 +502,14 @@ Ip4DestroyChildEntryInHandleBuffer ( - UINTN NumberOfChildren; - EFI_HANDLE *ChildHandleBuffer; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE); -- ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; -- NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; -- ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; -+ IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE); -+ ServiceBinding = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding; -+ NumberOfChildren = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren; -+ ChildHandleBuffer = ((IP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer; - - if (!NetIsInHandleBuffer (IpInstance->Handle, NumberOfChildren, ChildHandleBuffer)) { - return EFI_SUCCESS; -@@ -544,11 +544,11 @@ Ip4DriverBindingStart ( - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) - { -- EFI_STATUS Status; -- IP4_SERVICE *IpSb; -- EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; -- UINTN Index; -- IP4_CONFIG2_DATA_ITEM *DataItem; -+ EFI_STATUS Status; -+ IP4_SERVICE *IpSb; -+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; -+ UINTN Index; -+ IP4_CONFIG2_DATA_ITEM *DataItem; - - IpSb = NULL; - Ip4Cfg2 = NULL; -@@ -578,7 +578,7 @@ Ip4DriverBindingStart ( - - ASSERT (IpSb != NULL); - -- Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2; -+ Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2; - - // - // Install the Ip4ServiceBinding Protocol onto ControllerHandle -@@ -617,11 +617,11 @@ Ip4DriverBindingStart ( - DataItem->DataSize, - DataItem->Data.Ptr - ); -- if (EFI_ERROR(Status)) { -+ if (EFI_ERROR (Status)) { - goto UNINSTALL_PROTOCOL; - } - -- if (Index == Ip4Config2DataTypePolicy && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) { -+ if ((Index == Ip4Config2DataTypePolicy) && (*(DataItem->Data.Policy) == Ip4Config2PolicyDhcp)) { - break; - } - } -@@ -634,7 +634,7 @@ Ip4DriverBindingStart ( - // - Status = Ip4ReceiveFrame (IpSb->DefaultInterface, NULL, Ip4AccpetFrame, IpSb); - -- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) { -+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { - goto UNINSTALL_PROTOCOL; - } - -@@ -673,7 +673,6 @@ FREE_SERVICE: - return Status; - } - -- - /** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to -@@ -711,9 +710,9 @@ Ip4DriverBindingStop ( - IP4_INTERFACE *IpIf; - IP4_ROUTE_TABLE *RouteTable; - -- BOOLEAN IsDhcp4; -+ BOOLEAN IsDhcp4; - -- IsDhcp4 = FALSE; -+ IsDhcp4 = FALSE; - - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); - if (NicHandle == NULL) { -@@ -731,7 +730,7 @@ Ip4DriverBindingStop ( - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiIp4ServiceBindingProtocolGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - This->DriverBindingHandle, - NicHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -747,18 +746,17 @@ Ip4DriverBindingStop ( - gBS->CloseEvent (IpSb->Ip4Config2Instance.Dhcp4Event); - IpSb->Ip4Config2Instance.Dhcp4Event = NULL; - } else if (NumberOfChildren != 0) { -- List = &IpSb->Children; -+ List = &IpSb->Children; - Context.ServiceBinding = ServiceBinding; - Context.NumberOfChildren = NumberOfChildren; - Context.ChildHandleBuffer = ChildHandleBuffer; -- Status = NetDestroyLinkList ( -- List, -- Ip4DestroyChildEntryInHandleBuffer, -- &Context, -- NULL -- ); -+ Status = NetDestroyLinkList ( -+ List, -+ Ip4DestroyChildEntryInHandleBuffer, -+ &Context, -+ NULL -+ ); - } else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) { -- - // - // The ARP protocol for the default interface is being uninstalled and all - // its IP child handles should have been destroyed before. So, release the -@@ -772,21 +770,21 @@ Ip4DriverBindingStop ( - if (IpIf == NULL) { - goto ON_ERROR; - } -+ - RouteTable = Ip4CreateRouteTable (); - if (RouteTable == NULL) { - Ip4FreeInterface (IpIf, NULL); -- goto ON_ERROR;; -+ goto ON_ERROR; - } - -- IpSb->DefaultInterface = IpIf; -+ IpSb->DefaultInterface = IpIf; - InsertHeadList (&IpSb->Interfaces, &IpIf->Link); - IpSb->DefaultRouteTable = RouteTable; - Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb); - - IpSb->State = IP4_SERVICE_UNSTARTED; -- - } else if (IsListEmpty (&IpSb->Children)) { -- State = IpSb->State; -+ State = IpSb->State; - // - // OK, clean other resources then uninstall the service binding protocol. - // -@@ -809,6 +807,7 @@ Ip4DriverBindingStop ( - FreeUnicodeStringTable (gIp4ControllerNameTable); - gIp4ControllerNameTable = NULL; - } -+ - FreePool (IpSb); - } - -@@ -816,7 +815,6 @@ ON_ERROR: - return Status; - } - -- - /** - Creates a child handle and installs a protocol. - -@@ -843,11 +841,11 @@ Ip4ServiceBindingCreateChild ( - IN OUT EFI_HANDLE *ChildHandle - ) - { -- IP4_SERVICE *IpSb; -- IP4_PROTOCOL *IpInstance; -- EFI_TPL OldTpl; -- EFI_STATUS Status; -- VOID *Mnp; -+ IP4_SERVICE *IpSb; -+ IP4_PROTOCOL *IpInstance; -+ EFI_TPL OldTpl; -+ EFI_STATUS Status; -+ VOID *Mnp; - - if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -884,7 +882,7 @@ Ip4ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - IpSb->MnpChildHandle, - &gEfiManagedNetworkProtocolGuid, -- (VOID **) &Mnp, -+ (VOID **)&Mnp, - gIp4DriverBinding.DriverBindingHandle, - IpInstance->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -913,7 +911,6 @@ Ip4ServiceBindingCreateChild ( - ON_ERROR: - - if (EFI_ERROR (Status)) { -- - Ip4CleanProtocol (IpInstance); - - FreePool (IpInstance); -@@ -922,7 +919,6 @@ ON_ERROR: - return Status; - } - -- - /** - Destroys a child handle with a protocol installed on it. - -@@ -948,11 +944,11 @@ Ip4ServiceBindingDestroyChild ( - IN EFI_HANDLE ChildHandle - ) - { -- EFI_STATUS Status; -- IP4_SERVICE *IpSb; -- IP4_PROTOCOL *IpInstance; -- EFI_IP4_PROTOCOL *Ip4; -- EFI_TPL OldTpl; -+ EFI_STATUS Status; -+ IP4_SERVICE *IpSb; -+ IP4_PROTOCOL *IpInstance; -+ EFI_IP4_PROTOCOL *Ip4; -+ EFI_TPL OldTpl; - - if ((This == NULL) || (ChildHandle == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -961,12 +957,12 @@ Ip4ServiceBindingDestroyChild ( - // - // Retrieve the private context data structures - // -- IpSb = IP4_SERVICE_FROM_PROTOCOL (This); -+ IpSb = IP4_SERVICE_FROM_PROTOCOL (This); - - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiIp4ProtocolGuid, -- (VOID **) &Ip4, -+ (VOID **)&Ip4, - gIp4DriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1007,7 +1003,7 @@ Ip4ServiceBindingDestroyChild ( - ChildHandle - ); - -- if (IpInstance->Interface != NULL && IpInstance->Interface->Arp != NULL) { -+ if ((IpInstance->Interface != NULL) && (IpInstance->Interface->Arp != NULL)) { - gBS->CloseProtocol ( - IpInstance->Interface->ArpHandle, - &gEfiArpProtocolGuid, -diff --git a/NetworkPkg/Ip6Dxe/Ip6If.c b/NetworkPkg/Ip6Dxe/Ip6If.c -index 5b46971057..4629c05f25 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6If.c -+++ b/NetworkPkg/Ip6Dxe/Ip6If.c -@@ -19,8 +19,8 @@ - VOID - EFIAPI - Ip6OnFrameSent ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ); - - /** -@@ -37,11 +37,11 @@ Ip6OnFrameSent ( - **/ - BOOLEAN - Ip6CancelInstanceFrame ( -- IN IP6_LINK_TX_TOKEN *Frame, -- IN VOID *Context -+ IN IP6_LINK_TX_TOKEN *Frame, -+ IN VOID *Context - ) - { -- if (Frame->IpInstance == (IP6_PROTOCOL *) Context) { -+ if (Frame->IpInstance == (IP6_PROTOCOL *)Context) { - return TRUE; - } - -@@ -73,14 +73,14 @@ Ip6CancelInstanceFrame ( - **/ - EFI_STATUS - Ip6SetAddress ( -- IN IP6_INTERFACE *Interface, -- IN EFI_IPv6_ADDRESS *Ip6Addr, -- IN BOOLEAN IsAnycast, -- IN UINT8 PrefixLength, -- IN UINT32 ValidLifetime, -- IN UINT32 PreferredLifetime, -- IN IP6_DAD_CALLBACK DadCallback OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_INTERFACE *Interface, -+ IN EFI_IPv6_ADDRESS *Ip6Addr, -+ IN BOOLEAN IsAnycast, -+ IN UINT8 PrefixLength, -+ IN UINT32 ValidLifetime, -+ IN UINT32 PreferredLifetime, -+ IN IP6_DAD_CALLBACK DadCallback OPTIONAL, -+ IN VOID *Context OPTIONAL - ) - { - IP6_SERVICE *IpSb; -@@ -109,12 +109,12 @@ Ip6SetAddress ( - return EFI_SUCCESS; - } - -- AddressInfo = (IP6_ADDRESS_INFO *) AllocatePool (sizeof (IP6_ADDRESS_INFO)); -+ AddressInfo = (IP6_ADDRESS_INFO *)AllocatePool (sizeof (IP6_ADDRESS_INFO)); - if (AddressInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE; -+ AddressInfo->Signature = IP6_ADDR_INFO_SIGNATURE; - IP6_COPY_ADDRESS (&AddressInfo->Address, Ip6Addr); - AddressInfo->IsAnycast = IsAnycast; - AddressInfo->PrefixLength = PrefixLength; -@@ -158,24 +158,23 @@ Ip6SetAddress ( - AddressInfo->PrefixLength = IP6_LINK_LOCAL_PREFIX_LENGTH; - } - -- - // - // Node should delay joining the solicited-node multicast address by a random delay - // between 0 and MAX_RTR_SOLICITATION_DELAY (1 second). - // Thus queue the address to be processed in Duplicate Address Detection module - // after the delay time (in milliseconds). - // -- Delay = (UINT64) NET_RANDOM (NetRandomInitSeed ()); -+ Delay = (UINT64)NET_RANDOM (NetRandomInitSeed ()); - Delay = MultU64x32 (Delay, IP6_ONE_SECOND_IN_MS); - Delay = RShiftU64 (Delay, 32); - -- DelayNode = (IP6_DELAY_JOIN_LIST *) AllocatePool (sizeof (IP6_DELAY_JOIN_LIST)); -+ DelayNode = (IP6_DELAY_JOIN_LIST *)AllocatePool (sizeof (IP6_DELAY_JOIN_LIST)); - if (DelayNode == NULL) { - FreePool (AddressInfo); - return EFI_OUT_OF_RESOURCES; - } - -- DelayNode->DelayTime = (UINT32) (DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS)); -+ DelayNode->DelayTime = (UINT32)(DivU64x32 (Delay, IP6_TIMER_INTERVAL_IN_MS)); - DelayNode->Interface = Interface; - DelayNode->AddressInfo = AddressInfo; - DelayNode->DadCallback = DadCallback; -@@ -197,13 +196,13 @@ Ip6SetAddress ( - **/ - IP6_INTERFACE * - Ip6CreateInterface ( -- IN IP6_SERVICE *IpSb, -- IN BOOLEAN LinkLocal -+ IN IP6_SERVICE *IpSb, -+ IN BOOLEAN LinkLocal - ) - { -- EFI_STATUS Status; -- IP6_INTERFACE *Interface; -- EFI_IPv6_ADDRESS *Ip6Addr; -+ EFI_STATUS Status; -+ IP6_INTERFACE *Interface; -+ EFI_IPv6_ADDRESS *Ip6Addr; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - -@@ -212,27 +211,27 @@ Ip6CreateInterface ( - return NULL; - } - -- Interface->Signature = IP6_INTERFACE_SIGNATURE; -- Interface->RefCnt = 1; -+ Interface->Signature = IP6_INTERFACE_SIGNATURE; -+ Interface->RefCnt = 1; - - InitializeListHead (&Interface->AddressList); -- Interface->AddressCount = 0; -- Interface->Configured = FALSE; -+ Interface->AddressCount = 0; -+ Interface->Configured = FALSE; - -- Interface->Service = IpSb; -- Interface->Controller = IpSb->Controller; -- Interface->Image = IpSb->Image; -+ Interface->Service = IpSb; -+ Interface->Controller = IpSb->Controller; -+ Interface->Image = IpSb->Image; - - InitializeListHead (&Interface->ArpQues); - InitializeListHead (&Interface->SentFrames); - -- Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits; -+ Interface->DupAddrDetect = IpSb->Ip6ConfigInstance.DadXmits.DupAddrDetectTransmits; - InitializeListHead (&Interface->DupAddrDetectList); - - InitializeListHead (&Interface->DelayJoinList); - - InitializeListHead (&Interface->IpInstances); -- Interface->PromiscRecv = FALSE; -+ Interface->PromiscRecv = FALSE; - - if (!LinkLocal) { - return Interface; -@@ -254,8 +253,8 @@ Ip6CreateInterface ( - Ip6Addr, - FALSE, - IP6_LINK_LOCAL_PREFIX_LENGTH, -- (UINT32) IP6_INFINIT_LIFETIME, -- (UINT32) IP6_INFINIT_LIFETIME, -+ (UINT32)IP6_INFINIT_LIFETIME, -+ (UINT32)IP6_INFINIT_LIFETIME, - NULL, - NULL - ); -@@ -288,12 +287,12 @@ ON_ERROR: - **/ - VOID - Ip6CleanInterface ( -- IN IP6_INTERFACE *Interface, -- IN IP6_PROTOCOL *IpInstance OPTIONAL -+ IN IP6_INTERFACE *Interface, -+ IN IP6_PROTOCOL *IpInstance OPTIONAL - ) - { -- IP6_DAD_ENTRY *Duplicate; -- IP6_DELAY_JOIN_LIST *Delay; -+ IP6_DAD_ENTRY *Duplicate; -+ IP6_DELAY_JOIN_LIST *Delay; - - NET_CHECK_SIGNATURE (Interface, IP6_INTERFACE_SIGNATURE); - ASSERT (Interface->RefCnt > 0); -@@ -352,11 +351,11 @@ Ip6CleanInterface ( - **/ - IP6_LINK_TX_TOKEN * - Ip6CreateLinkTxToken ( -- IN IP6_INTERFACE *Interface, -- IN IP6_PROTOCOL *IpInstance OPTIONAL, -- IN NET_BUF *Packet, -- IN IP6_FRAME_CALLBACK CallBack, -- IN VOID *Context -+ IN IP6_INTERFACE *Interface, -+ IN IP6_PROTOCOL *IpInstance OPTIONAL, -+ IN NET_BUF *Packet, -+ IN IP6_FRAME_CALLBACK CallBack, -+ IN VOID *Context - ) - { - EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken; -@@ -381,8 +380,8 @@ Ip6CreateLinkTxToken ( - ZeroMem (&Token->DstMac, sizeof (EFI_MAC_ADDRESS)); - IP6_COPY_LINK_ADDRESS (&Token->SrcMac, &Interface->Service->SnpMode.CurrentAddress); - -- MnpToken = &(Token->MnpToken); -- MnpToken->Status = EFI_NOT_READY; -+ MnpToken = &(Token->MnpToken); -+ MnpToken->Status = EFI_NOT_READY; - - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, -@@ -397,8 +396,8 @@ Ip6CreateLinkTxToken ( - return NULL; - } - -- MnpTxData = &Token->MnpTxData; -- MnpToken->Packet.TxData = MnpTxData; -+ MnpTxData = &Token->MnpTxData; -+ MnpToken->Packet.TxData = MnpTxData; - - MnpTxData->DestinationAddress = &Token->DstMac; - MnpTxData->SourceAddress = &Token->SrcMac; -@@ -406,10 +405,10 @@ Ip6CreateLinkTxToken ( - MnpTxData->DataLength = Packet->TotalSize; - MnpTxData->HeaderLength = 0; - -- Count = Packet->BlockOpNum; -+ Count = Packet->BlockOpNum; - -- NetbufBuildExt (Packet, (NET_FRAGMENT *) MnpTxData->FragmentTable, &Count); -- MnpTxData->FragmentCount = (UINT16)Count; -+ NetbufBuildExt (Packet, (NET_FRAGMENT *)MnpTxData->FragmentTable, &Count); -+ MnpTxData->FragmentCount = (UINT16)Count; - - return Token; - } -@@ -423,7 +422,7 @@ Ip6CreateLinkTxToken ( - **/ - VOID - Ip6FreeLinkTxToken ( -- IN IP6_LINK_TX_TOKEN *Token -+ IN IP6_LINK_TX_TOKEN *Token - ) - { - NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE); -@@ -442,12 +441,12 @@ Ip6FreeLinkTxToken ( - VOID - EFIAPI - Ip6RecycleFrame ( -- IN VOID *Context -+ IN VOID *Context - ) - { - EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData; - -- RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *) Context; -+ RxData = (EFI_MANAGED_NETWORK_RECEIVE_DATA *)Context; - - gBS->SignalEvent (RxData->RecycleEvent); - } -@@ -466,7 +465,7 @@ Ip6RecycleFrame ( - VOID - EFIAPI - Ip6OnFrameReceivedDpc ( -- IN VOID *Context -+ IN VOID *Context - ) - { - EFI_MANAGED_NETWORK_COMPLETION_TOKEN *MnpToken; -@@ -477,23 +476,22 @@ Ip6OnFrameReceivedDpc ( - UINT32 Flag; - IP6_SERVICE *IpSb; - -- Token = (IP6_LINK_RX_TOKEN *) Context; -+ Token = (IP6_LINK_RX_TOKEN *)Context; - NET_CHECK_SIGNATURE (Token, IP6_LINK_RX_SIGNATURE); - - // - // First clear the interface's receive request in case the - // caller wants to call Ip6ReceiveFrame in the callback. - // -- IpSb = (IP6_SERVICE *) Token->Context; -+ IpSb = (IP6_SERVICE *)Token->Context; - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - -- - MnpToken = &Token->MnpToken; - MnpRxData = MnpToken->Packet.RxData; - - if (EFI_ERROR (MnpToken->Status) || (MnpRxData == NULL)) { - Token->CallBack (NULL, MnpToken->Status, 0, Token->Context); -- return ; -+ return; - } - - // -@@ -510,7 +508,7 @@ Ip6OnFrameReceivedDpc ( - - Token->CallBack (NULL, EFI_OUT_OF_RESOURCES, 0, Token->Context); - -- return ; -+ return; - } - - Flag = (MnpRxData->BroadcastFlag ? IP6_LINK_BROADCAST : 0); -@@ -530,8 +528,8 @@ Ip6OnFrameReceivedDpc ( - VOID - EFIAPI - Ip6OnFrameReceived ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { - // -@@ -553,18 +551,18 @@ Ip6OnFrameReceived ( - **/ - EFI_STATUS - Ip6ReceiveFrame ( -- IN IP6_FRAME_CALLBACK CallBack, -- IN IP6_SERVICE *IpSb -+ IN IP6_FRAME_CALLBACK CallBack, -+ IN IP6_SERVICE *IpSb - ) - { -- EFI_STATUS Status; -- IP6_LINK_RX_TOKEN *Token; -+ EFI_STATUS Status; -+ IP6_LINK_RX_TOKEN *Token; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - - Token = &IpSb->RecvRequest; - Token->CallBack = CallBack; -- Token->Context = (VOID *) IpSb; -+ Token->Context = (VOID *)IpSb; - - Status = IpSb->Mnp->Receive (IpSb->Mnp, &Token->MnpToken); - if (EFI_ERROR (Status)) { -@@ -584,22 +582,22 @@ Ip6ReceiveFrame ( - VOID - EFIAPI - Ip6OnFrameSentDpc ( -- IN VOID *Context -+ IN VOID *Context - ) - { -- IP6_LINK_TX_TOKEN *Token; -+ IP6_LINK_TX_TOKEN *Token; - -- Token = (IP6_LINK_TX_TOKEN *) Context; -+ Token = (IP6_LINK_TX_TOKEN *)Context; - NET_CHECK_SIGNATURE (Token, IP6_LINK_TX_SIGNATURE); - - RemoveEntryList (&Token->Link); - - Token->CallBack ( -- Token->Packet, -- Token->MnpToken.Status, -- 0, -- Token->Context -- ); -+ Token->Packet, -+ Token->MnpToken.Status, -+ 0, -+ Token->Context -+ ); - - Ip6FreeLinkTxToken (Token); - } -@@ -614,8 +612,8 @@ Ip6OnFrameSentDpc ( - VOID - EFIAPI - Ip6OnFrameSent ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { - // -@@ -646,20 +644,20 @@ Ip6OnFrameSent ( - **/ - EFI_STATUS - Ip6SendFrame ( -- IN IP6_INTERFACE *Interface, -- IN IP6_PROTOCOL *IpInstance OPTIONAL, -- IN NET_BUF *Packet, -- IN EFI_IPv6_ADDRESS *NextHop, -- IN IP6_FRAME_CALLBACK CallBack, -- IN VOID *Context -+ IN IP6_INTERFACE *Interface, -+ IN IP6_PROTOCOL *IpInstance OPTIONAL, -+ IN NET_BUF *Packet, -+ IN EFI_IPv6_ADDRESS *NextHop, -+ IN IP6_FRAME_CALLBACK CallBack, -+ IN VOID *Context - ) - { -- IP6_SERVICE *IpSb; -- IP6_LINK_TX_TOKEN *Token; -- EFI_STATUS Status; -- IP6_NEIGHBOR_ENTRY *NeighborCache; -- LIST_ENTRY *Entry; -- IP6_NEIGHBOR_ENTRY *ArpQue; -+ IP6_SERVICE *IpSb; -+ IP6_LINK_TX_TOKEN *Token; -+ EFI_STATUS Status; -+ IP6_NEIGHBOR_ENTRY *NeighborCache; -+ LIST_ENTRY *Entry; -+ IP6_NEIGHBOR_ENTRY *ArpQue; - - IpSb = Interface->Service; - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); -@@ -706,21 +704,21 @@ Ip6SendFrame ( - } - - switch (NeighborCache->State) { -- case EfiNeighborStale: -- NeighborCache->State = EfiNeighborDelay; -- NeighborCache->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME); -+ case EfiNeighborStale: -+ NeighborCache->State = EfiNeighborDelay; -+ NeighborCache->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME); - // - // Fall through - // -- case EfiNeighborReachable: -- case EfiNeighborDelay: -- case EfiNeighborProbe: -- IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress); -- goto SendNow; -- break; -- -- default: -- break; -+ case EfiNeighborReachable: -+ case EfiNeighborDelay: -+ case EfiNeighborProbe: -+ IP6_COPY_LINK_ADDRESS (&Token->DstMac, &NeighborCache->LinkAddress); -+ goto SendNow; -+ break; -+ -+ default: -+ break; - } - - // -@@ -747,7 +745,7 @@ Ip6SendFrame ( - return EFI_SUCCESS; - - SendNow: -- // -+ // - // Insert the tx token into the SentFrames list before calling Mnp->Transmit. - // Remove it if the returned status is not EFI_SUCCESS. - // -@@ -777,13 +775,13 @@ Error: - VOID - EFIAPI - Ip6TimerTicking ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { -- IP6_SERVICE *IpSb; -+ IP6_SERVICE *IpSb; - -- IpSb = (IP6_SERVICE *) Context; -+ IpSb = (IP6_SERVICE *)Context; - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - - Ip6PacketTimerTicking (IpSb); -diff --git a/NetworkPkg/Ip6Dxe/Ip6Mld.c b/NetworkPkg/Ip6Dxe/Ip6Mld.c -index ba12089dee..e6b2b653e2 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Mld.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Mld.c -@@ -21,12 +21,12 @@ - **/ - IP6_MLD_GROUP * - Ip6CreateMldEntry ( -- IN OUT IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *MulticastAddr, -- IN UINT32 DelayTimer -+ IN OUT IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *MulticastAddr, -+ IN UINT32 DelayTimer - ) - { -- IP6_MLD_GROUP *Entry; -+ IP6_MLD_GROUP *Entry; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr)); -@@ -54,12 +54,12 @@ Ip6CreateMldEntry ( - **/ - IP6_MLD_GROUP * - Ip6FindMldEntry ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *MulticastAddr -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *MulticastAddr - ) - { -- LIST_ENTRY *Entry; -- IP6_MLD_GROUP *Group; -+ LIST_ENTRY *Entry; -+ IP6_MLD_GROUP *Group; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr)); -@@ -88,13 +88,13 @@ Ip6FindMldEntry ( - **/ - INTN - Ip6FindMac ( -- IN IP6_MLD_SERVICE_DATA *MldCtrl, -- IN EFI_MAC_ADDRESS *Mac -+ IN IP6_MLD_SERVICE_DATA *MldCtrl, -+ IN EFI_MAC_ADDRESS *Mac - ) - { -- LIST_ENTRY *Entry; -- IP6_MLD_GROUP *Group; -- INTN Count; -+ LIST_ENTRY *Entry; -+ IP6_MLD_GROUP *Group; -+ INTN Count; - - Count = 0; - -@@ -125,20 +125,20 @@ Ip6FindMac ( - **/ - EFI_STATUS - Ip6SendMldReport ( -- IN IP6_SERVICE *IpSb, -- IN IP6_INTERFACE *Interface OPTIONAL, -- IN EFI_IPv6_ADDRESS *MulticastAddr -+ IN IP6_SERVICE *IpSb, -+ IN IP6_INTERFACE *Interface OPTIONAL, -+ IN EFI_IPv6_ADDRESS *MulticastAddr - ) - { -- IP6_MLD_HEAD *MldHead; -- NET_BUF *Packet; -- EFI_IP6_HEADER Head; -- UINT16 PayloadLen; -- UINTN OptionLen; -- UINT8 *Options; -- EFI_STATUS Status; -- UINT16 HeadChecksum; -- UINT16 PseudoChecksum; -+ IP6_MLD_HEAD *MldHead; -+ NET_BUF *Packet; -+ EFI_IP6_HEADER Head; -+ UINT16 PayloadLen; -+ UINTN OptionLen; -+ UINT8 *Options; -+ EFI_STATUS Status; -+ UINT16 HeadChecksum; -+ UINT16 PseudoChecksum; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr)); -@@ -149,11 +149,11 @@ Ip6SendMldReport ( - // - - OptionLen = 0; -- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP); -+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - -- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD)); -- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen); -+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD)); -+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen); - if (Packet == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -163,11 +163,11 @@ Ip6SendMldReport ( - // RFC3590: Use link-local address as source address if it is available, - // otherwise use the unspecified address. - // -- Head.FlowLabelL = 0; -- Head.FlowLabelH = 0; -- Head.PayloadLength = HTONS (PayloadLen); -- Head.NextHeader = IP6_HOP_BY_HOP; -- Head.HopLimit = 1; -+ Head.FlowLabelL = 0; -+ Head.FlowLabelH = 0; -+ Head.PayloadLength = HTONS (PayloadLen); -+ Head.NextHeader = IP6_HOP_BY_HOP; -+ Head.HopLimit = 1; - IP6_COPY_ADDRESS (&Head.DestinationAddress, MulticastAddr); - - // -@@ -180,7 +180,7 @@ Ip6SendMldReport ( - // - // Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header - // -- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE); -+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE); - ASSERT (Options != NULL); - Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP); - if (EFI_ERROR (Status)) { -@@ -192,14 +192,14 @@ Ip6SendMldReport ( - // - // Fill in MLD message - Report - // -- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE); -+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE); - ASSERT (MldHead != NULL); - ZeroMem (MldHead, sizeof (IP6_MLD_HEAD)); - MldHead->Head.Type = ICMP_V6_LISTENER_REPORT; - MldHead->Head.Code = 0; - IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr); - -- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD)); -+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD)); - PseudoChecksum = NetIp6PseudoHeadChecksum ( - &Head.SourceAddress, - &Head.DestinationAddress, -@@ -229,20 +229,20 @@ Ip6SendMldReport ( - **/ - EFI_STATUS - Ip6SendMldDone ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *MulticastAddr -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *MulticastAddr - ) - { -- IP6_MLD_HEAD *MldHead; -- NET_BUF *Packet; -- EFI_IP6_HEADER Head; -- UINT16 PayloadLen; -- UINTN OptionLen; -- UINT8 *Options; -- EFI_STATUS Status; -- EFI_IPv6_ADDRESS Destination; -- UINT16 HeadChecksum; -- UINT16 PseudoChecksum; -+ IP6_MLD_HEAD *MldHead; -+ NET_BUF *Packet; -+ EFI_IP6_HEADER Head; -+ UINT16 PayloadLen; -+ UINTN OptionLen; -+ UINT8 *Options; -+ EFI_STATUS Status; -+ EFI_IPv6_ADDRESS Destination; -+ UINT16 HeadChecksum; -+ UINT16 PseudoChecksum; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (MulticastAddr != NULL && IP6_IS_MULTICAST (MulticastAddr)); -@@ -253,11 +253,11 @@ Ip6SendMldDone ( - // - - OptionLen = 0; -- Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP); -+ Status = Ip6FillHopByHop (NULL, &OptionLen, IP6_ICMP); - ASSERT (Status == EFI_BUFFER_TOO_SMALL); - -- PayloadLen = (UINT16) (OptionLen + sizeof (IP6_MLD_HEAD)); -- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen); -+ PayloadLen = (UINT16)(OptionLen + sizeof (IP6_MLD_HEAD)); -+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen); - if (Packet == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -265,11 +265,11 @@ Ip6SendMldDone ( - // - // Create the basic IPv6 header. - // -- Head.FlowLabelL = 0; -- Head.FlowLabelH = 0; -- Head.PayloadLength = HTONS (PayloadLen); -- Head.NextHeader = IP6_HOP_BY_HOP; -- Head.HopLimit = 1; -+ Head.FlowLabelL = 0; -+ Head.FlowLabelH = 0; -+ Head.PayloadLength = HTONS (PayloadLen); -+ Head.NextHeader = IP6_HOP_BY_HOP; -+ Head.HopLimit = 1; - - // - // If Link-Local address is not ready, we use unspecified address. -@@ -284,7 +284,7 @@ Ip6SendMldDone ( - // - // Fill a IPv6 Router Alert option in a Hop-by-Hop Options Header - // -- Options = NetbufAllocSpace (Packet, (UINT32) OptionLen, FALSE); -+ Options = NetbufAllocSpace (Packet, (UINT32)OptionLen, FALSE); - ASSERT (Options != NULL); - Status = Ip6FillHopByHop (Options, &OptionLen, IP6_ICMP); - if (EFI_ERROR (Status)) { -@@ -296,14 +296,14 @@ Ip6SendMldDone ( - // - // Fill in MLD message - Done - // -- MldHead = (IP6_MLD_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE); -+ MldHead = (IP6_MLD_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_MLD_HEAD), FALSE); - ASSERT (MldHead != NULL); - ZeroMem (MldHead, sizeof (IP6_MLD_HEAD)); - MldHead->Head.Type = ICMP_V6_LISTENER_DONE; - MldHead->Head.Code = 0; - IP6_COPY_ADDRESS (&MldHead->Group, MulticastAddr); - -- HeadChecksum = NetblockChecksum ((UINT8 *) MldHead, sizeof (IP6_MLD_HEAD)); -+ HeadChecksum = NetblockChecksum ((UINT8 *)MldHead, sizeof (IP6_MLD_HEAD)); - PseudoChecksum = NetIp6PseudoHeadChecksum ( - &Head.SourceAddress, - &Head.DestinationAddress, -@@ -332,12 +332,12 @@ Ip6SendMldDone ( - **/ - EFI_STATUS - Ip6InitMld ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ) - { -- EFI_IPv6_ADDRESS AllNodes; -- IP6_MLD_GROUP *Group; -- EFI_STATUS Status; -+ EFI_IPv6_ADDRESS AllNodes; -+ IP6_MLD_GROUP *Group; -+ EFI_STATUS Status; - - // - // Join the link-scope all-nodes multicast address (FF02::1). -@@ -347,7 +347,7 @@ Ip6InitMld ( - - Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes); - -- Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32) IP6_INFINIT_LIFETIME); -+ Group = Ip6CreateMldEntry (IpSb, &AllNodes, (UINT32)IP6_INFINIT_LIFETIME); - if (Group == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -388,11 +388,11 @@ ERROR: - **/ - EFI_STATUS - Ip6CombineGroups ( -- IN OUT IP6_PROTOCOL *IpInstance, -- IN EFI_IPv6_ADDRESS *Group -+ IN OUT IP6_PROTOCOL *IpInstance, -+ IN EFI_IPv6_ADDRESS *Group - ) - { -- EFI_IPv6_ADDRESS *GroupList; -+ EFI_IPv6_ADDRESS *GroupList; - - NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE); - ASSERT (Group != NULL && IP6_IS_MULTICAST (Group)); -@@ -437,12 +437,12 @@ Ip6CombineGroups ( - **/ - EFI_STATUS - Ip6RemoveGroup ( -- IN OUT IP6_PROTOCOL *IpInstance, -- IN EFI_IPv6_ADDRESS *Group -+ IN OUT IP6_PROTOCOL *IpInstance, -+ IN EFI_IPv6_ADDRESS *Group - ) - { -- UINT32 Index; -- UINT32 Count; -+ UINT32 Index; -+ UINT32 Count; - - Count = IpInstance->GroupCount; - -@@ -481,13 +481,13 @@ Ip6RemoveGroup ( - **/ - EFI_STATUS - Ip6JoinGroup ( -- IN IP6_SERVICE *IpSb, -- IN IP6_INTERFACE *Interface, -- IN EFI_IPv6_ADDRESS *Address -+ IN IP6_SERVICE *IpSb, -+ IN IP6_INTERFACE *Interface, -+ IN EFI_IPv6_ADDRESS *Address - ) - { -- IP6_MLD_GROUP *Group; -- EFI_STATUS Status; -+ IP6_MLD_GROUP *Group; -+ EFI_STATUS Status; - - Group = Ip6FindMldEntry (IpSb, Address); - if (Group != NULL) { -@@ -545,12 +545,12 @@ ERROR: - **/ - EFI_STATUS - Ip6LeaveGroup ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Address -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Address - ) - { -- IP6_MLD_GROUP *Group; -- EFI_STATUS Status; -+ IP6_MLD_GROUP *Group; -+ EFI_STATUS Status; - - Group = Ip6FindMldEntry (IpSb, Address); - if (Group == NULL) { -@@ -611,15 +611,15 @@ Ip6LeaveGroup ( - **/ - EFI_STATUS - Ip6Groups ( -- IN IP6_PROTOCOL *IpInstance, -- IN BOOLEAN JoinFlag, -- IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL -+ IN IP6_PROTOCOL *IpInstance, -+ IN BOOLEAN JoinFlag, -+ IN EFI_IPv6_ADDRESS *GroupAddress OPTIONAL - ) - { -- EFI_STATUS Status; -- IP6_SERVICE *IpSb; -- UINT32 Index; -- EFI_IPv6_ADDRESS *Group; -+ EFI_STATUS Status; -+ IP6_SERVICE *IpSb; -+ UINT32 Index; -+ EFI_IPv6_ADDRESS *Group; - - IpSb = IpInstance->Service; - -@@ -690,13 +690,13 @@ Ip6Groups ( - **/ - EFI_STATUS - Ip6UpdateDelayTimer ( -- IN IP6_SERVICE *IpSb, -- IN UINT16 MaxRespDelay, -- IN EFI_IPv6_ADDRESS *MulticastAddr, -- IN OUT IP6_MLD_GROUP *Group -+ IN IP6_SERVICE *IpSb, -+ IN UINT16 MaxRespDelay, -+ IN EFI_IPv6_ADDRESS *MulticastAddr, -+ IN OUT IP6_MLD_GROUP *Group - ) - { -- UINT32 Delay; -+ UINT32 Delay; - - // - // If the Query packet specifies a Maximum Response Delay of zero, perform timer -@@ -707,14 +707,14 @@ Ip6UpdateDelayTimer ( - return Ip6SendMldReport (IpSb, NULL, MulticastAddr); - } - -- Delay = (UINT32) (MaxRespDelay / 1000); -+ Delay = (UINT32)(MaxRespDelay / 1000); - - // - // Sets a delay timer to a random value selected from the range [0, Maximum Response Delay] - // If a timer is already running, resets it if the request Maximum Response Delay - // is less than the remaining value of the running timer. - // -- if (Group->DelayTimer == 0 || Delay < Group->DelayTimer) { -+ if ((Group->DelayTimer == 0) || (Delay < Group->DelayTimer)) { - Group->DelayTimer = Delay / 4294967295UL * NET_RANDOM (NetRandomInitSeed ()); - } - -@@ -736,16 +736,16 @@ Ip6UpdateDelayTimer ( - **/ - EFI_STATUS - Ip6ProcessMldQuery ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- EFI_IPv6_ADDRESS AllNodes; -- IP6_MLD_GROUP *Group; -- IP6_MLD_HEAD MldPacket; -- LIST_ENTRY *Entry; -- EFI_STATUS Status; -+ EFI_IPv6_ADDRESS AllNodes; -+ IP6_MLD_GROUP *Group; -+ IP6_MLD_HEAD MldPacket; -+ LIST_ENTRY *Entry; -+ EFI_STATUS Status; - - Status = EFI_INVALID_PARAMETER; - -@@ -756,14 +756,14 @@ Ip6ProcessMldQuery ( - goto Exit; - } - -- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) { -+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) { - goto Exit; - } - - // - // The Packet points to MLD report raw data without Hop-By-Hop option. - // -- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket); -+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket); - MldPacket.MaxRespDelay = NTOHS (MldPacket.MaxRespDelay); - - Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes); -@@ -774,6 +774,7 @@ Ip6ProcessMldQuery ( - if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) { - goto Exit; - } -+ - // - // The node is not listening but it receives the specific query. Just return. - // -@@ -824,14 +825,14 @@ Exit: - **/ - EFI_STATUS - Ip6ProcessMldReport ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- IP6_MLD_HEAD MldPacket; -- IP6_MLD_GROUP *Group; -- EFI_STATUS Status; -+ IP6_MLD_HEAD MldPacket; -+ IP6_MLD_GROUP *Group; -+ EFI_STATUS Status; - - Status = EFI_INVALID_PARAMETER; - -@@ -842,14 +843,14 @@ Ip6ProcessMldReport ( - goto Exit; - } - -- if (Head->HopLimit != 1 || !IP6_IS_MULTICAST (&Head->DestinationAddress)) { -+ if ((Head->HopLimit != 1) || !IP6_IS_MULTICAST (&Head->DestinationAddress)) { - goto Exit; - } - - // - // The Packet points to MLD report raw data without Hop-By-Hop option. - // -- NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *) &MldPacket); -+ NetbufCopy (Packet, 0, sizeof (IP6_MLD_HEAD), (UINT8 *)&MldPacket); - if (!EFI_IP6_EQUAL (&Head->DestinationAddress, &MldPacket.Group)) { - goto Exit; - } -@@ -883,11 +884,11 @@ Exit: - **/ - VOID - Ip6MldTimerTicking ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ) - { -- IP6_MLD_GROUP *Group; -- LIST_ENTRY *Entry; -+ IP6_MLD_GROUP *Group; -+ LIST_ENTRY *Entry; - - // - // Send solicited report when timer expires -@@ -899,4 +900,3 @@ Ip6MldTimerTicking ( - } - } - } -- -diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c -index 0780a98cb3..c10c7017f8 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Nd.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c -@@ -9,7 +9,7 @@ - - #include "Ip6Impl.h" - --EFI_MAC_ADDRESS mZeroMacAddress; -+EFI_MAC_ADDRESS mZeroMacAddress; - - /** - Update the ReachableTime in IP6 service binding instance data, in milliseconds. -@@ -22,10 +22,10 @@ Ip6UpdateReachableTime ( - IN OUT IP6_SERVICE *IpSb - ) - { -- UINT32 Random; -+ UINT32 Random; - -- Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE; -- Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED; -+ Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE; -+ Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED; - IpSb->ReachableTime = (IpSb->BaseReachableTime * Random) / IP6_RANDOM_FACTOR_SCALE; - } - -@@ -43,17 +43,17 @@ Ip6UpdateReachableTime ( - **/ - EFI_STATUS - Ip6BuildEfiNeighborCache ( -- IN IP6_PROTOCOL *IpInstance, -- OUT UINT32 *NeighborCount, -- OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache -+ IN IP6_PROTOCOL *IpInstance, -+ OUT UINT32 *NeighborCount, -+ OUT EFI_IP6_NEIGHBOR_CACHE **NeighborCache - ) - { -- IP6_NEIGHBOR_ENTRY *Neighbor; -- LIST_ENTRY *Entry; -- IP6_SERVICE *IpSb; -- UINT32 Count; -- EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache; -- EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp; -+ IP6_NEIGHBOR_ENTRY *Neighbor; -+ LIST_ENTRY *Entry; -+ IP6_SERVICE *IpSb; -+ UINT32 Count; -+ EFI_IP6_NEIGHBOR_CACHE *EfiNeighborCache; -+ EFI_IP6_NEIGHBOR_CACHE *NeighborCacheTmp; - - NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE); - ASSERT (NeighborCount != NULL && NeighborCache != NULL); -@@ -82,7 +82,7 @@ Ip6BuildEfiNeighborCache ( - - EfiNeighborCache = NeighborCacheTmp + Count; - -- EfiNeighborCache->State = Neighbor->State; -+ EfiNeighborCache->State = Neighbor->State; - IP6_COPY_ADDRESS (&EfiNeighborCache->Neighbor, &Neighbor->Neighbor); - IP6_COPY_LINK_ADDRESS (&EfiNeighborCache->LinkAddress, &Neighbor->LinkAddress); - -@@ -114,12 +114,12 @@ Ip6BuildPrefixTable ( - OUT EFI_IP6_ADDRESS_INFO **PrefixTable - ) - { -- LIST_ENTRY *Entry; -- IP6_SERVICE *IpSb; -- UINT32 Count; -- IP6_PREFIX_LIST_ENTRY *PrefixList; -- EFI_IP6_ADDRESS_INFO *EfiPrefix; -- EFI_IP6_ADDRESS_INFO *PrefixTableTmp; -+ LIST_ENTRY *Entry; -+ IP6_SERVICE *IpSb; -+ UINT32 Count; -+ IP6_PREFIX_LIST_ENTRY *PrefixList; -+ EFI_IP6_ADDRESS_INFO *EfiPrefix; -+ EFI_IP6_ADDRESS_INFO *PrefixTableTmp; - - NET_CHECK_SIGNATURE (IpInstance, IP6_PROTOCOL_SIGNATURE); - ASSERT (PrefixCount != NULL && PrefixTable != NULL); -@@ -178,21 +178,21 @@ Ip6BuildPrefixTable ( - **/ - IP6_PREFIX_LIST_ENTRY * - Ip6CreatePrefixListEntry ( -- IN IP6_SERVICE *IpSb, -- IN BOOLEAN OnLinkOrAuto, -- IN UINT32 ValidLifetime, -- IN UINT32 PreferredLifetime, -- IN UINT8 PrefixLength, -- IN EFI_IPv6_ADDRESS *Prefix -+ IN IP6_SERVICE *IpSb, -+ IN BOOLEAN OnLinkOrAuto, -+ IN UINT32 ValidLifetime, -+ IN UINT32 PreferredLifetime, -+ IN UINT8 PrefixLength, -+ IN EFI_IPv6_ADDRESS *Prefix - ) - { -- IP6_PREFIX_LIST_ENTRY *PrefixEntry; -- IP6_ROUTE_ENTRY *RtEntry; -- LIST_ENTRY *ListHead; -- LIST_ENTRY *Entry; -- IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry; -+ IP6_PREFIX_LIST_ENTRY *PrefixEntry; -+ IP6_ROUTE_ENTRY *RtEntry; -+ LIST_ENTRY *ListHead; -+ LIST_ENTRY *Entry; -+ IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry; - -- if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > IP6_PREFIX_MAX) { -+ if ((Prefix == NULL) || (PreferredLifetime > ValidLifetime) || (PrefixLength > IP6_PREFIX_MAX)) { - return NULL; - } - -@@ -205,7 +205,7 @@ Ip6CreatePrefixListEntry ( - Prefix - ); - if (PrefixEntry != NULL) { -- PrefixEntry->RefCnt ++; -+ PrefixEntry->RefCnt++; - return PrefixEntry; - } - -@@ -242,7 +242,7 @@ Ip6CreatePrefixListEntry ( - // is put ahead in the list. - // - NET_LIST_FOR_EACH (Entry, ListHead) { -- TmpPrefixEntry = NET_LIST_USER_STRUCT(Entry, IP6_PREFIX_LIST_ENTRY, Link); -+ TmpPrefixEntry = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link); - - if (TmpPrefixEntry->PrefixLength < PrefixEntry->PrefixLength) { - break; -@@ -274,26 +274,26 @@ Ip6DestroyPrefixListEntry ( - IN BOOLEAN ImmediateDelete - ) - { -- LIST_ENTRY *Entry; -- IP6_INTERFACE *IpIf; -- EFI_STATUS Status; -+ LIST_ENTRY *Entry; -+ IP6_INTERFACE *IpIf; -+ EFI_STATUS Status; - - if ((!ImmediateDelete) && (PrefixEntry->RefCnt > 0) && ((--PrefixEntry->RefCnt) > 0)) { -- return ; -+ return; - } - - if (OnLinkOrAuto) { -- // -- // Remove the direct route for onlink prefix from route table. -- // -- do { -- Status = Ip6DelRoute ( -- IpSb->RouteTable, -- &PrefixEntry->Prefix, -- PrefixEntry->PrefixLength, -- NULL -- ); -- } while (Status != EFI_NOT_FOUND); -+ // -+ // Remove the direct route for onlink prefix from route table. -+ // -+ do { -+ Status = Ip6DelRoute ( -+ IpSb->RouteTable, -+ &PrefixEntry->Prefix, -+ PrefixEntry->PrefixLength, -+ NULL -+ ); -+ } while (Status != EFI_NOT_FOUND); - } else { - // - // Remove the corresponding addresses generated from this autonomous prefix. -@@ -324,15 +324,15 @@ Ip6DestroyPrefixListEntry ( - **/ - IP6_PREFIX_LIST_ENTRY * - Ip6FindPrefixListEntry ( -- IN IP6_SERVICE *IpSb, -- IN BOOLEAN OnLinkOrAuto, -- IN UINT8 PrefixLength, -- IN EFI_IPv6_ADDRESS *Prefix -+ IN IP6_SERVICE *IpSb, -+ IN BOOLEAN OnLinkOrAuto, -+ IN UINT8 PrefixLength, -+ IN EFI_IPv6_ADDRESS *Prefix - ) - { -- IP6_PREFIX_LIST_ENTRY *PrefixList; -- LIST_ENTRY *Entry; -- LIST_ENTRY *ListHead; -+ IP6_PREFIX_LIST_ENTRY *PrefixList; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *ListHead; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (Prefix != NULL); -@@ -349,8 +349,9 @@ Ip6FindPrefixListEntry ( - // - // Perform exactly prefix match. - // -- if (PrefixList->PrefixLength == PrefixLength && -- NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength)) { -+ if ((PrefixList->PrefixLength == PrefixLength) && -+ NetIp6IsNetEqual (&PrefixList->Prefix, Prefix, PrefixLength)) -+ { - return PrefixList; - } - } else { -@@ -377,14 +378,14 @@ Ip6FindPrefixListEntry ( - **/ - VOID - Ip6CleanPrefixListTable ( -- IN IP6_SERVICE *IpSb, -- IN LIST_ENTRY *ListHead -+ IN IP6_SERVICE *IpSb, -+ IN LIST_ENTRY *ListHead - ) - { -- IP6_PREFIX_LIST_ENTRY *PrefixList; -- BOOLEAN OnLink; -+ IP6_PREFIX_LIST_ENTRY *PrefixList; -+ BOOLEAN OnLink; - -- OnLink = (BOOLEAN) (ListHead == &IpSb->OnlinkPrefix); -+ OnLink = (BOOLEAN)(ListHead == &IpSb->OnlinkPrefix); - - while (!IsListEmpty (ListHead)) { - PrefixList = NET_LIST_HEAD (ListHead, IP6_PREFIX_LIST_ENTRY, Link); -@@ -402,25 +403,25 @@ Ip6CleanPrefixListTable ( - **/ - VOID - Ip6OnArpResolved ( -- IN VOID *Context -+ IN VOID *Context - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- IP6_NEIGHBOR_ENTRY *ArpQue; -- IP6_SERVICE *IpSb; -- IP6_LINK_TX_TOKEN *Token; -- EFI_STATUS Status; -- BOOLEAN Sent; -- -- ArpQue = (IP6_NEIGHBOR_ENTRY *) Context; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ IP6_NEIGHBOR_ENTRY *ArpQue; -+ IP6_SERVICE *IpSb; -+ IP6_LINK_TX_TOKEN *Token; -+ EFI_STATUS Status; -+ BOOLEAN Sent; -+ -+ ArpQue = (IP6_NEIGHBOR_ENTRY *)Context; - if ((ArpQue == NULL) || (ArpQue->Interface == NULL)) { -- return ; -+ return; - } - -- IpSb = ArpQue->Interface->Service; -+ IpSb = ArpQue->Interface->Service; - if ((IpSb == NULL) || (IpSb->Signature != IP6_SERVICE_SIGNATURE)) { -- return ; -+ return; - } - - // -@@ -430,7 +431,7 @@ Ip6OnArpResolved ( - // - if (NET_MAC_EQUAL (&ArpQue->LinkAddress, &mZeroMacAddress, IpSb->SnpMode.HwAddressSize)) { - Ip6FreeNeighborEntry (IpSb, ArpQue, FALSE, TRUE, EFI_NO_MAPPING, NULL, NULL); -- return ; -+ return; - } - - // -@@ -471,7 +472,7 @@ Ip6OnArpResolved ( - - if (Sent && (ArpQue->State == EfiNeighborStale)) { - ArpQue->State = EfiNeighborDelay; -- ArpQue->Ticks = (UINT32) IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME); -+ ArpQue->Ticks = (UINT32)IP6_GET_TICKS (IP6_DELAY_FIRST_PROBE_TIME); - } - } - -@@ -491,17 +492,17 @@ Ip6OnArpResolved ( - **/ - IP6_NEIGHBOR_ENTRY * - Ip6CreateNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN IP6_ARP_CALLBACK CallBack, -- IN EFI_IPv6_ADDRESS *Ip6Address, -- IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_ARP_CALLBACK CallBack, -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ IN EFI_MAC_ADDRESS *LinkAddress OPTIONAL - ) - { -- IP6_NEIGHBOR_ENTRY *Entry; -- IP6_DEFAULT_ROUTER *DefaultRouter; -+ IP6_NEIGHBOR_ENTRY *Entry; -+ IP6_DEFAULT_ROUTER *DefaultRouter; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); -- ASSERT (Ip6Address!= NULL); -+ ASSERT (Ip6Address != NULL); - - Entry = AllocateZeroPool (sizeof (IP6_NEIGHBOR_ENTRY)); - if (Entry == NULL) { -@@ -552,13 +553,13 @@ Ip6CreateNeighborEntry ( - **/ - IP6_NEIGHBOR_ENTRY * - Ip6FindNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- IP6_NEIGHBOR_ENTRY *Neighbor; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ IP6_NEIGHBOR_ENTRY *Neighbor; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (Ip6Address != NULL); -@@ -599,25 +600,25 @@ Ip6FindNeighborEntry ( - **/ - EFI_STATUS - Ip6FreeNeighborEntry ( -- IN IP6_SERVICE *IpSb, -- IN IP6_NEIGHBOR_ENTRY *NeighborCache, -- IN BOOLEAN SendIcmpError, -- IN BOOLEAN FullFree, -- IN EFI_STATUS IoStatus, -- IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_NEIGHBOR_ENTRY *NeighborCache, -+ IN BOOLEAN SendIcmpError, -+ IN BOOLEAN FullFree, -+ IN EFI_STATUS IoStatus, -+ IN IP6_FRAME_TO_CANCEL FrameToCancel OPTIONAL, -+ IN VOID *Context OPTIONAL - ) - { -- IP6_LINK_TX_TOKEN *TxToken; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- IP6_DEFAULT_ROUTER *DefaultRouter; -+ IP6_LINK_TX_TOKEN *TxToken; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ IP6_DEFAULT_ROUTER *DefaultRouter; - - // - // If FrameToCancel fails, the token will not be released. - // To avoid the memory leak, stop this usage model. - // -- if (FullFree && FrameToCancel != NULL) { -+ if (FullFree && (FrameToCancel != NULL)) { - return EFI_INVALID_PARAMETER; - } - -@@ -677,13 +678,13 @@ Ip6FreeNeighborEntry ( - **/ - IP6_DEFAULT_ROUTER * - Ip6CreateDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address, -- IN UINT16 RouterLifetime -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ IN UINT16 RouterLifetime - ) - { -- IP6_DEFAULT_ROUTER *Entry; -- IP6_ROUTE_ENTRY *RtEntry; -+ IP6_DEFAULT_ROUTER *Entry; -+ IP6_ROUTE_ENTRY *RtEntry; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (Ip6Address != NULL); -@@ -724,11 +725,11 @@ Ip6CreateDefaultRouter ( - **/ - VOID - Ip6DestroyDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN IP6_DEFAULT_ROUTER *DefaultRouter -+ IN IP6_SERVICE *IpSb, -+ IN IP6_DEFAULT_ROUTER *DefaultRouter - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - - RemoveEntryList (&DefaultRouter->Link); - -@@ -751,10 +752,10 @@ Ip6DestroyDefaultRouter ( - **/ - VOID - Ip6CleanDefaultRouterList ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ) - { -- IP6_DEFAULT_ROUTER *DefaultRouter; -+ IP6_DEFAULT_ROUTER *DefaultRouter; - - while (!IsListEmpty (&IpSb->DefaultRouterList)) { - DefaultRouter = NET_LIST_HEAD (&IpSb->DefaultRouterList, IP6_DEFAULT_ROUTER, Link); -@@ -774,12 +775,12 @@ Ip6CleanDefaultRouterList ( - **/ - IP6_DEFAULT_ROUTER * - Ip6FindDefaultRouter ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Ip6Address -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Ip6Address - ) - { -- LIST_ENTRY *Entry; -- IP6_DEFAULT_ROUTER *DefaultRouter; -+ LIST_ENTRY *Entry; -+ IP6_DEFAULT_ROUTER *DefaultRouter; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - ASSERT (Ip6Address != NULL); -@@ -846,10 +847,10 @@ Ip6OnDADFinished ( - // Set the exta options to send. Here we only want the option request option - // with DNS SERVERS. - // -- Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf; -- Oro->OpCode = HTONS (DHCP6_OPT_ORO); -- Oro->OpLen = HTONS (2); -- *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS); -+ Oro = (EFI_DHCP6_PACKET_OPTION *)OptBuf; -+ Oro->OpCode = HTONS (DHCP6_OPT_ORO); -+ Oro->OpLen = HTONS (2); -+ *((UINT16 *)&Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS); - - InfoReqReXmit.Irt = 4; - InfoReqReXmit.Mrc = 64; -@@ -875,12 +876,11 @@ Ip6OnDADFinished ( - Ip6CreatePrefixListEntry ( - IpSb, - TRUE, -- (UINT32) IP6_INFINIT_LIFETIME, -- (UINT32) IP6_INFINIT_LIFETIME, -+ (UINT32)IP6_INFINIT_LIFETIME, -+ (UINT32)IP6_INFINIT_LIFETIME, - IP6_LINK_LOCAL_PREFIX_LENGTH, - &IpSb->LinkLocalAddr - ); -- - } else { - // - // Global scope unicast address. -@@ -928,7 +928,7 @@ Ip6OnDADFinished ( - IpSb->Mnp->Configure (IpSb->Mnp, NULL); - gBS->SetTimer (IpSb->Timer, TimerCancel, 0); - gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0); -- return ; -+ return; - } - - if (!IsDadPassed || NetIp6IsLinkLocalAddr (&AddrInfo->Address)) { -@@ -961,10 +961,10 @@ Ip6OnDADFinished ( - **/ - EFI_STATUS - Ip6InitDADProcess ( -- IN IP6_INTERFACE *IpIf, -- IN IP6_ADDRESS_INFO *AddressInfo, -- IN IP6_DAD_CALLBACK Callback OPTIONAL, -- IN VOID *Context OPTIONAL -+ IN IP6_INTERFACE *IpIf, -+ IN IP6_ADDRESS_INFO *AddressInfo, -+ IN IP6_DAD_CALLBACK Callback OPTIONAL, -+ IN VOID *Context OPTIONAL - ) - { - IP6_DAD_ENTRY *Entry; -@@ -1009,15 +1009,15 @@ Ip6InitDADProcess ( - return Status; - } - -- Entry->Signature = IP6_DAD_ENTRY_SIGNATURE; -- Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits; -- Entry->Transmit = 0; -- Entry->Receive = 0; -- MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS; -- Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5; -- Entry->AddressInfo = AddressInfo; -- Entry->Callback = Callback; -- Entry->Context = Context; -+ Entry->Signature = IP6_DAD_ENTRY_SIGNATURE; -+ Entry->MaxTransmit = DadXmits->DupAddrDetectTransmits; -+ Entry->Transmit = 0; -+ Entry->Receive = 0; -+ MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS; -+ Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5; -+ Entry->AddressInfo = AddressInfo; -+ Entry->Callback = Callback; -+ Entry->Context = Context; - InsertTailList (&IpIf->DupAddrDetectList, &Entry->Link); - - if (Entry->MaxTransmit == 0) { -@@ -1044,16 +1044,16 @@ Ip6InitDADProcess ( - **/ - IP6_DAD_ENTRY * - Ip6FindDADEntry ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *Target, -- OUT IP6_INTERFACE **Interface OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *Target, -+ OUT IP6_INTERFACE **Interface OPTIONAL - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Entry2; -- IP6_INTERFACE *IpIf; -- IP6_DAD_ENTRY *DupAddrDetect; -- IP6_ADDRESS_INFO *AddrInfo; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Entry2; -+ IP6_INTERFACE *IpIf; -+ IP6_DAD_ENTRY *DupAddrDetect; -+ IP6_ADDRESS_INFO *AddrInfo; - - NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { - IpIf = NET_LIST_USER_STRUCT (Entry, IP6_INTERFACE, Link); -@@ -1065,6 +1065,7 @@ Ip6FindDADEntry ( - if (Interface != NULL) { - *Interface = IpIf; - } -+ - return DupAddrDetect; - } - } -@@ -1093,24 +1094,24 @@ Ip6FindDADEntry ( - **/ - EFI_STATUS - Ip6SendRouterSolicit ( -- IN IP6_SERVICE *IpSb, -- IN IP6_INTERFACE *Interface OPTIONAL, -- IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, -- IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL, -- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN IP6_INTERFACE *Interface OPTIONAL, -+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, -+ IN EFI_IPv6_ADDRESS *DestinationAddress OPTIONAL, -+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL - ) - { -- NET_BUF *Packet; -- EFI_IP6_HEADER Head; -- IP6_ICMP_INFORMATION_HEAD *IcmpHead; -- IP6_ETHER_ADDR_OPTION *LinkLayerOption; -- UINT16 PayloadLen; -- IP6_INTERFACE *IpIf; -+ NET_BUF *Packet; -+ EFI_IP6_HEADER Head; -+ IP6_ICMP_INFORMATION_HEAD *IcmpHead; -+ IP6_ETHER_ADDR_OPTION *LinkLayerOption; -+ UINT16 PayloadLen; -+ IP6_INTERFACE *IpIf; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - - IpIf = Interface; -- if (IpIf == NULL && IpSb->DefaultInterface != NULL) { -+ if ((IpIf == NULL) && (IpSb->DefaultInterface != NULL)) { - IpIf = IpSb->DefaultInterface; - } - -@@ -1118,12 +1119,12 @@ Ip6SendRouterSolicit ( - // Generate the packet to be sent - // - -- PayloadLen = (UINT16) sizeof (IP6_ICMP_INFORMATION_HEAD); -+ PayloadLen = (UINT16)sizeof (IP6_ICMP_INFORMATION_HEAD); - if (SourceLinkAddress != NULL) { - PayloadLen += sizeof (IP6_ETHER_ADDR_OPTION); - } - -- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen); -+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen); - if (Packet == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -1131,11 +1132,11 @@ Ip6SendRouterSolicit ( - // - // Create the basic IPv6 header. - // -- Head.FlowLabelL = 0; -- Head.FlowLabelH = 0; -- Head.PayloadLength = HTONS (PayloadLen); -- Head.NextHeader = IP6_ICMP; -- Head.HopLimit = IP6_HOP_LIMIT; -+ Head.FlowLabelL = 0; -+ Head.FlowLabelH = 0; -+ Head.PayloadLength = HTONS (PayloadLen); -+ Head.NextHeader = IP6_ICMP; -+ Head.HopLimit = IP6_HOP_LIMIT; - - if (SourceAddress != NULL) { - IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress); -@@ -1143,7 +1144,6 @@ Ip6SendRouterSolicit ( - ZeroMem (&Head.SourceAddress, sizeof (EFI_IPv6_ADDRESS)); - } - -- - if (DestinationAddress != NULL) { - IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress); - } else { -@@ -1156,7 +1156,7 @@ Ip6SendRouterSolicit ( - // Fill in the ICMP header, and Source link-layer address if contained. - // - -- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); -+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); - ASSERT (IcmpHead != NULL); - ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD)); - IcmpHead->Head.Type = ICMP_V6_ROUTER_SOLICIT; -@@ -1164,14 +1164,14 @@ Ip6SendRouterSolicit ( - - LinkLayerOption = NULL; - if (SourceLinkAddress != NULL) { -- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace ( -- Packet, -- sizeof (IP6_ETHER_ADDR_OPTION), -- FALSE -- ); -+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace ( -+ Packet, -+ sizeof (IP6_ETHER_ADDR_OPTION), -+ FALSE -+ ); - ASSERT (LinkLayerOption != NULL); - LinkLayerOption->Type = Ip6OptionEtherSource; -- LinkLayerOption->Length = (UINT8) sizeof (IP6_ETHER_ADDR_OPTION); -+ LinkLayerOption->Length = (UINT8)sizeof (IP6_ETHER_ADDR_OPTION); - CopyMem (LinkLayerOption->EtherAddr, SourceLinkAddress, 6); - } - -@@ -1205,22 +1205,22 @@ Ip6SendRouterSolicit ( - **/ - EFI_STATUS - Ip6SendNeighborAdvertise ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *SourceAddress, -- IN EFI_IPv6_ADDRESS *DestinationAddress, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *TargetLinkAddress, -- IN BOOLEAN IsRouter, -- IN BOOLEAN Override, -- IN BOOLEAN Solicited -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *SourceAddress, -+ IN EFI_IPv6_ADDRESS *DestinationAddress, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *TargetLinkAddress, -+ IN BOOLEAN IsRouter, -+ IN BOOLEAN Override, -+ IN BOOLEAN Solicited - ) - { -- NET_BUF *Packet; -- EFI_IP6_HEADER Head; -- IP6_ICMP_INFORMATION_HEAD *IcmpHead; -- IP6_ETHER_ADDR_OPTION *LinkLayerOption; -- EFI_IPv6_ADDRESS *Target; -- UINT16 PayloadLen; -+ NET_BUF *Packet; -+ EFI_IP6_HEADER Head; -+ IP6_ICMP_INFORMATION_HEAD *IcmpHead; -+ IP6_ETHER_ADDR_OPTION *LinkLayerOption; -+ EFI_IPv6_ADDRESS *Target; -+ UINT16 PayloadLen; - - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - -@@ -1232,13 +1232,13 @@ Ip6SendNeighborAdvertise ( - // - ASSERT (DestinationAddress != NULL && TargetIp6Address != NULL && TargetLinkAddress != NULL); - -- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION)); -+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS) + sizeof (IP6_ETHER_ADDR_OPTION)); - - // - // Generate the packet to be sent - // - -- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen); -+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen); - if (Packet == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -1246,11 +1246,11 @@ Ip6SendNeighborAdvertise ( - // - // Create the basic IPv6 header. - // -- Head.FlowLabelL = 0; -- Head.FlowLabelH = 0; -- Head.PayloadLength = HTONS (PayloadLen); -- Head.NextHeader = IP6_ICMP; -- Head.HopLimit = IP6_HOP_LIMIT; -+ Head.FlowLabelL = 0; -+ Head.FlowLabelH = 0; -+ Head.PayloadLength = HTONS (PayloadLen); -+ Head.NextHeader = IP6_ICMP; -+ Head.HopLimit = IP6_HOP_LIMIT; - - IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress); - IP6_COPY_ADDRESS (&Head.DestinationAddress, DestinationAddress); -@@ -1262,7 +1262,7 @@ Ip6SendNeighborAdvertise ( - // Set the Router flag, Solicited flag and Override flag. - // - -- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); -+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); - ASSERT (IcmpHead != NULL); - ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD)); - IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_ADVERTISE; -@@ -1280,15 +1280,15 @@ Ip6SendNeighborAdvertise ( - IcmpHead->Fourth |= IP6_OVERRIDE_FLAG; - } - -- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE); -+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE); - ASSERT (Target != NULL); - IP6_COPY_ADDRESS (Target, TargetIp6Address); - -- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace ( -- Packet, -- sizeof (IP6_ETHER_ADDR_OPTION), -- FALSE -- ); -+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace ( -+ Packet, -+ sizeof (IP6_ETHER_ADDR_OPTION), -+ FALSE -+ ); - ASSERT (LinkLayerOption != NULL); - LinkLayerOption->Type = Ip6OptionEtherTarget; - LinkLayerOption->Length = 1; -@@ -1320,33 +1320,33 @@ Ip6SendNeighborAdvertise ( - **/ - EFI_STATUS - Ip6SendNeighborSolicit ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *SourceAddress, -- IN EFI_IPv6_ADDRESS *DestinationAddress, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *SourceAddress, -+ IN EFI_IPv6_ADDRESS *DestinationAddress, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *SourceLinkAddress OPTIONAL - ) - { -- NET_BUF *Packet; -- EFI_IP6_HEADER Head; -- IP6_ICMP_INFORMATION_HEAD *IcmpHead; -- IP6_ETHER_ADDR_OPTION *LinkLayerOption; -- EFI_IPv6_ADDRESS *Target; -- BOOLEAN IsDAD; -- UINT16 PayloadLen; -- IP6_NEIGHBOR_ENTRY *Neighbor; -+ NET_BUF *Packet; -+ EFI_IP6_HEADER Head; -+ IP6_ICMP_INFORMATION_HEAD *IcmpHead; -+ IP6_ETHER_ADDR_OPTION *LinkLayerOption; -+ EFI_IPv6_ADDRESS *Target; -+ BOOLEAN IsDAD; -+ UINT16 PayloadLen; -+ IP6_NEIGHBOR_ENTRY *Neighbor; - - // - // Check input parameters - // - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); -- if (DestinationAddress == NULL || TargetIp6Address == NULL) { -+ if ((DestinationAddress == NULL) || (TargetIp6Address == NULL)) { - return EFI_INVALID_PARAMETER; - } - - IsDAD = FALSE; - -- if (SourceAddress == NULL || (SourceAddress != NULL && NetIp6IsUnspecifiedAddr (SourceAddress))) { -+ if ((SourceAddress == NULL) || ((SourceAddress != NULL) && NetIp6IsUnspecifiedAddr (SourceAddress))) { - IsDAD = TRUE; - } - -@@ -1355,21 +1355,21 @@ Ip6SendNeighborSolicit ( - // if the solicitation is not sent by performing DAD - Duplicate Address Detection. - // Otherwise must not include it. - // -- PayloadLen = (UINT16) (sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS)); -+ PayloadLen = (UINT16)(sizeof (IP6_ICMP_INFORMATION_HEAD) + sizeof (EFI_IPv6_ADDRESS)); - - if (!IsDAD) { - if (SourceLinkAddress == NULL) { - return EFI_INVALID_PARAMETER; - } - -- PayloadLen = (UINT16) (PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION)); -+ PayloadLen = (UINT16)(PayloadLen + sizeof (IP6_ETHER_ADDR_OPTION)); - } - - // - // Generate the packet to be sent - // - -- Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32) PayloadLen); -+ Packet = NetbufAlloc (sizeof (EFI_IP6_HEADER) + (UINT32)PayloadLen); - if (Packet == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -1377,11 +1377,11 @@ Ip6SendNeighborSolicit ( - // - // Create the basic IPv6 header - // -- Head.FlowLabelL = 0; -- Head.FlowLabelH = 0; -- Head.PayloadLength = HTONS (PayloadLen); -- Head.NextHeader = IP6_ICMP; -- Head.HopLimit = IP6_HOP_LIMIT; -+ Head.FlowLabelL = 0; -+ Head.FlowLabelH = 0; -+ Head.PayloadLength = HTONS (PayloadLen); -+ Head.NextHeader = IP6_ICMP; -+ Head.HopLimit = IP6_HOP_LIMIT; - - if (SourceAddress != NULL) { - IP6_COPY_ADDRESS (&Head.SourceAddress, SourceAddress); -@@ -1396,27 +1396,26 @@ Ip6SendNeighborSolicit ( - // - // Fill in the ICMP header, Target address, and Source link-layer address. - // -- IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); -+ IcmpHead = (IP6_ICMP_INFORMATION_HEAD *)NetbufAllocSpace (Packet, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE); - ASSERT (IcmpHead != NULL); - ZeroMem (IcmpHead, sizeof (IP6_ICMP_INFORMATION_HEAD)); - IcmpHead->Head.Type = ICMP_V6_NEIGHBOR_SOLICIT; - IcmpHead->Head.Code = 0; - -- Target = (EFI_IPv6_ADDRESS *) NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE); -+ Target = (EFI_IPv6_ADDRESS *)NetbufAllocSpace (Packet, sizeof (EFI_IPv6_ADDRESS), FALSE); - ASSERT (Target != NULL); - IP6_COPY_ADDRESS (Target, TargetIp6Address); - - LinkLayerOption = NULL; - if (!IsDAD) { -- - // - // Fill in the source link-layer address option - // -- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) NetbufAllocSpace ( -- Packet, -- sizeof (IP6_ETHER_ADDR_OPTION), -- FALSE -- ); -+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)NetbufAllocSpace ( -+ Packet, -+ sizeof (IP6_ETHER_ADDR_OPTION), -+ FALSE -+ ); - ASSERT (LinkLayerOption != NULL); - LinkLayerOption->Type = Ip6OptionEtherSource; - LinkLayerOption->Length = 1; -@@ -1457,30 +1456,30 @@ Ip6SendNeighborSolicit ( - **/ - EFI_STATUS - Ip6ProcessNeighborSolicit ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- IP6_ICMP_INFORMATION_HEAD Icmp; -- EFI_IPv6_ADDRESS Target; -- IP6_ETHER_ADDR_OPTION LinkLayerOption; -- BOOLEAN IsDAD; -- BOOLEAN IsUnicast; -- BOOLEAN IsMaintained; -- IP6_DAD_ENTRY *DupAddrDetect; -- IP6_INTERFACE *IpIf; -- IP6_NEIGHBOR_ENTRY *Neighbor; -- BOOLEAN Solicited; -- BOOLEAN UpdateCache; -- EFI_IPv6_ADDRESS Dest; -- UINT16 OptionLen; -- UINT8 *Option; -- BOOLEAN Provided; -- EFI_STATUS Status; -- VOID *MacAddress; -- -- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); -+ IP6_ICMP_INFORMATION_HEAD Icmp; -+ EFI_IPv6_ADDRESS Target; -+ IP6_ETHER_ADDR_OPTION LinkLayerOption; -+ BOOLEAN IsDAD; -+ BOOLEAN IsUnicast; -+ BOOLEAN IsMaintained; -+ IP6_DAD_ENTRY *DupAddrDetect; -+ IP6_INTERFACE *IpIf; -+ IP6_NEIGHBOR_ENTRY *Neighbor; -+ BOOLEAN Solicited; -+ BOOLEAN UpdateCache; -+ EFI_IPv6_ADDRESS Dest; -+ UINT16 OptionLen; -+ UINT8 *Option; -+ BOOLEAN Provided; -+ EFI_STATUS Status; -+ VOID *MacAddress; -+ -+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp); - NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr); - - // -@@ -1492,7 +1491,7 @@ Ip6ProcessNeighborSolicit ( - // - Status = EFI_INVALID_PARAMETER; - -- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) { -+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) { - goto Exit; - } - -@@ -1503,9 +1502,9 @@ Ip6ProcessNeighborSolicit ( - if (Head->PayloadLength < IP6_ND_LENGTH) { - goto Exit; - } else { -- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH); -+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH); - if (OptionLen != 0) { -- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); -+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); - ASSERT (Option != NULL); - - // -@@ -1527,7 +1526,7 @@ Ip6ProcessNeighborSolicit ( - Packet, - IP6_ND_LENGTH, - sizeof (IP6_ETHER_ADDR_OPTION), -- (UINT8 *) &LinkLayerOption -+ (UINT8 *)&LinkLayerOption - ); - // - // The solicitation for neighbor discovery should include a source link-layer -@@ -1591,7 +1590,8 @@ Ip6ProcessNeighborSolicit ( - MacAddress, - &IpSb->SnpMode.CurrentAddress, - IpSb->SnpMode.HwAddressSize -- ) != 0) { -+ ) != 0) -+ { - // - // The NS is from another node to performing DAD on the same address. - // Fail DAD for the tentative address. -@@ -1607,6 +1607,7 @@ Ip6ProcessNeighborSolicit ( - } - } - } -+ - goto Exit; - } - -@@ -1624,6 +1625,7 @@ Ip6ProcessNeighborSolicit ( - Status = EFI_OUT_OF_RESOURCES; - goto Exit; - } -+ - UpdateCache = TRUE; - } else { - if (CompareMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6) != 0) { -@@ -1633,12 +1635,12 @@ Ip6ProcessNeighborSolicit ( - - if (UpdateCache) { - Neighbor->State = EfiNeighborStale; -- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6); - // - // Send queued packets if exist. - // -- Neighbor->CallBack ((VOID *) Neighbor); -+ Neighbor->CallBack ((VOID *)Neighbor); - } - } - -@@ -1686,28 +1688,28 @@ Exit: - **/ - EFI_STATUS - Ip6ProcessNeighborAdvertise ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- IP6_ICMP_INFORMATION_HEAD Icmp; -- EFI_IPv6_ADDRESS Target; -- IP6_ETHER_ADDR_OPTION LinkLayerOption; -- BOOLEAN Provided; -- INTN Compare; -- IP6_NEIGHBOR_ENTRY *Neighbor; -- IP6_DEFAULT_ROUTER *DefaultRouter; -- BOOLEAN Solicited; -- BOOLEAN IsRouter; -- BOOLEAN Override; -- IP6_DAD_ENTRY *DupAddrDetect; -- IP6_INTERFACE *IpIf; -- UINT16 OptionLen; -- UINT8 *Option; -- EFI_STATUS Status; -- -- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); -+ IP6_ICMP_INFORMATION_HEAD Icmp; -+ EFI_IPv6_ADDRESS Target; -+ IP6_ETHER_ADDR_OPTION LinkLayerOption; -+ BOOLEAN Provided; -+ INTN Compare; -+ IP6_NEIGHBOR_ENTRY *Neighbor; -+ IP6_DEFAULT_ROUTER *DefaultRouter; -+ BOOLEAN Solicited; -+ BOOLEAN IsRouter; -+ BOOLEAN Override; -+ IP6_DAD_ENTRY *DupAddrDetect; -+ IP6_INTERFACE *IpIf; -+ UINT16 OptionLen; -+ UINT8 *Option; -+ EFI_STATUS Status; -+ -+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp); - NetbufCopy (Packet, sizeof (Icmp), sizeof (Target), Target.Addr); - - // -@@ -1720,7 +1722,7 @@ Ip6ProcessNeighborAdvertise ( - // ICMP Code is 0. - // Target Address is not a multicast address. - // -- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || !NetIp6IsValidUnicast (&Target)) { -+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || !NetIp6IsValidUnicast (&Target)) { - goto Exit; - } - -@@ -1732,9 +1734,9 @@ Ip6ProcessNeighborAdvertise ( - if (Head->PayloadLength < IP6_ND_LENGTH) { - goto Exit; - } else { -- OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH); -+ OptionLen = (UINT16)(Head->PayloadLength - IP6_ND_LENGTH); - if (OptionLen != 0) { -- Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); -+ Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); - ASSERT (Option != NULL); - - // -@@ -1753,6 +1755,7 @@ Ip6ProcessNeighborAdvertise ( - if ((Icmp.Fourth & IP6_SOLICITED_FLAG) == IP6_SOLICITED_FLAG) { - Solicited = TRUE; - } -+ - if (IP6_IS_MULTICAST (&Head->DestinationAddress) && Solicited) { - goto Exit; - } -@@ -1787,6 +1790,7 @@ Ip6ProcessNeighborAdvertise ( - if ((Icmp.Fourth & IP6_IS_ROUTER_FLAG) == IP6_IS_ROUTER_FLAG) { - IsRouter = TRUE; - } -+ - if ((Icmp.Fourth & IP6_OVERRIDE_FLAG) == IP6_OVERRIDE_FLAG) { - Override = TRUE; - } -@@ -1799,7 +1803,7 @@ Ip6ProcessNeighborAdvertise ( - Packet, - IP6_ND_LENGTH, - sizeof (IP6_ETHER_ADDR_OPTION), -- (UINT8 *) &LinkLayerOption -+ (UINT8 *)&LinkLayerOption - ); - - if (LinkLayerOption.Type == Ip6OptionEtherTarget) { -@@ -1828,6 +1832,7 @@ Ip6ProcessNeighborAdvertise ( - if (!Provided) { - goto Exit; - } -+ - // - // Update the Neighbor Cache - // -@@ -1837,17 +1842,16 @@ Ip6ProcessNeighborAdvertise ( - Neighbor->Ticks = IP6_GET_TICKS (IpSb->ReachableTime); - } else { - Neighbor->State = EfiNeighborStale; -- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - // - // Send any packets queued for the neighbor awaiting address resolution. - // -- Neighbor->CallBack ((VOID *) Neighbor); -+ Neighbor->CallBack ((VOID *)Neighbor); - } - - Neighbor->IsRouter = IsRouter; -- - } else { -- if (!Override && Compare != 0) { -+ if (!Override && (Compare != 0)) { - // - // When the Override Flag is clear and supplied link-layer address differs from - // that in the cache, if the state of the entry is not REACHABLE, ignore the -@@ -1856,12 +1860,13 @@ Ip6ProcessNeighborAdvertise ( - // - if (Neighbor->State == EfiNeighborReachable) { - Neighbor->State = EfiNeighborStale; -- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - } - } else { - if (Compare != 0) { - CopyMem (Neighbor->LinkAddress.Addr, LinkLayerOption.EtherAddr, 6); - } -+ - // - // Update the entry's state - // -@@ -1871,7 +1876,7 @@ Ip6ProcessNeighborAdvertise ( - } else { - if (Compare != 0) { - Neighbor->State = EfiNeighborStale; -- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - } - } - -@@ -1892,7 +1897,7 @@ Ip6ProcessNeighborAdvertise ( - } - - if (Neighbor->State == EfiNeighborReachable) { -- Neighbor->CallBack ((VOID *) Neighbor); -+ Neighbor->CallBack ((VOID *)Neighbor); - } - - Status = EFI_SUCCESS; -@@ -1918,36 +1923,36 @@ Exit: - **/ - EFI_STATUS - Ip6ProcessRouterAdvertise ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- IP6_ICMP_INFORMATION_HEAD Icmp; -- UINT32 ReachableTime; -- UINT32 RetransTimer; -- UINT16 RouterLifetime; -- UINT32 Offset; -- UINT8 Type; -- UINT8 Length; -- IP6_ETHER_ADDR_OPTION LinkLayerOption; -- UINT32 Fourth; -- UINT8 CurHopLimit; -- BOOLEAN Mflag; -- BOOLEAN Oflag; -- IP6_DEFAULT_ROUTER *DefaultRouter; -- IP6_NEIGHBOR_ENTRY *NeighborCache; -- EFI_MAC_ADDRESS LinkLayerAddress; -- IP6_MTU_OPTION MTUOption; -- IP6_PREFIX_INFO_OPTION PrefixOption; -- IP6_PREFIX_LIST_ENTRY *PrefixList; -- BOOLEAN OnLink; -- BOOLEAN Autonomous; -- EFI_IPv6_ADDRESS StatelessAddress; -- EFI_STATUS Status; -- UINT16 OptionLen; -- UINT8 *Option; -- INTN Result; -+ IP6_ICMP_INFORMATION_HEAD Icmp; -+ UINT32 ReachableTime; -+ UINT32 RetransTimer; -+ UINT16 RouterLifetime; -+ UINT32 Offset; -+ UINT8 Type; -+ UINT8 Length; -+ IP6_ETHER_ADDR_OPTION LinkLayerOption; -+ UINT32 Fourth; -+ UINT8 CurHopLimit; -+ BOOLEAN Mflag; -+ BOOLEAN Oflag; -+ IP6_DEFAULT_ROUTER *DefaultRouter; -+ IP6_NEIGHBOR_ENTRY *NeighborCache; -+ EFI_MAC_ADDRESS LinkLayerAddress; -+ IP6_MTU_OPTION MTUOption; -+ IP6_PREFIX_INFO_OPTION PrefixOption; -+ IP6_PREFIX_LIST_ENTRY *PrefixList; -+ BOOLEAN OnLink; -+ BOOLEAN Autonomous; -+ EFI_IPv6_ADDRESS StatelessAddress; -+ EFI_STATUS Status; -+ UINT16 OptionLen; -+ UINT8 *Option; -+ INTN Result; - - Status = EFI_INVALID_PARAMETER; - -@@ -1958,7 +1963,7 @@ Ip6ProcessRouterAdvertise ( - goto Exit; - } - -- NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *) &Icmp); -+ NetbufCopy (Packet, 0, sizeof (Icmp), (UINT8 *)&Icmp); - - // - // Validate the incoming Router Advertisement -@@ -1970,23 +1975,25 @@ Ip6ProcessRouterAdvertise ( - if (!NetIp6IsLinkLocalAddr (&Head->SourceAddress)) { - goto Exit; - } -+ - // - // The IP Hop Limit field has a value of 255, i.e. the packet - // could not possibly have been forwarded by a router. - // ICMP Code is 0. - // ICMP length (derived from the IP length) is 16 or more octets. - // -- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp.Head.Code != 0 || -- Head->PayloadLength < IP6_RA_LENGTH) { -+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp.Head.Code != 0) || -+ (Head->PayloadLength < IP6_RA_LENGTH)) -+ { - goto Exit; - } - - // - // All included options have a length that is greater than zero. - // -- OptionLen = (UINT16) (Head->PayloadLength - IP6_RA_LENGTH); -+ OptionLen = (UINT16)(Head->PayloadLength - IP6_RA_LENGTH); - if (OptionLen != 0) { -- Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL); -+ Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL); - ASSERT (Option != NULL); - - if (!Ip6IsNDOptionValid (Option, OptionLen)) { -@@ -2035,17 +2042,17 @@ Ip6ProcessRouterAdvertise ( - } - } - -- CurHopLimit = *((UINT8 *) &Fourth + 3); -+ CurHopLimit = *((UINT8 *)&Fourth + 3); - if (CurHopLimit != 0) { - IpSb->CurHopLimit = CurHopLimit; - } - - Mflag = FALSE; - Oflag = FALSE; -- if ((*((UINT8 *) &Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) { -+ if ((*((UINT8 *)&Fourth + 2) & IP6_M_ADDR_CONFIG_FLAG) == IP6_M_ADDR_CONFIG_FLAG) { - Mflag = TRUE; - } else { -- if ((*((UINT8 *) &Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) { -+ if ((*((UINT8 *)&Fourth + 2) & IP6_O_CONFIG_FLAG) == IP6_O_CONFIG_FLAG) { - Oflag = TRUE; - } - } -@@ -2060,12 +2067,12 @@ Ip6ProcessRouterAdvertise ( - // - // Process Reachable Time and Retrans Timer fields. - // -- NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *) &ReachableTime); -- NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *) &RetransTimer); -+ NetbufCopy (Packet, sizeof (Icmp), sizeof (UINT32), (UINT8 *)&ReachableTime); -+ NetbufCopy (Packet, sizeof (Icmp) + sizeof (UINT32), sizeof (UINT32), (UINT8 *)&RetransTimer); - ReachableTime = NTOHL (ReachableTime); - RetransTimer = NTOHL (RetransTimer); - -- if (ReachableTime != 0 && ReachableTime != IpSb->BaseReachableTime) { -+ if ((ReachableTime != 0) && (ReachableTime != IpSb->BaseReachableTime)) { - // - // If new value is not unspecified and differs from the previous one, record it - // in BaseReachableTime and recompute a ReachableTime. -@@ -2098,262 +2105,266 @@ Ip6ProcessRouterAdvertise ( - // fit within the input packet. - // - Offset = 16; -- while (Offset < (UINT32) Head->PayloadLength) { -+ while (Offset < (UINT32)Head->PayloadLength) { - NetbufCopy (Packet, Offset, sizeof (UINT8), &Type); - switch (Type) { -- case Ip6OptionEtherSource: -- // -- // Update the neighbor cache -- // -- NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *) &LinkLayerOption); -+ case Ip6OptionEtherSource: -+ // -+ // Update the neighbor cache -+ // -+ NetbufCopy (Packet, Offset, sizeof (IP6_ETHER_ADDR_OPTION), (UINT8 *)&LinkLayerOption); - -- // -- // Option size validity ensured by Ip6IsNDOptionValid(). -- // -- ASSERT (LinkLayerOption.Length != 0); -- ASSERT (Offset + (UINT32) LinkLayerOption.Length * 8 <= (UINT32) Head->PayloadLength); -+ // -+ // Option size validity ensured by Ip6IsNDOptionValid(). -+ // -+ ASSERT (LinkLayerOption.Length != 0); -+ ASSERT (Offset + (UINT32)LinkLayerOption.Length * 8 <= (UINT32)Head->PayloadLength); - -- ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS)); -- CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6); -+ ZeroMem (&LinkLayerAddress, sizeof (EFI_MAC_ADDRESS)); -+ CopyMem (&LinkLayerAddress, LinkLayerOption.EtherAddr, 6); - -- if (NeighborCache == NULL) { -- NeighborCache = Ip6CreateNeighborEntry ( -- IpSb, -- Ip6OnArpResolved, -- &Head->SourceAddress, -- &LinkLayerAddress -- ); - if (NeighborCache == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto Exit; -+ NeighborCache = Ip6CreateNeighborEntry ( -+ IpSb, -+ Ip6OnArpResolved, -+ &Head->SourceAddress, -+ &LinkLayerAddress -+ ); -+ if (NeighborCache == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto Exit; -+ } -+ -+ NeighborCache->IsRouter = TRUE; -+ NeighborCache->State = EfiNeighborStale; -+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME; -+ } else { -+ Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6); -+ -+ // -+ // If the link-local address is the same as that already in the cache, -+ // the cache entry's state remains unchanged. Otherwise update the -+ // reachability state to STALE. -+ // -+ if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) { -+ CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6); -+ -+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME; -+ -+ if (NeighborCache->State == EfiNeighborInComplete) { -+ // -+ // Send queued packets if exist. -+ // -+ NeighborCache->State = EfiNeighborStale; -+ NeighborCache->CallBack ((VOID *)NeighborCache); -+ } else { -+ NeighborCache->State = EfiNeighborStale; -+ } -+ } - } -- NeighborCache->IsRouter = TRUE; -- NeighborCache->State = EfiNeighborStale; -- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -- } else { -- Result = CompareMem (&LinkLayerAddress, &NeighborCache->LinkAddress, 6); -+ -+ Offset += (UINT32)LinkLayerOption.Length * 8; -+ break; -+ case Ip6OptionPrefixInfo: -+ NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *)&PrefixOption); - - // -- // If the link-local address is the same as that already in the cache, -- // the cache entry's state remains unchanged. Otherwise update the -- // reachability state to STALE. -+ // Option size validity ensured by Ip6IsNDOptionValid(). - // -- if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) { -- CopyMem (&NeighborCache->LinkAddress, &LinkLayerAddress, 6); -+ ASSERT (PrefixOption.Length == 4); -+ ASSERT (Offset + (UINT32)PrefixOption.Length * 8 <= (UINT32)Head->PayloadLength); - -- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime); -+ PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime); - -- if (NeighborCache->State == EfiNeighborInComplete) { -- // -- // Send queued packets if exist. -- // -- NeighborCache->State = EfiNeighborStale; -- NeighborCache->CallBack ((VOID *) NeighborCache); -- } else { -- NeighborCache->State = EfiNeighborStale; -- } -+ // -+ // Get L and A flag, recorded in the lower 2 bits of Reserved1 -+ // -+ OnLink = FALSE; -+ if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) { -+ OnLink = TRUE; - } -- } -- -- Offset += (UINT32) LinkLayerOption.Length * 8; -- break; -- case Ip6OptionPrefixInfo: -- NetbufCopy (Packet, Offset, sizeof (IP6_PREFIX_INFO_OPTION), (UINT8 *) &PrefixOption); - -- // -- // Option size validity ensured by Ip6IsNDOptionValid(). -- // -- ASSERT (PrefixOption.Length == 4); -- ASSERT (Offset + (UINT32) PrefixOption.Length * 8 <= (UINT32) Head->PayloadLength); -- -- PrefixOption.ValidLifetime = NTOHL (PrefixOption.ValidLifetime); -- PrefixOption.PreferredLifetime = NTOHL (PrefixOption.PreferredLifetime); -+ Autonomous = FALSE; -+ if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) { -+ Autonomous = TRUE; -+ } - -- // -- // Get L and A flag, recorded in the lower 2 bits of Reserved1 -- // -- OnLink = FALSE; -- if ((PrefixOption.Reserved1 & IP6_ON_LINK_FLAG) == IP6_ON_LINK_FLAG) { -- OnLink = TRUE; -- } -- Autonomous = FALSE; -- if ((PrefixOption.Reserved1 & IP6_AUTO_CONFIG_FLAG) == IP6_AUTO_CONFIG_FLAG) { -- Autonomous = TRUE; -- } -+ // -+ // If the prefix is the link-local prefix, silently ignore the prefix option. -+ // -+ if ((PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH) && -+ NetIp6IsLinkLocalAddr (&PrefixOption.Prefix) -+ ) -+ { -+ Offset += sizeof (IP6_PREFIX_INFO_OPTION); -+ break; -+ } - -- // -- // If the prefix is the link-local prefix, silently ignore the prefix option. -- // -- if (PrefixOption.PrefixLength == IP6_LINK_LOCAL_PREFIX_LENGTH && -- NetIp6IsLinkLocalAddr (&PrefixOption.Prefix) -- ) { -- Offset += sizeof (IP6_PREFIX_INFO_OPTION); -- break; -- } -- // -- // Do following if on-link flag is set according to RFC4861. -- // -- if (OnLink) { -- PrefixList = Ip6FindPrefixListEntry ( -- IpSb, -- TRUE, -- PrefixOption.PrefixLength, -- &PrefixOption.Prefix -- ); - // -- // Create a new entry for the prefix, if the ValidLifetime is zero, -- // silently ignore the prefix option. -+ // Do following if on-link flag is set according to RFC4861. - // -- if (PrefixList == NULL && PrefixOption.ValidLifetime != 0) { -- PrefixList = Ip6CreatePrefixListEntry ( -+ if (OnLink) { -+ PrefixList = Ip6FindPrefixListEntry ( - IpSb, - TRUE, -- PrefixOption.ValidLifetime, -- PrefixOption.PreferredLifetime, - PrefixOption.PrefixLength, - &PrefixOption.Prefix - ); -- if (PrefixList == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto Exit; -- } -- } else if (PrefixList != NULL) { -- if (PrefixOption.ValidLifetime != 0) { -- PrefixList->ValidLifetime = PrefixOption.ValidLifetime; -- } else { -- // -- // If the prefix exists and incoming ValidLifetime is zero, immediately -- // remove the prefix. -- Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE); -- } -- } -- } -- -- // -- // Do following if Autonomous flag is set according to RFC4862. -- // -- if (Autonomous && PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime) { -- PrefixList = Ip6FindPrefixListEntry ( -- IpSb, -- FALSE, -- PrefixOption.PrefixLength, -- &PrefixOption.Prefix -- ); -- // -- // Create a new entry for the prefix, and form an address by prefix + interface id -- // If the sum of the prefix length and interface identifier length -- // does not equal 128 bits, the Prefix Information option MUST be ignored. -- // -- if (PrefixList == NULL && -- PrefixOption.ValidLifetime != 0 && -- PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128 -- ) { - // -- // Form the address in network order. -+ // Create a new entry for the prefix, if the ValidLifetime is zero, -+ // silently ignore the prefix option. - // -- CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64)); -- CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64)); -- -- // -- // If the address is not yet in the assigned address list, adds it into. -- // -- if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) { -- // -- // And also not in the DAD process, check its uniqueness firstly. -- // -- if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) { -- Status = Ip6SetAddress ( -- IpSb->DefaultInterface, -- &StatelessAddress, -- FALSE, -- PrefixOption.PrefixLength, -- PrefixOption.ValidLifetime, -- PrefixOption.PreferredLifetime, -- NULL, -- NULL -- ); -- if (EFI_ERROR (Status)) { -- goto Exit; -- } -+ if ((PrefixList == NULL) && (PrefixOption.ValidLifetime != 0)) { -+ PrefixList = Ip6CreatePrefixListEntry ( -+ IpSb, -+ TRUE, -+ PrefixOption.ValidLifetime, -+ PrefixOption.PreferredLifetime, -+ PrefixOption.PrefixLength, -+ &PrefixOption.Prefix -+ ); -+ if (PrefixList == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto Exit; -+ } -+ } else if (PrefixList != NULL) { -+ if (PrefixOption.ValidLifetime != 0) { -+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime; -+ } else { -+ // -+ // If the prefix exists and incoming ValidLifetime is zero, immediately -+ // remove the prefix. -+ Ip6DestroyPrefixListEntry (IpSb, PrefixList, OnLink, TRUE); - } - } -+ } - -- // -- // Adds the prefix option to stateless prefix option list. -- // -- PrefixList = Ip6CreatePrefixListEntry ( -+ // -+ // Do following if Autonomous flag is set according to RFC4862. -+ // -+ if (Autonomous && (PrefixOption.PreferredLifetime <= PrefixOption.ValidLifetime)) { -+ PrefixList = Ip6FindPrefixListEntry ( - IpSb, - FALSE, -- PrefixOption.ValidLifetime, -- PrefixOption.PreferredLifetime, - PrefixOption.PrefixLength, - &PrefixOption.Prefix - ); -- if (PrefixList == NULL) { -- Status = EFI_OUT_OF_RESOURCES; -- goto Exit; -- } -- } else if (PrefixList != NULL) { -- - // -- // Reset the preferred lifetime of the address if the advertised prefix exists. -- // Perform specific action to valid lifetime together. -+ // Create a new entry for the prefix, and form an address by prefix + interface id -+ // If the sum of the prefix length and interface identifier length -+ // does not equal 128 bits, the Prefix Information option MUST be ignored. - // -- PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime; -- if ((PrefixOption.ValidLifetime > 7200) || -- (PrefixOption.ValidLifetime > PrefixList->ValidLifetime)) { -+ if ((PrefixList == NULL) && -+ (PrefixOption.ValidLifetime != 0) && -+ (PrefixOption.PrefixLength + IpSb->InterfaceIdLen * 8 == 128) -+ ) -+ { - // -- // If the received Valid Lifetime is greater than 2 hours or -- // greater than RemainingLifetime, set the valid lifetime of the -- // corresponding address to the advertised Valid Lifetime. -+ // Form the address in network order. - // -- PrefixList->ValidLifetime = PrefixOption.ValidLifetime; -+ CopyMem (&StatelessAddress, &PrefixOption.Prefix, sizeof (UINT64)); -+ CopyMem (&StatelessAddress.Addr[8], IpSb->InterfaceId, sizeof (UINT64)); - -- } else if (PrefixList->ValidLifetime <= 7200) { - // -- // If RemainingLifetime is less than or equals to 2 hours, ignore the -- // Prefix Information option with regards to the valid lifetime. -- // TODO: If this option has been authenticated, set the valid lifetime. -+ // If the address is not yet in the assigned address list, adds it into. - // -- } else { -+ if (!Ip6IsOneOfSetAddress (IpSb, &StatelessAddress, NULL, NULL)) { -+ // -+ // And also not in the DAD process, check its uniqueness firstly. -+ // -+ if (Ip6FindDADEntry (IpSb, &StatelessAddress, NULL) == NULL) { -+ Status = Ip6SetAddress ( -+ IpSb->DefaultInterface, -+ &StatelessAddress, -+ FALSE, -+ PrefixOption.PrefixLength, -+ PrefixOption.ValidLifetime, -+ PrefixOption.PreferredLifetime, -+ NULL, -+ NULL -+ ); -+ if (EFI_ERROR (Status)) { -+ goto Exit; -+ } -+ } -+ } -+ - // -- // Otherwise, reset the valid lifetime of the corresponding -- // address to 2 hours. -+ // Adds the prefix option to stateless prefix option list. -+ // -+ PrefixList = Ip6CreatePrefixListEntry ( -+ IpSb, -+ FALSE, -+ PrefixOption.ValidLifetime, -+ PrefixOption.PreferredLifetime, -+ PrefixOption.PrefixLength, -+ &PrefixOption.Prefix -+ ); -+ if (PrefixList == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto Exit; -+ } -+ } else if (PrefixList != NULL) { - // -- PrefixList->ValidLifetime = 7200; -+ // Reset the preferred lifetime of the address if the advertised prefix exists. -+ // Perform specific action to valid lifetime together. -+ // -+ PrefixList->PreferredLifetime = PrefixOption.PreferredLifetime; -+ if ((PrefixOption.ValidLifetime > 7200) || -+ (PrefixOption.ValidLifetime > PrefixList->ValidLifetime)) -+ { -+ // -+ // If the received Valid Lifetime is greater than 2 hours or -+ // greater than RemainingLifetime, set the valid lifetime of the -+ // corresponding address to the advertised Valid Lifetime. -+ // -+ PrefixList->ValidLifetime = PrefixOption.ValidLifetime; -+ } else if (PrefixList->ValidLifetime <= 7200) { -+ // -+ // If RemainingLifetime is less than or equals to 2 hours, ignore the -+ // Prefix Information option with regards to the valid lifetime. -+ // TODO: If this option has been authenticated, set the valid lifetime. -+ // -+ } else { -+ // -+ // Otherwise, reset the valid lifetime of the corresponding -+ // address to 2 hours. -+ // -+ PrefixList->ValidLifetime = 7200; -+ } - } - } -- } - -- Offset += sizeof (IP6_PREFIX_INFO_OPTION); -- break; -- case Ip6OptionMtu: -- NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *) &MTUOption); -+ Offset += sizeof (IP6_PREFIX_INFO_OPTION); -+ break; -+ case Ip6OptionMtu: -+ NetbufCopy (Packet, Offset, sizeof (IP6_MTU_OPTION), (UINT8 *)&MTUOption); - -- // -- // Option size validity ensured by Ip6IsNDOptionValid(). -- // -- ASSERT (MTUOption.Length == 1); -- ASSERT (Offset + (UINT32) MTUOption.Length * 8 <= (UINT32) Head->PayloadLength); -+ // -+ // Option size validity ensured by Ip6IsNDOptionValid(). -+ // -+ ASSERT (MTUOption.Length == 1); -+ ASSERT (Offset + (UINT32)MTUOption.Length * 8 <= (UINT32)Head->PayloadLength); - -- // -- // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order -- // to omit implementation of Path MTU Discovery. Thus ignore the MTU option -- // in Router Advertisement. -- // -+ // -+ // Use IPv6 minimum link MTU 1280 bytes as the maximum packet size in order -+ // to omit implementation of Path MTU Discovery. Thus ignore the MTU option -+ // in Router Advertisement. -+ // - -- Offset += sizeof (IP6_MTU_OPTION); -- break; -- default: -- // -- // Silently ignore unrecognized options -- // -- NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length); -+ Offset += sizeof (IP6_MTU_OPTION); -+ break; -+ default: -+ // -+ // Silently ignore unrecognized options -+ // -+ NetbufCopy (Packet, Offset + sizeof (UINT8), sizeof (UINT8), &Length); - -- ASSERT (Length != 0); -+ ASSERT (Length != 0); - -- Offset += (UINT32) Length * 8; -- break; -+ Offset += (UINT32)Length * 8; -+ break; - } - } - -@@ -2382,31 +2393,31 @@ Exit: - **/ - EFI_STATUS - Ip6ProcessRedirect ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IP6_HEADER *Head, -- IN NET_BUF *Packet -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IP6_HEADER *Head, -+ IN NET_BUF *Packet - ) - { -- IP6_ICMP_INFORMATION_HEAD *Icmp; -- EFI_IPv6_ADDRESS *Target; -- EFI_IPv6_ADDRESS *IcmpDest; -- UINT8 *Option; -- UINT16 OptionLen; -- IP6_ROUTE_ENTRY *RouteEntry; -- IP6_ROUTE_CACHE_ENTRY *RouteCache; -- IP6_NEIGHBOR_ENTRY *NeighborCache; -- INT32 Length; -- UINT8 OptLen; -- IP6_ETHER_ADDR_OPTION *LinkLayerOption; -- EFI_MAC_ADDRESS Mac; -- UINT32 Index; -- BOOLEAN IsRouter; -- EFI_STATUS Status; -- INTN Result; -+ IP6_ICMP_INFORMATION_HEAD *Icmp; -+ EFI_IPv6_ADDRESS *Target; -+ EFI_IPv6_ADDRESS *IcmpDest; -+ UINT8 *Option; -+ UINT16 OptionLen; -+ IP6_ROUTE_ENTRY *RouteEntry; -+ IP6_ROUTE_CACHE_ENTRY *RouteCache; -+ IP6_NEIGHBOR_ENTRY *NeighborCache; -+ INT32 Length; -+ UINT8 OptLen; -+ IP6_ETHER_ADDR_OPTION *LinkLayerOption; -+ EFI_MAC_ADDRESS Mac; -+ UINT32 Index; -+ BOOLEAN IsRouter; -+ EFI_STATUS Status; -+ INTN Result; - - Status = EFI_INVALID_PARAMETER; - -- Icmp = (IP6_ICMP_INFORMATION_HEAD *) NetbufGetByte (Packet, 0, NULL); -+ Icmp = (IP6_ICMP_INFORMATION_HEAD *)NetbufGetByte (Packet, 0, NULL); - if (Icmp == NULL) { - goto Exit; - } -@@ -2421,8 +2432,9 @@ Ip6ProcessRedirect ( - // ICMP Code is 0. - // ICMP length (derived from the IP length) is 40 or more octets. - // -- if (Head->HopLimit != IP6_HOP_LIMIT || Icmp->Head.Code != 0 || -- Head->PayloadLength < IP6_REDITECT_LENGTH) { -+ if ((Head->HopLimit != IP6_HOP_LIMIT) || (Icmp->Head.Code != 0) || -+ (Head->PayloadLength < IP6_REDITECT_LENGTH)) -+ { - goto Exit; - } - -@@ -2443,9 +2455,9 @@ Ip6ProcessRedirect ( - // - // All included options have a length that is greater than zero. - // -- OptionLen = (UINT16) (Head->PayloadLength - IP6_REDITECT_LENGTH); -+ OptionLen = (UINT16)(Head->PayloadLength - IP6_REDITECT_LENGTH); - if (OptionLen != 0) { -- Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL); -+ Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL); - ASSERT (Option != NULL); - - if (!Ip6IsNDOptionValid (Option, OptionLen)) { -@@ -2453,7 +2465,7 @@ Ip6ProcessRedirect ( - } - } - -- Target = (EFI_IPv6_ADDRESS *) (Icmp + 1); -+ Target = (EFI_IPv6_ADDRESS *)(Icmp + 1); - IcmpDest = Target + 1; - - // -@@ -2479,32 +2491,34 @@ Ip6ProcessRedirect ( - // address option. - // - Length = Packet->TotalSize - 40; -- Option = (UINT8 *) (IcmpDest + 1); -+ Option = (UINT8 *)(IcmpDest + 1); - LinkLayerOption = NULL; - while (Length > 0) { - switch (*Option) { -- case Ip6OptionEtherTarget: -+ case Ip6OptionEtherTarget: - -- LinkLayerOption = (IP6_ETHER_ADDR_OPTION *) Option; -- OptLen = LinkLayerOption->Length; -- if (OptLen != 1) { -- // -- // For ethernet, the length must be 1. -- // -- goto Exit; -- } -- break; -+ LinkLayerOption = (IP6_ETHER_ADDR_OPTION *)Option; -+ OptLen = LinkLayerOption->Length; -+ if (OptLen != 1) { -+ // -+ // For ethernet, the length must be 1. -+ // -+ goto Exit; -+ } - -- default: -+ break; - -- OptLen = *(Option + 1); -- if (OptLen == 0) { -- // -- // A length of 0 is invalid. -- // -- goto Exit; -- } -- break; -+ default: -+ -+ OptLen = *(Option + 1); -+ if (OptLen == 0) { -+ // -+ // A length of 0 is invalid. -+ // -+ goto Exit; -+ } -+ -+ break; - } - - Length -= 8 * OptLen; -@@ -2535,10 +2549,9 @@ Ip6ProcessRedirect ( - IP6_COPY_ADDRESS (&RouteCache->NextHop, Target); - - if (!IsRouter) { -- RouteEntry = (IP6_ROUTE_ENTRY *) RouteCache->Tag; -+ RouteEntry = (IP6_ROUTE_ENTRY *)RouteCache->Tag; - RouteEntry->Flag = RouteEntry->Flag | IP6_DIRECT_ROUTE; - } -- - } else { - // - // Get the Route Entry. -@@ -2563,7 +2576,7 @@ Ip6ProcessRedirect ( - IcmpDest, - &Head->DestinationAddress, - Target, -- (UINTN) RouteEntry -+ (UINTN)RouteEntry - ); - if (RouteCache == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -2600,7 +2613,7 @@ Ip6ProcessRedirect ( - } - - NeighborCache->State = EfiNeighborStale; -- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - } else { - Result = CompareMem (LinkLayerOption->EtherAddr, &NeighborCache->LinkAddress, 6); - -@@ -2612,14 +2625,14 @@ Ip6ProcessRedirect ( - if ((NeighborCache->State == EfiNeighborInComplete) || (Result != 0)) { - CopyMem (&NeighborCache->LinkAddress, LinkLayerOption->EtherAddr, 6); - -- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - - if (NeighborCache->State == EfiNeighborInComplete) { - // - // Send queued packets if exist. - // - NeighborCache->State = EfiNeighborStale; -- NeighborCache->CallBack ((VOID *) NeighborCache); -+ NeighborCache->CallBack ((VOID *)NeighborCache); - } else { - NeighborCache->State = EfiNeighborStale; - } -@@ -2627,7 +2640,7 @@ Ip6ProcessRedirect ( - } - } - -- if (NeighborCache != NULL && IsRouter) { -+ if ((NeighborCache != NULL) && IsRouter) { - // - // The Target is a router, set IsRouter to TRUE. - // -@@ -2667,14 +2680,14 @@ Exit: - **/ - EFI_STATUS - Ip6AddNeighbor ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -- IN UINT32 Timeout, -- IN BOOLEAN Override -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -+ IN UINT32 Timeout, -+ IN BOOLEAN Override - ) - { -- IP6_NEIGHBOR_ENTRY *Neighbor; -+ IP6_NEIGHBOR_ENTRY *Neighbor; - - Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address); - if (Neighbor != NULL) { -@@ -2702,7 +2715,7 @@ Ip6AddNeighbor ( - Neighbor->Ticks = IP6_GET_TICKS (Timeout / TICKS_PER_MS); - Neighbor->Dynamic = TRUE; - } else { -- Neighbor->Ticks = (UINT32) IP6_INFINIT_LIFETIME; -+ Neighbor->Ticks = (UINT32)IP6_INFINIT_LIFETIME; - } - - return EFI_SUCCESS; -@@ -2729,14 +2742,14 @@ Ip6AddNeighbor ( - **/ - EFI_STATUS - Ip6DelNeighbor ( -- IN IP6_SERVICE *IpSb, -- IN EFI_IPv6_ADDRESS *TargetIp6Address, -- IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -- IN UINT32 Timeout, -- IN BOOLEAN Override -+ IN IP6_SERVICE *IpSb, -+ IN EFI_IPv6_ADDRESS *TargetIp6Address, -+ IN EFI_MAC_ADDRESS *TargetLinkAddress OPTIONAL, -+ IN UINT32 Timeout, -+ IN BOOLEAN Override - ) - { -- IP6_NEIGHBOR_ENTRY *Neighbor; -+ IP6_NEIGHBOR_ENTRY *Neighbor; - - Neighbor = Ip6FindNeighborEntry (IpSb, TargetIp6Address); - if (Neighbor == NULL) { -@@ -2761,24 +2774,24 @@ Ip6DelNeighbor ( - VOID - EFIAPI - Ip6NdFasterTimerTicking ( -- IN EFI_EVENT Event, -- IN VOID *Context -+ IN EFI_EVENT Event, -+ IN VOID *Context - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- LIST_ENTRY *Entry2; -- IP6_INTERFACE *IpIf; -- IP6_DELAY_JOIN_LIST *DelayNode; -- EFI_IPv6_ADDRESS Source; -- IP6_DAD_ENTRY *DupAddrDetect; -- EFI_STATUS Status; -- IP6_NEIGHBOR_ENTRY *NeighborCache; -- EFI_IPv6_ADDRESS Destination; -- IP6_SERVICE *IpSb; -- BOOLEAN Flag; -- -- IpSb = (IP6_SERVICE *) Context; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ LIST_ENTRY *Entry2; -+ IP6_INTERFACE *IpIf; -+ IP6_DELAY_JOIN_LIST *DelayNode; -+ EFI_IPv6_ADDRESS Source; -+ IP6_DAD_ENTRY *DupAddrDetect; -+ EFI_STATUS Status; -+ IP6_NEIGHBOR_ENTRY *NeighborCache; -+ EFI_IPv6_ADDRESS Destination; -+ IP6_SERVICE *IpSb; -+ BOOLEAN Flag; -+ -+ IpSb = (IP6_SERVICE *)Context; - NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); - - ZeroMem (&Source, sizeof (EFI_IPv6_ADDRESS)); -@@ -2790,13 +2803,14 @@ Ip6NdFasterTimerTicking ( - // - if ((IpSb->Ip6ConfigInstance.Policy == Ip6ConfigPolicyAutomatic) && - !IpSb->RouterAdvertiseReceived && -- IpSb->SolicitTimer > 0 -- ) { -+ (IpSb->SolicitTimer > 0) -+ ) -+ { - if ((IpSb->Ticks == 0) || (--IpSb->Ticks == 0)) { - Status = Ip6SendRouterSolicit (IpSb, NULL, NULL, NULL, NULL); - if (!EFI_ERROR (Status)) { - IpSb->SolicitTimer--; -- IpSb->Ticks = (UINT32) IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL); -+ IpSb->Ticks = (UINT32)IP6_GET_TICKS (IP6_RTR_SOLICITATION_INTERVAL); - } - } - } -@@ -2864,7 +2878,8 @@ Ip6NdFasterTimerTicking ( - // - Flag = FALSE; - if ((DupAddrDetect->Receive == 0) || -- (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) { -+ (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) -+ { - Flag = TRUE; - } - -@@ -2881,149 +2896,111 @@ Ip6NdFasterTimerTicking ( - NeighborCache = NET_LIST_USER_STRUCT (Entry, IP6_NEIGHBOR_ENTRY, Link); - - switch (NeighborCache->State) { -- case EfiNeighborInComplete: -- if (NeighborCache->Ticks > 0) { -- --NeighborCache->Ticks; -- } -- -- // -- // Retransmit Neighbor Solicitation messages approximately every -- // RetransTimer milliseconds while awaiting a response. -- // -- if (NeighborCache->Ticks == 0) { -- if (NeighborCache->Transmit > 1) { -- // -- // Send out multicast neighbor solicitation for address resolution. -- // After last neighbor solicitation message has been sent out, wait -- // for RetransTimer and then remove entry if no response is received. -- // -- Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination); -- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source); -- if (EFI_ERROR (Status)) { -- return; -- } -- -- Status = Ip6SendNeighborSolicit ( -- IpSb, -- &Source, -- &Destination, -- &NeighborCache->Neighbor, -- &IpSb->SnpMode.CurrentAddress -- ); -- if (EFI_ERROR (Status)) { -- return; -- } -+ case EfiNeighborInComplete: -+ if (NeighborCache->Ticks > 0) { -+ --NeighborCache->Ticks; - } - - // -- // Update the retransmit times. -+ // Retransmit Neighbor Solicitation messages approximately every -+ // RetransTimer milliseconds while awaiting a response. - // -- if (NeighborCache->Transmit > 0) { -- --NeighborCache->Transmit; -- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -- } -- } -- -- if (NeighborCache->Transmit == 0) { -- // -- // Timeout, send ICMP destination unreachable packet and then remove entry -- // -- Status = Ip6FreeNeighborEntry ( -- IpSb, -- NeighborCache, -- TRUE, -- TRUE, -- EFI_ICMP_ERROR, -- NULL, -- NULL -- ); -- if (EFI_ERROR (Status)) { -- return; -- } -- } -+ if (NeighborCache->Ticks == 0) { -+ if (NeighborCache->Transmit > 1) { -+ // -+ // Send out multicast neighbor solicitation for address resolution. -+ // After last neighbor solicitation message has been sent out, wait -+ // for RetransTimer and then remove entry if no response is received. -+ // -+ Ip6CreateSNMulticastAddr (&NeighborCache->Neighbor, &Destination); -+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source); -+ if (EFI_ERROR (Status)) { -+ return; -+ } - -- break; -+ Status = Ip6SendNeighborSolicit ( -+ IpSb, -+ &Source, -+ &Destination, -+ &NeighborCache->Neighbor, -+ &IpSb->SnpMode.CurrentAddress -+ ); -+ if (EFI_ERROR (Status)) { -+ return; -+ } -+ } - -- case EfiNeighborReachable: -- // -- // This entry is inserted by EfiIp6Neighbors() as static entry -- // and will not timeout. -- // -- if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) { -- break; -- } -+ // -+ // Update the retransmit times. -+ // -+ if (NeighborCache->Transmit > 0) { -+ --NeighborCache->Transmit; -+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -+ } -+ } - -- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) { -- if (NeighborCache->Dynamic) { -+ if (NeighborCache->Transmit == 0) { - // -- // This entry is inserted by EfiIp6Neighbors() as dynamic entry -- // and will be deleted after timeout. -+ // Timeout, send ICMP destination unreachable packet and then remove entry - // - Status = Ip6FreeNeighborEntry ( - IpSb, - NeighborCache, -- FALSE, - TRUE, -- EFI_TIMEOUT, -+ TRUE, -+ EFI_ICMP_ERROR, - NULL, - NULL - ); - if (EFI_ERROR (Status)) { - return; - } -- } else { -- NeighborCache->State = EfiNeighborStale; -- NeighborCache->Ticks = (UINT32) IP6_INFINIT_LIFETIME; - } -- } - -- break; -- -- case EfiNeighborDelay: -- if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) { -+ break; - -- NeighborCache->State = EfiNeighborProbe; -- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -- NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1; -+ case EfiNeighborReachable: - // -- // Send out unicast neighbor solicitation for Neighbor Unreachability Detection -+ // This entry is inserted by EfiIp6Neighbors() as static entry -+ // and will not timeout. - // -- Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source); -- if (EFI_ERROR (Status)) { -- return; -+ if (!NeighborCache->Dynamic && (NeighborCache->Ticks == IP6_INFINIT_LIFETIME)) { -+ break; - } - -- Status = Ip6SendNeighborSolicit ( -- IpSb, -- &Source, -- &NeighborCache->Neighbor, -- &NeighborCache->Neighbor, -- &IpSb->SnpMode.CurrentAddress -- ); -- if (EFI_ERROR (Status)) { -- return; -+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) { -+ if (NeighborCache->Dynamic) { -+ // -+ // This entry is inserted by EfiIp6Neighbors() as dynamic entry -+ // and will be deleted after timeout. -+ // -+ Status = Ip6FreeNeighborEntry ( -+ IpSb, -+ NeighborCache, -+ FALSE, -+ TRUE, -+ EFI_TIMEOUT, -+ NULL, -+ NULL -+ ); -+ if (EFI_ERROR (Status)) { -+ return; -+ } -+ } else { -+ NeighborCache->State = EfiNeighborStale; -+ NeighborCache->Ticks = (UINT32)IP6_INFINIT_LIFETIME; -+ } - } - -- NeighborCache->Transmit--; -- } -- -- break; -- -- case EfiNeighborProbe: -- if (NeighborCache->Ticks > 0) { -- --NeighborCache->Ticks; -- } -+ break; - -- // -- // Retransmit Neighbor Solicitation messages approximately every -- // RetransTimer milliseconds while awaiting a response. -- // -- if (NeighborCache->Ticks == 0) { -- if (NeighborCache->Transmit > 1) { -+ case EfiNeighborDelay: -+ if ((NeighborCache->Ticks == 0) || (--NeighborCache->Ticks == 0)) { -+ NeighborCache->State = EfiNeighborProbe; -+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -+ NeighborCache->Transmit = IP6_MAX_UNICAST_SOLICIT + 1; - // -- // Send out unicast neighbor solicitation for Neighbor Unreachability -- // Detection. After last neighbor solicitation message has been sent out, -- // wait for RetransTimer and then remove entry if no response is received. -+ // Send out unicast neighbor solicitation for Neighbor Unreachability Detection - // - Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source); - if (EFI_ERROR (Status)) { -@@ -3040,39 +3017,76 @@ Ip6NdFasterTimerTicking ( - if (EFI_ERROR (Status)) { - return; - } -+ -+ NeighborCache->Transmit--; - } - -- // -- // Update the retransmit times. -- // -- if (NeighborCache->Transmit > 0) { -- --NeighborCache->Transmit; -- NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -+ break; -+ -+ case EfiNeighborProbe: -+ if (NeighborCache->Ticks > 0) { -+ --NeighborCache->Ticks; - } -- } - -- if (NeighborCache->Transmit == 0) { - // -- // Delete the neighbor entry. -+ // Retransmit Neighbor Solicitation messages approximately every -+ // RetransTimer milliseconds while awaiting a response. - // -- Status = Ip6FreeNeighborEntry ( -- IpSb, -- NeighborCache, -- FALSE, -- TRUE, -- EFI_TIMEOUT, -- NULL, -- NULL -- ); -- if (EFI_ERROR (Status)) { -- return; -+ if (NeighborCache->Ticks == 0) { -+ if (NeighborCache->Transmit > 1) { -+ // -+ // Send out unicast neighbor solicitation for Neighbor Unreachability -+ // Detection. After last neighbor solicitation message has been sent out, -+ // wait for RetransTimer and then remove entry if no response is received. -+ // -+ Status = Ip6SelectSourceAddress (IpSb, &NeighborCache->Neighbor, &Source); -+ if (EFI_ERROR (Status)) { -+ return; -+ } -+ -+ Status = Ip6SendNeighborSolicit ( -+ IpSb, -+ &Source, -+ &NeighborCache->Neighbor, -+ &NeighborCache->Neighbor, -+ &IpSb->SnpMode.CurrentAddress -+ ); -+ if (EFI_ERROR (Status)) { -+ return; -+ } -+ } -+ -+ // -+ // Update the retransmit times. -+ // -+ if (NeighborCache->Transmit > 0) { -+ --NeighborCache->Transmit; -+ NeighborCache->Ticks = IP6_GET_TICKS (IpSb->RetransTimer); -+ } - } -- } - -- break; -+ if (NeighborCache->Transmit == 0) { -+ // -+ // Delete the neighbor entry. -+ // -+ Status = Ip6FreeNeighborEntry ( -+ IpSb, -+ NeighborCache, -+ FALSE, -+ TRUE, -+ EFI_TIMEOUT, -+ NULL, -+ NULL -+ ); -+ if (EFI_ERROR (Status)) { -+ return; -+ } -+ } - -- default: -- break; -+ break; -+ -+ default: -+ break; - } - } - } -@@ -3087,15 +3101,15 @@ Ip6NdFasterTimerTicking ( - **/ - VOID - Ip6NdTimerTicking ( -- IN IP6_SERVICE *IpSb -+ IN IP6_SERVICE *IpSb - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- IP6_DEFAULT_ROUTER *DefaultRouter; -- IP6_PREFIX_LIST_ENTRY *PrefixOption; -- UINT8 Index; -- IP6_ROUTE_CACHE_ENTRY *RouteCache; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ IP6_DEFAULT_ROUTER *DefaultRouter; -+ IP6_PREFIX_LIST_ENTRY *PrefixOption; -+ UINT8 Index; -+ IP6_ROUTE_CACHE_ENTRY *RouteCache; - - // - // Decrease the lifetime of default router, if expires remove it from default router list. -@@ -3114,11 +3128,12 @@ Ip6NdTimerTicking ( - // - NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->AutonomousPrefix) { - PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link); -- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) { -+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) { - if ((PrefixOption->ValidLifetime > 0) && (--PrefixOption->ValidLifetime > 0)) { -- if ((PrefixOption->PreferredLifetime != (UINT32) IP6_INFINIT_LIFETIME) && -+ if ((PrefixOption->PreferredLifetime != (UINT32)IP6_INFINIT_LIFETIME) && - (PrefixOption->PreferredLifetime > 0) -- ) { -+ ) -+ { - --PrefixOption->PreferredLifetime; - } - } else { -@@ -3129,7 +3144,7 @@ Ip6NdTimerTicking ( - - NET_LIST_FOR_EACH_SAFE (Entry, Next, &IpSb->OnlinkPrefix) { - PrefixOption = NET_LIST_USER_STRUCT (Entry, IP6_PREFIX_LIST_ENTRY, Link); -- if (PrefixOption->ValidLifetime != (UINT32) IP6_INFINIT_LIFETIME) { -+ if (PrefixOption->ValidLifetime != (UINT32)IP6_INFINIT_LIFETIME) { - if ((PrefixOption->ValidLifetime == 0) || (--PrefixOption->ValidLifetime == 0)) { - Ip6DestroyPrefixListEntry (IpSb, PrefixOption, TRUE, TRUE); - } -@@ -3156,4 +3171,3 @@ Ip6NdTimerTicking ( - } - } - } -- -diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -index 0f95ce4b71..0428abdda0 100644 ---- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -+++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -@@ -32,8 +32,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - --#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE) --#define DEFAULT_ZERO_START ((UINTN) ~0) -+#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE) -+#define DEFAULT_ZERO_START ((UINTN) ~0) - - // - // All the supported IP4 masks in host byte order. -@@ -77,25 +77,27 @@ GLOBAL_REMOVE_IF_UNREFERENCED IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = { - 0xFFFFFFFF, - }; - --GLOBAL_REMOVE_IF_UNREFERENCED EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}}; -+GLOBAL_REMOVE_IF_UNREFERENCED EFI_IPv4_ADDRESS mZeroIp4Addr = { -+ { 0, 0, 0, 0 } -+}; - - // - // Any error level digitally larger than mNetDebugLevelMax - // will be silently discarded. - // --GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR; --GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogPacketSeq = 0xDEADBEEF; -+GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR; -+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogPacketSeq = 0xDEADBEEF; - - // - // You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp - // here to direct the syslog packets to the syslog deamon. The - // default is broadcast to both the ethernet and IP. - // --GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; --GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogDstIp = 0xffffffff; --GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogSrcIp = 0; -+GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogDstIp = 0xffffffff; -+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogSrcIp = 0; - --GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = { -+GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = { - "Jan", - "Feb", - "Mar", -@@ -113,13 +115,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = { - // - // VLAN device path node template - // --GLOBAL_REMOVE_IF_UNREFERENCED VLAN_DEVICE_PATH mNetVlanDevicePathTemplate = { -+GLOBAL_REMOVE_IF_UNREFERENCED VLAN_DEVICE_PATH mNetVlanDevicePathTemplate = { - { - MESSAGING_DEVICE_PATH, - MSG_VLAN_DP, - { -- (UINT8) (sizeof (VLAN_DEVICE_PATH)), -- (UINT8) ((sizeof (VLAN_DEVICE_PATH)) >> 8) -+ (UINT8)(sizeof (VLAN_DEVICE_PATH)), -+ (UINT8)((sizeof (VLAN_DEVICE_PATH)) >> 8) - } - }, - 0 -@@ -138,11 +140,11 @@ SyslogLocateSnp ( - VOID - ) - { -- EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -- EFI_STATUS Status; -- EFI_HANDLE *Handles; -- UINTN HandleCount; -- UINTN Index; -+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -+ EFI_STATUS Status; -+ EFI_HANDLE *Handles; -+ UINTN HandleCount; -+ UINTN Index; - - // - // Locate the handles which has SNP installed. -@@ -169,13 +171,13 @@ SyslogLocateSnp ( - Status = gBS->HandleProtocol ( - Handles[Index], - &gEfiSimpleNetworkProtocolGuid, -- (VOID **) &Snp -+ (VOID **)&Snp - ); - - if ((Status == EFI_SUCCESS) && (Snp != NULL) && - (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) && -- (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) { -- -+ (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) -+ { - break; - } - -@@ -204,15 +206,15 @@ SyslogLocateSnp ( - **/ - EFI_STATUS - SyslogSendPacket ( -- IN CHAR8 *Packet, -- IN UINT32 Length -+ IN CHAR8 *Packet, -+ IN UINT32 Length - ) - { -- EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -- ETHER_HEAD *Ether; -- EFI_STATUS Status; -- EFI_EVENT TimeoutEvent; -- UINT8 *TxBuf; -+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -+ ETHER_HEAD *Ether; -+ EFI_STATUS Status; -+ EFI_EVENT TimeoutEvent; -+ UINT8 *TxBuf; - - ASSERT (Packet != NULL); - -@@ -222,7 +224,7 @@ SyslogSendPacket ( - return EFI_DEVICE_ERROR; - } - -- Ether = (ETHER_HEAD *) Packet; -+ Ether = (ETHER_HEAD *)Packet; - CopyMem (Ether->SrcMac, Snp->Mode->CurrentAddress.Addr, NET_ETHER_ADDR_LEN); - - // -@@ -246,7 +248,7 @@ SyslogSendPacket ( - goto ON_EXIT; - } - -- for (;;) { -+ for ( ; ;) { - // - // Transmit the packet through SNP. - // -@@ -268,13 +270,12 @@ SyslogSendPacket ( - // - // Get the recycled transmit buffer status. - // -- Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf); -+ Snp->GetStatus (Snp, NULL, (VOID **)&TxBuf); - - if (!EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) { - Status = EFI_TIMEOUT; - break; - } -- - } while (TxBuf == NULL); - - if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) { -@@ -312,71 +313,71 @@ ON_EXIT: - **/ - UINT32 - SyslogBuildPacket ( -- IN UINT32 Level, -- IN UINT8 *Module, -- IN UINT8 *File, -- IN UINT32 Line, -- IN UINT8 *Message, -- IN UINT32 BufLen, -- OUT CHAR8 *Buf -+ IN UINT32 Level, -+ IN UINT8 *Module, -+ IN UINT8 *File, -+ IN UINT32 Line, -+ IN UINT8 *Message, -+ IN UINT32 BufLen, -+ OUT CHAR8 *Buf - ) - { -- EFI_STATUS Status; -- ETHER_HEAD *Ether; -- IP4_HEAD *Ip4; -- EFI_UDP_HEADER *Udp4; -- EFI_TIME Time; -- UINT32 Pri; -- UINT32 Len; -+ EFI_STATUS Status; -+ ETHER_HEAD *Ether; -+ IP4_HEAD *Ip4; -+ EFI_UDP_HEADER *Udp4; -+ EFI_TIME Time; -+ UINT32 Pri; -+ UINT32 Len; - - // - // Fill in the Ethernet header. Leave alone the source MAC. - // SyslogSendPacket will fill in the address for us. - // -- Ether = (ETHER_HEAD *) Buf; -+ Ether = (ETHER_HEAD *)Buf; - CopyMem (Ether->DstMac, mSyslogDstMac, NET_ETHER_ADDR_LEN); - ZeroMem (Ether->SrcMac, NET_ETHER_ADDR_LEN); - - Ether->EtherType = HTONS (0x0800); // IPv4 protocol - -- Buf += sizeof (ETHER_HEAD); -- BufLen -= sizeof (ETHER_HEAD); -+ Buf += sizeof (ETHER_HEAD); -+ BufLen -= sizeof (ETHER_HEAD); - - // - // Fill in the IP header - // -- Ip4 = (IP4_HEAD *) Buf; -- Ip4->HeadLen = 5; -- Ip4->Ver = 4; -- Ip4->Tos = 0; -- Ip4->TotalLen = 0; -- Ip4->Id = (UINT16) mSyslogPacketSeq; -- Ip4->Fragment = 0; -- Ip4->Ttl = 16; -- Ip4->Protocol = 0x11; -- Ip4->Checksum = 0; -- Ip4->Src = mSyslogSrcIp; -- Ip4->Dst = mSyslogDstIp; -+ Ip4 = (IP4_HEAD *)Buf; -+ Ip4->HeadLen = 5; -+ Ip4->Ver = 4; -+ Ip4->Tos = 0; -+ Ip4->TotalLen = 0; -+ Ip4->Id = (UINT16)mSyslogPacketSeq; -+ Ip4->Fragment = 0; -+ Ip4->Ttl = 16; -+ Ip4->Protocol = 0x11; -+ Ip4->Checksum = 0; -+ Ip4->Src = mSyslogSrcIp; -+ Ip4->Dst = mSyslogDstIp; - -- Buf += sizeof (IP4_HEAD); -- BufLen -= sizeof (IP4_HEAD); -+ Buf += sizeof (IP4_HEAD); -+ BufLen -= sizeof (IP4_HEAD); - - // - // Fill in the UDP header, Udp checksum is optional. Leave it zero. - // -- Udp4 = (EFI_UDP_HEADER *) Buf; -- Udp4->SrcPort = HTONS (514); -- Udp4->DstPort = HTONS (514); -- Udp4->Length = 0; -- Udp4->Checksum = 0; -+ Udp4 = (EFI_UDP_HEADER *)Buf; -+ Udp4->SrcPort = HTONS (514); -+ Udp4->DstPort = HTONS (514); -+ Udp4->Length = 0; -+ Udp4->Checksum = 0; - -- Buf += sizeof (EFI_UDP_HEADER); -- BufLen -= sizeof (EFI_UDP_HEADER); -+ Buf += sizeof (EFI_UDP_HEADER); -+ BufLen -= sizeof (EFI_UDP_HEADER); - - // - // Build the syslog message body with Timestamp machine module Message - // -- Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7); -+ Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7); - Status = gRT->GetTime (&Time, NULL); - if (EFI_ERROR (Status)) { - return 0; -@@ -386,38 +387,38 @@ SyslogBuildPacket ( - // Use %a to format the ASCII strings, %s to format UNICODE strings - // - Len = 0; -- Len += (UINT32) AsciiSPrint ( -- Buf, -- BufLen, -- "<%d> %a %d %d:%d:%d ", -- Pri, -- mMonthName [Time.Month-1], -- Time.Day, -- Time.Hour, -- Time.Minute, -- Time.Second -- ); -+ Len += (UINT32)AsciiSPrint ( -+ Buf, -+ BufLen, -+ "<%d> %a %d %d:%d:%d ", -+ Pri, -+ mMonthName[Time.Month-1], -+ Time.Day, -+ Time.Hour, -+ Time.Minute, -+ Time.Second -+ ); - -- Len += (UINT32) AsciiSPrint ( -- Buf + Len, -- BufLen - Len, -- "Tiano %a: %a (Line: %d File: %a)", -- Module, -- Message, -- Line, -- File -- ); -- Len ++; -+ Len += (UINT32)AsciiSPrint ( -+ Buf + Len, -+ BufLen - Len, -+ "Tiano %a: %a (Line: %d File: %a)", -+ Module, -+ Message, -+ Line, -+ File -+ ); -+ Len++; - - // - // OK, patch the IP length/checksum and UDP length fields. - // -- Len += sizeof (EFI_UDP_HEADER); -- Udp4->Length = HTONS ((UINT16) Len); -+ Len += sizeof (EFI_UDP_HEADER); -+ Udp4->Length = HTONS ((UINT16)Len); - -- Len += sizeof (IP4_HEAD); -- Ip4->TotalLen = HTONS ((UINT16) Len); -- Ip4->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Ip4, sizeof (IP4_HEAD))); -+ Len += sizeof (IP4_HEAD); -+ Ip4->TotalLen = HTONS ((UINT16)Len); -+ Ip4->Checksum = (UINT16)(~NetblockChecksum ((UINT8 *)Ip4, sizeof (IP4_HEAD))); - - return Len + sizeof (ETHER_HEAD); - } -@@ -451,16 +452,16 @@ SyslogBuildPacket ( - CHAR8 * - EFIAPI - NetDebugASPrint ( -- IN CHAR8 *Format, -+ IN CHAR8 *Format, - ... - ) - { -- VA_LIST Marker; -- CHAR8 *Buf; -+ VA_LIST Marker; -+ CHAR8 *Buf; - - ASSERT (Format != NULL); - -- Buf = (CHAR8 *) AllocatePool (NET_DEBUG_MSG_LEN); -+ Buf = (CHAR8 *)AllocatePool (NET_DEBUG_MSG_LEN); - - if (Buf == NULL) { - return NULL; -@@ -494,21 +495,21 @@ NetDebugASPrint ( - EFI_STATUS - EFIAPI - NetDebugOutput ( -- IN UINT32 Level, -- IN UINT8 *Module, -- IN UINT8 *File, -- IN UINT32 Line, -- IN UINT8 *Message -+ IN UINT32 Level, -+ IN UINT8 *Module, -+ IN UINT8 *File, -+ IN UINT32 Line, -+ IN UINT8 *Message - ) - { -- CHAR8 *Packet; -- UINT32 Len; -- EFI_STATUS Status; -+ CHAR8 *Packet; -+ UINT32 Len; -+ EFI_STATUS Status; - - // - // Check whether the message should be sent out - // -- if (Message == NULL || File == NULL || Module == NULL) { -+ if ((Message == NULL) || (File == NULL) || (Module == NULL)) { - return EFI_INVALID_PARAMETER; - } - -@@ -522,7 +523,7 @@ NetDebugOutput ( - // that the message plus the ethernet/ip/udp header is shorter - // than this - // -- Packet = (CHAR8 *) AllocatePool (NET_SYSLOG_PACKET_LEN); -+ Packet = (CHAR8 *)AllocatePool (NET_SYSLOG_PACKET_LEN); - - if (Packet == NULL) { - Status = EFI_OUT_OF_RESOURCES; -@@ -554,6 +555,7 @@ ON_EXIT: - FreePool (Message); - return Status; - } -+ - /** - Return the length of the mask. - -@@ -569,10 +571,10 @@ ON_EXIT: - INTN - EFIAPI - NetGetMaskLength ( -- IN IP4_ADDR NetMask -+ IN IP4_ADDR NetMask - ) - { -- INTN Index; -+ INTN Index; - - for (Index = 0; Index <= IP4_MASK_MAX; Index++) { - if (NetMask == gIp4AllMasks[Index]) { -@@ -583,8 +585,6 @@ NetGetMaskLength ( - return Index; - } - -- -- - /** - Return the class of the IP address, such as class A, B, C. - Addr is in host byte order. -@@ -614,32 +614,26 @@ NetGetMaskLength ( - INTN - EFIAPI - NetGetIpClass ( -- IN IP4_ADDR Addr -+ IN IP4_ADDR Addr - ) - { -- UINT8 ByteOne; -+ UINT8 ByteOne; - -- ByteOne = (UINT8) (Addr >> 24); -+ ByteOne = (UINT8)(Addr >> 24); - - if ((ByteOne & 0x80) == 0) { - return IP4_ADDR_CLASSA; -- - } else if ((ByteOne & 0xC0) == 0x80) { - return IP4_ADDR_CLASSB; -- - } else if ((ByteOne & 0xE0) == 0xC0) { - return IP4_ADDR_CLASSC; -- - } else if ((ByteOne & 0xF0) == 0xE0) { - return IP4_ADDR_CLASSD; -- - } else { - return IP4_ADDR_CLASSE; -- - } - } - -- - /** - Check whether the IP is a valid unicast address according to - the netmask. -@@ -660,15 +654,15 @@ NetGetIpClass ( - BOOLEAN - EFIAPI - NetIp4IsUnicast ( -- IN IP4_ADDR Ip, -- IN IP4_ADDR NetMask -+ IN IP4_ADDR Ip, -+ IN IP4_ADDR NetMask - ) - { -- INTN MaskLength; -+ INTN MaskLength; - - ASSERT (NetMask != 0); - -- if (Ip == 0 || IP4_IS_LOCAL_BROADCAST (Ip)) { -+ if ((Ip == 0) || IP4_IS_LOCAL_BROADCAST (Ip)) { - return FALSE; - } - -@@ -702,11 +696,11 @@ NetIp4IsUnicast ( - BOOLEAN - EFIAPI - NetIp6IsValidUnicast ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ) - { -- UINT8 Byte; -- UINT8 Index; -+ UINT8 Byte; -+ UINT8 Index; - - ASSERT (Ip6 != NULL); - -@@ -722,7 +716,7 @@ NetIp6IsValidUnicast ( - - Byte = Ip6->Addr[Index]; - -- if (Byte == 0x0 || Byte == 0x1) { -+ if ((Byte == 0x0) || (Byte == 0x1)) { - return FALSE; - } - -@@ -743,10 +737,10 @@ NetIp6IsValidUnicast ( - BOOLEAN - EFIAPI - NetIp6IsUnspecifiedAddr ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ) - { -- UINT8 Index; -+ UINT8 Index; - - ASSERT (Ip6 != NULL); - -@@ -773,10 +767,10 @@ NetIp6IsUnspecifiedAddr ( - BOOLEAN - EFIAPI - NetIp6IsLinkLocalAddr ( -- IN EFI_IPv6_ADDRESS *Ip6 -+ IN EFI_IPv6_ADDRESS *Ip6 - ) - { -- UINT8 Index; -+ UINT8 Index; - - ASSERT (Ip6 != NULL); - -@@ -814,14 +808,14 @@ NetIp6IsLinkLocalAddr ( - BOOLEAN - EFIAPI - NetIp6IsNetEqual ( -- EFI_IPv6_ADDRESS *Ip1, -- EFI_IPv6_ADDRESS *Ip2, -- UINT8 PrefixLength -+ EFI_IPv6_ADDRESS *Ip1, -+ EFI_IPv6_ADDRESS *Ip2, -+ UINT8 PrefixLength - ) - { -- UINT8 Byte; -- UINT8 Bit; -- UINT8 Mask; -+ UINT8 Byte; -+ UINT8 Bit; -+ UINT8 Mask; - - ASSERT ((Ip1 != NULL) && (Ip2 != NULL) && (PrefixLength < IP6_PREFIX_MAX)); - -@@ -829,20 +823,21 @@ NetIp6IsNetEqual ( - return TRUE; - } - -- Byte = (UINT8) (PrefixLength / 8); -- Bit = (UINT8) (PrefixLength % 8); -+ Byte = (UINT8)(PrefixLength / 8); -+ Bit = (UINT8)(PrefixLength % 8); - - if (CompareMem (Ip1, Ip2, Byte) != 0) { - return FALSE; - } - - if (Bit > 0) { -- Mask = (UINT8) (0xFF << (8 - Bit)); -+ Mask = (UINT8)(0xFF << (8 - Bit)); - - ASSERT (Byte < 16); - if (Byte >= 16) { - return FALSE; - } -+ - if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { - return FALSE; - } -@@ -851,7 +846,6 @@ NetIp6IsNetEqual ( - return TRUE; - } - -- - /** - Switches the endianess of an IPv6 address - -@@ -869,11 +863,11 @@ NetIp6IsNetEqual ( - EFI_IPv6_ADDRESS * - EFIAPI - Ip6Swap128 ( -- EFI_IPv6_ADDRESS *Ip6 -+ EFI_IPv6_ADDRESS *Ip6 - ) - { -- UINT64 High; -- UINT64 Low; -+ UINT64 High; -+ UINT64 Low; - - ASSERT (Ip6 != NULL); - -@@ -905,22 +899,21 @@ NetRandomInitSeed ( - VOID - ) - { -- EFI_TIME Time; -- UINT32 Seed; -- UINT64 MonotonicCount; -+ EFI_TIME Time; -+ UINT32 Seed; -+ UINT64 MonotonicCount; - - gRT->GetTime (&Time, NULL); -- Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); -+ Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); - Seed ^= Time.Nanosecond; - Seed ^= Time.Year << 7; - - gBS->GetNextMonotonicCount (&MonotonicCount); -- Seed += (UINT32) MonotonicCount; -+ Seed += (UINT32)MonotonicCount; - - return Seed; - } - -- - /** - Extract a UINT32 from a byte stream. - -@@ -937,10 +930,10 @@ NetRandomInitSeed ( - UINT32 - EFIAPI - NetGetUint32 ( -- IN UINT8 *Buf -+ IN UINT8 *Buf - ) - { -- UINT32 Value; -+ UINT32 Value; - - ASSERT (Buf != NULL); - -@@ -948,7 +941,6 @@ NetGetUint32 ( - return NTOHL (Value); - } - -- - /** - Put a UINT32 to the byte stream in network byte order. - -@@ -964,8 +956,8 @@ NetGetUint32 ( - VOID - EFIAPI - NetPutUint32 ( -- IN OUT UINT8 *Buf, -- IN UINT32 Data -+ IN OUT UINT8 *Buf, -+ IN UINT32 Data - ) - { - ASSERT (Buf != NULL); -@@ -974,7 +966,6 @@ NetPutUint32 ( - CopyMem (Buf, &Data, sizeof (UINT32)); - } - -- - /** - Remove the first node entry on the list, and return the removed node entry. - -@@ -996,10 +987,10 @@ NetPutUint32 ( - LIST_ENTRY * - EFIAPI - NetListRemoveHead ( -- IN OUT LIST_ENTRY *Head -+ IN OUT LIST_ENTRY *Head - ) - { -- LIST_ENTRY *First; -+ LIST_ENTRY *First; - - ASSERT (Head != NULL); - -@@ -1007,19 +998,18 @@ NetListRemoveHead ( - return NULL; - } - -- First = Head->ForwardLink; -- Head->ForwardLink = First->ForwardLink; -- First->ForwardLink->BackLink = Head; -+ First = Head->ForwardLink; -+ Head->ForwardLink = First->ForwardLink; -+ First->ForwardLink->BackLink = Head; - - DEBUG_CODE ( -- First->ForwardLink = (LIST_ENTRY *) NULL; -- First->BackLink = (LIST_ENTRY *) NULL; -- ); -+ First->ForwardLink = (LIST_ENTRY *)NULL; -+ First->BackLink = (LIST_ENTRY *)NULL; -+ ); - - return First; - } - -- - /** - Remove the last node entry on the list and and return the removed node entry. - -@@ -1041,10 +1031,10 @@ NetListRemoveHead ( - LIST_ENTRY * - EFIAPI - NetListRemoveTail ( -- IN OUT LIST_ENTRY *Head -+ IN OUT LIST_ENTRY *Head - ) - { -- LIST_ENTRY *Last; -+ LIST_ENTRY *Last; - - ASSERT (Head != NULL); - -@@ -1057,14 +1047,13 @@ NetListRemoveTail ( - Last->BackLink->ForwardLink = Head; - - DEBUG_CODE ( -- Last->ForwardLink = (LIST_ENTRY *) NULL; -- Last->BackLink = (LIST_ENTRY *) NULL; -- ); -+ Last->ForwardLink = (LIST_ENTRY *)NULL; -+ Last->BackLink = (LIST_ENTRY *)NULL; -+ ); - - return Last; - } - -- - /** - Insert a new node entry after a designated node entry of a doubly linked list. - -@@ -1080,19 +1069,18 @@ NetListRemoveTail ( - VOID - EFIAPI - NetListInsertAfter ( -- IN OUT LIST_ENTRY *PrevEntry, -- IN OUT LIST_ENTRY *NewEntry -+ IN OUT LIST_ENTRY *PrevEntry, -+ IN OUT LIST_ENTRY *NewEntry - ) - { - ASSERT (PrevEntry != NULL && NewEntry != NULL); - -- NewEntry->BackLink = PrevEntry; -- NewEntry->ForwardLink = PrevEntry->ForwardLink; -- PrevEntry->ForwardLink->BackLink = NewEntry; -- PrevEntry->ForwardLink = NewEntry; -+ NewEntry->BackLink = PrevEntry; -+ NewEntry->ForwardLink = PrevEntry->ForwardLink; -+ PrevEntry->ForwardLink->BackLink = NewEntry; -+ PrevEntry->ForwardLink = NewEntry; - } - -- - /** - Insert a new node entry before a designated node entry of a doubly linked list. - -@@ -1108,16 +1096,16 @@ NetListInsertAfter ( - VOID - EFIAPI - NetListInsertBefore ( -- IN OUT LIST_ENTRY *PostEntry, -- IN OUT LIST_ENTRY *NewEntry -+ IN OUT LIST_ENTRY *PostEntry, -+ IN OUT LIST_ENTRY *NewEntry - ) - { - ASSERT (PostEntry != NULL && NewEntry != NULL); - -- NewEntry->ForwardLink = PostEntry; -- NewEntry->BackLink = PostEntry->BackLink; -- PostEntry->BackLink->ForwardLink = NewEntry; -- PostEntry->BackLink = NewEntry; -+ NewEntry->ForwardLink = PostEntry; -+ NewEntry->BackLink = PostEntry->BackLink; -+ PostEntry->BackLink->ForwardLink = NewEntry; -+ PostEntry->BackLink = NewEntry; - } - - /** -@@ -1151,25 +1139,26 @@ NetDestroyLinkList ( - OUT UINTN *ListLength OPTIONAL - ) - { -- UINTN PreviousLength; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Ptr; -- UINTN Length; -- EFI_STATUS Status; -+ UINTN PreviousLength; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Ptr; -+ UINTN Length; -+ EFI_STATUS Status; - -- if (List == NULL || CallBack == NULL) { -+ if ((List == NULL) || (CallBack == NULL)) { - return EFI_INVALID_PARAMETER; - } - - Length = 0; - do { - PreviousLength = Length; -- Entry = GetFirstNode (List); -+ Entry = GetFirstNode (List); - while (!IsNull (List, Entry)) { - Status = CallBack (Entry, Context); - if (EFI_ERROR (Status)) { - return Status; - } -+ - // - // Walk through the list to see whether the Entry has been removed or not. - // If the Entry still exists, just try to destroy the next one. -@@ -1180,18 +1169,22 @@ NetDestroyLinkList ( - break; - } - } -+ - if (Ptr == Entry) { - Entry = GetNextNode (List, Entry); - } else { - Entry = GetFirstNode (List); - } - } -- for (Length = 0, Ptr = List->ForwardLink; Ptr != List; Length++, Ptr = Ptr->ForwardLink); -+ -+ for (Length = 0, Ptr = List->ForwardLink; Ptr != List; Length++, Ptr = Ptr->ForwardLink) { -+ } - } while (Length != PreviousLength); - - if (ListLength != NULL) { - *ListLength = Length; - } -+ - return EFI_SUCCESS; - } - -@@ -1210,14 +1203,14 @@ NetDestroyLinkList ( - BOOLEAN - EFIAPI - NetIsInHandleBuffer ( -- IN EFI_HANDLE Handle, -- IN UINTN NumberOfChildren, -- IN EFI_HANDLE *ChildHandleBuffer OPTIONAL -+ IN EFI_HANDLE Handle, -+ IN UINTN NumberOfChildren, -+ IN EFI_HANDLE *ChildHandleBuffer OPTIONAL - ) - { -- UINTN Index; -+ UINTN Index; - -- if (NumberOfChildren == 0 || ChildHandleBuffer == NULL) { -+ if ((NumberOfChildren == 0) || (ChildHandleBuffer == NULL)) { - return FALSE; - } - -@@ -1230,7 +1223,6 @@ NetIsInHandleBuffer ( - return FALSE; - } - -- - /** - Initialize the netmap. Netmap is a reposity to keep the pairs. - -@@ -1248,7 +1240,7 @@ NetIsInHandleBuffer ( - VOID - EFIAPI - NetMapInit ( -- IN OUT NET_MAP *Map -+ IN OUT NET_MAP *Map - ) - { - ASSERT (Map != NULL); -@@ -1258,7 +1250,6 @@ NetMapInit ( - Map->Count = 0; - } - -- - /** - To clean up the netmap, that is, release allocated memories. - -@@ -1274,12 +1265,12 @@ NetMapInit ( - VOID - EFIAPI - NetMapClean ( -- IN OUT NET_MAP *Map -+ IN OUT NET_MAP *Map - ) - { -- NET_MAP_ITEM *Item; -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -+ NET_MAP_ITEM *Item; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; - - ASSERT (Map != NULL); - -@@ -1304,7 +1295,6 @@ NetMapClean ( - ASSERT (IsListEmpty (&Map->Recycled)); - } - -- - /** - Test whether the netmap is empty and return true if it is. - -@@ -1320,14 +1310,13 @@ NetMapClean ( - BOOLEAN - EFIAPI - NetMapIsEmpty ( -- IN NET_MAP *Map -+ IN NET_MAP *Map - ) - { - ASSERT (Map != NULL); -- return (BOOLEAN) (Map->Count == 0); -+ return (BOOLEAN)(Map->Count == 0); - } - -- - /** - Return the number of the pairs in the netmap. - -@@ -1341,14 +1330,13 @@ NetMapIsEmpty ( - UINTN - EFIAPI - NetMapGetCount ( -- IN NET_MAP *Map -+ IN NET_MAP *Map - ) - { - ASSERT (Map != NULL); - return Map->Count; - } - -- - /** - Return one allocated item. - -@@ -1367,12 +1355,12 @@ NetMapGetCount ( - **/ - NET_MAP_ITEM * - NetMapAllocItem ( -- IN OUT NET_MAP *Map -+ IN OUT NET_MAP *Map - ) - { -- NET_MAP_ITEM *Item; -- LIST_ENTRY *Head; -- UINTN Index; -+ NET_MAP_ITEM *Item; -+ LIST_ENTRY *Head; -+ UINTN Index; - - ASSERT (Map != NULL); - -@@ -1400,7 +1388,6 @@ NetMapAllocItem ( - return Item; - } - -- - /** - Allocate an item to save the pair to the head of the netmap. - -@@ -1422,12 +1409,12 @@ NetMapAllocItem ( - EFI_STATUS - EFIAPI - NetMapInsertHead ( -- IN OUT NET_MAP *Map, -- IN VOID *Key, -- IN VOID *Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN VOID *Key, -+ IN VOID *Value OPTIONAL - ) - { -- NET_MAP_ITEM *Item; -+ NET_MAP_ITEM *Item; - - ASSERT (Map != NULL && Key != NULL); - -@@ -1445,7 +1432,6 @@ NetMapInsertHead ( - return EFI_SUCCESS; - } - -- - /** - Allocate an item to save the pair to the tail of the netmap. - -@@ -1467,12 +1453,12 @@ NetMapInsertHead ( - EFI_STATUS - EFIAPI - NetMapInsertTail ( -- IN OUT NET_MAP *Map, -- IN VOID *Key, -- IN VOID *Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN VOID *Key, -+ IN VOID *Value OPTIONAL - ) - { -- NET_MAP_ITEM *Item; -+ NET_MAP_ITEM *Item; - - ASSERT (Map != NULL && Key != NULL); - -@@ -1491,7 +1477,6 @@ NetMapInsertTail ( - return EFI_SUCCESS; - } - -- - /** - Check whether the item is in the Map and return TRUE if it is. - -@@ -1506,11 +1491,11 @@ NetMapInsertTail ( - **/ - BOOLEAN - NetItemInMap ( -- IN NET_MAP *Map, -- IN NET_MAP_ITEM *Item -+ IN NET_MAP *Map, -+ IN NET_MAP_ITEM *Item - ) - { -- LIST_ENTRY *ListEntry; -+ LIST_ENTRY *ListEntry; - - ASSERT (Map != NULL && Item != NULL); - -@@ -1523,7 +1508,6 @@ NetItemInMap ( - return FALSE; - } - -- - /** - Find the key in the netmap and returns the point to the item contains the Key. - -@@ -1542,12 +1526,12 @@ NetItemInMap ( - NET_MAP_ITEM * - EFIAPI - NetMapFindKey ( -- IN NET_MAP *Map, -- IN VOID *Key -+ IN NET_MAP *Map, -+ IN VOID *Key - ) - { -- LIST_ENTRY *Entry; -- NET_MAP_ITEM *Item; -+ LIST_ENTRY *Entry; -+ NET_MAP_ITEM *Item; - - ASSERT (Map != NULL && Key != NULL); - -@@ -1562,7 +1546,6 @@ NetMapFindKey ( - return NULL; - } - -- - /** - Remove the node entry of the item from the netmap and return the key of the removed item. - -@@ -1585,9 +1568,9 @@ NetMapFindKey ( - VOID * - EFIAPI - NetMapRemoveItem ( -- IN OUT NET_MAP *Map, -- IN OUT NET_MAP_ITEM *Item, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ IN OUT NET_MAP_ITEM *Item, -+ OUT VOID **Value OPTIONAL - ) - { - ASSERT ((Map != NULL) && (Item != NULL)); -@@ -1604,7 +1587,6 @@ NetMapRemoveItem ( - return Item->Key; - } - -- - /** - Remove the first node entry on the netmap and return the key of the removed item. - -@@ -1625,8 +1607,8 @@ NetMapRemoveItem ( - VOID * - EFIAPI - NetMapRemoveHead ( -- IN OUT NET_MAP *Map, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ OUT VOID **Value OPTIONAL - ) - { - NET_MAP_ITEM *Item; -@@ -1649,7 +1631,6 @@ NetMapRemoveHead ( - return Item->Key; - } - -- - /** - Remove the last node entry on the netmap and return the key of the removed item. - -@@ -1670,11 +1651,11 @@ NetMapRemoveHead ( - VOID * - EFIAPI - NetMapRemoveTail ( -- IN OUT NET_MAP *Map, -- OUT VOID **Value OPTIONAL -+ IN OUT NET_MAP *Map, -+ OUT VOID **Value OPTIONAL - ) - { -- NET_MAP_ITEM *Item; -+ NET_MAP_ITEM *Item; - - // - // Often, it indicates a programming error to remove -@@ -1694,7 +1675,6 @@ NetMapRemoveTail ( - return Item->Key; - } - -- - /** - Iterate through the netmap and call CallBack for each item. - -@@ -1717,17 +1697,16 @@ NetMapRemoveTail ( - EFI_STATUS - EFIAPI - NetMapIterate ( -- IN NET_MAP *Map, -- IN NET_MAP_CALLBACK CallBack, -- IN VOID *Arg OPTIONAL -+ IN NET_MAP *Map, -+ IN NET_MAP_CALLBACK CallBack, -+ IN VOID *Arg OPTIONAL - ) - { -- -- LIST_ENTRY *Entry; -- LIST_ENTRY *Next; -- LIST_ENTRY *Head; -- NET_MAP_ITEM *Item; -- EFI_STATUS Result; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Next; -+ LIST_ENTRY *Head; -+ NET_MAP_ITEM *Item; -+ EFI_STATUS Result; - - ASSERT ((Map != NULL) && (CallBack != NULL)); - -@@ -1749,7 +1728,6 @@ NetMapIterate ( - return EFI_SUCCESS; - } - -- - /** - This is the default unload handle for all the network drivers. - -@@ -1765,17 +1743,17 @@ NetMapIterate ( - EFI_STATUS - EFIAPI - NetLibDefaultUnload ( -- IN EFI_HANDLE ImageHandle -+ IN EFI_HANDLE ImageHandle - ) - { -- EFI_STATUS Status; -- EFI_HANDLE *DeviceHandleBuffer; -- UINTN DeviceHandleCount; -- UINTN Index; -- UINTN Index2; -- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; -- EFI_COMPONENT_NAME_PROTOCOL *ComponentName; -- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; -+ EFI_STATUS Status; -+ EFI_HANDLE *DeviceHandleBuffer; -+ UINTN DeviceHandleCount; -+ UINTN Index; -+ UINTN Index2; -+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; -+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName; -+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; - - // - // Get the list of all the handles in the handle database. -@@ -1798,7 +1776,7 @@ NetLibDefaultUnload ( - Status = gBS->HandleProtocol ( - DeviceHandleBuffer[Index], - &gEfiDriverBindingProtocolGuid, -- (VOID **) &DriverBinding -+ (VOID **)&DriverBinding - ); - if (EFI_ERROR (Status)) { - continue; -@@ -1824,15 +1802,15 @@ NetLibDefaultUnload ( - // Uninstall all the protocols installed in the driver entry point - // - gBS->UninstallProtocolInterface ( -- DriverBinding->DriverBindingHandle, -- &gEfiDriverBindingProtocolGuid, -- DriverBinding -- ); -+ DriverBinding->DriverBindingHandle, -+ &gEfiDriverBindingProtocolGuid, -+ DriverBinding -+ ); - - Status = gBS->HandleProtocol ( - DeviceHandleBuffer[Index], - &gEfiComponentNameProtocolGuid, -- (VOID **) &ComponentName -+ (VOID **)&ComponentName - ); - if (!EFI_ERROR (Status)) { - gBS->UninstallProtocolInterface ( -@@ -1845,7 +1823,7 @@ NetLibDefaultUnload ( - Status = gBS->HandleProtocol ( - DeviceHandleBuffer[Index], - &gEfiComponentName2ProtocolGuid, -- (VOID **) &ComponentName2 -+ (VOID **)&ComponentName2 - ); - if (!EFI_ERROR (Status)) { - gBS->UninstallProtocolInterface ( -@@ -1866,8 +1844,6 @@ NetLibDefaultUnload ( - return EFI_SUCCESS; - } - -- -- - /** - Create a child of the service that is identified by ServiceBindingGuid. - -@@ -1888,16 +1864,15 @@ NetLibDefaultUnload ( - EFI_STATUS - EFIAPI - NetLibCreateServiceChild ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE Image, -- IN EFI_GUID *ServiceBindingGuid, -- IN OUT EFI_HANDLE *ChildHandle -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE Image, -+ IN EFI_GUID *ServiceBindingGuid, -+ IN OUT EFI_HANDLE *ChildHandle - ) - { - EFI_STATUS Status; - EFI_SERVICE_BINDING_PROTOCOL *Service; - -- - ASSERT ((ServiceBindingGuid != NULL) && (ChildHandle != NULL)); - - // -@@ -1906,7 +1881,7 @@ NetLibCreateServiceChild ( - Status = gBS->OpenProtocol ( - Controller, - ServiceBindingGuid, -- (VOID **) &Service, -+ (VOID **)&Service, - Image, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1923,7 +1898,6 @@ NetLibCreateServiceChild ( - return Status; - } - -- - /** - Destroy a child of the service that is identified by ServiceBindingGuid. - -@@ -1943,10 +1917,10 @@ NetLibCreateServiceChild ( - EFI_STATUS - EFIAPI - NetLibDestroyServiceChild ( -- IN EFI_HANDLE Controller, -- IN EFI_HANDLE Image, -- IN EFI_GUID *ServiceBindingGuid, -- IN EFI_HANDLE ChildHandle -+ IN EFI_HANDLE Controller, -+ IN EFI_HANDLE Image, -+ IN EFI_GUID *ServiceBindingGuid, -+ IN EFI_HANDLE ChildHandle - ) - { - EFI_STATUS Status; -@@ -1960,7 +1934,7 @@ NetLibDestroyServiceChild ( - Status = gBS->OpenProtocol ( - Controller, - ServiceBindingGuid, -- (VOID **) &Service, -+ (VOID **)&Service, - Image, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1996,8 +1970,8 @@ NetLibDestroyServiceChild ( - EFI_HANDLE - EFIAPI - NetLibGetSnpHandle ( -- IN EFI_HANDLE ServiceHandle, -- OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL -+ IN EFI_HANDLE ServiceHandle, -+ OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL - ) - { - EFI_STATUS Status; -@@ -2009,11 +1983,12 @@ NetLibGetSnpHandle ( - // Try to open SNP from ServiceHandle - // - SnpInstance = NULL; -- Status = gBS->HandleProtocol (ServiceHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &SnpInstance); -+ Status = gBS->HandleProtocol (ServiceHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance); - if (!EFI_ERROR (Status)) { - if (Snp != NULL) { - *Snp = SnpInstance; - } -+ - return ServiceHandle; - } - -@@ -2026,7 +2001,7 @@ NetLibGetSnpHandle ( - } - - SnpHandle = NULL; -- Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &DevicePath, &SnpHandle); -+ Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &DevicePath, &SnpHandle); - if (EFI_ERROR (Status)) { - // - // Failed to find SNP handle -@@ -2034,11 +2009,12 @@ NetLibGetSnpHandle ( - return NULL; - } - -- Status = gBS->HandleProtocol (SnpHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &SnpInstance); -+ Status = gBS->HandleProtocol (SnpHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance); - if (!EFI_ERROR (Status)) { - if (Snp != NULL) { - *Snp = SnpInstance; - } -+ - return SnpHandle; - } - -@@ -2061,7 +2037,7 @@ NetLibGetSnpHandle ( - UINT16 - EFIAPI - NetLibGetVlanId ( -- IN EFI_HANDLE ServiceHandle -+ IN EFI_HANDLE ServiceHandle - ) - { - EFI_DEVICE_PATH_PROTOCOL *DevicePath; -@@ -2074,9 +2050,10 @@ NetLibGetVlanId ( - - Node = DevicePath; - while (!IsDevicePathEnd (Node)) { -- if (Node->Type == MESSAGING_DEVICE_PATH && Node->SubType == MSG_VLAN_DP) { -- return ((VLAN_DEVICE_PATH *) Node)->VlanId; -+ if ((Node->Type == MESSAGING_DEVICE_PATH) && (Node->SubType == MSG_VLAN_DP)) { -+ return ((VLAN_DEVICE_PATH *)Node)->VlanId; - } -+ - Node = NextDevicePathNode (Node); - } - -@@ -2100,8 +2077,8 @@ NetLibGetVlanId ( - EFI_HANDLE - EFIAPI - NetLibGetVlanHandle ( -- IN EFI_HANDLE ControllerHandle, -- IN UINT16 VlanId -+ IN EFI_HANDLE ControllerHandle, -+ IN UINT16 VlanId - ) - { - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; -@@ -2120,10 +2097,10 @@ NetLibGetVlanHandle ( - // - CopyMem (&VlanNode, &mNetVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH)); - VlanNode.VlanId = VlanId; -- VlanDevicePath = AppendDevicePathNode ( -- ParentDevicePath, -- (EFI_DEVICE_PATH_PROTOCOL *) &VlanNode -- ); -+ VlanDevicePath = AppendDevicePathNode ( -+ ParentDevicePath, -+ (EFI_DEVICE_PATH_PROTOCOL *)&VlanNode -+ ); - if (VlanDevicePath == NULL) { - return NULL; - } -@@ -2131,7 +2108,7 @@ NetLibGetVlanHandle ( - // - // Find VLAN device handle - // -- Handle = NULL; -+ Handle = NULL; - DevicePath = VlanDevicePath; - gBS->LocateDevicePath ( - &gEfiDevicePathProtocolGuid, -@@ -2171,19 +2148,19 @@ NetLibGetVlanHandle ( - EFI_STATUS - EFIAPI - NetLibGetMacAddress ( -- IN EFI_HANDLE ServiceHandle, -- OUT EFI_MAC_ADDRESS *MacAddress, -- OUT UINTN *AddressSize -+ IN EFI_HANDLE ServiceHandle, -+ OUT EFI_MAC_ADDRESS *MacAddress, -+ OUT UINTN *AddressSize - ) - { -- EFI_STATUS Status; -- EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -- EFI_SIMPLE_NETWORK_MODE *SnpMode; -- EFI_SIMPLE_NETWORK_MODE SnpModeData; -- EFI_MANAGED_NETWORK_PROTOCOL *Mnp; -- EFI_SERVICE_BINDING_PROTOCOL *MnpSb; -- EFI_HANDLE SnpHandle; -- EFI_HANDLE MnpChildHandle; -+ EFI_STATUS Status; -+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -+ EFI_SIMPLE_NETWORK_MODE *SnpMode; -+ EFI_SIMPLE_NETWORK_MODE SnpModeData; -+ EFI_MANAGED_NETWORK_PROTOCOL *Mnp; -+ EFI_SERVICE_BINDING_PROTOCOL *MnpSb; -+ EFI_HANDLE SnpHandle; -+ EFI_HANDLE MnpChildHandle; - - ASSERT (MacAddress != NULL); - ASSERT (AddressSize != NULL); -@@ -2191,7 +2168,7 @@ NetLibGetMacAddress ( - // - // Try to get SNP handle - // -- Snp = NULL; -+ Snp = NULL; - SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp); - if (SnpHandle != NULL) { - // -@@ -2203,11 +2180,11 @@ NetLibGetMacAddress ( - // Failed to get SNP handle, try to get MAC address from MNP - // - MnpChildHandle = NULL; -- Status = gBS->HandleProtocol ( -- ServiceHandle, -- &gEfiManagedNetworkServiceBindingProtocolGuid, -- (VOID **) &MnpSb -- ); -+ Status = gBS->HandleProtocol ( -+ ServiceHandle, -+ &gEfiManagedNetworkServiceBindingProtocolGuid, -+ (VOID **)&MnpSb -+ ); - if (EFI_ERROR (Status)) { - return Status; - } -@@ -2226,7 +2203,7 @@ NetLibGetMacAddress ( - Status = gBS->HandleProtocol ( - MnpChildHandle, - &gEfiManagedNetworkProtocolGuid, -- (VOID **) &Mnp -+ (VOID **)&Mnp - ); - if (EFI_ERROR (Status)) { - MnpSb->DestroyChild (MnpSb, MnpChildHandle); -@@ -2241,6 +2218,7 @@ NetLibGetMacAddress ( - MnpSb->DestroyChild (MnpSb, MnpChildHandle); - return Status; - } -+ - SnpMode = &SnpModeData; - - // -@@ -2287,14 +2265,14 @@ NetLibGetMacString ( - OUT CHAR16 **MacString - ) - { -- EFI_STATUS Status; -- EFI_MAC_ADDRESS MacAddress; -- UINT8 *HwAddress; -- UINTN HwAddressSize; -- UINT16 VlanId; -- CHAR16 *String; -- UINTN Index; -- UINTN BufferSize; -+ EFI_STATUS Status; -+ EFI_MAC_ADDRESS MacAddress; -+ UINT8 *HwAddress; -+ UINTN HwAddressSize; -+ UINT16 VlanId; -+ CHAR16 *String; -+ UINTN Index; -+ UINTN BufferSize; - - ASSERT (MacString != NULL); - -@@ -2312,10 +2290,11 @@ NetLibGetMacString ( - // Plus one unicode character for the null-terminator. - // - BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16); -- String = AllocateZeroPool (BufferSize); -+ String = AllocateZeroPool (BufferSize); - if (String == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - *MacString = String; - - // -@@ -2390,8 +2369,8 @@ NetLibGetMacString ( - EFI_STATUS - EFIAPI - NetLibDetectMedia ( -- IN EFI_HANDLE ServiceHandle, -- OUT BOOLEAN *MediaPresent -+ IN EFI_HANDLE ServiceHandle, -+ OUT BOOLEAN *MediaPresent - ) - { - EFI_STATUS Status; -@@ -2410,7 +2389,7 @@ NetLibDetectMedia ( - // - // Get SNP handle - // -- Snp = NULL; -+ Snp = NULL; - SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp); - if (SnpHandle == NULL) { - return EFI_INVALID_PARAMETER; -@@ -2485,6 +2464,7 @@ NetLibDetectMedia ( - if (!EFI_ERROR (Status)) { - Status = Snp->Stop (Snp); - } -+ - if (EFI_ERROR (Status)) { - goto Exit; - } -@@ -2496,6 +2476,7 @@ NetLibDetectMedia ( - if (!EFI_ERROR (Status)) { - Status = Snp->Initialize (Snp, 0, 0); - } -+ - if (EFI_ERROR (Status)) { - goto Exit; - } -@@ -2599,9 +2580,9 @@ Exit: - EFI_STATUS - EFIAPI - NetLibDetectMediaWaitTimeout ( -- IN EFI_HANDLE ServiceHandle, -- IN UINT64 Timeout, -- OUT EFI_STATUS *MediaState -+ IN EFI_HANDLE ServiceHandle, -+ IN UINT64 Timeout, -+ OUT EFI_STATUS *MediaState - ) - { - EFI_STATUS Status; -@@ -2618,13 +2599,14 @@ NetLibDetectMediaWaitTimeout ( - if (MediaState == NULL) { - return EFI_INVALID_PARAMETER; - } -+ - *MediaState = EFI_SUCCESS; - MediaInfo = NULL; - - // - // Get SNP handle - // -- Snp = NULL; -+ Snp = NULL; - SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp); - if (SnpHandle == NULL) { - return EFI_INVALID_PARAMETER; -@@ -2633,12 +2615,11 @@ NetLibDetectMediaWaitTimeout ( - Status = gBS->HandleProtocol ( - SnpHandle, - &gEfiAdapterInformationProtocolGuid, -- (VOID *) &Aip -+ (VOID *)&Aip - ); - if (EFI_ERROR (Status)) { -- - MediaPresent = TRUE; -- Status = NetLibDetectMedia (ServiceHandle, &MediaPresent); -+ Status = NetLibDetectMedia (ServiceHandle, &MediaPresent); - if (!EFI_ERROR (Status)) { - if (MediaPresent) { - *MediaState = EFI_SUCCESS; -@@ -2656,30 +2637,26 @@ NetLibDetectMediaWaitTimeout ( - Status = Aip->GetInformation ( - Aip, - &gEfiAdapterInfoMediaStateGuid, -- (VOID **) &MediaInfo, -+ (VOID **)&MediaInfo, - &DataSize - ); - if (!EFI_ERROR (Status)) { -- - *MediaState = MediaInfo->MediaState; - FreePool (MediaInfo); -- if (*MediaState != EFI_NOT_READY || Timeout < MEDIA_STATE_DETECT_TIME_INTERVAL) { -- -+ if ((*MediaState != EFI_NOT_READY) || (Timeout < MEDIA_STATE_DETECT_TIME_INTERVAL)) { - return EFI_SUCCESS; - } - } else { -- - if (MediaInfo != NULL) { - FreePool (MediaInfo); - } - - if (Status == EFI_UNSUPPORTED) { -- - // - // If gEfiAdapterInfoMediaStateGuid is not supported, call NetLibDetectMedia to get media state! - // - MediaPresent = TRUE; -- Status = NetLibDetectMedia (ServiceHandle, &MediaPresent); -+ Status = NetLibDetectMedia (ServiceHandle, &MediaPresent); - if (!EFI_ERROR (Status)) { - if (MediaPresent) { - *MediaState = EFI_SUCCESS; -@@ -2687,6 +2664,7 @@ NetLibDetectMediaWaitTimeout ( - *MediaState = EFI_NO_MEDIA; - } - } -+ - return Status; - } - -@@ -2699,7 +2677,7 @@ NetLibDetectMediaWaitTimeout ( - - Timer = NULL; - TimeRemained = Timeout; -- Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer); -+ Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer); - if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; - } -@@ -2711,39 +2689,37 @@ NetLibDetectMediaWaitTimeout ( - MEDIA_STATE_DETECT_TIME_INTERVAL - ); - if (EFI_ERROR (Status)) { -- gBS->CloseEvent(Timer); -+ gBS->CloseEvent (Timer); - return EFI_DEVICE_ERROR; - } - - do { - TimerStatus = gBS->CheckEvent (Timer); - if (!EFI_ERROR (TimerStatus)) { -- - TimeRemained -= MEDIA_STATE_DETECT_TIME_INTERVAL; -- Status = Aip->GetInformation ( -- Aip, -- &gEfiAdapterInfoMediaStateGuid, -- (VOID **) &MediaInfo, -- &DataSize -- ); -+ Status = Aip->GetInformation ( -+ Aip, -+ &gEfiAdapterInfoMediaStateGuid, -+ (VOID **)&MediaInfo, -+ &DataSize -+ ); - if (!EFI_ERROR (Status)) { -- - *MediaState = MediaInfo->MediaState; - FreePool (MediaInfo); - } else { -- - if (MediaInfo != NULL) { - FreePool (MediaInfo); - } -- gBS->CloseEvent(Timer); -+ -+ gBS->CloseEvent (Timer); - return Status; - } - } - } while (TimerStatus == EFI_NOT_READY); - } while (*MediaState == EFI_NOT_READY && TimeRemained >= MEDIA_STATE_DETECT_TIME_INTERVAL); - -- gBS->CloseEvent(Timer); -- if (*MediaState == EFI_NOT_READY && TimeRemained < MEDIA_STATE_DETECT_TIME_INTERVAL) { -+ gBS->CloseEvent (Timer); -+ if ((*MediaState == EFI_NOT_READY) && (TimeRemained < MEDIA_STATE_DETECT_TIME_INTERVAL)) { - return EFI_TIMEOUT; - } else { - return EFI_SUCCESS; -@@ -2770,22 +2746,22 @@ NetLibDefaultAddressIsStatic ( - IN EFI_HANDLE Controller - ) - { -- EFI_STATUS Status; -- EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; -- UINTN DataSize; -- EFI_IP4_CONFIG2_POLICY Policy; -- BOOLEAN IsStatic; -+ EFI_STATUS Status; -+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; -+ UINTN DataSize; -+ EFI_IP4_CONFIG2_POLICY Policy; -+ BOOLEAN IsStatic; - - Ip4Config2 = NULL; - - DataSize = sizeof (EFI_IP4_CONFIG2_POLICY); - -- IsStatic = TRUE; -+ IsStatic = TRUE; - - // - // Get Ip4Config2 policy. - // -- Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); -+ Status = gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2); - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } -@@ -2795,7 +2771,7 @@ NetLibDefaultAddressIsStatic ( - goto ON_EXIT; - } - -- IsStatic = (BOOLEAN) (Policy == Ip4Config2PolicyStatic); -+ IsStatic = (BOOLEAN)(Policy == Ip4Config2PolicyStatic); - - ON_EXIT: - -@@ -2907,7 +2883,7 @@ NetLibCreateIPv6DPathNode ( - Node->LocalPort = LocalPort; - Node->RemotePort = RemotePort; - -- Node->Protocol = Protocol; -+ Node->Protocol = Protocol; - - // - // Set default value to IPAddressOrigin, PrefixLength. -@@ -2940,15 +2916,15 @@ NetLibCreateIPv6DPathNode ( - EFI_HANDLE - EFIAPI - NetLibGetNicHandle ( -- IN EFI_HANDLE Controller, -- IN EFI_GUID *ProtocolGuid -+ IN EFI_HANDLE Controller, -+ IN EFI_GUID *ProtocolGuid - ) - { -- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenBuffer; -- EFI_HANDLE Handle; -- EFI_STATUS Status; -- UINTN OpenCount; -- UINTN Index; -+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenBuffer; -+ EFI_HANDLE Handle; -+ EFI_STATUS Status; -+ UINTN OpenCount; -+ UINTN Index; - - ASSERT (ProtocolGuid != NULL); - -@@ -2989,12 +2965,12 @@ NetLibGetNicHandle ( - EFI_STATUS - EFIAPI - NetLibAsciiStrToIp4 ( -- IN CONST CHAR8 *String, -- OUT EFI_IPv4_ADDRESS *Ip4Address -+ IN CONST CHAR8 *String, -+ OUT EFI_IPv4_ADDRESS *Ip4Address - ) - { -- RETURN_STATUS Status; -- CHAR8 *EndPointer; -+ RETURN_STATUS Status; -+ CHAR8 *EndPointer; - - Status = AsciiStrToIpv4Address (String, &EndPointer, Ip4Address, NULL); - if (RETURN_ERROR (Status) || (*EndPointer != '\0')) { -@@ -3004,7 +2980,6 @@ NetLibAsciiStrToIp4 ( - } - } - -- - /** - Convert one Null-terminated ASCII string to EFI_IPv6_ADDRESS. The format of the - string is defined in RFC 4291 - Text Representation of Addresses. -@@ -3019,12 +2994,12 @@ NetLibAsciiStrToIp4 ( - EFI_STATUS - EFIAPI - NetLibAsciiStrToIp6 ( -- IN CONST CHAR8 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address -+ IN CONST CHAR8 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address - ) - { -- RETURN_STATUS Status; -- CHAR8 *EndPointer; -+ RETURN_STATUS Status; -+ CHAR8 *EndPointer; - - Status = AsciiStrToIpv6Address (String, &EndPointer, Ip6Address, NULL); - if (RETURN_ERROR (Status) || (*EndPointer != '\0')) { -@@ -3034,7 +3009,6 @@ NetLibAsciiStrToIp6 ( - } - } - -- - /** - Convert one Null-terminated Unicode string (decimal dotted) to EFI_IPv4_ADDRESS. - -@@ -3048,12 +3022,12 @@ NetLibAsciiStrToIp6 ( - EFI_STATUS - EFIAPI - NetLibStrToIp4 ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv4_ADDRESS *Ip4Address -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv4_ADDRESS *Ip4Address - ) - { -- RETURN_STATUS Status; -- CHAR16 *EndPointer; -+ RETURN_STATUS Status; -+ CHAR16 *EndPointer; - - Status = StrToIpv4Address (String, &EndPointer, Ip4Address, NULL); - if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) { -@@ -3063,7 +3037,6 @@ NetLibStrToIp4 ( - } - } - -- - /** - Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS. The format of - the string is defined in RFC 4291 - Text Representation of Addresses. -@@ -3078,12 +3051,12 @@ NetLibStrToIp4 ( - EFI_STATUS - EFIAPI - NetLibStrToIp6 ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address - ) - { -- RETURN_STATUS Status; -- CHAR16 *EndPointer; -+ RETURN_STATUS Status; -+ CHAR16 *EndPointer; - - Status = StrToIpv6Address (String, &EndPointer, Ip6Address, NULL); - if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) { -@@ -3109,13 +3082,13 @@ NetLibStrToIp6 ( - EFI_STATUS - EFIAPI - NetLibStrToIp6andPrefix ( -- IN CONST CHAR16 *String, -- OUT EFI_IPv6_ADDRESS *Ip6Address, -- OUT UINT8 *PrefixLength -+ IN CONST CHAR16 *String, -+ OUT EFI_IPv6_ADDRESS *Ip6Address, -+ OUT UINT8 *PrefixLength - ) - { -- RETURN_STATUS Status; -- CHAR16 *EndPointer; -+ RETURN_STATUS Status; -+ CHAR16 *EndPointer; - - Status = StrToIpv6Address (String, &EndPointer, Ip6Address, PrefixLength); - if (RETURN_ERROR (Status) || (*EndPointer != L'\0')) { -@@ -3142,21 +3115,21 @@ NetLibStrToIp6andPrefix ( - EFI_STATUS - EFIAPI - NetLibIp6ToStr ( -- IN EFI_IPv6_ADDRESS *Ip6Address, -- OUT CHAR16 *String, -- IN UINTN StringSize -+ IN EFI_IPv6_ADDRESS *Ip6Address, -+ OUT CHAR16 *String, -+ IN UINTN StringSize - ) - { -- UINT16 Ip6Addr[8]; -- UINTN Index; -- UINTN LongestZerosStart; -- UINTN LongestZerosLength; -- UINTN CurrentZerosStart; -- UINTN CurrentZerosLength; -- CHAR16 Buffer[sizeof"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; -- CHAR16 *Ptr; -- -- if (Ip6Address == NULL || String == NULL || StringSize == 0) { -+ UINT16 Ip6Addr[8]; -+ UINTN Index; -+ UINTN LongestZerosStart; -+ UINTN LongestZerosLength; -+ UINTN CurrentZerosStart; -+ UINTN CurrentZerosLength; -+ CHAR16 Buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; -+ CHAR16 *Ptr; -+ -+ if ((Ip6Address == NULL) || (String == NULL) || (StringSize == 0)) { - return EFI_INVALID_PARAMETER; - } - -@@ -3178,25 +3151,26 @@ NetLibIp6ToStr ( - for (Index = 0; Index < 8; Index++) { - if (Ip6Addr[Index] == 0) { - if (CurrentZerosStart == DEFAULT_ZERO_START) { -- CurrentZerosStart = Index; -+ CurrentZerosStart = Index; - CurrentZerosLength = 1; - } else { - CurrentZerosLength++; - } - } else { - if (CurrentZerosStart != DEFAULT_ZERO_START) { -- if (CurrentZerosLength > 2 && (LongestZerosStart == (DEFAULT_ZERO_START) || CurrentZerosLength > LongestZerosLength)) { -+ if ((CurrentZerosLength > 2) && ((LongestZerosStart == (DEFAULT_ZERO_START)) || (CurrentZerosLength > LongestZerosLength))) { - LongestZerosStart = CurrentZerosStart; - LongestZerosLength = CurrentZerosLength; - } -+ - CurrentZerosStart = DEFAULT_ZERO_START; - CurrentZerosLength = 0; - } - } - } - -- if (CurrentZerosStart != DEFAULT_ZERO_START && CurrentZerosLength > 2) { -- if (LongestZerosStart == DEFAULT_ZERO_START || LongestZerosLength < CurrentZerosLength) { -+ if ((CurrentZerosStart != DEFAULT_ZERO_START) && (CurrentZerosLength > 2)) { -+ if ((LongestZerosStart == DEFAULT_ZERO_START) || (LongestZerosLength < CurrentZerosLength)) { - LongestZerosStart = CurrentZerosStart; - LongestZerosLength = CurrentZerosLength; - } -@@ -3204,21 +3178,25 @@ NetLibIp6ToStr ( - - Ptr = Buffer; - for (Index = 0; Index < 8; Index++) { -- if (LongestZerosStart != DEFAULT_ZERO_START && Index >= LongestZerosStart && Index < LongestZerosStart + LongestZerosLength) { -+ if ((LongestZerosStart != DEFAULT_ZERO_START) && (Index >= LongestZerosStart) && (Index < LongestZerosStart + LongestZerosLength)) { - if (Index == LongestZerosStart) { - *Ptr++ = L':'; - } -+ - continue; - } -+ - if (Index != 0) { - *Ptr++ = L':'; - } -- Ptr += UnicodeSPrint(Ptr, 10, L"%x", Ip6Addr[Index]); -+ -+ Ptr += UnicodeSPrint (Ptr, 10, L"%x", Ip6Addr[Index]); - } - -- if (LongestZerosStart != DEFAULT_ZERO_START && LongestZerosStart + LongestZerosLength == 8) { -+ if ((LongestZerosStart != DEFAULT_ZERO_START) && (LongestZerosStart + LongestZerosLength == 8)) { - *Ptr++ = L':'; - } -+ - *Ptr = L'\0'; - - if ((UINTN)Ptr - (UINTN)Buffer > StringSize) { -@@ -3244,7 +3222,7 @@ NetLibIp6ToStr ( - EFI_STATUS - EFIAPI - NetLibGetSystemGuid ( -- OUT EFI_GUID *SystemGuid -+ OUT EFI_GUID *SystemGuid - ) - { - EFI_STATUS Status; -@@ -3257,17 +3235,18 @@ NetLibGetSystemGuid ( - ASSERT (SystemGuid != NULL); - - SmbiosTable = NULL; -- Status = EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **) &Smbios30Table); -- if (!(EFI_ERROR (Status) || Smbios30Table == NULL)) { -- Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) Smbios30Table->TableAddress; -- SmbiosEnd.Raw = (UINT8 *) (UINTN) (Smbios30Table->TableAddress + Smbios30Table->TableMaximumSize); -+ Status = EfiGetSystemConfigurationTable (&gEfiSmbios3TableGuid, (VOID **)&Smbios30Table); -+ if (!(EFI_ERROR (Status) || (Smbios30Table == NULL))) { -+ Smbios.Hdr = (SMBIOS_STRUCTURE *)(UINTN)Smbios30Table->TableAddress; -+ SmbiosEnd.Raw = (UINT8 *)(UINTN)(Smbios30Table->TableAddress + Smbios30Table->TableMaximumSize); - } else { -- Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &SmbiosTable); -- if (EFI_ERROR (Status) || SmbiosTable == NULL) { -+ Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **)&SmbiosTable); -+ if (EFI_ERROR (Status) || (SmbiosTable == NULL)) { - return EFI_NOT_FOUND; - } -- Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress; -- SmbiosEnd.Raw = (UINT8 *) ((UINTN) SmbiosTable->TableAddress + SmbiosTable->TableLength); -+ -+ Smbios.Hdr = (SMBIOS_STRUCTURE *)(UINTN)SmbiosTable->TableAddress; -+ SmbiosEnd.Raw = (UINT8 *)((UINTN)SmbiosTable->TableAddress + SmbiosTable->TableLength); - } - - do { -@@ -3296,7 +3275,7 @@ NetLibGetSystemGuid ( - // - // Step 1: Skip over formatted section. - // -- String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length); -+ String = (CHAR8 *)(Smbios.Raw + Smbios.Hdr->Length); - - // - // Step 2: Skip over unformatted string section. -@@ -3309,7 +3288,7 @@ NetLibGetSystemGuid ( - for ( ; *String != 0; String++) { - } - -- if (*(UINT8*)++String == 0) { -+ if (*(UINT8 *)++String == 0) { - // - // Pointer to the next SMBIOS structure. - // -@@ -3318,6 +3297,7 @@ NetLibGetSystemGuid ( - } - } while (TRUE); - } while (Smbios.Raw < SmbiosEnd.Raw); -+ - return EFI_NOT_FOUND; - } - -@@ -3341,15 +3321,15 @@ NetLibGetSystemGuid ( - CHAR8 * - EFIAPI - NetLibCreateDnsQName ( -- IN CHAR16 *DomainName -+ IN CHAR16 *DomainName - ) - { -- CHAR8 *QueryName; -- UINTN QueryNameSize; -- CHAR8 *Header; -- CHAR8 *Tail; -- UINTN Len; -- UINTN Index; -+ CHAR8 *QueryName; -+ UINTN QueryNameSize; -+ CHAR8 *Header; -+ CHAR8 *Tail; -+ UINTN Len; -+ UINTN Index; - - ASSERT (DomainName != NULL); - -@@ -3373,22 +3353,23 @@ NetLibCreateDnsQName ( - } - - Header = QueryName; -- Tail = Header + 1; -- Len = 0; -+ Tail = Header + 1; -+ Len = 0; - for (Index = 0; DomainName[Index] != 0; Index++) { -- *Tail = (CHAR8) DomainName[Index]; -+ *Tail = (CHAR8)DomainName[Index]; - if (*Tail == '.') { -- *Header = (CHAR8) Len; -- Header = Tail; -- Tail ++; -+ *Header = (CHAR8)Len; -+ Header = Tail; -+ Tail++; - Len = 0; - } else { - Tail++; - Len++; - } - } -- *Header = (CHAR8) Len; -- *Tail = 0; -+ -+ *Header = (CHAR8)Len; -+ *Tail = 0; - - return QueryName; - } -diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c -index c4dcb5e193..8a75b4b55b 100644 ---- a/NetworkPkg/TcpDxe/TcpDriver.c -+++ b/NetworkPkg/TcpDxe/TcpDriver.c -@@ -9,15 +9,15 @@ - - #include "TcpMain.h" - --UINT16 mTcp4RandomPort; --UINT16 mTcp6RandomPort; -+UINT16 mTcp4RandomPort; -+UINT16 mTcp6RandomPort; - --TCP_HEARTBEAT_TIMER mTcpTimer = { -+TCP_HEARTBEAT_TIMER mTcpTimer = { - NULL, - 0 - }; - --EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = { -+EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = { - Tcp4GetModeData, - Tcp4Configure, - Tcp4Routes, -@@ -30,7 +30,7 @@ EFI_TCP4_PROTOCOL gTcp4ProtocolTemplate = { - Tcp4Poll - }; - --EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = { -+EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = { - Tcp6GetModeData, - Tcp6Configure, - Tcp6Connect, -@@ -42,7 +42,7 @@ EFI_TCP6_PROTOCOL gTcp6ProtocolTemplate = { - Tcp6Poll - }; - --SOCK_INIT_DATA mTcpDefaultSockData = { -+SOCK_INIT_DATA mTcpDefaultSockData = { - SockStream, - SO_CLOSED, - NULL, -@@ -60,7 +60,7 @@ SOCK_INIT_DATA mTcpDefaultSockData = { - NULL, - }; - --EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = { - Tcp4DriverBindingSupported, - Tcp4DriverBindingStart, - Tcp4DriverBindingStop, -@@ -69,7 +69,7 @@ EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = { - NULL - }; - --EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = { - Tcp6DriverBindingSupported, - Tcp6DriverBindingStart, - Tcp6DriverBindingStop, -@@ -83,7 +83,6 @@ EFI_SERVICE_BINDING_PROTOCOL gTcpServiceBinding = { - TcpServiceBindingDestroyChild - }; - -- - /** - Create and start the heartbeat timer for the TCP driver. - -@@ -101,7 +100,6 @@ TcpCreateTimer ( - Status = EFI_SUCCESS; - - if (mTcpTimer.RefCnt == 0) { -- - Status = gBS->CreateEvent ( - EVT_TIMER | EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, -@@ -110,17 +108,15 @@ TcpCreateTimer ( - &mTcpTimer.TimerEvent - ); - if (!EFI_ERROR (Status)) { -- - Status = gBS->SetTimer ( - mTcpTimer.TimerEvent, - TimerPeriodic, -- (UINT64) (TICKS_PER_SECOND / TCP_TICK_HZ) -+ (UINT64)(TICKS_PER_SECOND / TCP_TICK_HZ) - ); - } - } - - if (!EFI_ERROR (Status)) { -- - mTcpTimer.RefCnt++; - } - -@@ -209,7 +205,7 @@ TcpDriverEntryPoint ( - // - Seed = NetRandomInitSeed (); - mTcpGlobalIss = NET_RANDOM (Seed) % mTcpGlobalIss; -- mTcp4RandomPort = (UINT16) (TCP_PORT_KNOWN + (NET_RANDOM (Seed) % TCP_PORT_KNOWN)); -+ mTcp4RandomPort = (UINT16)(TCP_PORT_KNOWN + (NET_RANDOM (Seed) % TCP_PORT_KNOWN)); - mTcp6RandomPort = mTcp4RandomPort; - - return EFI_SUCCESS; -@@ -233,11 +229,11 @@ TcpCreateService ( - IN UINT8 IpVersion - ) - { -- EFI_STATUS Status; -- EFI_GUID *IpServiceBindingGuid; -- EFI_GUID *TcpServiceBindingGuid; -- TCP_SERVICE_DATA *TcpServiceData; -- IP_IO_OPEN_DATA OpenData; -+ EFI_STATUS Status; -+ EFI_GUID *IpServiceBindingGuid; -+ EFI_GUID *TcpServiceBindingGuid; -+ TCP_SERVICE_DATA *TcpServiceData; -+ IP_IO_OPEN_DATA OpenData; - - if (IpVersion == IP_VERSION_4) { - IpServiceBindingGuid = &gEfiIp4ServiceBindingProtocolGuid; -@@ -279,10 +275,10 @@ TcpCreateService ( - return EFI_OUT_OF_RESOURCES; - } - -- TcpServiceData->Signature = TCP_DRIVER_SIGNATURE; -- TcpServiceData->ControllerHandle = Controller; -- TcpServiceData->DriverBindingHandle = Image; -- TcpServiceData->IpVersion = IpVersion; -+ TcpServiceData->Signature = TCP_DRIVER_SIGNATURE; -+ TcpServiceData->ControllerHandle = Controller; -+ TcpServiceData->DriverBindingHandle = Image; -+ TcpServiceData->IpVersion = IpVersion; - CopyMem ( - &TcpServiceData->ServiceBinding, - &gTcpServiceBinding, -@@ -295,7 +291,6 @@ TcpCreateService ( - goto ON_ERROR; - } - -- - InitializeListHead (&TcpServiceData->SocketList); - ZeroMem (&OpenData, sizeof (IP_IO_OPEN_DATA)); - -@@ -315,8 +310,8 @@ TcpCreateService ( - OpenData.IpConfigData.Ip6CfgData.DefaultProtocol = EFI_IP_PROTO_TCP; - } - -- OpenData.PktRcvdNotify = TcpRxCallback; -- Status = IpIoOpen (TcpServiceData->IpIo, &OpenData); -+ OpenData.PktRcvdNotify = TcpRxCallback; -+ Status = IpIoOpen (TcpServiceData->IpIo, &OpenData); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } -@@ -365,8 +360,8 @@ ON_ERROR: - EFI_STATUS - EFIAPI - TcpDestroyChildEntryInHandleBuffer ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { - SOCKET *Sock; -@@ -374,14 +369,14 @@ TcpDestroyChildEntryInHandleBuffer ( - UINTN NumberOfChildren; - EFI_HANDLE *ChildHandleBuffer; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE); -- ServiceBinding = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; -- NumberOfChildren = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; -- ChildHandleBuffer = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; -+ Sock = NET_LIST_USER_STRUCT_S (Entry, SOCKET, Link, SOCK_SIGNATURE); -+ ServiceBinding = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding; -+ NumberOfChildren = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren; -+ ChildHandleBuffer = ((TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer; - - if (!NetIsInHandleBuffer (Sock->SockHandle, NumberOfChildren, ChildHandleBuffer)) { - return EFI_SUCCESS; -@@ -415,13 +410,13 @@ TcpDestroyService ( - IN UINT8 IpVersion - ) - { -- EFI_HANDLE NicHandle; -- EFI_GUID *IpProtocolGuid; -- EFI_GUID *ServiceBindingGuid; -- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -- TCP_SERVICE_DATA *TcpServiceData; -- EFI_STATUS Status; -- LIST_ENTRY *List; -+ EFI_HANDLE NicHandle; -+ EFI_GUID *IpProtocolGuid; -+ EFI_GUID *ServiceBindingGuid; -+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -+ TCP_SERVICE_DATA *TcpServiceData; -+ EFI_STATUS Status; -+ LIST_ENTRY *List; - TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; - - ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6)); -@@ -442,7 +437,7 @@ TcpDestroyService ( - Status = gBS->OpenProtocol ( - NicHandle, - ServiceBindingGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - ImageHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -454,16 +449,16 @@ TcpDestroyService ( - TcpServiceData = TCP_SERVICE_FROM_THIS (ServiceBinding); - - if (NumberOfChildren != 0) { -- List = &TcpServiceData->SocketList; -- Context.ServiceBinding = ServiceBinding; -- Context.NumberOfChildren = NumberOfChildren; -+ List = &TcpServiceData->SocketList; -+ Context.ServiceBinding = ServiceBinding; -+ Context.NumberOfChildren = NumberOfChildren; - Context.ChildHandleBuffer = ChildHandleBuffer; -- Status = NetDestroyLinkList ( -- List, -- TcpDestroyChildEntryInHandleBuffer, -- &Context, -- NULL -- ); -+ Status = NetDestroyLinkList ( -+ List, -+ TcpDestroyChildEntryInHandleBuffer, -+ &Context, -+ NULL -+ ); - } else if (IsListEmpty (&TcpServiceData->SocketList)) { - // - // Uninstall TCP servicebinding protocol -@@ -758,7 +753,7 @@ TcpCreateSocketCallback ( - IpProtocolGuid = &gEfiIp6ProtocolGuid; - } - -- TcpServiceData = ((TCP_PROTO_DATA *) This->ProtoReserved)->TcpService; -+ TcpServiceData = ((TCP_PROTO_DATA *)This->ProtoReserved)->TcpService; - - // - // Open the default IP protocol of IP_IO BY_DRIVER. -@@ -781,7 +776,7 @@ TcpCreateSocketCallback ( - Status = gBS->OpenProtocol ( - TcpServiceData->ControllerHandle, - &gEfiDevicePathProtocolGuid, -- (VOID **) &This->ParentDevicePath, -+ (VOID **)&This->ParentDevicePath, - TcpServiceData->DriverBindingHandle, - This->SockHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -825,7 +820,7 @@ TcpDestroySocketCallback ( - IpProtocolGuid = &gEfiIp6ProtocolGuid; - } - -- TcpServiceData = ((TCP_PROTO_DATA *) This->ProtoReserved)->TcpService; -+ TcpServiceData = ((TCP_PROTO_DATA *)This->ProtoReserved)->TcpService; - - // - // Remove this node from the list. -@@ -876,7 +871,7 @@ TcpServiceBindingCreateChild ( - EFI_STATUS Status; - EFI_TPL OldTpl; - -- if (NULL == This || NULL == ChildHandle) { -+ if ((NULL == This) || (NULL == ChildHandle)) { - return EFI_INVALID_PARAMETER; - } - -@@ -914,7 +909,7 @@ TcpServiceBindingCreateChild ( - *ChildHandle = Sock->SockHandle; - } - -- mTcpDefaultSockData.ProtoData = NULL; -+ mTcpDefaultSockData.ProtoData = NULL; - - gBS->RestoreTPL (OldTpl); - return Status; -@@ -949,7 +944,7 @@ TcpServiceBindingDestroyChild ( - VOID *Tcp; - SOCKET *Sock; - -- if (NULL == This || NULL == ChildHandle) { -+ if ((NULL == This) || (NULL == ChildHandle)) { - return EFI_INVALID_PARAMETER; - } - -diff --git a/NetworkPkg/TcpDxe/TcpMain.h b/NetworkPkg/TcpDxe/TcpMain.h -index 35f12a16a8..0709298bbf 100644 ---- a/NetworkPkg/TcpDxe/TcpMain.h -+++ b/NetworkPkg/TcpDxe/TcpMain.h -@@ -3,7 +3,6 @@ - It is the common head file for all Tcp*.c in TCP driver. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-- - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -29,19 +28,19 @@ extern EFI_COMPONENT_NAME_PROTOCOL gTcpComponentName; - extern EFI_COMPONENT_NAME2_PROTOCOL gTcpComponentName2; - extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable; - --extern LIST_ENTRY mTcpRunQue; --extern LIST_ENTRY mTcpListenQue; --extern TCP_SEQNO mTcpGlobalIss; --extern UINT32 mTcpTick; -+extern LIST_ENTRY mTcpRunQue; -+extern LIST_ENTRY mTcpListenQue; -+extern TCP_SEQNO mTcpGlobalIss; -+extern UINT32 mTcpTick; - - /// - /// 30 seconds. - /// --#define TCP6_KEEP_NEIGHBOR_TIME 30 -+#define TCP6_KEEP_NEIGHBOR_TIME 30 - /// - /// 5 seconds, since 1 tick equals 200ms. - /// --#define TCP6_REFRESH_NEIGHBOR_TICK 25 -+#define TCP6_REFRESH_NEIGHBOR_TICK 25 - - #define TCP_EXPIRE_TIME 65535 - -@@ -53,43 +52,44 @@ extern UINT32 mTcpTick; - #define TCP_ISS_INCREMENT_1 2048 - #define TCP_ISS_INCREMENT_2 100 - -+ - typedef union { -- EFI_TCP4_CONFIG_DATA Tcp4CfgData; -- EFI_TCP6_CONFIG_DATA Tcp6CfgData; -+ EFI_TCP4_CONFIG_DATA Tcp4CfgData; -+ EFI_TCP6_CONFIG_DATA Tcp6CfgData; - } TCP_CONFIG_DATA; - - typedef union { -- EFI_TCP4_ACCESS_POINT Tcp4Ap; -- EFI_TCP6_ACCESS_POINT Tcp6Ap; -+ EFI_TCP4_ACCESS_POINT Tcp4Ap; -+ EFI_TCP6_ACCESS_POINT Tcp6Ap; - } TCP_ACCESS_POINT; - - typedef struct _TCP4_MODE_DATA { -- EFI_TCP4_CONNECTION_STATE *Tcp4State; -- EFI_TCP4_CONFIG_DATA *Tcp4ConfigData; -- EFI_IP4_MODE_DATA *Ip4ModeData; -- EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; -- EFI_SIMPLE_NETWORK_MODE *SnpModeData; -+ EFI_TCP4_CONNECTION_STATE *Tcp4State; -+ EFI_TCP4_CONFIG_DATA *Tcp4ConfigData; -+ EFI_IP4_MODE_DATA *Ip4ModeData; -+ EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; -+ EFI_SIMPLE_NETWORK_MODE *SnpModeData; - } TCP4_MODE_DATA; - - typedef struct _TCP6_MODE_DATA { -- EFI_TCP6_CONNECTION_STATE *Tcp6State; -- EFI_TCP6_CONFIG_DATA *Tcp6ConfigData; -- EFI_IP6_MODE_DATA *Ip6ModeData; -- EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; -- EFI_SIMPLE_NETWORK_MODE *SnpModeData; -+ EFI_TCP6_CONNECTION_STATE *Tcp6State; -+ EFI_TCP6_CONFIG_DATA *Tcp6ConfigData; -+ EFI_IP6_MODE_DATA *Ip6ModeData; -+ EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData; -+ EFI_SIMPLE_NETWORK_MODE *SnpModeData; - } TCP6_MODE_DATA; - - typedef struct _TCP4_ROUTE_INFO { -- BOOLEAN DeleteRoute; -- EFI_IPv4_ADDRESS *SubnetAddress; -- EFI_IPv4_ADDRESS *SubnetMask; -- EFI_IPv4_ADDRESS *GatewayAddress; -+ BOOLEAN DeleteRoute; -+ EFI_IPv4_ADDRESS *SubnetAddress; -+ EFI_IPv4_ADDRESS *SubnetMask; -+ EFI_IPv4_ADDRESS *GatewayAddress; - } TCP4_ROUTE_INFO; - - typedef struct { -- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -- UINTN NumberOfChildren; -- EFI_HANDLE *ChildHandleBuffer; -+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; -+ UINTN NumberOfChildren; -+ EFI_HANDLE *ChildHandleBuffer; - } TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT; - - // -@@ -122,12 +122,12 @@ typedef struct { - EFI_STATUS - EFIAPI - Tcp4GetModeData ( -- IN EFI_TCP4_PROTOCOL *This, -- OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL, -- OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL, -- OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, -- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, -- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL -+ IN EFI_TCP4_PROTOCOL *This, -+ OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL, -+ OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL, -+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, -+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, -+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL - ); - - /** -@@ -155,8 +155,8 @@ Tcp4GetModeData ( - EFI_STATUS - EFIAPI - Tcp4Configure ( -- IN EFI_TCP4_PROTOCOL * This, -- IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL - ); - - /** -@@ -187,11 +187,11 @@ Tcp4Configure ( - EFI_STATUS - EFIAPI - Tcp4Routes ( -- IN EFI_TCP4_PROTOCOL *This, -- IN BOOLEAN DeleteRoute, -- IN EFI_IPv4_ADDRESS *SubnetAddress, -- IN EFI_IPv4_ADDRESS *SubnetMask, -- IN EFI_IPv4_ADDRESS *GatewayAddress -+ IN EFI_TCP4_PROTOCOL *This, -+ IN BOOLEAN DeleteRoute, -+ IN EFI_IPv4_ADDRESS *SubnetAddress, -+ IN EFI_IPv4_ADDRESS *SubnetMask, -+ IN EFI_IPv4_ADDRESS *GatewayAddress - ); - - /** -@@ -216,8 +216,8 @@ Tcp4Routes ( - EFI_STATUS - EFIAPI - Tcp4Connect ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken - ); - - /** -@@ -243,8 +243,8 @@ Tcp4Connect ( - EFI_STATUS - EFIAPI - Tcp4Accept ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_LISTEN_TOKEN *ListenToken -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_LISTEN_TOKEN *ListenToken - ); - - /** -@@ -279,8 +279,8 @@ Tcp4Accept ( - EFI_STATUS - EFIAPI - Tcp4Transmit ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_IO_TOKEN *Token -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_IO_TOKEN *Token - ); - - /** -@@ -317,8 +317,8 @@ Tcp4Transmit ( - EFI_STATUS - EFIAPI - Tcp4Receive ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_IO_TOKEN *Token -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_IO_TOKEN *Token - ); - - /** -@@ -346,8 +346,8 @@ Tcp4Receive ( - EFI_STATUS - EFIAPI - Tcp4Close ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_CLOSE_TOKEN *CloseToken -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_CLOSE_TOKEN *CloseToken - ); - - /** -@@ -377,8 +377,8 @@ Tcp4Close ( - EFI_STATUS - EFIAPI - Tcp4Cancel ( -- IN EFI_TCP4_PROTOCOL *This, -- IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL -+ IN EFI_TCP4_PROTOCOL *This, -+ IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL - ); - - /** -@@ -398,7 +398,7 @@ Tcp4Cancel ( - EFI_STATUS - EFIAPI - Tcp4Poll ( -- IN EFI_TCP4_PROTOCOL *This -+ IN EFI_TCP4_PROTOCOL *This - ); - - // -@@ -436,12 +436,12 @@ Tcp4Poll ( - EFI_STATUS - EFIAPI - Tcp6GetModeData ( -- IN EFI_TCP6_PROTOCOL *This, -- OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL, -- OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL, -- OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, -- OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, -- OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL -+ IN EFI_TCP6_PROTOCOL *This, -+ OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL, -+ OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL, -+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL, -+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, -+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL - ); - - /** -@@ -494,8 +494,8 @@ Tcp6GetModeData ( - EFI_STATUS - EFIAPI - Tcp6Configure ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL - ); - - /** -@@ -531,8 +531,8 @@ Tcp6Configure ( - EFI_STATUS - EFIAPI - Tcp6Connect ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken - ); - - /** -@@ -574,8 +574,8 @@ Tcp6Connect ( - EFI_STATUS - EFIAPI - Tcp6Accept ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_LISTEN_TOKEN *ListenToken -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_LISTEN_TOKEN *ListenToken - ); - - /** -@@ -618,8 +618,8 @@ Tcp6Accept ( - EFI_STATUS - EFIAPI - Tcp6Transmit ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_IO_TOKEN *Token -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_IO_TOKEN *Token - ); - - /** -@@ -671,8 +671,8 @@ Tcp6Transmit ( - EFI_STATUS - EFIAPI - Tcp6Receive ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_IO_TOKEN *Token -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_IO_TOKEN *Token - ); - - /** -@@ -705,8 +705,8 @@ Tcp6Receive ( - EFI_STATUS - EFIAPI - Tcp6Close ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_CLOSE_TOKEN *CloseToken -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_CLOSE_TOKEN *CloseToken - ); - - /** -@@ -747,8 +747,8 @@ Tcp6Close ( - EFI_STATUS - EFIAPI - Tcp6Cancel ( -- IN EFI_TCP6_PROTOCOL *This, -- IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL -+ IN EFI_TCP6_PROTOCOL *This, -+ IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL - ); - - /** -@@ -771,7 +771,7 @@ Tcp6Cancel ( - EFI_STATUS - EFIAPI - Tcp6Poll ( -- IN EFI_TCP6_PROTOCOL *This -+ IN EFI_TCP6_PROTOCOL *This - ); - - #endif -diff --git a/NetworkPkg/TcpDxe/TcpMisc.c b/NetworkPkg/TcpDxe/TcpMisc.c -index 73ed33de85..3fa9d90d9f 100644 ---- a/NetworkPkg/TcpDxe/TcpMisc.c -+++ b/NetworkPkg/TcpDxe/TcpMisc.c -@@ -3,26 +3,25 @@ - - (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-- - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ - - #include "TcpMain.h" - --LIST_ENTRY mTcpRunQue = { -+LIST_ENTRY mTcpRunQue = { - &mTcpRunQue, - &mTcpRunQue - }; - --LIST_ENTRY mTcpListenQue = { -+LIST_ENTRY mTcpListenQue = { - &mTcpListenQue, - &mTcpListenQue - }; - - TCP_SEQNO mTcpGlobalIss = TCP_BASE_ISS; - --CHAR16 *mTcpStateName[] = { -+CHAR16 *mTcpStateName[] = { - L"TCP_CLOSED", - L"TCP_LISTEN", - L"TCP_SYN_SENT", -@@ -36,7 +35,6 @@ CHAR16 *mTcpStateName[] = { - L"TCP_LAST_ACK" - }; - -- - /** - Initialize the Tcb local related members. - -@@ -53,18 +51,18 @@ TcpInitTcbLocal ( - // - if (Tcb->Sk->IpVersion == IP_VERSION_4) { - Tcb->HeadSum = NetPseudoHeadChecksum ( -- Tcb->LocalEnd.Ip.Addr[0], -- Tcb->RemoteEnd.Ip.Addr[0], -- 0x06, -- 0 -- ); -+ Tcb->LocalEnd.Ip.Addr[0], -+ Tcb->RemoteEnd.Ip.Addr[0], -+ 0x06, -+ 0 -+ ); - } else { - Tcb->HeadSum = NetIp6PseudoHeadChecksum ( -- &Tcb->LocalEnd.Ip.v6, -- &Tcb->RemoteEnd.Ip.v6, -- 0x06, -- 0 -- ); -+ &Tcb->LocalEnd.Ip.v6, -+ &Tcb->RemoteEnd.Ip.v6, -+ 0x06, -+ 0 -+ ); - } - - Tcb->Iss = TcpGetIss (); -@@ -79,7 +77,7 @@ TcpInitTcbLocal ( - // - // First window size is never scaled - // -- Tcb->RcvWndScale = 0; -+ Tcb->RcvWndScale = 0; - Tcb->RetxmitSeqMax = 0; - - Tcb->ProbeTimerOn = FALSE; -@@ -95,9 +93,9 @@ TcpInitTcbLocal ( - **/ - VOID - TcpInitTcbPeer ( -- IN OUT TCP_CB *Tcb, -- IN TCP_SEG *Seg, -- IN TCP_OPTION *Opt -+ IN OUT TCP_CB *Tcb, -+ IN TCP_SEG *Seg, -+ IN TCP_OPTION *Opt - ) - { - UINT16 RcvMss; -@@ -105,9 +103,9 @@ TcpInitTcbPeer ( - ASSERT ((Tcb != NULL) && (Seg != NULL) && (Opt != NULL)); - ASSERT (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN)); - -- Tcb->SndWnd = Seg->Wnd; -- Tcb->SndWndMax = Tcb->SndWnd; -- Tcb->SndWl1 = Seg->Seq; -+ Tcb->SndWnd = Seg->Wnd; -+ Tcb->SndWndMax = Tcb->SndWnd; -+ Tcb->SndWl1 = Seg->Seq; - - if (TCP_FLG_ON (Seg->Flag, TCP_FLG_ACK)) { - Tcb->SndWl2 = Seg->Ack; -@@ -116,13 +114,12 @@ TcpInitTcbPeer ( - } - - if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_MSS)) { -- Tcb->SndMss = (UINT16) MAX (64, Opt->Mss); -+ Tcb->SndMss = (UINT16)MAX (64, Opt->Mss); - -- RcvMss = TcpGetRcvMss (Tcb->Sk); -+ RcvMss = TcpGetRcvMss (Tcb->Sk); - if (Tcb->SndMss > RcvMss) { - Tcb->SndMss = RcvMss; - } -- - } else { - // - // One end doesn't support MSS option, use default. -@@ -130,7 +127,7 @@ TcpInitTcbPeer ( - Tcb->RcvMss = 536; - } - -- Tcb->CWnd = Tcb->SndMss; -+ Tcb->CWnd = Tcb->SndMss; - - Tcb->Irs = Seg->Seq; - Tcb->RcvNxt = Tcb->Irs + 1; -@@ -138,12 +135,10 @@ TcpInitTcbPeer ( - Tcb->RcvWl2 = Tcb->RcvNxt; - - if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_WS) && !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_NO_WS)) { -+ Tcb->SndWndScale = Opt->WndScale; - -- Tcb->SndWndScale = Opt->WndScale; -- -- Tcb->RcvWndScale = TcpComputeScale (Tcb); -+ Tcb->RcvWndScale = TcpComputeScale (Tcb); - TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RCVD_WS); -- - } else { - // - // One end doesn't support window scale option. use zero. -@@ -152,7 +147,6 @@ TcpInitTcbPeer ( - } - - if (TCP_FLG_ON (Opt->Flag, TCP_OPTION_RCVD_TS) && !TCP_FLG_ON (Tcb->CtrlFlag, TCP_CTRL_NO_TS)) { -- - TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_SND_TS); - TCP_SET_FLG (Tcb->CtrlFlag, TCP_CTRL_RCVD_TS); - -@@ -189,9 +183,9 @@ TcpIsIpEqual ( - ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6)); - - if (Version == IP_VERSION_4) { -- return (BOOLEAN) (Ip1->Addr[0] == Ip2->Addr[0]); -+ return (BOOLEAN)(Ip1->Addr[0] == Ip2->Addr[0]); - } else { -- return (BOOLEAN) EFI_IP6_EQUAL (&Ip1->v6, &Ip2->v6); -+ return (BOOLEAN)EFI_IP6_EQUAL (&Ip1->v6, &Ip2->v6); - } - } - -@@ -208,17 +202,17 @@ TcpIsIpEqual ( - **/ - BOOLEAN - TcpIsIpZero ( -- IN EFI_IP_ADDRESS *Ip, -- IN UINT8 Version -+ IN EFI_IP_ADDRESS *Ip, -+ IN UINT8 Version - ) - { - ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6)); - - if (Version == IP_VERSION_4) { -- return (BOOLEAN) (Ip->Addr[0] == 0); -+ return (BOOLEAN)(Ip->Addr[0] == 0); - } else { -- return (BOOLEAN) ((Ip->Addr[0] == 0) && (Ip->Addr[1] == 0) && -- (Ip->Addr[2] == 0) && (Ip->Addr[3] == 0)); -+ return (BOOLEAN)((Ip->Addr[0] == 0) && (Ip->Addr[1] == 0) && -+ (Ip->Addr[2] == 0) && (Ip->Addr[3] == 0)); - } - } - -@@ -236,16 +230,16 @@ TcpIsIpZero ( - **/ - TCP_CB * - TcpLocateListenTcb ( -- IN TCP_PEER *Local, -- IN TCP_PEER *Remote, -- IN UINT8 Version -+ IN TCP_PEER *Local, -+ IN TCP_PEER *Remote, -+ IN UINT8 Version - ) - { -- LIST_ENTRY *Entry; -- TCP_CB *Node; -- TCP_CB *Match; -- INTN Last; -- INTN Cur; -+ LIST_ENTRY *Entry; -+ TCP_CB *Node; -+ TCP_CB *Match; -+ INTN Last; -+ INTN Cur; - - Last = 4; - Match = NULL; -@@ -257,8 +251,8 @@ TcpLocateListenTcb ( - (Local->Port != Node->LocalEnd.Port) || - !TCP_PEER_MATCH (Remote, &Node->RemoteEnd, Version) || - !TCP_PEER_MATCH (Local, &Node->LocalEnd, Version) -- ) { -- -+ ) -+ { - continue; - } - -@@ -311,9 +305,9 @@ TcpFindTcbByPeer ( - IN UINT8 Version - ) - { -- TCP_PORTNO LocalPort; -- LIST_ENTRY *Entry; -- TCP_CB *Tcb; -+ TCP_PORTNO LocalPort; -+ LIST_ENTRY *Entry; -+ TCP_CB *Tcb; - - ASSERT ((Addr != NULL) && (Port != 0)); - -@@ -323,10 +317,10 @@ TcpFindTcbByPeer ( - Tcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List); - - if ((Version == Tcb->Sk->IpVersion) && -- TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) && -+ TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) && - (LocalPort == Tcb->LocalEnd.Port) -- ) { -- -+ ) -+ { - return TRUE; - } - } -@@ -335,10 +329,10 @@ TcpFindTcbByPeer ( - Tcb = NET_LIST_USER_STRUCT (Entry, TCP_CB, List); - - if ((Version == Tcb->Sk->IpVersion) && -- TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) && -+ TcpIsIpEqual (Addr, &Tcb->LocalEnd.Ip, Version) && - (LocalPort == Tcb->LocalEnd.Port) -- ) { -- -+ ) -+ { - return TRUE; - } - } -@@ -370,10 +364,10 @@ TcpLocateTcb ( - IN BOOLEAN Syn - ) - { -- TCP_PEER Local; -- TCP_PEER Remote; -- LIST_ENTRY *Entry; -- TCP_CB *Tcb; -+ TCP_PEER Local; -+ TCP_PEER Remote; -+ LIST_ENTRY *Entry; -+ TCP_CB *Tcb; - - Local.Port = LocalPort; - Remote.Port = RemotePort; -@@ -390,8 +384,8 @@ TcpLocateTcb ( - if ((Version == Tcb->Sk->IpVersion) && - TCP_PEER_EQUAL (&Remote, &Tcb->RemoteEnd, Version) && - TCP_PEER_EQUAL (&Local, &Tcb->LocalEnd, Version) -- ) { -- -+ ) -+ { - RemoveEntryList (&Tcb->List); - InsertHeadList (&mTcpRunQue, &Tcb->List); - -@@ -420,20 +414,20 @@ TcpLocateTcb ( - **/ - INTN - TcpInsertTcb ( -- IN TCP_CB *Tcb -+ IN TCP_CB *Tcb - ) - { -- LIST_ENTRY *Entry; -- LIST_ENTRY *Head; -- TCP_CB *Node; -+ LIST_ENTRY *Entry; -+ LIST_ENTRY *Head; -+ TCP_CB *Node; - - ASSERT ( - (Tcb != NULL) && - ( -- (Tcb->State == TCP_LISTEN) || -- (Tcb->State == TCP_SYN_SENT) || -- (Tcb->State == TCP_SYN_RCVD) || -- (Tcb->State == TCP_CLOSED) -+ (Tcb->State == TCP_LISTEN) || -+ (Tcb->State == TCP_SYN_SENT) || -+ (Tcb->State == TCP_SYN_RCVD) || -+ (Tcb->State == TCP_CLOSED) - ) - ); - -@@ -455,15 +449,14 @@ TcpInsertTcb ( - - if (TCP_PEER_EQUAL (&Tcb->LocalEnd, &Node->LocalEnd, Tcb->Sk->IpVersion) && - TCP_PEER_EQUAL (&Tcb->RemoteEnd, &Node->RemoteEnd, Tcb->Sk->IpVersion) -- ) { -- -+ ) -+ { - return -1; - } - } - - InsertHeadList (Head, &Tcb->List); - -- - return 0; - } - -@@ -477,10 +470,10 @@ TcpInsertTcb ( - **/ - TCP_CB * - TcpCloneTcb ( -- IN TCP_CB *Tcb -+ IN TCP_CB *Tcb - ) - { -- TCP_CB *Clone; -+ TCP_CB *Clone; - - Clone = AllocateZeroPool (sizeof (TCP_CB)); - -@@ -506,7 +499,7 @@ TcpCloneTcb ( - return NULL; - } - -- ((TCP_PROTO_DATA *) (Clone->Sk->ProtoReserved))->TcpPcb = Clone; -+ ((TCP_PROTO_DATA *)(Clone->Sk->ProtoReserved))->TcpPcb = Clone; - - return Clone; - } -@@ -539,25 +532,25 @@ TcpGetRcvMss ( - IN SOCKET *Sock - ) - { -- EFI_IP4_MODE_DATA Ip4Mode; -- EFI_IP6_MODE_DATA Ip6Mode; -- EFI_IP4_PROTOCOL *Ip4; -- EFI_IP6_PROTOCOL *Ip6; -- TCP_PROTO_DATA *TcpProto; -+ EFI_IP4_MODE_DATA Ip4Mode; -+ EFI_IP6_MODE_DATA Ip6Mode; -+ EFI_IP4_PROTOCOL *Ip4; -+ EFI_IP6_PROTOCOL *Ip6; -+ TCP_PROTO_DATA *TcpProto; - - ASSERT (Sock != NULL); - - ZeroMem (&Ip4Mode, sizeof (EFI_IP4_MODE_DATA)); - ZeroMem (&Ip6Mode, sizeof (EFI_IP6_MODE_DATA)); - -- TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved; -+ TcpProto = (TCP_PROTO_DATA *)Sock->ProtoReserved; - - if (Sock->IpVersion == IP_VERSION_4) { - Ip4 = TcpProto->TcpService->IpIo->Ip.Ip4; - ASSERT (Ip4 != NULL); - Ip4->GetModeData (Ip4, &Ip4Mode, NULL, NULL); - -- return (UINT16) (Ip4Mode.MaxPacketSize - sizeof (TCP_HEAD)); -+ return (UINT16)(Ip4Mode.MaxPacketSize - sizeof (TCP_HEAD)); - } else { - Ip6 = TcpProto->TcpService->IpIo->Ip.Ip6; - ASSERT (Ip6 != NULL); -@@ -587,7 +580,7 @@ TcpGetRcvMss ( - } - } - -- return (UINT16) (Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD)); -+ return (UINT16)(Ip6Mode.MaxPacketSize - sizeof (TCP_HEAD)); - } - } - -@@ -600,8 +593,8 @@ TcpGetRcvMss ( - **/ - VOID - TcpSetState ( -- IN TCP_CB *Tcb, -- IN UINT8 State -+ IN TCP_CB *Tcb, -+ IN UINT8 State - ) - { - ASSERT (Tcb->State < (sizeof (mTcpStateName) / sizeof (CHAR16 *))); -@@ -609,36 +602,36 @@ TcpSetState ( - - DEBUG ( - (EFI_D_NET, -- "Tcb (%p) state %s --> %s\n", -- Tcb, -- mTcpStateName[Tcb->State], -- mTcpStateName[State]) -+ "Tcb (%p) state %s --> %s\n", -+ Tcb, -+ mTcpStateName[Tcb->State], -+ mTcpStateName[State]) - ); - - Tcb->State = State; - - switch (State) { -- case TCP_ESTABLISHED: -+ case TCP_ESTABLISHED: - -- SockConnEstablished (Tcb->Sk); -+ SockConnEstablished (Tcb->Sk); - -- if (Tcb->Parent != NULL) { -- // -- // A new connection is accepted by a listening socket. Install -- // the device path. -- // -- TcpInstallDevicePath (Tcb->Sk); -- } -+ if (Tcb->Parent != NULL) { -+ // -+ // A new connection is accepted by a listening socket. Install -+ // the device path. -+ // -+ TcpInstallDevicePath (Tcb->Sk); -+ } - -- break; -+ break; - -- case TCP_CLOSED: -+ case TCP_CLOSED: - -- SockConnClosed (Tcb->Sk); -+ SockConnClosed (Tcb->Sk); - -- break; -- default: -- break; -+ break; -+ default: -+ break; - } - } - -@@ -653,21 +646,21 @@ TcpSetState ( - **/ - UINT16 - TcpChecksum ( -- IN NET_BUF *Nbuf, -- IN UINT16 HeadSum -+ IN NET_BUF *Nbuf, -+ IN UINT16 HeadSum - ) - { - UINT16 Checksum; - -- Checksum = NetbufChecksum (Nbuf); -- Checksum = NetAddChecksum (Checksum, HeadSum); -+ Checksum = NetbufChecksum (Nbuf); -+ Checksum = NetAddChecksum (Checksum, HeadSum); - - Checksum = NetAddChecksum ( -- Checksum, -- HTONS ((UINT16) Nbuf->TotalSize) -- ); -+ Checksum, -+ HTONS ((UINT16)Nbuf->TotalSize) -+ ); - -- return (UINT16) (~Checksum); -+ return (UINT16)(~Checksum); - } - - /** -@@ -682,22 +675,22 @@ TcpChecksum ( - **/ - TCP_SEG * - TcpFormatNetbuf ( -- IN TCP_CB *Tcb, -- IN OUT NET_BUF *Nbuf -+ IN TCP_CB *Tcb, -+ IN OUT NET_BUF *Nbuf - ) - { - TCP_SEG *Seg; - TCP_HEAD *Head; - -- Seg = TCPSEG_NETBUF (Nbuf); -- Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL); -+ Seg = TCPSEG_NETBUF (Nbuf); -+ Head = (TCP_HEAD *)NetbufGetByte (Nbuf, 0, NULL); - ASSERT (Head != NULL); - - Nbuf->Tcp = Head; - -- Seg->Seq = NTOHL (Head->Seq); -- Seg->Ack = NTOHL (Head->Ack); -- Seg->End = Seg->Seq + (Nbuf->TotalSize - (Head->HeadLen << 2)); -+ Seg->Seq = NTOHL (Head->Seq); -+ Seg->Ack = NTOHL (Head->Ack); -+ Seg->End = Seg->Seq + (Nbuf->TotalSize - (Head->HeadLen << 2)); - - Seg->Urg = NTOHS (Head->Urg); - Seg->Wnd = (NTOHS (Head->Wnd) << Tcb->SndWndScale); -@@ -726,7 +719,6 @@ TcpFormatNetbuf ( - - @param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a - connection. -- - **/ - VOID - TcpOnAppConnect ( -@@ -749,17 +741,16 @@ TcpOnAppConnect ( - **/ - VOID - TcpOnAppClose ( -- IN OUT TCP_CB *Tcb -+ IN OUT TCP_CB *Tcb - ) - { - ASSERT (Tcb != NULL); - -- if (!IsListEmpty (&Tcb->RcvQue) || GET_RCV_DATASIZE (Tcb->Sk) != 0) { -- -+ if (!IsListEmpty (&Tcb->RcvQue) || (GET_RCV_DATASIZE (Tcb->Sk) != 0)) { - DEBUG ( - (EFI_D_WARN, -- "TcpOnAppClose: connection reset because data is lost for TCB %p\n", -- Tcb) -+ "TcpOnAppClose: connection reset because data is lost for TCB %p\n", -+ Tcb) - ); - - TcpResetConnection (Tcb); -@@ -768,22 +759,22 @@ TcpOnAppClose ( - } - - switch (Tcb->State) { -- case TCP_CLOSED: -- case TCP_LISTEN: -- case TCP_SYN_SENT: -- TcpSetState (Tcb, TCP_CLOSED); -- break; -- -- case TCP_SYN_RCVD: -- case TCP_ESTABLISHED: -- TcpSetState (Tcb, TCP_FIN_WAIT_1); -- break; -- -- case TCP_CLOSE_WAIT: -- TcpSetState (Tcb, TCP_LAST_ACK); -- break; -- default: -- break; -+ case TCP_CLOSED: -+ case TCP_LISTEN: -+ case TCP_SYN_SENT: -+ TcpSetState (Tcb, TCP_CLOSED); -+ break; -+ -+ case TCP_SYN_RCVD: -+ case TCP_ESTABLISHED: -+ TcpSetState (Tcb, TCP_FIN_WAIT_1); -+ break; -+ -+ case TCP_CLOSE_WAIT: -+ TcpSetState (Tcb, TCP_LAST_ACK); -+ break; -+ default: -+ break; - } - - TcpToSendData (Tcb, 1); -@@ -801,35 +792,34 @@ TcpOnAppClose ( - **/ - INTN - TcpOnAppSend ( -- IN OUT TCP_CB *Tcb -+ IN OUT TCP_CB *Tcb - ) - { -- - switch (Tcb->State) { -- case TCP_CLOSED: -- return -1; -+ case TCP_CLOSED: -+ return -1; - -- case TCP_LISTEN: -- return -1; -+ case TCP_LISTEN: -+ return -1; - -- case TCP_SYN_SENT: -- case TCP_SYN_RCVD: -- return 0; -+ case TCP_SYN_SENT: -+ case TCP_SYN_RCVD: -+ return 0; - -- case TCP_ESTABLISHED: -- case TCP_CLOSE_WAIT: -- TcpToSendData (Tcb, 0); -- return 0; -+ case TCP_ESTABLISHED: -+ case TCP_CLOSE_WAIT: -+ TcpToSendData (Tcb, 0); -+ return 0; - -- case TCP_FIN_WAIT_1: -- case TCP_FIN_WAIT_2: -- case TCP_CLOSING: -- case TCP_LAST_ACK: -- case TCP_TIME_WAIT: -- return -1; -+ case TCP_FIN_WAIT_1: -+ case TCP_FIN_WAIT_2: -+ case TCP_CLOSING: -+ case TCP_LAST_ACK: -+ case TCP_TIME_WAIT: -+ return -1; - -- default: -- break; -+ default: -+ break; - } - - return 0; -@@ -844,41 +834,38 @@ TcpOnAppSend ( - **/ - VOID - TcpOnAppConsume ( -- IN TCP_CB *Tcb -+ IN TCP_CB *Tcb - ) - { -- UINT32 TcpOld; -+ UINT32 TcpOld; - - switch (Tcb->State) { -- case TCP_ESTABLISHED: -- TcpOld = TcpRcvWinOld (Tcb); -- if (TcpRcvWinNow (Tcb) > TcpOld) { -- -- if (TcpOld < Tcb->RcvMss) { -- -- DEBUG ( -- (EFI_D_NET, -- "TcpOnAppConsume: send a window update for a window closed Tcb %p\n", -- Tcb) -- ); -- -- TcpSendAck (Tcb); -- } else if (Tcb->DelayedAck == 0) { -- -- DEBUG ( -- (EFI_D_NET, -- "TcpOnAppConsume: scheduled a delayed ACK to update window for Tcb %p\n", -- Tcb) -- ); -- -- Tcb->DelayedAck = 1; -+ case TCP_ESTABLISHED: -+ TcpOld = TcpRcvWinOld (Tcb); -+ if (TcpRcvWinNow (Tcb) > TcpOld) { -+ if (TcpOld < Tcb->RcvMss) { -+ DEBUG ( -+ (EFI_D_NET, -+ "TcpOnAppConsume: send a window update for a window closed Tcb %p\n", -+ Tcb) -+ ); -+ -+ TcpSendAck (Tcb); -+ } else if (Tcb->DelayedAck == 0) { -+ DEBUG ( -+ (EFI_D_NET, -+ "TcpOnAppConsume: scheduled a delayed ACK to update window for Tcb %p\n", -+ Tcb) -+ ); -+ -+ Tcb->DelayedAck = 1; -+ } - } -- } - -- break; -+ break; - -- default: -- break; -+ default: -+ break; - } - } - -@@ -891,25 +878,25 @@ TcpOnAppConsume ( - **/ - VOID - TcpOnAppAbort ( -- IN TCP_CB *Tcb -+ IN TCP_CB *Tcb - ) - { - DEBUG ( - (EFI_D_WARN, -- "TcpOnAppAbort: connection reset issued by application for TCB %p\n", -- Tcb) -+ "TcpOnAppAbort: connection reset issued by application for TCB %p\n", -+ Tcb) - ); - - switch (Tcb->State) { -- case TCP_SYN_RCVD: -- case TCP_ESTABLISHED: -- case TCP_FIN_WAIT_1: -- case TCP_FIN_WAIT_2: -- case TCP_CLOSE_WAIT: -- TcpResetConnection (Tcb); -- break; -- default: -- break; -+ case TCP_SYN_RCVD: -+ case TCP_ESTABLISHED: -+ case TCP_FIN_WAIT_1: -+ case TCP_FIN_WAIT_2: -+ case TCP_CLOSE_WAIT: -+ TcpResetConnection (Tcb); -+ break; -+ default: -+ break; - } - - TcpSetState (Tcb, TCP_CLOSED); -@@ -923,7 +910,7 @@ TcpOnAppAbort ( - **/ - VOID - TcpResetConnection ( -- IN TCP_CB *Tcb -+ IN TCP_CB *Tcb - ) - { - NET_BUF *Nbuf; -@@ -932,10 +919,10 @@ TcpResetConnection ( - Nbuf = NetbufAlloc (TCP_MAX_HEAD); - - if (Nbuf == NULL) { -- return ; -+ return; - } - -- Nhead = (TCP_HEAD *) NetbufAllocSpace ( -+ Nhead = (TCP_HEAD *)NetbufAllocSpace ( - Nbuf, - sizeof (TCP_HEAD), - NET_BUF_TAIL -@@ -943,14 +930,14 @@ TcpResetConnection ( - - ASSERT (Nhead != NULL); - -- Nbuf->Tcp = Nhead; -+ Nbuf->Tcp = Nhead; - - Nhead->Flag = TCP_FLG_RST; - Nhead->Seq = HTONL (Tcb->SndNxt); - Nhead->Ack = HTONL (Tcb->RcvNxt); - Nhead->SrcPort = Tcb->LocalEnd.Port; - Nhead->DstPort = Tcb->RemoteEnd.Port; -- Nhead->HeadLen = (UINT8) (sizeof (TCP_HEAD) >> 2); -+ Nhead->HeadLen = (UINT8)(sizeof (TCP_HEAD) >> 2); - Nhead->Res = 0; - Nhead->Wnd = HTONS (0xFFFF); - Nhead->Checksum = 0; -@@ -973,24 +960,24 @@ TcpResetConnection ( - **/ - EFI_STATUS - TcpInstallDevicePath ( -- IN SOCKET *Sock -+ IN SOCKET *Sock - ) - { -- TCP_PROTO_DATA *TcpProto; -- TCP_SERVICE_DATA *TcpService; -- TCP_CB *Tcb; -- IPv4_DEVICE_PATH Ip4DPathNode; -- IPv6_DEVICE_PATH Ip6DPathNode; -- EFI_DEVICE_PATH_PROTOCOL *DevicePath; -- EFI_STATUS Status; -- TCP_PORTNO LocalPort; -- TCP_PORTNO RemotePort; -- -- TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved; -+ TCP_PROTO_DATA *TcpProto; -+ TCP_SERVICE_DATA *TcpService; -+ TCP_CB *Tcb; -+ IPv4_DEVICE_PATH Ip4DPathNode; -+ IPv6_DEVICE_PATH Ip6DPathNode; -+ EFI_DEVICE_PATH_PROTOCOL *DevicePath; -+ EFI_STATUS Status; -+ TCP_PORTNO LocalPort; -+ TCP_PORTNO RemotePort; -+ -+ TcpProto = (TCP_PROTO_DATA *)Sock->ProtoReserved; - TcpService = TcpProto->TcpService; - Tcb = TcpProto->TcpPcb; - -- LocalPort = NTOHS (Tcb->LocalEnd.Port); -+ LocalPort = NTOHS (Tcb->LocalEnd.Port); - RemotePort = NTOHS (Tcb->RemoteEnd.Port); - if (Sock->IpVersion == IP_VERSION_4) { - NetLibCreateIPv4DPathNode ( -@@ -1006,7 +993,7 @@ TcpInstallDevicePath ( - - IP4_COPY_ADDRESS (&Ip4DPathNode.SubnetMask, &Tcb->SubnetMask); - -- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &Ip4DPathNode; -+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&Ip4DPathNode; - } else { - NetLibCreateIPv6DPathNode ( - &Ip6DPathNode, -@@ -1018,7 +1005,7 @@ TcpInstallDevicePath ( - EFI_IP_PROTO_TCP - ); - -- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &Ip6DPathNode; -+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&Ip6DPathNode; - } - - Sock->DevicePath = AppendDevicePathNode (Sock->ParentDevicePath, DevicePath); -@@ -1039,4 +1026,3 @@ TcpInstallDevicePath ( - - return Status; - } -- -diff --git a/NetworkPkg/Udp4Dxe/Udp4Driver.c b/NetworkPkg/Udp4Dxe/Udp4Driver.c -index 44032682e2..cb917fcfc9 100644 ---- a/NetworkPkg/Udp4Dxe/Udp4Driver.c -+++ b/NetworkPkg/Udp4Dxe/Udp4Driver.c -@@ -5,10 +5,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ - -- - #include "Udp4Impl.h" - --EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = { - Udp4DriverBindingSupported, - Udp4DriverBindingStart, - Udp4DriverBindingStop, -@@ -17,7 +16,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUdp4DriverBinding = { - NULL - }; - --EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = { -+EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = { - Udp4ServiceBindingCreateChild, - Udp4ServiceBindingDestroyChild - }; -@@ -35,8 +34,8 @@ EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding = { - EFI_STATUS - EFIAPI - Udp4DestroyChildEntryInHandleBuffer ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { - UDP4_INSTANCE_DATA *Instance; -@@ -44,14 +43,14 @@ Udp4DestroyChildEntryInHandleBuffer ( - UINTN NumberOfChildren; - EFI_HANDLE *ChildHandleBuffer; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE); -- ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; -- NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; -- ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; -+ Instance = NET_LIST_USER_STRUCT_S (Entry, UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE); -+ ServiceBinding = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding; -+ NumberOfChildren = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren; -+ ChildHandleBuffer = ((UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer; - - if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { - return EFI_SUCCESS; -@@ -60,7 +59,6 @@ Udp4DestroyChildEntryInHandleBuffer ( - return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle); - } - -- - /** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In -@@ -119,7 +117,6 @@ Udp4DriverBindingSupported ( - return Status; - } - -- - /** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make -@@ -180,7 +177,6 @@ Udp4DriverBindingStart ( - return Status; - } - -- - /** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to -@@ -229,7 +225,7 @@ Udp4DriverBindingStop ( - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiUdp4ServiceBindingProtocolGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - This->DriverBindingHandle, - NicHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -243,16 +239,16 @@ Udp4DriverBindingStop ( - // - // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer. - // -- List = &Udp4Service->ChildrenList; -+ List = &Udp4Service->ChildrenList; - Context.ServiceBinding = ServiceBinding; - Context.NumberOfChildren = NumberOfChildren; - Context.ChildHandleBuffer = ChildHandleBuffer; -- Status = NetDestroyLinkList ( -- List, -- Udp4DestroyChildEntryInHandleBuffer, -- &Context, -- NULL -- ); -+ Status = NetDestroyLinkList ( -+ List, -+ Udp4DestroyChildEntryInHandleBuffer, -+ &Context, -+ NULL -+ ); - } else { - gBS->UninstallMultipleProtocolInterfaces ( - NicHandle, -@@ -267,13 +263,13 @@ Udp4DriverBindingStop ( - FreeUnicodeStringTable (gUdpControllerNameTable); - gUdpControllerNameTable = NULL; - } -+ - FreePool (Udp4Service); - } - - return Status; - } - -- - /** - Creates a child handle and installs a protocol. - -@@ -352,7 +348,7 @@ Udp4ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - Udp4Service->IpIo->ChildHandle, - &gEfiIp4ProtocolGuid, -- (VOID **) &Ip4, -+ (VOID **)&Ip4, - gUdp4DriverBinding.DriverBindingHandle, - Instance->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -367,7 +363,7 @@ Udp4ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - Instance->IpInfo->ChildHandle, - &gEfiIp4ProtocolGuid, -- (VOID **) &Ip4, -+ (VOID **)&Ip4, - gUdp4DriverBinding.DriverBindingHandle, - Instance->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -410,7 +406,6 @@ ON_ERROR: - return Status; - } - -- - /** - Destroys a child handle with a protocol installed on it. - -@@ -454,7 +449,7 @@ Udp4ServiceBindingDestroyChild ( - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiUdp4ProtocolGuid, -- (VOID **) &Udp4Proto, -+ (VOID **)&Udp4Proto, - gUdp4DriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -499,7 +494,7 @@ Udp4ServiceBindingDestroyChild ( - Status = gBS->UninstallMultipleProtocolInterfaces ( - ChildHandle, - &gEfiUdp4ProtocolGuid, -- (VOID *) &Instance->Udp4Proto, -+ (VOID *)&Instance->Udp4Proto, - NULL - ); - if (EFI_ERROR (Status)) { -@@ -576,9 +571,8 @@ Udp4DriverEntryPoint ( - // - // Initialize the UDP random port. - // -- mUdp4RandomPort = (UINT16) (((UINT16) NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN); -+ mUdp4RandomPort = (UINT16)(((UINT16)NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN); - } - - return Status; - } -- -diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Driver.c -index 6021bb3699..ae96fb9966 100644 ---- a/NetworkPkg/Udp6Dxe/Udp6Driver.c -+++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c -@@ -9,7 +9,7 @@ - - #include "Udp6Impl.h" - --EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = { - Udp6DriverBindingSupported, - Udp6DriverBindingStart, - Udp6DriverBindingStop, -@@ -18,7 +18,7 @@ EFI_DRIVER_BINDING_PROTOCOL gUdp6DriverBinding = { - NULL - }; - --EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = { -+EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding = { - Udp6ServiceBindingCreateChild, - Udp6ServiceBindingDestroyChild - }; -@@ -74,6 +74,7 @@ Udp6DriverBindingSupported ( - ) - { - EFI_STATUS Status; -+ - // - // Test for the Udp6ServiceBinding Protocol - // -@@ -88,6 +89,7 @@ Udp6DriverBindingSupported ( - if (!EFI_ERROR (Status)) { - return EFI_ALREADY_STARTED; - } -+ - // - // Test for the Ip6ServiceBinding Protocol - // -@@ -166,6 +168,7 @@ EXIT: - FreePool (Udp6Service); - } - } -+ - return Status; - } - -@@ -183,8 +186,8 @@ EXIT: - EFI_STATUS - EFIAPI - Udp6DestroyChildEntryInHandleBuffer ( -- IN LIST_ENTRY *Entry, -- IN VOID *Context -+ IN LIST_ENTRY *Entry, -+ IN VOID *Context - ) - { - UDP6_INSTANCE_DATA *Instance; -@@ -192,14 +195,14 @@ Udp6DestroyChildEntryInHandleBuffer ( - UINTN NumberOfChildren; - EFI_HANDLE *ChildHandleBuffer; - -- if (Entry == NULL || Context == NULL) { -+ if ((Entry == NULL) || (Context == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE); -- ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding; -- NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren; -- ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer; -+ Instance = NET_LIST_USER_STRUCT_S (Entry, UDP6_INSTANCE_DATA, Link, UDP6_INSTANCE_DATA_SIGNATURE); -+ ServiceBinding = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding; -+ NumberOfChildren = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren; -+ ChildHandleBuffer = ((UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer; - - if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) { - return EFI_SUCCESS; -@@ -258,7 +261,7 @@ Udp6DriverBindingStop ( - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiUdp6ServiceBindingProtocolGuid, -- (VOID **) &ServiceBinding, -+ (VOID **)&ServiceBinding, - This->DriverBindingHandle, - NicHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -273,23 +276,23 @@ Udp6DriverBindingStop ( - // - // NumberOfChildren is not zero, destroy the children instances in ChildHandleBuffer. - // -- List = &Udp6Service->ChildrenList; -+ List = &Udp6Service->ChildrenList; - Context.ServiceBinding = ServiceBinding; - Context.NumberOfChildren = NumberOfChildren; - Context.ChildHandleBuffer = ChildHandleBuffer; -- Status = NetDestroyLinkList ( -- List, -- Udp6DestroyChildEntryInHandleBuffer, -- &Context, -- NULL -- ); -+ Status = NetDestroyLinkList ( -+ List, -+ Udp6DestroyChildEntryInHandleBuffer, -+ &Context, -+ NULL -+ ); - } else if (IsListEmpty (&Udp6Service->ChildrenList)) { - Status = gBS->UninstallMultipleProtocolInterfaces ( -- NicHandle, -- &gEfiUdp6ServiceBindingProtocolGuid, -- &Udp6Service->ServiceBinding, -- NULL -- ); -+ NicHandle, -+ &gEfiUdp6ServiceBindingProtocolGuid, -+ &Udp6Service->ServiceBinding, -+ NULL -+ ); - - Udp6CleanService (Udp6Service); - FreePool (Udp6Service); -@@ -376,7 +379,7 @@ Udp6ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - Udp6Service->IpIo->ChildHandle, - &gEfiIp6ProtocolGuid, -- (VOID **) &Ip6, -+ (VOID **)&Ip6, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -391,7 +394,7 @@ Udp6ServiceBindingCreateChild ( - Status = gBS->OpenProtocol ( - Instance->IpInfo->ChildHandle, - &gEfiIp6ProtocolGuid, -- (VOID **) &Ip6, -+ (VOID **)&Ip6, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -478,7 +481,7 @@ Udp6ServiceBindingDestroyChild ( - Status = gBS->OpenProtocol ( - ChildHandle, - &gEfiUdp6ProtocolGuid, -- (VOID **) &Udp6Proto, -+ (VOID **)&Udp6Proto, - gUdp6DriverBinding.DriverBindingHandle, - ChildHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -502,11 +505,11 @@ Udp6ServiceBindingDestroyChild ( - // Close the Ip6 protocol on the default IpIo. - // - Status = gBS->CloseProtocol ( -- Udp6Service->IpIo->ChildHandle, -- &gEfiIp6ProtocolGuid, -- gUdp6DriverBinding.DriverBindingHandle, -- Instance->ChildHandle -- ); -+ Udp6Service->IpIo->ChildHandle, -+ &gEfiIp6ProtocolGuid, -+ gUdp6DriverBinding.DriverBindingHandle, -+ Instance->ChildHandle -+ ); - if (EFI_ERROR (Status)) { - Instance->InDestroy = FALSE; - return Status; -@@ -516,11 +519,11 @@ Udp6ServiceBindingDestroyChild ( - // Close the Ip6 protocol on this instance's IpInfo. - // - Status = gBS->CloseProtocol ( -- Instance->IpInfo->ChildHandle, -- &gEfiIp6ProtocolGuid, -- gUdp6DriverBinding.DriverBindingHandle, -- Instance->ChildHandle -- ); -+ Instance->IpInfo->ChildHandle, -+ &gEfiIp6ProtocolGuid, -+ gUdp6DriverBinding.DriverBindingHandle, -+ Instance->ChildHandle -+ ); - if (EFI_ERROR (Status)) { - Instance->InDestroy = FALSE; - return Status; -@@ -532,7 +535,7 @@ Udp6ServiceBindingDestroyChild ( - Status = gBS->UninstallMultipleProtocolInterfaces ( - ChildHandle, - &gEfiUdp6ProtocolGuid, -- (VOID *) &Instance->Udp6Proto, -+ (VOID *)&Instance->Udp6Proto, - NULL - ); - if (EFI_ERROR (Status)) { -@@ -611,13 +614,11 @@ Udp6DriverEntryPoint ( - // Initialize the UDP random port. - // - mUdp6RandomPort = (UINT16)( -- ((UINT16) NetRandomInitSeed ()) % -- UDP6_PORT_KNOWN + -- UDP6_PORT_KNOWN -- ); -+ ((UINT16)NetRandomInitSeed ()) % -+ UDP6_PORT_KNOWN + -+ UDP6_PORT_KNOWN -+ ); - } - - return Status; - } -- -- -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -index fb63cf61a9..874fc2c37b 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -@@ -27,7 +27,6 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = { - // - UINT32 mPxeDhcpTimeout[4] = {4, 8, 16, 32}; - -- - /** - Parse a certain dhcp4 option by OptTag in Buffer, and return with start pointer. - -@@ -53,7 +52,6 @@ PxeBcParseDhcp4Options ( - Offset = 0; - - while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) { -- - if (Option->OpCode == OptTag) { - // - // Found the required option. -@@ -76,7 +74,6 @@ PxeBcParseDhcp4Options ( - return NULL; - } - -- - /** - Parse the PXE vendor options and extract the information from them. - -@@ -107,7 +104,6 @@ PxeBcParseVendorOptions ( - // Parse all the interesting PXE vendor options one by one. - // - switch (PxeOption->OpCode) { -- - case PXEBC_VENDOR_TAG_MTFTP_IP: - - CopyMem (&VendorOption->MtftpIp, PxeOption->Data, sizeof (EFI_IPv4_ADDRESS)); -@@ -205,7 +201,6 @@ PxeBcParseVendorOptions ( - } - } - -- - /** - Build the options buffer for the DHCPv4 request packet. - -@@ -377,7 +372,6 @@ PxeBcBuildDhcp4Options ( - return Index; - } - -- - /** - Create a template DHCPv4 packet as a seed. - -@@ -412,7 +406,6 @@ PxeBcSeedDhcp4Packet ( - Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP; - } - -- - /** - Cache the DHCPv4 packet. - -@@ -439,7 +432,6 @@ PxeBcCacheDhcp4Packet ( - return EFI_SUCCESS; - } - -- - /** - Parse the cached DHCPv4 packet, including all the options. - -@@ -485,6 +477,7 @@ PxeBcParseDhcp4Packet ( - mInterestedDhcp4Tags[Index] - ); - } -+ - // - // Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132. - // If yes, try to parse options from the BootFileName field, then ServerName field. -@@ -503,6 +496,7 @@ PxeBcParseDhcp4Packet ( - } - } - } -+ - if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) { - for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { - if (Options[Index] == NULL) { -@@ -528,7 +522,8 @@ PxeBcParseDhcp4Packet ( - // - Option = Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID]; - if ((Option != NULL) && (Option->Length >= 9) && -- (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) { -+ (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) -+ { - IsPxeOffer = TRUE; - } - -@@ -563,7 +558,6 @@ PxeBcParseDhcp4Packet ( - Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *) - (&Offer->Dhcp4.Header.BootFileName[0] - - OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0])); -- - } - - // -@@ -584,7 +578,6 @@ PxeBcParseDhcp4Packet ( - return EFI_DEVICE_ERROR; - } - } else { -- - if (IS_VALID_DISCOVER_VENDOR_OPTION (Cache4->VendorOpt.BitMap)) { - // - // It's a PXE10 offer with PXEClient and discover vendor option. -@@ -614,7 +607,6 @@ PxeBcParseDhcp4Packet ( - return EFI_SUCCESS; - } - -- - /** - Cache the DHCPv4 ack packet, and parse it on demand. - -@@ -655,7 +647,6 @@ PxeBcCopyDhcp4Ack ( - return EFI_SUCCESS; - } - -- - /** - Cache the DHCPv4 proxy offer packet according to the received order. - -@@ -701,7 +692,6 @@ PxeBcCopyProxyOffer ( - return EFI_SUCCESS; - } - -- - /** - Retry to request bootfile name by the BINL offer. - -@@ -725,8 +715,10 @@ PxeBcRetryBinlOffer ( - EFI_DHCP4_PACKET *Reply; - - ASSERT (Index < PXEBC_OFFER_MAX_NUM); -- ASSERT (Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl || -- Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl); -+ ASSERT ( -+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl || -+ Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl -+ ); - - Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer; - -@@ -866,7 +858,8 @@ PxeBcCacheDhcp4Offer ( - Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum; - Private->OfferCount[OfferType]++; - } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) && -- Private->OfferCount[OfferType] < 1) { -+ Private->OfferCount[OfferType] < 1) -+ { - // - // Only cache the first PXE10/WFM11a offer, and discard the others. - // -@@ -889,7 +882,6 @@ PxeBcCacheDhcp4Offer ( - return EFI_SUCCESS; - } - -- - /** - Select an DHCPv4 offer, and record SelectIndex and SelectProxyType. - -@@ -916,15 +908,14 @@ PxeBcSelectDhcp4Offer ( - // 1. DhcpPxe10 offer - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1; -- - } else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) { - // - // 2. DhcpWfm11a offer - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1; -- - } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 && -- Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) { -+ Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) -+ { - // - // 3. DhcpOnly offer and ProxyPxe10 offer. - // -@@ -1007,7 +998,6 @@ PxeBcSelectDhcp4Offer ( - } - } - -- - /** - Handle the DHCPv4 offer packet. - -@@ -1280,8 +1270,10 @@ PxeBcDhcp4CallBack ( - DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios table!\n")); - ZeroMem (Packet->Dhcp4.Header.ClientHwAddr, sizeof (EFI_GUID)); - } -+ - Packet->Dhcp4.Header.HwAddrLen = (UINT8) sizeof (EFI_GUID); - } -+ - break; - - case Dhcp4RcvdOffer: -@@ -1292,6 +1284,7 @@ PxeBcDhcp4CallBack ( - // - break; - } -+ - if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) { - // - // Cache the DHCPv4 offers to OfferBuffer[] for select later, and record -@@ -1300,6 +1293,7 @@ PxeBcDhcp4CallBack ( - // - PxeBcCacheDhcp4Offer (Private, Packet); - } -+ - break; - - case Dhcp4SelectOffer: -@@ -1316,6 +1310,7 @@ PxeBcDhcp4CallBack ( - } else { - *NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer; - } -+ - break; - - case Dhcp4RcvdAck: -@@ -1520,7 +1515,6 @@ PxeBcDhcp4Discover ( - } - - if (!EFI_ERROR (Status)) { -- - RepIndex = 0; - SrvIndex = 0; - Response = Token.ResponseList; -@@ -1539,10 +1533,13 @@ PxeBcDhcp4Discover ( - if (SrvList[SrvIndex].AcceptAnyResponse) { - break; - } -+ - if ((SrvList[SrvIndex].Type == Type) && -- EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr)) { -+ EFI_IP4_EQUAL (&Response->Dhcp4.Header.ServerAddr, &SrvList[SrvIndex].IpAddr)) -+ { - break; - } -+ - SrvIndex++; - } - -@@ -1565,6 +1562,7 @@ PxeBcDhcp4Discover ( - if (EFI_ERROR(Status)) { - goto ON_EXIT; - } -+ - CopyMem (&Mode->PxeDiscover, &Token.Packet->Dhcp4, Token.Packet->Length); - } else { - Status = PxeBcCacheDhcp4Packet (&Private->ProxyOffer.Dhcp4.Packet.Offer, Response); -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -index 0e2675be3c..d84aca7e85 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -@@ -10,8 +10,7 @@ - - #include "PxeBcImpl.h" - -- --EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = { - PxeBcIp4DriverBindingSupported, - PxeBcIp4DriverBindingStart, - PxeBcIp4DriverBindingStop, -@@ -20,7 +19,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = { - NULL - }; - --EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = { -+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = { - PxeBcIp6DriverBindingSupported, - PxeBcIp6DriverBindingStart, - PxeBcIp6DriverBindingStop, -@@ -39,10 +38,10 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = { - **/ - EFI_HANDLE - PxeBcGetNicByIp4Children ( -- IN EFI_HANDLE ControllerHandle -+ IN EFI_HANDLE ControllerHandle - ) - { -- EFI_HANDLE NicHandle; -+ EFI_HANDLE NicHandle; - - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); - if (NicHandle == NULL) { -@@ -64,7 +63,6 @@ PxeBcGetNicByIp4Children ( - return NicHandle; - } - -- - /** - Get the Nic handle using any child handle in the IPv6 stack. - -@@ -75,10 +73,10 @@ PxeBcGetNicByIp4Children ( - **/ - EFI_HANDLE - PxeBcGetNicByIp6Children ( -- IN EFI_HANDLE ControllerHandle -+ IN EFI_HANDLE ControllerHandle - ) - { -- EFI_HANDLE NicHandle; -+ EFI_HANDLE NicHandle; - - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid); - if (NicHandle == NULL) { -@@ -97,7 +95,6 @@ PxeBcGetNicByIp6Children ( - return NicHandle; - } - -- - /** - Destroy the opened instances based on IPv4. - -@@ -111,7 +108,7 @@ PxeBcDestroyIp4Children ( - IN PXEBC_PRIVATE_DATA *Private - ) - { -- ASSERT(Private != NULL); -+ ASSERT (Private != NULL); - - if (Private->ArpChild != NULL) { - // -@@ -175,11 +172,11 @@ PxeBcDestroyIp4Children ( - // Close Udp4 for PxeBc->UdpRead and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Udp4ReadChild, -- &gEfiUdp4ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Udp4ReadChild, -+ &gEfiUdp4ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -194,11 +191,11 @@ PxeBcDestroyIp4Children ( - // Close Mtftp4 for PxeBc->Mtftp4 and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Mtftp4Child, -- &gEfiMtftp4ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Mtftp4Child, -+ &gEfiMtftp4ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -213,11 +210,11 @@ PxeBcDestroyIp4Children ( - // Close Dhcp4 for PxeBc->Dhcp4 and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Dhcp4Child, -- &gEfiDhcp4ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Dhcp4Child, -+ &gEfiDhcp4ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -267,19 +264,19 @@ PxeBcDestroyIp4Children ( - Private->Snp - ); - } -+ - FreePool (Private->Ip4Nic); - } - -- Private->ArpChild = NULL; -- Private->Ip4Child = NULL; -- Private->Udp4WriteChild = NULL; -- Private->Udp4ReadChild = NULL; -- Private->Mtftp4Child = NULL; -- Private->Dhcp4Child = NULL; -- Private->Ip4Nic = NULL; -+ Private->ArpChild = NULL; -+ Private->Ip4Child = NULL; -+ Private->Udp4WriteChild = NULL; -+ Private->Udp4ReadChild = NULL; -+ Private->Mtftp4Child = NULL; -+ Private->Dhcp4Child = NULL; -+ Private->Ip4Nic = NULL; - } - -- - /** - Destroy the opened instances based on IPv6. - -@@ -293,18 +290,18 @@ PxeBcDestroyIp6Children ( - IN PXEBC_PRIVATE_DATA *Private - ) - { -- ASSERT(Private != NULL); -+ ASSERT (Private != NULL); - - if (Private->Ip6Child != NULL) { - // - // Close Ip6 for Ip6->Ip6Config and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Ip6Child, -- &gEfiIp6ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Ip6Child, -+ &gEfiIp6ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -337,11 +334,11 @@ PxeBcDestroyIp6Children ( - // Close Udp6 for PxeBc->UdpRead and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Udp6ReadChild, -- &gEfiUdp6ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Udp6ReadChild, -+ &gEfiUdp6ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - NetLibDestroyServiceChild ( - Private->Controller, - This->DriverBindingHandle, -@@ -355,11 +352,11 @@ PxeBcDestroyIp6Children ( - // Close Mtftp6 for PxeBc->Mtftp and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Mtftp6Child, -- &gEfiMtftp6ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Mtftp6Child, -+ &gEfiMtftp6ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -374,11 +371,11 @@ PxeBcDestroyIp6Children ( - // Close Dhcp6 for PxeBc->Dhcp and destroy the instance. - // - gBS->CloseProtocol ( -- Private->Dhcp6Child, -- &gEfiDhcp6ProtocolGuid, -- This->DriverBindingHandle, -- Private->Controller -- ); -+ Private->Dhcp6Child, -+ &gEfiDhcp6ProtocolGuid, -+ This->DriverBindingHandle, -+ Private->Controller -+ ); - - NetLibDestroyServiceChild ( - Private->Controller, -@@ -427,6 +424,7 @@ PxeBcDestroyIp6Children ( - Private->Snp - ); - } -+ - FreePool (Private->Ip6Nic); - } - -@@ -452,20 +450,20 @@ PxeBcDestroyIp6Children ( - **/ - EFI_STATUS - PxeBcCheckIpv6Support ( -- IN EFI_HANDLE ControllerHandle, -- IN PXEBC_PRIVATE_DATA *Private, -- OUT BOOLEAN *Ipv6Support -+ IN EFI_HANDLE ControllerHandle, -+ IN PXEBC_PRIVATE_DATA *Private, -+ OUT BOOLEAN *Ipv6Support - ) - { -- EFI_HANDLE Handle; -- EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; -- EFI_STATUS Status; -- EFI_GUID *InfoTypesBuffer; -- UINTN InfoTypeBufferCount; -- UINTN TypeIndex; -- BOOLEAN Supported; -- VOID *InfoBlock; -- UINTN InfoBlockSize; -+ EFI_HANDLE Handle; -+ EFI_ADAPTER_INFORMATION_PROTOCOL *Aip; -+ EFI_STATUS Status; -+ EFI_GUID *InfoTypesBuffer; -+ UINTN InfoTypeBufferCount; -+ UINTN TypeIndex; -+ BOOLEAN Supported; -+ VOID *InfoBlock; -+ UINTN InfoBlockSize; - - ASSERT (Private != NULL && Ipv6Support != NULL); - -@@ -493,16 +491,16 @@ PxeBcCheckIpv6Support ( - Status = gBS->HandleProtocol ( - Handle, - &gEfiAdapterInformationProtocolGuid, -- (VOID *) &Aip -+ (VOID *)&Aip - ); -- if (EFI_ERROR (Status) || Aip == NULL) { -+ if (EFI_ERROR (Status) || (Aip == NULL)) { - return EFI_NOT_FOUND; - } - - InfoTypesBuffer = NULL; - InfoTypeBufferCount = 0; -- Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); -- if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) { -+ Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount); -+ if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL)) { - FreePool (InfoTypesBuffer); - return EFI_NOT_FOUND; - } -@@ -525,16 +523,15 @@ PxeBcCheckIpv6Support ( - // - InfoBlock = NULL; - InfoBlockSize = 0; -- Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); -- if (EFI_ERROR (Status) || InfoBlock == NULL) { -+ Status = Aip->GetInformation (Aip, &gEfiAdapterInfoUndiIpv6SupportGuid, &InfoBlock, &InfoBlockSize); -+ if (EFI_ERROR (Status) || (InfoBlock == NULL)) { - FreePool (InfoBlock); - return EFI_NOT_FOUND; - } - -- *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support; -+ *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *)InfoBlock)->Ipv6Support; - FreePool (InfoBlock); - return EFI_SUCCESS; -- - } - - /** -@@ -555,14 +552,14 @@ PxeBcCreateIp4Children ( - IN PXEBC_PRIVATE_DATA *Private - ) - { -- EFI_STATUS Status; -- IPv4_DEVICE_PATH Ip4Node; -- EFI_PXE_BASE_CODE_MODE *Mode; -- EFI_UDP4_CONFIG_DATA *Udp4CfgData; -- EFI_IP4_CONFIG_DATA *Ip4CfgData; -- EFI_IP4_MODE_DATA Ip4ModeData; -- PXEBC_PRIVATE_PROTOCOL *Id; -- EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -+ EFI_STATUS Status; -+ IPv4_DEVICE_PATH Ip4Node; -+ EFI_PXE_BASE_CODE_MODE *Mode; -+ EFI_UDP4_CONFIG_DATA *Udp4CfgData; -+ EFI_IP4_CONFIG_DATA *Ip4CfgData; -+ EFI_IP4_MODE_DATA Ip4ModeData; -+ PXEBC_PRIVATE_PROTOCOL *Id; -+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp; - - if (Private->Ip4Nic != NULL) { - // -@@ -587,7 +584,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Dhcp4Child, - &gEfiDhcp4ProtocolGuid, -- (VOID **) &Private->Dhcp4, -+ (VOID **)&Private->Dhcp4, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -612,7 +609,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Mtftp4Child, - &gEfiMtftp4ProtocolGuid, -- (VOID **) &Private->Mtftp4, -+ (VOID **)&Private->Mtftp4, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -637,7 +634,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Udp4ReadChild, - &gEfiUdp4ProtocolGuid, -- (VOID **) &Private->Udp4Read, -+ (VOID **)&Private->Udp4Read, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -662,7 +659,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Udp4WriteChild, - &gEfiUdp4ProtocolGuid, -- (VOID **) &Private->Udp4Write, -+ (VOID **)&Private->Udp4Write, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -687,7 +684,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->ArpChild, - &gEfiArpProtocolGuid, -- (VOID **) &Private->Arp, -+ (VOID **)&Private->Arp, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -712,7 +709,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Ip4Child, - &gEfiIp4ProtocolGuid, -- (VOID **) &Private->Ip4, -+ (VOID **)&Private->Ip4, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -739,13 +736,13 @@ PxeBcCreateIp4Children ( - Private->Ip4Nic->Private = Private; - Private->Ip4Nic->Signature = PXEBC_VIRTUAL_NIC_SIGNATURE; - -- // -+ // - // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy. - // - Status = gBS->HandleProtocol ( - ControllerHandle, - &gEfiIp4Config2ProtocolGuid, -- (VOID **) &Private->Ip4Config2 -+ (VOID **)&Private->Ip4Config2 - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; -@@ -814,7 +811,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - Private->Ip4Nic->Controller, - &gEfiSimpleNetworkProtocolGuid, -- (VOID **) &Snp, -+ (VOID **)&Snp, - This->DriverBindingHandle, - Private->Ip4Nic->Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE -@@ -831,7 +828,7 @@ PxeBcCreateIp4Children ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiCallerIdGuid, -- (VOID **) &Id, -+ (VOID **)&Id, - This->DriverBindingHandle, - Private->Ip4Nic->Controller, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -843,9 +840,9 @@ PxeBcCreateIp4Children ( - // - // Set default configure data for Udp4Read and Ip4 instance. - // -- Mode = Private->PxeBc.Mode; -- Udp4CfgData = &Private->Udp4CfgData; -- Ip4CfgData = &Private->Ip4CfgData; -+ Mode = Private->PxeBc.Mode; -+ Udp4CfgData = &Private->Udp4CfgData; -+ Ip4CfgData = &Private->Ip4CfgData; - - Udp4CfgData->AcceptBroadcast = FALSE; - Udp4CfgData->AcceptAnyPort = TRUE; -@@ -855,12 +852,12 @@ PxeBcCreateIp4Children ( - Udp4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; - Udp4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; - -- Ip4CfgData->AcceptIcmpErrors = TRUE; -- Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP; -- Ip4CfgData->TypeOfService = Mode->ToS; -- Ip4CfgData->TimeToLive = Mode->TTL; -- Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; -- Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; -+ Ip4CfgData->AcceptIcmpErrors = TRUE; -+ Ip4CfgData->DefaultProtocol = EFI_IP_PROTO_ICMP; -+ Ip4CfgData->TypeOfService = Mode->ToS; -+ Ip4CfgData->TimeToLive = Mode->TTL; -+ Ip4CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; -+ Ip4CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; - - return EFI_SUCCESS; - -@@ -869,7 +866,6 @@ ON_ERROR: - return Status; - } - -- - /** - Create the opened instances based on IPv6. - -@@ -888,14 +884,14 @@ PxeBcCreateIp6Children ( - IN PXEBC_PRIVATE_DATA *Private - ) - { -- EFI_STATUS Status; -- IPv6_DEVICE_PATH Ip6Node; -- EFI_UDP6_CONFIG_DATA *Udp6CfgData; -- EFI_IP6_CONFIG_DATA *Ip6CfgData; -- EFI_IP6_MODE_DATA Ip6ModeData; -- PXEBC_PRIVATE_PROTOCOL *Id; -- EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -- UINTN Index; -+ EFI_STATUS Status; -+ IPv6_DEVICE_PATH Ip6Node; -+ EFI_UDP6_CONFIG_DATA *Udp6CfgData; -+ EFI_IP6_CONFIG_DATA *Ip6CfgData; -+ EFI_IP6_MODE_DATA Ip6ModeData; -+ PXEBC_PRIVATE_PROTOCOL *Id; -+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp; -+ UINTN Index; - - if (Private->Ip6Nic != NULL) { - // -@@ -929,7 +925,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Dhcp6Child, - &gEfiDhcp6ProtocolGuid, -- (VOID **) &Private->Dhcp6, -+ (VOID **)&Private->Dhcp6, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -964,7 +960,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Mtftp6Child, - &gEfiMtftp6ProtocolGuid, -- (VOID **) &Private->Mtftp6, -+ (VOID **)&Private->Mtftp6, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -989,7 +985,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Udp6ReadChild, - &gEfiUdp6ProtocolGuid, -- (VOID **) &Private->Udp6Read, -+ (VOID **)&Private->Udp6Read, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -1014,7 +1010,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Udp6WriteChild, - &gEfiUdp6ProtocolGuid, -- (VOID **) &Private->Udp6Write, -+ (VOID **)&Private->Udp6Write, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -1039,7 +1035,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Ip6Child, - &gEfiIp6ProtocolGuid, -- (VOID **) &Private->Ip6, -+ (VOID **)&Private->Ip6, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -1088,7 +1084,7 @@ PxeBcCreateIp6Children ( - Status = gBS->HandleProtocol ( - ControllerHandle, - &gEfiIp6ConfigProtocolGuid, -- (VOID **) &Private->Ip6Cfg -+ (VOID **)&Private->Ip6Cfg - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; -@@ -1098,9 +1094,9 @@ PxeBcCreateIp6Children ( - // Create a device path node for Ipv6 virtual nic, and append it. - // - ZeroMem (&Ip6Node, sizeof (IPv6_DEVICE_PATH)); -- Ip6Node.Header.Type = MESSAGING_DEVICE_PATH; -- Ip6Node.Header.SubType = MSG_IPv6_DP; -- Ip6Node.PrefixLength = IP6_PREFIX_LENGTH; -+ Ip6Node.Header.Type = MESSAGING_DEVICE_PATH; -+ Ip6Node.Header.SubType = MSG_IPv6_DP; -+ Ip6Node.PrefixLength = IP6_PREFIX_LENGTH; - - SetDevicePathNodeLength (&Ip6Node.Header, sizeof (Ip6Node)); - -@@ -1157,7 +1153,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - Private->Ip6Nic->Controller, - &gEfiSimpleNetworkProtocolGuid, -- (VOID **) &Snp, -+ (VOID **)&Snp, - This->DriverBindingHandle, - Private->Ip6Nic->Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE -@@ -1174,7 +1170,7 @@ PxeBcCreateIp6Children ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiCallerIdGuid, -- (VOID **) &Id, -+ (VOID **)&Id, - This->DriverBindingHandle, - Private->Ip6Nic->Controller, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER -@@ -1192,15 +1188,15 @@ PxeBcCreateIp6Children ( - // - // Fail to get the data whether UNDI supports IPv6. Set default value. - // -- Private->Mode.Ipv6Available = TRUE; -+ Private->Mode.Ipv6Available = TRUE; - } - - if (!Private->Mode.Ipv6Available) { - goto ON_ERROR; - } - -- Udp6CfgData = &Private->Udp6CfgData; -- Ip6CfgData = &Private->Ip6CfgData; -+ Udp6CfgData = &Private->Udp6CfgData; -+ Ip6CfgData = &Private->Ip6CfgData; - - Udp6CfgData->AcceptAnyPort = TRUE; - Udp6CfgData->AllowDuplicatePort = TRUE; -@@ -1208,11 +1204,11 @@ PxeBcCreateIp6Children ( - Udp6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; - Udp6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; - -- Ip6CfgData->AcceptIcmpErrors = TRUE; -- Ip6CfgData->DefaultProtocol = IP6_ICMP; -- Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT; -- Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; -- Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; -+ Ip6CfgData->AcceptIcmpErrors = TRUE; -+ Ip6CfgData->DefaultProtocol = IP6_ICMP; -+ Ip6CfgData->HopLimit = PXEBC_DEFAULT_HOPLIMIT; -+ Ip6CfgData->ReceiveTimeout = PXEBC_DEFAULT_LIFETIME; -+ Ip6CfgData->TransmitTimeout = PXEBC_DEFAULT_LIFETIME; - - return EFI_SUCCESS; - -@@ -1221,7 +1217,6 @@ ON_ERROR: - return Status; - } - -- - /** - The entry point for UefiPxeBc driver that installs the driver - binding and component name protocol on its image. -@@ -1236,13 +1231,13 @@ ON_ERROR: - EFI_STATUS - EFIAPI - PxeBcDriverEntryPoint ( -- IN EFI_HANDLE ImageHandle, -- IN EFI_SYSTEM_TABLE *SystemTable -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable - ) - { - EFI_STATUS Status; - -- if ((PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED)) { -+ if ((PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED)) { - return EFI_UNSUPPORTED; - } - -@@ -1300,20 +1295,22 @@ PxeBcSupported ( - IN UINT8 IpVersion - ) - { -- EFI_STATUS Status; -- EFI_GUID *DhcpServiceBindingGuid; -- EFI_GUID *MtftpServiceBindingGuid; -+ EFI_STATUS Status; -+ EFI_GUID *DhcpServiceBindingGuid; -+ EFI_GUID *MtftpServiceBindingGuid; - - if (IpVersion == IP_VERSION_4) { -- if (PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) { -+ if (PcdGet8 (PcdIPv4PXESupport) == PXE_DISABLED) { - return EFI_UNSUPPORTED; - } -+ - DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid; - MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid; - } else { -- if (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED) { -+ if (PcdGet8 (PcdIPv6PXESupport) == PXE_DISABLED) { - return EFI_UNSUPPORTED; - } -+ - DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid; - MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid; - } -@@ -1322,22 +1319,22 @@ PxeBcSupported ( - // Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready. - // - Status = gBS->OpenProtocol ( -- ControllerHandle, -- DhcpServiceBindingGuid, -- NULL, -- This->DriverBindingHandle, -- ControllerHandle, -- EFI_OPEN_PROTOCOL_TEST_PROTOCOL -- ); -+ ControllerHandle, -+ DhcpServiceBindingGuid, -+ NULL, -+ This->DriverBindingHandle, -+ ControllerHandle, -+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL -+ ); - if (!EFI_ERROR (Status)) { - Status = gBS->OpenProtocol ( -- ControllerHandle, -- MtftpServiceBindingGuid, -- NULL, -- This->DriverBindingHandle, -- ControllerHandle, -- EFI_OPEN_PROTOCOL_TEST_PROTOCOL -- ); -+ ControllerHandle, -+ MtftpServiceBindingGuid, -+ NULL, -+ This->DriverBindingHandle, -+ ControllerHandle, -+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL -+ ); - } - - // -@@ -1375,20 +1372,20 @@ PxeBcStart ( - IN UINT8 IpVersion - ) - { -- PXEBC_PRIVATE_DATA *Private; -- EFI_STATUS Status; -- PXEBC_PRIVATE_PROTOCOL *Id; -- BOOLEAN FirstStart; -+ PXEBC_PRIVATE_DATA *Private; -+ EFI_STATUS Status; -+ PXEBC_PRIVATE_PROTOCOL *Id; -+ BOOLEAN FirstStart; - - FirstStart = FALSE; -- Status = gBS->OpenProtocol ( -- ControllerHandle, -- &gEfiCallerIdGuid, -- (VOID **) &Id, -- This->DriverBindingHandle, -- ControllerHandle, -- EFI_OPEN_PROTOCOL_GET_PROTOCOL -- ); -+ Status = gBS->OpenProtocol ( -+ ControllerHandle, -+ &gEfiCallerIdGuid, -+ (VOID **)&Id, -+ This->DriverBindingHandle, -+ ControllerHandle, -+ EFI_OPEN_PROTOCOL_GET_PROTOCOL -+ ); - if (!EFI_ERROR (Status)) { - // - // Skip the initialization if the driver has been started already. -@@ -1425,7 +1422,7 @@ PxeBcStart ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, -- (VOID **) &Private->DevicePath, -+ (VOID **)&Private->DevicePath, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1441,7 +1438,7 @@ PxeBcStart ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, -- (VOID **) &Private->Nii, -+ (VOID **)&Private->Nii, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1469,7 +1466,7 @@ PxeBcStart ( - // - // Try to locate SNP protocol. - // -- NetLibGetSnpHandle(ControllerHandle, &Private->Snp); -+ NetLibGetSnpHandle (ControllerHandle, &Private->Snp); - } - - if (IpVersion == IP_VERSION_4) { -@@ -1483,6 +1480,7 @@ PxeBcStart ( - // - Status = PxeBcCreateIp6Children (This, ControllerHandle, Private); - } -+ - if (EFI_ERROR (Status)) { - // - // Failed to start PXE driver if IPv4 and IPv6 stack are both not available. -@@ -1508,14 +1506,13 @@ ON_ERROR: - PxeBcDestroyIp6Children (This, Private); - } - -- if (FirstStart && Private != NULL) { -+ if (FirstStart && (Private != NULL)) { - FreePool (Private); - } - - return Status; - } - -- - /** - Stop this driver on ControllerHandle. This is the worker function for - PxeBcIp4(6)DriverBindingStop. -@@ -1542,12 +1539,12 @@ PxeBcStop ( - IN UINT8 IpVersion - ) - { -- PXEBC_PRIVATE_DATA *Private; -- PXEBC_VIRTUAL_NIC *VirtualNic; -- EFI_LOAD_FILE_PROTOCOL *LoadFile; -- EFI_STATUS Status; -- EFI_HANDLE NicHandle; -- PXEBC_PRIVATE_PROTOCOL *Id; -+ PXEBC_PRIVATE_DATA *Private; -+ PXEBC_VIRTUAL_NIC *VirtualNic; -+ EFI_LOAD_FILE_PROTOCOL *LoadFile; -+ EFI_STATUS Status; -+ EFI_HANDLE NicHandle; -+ PXEBC_PRIVATE_PROTOCOL *Id; - - Private = NULL; - NicHandle = NULL; -@@ -1558,7 +1555,7 @@ PxeBcStop ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiLoadFileProtocolGuid, -- (VOID **) &LoadFile, -+ (VOID **)&LoadFile, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1572,6 +1569,7 @@ PxeBcStop ( - } else { - NicHandle = PxeBcGetNicByIp6Children (ControllerHandle); - } -+ - if (NicHandle == NULL) { - return EFI_SUCCESS; - } -@@ -1582,7 +1580,7 @@ PxeBcStop ( - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiCallerIdGuid, -- (VOID **) &Id, -+ (VOID **)&Id, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1590,8 +1588,8 @@ PxeBcStop ( - if (EFI_ERROR (Status)) { - return Status; - } -- Private = PXEBC_PRIVATE_DATA_FROM_ID (Id); - -+ Private = PXEBC_PRIVATE_DATA_FROM_ID (Id); - } else { - // - // It's a virtual handle with LoadFileProtocol. -@@ -1599,7 +1597,7 @@ PxeBcStop ( - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiLoadFileProtocolGuid, -- (VOID **) &LoadFile, -+ (VOID **)&LoadFile, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL -@@ -1617,20 +1615,19 @@ PxeBcStop ( - // Stop functionality of PXE Base Code protocol - // - Status = Private->PxeBc.Stop (&Private->PxeBc); -- if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) { -+ if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_STARTED)) { - return Status; - } - -- -- if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) { -+ if ((Private->Ip4Nic != NULL) && (IpVersion == IP_VERSION_4)) { - PxeBcDestroyIp4Children (This, Private); - } - -- if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) { -+ if ((Private->Ip6Nic != NULL) && (IpVersion == IP_VERSION_6)) { - PxeBcDestroyIp6Children (This, Private); - } - -- if (Private->Ip4Nic == NULL && Private->Ip6Nic == NULL) { -+ if ((Private->Ip4Nic == NULL) && (Private->Ip6Nic == NULL)) { - gBS->UninstallProtocolInterface ( - NicHandle, - &gEfiCallerIdGuid, --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.patch b/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.patch deleted file mode 100644 index 2bf3ddf..0000000 --- a/SOURCES/edk2-NetworkPkg-Apply-uncrustify-changes.patch +++ /dev/null @@ -1,1937 +0,0 @@ -From daa72dcc870f9488f2afccdaa2341f24b1269abc Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 15:22:22 -0500 -Subject: [PATCH 06/15] NetworkPkg: Apply uncrustify changes - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [6/15] 823604dd0cad46a8ae5796cde6d1683aa23f1be5 - -JIRA: https://issues.redhat.com/browse/RHEL-21850 -CVE: CVE-2022-45234 -Upstream: Merged -Conflicts: This patch is too intrusive to apply at once in its entirety, - but we can apply a subset touching only the file being - targeted in the next commit in this series. - This way, that commit applies cleanly. - -commit d1050b9dff1cace252aff86630bfdb59dff5f507 -Author: Michael Kubacki -Date: Sun Dec 5 14:54:07 2021 -0800 - - NetworkPkg: Apply uncrustify changes - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 - - Apply uncrustify changes to .c/.h files in the NetworkPkg package - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael D Kinney - Signed-off-by: Michael Kubacki - Reviewed-by: Maciej Rabeda - -Signed-off-by: Jon Maloy ---- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 973 ++++++++++++++------------- - 1 file changed, 498 insertions(+), 475 deletions(-) - -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -index 8d71143b79..425e0cf806 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -@@ -15,7 +15,9 @@ - // - // ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2 - // --EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2}}; -+EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = { -+ { 0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2 } -+}; - - /** - Parse out a DHCPv6 option by OptTag, and find the position in buffer. -@@ -30,35 +32,32 @@ EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, - **/ - EFI_DHCP6_PACKET_OPTION * - PxeBcParseDhcp6Options ( -- IN UINT8 *Buffer, -- IN UINT32 Length, -- IN UINT16 OptTag -+ IN UINT8 *Buffer, -+ IN UINT32 Length, -+ IN UINT16 OptTag - ) - { -- EFI_DHCP6_PACKET_OPTION *Option; -- UINT32 Offset; -+ EFI_DHCP6_PACKET_OPTION *Option; -+ UINT32 Offset; - -- Option = (EFI_DHCP6_PACKET_OPTION *) Buffer; -- Offset = 0; -+ Option = (EFI_DHCP6_PACKET_OPTION *)Buffer; -+ Offset = 0; - - // - // OpLen and OpCode here are both stored in network order. - // - while (Offset < Length) { -- - if (NTOHS (Option->OpCode) == OptTag) { -- - return Option; - } - -- Offset += (NTOHS(Option->OpLen) + 4); -- Option = (EFI_DHCP6_PACKET_OPTION *) (Buffer + Offset); -+ Offset += (NTOHS (Option->OpLen) + 4); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Buffer + Offset); - } - - return NULL; - } - -- - /** - Build the options buffer for the DHCPv6 request packet. - -@@ -71,70 +70,70 @@ PxeBcParseDhcp6Options ( - **/ - UINT32 - PxeBcBuildDhcp6Options ( -- IN PXEBC_PRIVATE_DATA *Private, -- OUT EFI_DHCP6_PACKET_OPTION **OptList, -- IN UINT8 *Buffer -+ IN PXEBC_PRIVATE_DATA *Private, -+ OUT EFI_DHCP6_PACKET_OPTION **OptList, -+ IN UINT8 *Buffer - ) - { -- PXEBC_DHCP6_OPTION_ENTRY OptEnt; -- UINT32 Index; -- UINT16 Value; -+ PXEBC_DHCP6_OPTION_ENTRY OptEnt; -+ UINT32 Index; -+ UINT16 Value; - -- Index = 0; -- OptList[0] = (EFI_DHCP6_PACKET_OPTION *) Buffer; -+ Index = 0; -+ OptList[0] = (EFI_DHCP6_PACKET_OPTION *)Buffer; - - // - // Append client option request option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); -- OptList[Index]->OpLen = HTONS (8); -- OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data; -- OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL); -- OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM); -- OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS); -- OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS); -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO); -+ OptList[Index]->OpLen = HTONS (8); -+ OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *)OptList[Index]->Data; -+ OptEnt.Oro->OpCode[0] = HTONS (DHCP6_OPT_BOOT_FILE_URL); -+ OptEnt.Oro->OpCode[1] = HTONS (DHCP6_OPT_BOOT_FILE_PARAM); -+ OptEnt.Oro->OpCode[2] = HTONS (DHCP6_OPT_DNS_SERVERS); -+ OptEnt.Oro->OpCode[3] = HTONS (DHCP6_OPT_VENDOR_CLASS); - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append client network device interface option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); -- OptList[Index]->OpLen = HTONS ((UINT16)3); -- OptEnt.Undi = (PXEBC_DHCP6_OPTION_UNDI *) OptList[Index]->Data; -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_UNDI); -+ OptList[Index]->OpLen = HTONS ((UINT16)3); -+ OptEnt.Undi = (PXEBC_DHCP6_OPTION_UNDI *)OptList[Index]->Data; - - if (Private->Nii != NULL) { -- OptEnt.Undi->Type = Private->Nii->Type; -- OptEnt.Undi->MajorVer = Private->Nii->MajorVer; -- OptEnt.Undi->MinorVer = Private->Nii->MinorVer; -+ OptEnt.Undi->Type = Private->Nii->Type; -+ OptEnt.Undi->MajorVer = Private->Nii->MajorVer; -+ OptEnt.Undi->MinorVer = Private->Nii->MinorVer; - } else { -- OptEnt.Undi->Type = DEFAULT_UNDI_TYPE; -- OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR; -- OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR; -+ OptEnt.Undi->Type = DEFAULT_UNDI_TYPE; -+ OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR; -+ OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR; - } - - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append client system architecture option - // -- OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); -- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_ARCH)); -- OptEnt.Arch = (PXEBC_DHCP6_OPTION_ARCH *) OptList[Index]->Data; -- Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE); -+ OptList[Index]->OpCode = HTONS (DHCP6_OPT_ARCH); -+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_ARCH)); -+ OptEnt.Arch = (PXEBC_DHCP6_OPTION_ARCH *)OptList[Index]->Data; -+ Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE); - CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16)); - Index++; -- OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); -+ OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]); - - // - // Append vendor class option to store the PXE class identifier. - // - OptList[Index]->OpCode = HTONS (DHCP6_OPT_VENDOR_CLASS); -- OptList[Index]->OpLen = HTONS ((UINT16) sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS)); -- OptEnt.VendorClass = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *) OptList[Index]->Data; -+ OptList[Index]->OpLen = HTONS ((UINT16)sizeof (PXEBC_DHCP6_OPTION_VENDOR_CLASS)); -+ OptEnt.VendorClass = (PXEBC_DHCP6_OPTION_VENDOR_CLASS *)OptList[Index]->Data; - OptEnt.VendorClass->Vendor = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM); -- OptEnt.VendorClass->ClassLen = HTONS ((UINT16) sizeof (PXEBC_CLASS_ID)); -+ OptEnt.VendorClass->ClassLen = HTONS ((UINT16)sizeof (PXEBC_CLASS_ID)); - CopyMem ( - &OptEnt.VendorClass->ClassId, - DEFAULT_CLASS_ID_DATA, -@@ -169,7 +168,6 @@ PxeBcBuildDhcp6Options ( - return Index; - } - -- - /** - Cache the DHCPv6 packet. - -@@ -182,8 +180,8 @@ PxeBcBuildDhcp6Options ( - **/ - EFI_STATUS - PxeBcCacheDhcp6Packet ( -- IN EFI_DHCP6_PACKET *Dst, -- IN EFI_DHCP6_PACKET *Src -+ IN EFI_DHCP6_PACKET *Dst, -+ IN EFI_DHCP6_PACKET *Src - ) - { - if (Dst->Size < Src->Length) { -@@ -211,22 +209,22 @@ PxeBcCacheDhcp6Packet ( - **/ - EFI_STATUS - PxeBcDns6 ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN CHAR16 *HostName, -- OUT EFI_IPv6_ADDRESS *IpAddress -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN CHAR16 *HostName, -+ OUT EFI_IPv6_ADDRESS *IpAddress - ) - { -- EFI_STATUS Status; -- EFI_DNS6_PROTOCOL *Dns6; -- EFI_DNS6_CONFIG_DATA Dns6ConfigData; -- EFI_DNS6_COMPLETION_TOKEN Token; -- EFI_HANDLE Dns6Handle; -- EFI_IPv6_ADDRESS *DnsServerList; -- BOOLEAN IsDone; -- -- Dns6 = NULL; -- Dns6Handle = NULL; -- DnsServerList = Private->DnsServer; -+ EFI_STATUS Status; -+ EFI_DNS6_PROTOCOL *Dns6; -+ EFI_DNS6_CONFIG_DATA Dns6ConfigData; -+ EFI_DNS6_COMPLETION_TOKEN Token; -+ EFI_HANDLE Dns6Handle; -+ EFI_IPv6_ADDRESS *DnsServerList; -+ BOOLEAN IsDone; -+ -+ Dns6 = NULL; -+ Dns6Handle = NULL; -+ DnsServerList = Private->DnsServer; - ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN)); - - // -@@ -245,7 +243,7 @@ PxeBcDns6 ( - Status = gBS->OpenProtocol ( - Dns6Handle, - &gEfiDns6ProtocolGuid, -- (VOID **) &Dns6, -+ (VOID **)&Dns6, - Private->Image, - Private->Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER -@@ -308,10 +306,12 @@ PxeBcDns6 ( - Status = EFI_DEVICE_ERROR; - goto Exit; - } -- if (Token.RspData.H2AData->IpCount == 0 || Token.RspData.H2AData->IpList == NULL) { -+ -+ if ((Token.RspData.H2AData->IpCount == 0) || (Token.RspData.H2AData->IpList == NULL)) { - Status = EFI_DEVICE_ERROR; - goto Exit; - } -+ - // - // We just return the first IPv6 address from DNS protocol. - // -@@ -325,10 +325,12 @@ Exit: - if (Token.Event != NULL) { - gBS->CloseEvent (Token.Event); - } -+ - if (Token.RspData.H2AData != NULL) { - if (Token.RspData.H2AData->IpList != NULL) { - FreePool (Token.RspData.H2AData->IpList); - } -+ - FreePool (Token.RspData.H2AData); - } - -@@ -375,26 +377,26 @@ Exit: - **/ - EFI_STATUS - PxeBcExtractBootFileUrl ( -- IN PXEBC_PRIVATE_DATA *Private, -- OUT UINT8 **FileName, -- IN OUT EFI_IPv6_ADDRESS *SrvAddr, -- IN CHAR8 *BootFile, -- IN UINT16 Length -+ IN PXEBC_PRIVATE_DATA *Private, -+ OUT UINT8 **FileName, -+ IN OUT EFI_IPv6_ADDRESS *SrvAddr, -+ IN CHAR8 *BootFile, -+ IN UINT16 Length - ) - { -- UINT16 PrefixLen; -- CHAR8 *BootFileNamePtr; -- CHAR8 *BootFileName; -- UINT16 BootFileNameLen; -- CHAR8 *TmpStr; -- CHAR8 TmpChar; -- CHAR8 *ServerAddressOption; -- CHAR8 *ServerAddress; -- CHAR8 *ModeStr; -- CHAR16 *HostName; -- BOOLEAN IpExpressedUrl; -- UINTN Len; -- EFI_STATUS Status; -+ UINT16 PrefixLen; -+ CHAR8 *BootFileNamePtr; -+ CHAR8 *BootFileName; -+ UINT16 BootFileNameLen; -+ CHAR8 *TmpStr; -+ CHAR8 TmpChar; -+ CHAR8 *ServerAddressOption; -+ CHAR8 *ServerAddress; -+ CHAR8 *ModeStr; -+ CHAR16 *HostName; -+ BOOLEAN IpExpressedUrl; -+ UINTN Len; -+ EFI_STATUS Status; - - IpExpressedUrl = TRUE; - // -@@ -417,17 +419,18 @@ PxeBcExtractBootFileUrl ( - // As an example where the BOOTFILE_NAME is the EFI loader and - // SERVER_ADDRESS is the ASCII encoding of an IPV6 address. - // -- PrefixLen = (UINT16) AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX); -+ PrefixLen = (UINT16)AsciiStrLen (PXEBC_DHCP6_BOOT_FILE_URL_PREFIX); - -- if (Length <= PrefixLen || -- CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0) { -+ if ((Length <= PrefixLen) || -+ (CompareMem (BootFile, PXEBC_DHCP6_BOOT_FILE_URL_PREFIX, PrefixLen) != 0)) -+ { - return EFI_NOT_FOUND; - } - - BootFile = BootFile + PrefixLen; -- Length = (UINT16) (Length - PrefixLen); -+ Length = (UINT16)(Length - PrefixLen); - -- TmpStr = (CHAR8 *) AllocateZeroPool (Length + 1); -+ TmpStr = (CHAR8 *)AllocateZeroPool (Length + 1); - if (TmpStr == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -440,7 +443,7 @@ PxeBcExtractBootFileUrl ( - // - ServerAddressOption = TmpStr; - if (*ServerAddressOption == PXEBC_ADDR_START_DELIMITER) { -- ServerAddressOption ++; -+ ServerAddressOption++; - ServerAddress = ServerAddressOption; - while (*ServerAddress != '\0' && *ServerAddress != PXEBC_ADDR_END_DELIMITER) { - ServerAddress++; -@@ -461,10 +464,9 @@ PxeBcExtractBootFileUrl ( - FreePool (TmpStr); - return Status; - } -- - } else { - IpExpressedUrl = FALSE; -- ServerAddress = ServerAddressOption; -+ ServerAddress = ServerAddressOption; - while (*ServerAddress != '\0' && *ServerAddress != PXEBC_TFTP_URL_SEPARATOR) { - ServerAddress++; - } -@@ -473,14 +475,16 @@ PxeBcExtractBootFileUrl ( - FreePool (TmpStr); - return EFI_INVALID_PARAMETER; - } -+ - *ServerAddress = '\0'; - -- Len = AsciiStrSize (ServerAddressOption); -+ Len = AsciiStrSize (ServerAddressOption); - HostName = AllocateZeroPool (Len * sizeof (CHAR16)); - if (HostName == NULL) { - FreePool (TmpStr); - return EFI_OUT_OF_RESOURCES; - } -+ - AsciiStrToUnicodeStrS ( - ServerAddressOption, - HostName, -@@ -490,7 +494,7 @@ PxeBcExtractBootFileUrl ( - // - // Perform DNS resolution. - // -- Status = PxeBcDns6 (Private,HostName, SrvAddr); -+ Status = PxeBcDns6 (Private, HostName, SrvAddr); - if (EFI_ERROR (Status)) { - FreePool (TmpStr); - return Status; -@@ -500,23 +504,24 @@ PxeBcExtractBootFileUrl ( - // - // Get the part of BOOTFILE_NAME string. - // -- BootFileNamePtr = (CHAR8*)((UINTN)ServerAddress + 1); -+ BootFileNamePtr = (CHAR8 *)((UINTN)ServerAddress + 1); - if (IpExpressedUrl) { - if (*BootFileNamePtr != PXEBC_TFTP_URL_SEPARATOR) { - FreePool (TmpStr); - return EFI_INVALID_PARAMETER; - } -+ - ++BootFileNamePtr; - } - -- BootFileNameLen = (UINT16)(Length - (UINT16) ((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1); -- if (BootFileNameLen != 0 || FileName != NULL) { -+ BootFileNameLen = (UINT16)(Length - (UINT16)((UINTN)BootFileNamePtr - (UINTN)TmpStr) + 1); -+ if ((BootFileNameLen != 0) || (FileName != NULL)) { - // - // Remove trailing mode=octet if present and ignore. All other modes are - // invalid for netboot6, so reject them. - // - ModeStr = AsciiStrStr (BootFileNamePtr, ";mode=octet"); -- if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') { -+ if ((ModeStr != NULL) && (*(ModeStr + AsciiStrLen (";mode=octet")) == '\0')) { - *ModeStr = '\0'; - } else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) { - FreePool (TmpStr); -@@ -526,30 +531,32 @@ PxeBcExtractBootFileUrl ( - // - // Extract boot file name from URL. - // -- BootFileName = (CHAR8 *) AllocateZeroPool (BootFileNameLen); -+ BootFileName = (CHAR8 *)AllocateZeroPool (BootFileNameLen); - if (BootFileName == NULL) { - FreePool (TmpStr); - return EFI_OUT_OF_RESOURCES; - } -- *FileName = (UINT8*) BootFileName; -+ -+ *FileName = (UINT8 *)BootFileName; - - // - // Decode percent-encoding in boot file name. - // - while (*BootFileNamePtr != '\0') { - if (*BootFileNamePtr == '%') { -- TmpChar = *(BootFileNamePtr+ 3); -+ TmpChar = *(BootFileNamePtr+ 3); - *(BootFileNamePtr+ 3) = '\0'; -- *BootFileName = (UINT8) AsciiStrHexToUintn ((CHAR8*)(BootFileNamePtr + 1)); -+ *BootFileName = (UINT8)AsciiStrHexToUintn ((CHAR8 *)(BootFileNamePtr + 1)); - BootFileName++; - *(BootFileNamePtr+ 3) = TmpChar; -- BootFileNamePtr += 3; -+ BootFileNamePtr += 3; - } else { - *BootFileName = *BootFileNamePtr; - BootFileName++; - BootFileNamePtr++; - } - } -+ - *BootFileName = '\0'; - } - -@@ -558,7 +565,6 @@ PxeBcExtractBootFileUrl ( - return EFI_SUCCESS; - } - -- - /** - Parse the Boot File Parameter option. - -@@ -571,14 +577,14 @@ PxeBcExtractBootFileUrl ( - **/ - EFI_STATUS - PxeBcExtractBootFileParam ( -- IN CHAR8 *BootFilePara, -- OUT UINT16 *BootFileSize -+ IN CHAR8 *BootFilePara, -+ OUT UINT16 *BootFileSize - ) - { -- UINT16 Length; -- UINT8 Index; -- UINT8 Digit; -- UINT32 Size; -+ UINT16 Length; -+ UINT8 Index; -+ UINT8 Digit; -+ UINT32 Size; - - CopyMem (&Length, BootFilePara, sizeof (UINT16)); - Length = NTOHS (Length); -@@ -586,7 +592,7 @@ PxeBcExtractBootFileParam ( - // - // The BootFile Size should be 1~5 byte ASCII strings - // -- if (Length < 1 || Length > 5) { -+ if ((Length < 1) || (Length > 5)) { - return EFI_NOT_FOUND; - } - -@@ -608,11 +614,10 @@ PxeBcExtractBootFileParam ( - return EFI_NOT_FOUND; - } - -- *BootFileSize = (UINT16) Size; -+ *BootFileSize = (UINT16)Size; - return EFI_SUCCESS; - } - -- - /** - Parse the cached DHCPv6 packet, including all the options. - -@@ -627,15 +632,15 @@ PxeBcParseDhcp6Packet ( - IN PXEBC_DHCP6_PACKET_CACHE *Cache6 - ) - { -- EFI_DHCP6_PACKET *Offer; -- EFI_DHCP6_PACKET_OPTION **Options; -- EFI_DHCP6_PACKET_OPTION *Option; -- PXEBC_OFFER_TYPE OfferType; -- BOOLEAN IsProxyOffer; -- BOOLEAN IsPxeOffer; -- UINT32 Offset; -- UINT32 Length; -- UINT32 EnterpriseNum; -+ EFI_DHCP6_PACKET *Offer; -+ EFI_DHCP6_PACKET_OPTION **Options; -+ EFI_DHCP6_PACKET_OPTION *Option; -+ PXEBC_OFFER_TYPE OfferType; -+ BOOLEAN IsProxyOffer; -+ BOOLEAN IsPxeOffer; -+ UINT32 Offset; -+ UINT32 Length; -+ UINT32 EnterpriseNum; - - IsProxyOffer = TRUE; - IsPxeOffer = FALSE; -@@ -644,15 +649,14 @@ PxeBcParseDhcp6Packet ( - - ZeroMem (Cache6->OptList, sizeof (Cache6->OptList)); - -- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option); -- Offset = 0; -- Length = GET_DHCP6_OPTION_SIZE (Offer); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option); -+ Offset = 0; -+ Length = GET_DHCP6_OPTION_SIZE (Offer); - - // - // OpLen and OpCode here are both stored in network order, since they are from original packet. - // - while (Offset < Length) { -- - if (NTOHS (Option->OpCode) == DHCP6_OPT_IA_NA) { - Options[PXEBC_DHCP6_IDX_IA_NA] = Option; - } else if (NTOHS (Option->OpCode) == DHCP6_OPT_BOOT_FILE_URL) { -@@ -669,7 +673,7 @@ PxeBcParseDhcp6Packet ( - } - - Offset += (NTOHS (Option->OpLen) + 4); -- Option = (EFI_DHCP6_PACKET_OPTION *) (Offer->Dhcp6.Option + Offset); -+ Option = (EFI_DHCP6_PACKET_OPTION *)(Offer->Dhcp6.Option + Offset); - } - - // -@@ -683,7 +687,7 @@ PxeBcParseDhcp6Packet ( - NTOHS (Option->OpLen), - DHCP6_OPT_STATUS_CODE - ); -- if ((Option != NULL && Option->Data[0] == 0) || (Option == NULL)) { -+ if (((Option != NULL) && (Option->Data[0] == 0)) || (Option == NULL)) { - IsProxyOffer = FALSE; - } - } -@@ -692,12 +696,13 @@ PxeBcParseDhcp6Packet ( - // The offer with "PXEClient" is a pxe offer. - // - Option = Options[PXEBC_DHCP6_IDX_VENDOR_CLASS]; -- EnterpriseNum = HTONL(PXEBC_DHCP6_ENTERPRISE_NUM); -+ EnterpriseNum = HTONL (PXEBC_DHCP6_ENTERPRISE_NUM); - -- if (Option != NULL && -- NTOHS(Option->OpLen) >= 13 && -- CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0 && -- CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0) { -+ if ((Option != NULL) && -+ (NTOHS (Option->OpLen) >= 13) && -+ (CompareMem (Option->Data, &EnterpriseNum, sizeof (UINT32)) == 0) && -+ (CompareMem (&Option->Data[6], DEFAULT_CLASS_ID_DATA, 9) == 0)) -+ { - IsPxeOffer = TRUE; - } - -@@ -721,7 +726,6 @@ PxeBcParseDhcp6Packet ( - return EFI_SUCCESS; - } - -- - /** - Cache the DHCPv6 ack packet, and parse it on demand. - -@@ -735,9 +739,9 @@ PxeBcParseDhcp6Packet ( - **/ - EFI_STATUS - PxeBcCopyDhcp6Ack ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN EFI_DHCP6_PACKET *Ack, -- IN BOOLEAN Verified -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN EFI_DHCP6_PACKET *Ack, -+ IN BOOLEAN Verified - ) - { - EFI_PXE_BASE_CODE_MODE *Mode; -@@ -762,7 +766,6 @@ PxeBcCopyDhcp6Ack ( - return EFI_SUCCESS; - } - -- - /** - Cache the DHCPv6 proxy offer packet according to the received order. - -@@ -775,12 +778,12 @@ PxeBcCopyDhcp6Ack ( - **/ - EFI_STATUS - PxeBcCopyDhcp6Proxy ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN UINT32 OfferIndex -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN UINT32 OfferIndex - ) - { -- EFI_PXE_BASE_CODE_MODE *Mode; -- EFI_DHCP6_PACKET *Offer; -+ EFI_PXE_BASE_CODE_MODE *Mode; -+ EFI_DHCP6_PACKET *Offer; - EFI_STATUS Status; - - ASSERT (OfferIndex < Private->OfferNum); -@@ -793,9 +796,10 @@ PxeBcCopyDhcp6Proxy ( - // Cache the proxy offer packet and parse it. - // - Status = PxeBcCacheDhcp6Packet (&Private->ProxyOffer.Dhcp6.Packet.Offer, Offer); -- if (EFI_ERROR(Status)) { -+ if (EFI_ERROR (Status)) { - return Status; - } -+ - PxeBcParseDhcp6Packet (&Private->ProxyOffer.Dhcp6); - - // -@@ -820,33 +824,33 @@ PxeBcCopyDhcp6Proxy ( - **/ - UINT8 * - PxeBcDhcp6SeekOption ( -- IN UINT8 *Buf, -- IN UINT32 SeekLen, -- IN UINT16 OptType -+ IN UINT8 *Buf, -+ IN UINT32 SeekLen, -+ IN UINT16 OptType - ) - { -- UINT8 *Cursor; -- UINT8 *Option; -- UINT16 DataLen; -- UINT16 OpCode; -+ UINT8 *Cursor; -+ UINT8 *Option; -+ UINT16 DataLen; -+ UINT16 OpCode; - - Option = NULL; - Cursor = Buf; - - while (Cursor < Buf + SeekLen) { -- OpCode = ReadUnaligned16 ((UINT16 *) Cursor); -+ OpCode = ReadUnaligned16 ((UINT16 *)Cursor); - if (OpCode == HTONS (OptType)) { - Option = Cursor; - break; - } -- DataLen = NTOHS (ReadUnaligned16 ((UINT16 *) (Cursor + 2))); -+ -+ DataLen = NTOHS (ReadUnaligned16 ((UINT16 *)(Cursor + 2))); - Cursor += (DataLen + 4); - } - - return Option; - } - -- - /** - Build and send out the request packet for the bootfile, and parse the reply. - -@@ -861,34 +865,34 @@ PxeBcDhcp6SeekOption ( - **/ - EFI_STATUS - PxeBcRequestBootService ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN UINT32 Index -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN UINT32 Index - ) - { -- EFI_PXE_BASE_CODE_UDP_PORT SrcPort; -- EFI_PXE_BASE_CODE_UDP_PORT DestPort; -- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; -- EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover; -- UINTN DiscoverLen; -- EFI_DHCP6_PACKET *Request; -- UINTN RequestLen; -- EFI_DHCP6_PACKET *Reply; -- UINT8 *RequestOpt; -- UINT8 *DiscoverOpt; -- UINTN ReadSize; -- UINT16 OpFlags; -- UINT16 OpCode; -- UINT16 OpLen; -- EFI_STATUS Status; -- EFI_DHCP6_PACKET *IndexOffer; -- UINT8 *Option; -- -- PxeBc = &Private->PxeBc; -- Request = Private->Dhcp6Request; -- IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer; -- SrcPort = PXEBC_BS_DISCOVER_PORT; -- DestPort = PXEBC_BS_DISCOVER_PORT; -- OpFlags = 0; -+ EFI_PXE_BASE_CODE_UDP_PORT SrcPort; -+ EFI_PXE_BASE_CODE_UDP_PORT DestPort; -+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; -+ EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover; -+ UINTN DiscoverLen; -+ EFI_DHCP6_PACKET *Request; -+ UINTN RequestLen; -+ EFI_DHCP6_PACKET *Reply; -+ UINT8 *RequestOpt; -+ UINT8 *DiscoverOpt; -+ UINTN ReadSize; -+ UINT16 OpFlags; -+ UINT16 OpCode; -+ UINT16 OpLen; -+ EFI_STATUS Status; -+ EFI_DHCP6_PACKET *IndexOffer; -+ UINT8 *Option; -+ -+ PxeBc = &Private->PxeBc; -+ Request = Private->Dhcp6Request; -+ IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer; -+ SrcPort = PXEBC_BS_DISCOVER_PORT; -+ DestPort = PXEBC_BS_DISCOVER_PORT; -+ OpFlags = 0; - - if (Request == NULL) { - return EFI_DEVICE_ERROR; -@@ -925,19 +929,20 @@ PxeBcRequestBootService ( - // - // Add Server ID Option. - // -- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen); -+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)Option)->OpLen); - CopyMem (DiscoverOpt, Option, OpLen + 4); - DiscoverOpt += (OpLen + 4); - DiscoverLen += (OpLen + 4); - } - - while (RequestLen < Request->Length) { -- OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode); -- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen); -- if (OpCode != EFI_DHCP6_IA_TYPE_NA && -- OpCode != EFI_DHCP6_IA_TYPE_TA && -- OpCode != DHCP6_OPT_SERVER_ID -- ) { -+ OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode); -+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen); -+ if ((OpCode != EFI_DHCP6_IA_TYPE_NA) && -+ (OpCode != EFI_DHCP6_IA_TYPE_TA) && -+ (OpCode != DHCP6_OPT_SERVER_ID) -+ ) -+ { - // - // Copy all the options except IA option and Server ID - // -@@ -945,6 +950,7 @@ PxeBcRequestBootService ( - DiscoverOpt += (OpLen + 4); - DiscoverLen += (OpLen + 4); - } -+ - RequestOpt += (OpLen + 4); - RequestLen += (OpLen + 4); - } -@@ -959,7 +965,7 @@ PxeBcRequestBootService ( - ); - if (Option != NULL) { - CalcElapsedTime (Private); -- WriteUnaligned16 ((UINT16*)(Option + 4), HTONS((UINT16) Private->ElapsedTime)); -+ WriteUnaligned16 ((UINT16 *)(Option + 4), HTONS ((UINT16)Private->ElapsedTime)); - } - - Status = PxeBc->UdpWrite ( -@@ -973,7 +979,7 @@ PxeBcRequestBootService ( - NULL, - NULL, - &DiscoverLen, -- (VOID *) Discover -+ (VOID *)Discover - ); - - if (EFI_ERROR (Status)) { -@@ -984,8 +990,8 @@ PxeBcRequestBootService ( - // Cache the right PXE reply packet here, set valid flag later. - // Especially for PXE discover packet, store it into mode data here. - // -- Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer; -- ReadSize = (UINTN) Reply->Size; -+ Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer; -+ ReadSize = (UINTN)Reply->Size; - - // - // Start Udp6Read instance -@@ -1005,7 +1011,7 @@ PxeBcRequestBootService ( - NULL, - NULL, - &ReadSize, -- (VOID *) &Reply->Dhcp6 -+ (VOID *)&Reply->Dhcp6 - ); - // - // Stop Udp6Read instance -@@ -1019,7 +1025,7 @@ PxeBcRequestBootService ( - // - // Update length - // -- Reply->Length = (UINT32) ReadSize; -+ Reply->Length = (UINT32)ReadSize; - - return EFI_SUCCESS; - -@@ -1031,7 +1037,6 @@ ON_ERROR: - return Status; - } - -- - /** - Retry to request bootfile name by the BINL offer. - -@@ -1054,8 +1059,10 @@ PxeBcRetryDhcp6Binl ( - EFI_STATUS Status; - - ASSERT (Index < PXEBC_OFFER_MAX_NUM); -- ASSERT (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl || -- Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl); -+ ASSERT ( -+ Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeDhcpBinl || -+ Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl -+ ); - - Mode = Private->PxeBc.Mode; - Private->IsDoDiscover = FALSE; -@@ -1078,7 +1085,7 @@ PxeBcRetryDhcp6Binl ( - Private, - &Private->BootFileName, - &Private->ServerIp.v6, -- (CHAR8 *) (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data), -+ (CHAR8 *)(Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data), - NTOHS (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen) - ); - if (EFI_ERROR (Status)) { -@@ -1101,9 +1108,10 @@ PxeBcRetryDhcp6Binl ( - return Status; - } - -- if (Cache6->OfferType != PxeOfferTypeProxyPxe10 && -- Cache6->OfferType != PxeOfferTypeProxyWfm11a && -- Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) { -+ if ((Cache6->OfferType != PxeOfferTypeProxyPxe10) && -+ (Cache6->OfferType != PxeOfferTypeProxyWfm11a) && -+ (Cache6->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL)) -+ { - // - // This BINL ack doesn't have discovery option set or multicast option set - // or bootfile name specified. -@@ -1121,7 +1129,6 @@ PxeBcRetryDhcp6Binl ( - return EFI_SUCCESS; - } - -- - /** - Cache all the received DHCPv6 offers, and set OfferIndex and OfferCount. - -@@ -1133,8 +1140,8 @@ PxeBcRetryDhcp6Binl ( - **/ - EFI_STATUS - PxeBcCacheDhcp6Offer ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN EFI_DHCP6_PACKET *RcvdOffer -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN EFI_DHCP6_PACKET *RcvdOffer - ) - { - PXEBC_DHCP6_PACKET_CACHE *Cache6; -@@ -1179,8 +1186,9 @@ PxeBcCacheDhcp6Offer ( - // - Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum; - Private->OfferCount[OfferType]++; -- } else if ((OfferType == PxeOfferTypeProxyPxe10 || OfferType == PxeOfferTypeProxyWfm11a) && -- Private->OfferCount[OfferType] < 1) { -+ } else if (((OfferType == PxeOfferTypeProxyPxe10) || (OfferType == PxeOfferTypeProxyWfm11a)) && -+ (Private->OfferCount[OfferType] < 1)) -+ { - // - // Only cache the first PXE10/WFM11a offer, and discard the others. - // -@@ -1202,7 +1210,6 @@ PxeBcCacheDhcp6Offer ( - return EFI_SUCCESS; - } - -- - /** - Select an DHCPv6 offer, and record SelectIndex and SelectProxyType. - -@@ -1211,12 +1218,12 @@ PxeBcCacheDhcp6Offer ( - **/ - VOID - PxeBcSelectDhcp6Offer ( -- IN PXEBC_PRIVATE_DATA *Private -+ IN PXEBC_PRIVATE_DATA *Private - ) - { -- UINT32 Index; -- UINT32 OfferIndex; -- PXEBC_OFFER_TYPE OfferType; -+ UINT32 Index; -+ UINT32 OfferIndex; -+ PXEBC_OFFER_TYPE OfferType; - - Private->SelectIndex = 0; - -@@ -1229,43 +1236,40 @@ PxeBcSelectDhcp6Offer ( - // 1. DhcpPxe10 offer - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1; -- - } else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) { - // - // 2. DhcpWfm11a offer - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1; -- -- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 && -- Private->OfferCount[PxeOfferTypeProxyPxe10] > 0) { -+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) && -+ (Private->OfferCount[PxeOfferTypeProxyPxe10] > 0)) -+ { - // - // 3. DhcpOnly offer and ProxyPxe10 offer. - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1; - Private->SelectProxyType = PxeOfferTypeProxyPxe10; -- -- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 && -- Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0) { -+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) && -+ (Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0)) -+ { - // - // 4. DhcpOnly offer and ProxyWfm11a offer. - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1; - Private->SelectProxyType = PxeOfferTypeProxyWfm11a; -- - } else if (Private->OfferCount[PxeOfferTypeDhcpBinl] > 0) { - // - // 5. DhcpBinl offer. - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpBinl][0] + 1; -- -- } else if (Private->OfferCount[PxeOfferTypeDhcpOnly] > 0 && -- Private->OfferCount[PxeOfferTypeProxyBinl] > 0) { -+ } else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) && -+ (Private->OfferCount[PxeOfferTypeProxyBinl] > 0)) -+ { - // - // 6. DhcpOnly offer and ProxyBinl offer. - // - Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1; - Private->SelectProxyType = PxeOfferTypeProxyBinl; -- - } else { - // - // 7. DhcpOnly offer with bootfilename. -@@ -1283,7 +1287,6 @@ PxeBcSelectDhcp6Offer ( - // Select offer by received order. - // - for (Index = 0; Index < Private->OfferNum; Index++) { -- - OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType; - - if (IS_PROXY_OFFER (OfferType)) { -@@ -1294,8 +1297,9 @@ PxeBcSelectDhcp6Offer ( - } - - if (!Private->IsProxyRecved && -- OfferType == PxeOfferTypeDhcpOnly && -- Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) { -+ (OfferType == PxeOfferTypeDhcpOnly) && -+ (Private->OfferBuffer[Index].Dhcp6.OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL)) -+ { - // - // Skip if DhcpOnly offer without any other proxy offers or bootfilename. - // -@@ -1308,7 +1312,6 @@ PxeBcSelectDhcp6Offer ( - } - } - -- - /** - Handle the DHCPv6 offer packet. - -@@ -1322,21 +1325,21 @@ PxeBcSelectDhcp6Offer ( - **/ - EFI_STATUS - PxeBcHandleDhcp6Offer ( -- IN PXEBC_PRIVATE_DATA *Private -+ IN PXEBC_PRIVATE_DATA *Private - ) - { -- PXEBC_DHCP6_PACKET_CACHE *Cache6; -- EFI_STATUS Status; -- PXEBC_OFFER_TYPE OfferType; -- UINT32 ProxyIndex; -- UINT32 SelectIndex; -- UINT32 Index; -+ PXEBC_DHCP6_PACKET_CACHE *Cache6; -+ EFI_STATUS Status; -+ PXEBC_OFFER_TYPE OfferType; -+ UINT32 ProxyIndex; -+ UINT32 SelectIndex; -+ UINT32 Index; - - ASSERT (Private->SelectIndex > 0); -- SelectIndex = (UINT32) (Private->SelectIndex - 1); -+ SelectIndex = (UINT32)(Private->SelectIndex - 1); - ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM); -- Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6; -- Status = EFI_SUCCESS; -+ Cache6 = &Private->OfferBuffer[SelectIndex].Dhcp6; -+ Status = EFI_SUCCESS; - - // - // First try to cache DNS server address if DHCP6 offer provides. -@@ -1346,6 +1349,7 @@ PxeBcHandleDhcp6Offer ( - if (Private->DnsServer == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); - } - -@@ -1357,7 +1361,6 @@ PxeBcHandleDhcp6Offer ( - Status = EFI_NO_RESPONSE; - } - } else if (Cache6->OfferType == PxeOfferTypeDhcpOnly) { -- - if (Private->IsProxyRecved) { - // - // DhcpOnly offer is selected, so need try to request bootfilename. -@@ -1375,12 +1378,12 @@ PxeBcHandleDhcp6Offer ( - // Try all the cached ProxyBinl offer one by one to request bootfilename. - // - for (Index = 0; Index < Private->OfferCount[Private->SelectProxyType]; Index++) { -- - ProxyIndex = Private->OfferIndex[Private->SelectProxyType][Index]; - if (!EFI_ERROR (PxeBcRetryDhcp6Binl (Private, ProxyIndex))) { - break; - } - } -+ - if (Index == Private->OfferCount[Private->SelectProxyType]) { - Status = EFI_NO_RESPONSE; - } -@@ -1397,7 +1400,6 @@ PxeBcHandleDhcp6Offer ( - Status = EFI_NO_RESPONSE; - - for (Index = 0; Index < Private->OfferNum; Index++) { -- - OfferType = Private->OfferBuffer[Index].Dhcp6.OfferType; - - if (!IS_PROXY_OFFER (OfferType)) { -@@ -1423,7 +1425,7 @@ PxeBcHandleDhcp6Offer ( - } - } - -- if (!EFI_ERROR (Status) && Private->SelectProxyType != PxeOfferTypeProxyBinl) { -+ if (!EFI_ERROR (Status) && (Private->SelectProxyType != PxeOfferTypeProxyBinl)) { - // - // Success to try to request by a ProxyPxe10 or ProxyWfm11a offer, copy and parse it. - // -@@ -1441,14 +1443,13 @@ PxeBcHandleDhcp6Offer ( - // - // All PXE boot information is ready by now. - // -- Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE); -+ Status = PxeBcCopyDhcp6Ack (Private, &Private->DhcpAck.Dhcp6.Packet.Ack, TRUE); - Private->PxeBc.Mode->DhcpDiscoverValid = TRUE; - } - - return Status; - } - -- - /** - Unregister the address by Ip6Config protocol. - -@@ -1457,7 +1458,7 @@ PxeBcHandleDhcp6Offer ( - **/ - VOID - PxeBcUnregisterIp6Address ( -- IN PXEBC_PRIVATE_DATA *Private -+ IN PXEBC_PRIVATE_DATA *Private - ) - { - if (Private->Ip6Policy != PXEBC_IP6_POLICY_MAX) { -@@ -1485,18 +1486,18 @@ PxeBcUnregisterIp6Address ( - **/ - EFI_STATUS - PxeBcCheckRouteTable ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN UINTN TimeOutInSecond, -- OUT EFI_IPv6_ADDRESS *GatewayAddr -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN UINTN TimeOutInSecond, -+ OUT EFI_IPv6_ADDRESS *GatewayAddr - ) - { -- EFI_STATUS Status; -- EFI_IP6_PROTOCOL *Ip6; -- EFI_IP6_MODE_DATA Ip6ModeData; -- UINTN Index; -- EFI_EVENT TimeOutEvt; -- UINTN RetryCount; -- BOOLEAN GatewayIsFound; -+ EFI_STATUS Status; -+ EFI_IP6_PROTOCOL *Ip6; -+ EFI_IP6_MODE_DATA Ip6ModeData; -+ UINTN Index; -+ EFI_EVENT TimeOutEvt; -+ UINTN RetryCount; -+ BOOLEAN GatewayIsFound; - - ASSERT (GatewayAddr != NULL); - ASSERT (Private != NULL); -@@ -1527,23 +1528,28 @@ PxeBcCheckRouteTable ( - if (Ip6ModeData.AddressList != NULL) { - FreePool (Ip6ModeData.AddressList); - } -+ - if (Ip6ModeData.GroupTable != NULL) { - FreePool (Ip6ModeData.GroupTable); - } -+ - if (Ip6ModeData.RouteTable != NULL) { - FreePool (Ip6ModeData.RouteTable); - } -+ - if (Ip6ModeData.NeighborCache != NULL) { - FreePool (Ip6ModeData.NeighborCache); - } -+ - if (Ip6ModeData.PrefixTable != NULL) { - FreePool (Ip6ModeData.PrefixTable); - } -+ - if (Ip6ModeData.IcmpTypeList != NULL) { - FreePool (Ip6ModeData.IcmpTypeList); - } - -- if (GatewayIsFound || RetryCount == TimeOutInSecond) { -+ if (GatewayIsFound || (RetryCount == TimeOutInSecond)) { - break; - } - -@@ -1569,6 +1575,7 @@ PxeBcCheckRouteTable ( - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } -+ - while (EFI_ERROR (gBS->CheckEvent (TimeOutEvt))) { - Ip6->Poll (Ip6); - } -@@ -1600,29 +1607,29 @@ ON_EXIT: - **/ - EFI_STATUS - PxeBcRegisterIp6Address ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN EFI_IPv6_ADDRESS *Address -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN EFI_IPv6_ADDRESS *Address - ) - { -- EFI_IP6_PROTOCOL *Ip6; -- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -- EFI_IP6_CONFIG_POLICY Policy; -- EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr; -- EFI_IPv6_ADDRESS GatewayAddr; -- UINTN DataSize; -- EFI_EVENT MappedEvt; -- EFI_STATUS Status; -- BOOLEAN NoGateway; -- EFI_IPv6_ADDRESS *Ip6Addr; -- UINTN Index; -- -- Status = EFI_SUCCESS; -- MappedEvt = NULL; -- Ip6Addr = NULL; -- DataSize = sizeof (EFI_IP6_CONFIG_POLICY); -- Ip6Cfg = Private->Ip6Cfg; -- Ip6 = Private->Ip6; -- NoGateway = FALSE; -+ EFI_IP6_PROTOCOL *Ip6; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -+ EFI_IP6_CONFIG_POLICY Policy; -+ EFI_IP6_CONFIG_MANUAL_ADDRESS CfgAddr; -+ EFI_IPv6_ADDRESS GatewayAddr; -+ UINTN DataSize; -+ EFI_EVENT MappedEvt; -+ EFI_STATUS Status; -+ BOOLEAN NoGateway; -+ EFI_IPv6_ADDRESS *Ip6Addr; -+ UINTN Index; -+ -+ Status = EFI_SUCCESS; -+ MappedEvt = NULL; -+ Ip6Addr = NULL; -+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY); -+ Ip6Cfg = Private->Ip6Cfg; -+ Ip6 = Private->Ip6; -+ NoGateway = FALSE; - - ZeroMem (&CfgAddr, sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS)); - CopyMem (&CfgAddr.Address, Address, sizeof (EFI_IPv6_ADDRESS)); -@@ -1648,7 +1655,7 @@ PxeBcRegisterIp6Address ( - Status = Ip6Cfg->SetData ( - Ip6Cfg, - Ip6ConfigDataTypePolicy, -- sizeof(EFI_IP6_CONFIG_POLICY), -+ sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - if (EFI_ERROR (Status)) { -@@ -1674,22 +1681,22 @@ PxeBcRegisterIp6Address ( - } - - Private->IsAddressOk = FALSE; -- Status = Ip6Cfg->RegisterDataNotify ( -- Ip6Cfg, -- Ip6ConfigDataTypeManualAddress, -- MappedEvt -- ); -- if (EFI_ERROR(Status)) { -+ Status = Ip6Cfg->RegisterDataNotify ( -+ Ip6Cfg, -+ Ip6ConfigDataTypeManualAddress, -+ MappedEvt -+ ); -+ if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - Status = Ip6Cfg->SetData ( - Ip6Cfg, - Ip6ConfigDataTypeManualAddress, -- sizeof(EFI_IP6_CONFIG_MANUAL_ADDRESS), -+ sizeof (EFI_IP6_CONFIG_MANUAL_ADDRESS), - &CfgAddr - ); -- if (EFI_ERROR(Status) && Status != EFI_NOT_READY) { -+ if (EFI_ERROR (Status) && (Status != EFI_NOT_READY)) { - goto ON_EXIT; - } else if (Status == EFI_NOT_READY) { - // -@@ -1698,17 +1705,18 @@ PxeBcRegisterIp6Address ( - while (!Private->IsAddressOk) { - Ip6->Poll (Ip6); - } -+ - // - // Check whether the IP6 address setting is successed. - // - DataSize = 0; -- Status = Ip6Cfg->GetData ( -- Ip6Cfg, -- Ip6ConfigDataTypeManualAddress, -- &DataSize, -- NULL -- ); -- if (Status != EFI_BUFFER_TOO_SMALL || DataSize == 0) { -+ Status = Ip6Cfg->GetData ( -+ Ip6Cfg, -+ Ip6ConfigDataTypeManualAddress, -+ &DataSize, -+ NULL -+ ); -+ if ((Status != EFI_BUFFER_TOO_SMALL) || (DataSize == 0)) { - Status = EFI_DEVICE_ERROR; - goto ON_EXIT; - } -@@ -1717,11 +1725,12 @@ PxeBcRegisterIp6Address ( - if (Ip6Addr == NULL) { - return EFI_OUT_OF_RESOURCES; - } -+ - Status = Ip6Cfg->GetData ( - Ip6Cfg, - Ip6ConfigDataTypeManualAddress, - &DataSize, -- (VOID*) Ip6Addr -+ (VOID *)Ip6Addr - ); - if (EFI_ERROR (Status)) { - Status = EFI_DEVICE_ERROR; -@@ -1733,6 +1742,7 @@ PxeBcRegisterIp6Address ( - break; - } - } -+ - if (Index == DataSize / sizeof (EFI_IPv6_ADDRESS)) { - Status = EFI_ABORTED; - goto ON_EXIT; -@@ -1763,9 +1773,11 @@ ON_EXIT: - ); - gBS->CloseEvent (MappedEvt); - } -+ - if (Ip6Addr != NULL) { - FreePool (Ip6Addr); - } -+ - return Status; - } - -@@ -1780,16 +1792,16 @@ ON_EXIT: - **/ - EFI_STATUS - PxeBcSetIp6Policy ( -- IN PXEBC_PRIVATE_DATA *Private -+ IN PXEBC_PRIVATE_DATA *Private - ) - { -- EFI_IP6_CONFIG_POLICY Policy; -- EFI_STATUS Status; -- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -- UINTN DataSize; -+ EFI_IP6_CONFIG_POLICY Policy; -+ EFI_STATUS Status; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -+ UINTN DataSize; - -- Ip6Cfg = Private->Ip6Cfg; -- DataSize = sizeof (EFI_IP6_CONFIG_POLICY); -+ Ip6Cfg = Private->Ip6Cfg; -+ DataSize = sizeof (EFI_IP6_CONFIG_POLICY); - - // - // Get and store the current policy of IP6 driver. -@@ -1809,7 +1821,7 @@ PxeBcSetIp6Policy ( - Status = Ip6Cfg->SetData ( - Ip6Cfg, - Ip6ConfigDataTypePolicy, -- sizeof(EFI_IP6_CONFIG_POLICY), -+ sizeof (EFI_IP6_CONFIG_POLICY), - &Policy - ); - if (EFI_ERROR (Status)) { -@@ -1834,11 +1846,11 @@ PxeBcSetIp6Policy ( - **/ - EFI_STATUS - PxeBcSetIp6Address ( -- IN PXEBC_PRIVATE_DATA *Private -+ IN PXEBC_PRIVATE_DATA *Private - ) - { -- EFI_STATUS Status; -- EFI_DHCP6_PROTOCOL *Dhcp6; -+ EFI_STATUS Status; -+ EFI_DHCP6_PROTOCOL *Dhcp6; - - Dhcp6 = Private->Dhcp6; - -@@ -1885,47 +1897,48 @@ PxeBcSetIp6Address ( - EFI_STATUS - EFIAPI - PxeBcDhcp6CallBack ( -- IN EFI_DHCP6_PROTOCOL *This, -- IN VOID *Context, -- IN EFI_DHCP6_STATE CurrentState, -- IN EFI_DHCP6_EVENT Dhcp6Event, -- IN EFI_DHCP6_PACKET *Packet, -- OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL -+ IN EFI_DHCP6_PROTOCOL *This, -+ IN VOID *Context, -+ IN EFI_DHCP6_STATE CurrentState, -+ IN EFI_DHCP6_EVENT Dhcp6Event, -+ IN EFI_DHCP6_PACKET *Packet, -+ OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL - ) - { -- PXEBC_PRIVATE_DATA *Private; -- EFI_PXE_BASE_CODE_MODE *Mode; -- EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; -- EFI_DHCP6_PACKET *SelectAd; -- EFI_STATUS Status; -- BOOLEAN Received; -+ PXEBC_PRIVATE_DATA *Private; -+ EFI_PXE_BASE_CODE_MODE *Mode; -+ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback; -+ EFI_DHCP6_PACKET *SelectAd; -+ EFI_STATUS Status; -+ BOOLEAN Received; - - if ((Dhcp6Event != Dhcp6RcvdAdvertise) && - (Dhcp6Event != Dhcp6SelectAdvertise) && - (Dhcp6Event != Dhcp6SendSolicit) && - (Dhcp6Event != Dhcp6SendRequest) && -- (Dhcp6Event != Dhcp6RcvdReply)) { -+ (Dhcp6Event != Dhcp6RcvdReply)) -+ { - return EFI_SUCCESS; - } - - ASSERT (Packet != NULL); - -- Private = (PXEBC_PRIVATE_DATA *) Context; -- Mode = Private->PxeBc.Mode; -- Callback = Private->PxeBcCallback; -+ Private = (PXEBC_PRIVATE_DATA *)Context; -+ Mode = Private->PxeBc.Mode; -+ Callback = Private->PxeBcCallback; - - // - // Callback to user when any traffic occurred if has. - // -- if (Dhcp6Event != Dhcp6SelectAdvertise && Callback != NULL) { -- Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply); -- Status = Callback->Callback ( -- Callback, -- Private->Function, -- Received, -- Packet->Length, -- (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp6 -- ); -+ if ((Dhcp6Event != Dhcp6SelectAdvertise) && (Callback != NULL)) { -+ Received = (BOOLEAN)(Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply); -+ Status = Callback->Callback ( -+ Callback, -+ Private->Function, -+ Received, -+ Packet->Length, -+ (EFI_PXE_BASE_CODE_PACKET *)&Packet->Dhcp6 -+ ); - if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) { - return EFI_ABORTED; - } -@@ -1934,108 +1947,114 @@ PxeBcDhcp6CallBack ( - Status = EFI_SUCCESS; - - switch (Dhcp6Event) { -+ case Dhcp6SendSolicit: -+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { -+ // -+ // If the to be sent packet exceeds the maximum length, abort the DHCP process. -+ // -+ Status = EFI_ABORTED; -+ break; -+ } - -- case Dhcp6SendSolicit: -- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { - // -- // If the to be sent packet exceeds the maximum length, abort the DHCP process. -+ // Record the first Solicate msg time - // -- Status = EFI_ABORTED; -- break; -- } -- -- // -- // Record the first Solicate msg time -- // -- if (Private->SolicitTimes == 0) { -- CalcElapsedTime (Private); -- Private->SolicitTimes++; -- } -- // -- // Cache the dhcp discover packet to mode data directly. -- // -- CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length); -- break; -+ if (Private->SolicitTimes == 0) { -+ CalcElapsedTime (Private); -+ Private->SolicitTimes++; -+ } - -- case Dhcp6RcvdAdvertise: -- Status = EFI_NOT_READY; -- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { - // -- // Ignore the incoming packets which exceed the maximum length. -+ // Cache the dhcp discover packet to mode data directly. - // -+ CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp6, Packet->Length); - break; -- } -- if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) { -+ -+ case Dhcp6RcvdAdvertise: -+ Status = EFI_NOT_READY; -+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { -+ // -+ // Ignore the incoming packets which exceed the maximum length. -+ // -+ break; -+ } -+ -+ if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) { -+ // -+ // Cache the dhcp offers to OfferBuffer[] for select later, and record -+ // the OfferIndex and OfferCount. -+ // -+ PxeBcCacheDhcp6Offer (Private, Packet); -+ } -+ -+ break; -+ -+ case Dhcp6SendRequest: -+ if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { -+ // -+ // If the to be sent packet exceeds the maximum length, abort the DHCP process. -+ // -+ Status = EFI_ABORTED; -+ break; -+ } -+ - // -- // Cache the dhcp offers to OfferBuffer[] for select later, and record -- // the OfferIndex and OfferCount. -+ // Store the request packet as seed packet for discover. - // -- PxeBcCacheDhcp6Offer (Private, Packet); -- } -- break; -+ if (Private->Dhcp6Request != NULL) { -+ FreePool (Private->Dhcp6Request); -+ } -+ -+ Private->Dhcp6Request = AllocateZeroPool (Packet->Size); -+ if (Private->Dhcp6Request != NULL) { -+ CopyMem (Private->Dhcp6Request, Packet, Packet->Size); -+ } -+ -+ break; - -- case Dhcp6SendRequest: -- if (Packet->Length > PXEBC_DHCP6_PACKET_MAX_SIZE) { -+ case Dhcp6SelectAdvertise: - // -- // If the to be sent packet exceeds the maximum length, abort the DHCP process. -+ // Select offer by the default policy or by order, and record the SelectIndex -+ // and SelectProxyType. - // -- Status = EFI_ABORTED; -- break; -- } -+ PxeBcSelectDhcp6Offer (Private); - -- // -- // Store the request packet as seed packet for discover. -- // -- if (Private->Dhcp6Request != NULL) { -- FreePool (Private->Dhcp6Request); -- } -- Private->Dhcp6Request = AllocateZeroPool (Packet->Size); -- if (Private->Dhcp6Request != NULL) { -- CopyMem (Private->Dhcp6Request, Packet, Packet->Size); -- } -- break; -+ if (Private->SelectIndex == 0) { -+ Status = EFI_ABORTED; -+ } else { -+ ASSERT (NewPacket != NULL); -+ SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer; -+ *NewPacket = AllocateZeroPool (SelectAd->Size); -+ ASSERT (*NewPacket != NULL); -+ if (*NewPacket == NULL) { -+ return EFI_ABORTED; -+ } - -- case Dhcp6SelectAdvertise: -- // -- // Select offer by the default policy or by order, and record the SelectIndex -- // and SelectProxyType. -- // -- PxeBcSelectDhcp6Offer (Private); -+ CopyMem (*NewPacket, SelectAd, SelectAd->Size); -+ } - -- if (Private->SelectIndex == 0) { -- Status = EFI_ABORTED; -- } else { -- ASSERT (NewPacket != NULL); -- SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer; -- *NewPacket = AllocateZeroPool (SelectAd->Size); -- ASSERT (*NewPacket != NULL); -- if (*NewPacket == NULL) { -- return EFI_ABORTED; -+ break; -+ -+ case Dhcp6RcvdReply: -+ // -+ // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data -+ // without verification. -+ // -+ ASSERT (Private->SelectIndex != 0); -+ Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE); -+ if (EFI_ERROR (Status)) { -+ Status = EFI_ABORTED; - } -- CopyMem (*NewPacket, SelectAd, SelectAd->Size); -- } -- break; - -- case Dhcp6RcvdReply: -- // -- // Cache the dhcp ack to Private->Dhcp6Ack, but it's not the final ack in mode data -- // without verification. -- // -- ASSERT (Private->SelectIndex != 0); -- Status = PxeBcCopyDhcp6Ack (Private, Packet, FALSE); -- if (EFI_ERROR (Status)) { -- Status = EFI_ABORTED; -- } -- break; -+ break; - -- default: -- ASSERT (0); -+ default: -+ ASSERT (0); - } - - return Status; - } - -- - /** - Build and send out the request packet for the bootfile, and parse the reply. - -@@ -2053,37 +2072,37 @@ PxeBcDhcp6CallBack ( - **/ - EFI_STATUS - PxeBcDhcp6Discover ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN UINT16 Type, -- IN UINT16 *Layer, -- IN BOOLEAN UseBis, -- IN EFI_IP_ADDRESS *DestIp -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN UINT16 Type, -+ IN UINT16 *Layer, -+ IN BOOLEAN UseBis, -+ IN EFI_IP_ADDRESS *DestIp - ) - { -- EFI_PXE_BASE_CODE_UDP_PORT SrcPort; -- EFI_PXE_BASE_CODE_UDP_PORT DestPort; -- EFI_PXE_BASE_CODE_MODE *Mode; -- EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; -- EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover; -- UINTN DiscoverLen; -- EFI_DHCP6_PACKET *Request; -- UINTN RequestLen; -- EFI_DHCP6_PACKET *Reply; -- UINT8 *RequestOpt; -- UINT8 *DiscoverOpt; -- UINTN ReadSize; -- UINT16 OpCode; -- UINT16 OpLen; -- UINT32 Xid; -- EFI_STATUS Status; -- -- PxeBc = &Private->PxeBc; -- Mode = PxeBc->Mode; -- Request = Private->Dhcp6Request; -- SrcPort = PXEBC_BS_DISCOVER_PORT; -- DestPort = PXEBC_BS_DISCOVER_PORT; -- -- if (!UseBis && Layer != NULL) { -+ EFI_PXE_BASE_CODE_UDP_PORT SrcPort; -+ EFI_PXE_BASE_CODE_UDP_PORT DestPort; -+ EFI_PXE_BASE_CODE_MODE *Mode; -+ EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; -+ EFI_PXE_BASE_CODE_DHCPV6_PACKET *Discover; -+ UINTN DiscoverLen; -+ EFI_DHCP6_PACKET *Request; -+ UINTN RequestLen; -+ EFI_DHCP6_PACKET *Reply; -+ UINT8 *RequestOpt; -+ UINT8 *DiscoverOpt; -+ UINTN ReadSize; -+ UINT16 OpCode; -+ UINT16 OpLen; -+ UINT32 Xid; -+ EFI_STATUS Status; -+ -+ PxeBc = &Private->PxeBc; -+ Mode = PxeBc->Mode; -+ Request = Private->Dhcp6Request; -+ SrcPort = PXEBC_BS_DISCOVER_PORT; -+ DestPort = PXEBC_BS_DISCOVER_PORT; -+ -+ if (!UseBis && (Layer != NULL)) { - *Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK; - } - -@@ -2108,10 +2127,11 @@ PxeBcDhcp6Discover ( - RequestLen = DiscoverLen; - - while (RequestLen < Request->Length) { -- OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode); -- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen); -- if (OpCode != EFI_DHCP6_IA_TYPE_NA && -- OpCode != EFI_DHCP6_IA_TYPE_TA) { -+ OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode); -+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen); -+ if ((OpCode != EFI_DHCP6_IA_TYPE_NA) && -+ (OpCode != EFI_DHCP6_IA_TYPE_TA)) -+ { - // - // Copy all the options except IA option. - // -@@ -2119,6 +2139,7 @@ PxeBcDhcp6Discover ( - DiscoverOpt += (OpLen + 4); - DiscoverLen += (OpLen + 4); - } -+ - RequestOpt += (OpLen + 4); - RequestLen += (OpLen + 4); - } -@@ -2134,7 +2155,7 @@ PxeBcDhcp6Discover ( - NULL, - NULL, - &DiscoverLen, -- (VOID *) Discover -+ (VOID *)Discover - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; -@@ -2150,7 +2171,8 @@ PxeBcDhcp6Discover ( - } else { - Reply = &Private->ProxyOffer.Dhcp6.Packet.Offer; - } -- ReadSize = (UINTN) Reply->Size; -+ -+ ReadSize = (UINTN)Reply->Size; - - // - // Start Udp6Read instance -@@ -2170,7 +2192,7 @@ PxeBcDhcp6Discover ( - NULL, - NULL, - &ReadSize, -- (VOID *) &Reply->Dhcp6 -+ (VOID *)&Reply->Dhcp6 - ); - // - // Stop Udp6Read instance -@@ -2190,7 +2212,6 @@ ON_ERROR: - return Status; - } - -- - /** - Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information. - -@@ -2203,35 +2224,35 @@ ON_ERROR: - **/ - EFI_STATUS - PxeBcDhcp6Sarr ( -- IN PXEBC_PRIVATE_DATA *Private, -- IN EFI_DHCP6_PROTOCOL *Dhcp6 -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN EFI_DHCP6_PROTOCOL *Dhcp6 - ) - { -- EFI_PXE_BASE_CODE_MODE *PxeMode; -- EFI_DHCP6_CONFIG_DATA Config; -- EFI_DHCP6_MODE_DATA Mode; -- EFI_DHCP6_RETRANSMISSION *Retransmit; -- EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_OPTION_MAX_NUM]; -- UINT8 Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE]; -- UINT32 OptCount; -- EFI_STATUS Status; -- EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -- EFI_STATUS TimerStatus; -- EFI_EVENT Timer; -- UINT64 GetMappingTimeOut; -- UINTN DataSize; -- EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; -- -- Status = EFI_SUCCESS; -- PxeMode = Private->PxeBc.Mode; -- Ip6Cfg = Private->Ip6Cfg; -- Timer = NULL; -+ EFI_PXE_BASE_CODE_MODE *PxeMode; -+ EFI_DHCP6_CONFIG_DATA Config; -+ EFI_DHCP6_MODE_DATA Mode; -+ EFI_DHCP6_RETRANSMISSION *Retransmit; -+ EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_OPTION_MAX_NUM]; -+ UINT8 Buffer[PXEBC_DHCP6_OPTION_MAX_SIZE]; -+ UINT32 OptCount; -+ EFI_STATUS Status; -+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; -+ EFI_STATUS TimerStatus; -+ EFI_EVENT Timer; -+ UINT64 GetMappingTimeOut; -+ UINTN DataSize; -+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; -+ -+ Status = EFI_SUCCESS; -+ PxeMode = Private->PxeBc.Mode; -+ Ip6Cfg = Private->Ip6Cfg; -+ Timer = NULL; - - // - // Build option list for the request packet. - // -- OptCount = PxeBcBuildDhcp6Options (Private, OptList, Buffer); -- ASSERT (OptCount> 0); -+ OptCount = PxeBcBuildDhcp6Options (Private, OptList, Buffer); -+ ASSERT (OptCount > 0); - - Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION)); - if (Retransmit == NULL) { -@@ -2274,7 +2295,6 @@ PxeBcDhcp6Sarr ( - ZeroMem (Private->OfferCount, sizeof (Private->OfferCount)); - ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex)); - -- - // - // Start DHCPv6 S.A.R.R. process to acquire IPv6 address. - // -@@ -2290,12 +2310,12 @@ PxeBcDhcp6Sarr ( - // Get Duplicate Address Detection Transmits count. - // - DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS); -- Status = Ip6Cfg->GetData ( -- Ip6Cfg, -- Ip6ConfigDataTypeDupAddrDetectTransmits, -- &DataSize, -- &DadXmits -- ); -+ Status = Ip6Cfg->GetData ( -+ Ip6Cfg, -+ Ip6ConfigDataTypeDupAddrDetectTransmits, -+ &DataSize, -+ &DadXmits -+ ); - if (EFI_ERROR (Status)) { - Dhcp6->Configure (Dhcp6, NULL); - return Status; -@@ -2308,7 +2328,7 @@ PxeBcDhcp6Sarr ( - } - - GetMappingTimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + PXEBC_DAD_ADDITIONAL_DELAY; -- Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut); -+ Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut); - if (EFI_ERROR (Status)) { - gBS->CloseEvent (Timer); - Dhcp6->Configure (Dhcp6, NULL); -@@ -2316,7 +2336,6 @@ PxeBcDhcp6Sarr ( - } - - do { -- - TimerStatus = gBS->CheckEvent (Timer); - if (!EFI_ERROR (TimerStatus)) { - Status = Dhcp6->Start (Dhcp6); -@@ -2325,10 +2344,12 @@ PxeBcDhcp6Sarr ( - - gBS->CloseEvent (Timer); - } -+ - if (EFI_ERROR (Status)) { - if (Status == EFI_ICMP_ERROR) { - PxeMode->IcmpErrorReceived = TRUE; - } -+ - Dhcp6->Configure (Dhcp6, NULL); - return Status; - } -@@ -2354,9 +2375,11 @@ PxeBcDhcp6Sarr ( - if (Mode.ClientId != NULL) { - FreePool (Mode.ClientId); - } -+ - if (Mode.Ia != NULL) { - FreePool (Mode.Ia); - } -+ - // - // Check the selected offer whether BINL retry is needed. - // --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Packet-Length-is-not-updated-bef.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Packet-Length-is-not-updated-bef.patch deleted file mode 100644 index e37b524..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Packet-Length-is-not-updated-bef.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 649fe647114ca5dee84b0c55106ee58a9703984f Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 15/15] NetworkPkg: Dhcp6Dxe: Packet-Length is not updated - before appending - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [15/15] bc7ef287311bb3f757bc26f8921875566bcb5917 - -JIRA: https://issues.redhat.com/browse/RHEL-21840 -CVE: CVE-2023-45229 -Upstream: Merged - -commit 75deaf5c3c0d164c61653258c331151241bb69d8 -Author: Doug Flick -Date: Tue Feb 13 10:46:02 2024 -0800 - - NetworkPkg: Dhcp6Dxe: Packet-Length is not updated before appending - - In order for Dhcp6AppendIaAddrOption (..) to safely append the IA - Address option, the Packet-Length field must be updated before appending - the option. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - Reviewed-by: Leif Lindholm - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -index e172ffc2a2..c23eff8766 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -@@ -948,6 +948,11 @@ Dhcp6AppendIaOption ( - *PacketCursor += sizeof (T2); - } - -+ // -+ // Update the packet length -+ // -+ Packet->Length += BytesNeeded; -+ - // - // Fill all the addresses belong to the Ia - // -@@ -959,11 +964,6 @@ Dhcp6AppendIaOption ( - } - } - -- // -- // Update the packet length -- // -- Packet->Length += BytesNeeded; -- - // - // Fill the value of Ia option length - // --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Removes-duplicate-check-and-repl.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Removes-duplicate-check-and-repl.patch deleted file mode 100644 index a928fa2..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-Removes-duplicate-check-and-repl.patch +++ /dev/null @@ -1,161 +0,0 @@ -From 4bf844922a963cb20fb1e72ca11a65a673992ca2 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 14/15] NetworkPkg: Dhcp6Dxe: Removes duplicate check and - replaces with macro - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [14/15] a943400f9267b219bf1fd202534500f82a2a4c56 - -JIRA: https://issues.redhat.com/browse/RHEL-21840 -CVE: CVE-2023-45229 -Upstream: Merged - -commit af3fad99d6088881562e50149f414f76a5be0140 -Author: Doug Flick -Date: Tue Feb 13 10:46:01 2024 -0800 - - NetworkPkg: Dhcp6Dxe: Removes duplicate check and replaces with macro - - Removes duplicate check after merge - - > - > // - > // Verify the PacketCursor is within the packet - > // - > if ( (*PacketCursor < Packet->Dhcp6.Option) - > || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - - sizeof (EFI_DHCP6_HEADER)))) - > { - > return EFI_INVALID_PARAMETER; - > } - > - - Converts the check to a macro and replaces all instances of the check - with the macro - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - Reviewed-by: Leif Lindholm - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 43 +++++++++++++----------------- - 1 file changed, 18 insertions(+), 25 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -index 484c360a96..e172ffc2a2 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -@@ -10,6 +10,15 @@ - - #include "Dhcp6Impl.h" - -+// -+// Verifies the packet cursor is within the packet -+// otherwise it is invalid -+// -+#define IS_INVALID_PACKET_CURSOR(PacketCursor, Packet) \ -+ (((*PacketCursor) < (Packet)->Dhcp6.Option) || \ -+ ((*PacketCursor) >= (Packet)->Dhcp6.Option + ((Packet)->Size - sizeof(EFI_DHCP6_HEADER))) \ -+ ) \ -+ - - /** - Generate client Duid in the format of Duid-llt. -@@ -662,9 +671,7 @@ Dhcp6AppendOption ( - // - // Verify the PacketCursor is within the packet - // -- if ( (*PacketCursor < Packet->Dhcp6.Option) -- || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -- { -+ if (IS_INVALID_PACKET_CURSOR (PacketCursor, Packet)) { - return EFI_INVALID_PARAMETER; - } - -@@ -681,15 +688,6 @@ Dhcp6AppendOption ( - return EFI_BUFFER_TOO_SMALL; - } - -- // -- // Verify the PacketCursor is within the packet -- // -- if ( (*PacketCursor < Packet->Dhcp6.Option) -- || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -- { -- return EFI_INVALID_PARAMETER; -- } -- - WriteUnaligned16 ((UINT16 *)*PacketCursor, OptType); - *PacketCursor += DHCP6_SIZE_OF_OPT_CODE; - WriteUnaligned16 ((UINT16 *)*PacketCursor, OptLen); -@@ -768,9 +766,7 @@ Dhcp6AppendIaAddrOption ( - // - // Verify the PacketCursor is within the packet - // -- if ( (*PacketCursor < Packet->Dhcp6.Option) -- || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -- { -+ if (IS_INVALID_PACKET_CURSOR (PacketCursor, Packet)) { - return EFI_INVALID_PARAMETER; - } - -@@ -902,9 +898,7 @@ Dhcp6AppendIaOption ( - // - // Verify the PacketCursor is within the packet - // -- if ( (*PacketCursor < Packet->Dhcp6.Option) -- || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -- { -+ if (IS_INVALID_PACKET_CURSOR (PacketCursor, Packet)) { - return EFI_INVALID_PARAMETER; - } - -@@ -966,14 +960,14 @@ Dhcp6AppendIaOption ( - } - - // -- // Fill the value of Ia option length -+ // Update the packet length - // -- *Len = HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2)); -+ Packet->Length += BytesNeeded; - - // -- // Update the packet length -+ // Fill the value of Ia option length - // -- Packet->Length += BytesNeeded; -+ *Len = HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2)); - - return EFI_SUCCESS; - } -@@ -982,6 +976,7 @@ Dhcp6AppendIaOption ( - Append the appointed Elapsed time option to Buf, and move Buf to the end. - - @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. - @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor - will be moved to the end of the option. - @param[in] Instance The pointer to the Dhcp6 instance. -@@ -1037,9 +1032,7 @@ Dhcp6AppendETOption ( - // - // Verify the PacketCursor is within the packet - // -- if ( (*PacketCursor < Packet->Dhcp6.Option) -- || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -- { -+ if (IS_INVALID_PACKET_CURSOR (PacketCursor, Packet)) { - return EFI_INVALID_PARAMETER; - } - --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Pa.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Pa.patch deleted file mode 100644 index dcf5bb7..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Pa.patch +++ /dev/null @@ -1,621 +0,0 @@ -From a115d0a66c3e73c60b74ec6d09e3759da89e919b Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 9 Feb 2024 17:57:07 -0500 -Subject: [PATCH 17/17] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 - Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 50: CVE-2023-45230 and CVE-2023-45229 -RH-Jira: RHEL-21840 RHEL-21842 -RH-Acked-by: Oliver Steffen -RH-Commit: [4/4] 3daf69000f78416ee1f1bad0b6ceb01ed28a84a5 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21840 -CVE: CVE-2023-45229 -Upstream: Merged - -commit 1dbb10cc52dc8ef49bb700daa1cefc76b26d52e0 -Author: Doug Flick via groups.io -Date: Fri Jan 26 05:54:46 2024 +0800 - - NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Patch - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4534 - - Bug Details: - PixieFail Bug #1 - CVE-2023-45229 - CVSS 6.5 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N - CWE-125 Out-of-bounds Read - - Change Overview: - - Introduce Dhcp6SeekInnerOptionSafe which performs checks before seeking - the Inner Option from a DHCP6 Option. - - > - > EFI_STATUS - > Dhcp6SeekInnerOptionSafe ( - > IN UINT16 IaType, - > IN UINT8 *Option, - > IN UINT32 OptionLen, - > OUT UINT8 **IaInnerOpt, - > OUT UINT16 *IaInnerLen - > ); - > - - Lots of code cleanup to improve code readability. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h | 138 ++++++++++++++++++--- - NetworkPkg/Dhcp6Dxe/Dhcp6Io.c | 205 +++++++++++++++++++++----------- - 2 files changed, 257 insertions(+), 86 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -index ec0ed5d8f5..e759ab9a62 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -@@ -47,6 +47,20 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE; - #define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S') - #define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I') - -+#define DHCP6_PACKET_ALL 0 -+#define DHCP6_PACKET_STATEFUL 1 -+#define DHCP6_PACKET_STATELESS 2 -+ -+#define DHCP6_BASE_PACKET_SIZE 1024 -+ -+#define DHCP6_PORT_CLIENT 546 -+#define DHCP6_PORT_SERVER 547 -+ -+#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) -+ -+#define DHCP6_INSTANCE_FROM_THIS(Instance) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE) -+#define DHCP6_SERVICE_FROM_THIS(Service) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE) -+ - // - // For more information on DHCP options see RFC 8415, Section 21.1 - // -@@ -61,12 +75,10 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE; - // | (option-len octets) | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // --#define DHCP6_SIZE_OF_OPT_CODE (sizeof(UINT16)) --#define DHCP6_SIZE_OF_OPT_LEN (sizeof(UINT16)) -+#define DHCP6_SIZE_OF_OPT_CODE (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpCode)) -+#define DHCP6_SIZE_OF_OPT_LEN (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpLen)) - --// - // Combined size of Code and Length --// - #define DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN (DHCP6_SIZE_OF_OPT_CODE + \ - DHCP6_SIZE_OF_OPT_LEN) - -@@ -75,34 +87,122 @@ STATIC_ASSERT ( - "Combined size of Code and Length must be 4 per RFC 8415" - ); - --// - // Offset to the length is just past the code --// --#define DHCP6_OPT_LEN_OFFSET(a) (a + DHCP6_SIZE_OF_OPT_CODE) -+#define DHCP6_OFFSET_OF_OPT_LEN(a) (a + DHCP6_SIZE_OF_OPT_CODE) - STATIC_ASSERT ( -- DHCP6_OPT_LEN_OFFSET (0) == 2, -+ DHCP6_OFFSET_OF_OPT_LEN (0) == 2, - "Offset of length is + 2 past start of option" - ); - --#define DHCP6_OPT_DATA_OFFSET(a) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN) -+#define DHCP6_OFFSET_OF_OPT_DATA(a) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN) - STATIC_ASSERT ( -- DHCP6_OPT_DATA_OFFSET (0) == 4, -+ DHCP6_OFFSET_OF_OPT_DATA (0) == 4, - "Offset to option data should be +4 from start of option" - ); -+// -+// Identity Association options (both NA (Non-Temporary) and TA (Temporary Association)) -+// are defined in RFC 8415 and are a deriviation of a TLV stucture -+// For more information on IA_NA see Section 21.4 -+// For more information on IA_TA see Section 21.5 -+// -+// -+// The format of IA_NA and IA_TA option: -+// -+// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | OPTION_IA_NA | option-len | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | IAID (4 octets) | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | T1 (only for IA_NA) | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | T2 (only for IA_NA) | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | | -+// . IA_NA-options/IA_TA-options . -+// . . -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// -+#define DHCP6_SIZE_OF_IAID (sizeof(UINT32)) -+#define DHCP6_SIZE_OF_TIME_INTERVAL (sizeof(UINT32)) - --#define DHCP6_PACKET_ALL 0 --#define DHCP6_PACKET_STATEFUL 1 --#define DHCP6_PACKET_STATELESS 2 -+// Combined size of IAID, T1, and T2 -+#define DHCP6_SIZE_OF_COMBINED_IAID_T1_T2 (DHCP6_SIZE_OF_IAID + \ -+ DHCP6_SIZE_OF_TIME_INTERVAL + \ -+ DHCP6_SIZE_OF_TIME_INTERVAL) -+STATIC_ASSERT ( -+ DHCP6_SIZE_OF_COMBINED_IAID_T1_T2 == 12, -+ "Combined size of IAID, T1, T2 must be 12 per RFC 8415" -+ ); - --#define DHCP6_BASE_PACKET_SIZE 1024 -+// This is the size of IA_TA without options -+#define DHCP6_MIN_SIZE_OF_IA_TA (DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \ -+ DHCP6_SIZE_OF_IAID) -+STATIC_ASSERT ( -+ DHCP6_MIN_SIZE_OF_IA_TA == 8, -+ "Minimum combined size of IA_TA per RFC 8415" -+ ); - --#define DHCP6_PORT_CLIENT 546 --#define DHCP6_PORT_SERVER 547 -+// Offset to a IA_TA inner option -+#define DHCP6_OFFSET_OF_IA_TA_INNER_OPT(a) (a + DHCP6_MIN_SIZE_OF_IA_TA) -+STATIC_ASSERT ( -+ DHCP6_OFFSET_OF_IA_TA_INNER_OPT (0) == 8, -+ "Offset of IA_TA Inner option is + 8 past start of option" -+ ); - --#define DHCP_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20) -+// This is the size of IA_NA without options (16) -+#define DHCP6_MIN_SIZE_OF_IA_NA DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \ -+ DHCP6_SIZE_OF_COMBINED_IAID_T1_T2 -+STATIC_ASSERT ( -+ DHCP6_MIN_SIZE_OF_IA_NA == 16, -+ "Minimum combined size of IA_TA per RFC 8415" -+ ); - --#define DHCP6_INSTANCE_FROM_THIS(Instance) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE) --#define DHCP6_SERVICE_FROM_THIS(Service) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE) -+#define DHCP6_OFFSET_OF_IA_NA_INNER_OPT(a) (a + DHCP6_MIN_SIZE_OF_IA_NA) -+STATIC_ASSERT ( -+ DHCP6_OFFSET_OF_IA_NA_INNER_OPT (0) == 16, -+ "Offset of IA_NA Inner option is + 16 past start of option" -+ ); -+ -+#define DHCP6_OFFSET_OF_IA_NA_T1(a) (a + \ -+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + \ -+ DHCP6_SIZE_OF_IAID) -+STATIC_ASSERT ( -+ DHCP6_OFFSET_OF_IA_NA_T1 (0) == 8, -+ "Offset of IA_NA Inner option is + 8 past start of option" -+ ); -+ -+#define DHCP6_OFFSET_OF_IA_NA_T2(a) (a + \ -+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN +\ -+ DHCP6_SIZE_OF_IAID + \ -+ DHCP6_SIZE_OF_TIME_INTERVAL) -+STATIC_ASSERT ( -+ DHCP6_OFFSET_OF_IA_NA_T2 (0) == 12, -+ "Offset of IA_NA Inner option is + 12 past start of option" -+ ); -+ -+// -+// For more information see RFC 8415 Section 21.13 -+// -+// The format of the Status Code Option: -+// -+// 0 1 2 3 -+// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | OPTION_STATUS_CODE | option-len | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | status-code | | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | -+// . . -+// . status-message . -+// . . -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// -+#define DHCP6_OFFSET_OF_STATUS_CODE(a) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN) -+STATIC_ASSERT ( -+ DHCP6_OFFSET_OF_STATUS_CODE (0) == 4, -+ "Offset of status is + 4 past start of option" -+ ); - - extern EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress; - extern EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate; -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -index 2976684aba..d680febbf1 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -@@ -611,8 +611,8 @@ Dhcp6UpdateIaInfo ( - // The inner options still start with 2 bytes option-code and 2 bytes option-len. - // - if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) { -- T1 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 8))); -- T2 = NTOHL (ReadUnaligned32 ((UINT32 *) (Option + 12))); -+ T1 = NTOHL (ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T1 (Option)))); -+ T2 = NTOHL (ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T2 (Option)))); - // - // Refer to RFC3155 Chapter 22.4. If a client receives an IA_NA with T1 greater than T2, - // and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes -@@ -621,13 +621,14 @@ Dhcp6UpdateIaInfo ( - if (T1 > T2 && T2 > 0) { - return EFI_DEVICE_ERROR; - } -- IaInnerOpt = Option + 16; -- IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 12); -+ IaInnerOpt = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option); -+ IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))) - DHCP6_SIZE_OF_COMBINED_IAID_T1_T2); - } else { - T1 = 0; - T2 = 0; -- IaInnerOpt = Option + 8; -- IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 2))) - 4); -+ -+ IaInnerOpt = DHCP6_OFFSET_OF_IA_TA_INNER_OPT (Option); -+ IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))) - DHCP6_SIZE_OF_IAID); - } - - // -@@ -653,7 +654,7 @@ Dhcp6UpdateIaInfo ( - Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); - - if (Option != NULL) { -- StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4))); -+ StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))); - if (StsCode != Dhcp6StsSuccess) { - return EFI_DEVICE_ERROR; - } -@@ -675,6 +676,87 @@ Dhcp6UpdateIaInfo ( - - - -+/** -+ Seeks the Inner Options from a DHCP6 Option -+ -+ @param[in] IaType The type of the IA option. -+ @param[in] Option The pointer to the DHCP6 Option. -+ @param[in] OptionLen The length of the DHCP6 Option. -+ @param[out] IaInnerOpt The pointer to the IA inner option. -+ @param[out] IaInnerLen The length of the IA inner option. -+ -+ @retval EFI_SUCCESS Seek the inner option successfully. -+ @retval EFI_DEVICE_ERROR The OptionLen is invalid. On Error, -+ the pointers are not modified -+**/ -+EFI_STATUS -+Dhcp6SeekInnerOptionSafe ( -+ IN UINT16 IaType, -+ IN UINT8 *Option, -+ IN UINT32 OptionLen, -+ OUT UINT8 **IaInnerOpt, -+ OUT UINT16 *IaInnerLen -+ ) -+{ -+ UINT16 IaInnerLenTmp; -+ UINT8 *IaInnerOptTmp; -+ -+ if (Option == NULL) { -+ ASSERT (Option != NULL); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ if (IaInnerOpt == NULL) { -+ ASSERT (IaInnerOpt != NULL); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ if (IaInnerLen == NULL) { -+ ASSERT (IaInnerLen != NULL); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ if (IaType == Dhcp6OptIana) { -+ // Verify we have a fully formed IA_NA -+ if (OptionLen < DHCP6_MIN_SIZE_OF_IA_NA) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ IaInnerOptTmp = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option); -+ -+ // Verify the IaInnerLen is valid. -+ IaInnerLenTmp = (UINT16)NTOHS (ReadUnaligned16 ((UINT16 *)DHCP6_OFFSET_OF_OPT_LEN (Option))); -+ if (IaInnerLenTmp < DHCP6_SIZE_OF_COMBINED_IAID_T1_T2) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ IaInnerLenTmp -= DHCP6_SIZE_OF_COMBINED_IAID_T1_T2; -+ } else if (IaType == Dhcp6OptIata) { -+ // Verify the OptionLen is valid. -+ if (OptionLen < DHCP6_MIN_SIZE_OF_IA_TA) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ IaInnerOptTmp = DHCP6_OFFSET_OF_IA_TA_INNER_OPT (Option); -+ -+ // Verify the IaInnerLen is valid. -+ IaInnerLenTmp = (UINT16)NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))); -+ if (IaInnerLenTmp < DHCP6_SIZE_OF_IAID) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ IaInnerLenTmp -= DHCP6_SIZE_OF_IAID; -+ } else { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ *IaInnerOpt = IaInnerOptTmp; -+ *IaInnerLen = IaInnerLenTmp; -+ -+ return EFI_SUCCESS; -+} -+ - /** - Seek StatusCode Option in package. A Status Code option may appear in the - options field of a DHCP message and/or in the options field of another option. -@@ -695,9 +777,15 @@ Dhcp6SeekStsOption ( - OUT UINT8 **Option - ) - { -- UINT8 *IaInnerOpt; -- UINT16 IaInnerLen; -- UINT16 StsCode; -+ UINT8 *IaInnerOpt; -+ UINT16 IaInnerLen; -+ UINT16 StsCode; -+ UINT32 OptionLen; -+ -+ // OptionLen is the length of the Options excluding the DHCP header. -+ // Length of the EFI_DHCP6_PACKET from the first byte of the Header field to the last -+ // byte of the Option[] field. -+ OptionLen = Packet->Length - sizeof (Packet->Dhcp6.Header); - - // - // Seek StatusCode option directly in DHCP message body. That is, search in -@@ -705,12 +793,12 @@ Dhcp6SeekStsOption ( - // - *Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ OptionLen, - Dhcp6OptStatusCode - ); - - if (*Option != NULL) { -- StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4))); -+ StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_STATUS_CODE (*Option)))); - if (StsCode != Dhcp6StsSuccess) { - return EFI_DEVICE_ERROR; - } -@@ -721,7 +809,7 @@ Dhcp6SeekStsOption ( - // - *Option = Dhcp6SeekIaOption ( - Packet->Dhcp6.Option, -- Packet->Length - sizeof (EFI_DHCP6_HEADER), -+ OptionLen, - &Instance->Config->IaDescriptor - ); - if (*Option == NULL) { -@@ -729,52 +817,35 @@ Dhcp6SeekStsOption ( - } - - // -- // The format of the IA_NA option is: -+ // Calculate the distance from Packet->Dhcp6.Option to the IA option. - // -- // 0 1 2 3 -- // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | OPTION_IA_NA | option-len | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | IAID (4 octets) | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | T1 | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | T2 | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | | -- // . IA_NA-options . -- // . . -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+ // Packet->Size and Packet->Length are both UINT32 type, and Packet->Size is -+ // the size of the whole packet, including the DHCP header, and Packet->Length -+ // is the length of the DHCP message body, excluding the DHCP header. - // -- // The format of the IA_TA option is: -+ // (*Option - Packet->Dhcp6.Option) is the number of bytes from the start of -+ // DHCP6 option area to the start of the IA option. - // -- // 0 1 2 3 -- // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | OPTION_IA_TA | option-len | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | IAID (4 octets) | -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- // | | -- // . IA_TA-options . -- // . . -- // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+ // Dhcp6SeekInnerOptionSafe() is searching starting from the start of the -+ // IA option to the end of the DHCP6 option area, thus subtract the space -+ // up until this option - // -+ OptionLen = OptionLen - (*Option - Packet->Dhcp6.Option); - - // -- // sizeof (option-code + option-len + IaId) = 8 -- // sizeof (option-code + option-len + IaId + T1) = 12 -- // sizeof (option-code + option-len + IaId + T1 + T2) = 16 -+ // Seek the inner option - // -- // The inner options still start with 2 bytes option-code and 2 bytes option-len. -- // -- if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) { -- IaInnerOpt = *Option + 16; -- IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 2))) - 12); -- } else { -- IaInnerOpt = *Option + 8; -- IaInnerLen = (UINT16) (NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 2))) - 4); -+ if (EFI_ERROR ( -+ Dhcp6SeekInnerOptionSafe ( -+ Instance->Config->IaDescriptor.Type, -+ *Option, -+ OptionLen, -+ &IaInnerOpt, -+ &IaInnerLen -+ ) -+ )) -+ { -+ return EFI_DEVICE_ERROR; - } - - // -@@ -798,7 +869,7 @@ Dhcp6SeekStsOption ( - // - *Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); - if (*Option != NULL) { -- StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (*Option + 4))); -+ StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (*Option))))); - if (StsCode != Dhcp6StsSuccess) { - return EFI_DEVICE_ERROR; - } -@@ -1123,7 +1194,7 @@ Dhcp6SendRequestMsg ( - // - Option = Dhcp6SeekOption ( - Instance->AdSelect->Dhcp6.Option, -- Instance->AdSelect->Length - 4, -+ Instance->AdSelect->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerId - ); - if (Option == NULL) { -@@ -1309,7 +1380,7 @@ Dhcp6SendDeclineMsg ( - // - Option = Dhcp6SeekOption ( - LastReply->Dhcp6.Option, -- LastReply->Length - 4, -+ LastReply->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerId - ); - if (Option == NULL) { -@@ -1469,7 +1540,7 @@ Dhcp6SendReleaseMsg ( - // - Option = Dhcp6SeekOption ( - LastReply->Dhcp6.Option, -- LastReply->Length - 4, -+ LastReply->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerId - ); - if (Option == NULL) { -@@ -1695,7 +1766,7 @@ Dhcp6SendRenewRebindMsg ( - - Option = Dhcp6SeekOption ( - LastReply->Dhcp6.Option, -- LastReply->Length - 4, -+ LastReply->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerId - ); - if (Option == NULL) { -@@ -2235,7 +2306,7 @@ Dhcp6HandleReplyMsg ( - // - Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ Packet->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptRapidCommit - ); - -@@ -2383,7 +2454,7 @@ Dhcp6HandleReplyMsg ( - // - // Any error status code option is found. - // -- StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) (Option + 4))); -+ StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)((DHCP6_OFFSET_OF_STATUS_CODE (Option))))); - switch (StsCode) { - case Dhcp6StsUnspecFail: - // -@@ -2514,7 +2585,7 @@ Dhcp6SelectAdvertiseMsg ( - // - Option = Dhcp6SeekOption( - AdSelect->Dhcp6.Option, -- AdSelect->Length - 4, -+ AdSelect->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerUnicast - ); - -@@ -2526,7 +2597,7 @@ Dhcp6SelectAdvertiseMsg ( - return EFI_OUT_OF_RESOURCES; - } - -- CopyMem (Instance->Unicast, Option + 4, sizeof(EFI_IPv6_ADDRESS)); -+ CopyMem (Instance->Unicast, DHCP6_OFFSET_OF_OPT_DATA (Option), sizeof (EFI_IPv6_ADDRESS)); - } - - // -@@ -2580,7 +2651,7 @@ Dhcp6HandleAdvertiseMsg ( - // - Option = Dhcp6SeekOption( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ Packet->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptRapidCommit - ); - -@@ -2676,7 +2747,7 @@ Dhcp6HandleAdvertiseMsg ( - CopyMem (Instance->AdSelect, Packet, Packet->Size); - - if (Option != NULL) { -- Instance->AdPref = *(Option + 4); -+ Instance->AdPref = *(DHCP6_OFFSET_OF_OPT_DATA (Option)); - } - } else { - // -@@ -2747,11 +2818,11 @@ Dhcp6HandleStateful ( - // - Option = Dhcp6SeekOption( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN, - Dhcp6OptClientId - ); - -- if (Option == NULL || CompareMem (Option + 4, ClientId->Duid, ClientId->Length) != 0) { -+ if ((Option == NULL) || (CompareMem (DHCP6_OFFSET_OF_OPT_DATA (Option), ClientId->Duid, ClientId->Length) != 0)) { - goto ON_CONTINUE; - } - -@@ -2760,7 +2831,7 @@ Dhcp6HandleStateful ( - // - Option = Dhcp6SeekOption( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ Packet->Length - DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN, - Dhcp6OptServerId - ); - -@@ -2865,7 +2936,7 @@ Dhcp6HandleStateless ( - // - Option = Dhcp6SeekOption ( - Packet->Dhcp6.Option, -- Packet->Length - 4, -+ Packet->Length - sizeof (EFI_DHCP6_HEADER), - Dhcp6OptServerId - ); - --- -2.41.0 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Re.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Re.patch deleted file mode 100644 index ea1b84f..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Re.patch +++ /dev/null @@ -1,257 +0,0 @@ -From 1b58858f28a364a8f8fa897a78db7ced068719dd Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 13/15] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 - Related Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [13/15] 904fd82592208d0ca42bbb64f437691a5bdfd0b6 - -JIRA: https://issues.redhat.com/browse/RHEL-21840 -CVE: CVE-2023-45229 -Upstream: Merged - -commit 1c440a5eceedc64e892877eeac0f1a4938f5abbb -Author: Doug Flick -Date: Tue Feb 13 10:46:00 2024 -0800 - - NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45229 Related Patch - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4673 - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4534 - - This was not part of the Quarkslab bugs however the same pattern - as CVE-2023-45229 exists in Dhcp6UpdateIaInfo. - - This patch replaces the code in question with the safe function - created to patch CVE-2023-45229 - - > - > if (EFI_ERROR ( - > Dhcp6SeekInnerOptionSafe ( - > Instance->Config->IaDescriptor.Type, - > Option, - > OptionLen, - > &IaInnerOpt, - > &IaInnerLen - > ) - > )) - > { - > return EFI_DEVICE_ERROR; - > } - > - - Additionally corrects incorrect usage of macro to read the status - - > - StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)DHCP6_OFFSET_OF_OPT_LEN - (Option))); - > + StsCode = NTOHS (ReadUnaligned16 ((UINT16 *) - DHCP6_OFFSET_OF_STATUS_CODE (Option)); - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - Reviewed-by: Leif Lindholm - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Io.c | 70 ++++++++++++++++++++++++++--------- - NetworkPkg/Dhcp6Dxe/Dhcp6Io.h | 22 +++++++++++ - 2 files changed, 75 insertions(+), 17 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -index 3b8feb4a20..a9bffae353 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -@@ -528,13 +528,23 @@ Dhcp6UpdateIaInfo ( - { - EFI_STATUS Status; - UINT8 *Option; -+ UINT32 OptionLen; - UINT8 *IaInnerOpt; - UINT16 IaInnerLen; - UINT16 StsCode; - UINT32 T1; - UINT32 T2; - -+ T1 = 0; -+ T2 = 0; -+ - ASSERT (Instance->Config != NULL); -+ -+ // OptionLen is the length of the Options excluding the DHCP header. -+ // Length of the EFI_DHCP6_PACKET from the first byte of the Header field to the last -+ // byte of the Option[] field. -+ OptionLen = Packet->Length - sizeof (Packet->Dhcp6.Header); -+ - // - // If the reply was received in response to a solicit with rapid commit option, - // request, renew or rebind message, the client updates the information it has -@@ -549,13 +559,29 @@ Dhcp6UpdateIaInfo ( - // - Option = Dhcp6SeekIaOption ( - Packet->Dhcp6.Option, -- Packet->Length - sizeof (EFI_DHCP6_HEADER), -+ OptionLen, - &Instance->Config->IaDescriptor - ); - if (Option == NULL) { - return EFI_DEVICE_ERROR; - } - -+ // -+ // Calculate the distance from Packet->Dhcp6.Option to the IA option. -+ // -+ // Packet->Size and Packet->Length are both UINT32 type, and Packet->Size is -+ // the size of the whole packet, including the DHCP header, and Packet->Length -+ // is the length of the DHCP message body, excluding the DHCP header. -+ // -+ // (*Option - Packet->Dhcp6.Option) is the number of bytes from the start of -+ // DHCP6 option area to the start of the IA option. -+ // -+ // Dhcp6SeekInnerOptionSafe() is searching starting from the start of the -+ // IA option to the end of the DHCP6 option area, thus subtract the space -+ // up until this option -+ // -+ OptionLen = OptionLen - (UINT32)(Option - Packet->Dhcp6.Option); -+ - // - // The format of the IA_NA option is: - // -@@ -591,32 +617,32 @@ Dhcp6UpdateIaInfo ( - // - - // -- // sizeof (option-code + option-len + IaId) = 8 -- // sizeof (option-code + option-len + IaId + T1) = 12 -- // sizeof (option-code + option-len + IaId + T1 + T2) = 16 -- // -- // The inner options still start with 2 bytes option-code and 2 bytes option-len. -+ // Seek the inner option - // -+ if (EFI_ERROR ( -+ Dhcp6SeekInnerOptionSafe ( -+ Instance->Config->IaDescriptor.Type, -+ Option, -+ OptionLen, -+ &IaInnerOpt, -+ &IaInnerLen -+ ) -+ )) -+ { -+ return EFI_DEVICE_ERROR; -+ } -+ - if (Instance->Config->IaDescriptor.Type == Dhcp6OptIana) { - T1 = NTOHL (ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T1 (Option)))); - T2 = NTOHL (ReadUnaligned32 ((UINT32 *)(DHCP6_OFFSET_OF_IA_NA_T2 (Option)))); - // - // Refer to RFC3155 Chapter 22.4. If a client receives an IA_NA with T1 greater than T2, - // and both T1 and T2 are greater than 0, the client discards the IA_NA option and processes -- // the remainder of the message as though the server had not included the invalid IA_NA option. -+ // the remainder of the message as though the server had not included the invalid IA_NA option. - // - if ((T1 > T2) && (T2 > 0)) { - return EFI_DEVICE_ERROR; - } -- -- IaInnerOpt = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option); -- IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))) - DHCP6_SIZE_OF_COMBINED_IAID_T1_T2); -- } else { -- T1 = 0; -- T2 = 0; -- -- IaInnerOpt = DHCP6_OFFSET_OF_IA_TA_INNER_OPT (Option); -- IaInnerLen = (UINT16)(NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))) - DHCP6_SIZE_OF_IAID); - } - - // -@@ -642,7 +668,7 @@ Dhcp6UpdateIaInfo ( - Option = Dhcp6SeekOption (IaInnerOpt, IaInnerLen, Dhcp6OptStatusCode); - - if (Option != NULL) { -- StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))); -+ StsCode = NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_STATUS_CODE (Option)))); - if (StsCode != Dhcp6StsSuccess) { - return EFI_DEVICE_ERROR; - } -@@ -703,15 +729,21 @@ Dhcp6SeekInnerOptionSafe ( - } - - if (IaType == Dhcp6OptIana) { -+ // - // Verify we have a fully formed IA_NA -+ // - if (OptionLen < DHCP6_MIN_SIZE_OF_IA_NA) { - return EFI_DEVICE_ERROR; - } - -+ // -+ // Get the IA Inner Option and Length - // - IaInnerOptTmp = DHCP6_OFFSET_OF_IA_NA_INNER_OPT (Option); - -+ // - // Verify the IaInnerLen is valid. -+ // - IaInnerLenTmp = (UINT16)NTOHS (ReadUnaligned16 ((UINT16 *)DHCP6_OFFSET_OF_OPT_LEN (Option))); - if (IaInnerLenTmp < DHCP6_SIZE_OF_COMBINED_IAID_T1_T2) { - return EFI_DEVICE_ERROR; -@@ -719,14 +751,18 @@ Dhcp6SeekInnerOptionSafe ( - - IaInnerLenTmp -= DHCP6_SIZE_OF_COMBINED_IAID_T1_T2; - } else if (IaType == Dhcp6OptIata) { -+ // - // Verify the OptionLen is valid. -+ // - if (OptionLen < DHCP6_MIN_SIZE_OF_IA_TA) { - return EFI_DEVICE_ERROR; - } - - IaInnerOptTmp = DHCP6_OFFSET_OF_IA_TA_INNER_OPT (Option); - -+ // - // Verify the IaInnerLen is valid. -+ // - IaInnerLenTmp = (UINT16)NTOHS (ReadUnaligned16 ((UINT16 *)(DHCP6_OFFSET_OF_OPT_LEN (Option)))); - if (IaInnerLenTmp < DHCP6_SIZE_OF_IAID) { - return EFI_DEVICE_ERROR; -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h -index 554f0f5e5d..8c0d282bca 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.h -@@ -218,4 +218,26 @@ Dhcp6OnTimerTick ( - IN VOID *Context - ); - -+/** -+ Seeks the Inner Options from a DHCP6 Option -+ -+ @param[in] IaType The type of the IA option. -+ @param[in] Option The pointer to the DHCP6 Option. -+ @param[in] OptionLen The length of the DHCP6 Option. -+ @param[out] IaInnerOpt The pointer to the IA inner option. -+ @param[out] IaInnerLen The length of the IA inner option. -+ -+ @retval EFI_SUCCESS Seek the inner option successfully. -+ @retval EFI_DEVICE_ERROR The OptionLen is invalid. On Error, -+ the pointers are not modified -+**/ -+EFI_STATUS -+Dhcp6SeekInnerOptionSafe ( -+ IN UINT16 IaType, -+ IN UINT8 *Option, -+ IN UINT32 OptionLen, -+ OUT UINT8 **IaInnerOpt, -+ OUT UINT16 *IaInnerLen -+ ); -+ - #endif --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Pa.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Pa.patch deleted file mode 100644 index f4ee0d4..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Pa.patch +++ /dev/null @@ -1,1644 +0,0 @@ -From 1ef9758121ee50437322d84ce394279e38a7055f Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 8 Feb 2024 10:35:14 -0500 -Subject: [PATCH 14/17] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 - Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 50: CVE-2023-45230 and CVE-2023-45229 -RH-Jira: RHEL-21840 RHEL-21842 -RH-Acked-by: Oliver Steffen -RH-Commit: [1/4] 26695f0c8bd1032ba04179cb9281f753fcff2c92 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21842 -CVE: CVE-2023-45230 -Upstream: Merged -Conflicts: Only whitespace issues caused by the 'uncrustify' tool. - -commit f31453e8d6542461d92d835e0b79fec8b039174d -Author: Doug Flick via groups.io -Date: Fri Jan 26 05:54:43 2024 +0800 - - NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Patch - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4535 - - Bug Details: - PixieFail Bug #2 - CVE-2023-45230 - CVSS 8.3 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H - CWE-119 Improper Restriction of Operations within the Bounds - of a Memory Buffer - - Changes Overview: - > -UINT8 * - > +EFI_STATUS - > Dhcp6AppendOption ( - > - IN OUT UINT8 *Buf, - > - IN UINT16 OptType, - > - IN UINT16 OptLen, - > - IN UINT8 *Data - > + IN OUT EFI_DHCP6_PACKET *Packet, - > + IN OUT UINT8 **PacketCursor, - > + IN UINT16 OptType, - > + IN UINT16 OptLen, - > + IN UINT8 *Data - > ); - - Dhcp6AppendOption() and variants can return errors now. All callsites - are adapted accordingly. - - It gets passed in EFI_DHCP6_PACKET as additional parameter ... - - > + // - > + // Verify the PacketCursor is within the packet - > + // - > + if ( (*PacketCursor < Packet->Dhcp6.Option) - > + || (*PacketCursor >= Packet->Dhcp6.Option + - (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) - > + { - > + return EFI_INVALID_PARAMETER; - > + } - - ... so it can look at Packet->Size when checking buffer space. - Also to allow Packet->Length updates. - - Lots of checks added. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h | 49 +++- - NetworkPkg/Dhcp6Dxe/Dhcp6Io.c | 409 +++++++++++++++++++---------- - NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c | 382 +++++++++++++++++++++------ - NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h | 82 +++--- - 4 files changed, 676 insertions(+), 246 deletions(-) - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -index f88b00ad04..ec0ed5d8f5 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h -@@ -47,9 +47,52 @@ typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE; - #define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S') - #define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I') - --#define DHCP6_PACKET_ALL 0 --#define DHCP6_PACKET_STATEFUL 1 --#define DHCP6_PACKET_STATELESS 2 -+// -+// For more information on DHCP options see RFC 8415, Section 21.1 -+// -+// The format of DHCP options is: -+// -+// 0 1 2 3 -+// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | option-code | option-len | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | option-data | -+// | (option-len octets) | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// -+#define DHCP6_SIZE_OF_OPT_CODE (sizeof(UINT16)) -+#define DHCP6_SIZE_OF_OPT_LEN (sizeof(UINT16)) -+ -+// -+// Combined size of Code and Length -+// -+#define DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN (DHCP6_SIZE_OF_OPT_CODE + \ -+ DHCP6_SIZE_OF_OPT_LEN) -+ -+STATIC_ASSERT ( -+ DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN == 4, -+ "Combined size of Code and Length must be 4 per RFC 8415" -+ ); -+ -+// -+// Offset to the length is just past the code -+// -+#define DHCP6_OPT_LEN_OFFSET(a) (a + DHCP6_SIZE_OF_OPT_CODE) -+STATIC_ASSERT ( -+ DHCP6_OPT_LEN_OFFSET (0) == 2, -+ "Offset of length is + 2 past start of option" -+ ); -+ -+#define DHCP6_OPT_DATA_OFFSET(a) (a + DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN) -+STATIC_ASSERT ( -+ DHCP6_OPT_DATA_OFFSET (0) == 4, -+ "Offset to option data should be +4 from start of option" -+ ); -+ -+#define DHCP6_PACKET_ALL 0 -+#define DHCP6_PACKET_STATEFUL 1 -+#define DHCP6_PACKET_STATELESS 2 - - #define DHCP6_BASE_PACKET_SIZE 1024 - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -index c20876d5a5..2976684aba 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Io.c -@@ -3,9 +3,9 @@ - - (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-+ Copyright (c) Microsoft Corporation - - SPDX-License-Identifier: BSD-2-Clause-Patent -- - **/ - - #include "Dhcp6Impl.h" -@@ -946,7 +946,8 @@ Dhcp6SendSolicitMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE + UserLen); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE + UserLen; -@@ -960,26 +961,38 @@ Dhcp6SendSolicitMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption ( -- Cursor, -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, - Instance->IaCb.Ia, - Instance->IaCb.T1, - Instance->IaCb.T2, - Packet->Dhcp6.Header.MessageType - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - // - // Append user-defined when configurate Dhcp6 service. -@@ -987,28 +1000,26 @@ Dhcp6SendSolicitMsg ( - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { - - UserOpt = Instance->Config->OptionList[Index]; -- Cursor = Dhcp6AppendOption( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - UserOpt->OpCode, - UserOpt->OpLen, - UserOpt->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // - // Callback to user with the packet to be sent and check the user's feedback. - // - Status = Dhcp6CallbackUser (Instance, Dhcp6SendSolicit, &Packet); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1022,10 +1033,8 @@ Dhcp6SendSolicitMsg ( - Instance->StartTime = 0; - - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1037,6 +1046,14 @@ Dhcp6SendSolicitMsg ( - Elapsed, - Instance->Config->SolicitRetransmission - ); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - /** -@@ -1128,7 +1145,8 @@ Dhcp6SendRequestMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE + UserLen); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE + UserLen; -@@ -1142,33 +1160,49 @@ Dhcp6SendRequestMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptServerId), - ServerId->Length, - ServerId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption ( -- Cursor, -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, - Instance->IaCb.Ia, - Instance->IaCb.T1, - Instance->IaCb.T2, - Packet->Dhcp6.Header.MessageType - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - // - // Append user-defined when configurate Dhcp6 service. -@@ -1176,18 +1210,18 @@ Dhcp6SendRequestMsg ( - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { - - UserOpt = Instance->Config->OptionList[Index]; -- Cursor = Dhcp6AppendOption( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - UserOpt->OpCode, - UserOpt->OpLen, - UserOpt->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // -@@ -1196,8 +1230,7 @@ Dhcp6SendRequestMsg ( - Status = Dhcp6CallbackUser (Instance, Dhcp6SendRequest, &Packet); - - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1213,14 +1246,21 @@ Dhcp6SendRequestMsg ( - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); - - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - -@@ -1286,7 +1326,8 @@ Dhcp6SendDeclineMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE; -@@ -1300,42 +1341,58 @@ Dhcp6SendDeclineMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptServerId), - ServerId->Length, - ServerId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption (Cursor, DecIa, 0, 0, Packet->Dhcp6.Header.MessageType); -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, -+ DecIa, -+ 0, -+ 0, -+ Packet->Dhcp6.Header.MessageType -+ ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // - // Callback to user with the packet to be sent and check the user's feedback. - // - Status = Dhcp6CallbackUser (Instance, Dhcp6SendDecline, &Packet); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1349,16 +1406,22 @@ Dhcp6SendDeclineMsg ( - Instance->StartTime = 0; - - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - -@@ -1420,7 +1483,8 @@ Dhcp6SendReleaseMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE; -@@ -1434,45 +1498,61 @@ Dhcp6SendReleaseMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - // - // ServerId is extracted from packet, it's network order. - // -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptServerId), - ServerId->Length, - ServerId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption (Cursor, RelIa, 0, 0, Packet->Dhcp6.Header.MessageType); -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, -+ RelIa, -+ 0, -+ 0, -+ Packet->Dhcp6.Header.MessageType -+ ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- // -- // Determine the size/length of packet -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // - // Callback to user with the packet to be sent and check the user's feedback. - // - Status = Dhcp6CallbackUser (Instance, Dhcp6SendRelease, &Packet); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1482,16 +1562,22 @@ Dhcp6SendReleaseMsg ( - Instance->IaCb.Ia->State = Dhcp6Releasing; - - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - -@@ -1551,7 +1637,8 @@ Dhcp6SendRenewRebindMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE + UserLen); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE + UserLen; -@@ -1565,26 +1652,38 @@ Dhcp6SendRenewRebindMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption ( -- Cursor, -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, - Instance->IaCb.Ia, - Instance->IaCb.T1, - Instance->IaCb.T2, - Packet->Dhcp6.Header.MessageType - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - if (!RebindRequest) { - // -@@ -1600,18 +1699,22 @@ Dhcp6SendRenewRebindMsg ( - Dhcp6OptServerId - ); - if (Option == NULL) { -- FreePool (Packet); -- return EFI_DEVICE_ERROR; -+ Status = EFI_DEVICE_ERROR; -+ goto ON_ERROR; - } - - ServerId = (EFI_DHCP6_DUID *) (Option + 2); - -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptServerId), - ServerId->Length, - ServerId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - - // -@@ -1620,18 +1723,18 @@ Dhcp6SendRenewRebindMsg ( - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { - - UserOpt = Instance->Config->OptionList[Index]; -- Cursor = Dhcp6AppendOption( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - UserOpt->OpCode, - UserOpt->OpLen, - UserOpt->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // -@@ -1641,10 +1744,8 @@ Dhcp6SendRenewRebindMsg ( - Event = (RebindRequest) ? Dhcp6EnterRebinding : Dhcp6EnterRenewing; - - Status = Dhcp6CallbackUser (Instance, Event, &Packet); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -1661,16 +1762,22 @@ Dhcp6SendRenewRebindMsg ( - Instance->StartTime = 0; - - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - /** -@@ -1834,7 +1941,8 @@ Dhcp6SendInfoRequestMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE + UserLen); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE + UserLen; -@@ -1851,26 +1959,38 @@ Dhcp6SendInfoRequestMsg ( - - if (SendClientId) { - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - OptionRequest->OpCode, - OptionRequest->OpLen, - OptionRequest->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - // - // Append user-defined when configurate Dhcp6 service. -@@ -1878,18 +1998,18 @@ Dhcp6SendInfoRequestMsg ( - for (Index = 0; Index < OptionCount; Index++) { - - UserOpt = OptionList[Index]; -- Cursor = Dhcp6AppendOption( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - UserOpt->OpCode, - UserOpt->OpLen, - UserOpt->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // -@@ -1901,16 +2021,22 @@ Dhcp6SendInfoRequestMsg ( - // Send info-request packet with no state. - // - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, Retransmission); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - -@@ -1962,7 +2088,8 @@ Dhcp6SendConfirmMsg ( - // - Packet = AllocateZeroPool (DHCP6_BASE_PACKET_SIZE + UserLen); - if (Packet == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; - } - - Packet->Size = DHCP6_BASE_PACKET_SIZE + UserLen; -@@ -1976,54 +2103,64 @@ Dhcp6SendConfirmMsg ( - Cursor = Packet->Dhcp6.Option; - - Length = HTONS (ClientId->Length); -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - HTONS (Dhcp6OptClientId), - Length, - ClientId->Duid - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendETOption ( -- Cursor, -+ Status = Dhcp6AppendETOption ( -+ Packet, -+ &Cursor, - Instance, - &Elapsed - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - -- Cursor = Dhcp6AppendIaOption ( -- Cursor, -+ Status = Dhcp6AppendIaOption ( -+ Packet, -+ &Cursor, - Instance->IaCb.Ia, - Instance->IaCb.T1, - Instance->IaCb.T2, - Packet->Dhcp6.Header.MessageType - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - - // - // Append user-defined when configurate Dhcp6 service. - // - for (Index = 0; Index < Instance->Config->OptionCount; Index++) { - UserOpt = Instance->Config->OptionList[Index]; -- Cursor = Dhcp6AppendOption ( -- Cursor, -+ Status = Dhcp6AppendOption ( -+ Packet, -+ &Cursor, - UserOpt->OpCode, - UserOpt->OpLen, - UserOpt->Data - ); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } - } - -- // -- // Determine the size/length of packet. -- // -- Packet->Length += (UINT32) (Cursor - Packet->Dhcp6.Option); - ASSERT (Packet->Size > Packet->Length + 8); - - // - // Callback to user with the packet to be sent and check the user's feedback. - // - Status = Dhcp6CallbackUser (Instance, Dhcp6SendConfirm, &Packet); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // -@@ -2037,16 +2174,22 @@ Dhcp6SendConfirmMsg ( - Instance->StartTime = 0; - - Status = Dhcp6TransmitPacket (Instance, Packet, Elapsed); -- - if (EFI_ERROR (Status)) { -- FreePool (Packet); -- return Status; -+ goto ON_ERROR; - } - - // - // Enqueue the sent packet for the retransmission in case reply timeout. - // - return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL); -+ -+ON_ERROR: -+ -+ if (Packet) { -+ FreePool (Packet); -+ } -+ -+ return Status; - } - - -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -index d249a1cca7..484c360a96 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c -@@ -601,24 +601,33 @@ Dhcp6OnTransmitted ( - - - /** -- Append the option to Buf, and move Buf to the end. -+ Append the option to Buf, update the length of packet, and move Buf to the end. - -- @param[in, out] Buf The pointer to the buffer. -- @param[in] OptType The option type. -- @param[in] OptLen The length of option contents. -- @param[in] Data The pointer to the option content. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. -+ @param[in] OptType The option type. -+ @param[in] OptLen The length of option contents. -+ @param[in] Data The pointer to the option content. - -- @return Buf The position to append the next option. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendOption ( -- IN OUT UINT8 *Buf, -- IN UINT16 OptType, -- IN UINT16 OptLen, -- IN UINT8 *Data -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN UINT16 OptType, -+ IN UINT16 OptLen, -+ IN UINT8 *Data - ) - { -+ UINT32 Length; -+ UINT32 BytesNeeded; -+ - // - // The format of Dhcp6 option: - // -@@ -631,35 +640,94 @@ Dhcp6AppendOption ( - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // - -- ASSERT (OptLen != 0); -+ // -+ // Verify the arguments are valid -+ // -+ if (Packet == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((PacketCursor == NULL) || (*PacketCursor == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (Data == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (OptLen == 0) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Verify the PacketCursor is within the packet -+ // -+ if ( (*PacketCursor < Packet->Dhcp6.Option) -+ || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -+ { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Calculate the bytes needed for the option -+ // -+ BytesNeeded = DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN + NTOHS (OptLen); -+ -+ // -+ // Space remaining in the packet -+ // -+ Length = Packet->Size - Packet->Length; -+ if (Length < BytesNeeded) { -+ return EFI_BUFFER_TOO_SMALL; -+ } -+ -+ // -+ // Verify the PacketCursor is within the packet -+ // -+ if ( (*PacketCursor < Packet->Dhcp6.Option) -+ || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -+ { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, OptType); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_CODE; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, OptLen); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_LEN; -+ CopyMem (*PacketCursor, Data, NTOHS (OptLen)); -+ *PacketCursor += NTOHS (OptLen); - -- WriteUnaligned16 ((UINT16 *) Buf, OptType); -- Buf += 2; -- WriteUnaligned16 ((UINT16 *) Buf, OptLen); -- Buf += 2; -- CopyMem (Buf, Data, NTOHS (OptLen)); -- Buf += NTOHS (OptLen); -+ // Update the packet length by the length of the option + 4 bytes -+ Packet->Length += BytesNeeded; - -- return Buf; -+ return EFI_SUCCESS; - } - - /** - Append the appointed IA Address option to Buf, and move Buf to the end. - -- @param[in, out] Buf The pointer to the position to append. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. - @param[in] IaAddr The pointer to the IA Address. - @param[in] MessageType Message type of DHCP6 package. - -- @return Buf The position to append the next option. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendIaAddrOption ( -- IN OUT UINT8 *Buf, -- IN EFI_DHCP6_IA_ADDRESS *IaAddr, -- IN UINT32 MessageType --) -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN EFI_DHCP6_IA_ADDRESS *IaAddr, -+ IN UINT32 MessageType -+ ) - { -+ UINT32 BytesNeeded; -+ UINT32 Length; - - // The format of the IA Address option is: - // -@@ -682,17 +750,60 @@ Dhcp6AppendIaAddrOption ( - // . . - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -+ // -+ // Verify the arguments are valid -+ // -+ if (Packet == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((PacketCursor == NULL) || (*PacketCursor == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (IaAddr == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Verify the PacketCursor is within the packet -+ // -+ if ( (*PacketCursor < Packet->Dhcp6.Option) -+ || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -+ { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ BytesNeeded = DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN; -+ BytesNeeded += sizeof (EFI_IPv6_ADDRESS); -+ // -+ // Even if the preferred-lifetime is 0, it still needs to store it. -+ // -+ BytesNeeded += sizeof (IaAddr->PreferredLifetime); -+ // -+ // Even if the valid-lifetime is 0, it still needs to store it. -+ // -+ BytesNeeded += sizeof (IaAddr->ValidLifetime); -+ -+ // -+ // Space remaining in the packet -+ // -+ Length = Packet->Size - Packet->Length; -+ if (Length < BytesNeeded) { -+ return EFI_BUFFER_TOO_SMALL; -+ } -+ - // - // Fill the value of Ia Address option type - // -- WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptIaAddr)); -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (Dhcp6OptIaAddr)); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_CODE; - -- WriteUnaligned16 ((UINT16 *) Buf, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS))); -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (sizeof (EFI_DHCP6_IA_ADDRESS))); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_LEN; - -- CopyMem (Buf, &IaAddr->IpAddress, sizeof(EFI_IPv6_ADDRESS)); -- Buf += sizeof(EFI_IPv6_ADDRESS); -+ CopyMem (*PacketCursor, &IaAddr->IpAddress, sizeof (EFI_IPv6_ADDRESS)); -+ *PacketCursor += sizeof (EFI_IPv6_ADDRESS); - - // - // Fill the value of preferred-lifetime and valid-lifetime. -@@ -700,43 +811,59 @@ Dhcp6AppendIaAddrOption ( - // should set to 0 when initiate a Confirm message. - // - if (MessageType != Dhcp6MsgConfirm) { -- WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->PreferredLifetime)); -+ WriteUnaligned32 ((UINT32 *)*PacketCursor, HTONL (IaAddr->PreferredLifetime)); - } -- Buf += 4; -+ -+ *PacketCursor += sizeof (IaAddr->PreferredLifetime); - - if (MessageType != Dhcp6MsgConfirm) { -- WriteUnaligned32 ((UINT32 *) Buf, HTONL (IaAddr->ValidLifetime)); -+ WriteUnaligned32 ((UINT32 *)*PacketCursor, HTONL (IaAddr->ValidLifetime)); - } -- Buf += 4; - -- return Buf; -+ *PacketCursor += sizeof (IaAddr->ValidLifetime); -+ -+ // -+ // Update the packet length -+ // -+ Packet->Length += BytesNeeded; -+ -+ return EFI_SUCCESS; - } - - - /** - Append the appointed Ia option to Buf, and move Buf to the end. - -- @param[in, out] Buf The pointer to the position to append. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. - @param[in] Ia The pointer to the Ia. - @param[in] T1 The time of T1. - @param[in] T2 The time of T2. - @param[in] MessageType Message type of DHCP6 package. - -- @return Buf The position to append the next Ia option. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendIaOption ( -- IN OUT UINT8 *Buf, -- IN EFI_DHCP6_IA *Ia, -- IN UINT32 T1, -- IN UINT32 T2, -- IN UINT32 MessageType -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN EFI_DHCP6_IA *Ia, -+ IN UINT32 T1, -+ IN UINT32 T2, -+ IN UINT32 MessageType - ) - { -- UINT8 *AddrOpt; -- UINT16 *Len; -- UINTN Index; -+ UINT8 *AddrOpt; -+ UINT16 *Len; -+ UINTN Index; -+ UINT32 BytesNeeded; -+ UINT32 Length; -+ EFI_STATUS Status; - - // - // The format of IA_NA and IA_TA option: -@@ -757,68 +884,126 @@ Dhcp6AppendIaOption ( - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // - -+ // -+ // Verify the arguments are valid -+ // -+ if (Packet == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((PacketCursor == NULL) || (*PacketCursor == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (Ia == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Verify the PacketCursor is within the packet -+ // -+ if ( (*PacketCursor < Packet->Dhcp6.Option) -+ || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -+ { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ BytesNeeded = DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN; -+ BytesNeeded += sizeof (Ia->Descriptor.IaId); -+ // -+ // + N for the IA_NA-options/IA_TA-options -+ // Dhcp6AppendIaAddrOption will need to check the length for each address -+ // -+ if (Ia->Descriptor.Type == Dhcp6OptIana) { -+ BytesNeeded += sizeof (T1) + sizeof (T2); -+ } -+ -+ // -+ // Space remaining in the packet -+ // -+ Length = (UINT16)(Packet->Size - Packet->Length); -+ if (Length < BytesNeeded) { -+ return EFI_BUFFER_TOO_SMALL; -+ } -+ - // - // Fill the value of Ia option type - // -- WriteUnaligned16 ((UINT16 *) Buf, HTONS (Ia->Descriptor.Type)); -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (Ia->Descriptor.Type)); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_CODE; - - // - // Fill the len of Ia option later, keep the pointer first - // -- Len = (UINT16 *) Buf; -- Buf += 2; -+ Len = (UINT16 *)*PacketCursor; -+ *PacketCursor += DHCP6_SIZE_OF_OPT_LEN; - - // - // Fill the value of iaid - // -- WriteUnaligned32 ((UINT32 *) Buf, HTONL (Ia->Descriptor.IaId)); -- Buf += 4; -+ WriteUnaligned32 ((UINT32 *)*PacketCursor, HTONL (Ia->Descriptor.IaId)); -+ *PacketCursor += sizeof (Ia->Descriptor.IaId); - - // - // Fill the value of t1 and t2 if iana, keep it 0xffffffff if no specified. - // - if (Ia->Descriptor.Type == Dhcp6OptIana) { -- WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T1 != 0) ? T1 : 0xffffffff)); -- Buf += 4; -- WriteUnaligned32 ((UINT32 *) Buf, HTONL ((T2 != 0) ? T2 : 0xffffffff)); -- Buf += 4; -+ WriteUnaligned32 ((UINT32 *)*PacketCursor, HTONL ((T1 != 0) ? T1 : 0xffffffff)); -+ *PacketCursor += sizeof (T1); -+ WriteUnaligned32 ((UINT32 *)*PacketCursor, HTONL ((T2 != 0) ? T2 : 0xffffffff)); -+ *PacketCursor += sizeof (T2); - } - - // - // Fill all the addresses belong to the Ia - // - for (Index = 0; Index < Ia->IaAddressCount; Index++) { -- AddrOpt = (UINT8 *) Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); -- Buf = Dhcp6AppendIaAddrOption (Buf, (EFI_DHCP6_IA_ADDRESS *) AddrOpt, MessageType); -+ AddrOpt = (UINT8 *)Ia->IaAddress + Index * sizeof (EFI_DHCP6_IA_ADDRESS); -+ Status = Dhcp6AppendIaAddrOption (Packet, PacketCursor, (EFI_DHCP6_IA_ADDRESS *)AddrOpt, MessageType); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } - } - - // - // Fill the value of Ia option length - // -- *Len = HTONS ((UINT16) (Buf - (UINT8 *) Len - 2)); -+ *Len = HTONS ((UINT16)(*PacketCursor - (UINT8 *)Len - 2)); -+ -+ // -+ // Update the packet length -+ // -+ Packet->Length += BytesNeeded; - -- return Buf; -+ return EFI_SUCCESS; - } - - /** - Append the appointed Elapsed time option to Buf, and move Buf to the end. - -- @param[in, out] Buf The pointer to the position to append. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. - @param[in] Instance The pointer to the Dhcp6 instance. - @param[out] Elapsed The pointer to the elapsed time value in -- the generated packet. -+ the generated packet. - -- @return Buf The position to append the next Ia option. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendETOption ( -- IN OUT UINT8 *Buf, -- IN DHCP6_INSTANCE *Instance, -- OUT UINT16 **Elapsed -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN DHCP6_INSTANCE *Instance, -+ OUT UINT16 **Elapsed - ) - { -+ UINT32 BytesNeeded; -+ UINT32 Length; -+ - // - // The format of elapsed time option: - // -@@ -830,27 +1015,70 @@ Dhcp6AppendETOption ( - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // - -+ // -+ // Verify the arguments are valid -+ // -+ if (Packet == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((PacketCursor == NULL) || (*PacketCursor == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (Instance == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((Elapsed == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Verify the PacketCursor is within the packet -+ // -+ if ( (*PacketCursor < Packet->Dhcp6.Option) -+ || (*PacketCursor >= Packet->Dhcp6.Option + (Packet->Size - sizeof (EFI_DHCP6_HEADER)))) -+ { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ BytesNeeded = DHCP6_SIZE_OF_COMBINED_CODE_AND_LEN; -+ // -+ // + 2 for elapsed-time -+ // -+ BytesNeeded += sizeof (UINT16); -+ // -+ // Space remaining in the packet -+ // -+ Length = Packet->Size - Packet->Length; -+ if (Length < BytesNeeded) { -+ return EFI_BUFFER_TOO_SMALL; -+ } -+ - // - // Fill the value of elapsed-time option type. - // -- WriteUnaligned16 ((UINT16 *) Buf, HTONS (Dhcp6OptElapsedTime)); -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (Dhcp6OptElapsedTime)); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_CODE; - - // - // Fill the len of elapsed-time option, which is fixed. - // -- WriteUnaligned16 ((UINT16 *) Buf, HTONS(2)); -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (2)); -+ *PacketCursor += DHCP6_SIZE_OF_OPT_LEN; - - // - // Fill in elapsed time value with 0 value for now. The actual value is - // filled in later just before the packet is transmitted. - // -- WriteUnaligned16 ((UINT16 *) Buf, HTONS(0)); -- *Elapsed = (UINT16 *) Buf; -- Buf += 2; -+ WriteUnaligned16 ((UINT16 *)*PacketCursor, HTONS (0)); -+ *Elapsed = (UINT16 *)*PacketCursor; -+ *PacketCursor += sizeof (UINT16); - -- return Buf; -+ Packet->Length += BytesNeeded; -+ -+ return EFI_SUCCESS; - } - - /** -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h -index 2f18eb3609..af68f77e8b 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h -@@ -161,69 +161,85 @@ Dhcp6OnTransmitted ( - ); - - /** -- Append the appointed option to the buf, and move the buf to the end. -- -- @param[in, out] Buf The pointer to buffer. -- @param[in] OptType The option type. -- @param[in] OptLen The length of option content.s -- @param[in] Data The pointer to the option content. -- -- @return Buf The position to append the next option. -- -+ Append the option to Buf, update the length of packet, and move Buf to the end. -+ -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. -+ @param[in] OptType The option type. -+ @param[in] OptLen The length of option contents. -+ @param[in] Data The pointer to the option content. -+ -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendOption ( -- IN OUT UINT8 *Buf, -- IN UINT16 OptType, -- IN UINT16 OptLen, -- IN UINT8 *Data -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN UINT16 OptType, -+ IN UINT16 OptLen, -+ IN UINT8 *Data - ); - - /** -- Append the Ia option to Buf, and move Buf to the end. -- -- @param[in, out] Buf The pointer to the position to append. -+ Append the appointed Ia option to Buf, update the Ia option length, and move Buf -+ to the end of the option. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ will be updated. -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. - @param[in] Ia The pointer to the Ia. - @param[in] T1 The time of T1. - @param[in] T2 The time of T2. - @param[in] MessageType Message type of DHCP6 package. - -- @return Buf The position to append the next Ia option. -- -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendIaOption ( -- IN OUT UINT8 *Buf, -- IN EFI_DHCP6_IA *Ia, -- IN UINT32 T1, -- IN UINT32 T2, -- IN UINT32 MessageType -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN EFI_DHCP6_IA *Ia, -+ IN UINT32 T1, -+ IN UINT32 T2, -+ IN UINT32 MessageType - ); - - /** - Append the appointed Elapsed time option to Buf, and move Buf to the end. - -- @param[in, out] Buf The pointer to the position to append. -+ @param[in, out] Packet A pointer to the packet, on success Packet->Length -+ @param[in, out] PacketCursor The pointer in the packet, on success PacketCursor -+ will be moved to the end of the option. - @param[in] Instance The pointer to the Dhcp6 instance. - @param[out] Elapsed The pointer to the elapsed time value in - the generated packet. - -- @return Buf The position to append the next Ia option. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - - **/ --UINT8 * -+EFI_STATUS - Dhcp6AppendETOption ( -- IN OUT UINT8 *Buf, -- IN DHCP6_INSTANCE *Instance, -- OUT UINT16 **Elapsed -+ IN OUT EFI_DHCP6_PACKET *Packet, -+ IN OUT UINT8 **PacketCursor, -+ IN DHCP6_INSTANCE *Instance, -+ OUT UINT16 **Elapsed - ); - - /** - Set the elapsed time based on the given instance and the pointer to the - elapsed time option. - -- @param[in] Elapsed The pointer to the position to append. -- @param[in] Instance The pointer to the Dhcp6 instance. -+ @retval EFI_INVALID_PARAMETER An argument provided to the function was invalid -+ @retval EFI_BUFFER_TOO_SMALL The buffer is too small to append the option. -+ @retval EFI_SUCCESS The option is appended successfully. - **/ - VOID - SetElapsedTime ( --- -2.41.0 - diff --git a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Un.patch b/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Un.patch deleted file mode 100644 index e7e40c1..0000000 --- a/SOURCES/edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Un.patch +++ /dev/null @@ -1,629 +0,0 @@ -From f5274b449181cb37efce0f08ed5d75a6bf6e54a8 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 8 Feb 2024 10:35:14 -0500 -Subject: [PATCH 16/17] NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 - Unit Tests - -RH-Author: Jon Maloy -RH-MergeRequest: 50: CVE-2023-45230 and CVE-2023-45229 -RH-Jira: RHEL-21840 RHEL-21842 -RH-Acked-by: Oliver Steffen -RH-Commit: [3/4] 43b8569c0586c7dbf66b19c5db335d0ce05829de (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21842 -CVE: CVE-2023-45230 -Upstream: Merged - -commit 5f3658197bf29c83b3349b0ab1d99cdb0c3814bc -Author: Doug Flick via groups.io -Date: Fri Jan 26 05:54:45 2024 +0800 - - NetworkPkg: Dhcp6Dxe: SECURITY PATCH CVE-2023-45230 Unit Tests - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4535 - - Confirms that reported issue... - - "Buffer overflow in the DHCPv6 client via a long Server ID option" - - ..has been corrected by the provided patch. - - Tests the following functions to ensure they appropriately handle - untrusted data (either too long or too small) to prevent a buffer - overflow: - - Dhcp6AppendOption - Dhcp6AppendETOption - Dhcp6AppendIaOption - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - .../GoogleTest/Dhcp6DxeGoogleTest.cpp | 20 + - .../GoogleTest/Dhcp6DxeGoogleTest.inf | 43 ++ - .../Dhcp6Dxe/GoogleTest/Dhcp6IoGoogleTest.cpp | 478 ++++++++++++++++++ - NetworkPkg/Test/NetworkPkgHostTest.dsc | 1 + - 4 files changed, 542 insertions(+) - create mode 100644 NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.cpp - create mode 100644 NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf - create mode 100644 NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6IoGoogleTest.cpp - -diff --git a/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.cpp b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.cpp -new file mode 100644 -index 0000000000..9aeced2f91 ---- /dev/null -+++ b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.cpp -@@ -0,0 +1,20 @@ -+/** @file -+ Acts as the main entry point for the tests for the Dhcp6Dxe module. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+//////////////////////////////////////////////////////////////////////////////// -+// Run the tests -+//////////////////////////////////////////////////////////////////////////////// -+int -+main ( -+ int argc, -+ char *argv[] -+ ) -+{ -+ testing::InitGoogleTest (&argc, argv); -+ return RUN_ALL_TESTS (); -+} -diff --git a/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf -new file mode 100644 -index 0000000000..8e9119a371 ---- /dev/null -+++ b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf -@@ -0,0 +1,43 @@ -+## @file -+# Unit test suite for the Dhcp6Dxe using Google Test -+# -+# Copyright (c) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+[Defines] -+ INF_VERSION = 0x00010017 -+ BASE_NAME = Dhcp6DxeGoogleTest -+ FILE_GUID = 1D2A4C65-38C8-4C2F-BB60-B5FA49625AA9 -+ VERSION_STRING = 1.0 -+ MODULE_TYPE = HOST_APPLICATION -+# -+# The following information is for reference only and not required by the build tools. -+# -+# VALID_ARCHITECTURES = IA32 X64 AARCH64 -+# -+[Sources] -+ Dhcp6DxeGoogleTest.cpp -+ Dhcp6IoGoogleTest.cpp -+ ../Dhcp6Io.c -+ ../Dhcp6Utility.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ MdeModulePkg/MdeModulePkg.dec -+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec -+ NetworkPkg/NetworkPkg.dec -+ -+[LibraryClasses] -+ GoogleTestLib -+ DebugLib -+ NetLib -+ PcdLib -+ -+[Protocols] -+ gEfiDhcp6ServiceBindingProtocolGuid -+ -+[Pcd] -+ gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType -+ -+[Guids] -+ gZeroGuid -diff --git a/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6IoGoogleTest.cpp b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6IoGoogleTest.cpp -new file mode 100644 -index 0000000000..7ee40e4af4 ---- /dev/null -+++ b/NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6IoGoogleTest.cpp -@@ -0,0 +1,478 @@ -+/** @file -+ Tests for Dhcp6Io.c. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+extern "C" { -+ #include -+ #include -+ #include -+ #include -+ #include "../Dhcp6Impl.h" -+ #include "../Dhcp6Utility.h" -+} -+ -+//////////////////////////////////////////////////////////////////////// -+// Defines -+//////////////////////////////////////////////////////////////////////// -+ -+#define DHCP6_PACKET_MAX_LEN 1500 -+ -+//////////////////////////////////////////////////////////////////////// -+//////////////////////////////////////////////////////////////////////// -+// Symbol Definitions -+// These functions are not directly under test - but required to compile -+//////////////////////////////////////////////////////////////////////// -+ -+// This definition is used by this test but is also required to compile -+// by Dhcp6Io.c -+EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress = { -+ { 0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2 } -+}; -+ -+EFI_STATUS -+EFIAPI -+UdpIoSendDatagram ( -+ IN UDP_IO *UdpIo, -+ IN NET_BUF *Packet, -+ IN UDP_END_POINT *EndPoint OPTIONAL, -+ IN EFI_IP_ADDRESS *Gateway OPTIONAL, -+ IN UDP_IO_CALLBACK CallBack, -+ IN VOID *Context -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+EFI_STATUS -+EFIAPI -+UdpIoRecvDatagram ( -+ IN UDP_IO *UdpIo, -+ IN UDP_IO_CALLBACK CallBack, -+ IN VOID *Context, -+ IN UINT32 HeadLen -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+//////////////////////////////////////////////////////////////////////// -+// Dhcp6AppendOptionTest Tests -+//////////////////////////////////////////////////////////////////////// -+ -+class Dhcp6AppendOptionTest : public ::testing::Test { -+public: -+ UINT8 *Buffer = NULL; -+ EFI_DHCP6_PACKET *Packet; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ // Initialize any resources or variables -+ Buffer = (UINT8 *)AllocateZeroPool (DHCP6_PACKET_MAX_LEN); -+ ASSERT_NE (Buffer, (UINT8 *)NULL); -+ -+ Packet = (EFI_DHCP6_PACKET *)Buffer; -+ Packet->Size = DHCP6_PACKET_MAX_LEN; -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ // Clean up any resources or variables -+ if (Buffer != NULL) { -+ FreePool (Buffer); -+ } -+ } -+}; -+ -+// Test Description: -+// Attempt to append an option to a packet that is too small by a duid that is too large -+TEST_F (Dhcp6AppendOptionTest, InvalidDataExpectBufferTooSmall) { -+ UINT8 *Cursor; -+ EFI_DHCP6_DUID *UntrustedDuid; -+ EFI_STATUS Status; -+ -+ UntrustedDuid = (EFI_DHCP6_DUID *)AllocateZeroPool (sizeof (EFI_DHCP6_DUID)); -+ ASSERT_NE (UntrustedDuid, (EFI_DHCP6_DUID *)NULL); -+ -+ UntrustedDuid->Length = NTOHS (0xFFFF); -+ -+ Cursor = Dhcp6AppendOptionTest::Packet->Dhcp6.Option; -+ -+ Status = Dhcp6AppendOption ( -+ Dhcp6AppendOptionTest::Packet, -+ &Cursor, -+ HTONS (Dhcp6OptServerId), -+ UntrustedDuid->Length, -+ UntrustedDuid->Duid -+ ); -+ -+ ASSERT_EQ (Status, EFI_BUFFER_TOO_SMALL); -+} -+ -+// Test Description: -+// Attempt to append an option to a packet that is large enough -+TEST_F (Dhcp6AppendOptionTest, ValidDataExpectSuccess) { -+ UINT8 *Cursor; -+ EFI_DHCP6_DUID *UntrustedDuid; -+ EFI_STATUS Status; -+ UINTN OriginalLength; -+ -+ UINT8 Duid[6] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; -+ -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+ OriginalLength = Packet->Length; -+ -+ UntrustedDuid = (EFI_DHCP6_DUID *)AllocateZeroPool (sizeof (EFI_DHCP6_DUID)); -+ ASSERT_NE (UntrustedDuid, (EFI_DHCP6_DUID *)NULL); -+ -+ UntrustedDuid->Length = NTOHS (sizeof (Duid)); -+ CopyMem (UntrustedDuid->Duid, Duid, sizeof (Duid)); -+ -+ Cursor = Dhcp6AppendOptionTest::Packet->Dhcp6.Option; -+ -+ Status = Dhcp6AppendOption ( -+ Dhcp6AppendOptionTest::Packet, -+ &Cursor, -+ HTONS (Dhcp6OptServerId), -+ UntrustedDuid->Length, -+ UntrustedDuid->Duid -+ ); -+ -+ ASSERT_EQ (Status, EFI_SUCCESS); -+ -+ // verify that the pointer to cursor moved by the expected amount -+ ASSERT_EQ (Cursor, (UINT8 *)Dhcp6AppendOptionTest::Packet->Dhcp6.Option + sizeof (Duid) + 4); -+ -+ // verify that the length of the packet is now the expected amount -+ ASSERT_EQ (Dhcp6AppendOptionTest::Packet->Length, OriginalLength + sizeof (Duid) + 4); -+} -+ -+//////////////////////////////////////////////////////////////////////// -+// Dhcp6AppendETOption Tests -+//////////////////////////////////////////////////////////////////////// -+ -+class Dhcp6AppendETOptionTest : public ::testing::Test { -+public: -+ UINT8 *Buffer = NULL; -+ EFI_DHCP6_PACKET *Packet; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ // Initialize any resources or variables -+ Buffer = (UINT8 *)AllocateZeroPool (DHCP6_PACKET_MAX_LEN); -+ ASSERT_NE (Buffer, (UINT8 *)NULL); -+ -+ Packet = (EFI_DHCP6_PACKET *)Buffer; -+ Packet->Size = DHCP6_PACKET_MAX_LEN; -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ // Clean up any resources or variables -+ if (Buffer != NULL) { -+ FreePool (Buffer); -+ } -+ } -+}; -+ -+// Test Description: -+// Attempt to append an option to a packet that is too small by a duid that is too large -+TEST_F (Dhcp6AppendETOptionTest, InvalidDataExpectBufferTooSmall) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ DHCP6_INSTANCE Instance; -+ UINT16 ElapsedTimeVal; -+ UINT16 *ElapsedTime; -+ -+ Cursor = Dhcp6AppendETOptionTest::Packet->Dhcp6.Option; -+ ElapsedTime = &ElapsedTimeVal; -+ -+ Packet->Length = Packet->Size - 2; -+ -+ Status = Dhcp6AppendETOption ( -+ Dhcp6AppendETOptionTest::Packet, -+ &Cursor, -+ &Instance, // Instance is not used in this function -+ &ElapsedTime -+ ); -+ -+ // verify that we error out because the packet is too small for the option header -+ ASSERT_EQ (Status, EFI_BUFFER_TOO_SMALL); -+ -+ // reset the length -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+} -+ -+// Test Description: -+// Attempt to append an option to a packet that is large enough -+TEST_F (Dhcp6AppendETOptionTest, ValidDataExpectSuccess) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ DHCP6_INSTANCE Instance; -+ UINT16 ElapsedTimeVal; -+ UINT16 *ElapsedTime; -+ UINTN ExpectedSize; -+ UINTN OriginalLength; -+ -+ Cursor = Dhcp6AppendETOptionTest::Packet->Dhcp6.Option; -+ ElapsedTime = &ElapsedTimeVal; -+ ExpectedSize = 6; -+ OriginalLength = Packet->Length; -+ -+ Status = Dhcp6AppendETOption ( -+ Dhcp6AppendETOptionTest::Packet, -+ &Cursor, -+ &Instance, // Instance is not used in this function -+ &ElapsedTime -+ ); -+ -+ // verify that the status is EFI_SUCCESS -+ ASSERT_EQ (Status, EFI_SUCCESS); -+ -+ // verify that the pointer to cursor moved by the expected amount -+ ASSERT_EQ (Cursor, (UINT8 *)Dhcp6AppendETOptionTest::Packet->Dhcp6.Option + ExpectedSize); -+ -+ // verify that the length of the packet is now the expected amount -+ ASSERT_EQ (Dhcp6AppendETOptionTest::Packet->Length, OriginalLength + ExpectedSize); -+} -+ -+//////////////////////////////////////////////////////////////////////// -+// Dhcp6AppendIaOption Tests -+//////////////////////////////////////////////////////////////////////// -+ -+class Dhcp6AppendIaOptionTest : public ::testing::Test { -+public: -+ UINT8 *Buffer = NULL; -+ EFI_DHCP6_PACKET *Packet; -+ EFI_DHCP6_IA *Ia; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ // Initialize any resources or variables -+ Buffer = (UINT8 *)AllocateZeroPool (DHCP6_PACKET_MAX_LEN); -+ ASSERT_NE (Buffer, (UINT8 *)NULL); -+ -+ Packet = (EFI_DHCP6_PACKET *)Buffer; -+ Packet->Size = DHCP6_PACKET_MAX_LEN; -+ -+ Ia = (EFI_DHCP6_IA *)AllocateZeroPool (sizeof (EFI_DHCP6_IA) + sizeof (EFI_DHCP6_IA_ADDRESS) * 2); -+ ASSERT_NE (Ia, (EFI_DHCP6_IA *)NULL); -+ -+ CopyMem (Ia->IaAddress, mAllDhcpRelayAndServersAddress.Addr, sizeof (EFI_IPv6_ADDRESS)); -+ CopyMem (Ia->IaAddress + 1, mAllDhcpRelayAndServersAddress.Addr, sizeof (EFI_IPv6_ADDRESS)); -+ -+ Ia->IaAddressCount = 2; -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ // Clean up any resources or variables -+ if (Buffer != NULL) { -+ FreePool (Buffer); -+ } -+ -+ if (Ia != NULL) { -+ FreePool (Ia); -+ } -+ } -+}; -+ -+// Test Description: -+// Attempt to append an option to a packet that doesn't have enough space -+// for the option header -+TEST_F (Dhcp6AppendIaOptionTest, IaNaInvalidDataExpectBufferTooSmall) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ -+ Packet->Length = Packet->Size - 2; -+ -+ Ia->Descriptor.Type = Dhcp6OptIana; -+ Ia->Descriptor.IaId = 0x12345678; -+ -+ Cursor = Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option; -+ -+ Status = Dhcp6AppendIaOption ( -+ Dhcp6AppendIaOptionTest::Packet, -+ &Cursor, -+ Ia, -+ 0x12345678, -+ 0x11111111, -+ Dhcp6OptIana -+ ); -+ -+ // verify that we error out because the packet is too small for the option header -+ ASSERT_EQ (Status, EFI_BUFFER_TOO_SMALL); -+ -+ // reset the length -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+} -+ -+// Test Description: -+// Attempt to append an option to a packet that doesn't have enough space -+// for the option header -+TEST_F (Dhcp6AppendIaOptionTest, IaTaInvalidDataExpectBufferTooSmall) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ -+ // Use up nearly all the space in the packet -+ Packet->Length = Packet->Size - 2; -+ -+ Ia->Descriptor.Type = Dhcp6OptIata; -+ Ia->Descriptor.IaId = 0x12345678; -+ -+ Cursor = Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option; -+ -+ Status = Dhcp6AppendIaOption ( -+ Dhcp6AppendIaOptionTest::Packet, -+ &Cursor, -+ Ia, -+ 0, -+ 0, -+ Dhcp6OptIata -+ ); -+ -+ // verify that we error out because the packet is too small for the option header -+ ASSERT_EQ (Status, EFI_BUFFER_TOO_SMALL); -+ -+ // reset the length -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+} -+ -+TEST_F (Dhcp6AppendIaOptionTest, IaNaValidDataExpectSuccess) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ UINTN ExpectedSize; -+ UINTN OriginalLength; -+ -+ // -+ // 2 bytes for the option header type -+ // -+ ExpectedSize = 2; -+ // -+ // 2 bytes for the option header length -+ // -+ ExpectedSize += 2; -+ // -+ // 4 bytes for the IAID -+ // -+ ExpectedSize += 4; -+ // -+ // + 4 bytes for the T1 -+ // -+ ExpectedSize += 4; -+ // -+ // + 4 bytes for the T2 -+ // -+ ExpectedSize += 4; -+ // -+ // + (4 + sizeof (EFI_DHCP6_IA_ADDRESS)) * 2; -+ // + 2 bytes for the option header type -+ // + 2 bytes for the option header length -+ // + sizeof (EFI_DHCP6_IA_ADDRESS) for the IA Address -+ // -+ ExpectedSize += (4 + sizeof (EFI_DHCP6_IA_ADDRESS)) * 2; -+ -+ Cursor = Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option; -+ -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+ OriginalLength = Packet->Length; -+ -+ Ia->Descriptor.Type = Dhcp6OptIana; -+ Ia->Descriptor.IaId = 0x12345678; -+ -+ Status = Dhcp6AppendIaOption ( -+ Dhcp6AppendIaOptionTest::Packet, -+ &Cursor, -+ Ia, -+ 0x12345678, -+ 0x12345678, -+ Dhcp6OptIana -+ ); -+ -+ // verify that the pointer to cursor moved by the expected amount -+ ASSERT_EQ (Cursor, (UINT8 *)Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option + ExpectedSize); -+ -+ // verify that the length of the packet is now the expected amount -+ ASSERT_EQ (Dhcp6AppendIaOptionTest::Packet->Length, OriginalLength + ExpectedSize); -+ -+ // verify that the status is EFI_SUCCESS -+ ASSERT_EQ (Status, EFI_SUCCESS); -+} -+ -+TEST_F (Dhcp6AppendIaOptionTest, IaTaValidDataExpectSuccess) { -+ UINT8 *Cursor; -+ EFI_STATUS Status; -+ UINTN ExpectedSize; -+ UINTN OriginalLength; -+ -+ // -+ // 2 bytes for the option header type -+ // -+ ExpectedSize = 2; -+ // -+ // 2 bytes for the option header length -+ // -+ ExpectedSize += 2; -+ // -+ // 4 bytes for the IAID -+ // -+ ExpectedSize += 4; -+ // -+ // + (4 + sizeof (EFI_DHCP6_IA_ADDRESS)) * 2; -+ // + 2 bytes for the option header type -+ // + 2 bytes for the option header length -+ // + sizeof (EFI_DHCP6_IA_ADDRESS) for the IA Address -+ // -+ ExpectedSize += (4 + sizeof (EFI_DHCP6_IA_ADDRESS)) * 2; -+ -+ Cursor = Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option; -+ -+ Packet->Length = sizeof (EFI_DHCP6_HEADER); -+ OriginalLength = Packet->Length; -+ -+ Ia->Descriptor.Type = Dhcp6OptIata; -+ Ia->Descriptor.IaId = 0x12345678; -+ -+ Status = Dhcp6AppendIaOption ( -+ Dhcp6AppendIaOptionTest::Packet, -+ &Cursor, -+ Ia, -+ 0, -+ 0, -+ Dhcp6OptIata -+ ); -+ -+ // verify that the pointer to cursor moved by the expected amount -+ ASSERT_EQ (Cursor, (UINT8 *)Dhcp6AppendIaOptionTest::Packet->Dhcp6.Option + ExpectedSize); -+ -+ // verify that the length of the packet is now the expected amount -+ ASSERT_EQ (Dhcp6AppendIaOptionTest::Packet->Length, OriginalLength + ExpectedSize); -+ -+ // verify that the status is EFI_SUCCESS -+ ASSERT_EQ (Status, EFI_SUCCESS); -+} -diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/NetworkPkgHostTest.dsc -index 1aeca5c5b3..20bc90b172 100644 ---- a/NetworkPkg/Test/NetworkPkgHostTest.dsc -+++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc -@@ -24,6 +24,7 @@ - # - # Build HOST_APPLICATION that tests NetworkPkg - # -+ NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf - - # Despite these library classes being listed in [LibraryClasses] below, they are not needed for the host-based unit tests. - [LibraryClasses] --- -2.41.0 - diff --git a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Patc.patch b/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Patc.patch deleted file mode 100644 index b87ded2..0000000 --- a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Patc.patch +++ /dev/null @@ -1,78 +0,0 @@ -From e3f153773bd2ca13ee4869187f1711840fc8afc9 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 15 Feb 2024 11:51:09 -0500 -Subject: [PATCH 02/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [2/15] 61eaf6aac61b774c3a8ace54af8abd607651d2db - -JIRA: https://issues.redhat.com/browse/RHEL-21844 -CVE: CVE-2022-45231 -Upstream: Merged - -commit bbfee34f4188ac00371abe1389ae9c9fb989a0cd -Author: Doug Flick -Date: Fri Jan 26 05:54:48 2024 +0800 - - NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Patch - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4536 - - Bug Overview: - PixieFail Bug #3 - CVE-2023-45231 - CVSS 6.5 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N - CWE-125 Out-of-bounds Read - - Out-of-bounds read when handling a ND Redirect message with truncated - options - - Change Overview: - - Adds a check to prevent truncated options from being parsed - + // - + // Cannot process truncated options. - + // Cannot process options with a length of 0 as there is no Type - field. - + // - + if (OptionLen < sizeof (IP6_OPTION_HEADER)) { - + return FALSE; - + } - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Ip6Dxe/Ip6Option.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.c b/NetworkPkg/Ip6Dxe/Ip6Option.c -index 199eea124d..8718d5d875 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Option.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Option.c -@@ -137,6 +137,14 @@ Ip6IsNDOptionValid ( - return FALSE; - } - -+ // -+ // Cannot process truncated options. -+ // Cannot process options with a length of 0 as there is no Type field. -+ // -+ if (OptionLen < sizeof (IP6_OPTION_HEADER)) { -+ return FALSE; -+ } -+ - Offset = 0; - - // --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Unit.patch b/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Unit.patch deleted file mode 100644 index 35eaa36..0000000 --- a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Unit.patch +++ /dev/null @@ -1,277 +0,0 @@ -From e8200dda7752d21794b2268efe9e957958ffef29 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 14 Feb 2024 12:24:44 -0500 -Subject: [PATCH 03/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Unit - Tests - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [3/15] ca554677a3397423073d3bb4774f856b2329ae9c - -JIRA: https://issues.redhat.com/browse/RHEL-21844 -CVE: CVE-2022-45231 -Upstream: Merged - -commit 6f77463d72807ec7f4ed6518c3dac29a1040df9f -Author: Doug Flick -Date: Fri Jan 26 05:54:49 2024 +0800 - - NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45231 Unit Tests - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4536 - - Validates that the patch for... - - Out-of-bounds read when handling a ND Redirect message with truncated - options - - .. has been fixed - - Tests the following function to ensure that an out of bounds read does - not occur - Ip6OptionValidation - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - .../Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.cpp | 20 +++ - .../Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf | 42 ++++++ - .../Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp | 129 ++++++++++++++++++ - NetworkPkg/Test/NetworkPkgHostTest.dsc | 1 + - 4 files changed, 192 insertions(+) - create mode 100644 NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.cpp - create mode 100644 NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf - create mode 100644 NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp - -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.cpp b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.cpp -new file mode 100644 -index 0000000000..6ebfd5fdfb ---- /dev/null -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.cpp -@@ -0,0 +1,20 @@ -+/** @file -+ Acts as the main entry point for the tests for the Ip6Dxe module. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+//////////////////////////////////////////////////////////////////////////////// -+// Run the tests -+//////////////////////////////////////////////////////////////////////////////// -+int -+main ( -+ int argc, -+ char *argv[] -+ ) -+{ -+ testing::InitGoogleTest (&argc, argv); -+ return RUN_ALL_TESTS (); -+} -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -new file mode 100644 -index 0000000000..6e4de0745f ---- /dev/null -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -@@ -0,0 +1,42 @@ -+## @file -+# Unit test suite for the Ip6Dxe using Google Test -+# -+# Copyright (c) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+[Defines] -+ INF_VERSION = 0x00010017 -+ BASE_NAME = Ip6DxeUnitTest -+ FILE_GUID = 4F05D17D-D3E7-4AAE-820C-576D46D2D34A -+ VERSION_STRING = 1.0 -+ MODULE_TYPE = HOST_APPLICATION -+# -+# The following information is for reference only and not required by the build tools. -+# -+# VALID_ARCHITECTURES = IA32 X64 AARCH64 -+# -+[Sources] -+ Ip6DxeGoogleTest.cpp -+ Ip6OptionGoogleTest.cpp -+ ../Ip6Option.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ MdeModulePkg/MdeModulePkg.dec -+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec -+ NetworkPkg/NetworkPkg.dec -+ -+[LibraryClasses] -+ GoogleTestLib -+ DebugLib -+ NetLib -+ PcdLib -+ -+[Protocols] -+ gEfiDhcp6ServiceBindingProtocolGuid -+ -+[Pcd] -+ gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType -+ -+[Guids] -+ gZeroGuid -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp -new file mode 100644 -index 0000000000..f2cd90e1a9 ---- /dev/null -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp -@@ -0,0 +1,129 @@ -+/** @file -+ Tests for Ip6Option.c. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+extern "C" { -+ #include -+ #include -+ #include -+ #include "../Ip6Impl.h" -+ #include "../Ip6Option.h" -+} -+ -+///////////////////////////////////////////////////////////////////////// -+// Defines -+/////////////////////////////////////////////////////////////////////// -+ -+#define IP6_PREFIX_INFO_OPTION_DATA_LEN 32 -+#define OPTION_HEADER_IP6_PREFIX_DATA_LEN (sizeof (IP6_OPTION_HEADER) + IP6_PREFIX_INFO_OPTION_DATA_LEN) -+ -+//////////////////////////////////////////////////////////////////////// -+// Symbol Definitions -+// These functions are not directly under test - but required to compile -+//////////////////////////////////////////////////////////////////////// -+UINT32 mIp6Id; -+ -+EFI_STATUS -+Ip6SendIcmpError ( -+ IN IP6_SERVICE *IpSb, -+ IN NET_BUF *Packet, -+ IN EFI_IPv6_ADDRESS *SourceAddress OPTIONAL, -+ IN EFI_IPv6_ADDRESS *DestinationAddress, -+ IN UINT8 Type, -+ IN UINT8 Code, -+ IN UINT32 *Pointer OPTIONAL -+ ) -+{ -+ // .. -+ return EFI_SUCCESS; -+} -+ -+//////////////////////////////////////////////////////////////////////// -+// Ip6OptionValidation Tests -+//////////////////////////////////////////////////////////////////////// -+ -+// Define a fixture for your tests if needed -+class Ip6OptionValidationTest : public ::testing::Test { -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ // Initialize any resources or variables -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ // Clean up any resources or variables -+ } -+}; -+ -+// Test Description: -+// Null option should return false -+TEST_F (Ip6OptionValidationTest, NullOptionShouldReturnFalse) { -+ UINT8 *option = nullptr; -+ UINT16 optionLen = 10; // Provide a suitable length -+ -+ EXPECT_FALSE (Ip6IsNDOptionValid (option, optionLen)); -+} -+ -+// Test Description: -+// Truncated option should return false -+TEST_F (Ip6OptionValidationTest, TruncatedOptionShouldReturnFalse) { -+ UINT8 option[] = { 0x01 }; // Provide a truncated option -+ UINT16 optionLen = 1; -+ -+ EXPECT_FALSE (Ip6IsNDOptionValid (option, optionLen)); -+} -+ -+// Test Description: -+// Ip6OptionPrefixInfo Option with zero length should return false -+TEST_F (Ip6OptionValidationTest, OptionWithZeroLengthShouldReturnFalse) { -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = Ip6OptionPrefixInfo; -+ optionHeader.Length = 0; -+ UINT8 option[sizeof (IP6_OPTION_HEADER)]; -+ -+ CopyMem (option, &optionHeader, sizeof (IP6_OPTION_HEADER)); -+ UINT16 optionLen = sizeof (IP6_OPTION_HEADER); -+ -+ EXPECT_FALSE (Ip6IsNDOptionValid (option, optionLen)); -+} -+ -+// Test Description: -+// Ip6OptionPrefixInfo Option with valid length should return true -+TEST_F (Ip6OptionValidationTest, ValidPrefixInfoOptionShouldReturnTrue) { -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = Ip6OptionPrefixInfo; -+ optionHeader.Length = 4; // Length 4 * 8 = 32 -+ UINT8 option[OPTION_HEADER_IP6_PREFIX_DATA_LEN]; -+ -+ CopyMem (option, &optionHeader, sizeof (IP6_OPTION_HEADER)); -+ -+ EXPECT_TRUE (Ip6IsNDOptionValid (option, IP6_PREFIX_INFO_OPTION_DATA_LEN)); -+} -+ -+// Test Description: -+// Ip6OptionPrefixInfo Option with invalid length should return false -+TEST_F (Ip6OptionValidationTest, InvalidPrefixInfoOptionLengthShouldReturnFalse) { -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = Ip6OptionPrefixInfo; -+ optionHeader.Length = 3; // Length 3 * 8 = 24 (Invalid) -+ UINT8 option[sizeof (IP6_OPTION_HEADER)]; -+ -+ CopyMem (option, &optionHeader, sizeof (IP6_OPTION_HEADER)); -+ UINT16 optionLen = sizeof (IP6_OPTION_HEADER); -+ -+ EXPECT_FALSE (Ip6IsNDOptionValid (option, optionLen)); -+} -diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/NetworkPkgHostTest.dsc -index 20bc90b172..ab7c2857b6 100644 ---- a/NetworkPkg/Test/NetworkPkgHostTest.dsc -+++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc -@@ -25,6 +25,7 @@ - # Build HOST_APPLICATION that tests NetworkPkg - # - NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf -+ NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf - - # Despite these library classes being listed in [LibraryClasses] below, they are not needed for the host-based unit tests. - [LibraryClasses] --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Patc.patch b/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Patc.patch deleted file mode 100644 index a7b6eb8..0000000 --- a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Patc.patch +++ /dev/null @@ -1,377 +0,0 @@ -From 23b31a16bbb789f4c251b1d2f23334210a9fb545 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 15 Feb 2024 11:51:09 -0500 -Subject: [PATCH 04/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [4/15] 48c273e43a6275c7eae3223c4ffa433f4d6531a4 - -JIRA: https://issues.redhat.com/browse/RHEL-21846 -CVE: CVE-2022-45232 -Upstream: Merged - -JIRA: https://issues.redhat.com/browse/RHEL-21848 -CVE: CVE-2022-45233 -Upstream: Merged - -commit 4df0229ef992d4f2721a8508787ebf9dc81fbd6e -Author: Doug Flick -Date: Fri Jan 26 05:54:50 2024 +0800 - - NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Patch - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4537 - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4538 - - Bug Details: - PixieFail Bug #4 - CVE-2023-45232 - CVSS 7.5 : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H - CWE-835 Loop with Unreachable Exit Condition ('Infinite Loop') - - Infinite loop when parsing unknown options in the Destination Options - header - - PixieFail Bug #5 - CVE-2023-45233 - CVSS 7.5 : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H - CWE-835 Loop with Unreachable Exit Condition ('Infinite Loop') - - Infinite loop when parsing a PadN option in the Destination Options - header - - Change Overview: - - Most importantly this change corrects the following incorrect math - and cleans up the code. - - > // It is a PadN option - > // - > - Offset = (UINT8)(Offset + *(Option + Offset + 1) + 2); - > + OptDataLen = ((EFI_IP6_OPTION *)(Option + Offset))->Length; - > + Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen); - - > case Ip6OptionSkip: - > - Offset = (UINT8)(Offset + *(Option + Offset + 1)); - > OptDataLen = ((EFI_IP6_OPTION *)(Option + Offset))->Length; - > Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen); - - Additionally, this change also corrects incorrect math where the calling - function was calculating the HDR EXT optionLen as a uint8 instead of a - uint16 - - > - OptionLen = (UINT8)((*Option + 1) * 8 - 2); - > + OptionLen = IP6_HDR_EXT_LEN (*Option) - - IP6_COMBINED_SIZE_OF_NEXT_HDR_AND_LEN; - - Additionally this check adds additional logic to santize the incoming - data - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Ip6Dxe/Ip6Nd.h | 35 ++++++++++++++++ - NetworkPkg/Ip6Dxe/Ip6Option.c | 76 ++++++++++++++++++++++++++++++----- - NetworkPkg/Ip6Dxe/Ip6Option.h | 71 ++++++++++++++++++++++++++++++++ - 3 files changed, 171 insertions(+), 11 deletions(-) - -diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.h b/NetworkPkg/Ip6Dxe/Ip6Nd.h -index 860934a167..bf64e9114e 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Nd.h -+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.h -@@ -56,13 +56,48 @@ VOID - VOID *Context - ); - -+// -+// Per RFC8200 Section 4.2 -+// -+// Two of the currently-defined extension headers -- the Hop-by-Hop -+// Options header and the Destination Options header -- carry a variable -+// number of type-length-value (TLV) encoded "options", of the following -+// format: -+// -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - - -+// | Option Type | Opt Data Len | Option Data -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - - -+// -+// Option Type 8-bit identifier of the type of option. -+// -+// Opt Data Len 8-bit unsigned integer. Length of the Option -+// Data field of this option, in octets. -+// -+// Option Data Variable-length field. Option-Type-specific -+// data. -+// - typedef struct _IP6_OPTION_HEADER { -+ /// -+ /// identifier of the type of option. -+ /// - UINT8 Type; -+ /// -+ /// Length of the Option Data field of this option, in octets. -+ /// - UINT8 Length; -+ /// -+ /// Option-Type-specific data. -+ /// - } IP6_OPTION_HEADER; - - STATIC_ASSERT (sizeof (IP6_OPTION_HEADER) == 2, "IP6_OPTION_HEADER is expected to be exactly 2 bytes long."); - -+#define IP6_NEXT_OPTION_OFFSET(offset, length) (offset + sizeof(IP6_OPTION_HEADER) + length) -+STATIC_ASSERT ( -+ IP6_NEXT_OPTION_OFFSET (0, 0) == 2, -+ "The next option is minimally the combined size of the option tag and length" -+ ); -+ - typedef struct _IP6_ETHE_ADDR_OPTION { - UINT8 Type; - UINT8 Length; -diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.c b/NetworkPkg/Ip6Dxe/Ip6Option.c -index 8718d5d875..fd97ce116f 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Option.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Option.c -@@ -17,7 +17,8 @@ - @param[in] IpSb The IP6 service data. - @param[in] Packet The to be validated packet. - @param[in] Option The first byte of the option. -- @param[in] OptionLen The length of the whole option. -+ @param[in] OptionLen The length of all options, expressed in byte length of octets. -+ Maximum length is 2046 bytes or ((n + 1) * 8) - 2 where n is 255. - @param[in] Pointer Identifies the octet offset within - the invoking packet where the error was detected. - -@@ -31,12 +32,33 @@ Ip6IsOptionValid ( - IN IP6_SERVICE *IpSb, - IN NET_BUF *Packet, - IN UINT8 *Option, -- IN UINT8 OptionLen, -+ IN UINT16 OptionLen, - IN UINT32 Pointer - ) - { -- UINT8 Offset; -- UINT8 OptionType; -+ UINT16 Offset; -+ UINT8 OptionType; -+ UINT8 OptDataLen; -+ -+ if (Option == NULL) { -+ ASSERT (Option != NULL); -+ return FALSE; -+ } -+ -+ if ((OptionLen <= 0) || (OptionLen > IP6_MAX_EXT_DATA_LENGTH)) { -+ ASSERT (OptionLen > 0 && OptionLen <= IP6_MAX_EXT_DATA_LENGTH); -+ return FALSE; -+ } -+ -+ if (Packet == NULL) { -+ ASSERT (Packet != NULL); -+ return FALSE; -+ } -+ -+ if (IpSb == NULL) { -+ ASSERT (IpSb != NULL); -+ return FALSE; -+ } - - Offset = 0; - -@@ -54,7 +76,8 @@ Ip6IsOptionValid ( - // - // It is a PadN option - // -- Offset = (UINT8)(Offset + *(Option + Offset + 1) + 2); -+ OptDataLen = ((IP6_OPTION_HEADER *)(Option + Offset))->Length; -+ Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen); - break; - case Ip6OptionRouterAlert: - // -@@ -69,7 +92,8 @@ Ip6IsOptionValid ( - // - switch (OptionType & Ip6OptionMask) { - case Ip6OptionSkip: -- Offset = (UINT8)(Offset + *(Option + Offset + 1)); -+ OptDataLen = ((IP6_OPTION_HEADER *)(Option + Offset))->Length; -+ Offset = IP6_NEXT_OPTION_OFFSET (Offset, OptDataLen); - break; - case Ip6OptionDiscard: - return FALSE; -@@ -308,7 +332,7 @@ Ip6IsExtsValid ( - UINT32 Pointer; - UINT32 Offset; - UINT8 *Option; -- UINT8 OptionLen; -+ UINT16 OptionLen; - BOOLEAN Flag; - UINT8 CountD; - UINT8 CountA; -@@ -385,6 +409,36 @@ Ip6IsExtsValid ( - // Fall through - // - case IP6_DESTINATION: -+ // -+ // See https://www.rfc-editor.org/rfc/rfc2460#section-4.2 page 23 -+ // -+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+ // | Next Header | Hdr Ext Len | | -+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + -+ // | | -+ // . . -+ // . Options . -+ // . . -+ // | | -+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+ // -+ // -+ // Next Header 8-bit selector. Identifies the type of header -+ // immediately following the Destination Options -+ // header. Uses the same values as the IPv4 -+ // Protocol field [RFC-1700 et seq.]. -+ // -+ // Hdr Ext Len 8-bit unsigned integer. Length of the -+ // Destination Options header in 8-octet units, not -+ // including the first 8 octets. -+ // -+ // Options Variable-length field, of length such that the -+ // complete Destination Options header is an -+ // integer multiple of 8 octets long. Contains one -+ // or more TLV-encoded options, as described in -+ // section 4.2. -+ // -+ - if (*NextHeader == IP6_DESTINATION) { - CountD++; - } -@@ -398,7 +452,7 @@ Ip6IsExtsValid ( - - Offset++; - Option = ExtHdrs + Offset; -- OptionLen = (UINT8)((*Option + 1) * 8 - 2); -+ OptionLen = IP6_HDR_EXT_LEN (*Option) - sizeof (IP6_EXT_HDR); - Option++; - Offset++; - -@@ -430,7 +484,7 @@ Ip6IsExtsValid ( - // - // Ignore the routing header and proceed to process the next header. - // -- Offset = Offset + (RoutingHead->HeaderLen + 1) * 8; -+ Offset = Offset + IP6_HDR_EXT_LEN (RoutingHead->HeaderLen); - - if (UnFragmentLen != NULL) { - *UnFragmentLen = Offset; -@@ -441,7 +495,7 @@ Ip6IsExtsValid ( - // to the packet's source address, pointing to the unrecognized routing - // type. - // -- Pointer = Offset + 2 + sizeof (EFI_IP6_HEADER); -+ Pointer = Offset + sizeof (IP6_EXT_HDR) + sizeof (EFI_IP6_HEADER); - if ((IpSb != NULL) && (Packet != NULL) && - !IP6_IS_MULTICAST (&Packet->Ip.Ip6->DestinationAddress)) - { -@@ -527,7 +581,7 @@ Ip6IsExtsValid ( - // - // RFC2402, Payload length is specified in 32-bit words, minus "2". - // -- OptionLen = (UINT8)((*Option + 2) * 4); -+ OptionLen = ((UINT16)(*Option + 2) * 4); - Offset = Offset + OptionLen; - break; - -diff --git a/NetworkPkg/Ip6Dxe/Ip6Option.h b/NetworkPkg/Ip6Dxe/Ip6Option.h -index bd8e223c8a..fb07c28f5a 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Option.h -+++ b/NetworkPkg/Ip6Dxe/Ip6Option.h -@@ -12,6 +12,77 @@ - - #define IP6_FRAGMENT_OFFSET_MASK (~0x3) - -+// -+// For more information see RFC 8200, Section 4.3, 4.4, and 4.6 -+// -+// This example format is from section 4.6 -+// This does not apply to fragment headers -+// -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// | Next Header | Hdr Ext Len | | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + -+// | | -+// . . -+// . Header-Specific Data . -+// . . -+// | | -+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -+// -+// Next Header 8-bit selector. Identifies the type of -+// header immediately following the extension -+// header. Uses the same values as the IPv4 -+// Protocol field [IANA-PN]. -+// -+// Hdr Ext Len 8-bit unsigned integer. Length of the -+// Destination Options header in 8-octet units, -+// not including the first 8 octets. -+ -+// -+// These defines apply to the following: -+// 1. Hop by Hop -+// 2. Routing -+// 3. Destination -+// -+typedef struct _IP6_EXT_HDR { -+ /// -+ /// The Next Header field identifies the type of header immediately -+ /// -+ UINT8 NextHeader; -+ /// -+ /// The Hdr Ext Len field specifies the length of the Hop-by-Hop Options -+ /// -+ UINT8 HdrExtLen; -+ /// -+ /// Header-Specific Data -+ /// -+} IP6_EXT_HDR; -+ -+STATIC_ASSERT ( -+ sizeof (IP6_EXT_HDR) == 2, -+ "The combined size of Next Header and Len is two 8 bit fields" -+ ); -+ -+// -+// IPv6 extension headers contain an 8-bit length field which describes the size of -+// the header. However, the length field only includes the size of the extension -+// header options, not the size of the first 8 bytes of the header. Therefore, in -+// order to calculate the full size of the extension header, we add 1 (to account -+// for the first 8 bytes omitted by the length field reporting) and then multiply -+// by 8 (since the size is represented in 8-byte units). -+// -+// a is the length field of the extension header (UINT8) -+// The result may be up to 2046 octets (UINT16) -+// -+#define IP6_HDR_EXT_LEN(a) (((UINT16)((UINT8)(a)) + 1) * 8) -+ -+// This is the maxmimum length permissible by a extension header -+// Length is UINT8 of 8 octets not including the first 8 octets -+#define IP6_MAX_EXT_DATA_LENGTH (IP6_HDR_EXT_LEN (MAX_UINT8) - sizeof(IP6_EXT_HDR)) -+STATIC_ASSERT ( -+ IP6_MAX_EXT_DATA_LENGTH == 2046, -+ "Maximum data length is ((MAX_UINT8 + 1) * 8) - 2" -+ ); -+ - typedef struct _IP6_FRAGMENT_HEADER { - UINT8 NextHeader; - UINT8 Reserved; --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Unit.patch b/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Unit.patch deleted file mode 100644 index 1add20a..0000000 --- a/SOURCES/edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Unit.patch +++ /dev/null @@ -1,430 +0,0 @@ -From 2bd8bc051f6394f2ab3c22649c54ecbed5d636cd Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 14 Feb 2024 20:25:29 -0500 -Subject: [PATCH 05/15] NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Unit - Tests - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [5/15] 624365d403df25927ab0514b0e25faea7376def8 - -JIRA: https://issues.redhat.com/browse/RHEL-21846 -CVE: CVE-2022-45232 -Upstream: Merged - -commit c9c87f08dd6ace36fa843424522c3558a8374cac -Author: Doug Flick -Date: Fri Jan 26 05:54:51 2024 +0800 - - NetworkPkg: Ip6Dxe: SECURITY PATCH CVE-2023-45232 Unit Tests - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4537 - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4538 - - Unit tests to confirm that.. - Infinite loop when parsing unknown options in the Destination Options - header - - and - - Infinite loop when parsing a PadN option in the Destination Options - header - - ... have been patched - - This patch tests the following functions: - Ip6IsOptionValid - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - .../Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf | 10 +- - .../Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp | 278 ++++++++++++++++++ - .../Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.h | 40 +++ - 3 files changed, 324 insertions(+), 4 deletions(-) - create mode 100644 NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.h - -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -index 6e4de0745f..ba29dbabad 100644 ---- a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -@@ -1,13 +1,13 @@ - ## @file --# Unit test suite for the Ip6Dxe using Google Test -+# Unit test suite for the Ip6DxeGoogleTest using Google Test - # - # Copyright (c) Microsoft Corporation.
- # SPDX-License-Identifier: BSD-2-Clause-Patent - ## - [Defines] - INF_VERSION = 0x00010017 -- BASE_NAME = Ip6DxeUnitTest -- FILE_GUID = 4F05D17D-D3E7-4AAE-820C-576D46D2D34A -+ BASE_NAME = Ip6DxeGoogleTest -+ FILE_GUID = AE39981C-B7FE-41A8-A9C2-F41910477CA3 - VERSION_STRING = 1.0 - MODULE_TYPE = HOST_APPLICATION - # -@@ -16,9 +16,11 @@ - # VALID_ARCHITECTURES = IA32 X64 AARCH64 - # - [Sources] -+ ../Ip6Option.c -+ Ip6OptionGoogleTest.h - Ip6DxeGoogleTest.cpp - Ip6OptionGoogleTest.cpp -- ../Ip6Option.c -+ Ip6OptionGoogleTest.h - - [Packages] - MdePkg/MdePkg.dec -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp -index f2cd90e1a9..29f8a4a96e 100644 ---- a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.cpp -@@ -12,6 +12,7 @@ extern "C" { - #include - #include "../Ip6Impl.h" - #include "../Ip6Option.h" -+ #include "Ip6OptionGoogleTest.h" - } - - ///////////////////////////////////////////////////////////////////////// -@@ -127,3 +128,280 @@ TEST_F (Ip6OptionValidationTest, InvalidPrefixInfoOptionLengthShouldReturnFalse) - - EXPECT_FALSE (Ip6IsNDOptionValid (option, optionLen)); - } -+ -+//////////////////////////////////////////////////////////////////////// -+// Ip6IsOptionValid Tests -+//////////////////////////////////////////////////////////////////////// -+ -+// Define a fixture for your tests if needed -+class Ip6IsOptionValidTest : public ::testing::Test { -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ // Initialize any resources or variables -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ // Clean up any resources or variables -+ } -+}; -+ -+// Test Description -+// Verify that a NULL option is Invalid -+TEST_F (Ip6IsOptionValidTest, NullOptionShouldReturnTrue) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ IP6_SERVICE *IpSb = NULL; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ EXPECT_FALSE (Ip6IsOptionValid (IpSb, &Packet, NULL, 0, 0)); -+} -+ -+// Test Description -+// Verify that an unknown option with a length of 0 and type of does not cause an infinite loop -+TEST_F (Ip6IsOptionValidTest, VerifyNoInfiniteLoopOnUnknownOptionLength0) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = 23; // Unknown Option -+ optionHeader.Length = 0; // This will cause an infinite loop if the function is not working correctly -+ -+ // This should be a valid option even though the length is 0 -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify that an unknown option with a length of 1 and type of does not cause an infinite loop -+TEST_F (Ip6IsOptionValidTest, VerifyNoInfiniteLoopOnUnknownOptionLength1) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = 23; // Unknown Option -+ optionHeader.Length = 1; // This will cause an infinite loop if the function is not working correctly -+ -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify that an unknown option with a length of 2 and type of does not cause an infinite loop -+TEST_F (Ip6IsOptionValidTest, VerifyIpSkipUnknownOption) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = 23; // Unknown Option -+ optionHeader.Length = 2; // Valid length for an unknown option -+ -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify that Ip6OptionPad1 is valid with a length of 0 -+TEST_F (Ip6IsOptionValidTest, VerifyIp6OptionPad1) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = Ip6OptionPad1; -+ optionHeader.Length = 0; -+ -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify that Ip6OptionPadN doesn't overflow with various lengths -+TEST_F (Ip6IsOptionValidTest, VerifyIp6OptionPadN) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = Ip6OptionPadN; -+ optionHeader.Length = 0xFF; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFE; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFD; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFC; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify an unknown option doesn't cause an infinite loop with various lengths -+TEST_F (Ip6IsOptionValidTest, VerifyNoInfiniteLoopOnUnknownOptionLengthAttemptOverflow) { -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ IP6_OPTION_HEADER optionHeader; -+ -+ optionHeader.Type = 23; // Unknown Option -+ optionHeader.Length = 0xFF; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFE; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFD; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+ -+ optionHeader.Length = 0xFC; -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, (UINT8 *)&optionHeader, sizeof (optionHeader), 0)); -+} -+ -+// Test Description -+// Verify that the function supports multiple options -+TEST_F (Ip6IsOptionValidTest, MultiOptionSupport) { -+ UINT16 HdrLen; -+ NET_BUF Packet = { 0 }; -+ // we need to define enough of the packet to make the function work -+ // The function being tested will pass IpSb to Ip6SendIcmpError which is defined above -+ UINT32 DeadCode = 0xDeadC0de; -+ // Don't actually use this pointer, just pass it to the function, nothing will be done with it -+ IP6_SERVICE *IpSb = (IP6_SERVICE *)&DeadCode; -+ -+ EFI_IPv6_ADDRESS SourceAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IPv6_ADDRESS DestinationAddress = { 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x42, 0x83, 0x29 }; -+ EFI_IP6_HEADER Ip6Header = { 0 }; -+ -+ Ip6Header.SourceAddress = SourceAddress; -+ Ip6Header.DestinationAddress = DestinationAddress; -+ Packet.Ip.Ip6 = &Ip6Header; -+ -+ UINT8 ExtHdr[1024] = { 0 }; -+ UINT8 *Cursor = ExtHdr; -+ IP6_OPTION_HEADER *Option = (IP6_OPTION_HEADER *)ExtHdr; -+ -+ // Let's start chaining options -+ -+ Option->Type = 23; // Unknown Option -+ Option->Length = 0xFC; -+ -+ Cursor += sizeof (IP6_OPTION_HEADER) + 0xFC; -+ -+ Option = (IP6_OPTION_HEADER *)Cursor; -+ Option->Type = Ip6OptionPad1; -+ -+ Cursor += sizeof (1); -+ -+ // Type and length aren't processed, instead it just moves the pointer forward by 4 bytes -+ Option = (IP6_OPTION_HEADER *)Cursor; -+ Option->Type = Ip6OptionRouterAlert; -+ Option->Length = 4; -+ -+ Cursor += sizeof (IP6_OPTION_HEADER) + 4; -+ -+ Option = (IP6_OPTION_HEADER *)Cursor; -+ Option->Type = Ip6OptionPadN; -+ Option->Length = 0xFC; -+ -+ Cursor += sizeof (IP6_OPTION_HEADER) + 0xFC; -+ -+ Option = (IP6_OPTION_HEADER *)Cursor; -+ Option->Type = Ip6OptionRouterAlert; -+ Option->Length = 4; -+ -+ Cursor += sizeof (IP6_OPTION_HEADER) + 4; -+ -+ // Total 524 -+ -+ HdrLen = (UINT16)(Cursor - ExtHdr); -+ -+ EXPECT_TRUE (Ip6IsOptionValid (IpSb, &Packet, ExtHdr, HdrLen, 0)); -+} -diff --git a/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.h b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.h -new file mode 100644 -index 0000000000..0509b6ae30 ---- /dev/null -+++ b/NetworkPkg/Ip6Dxe/GoogleTest/Ip6OptionGoogleTest.h -@@ -0,0 +1,40 @@ -+/** @file -+ Exposes the functions needed to test the Ip6Option module. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#ifndef IP6_OPTION_HEADER_GOOGLE_TEST_H_ -+#define IP6_OPTION_HEADER_GOOGLE_TEST_H_ -+ -+#include -+#include "../Ip6Impl.h" -+ -+/** -+ Validate the IP6 option format for both the packets we received -+ and that we will transmit. It will compute the ICMPv6 error message fields -+ if the option is malformatted. -+ -+ @param[in] IpSb The IP6 service data. -+ @param[in] Packet The to be validated packet. -+ @param[in] Option The first byte of the option. -+ @param[in] OptionLen The length of the whole option. -+ @param[in] Pointer Identifies the octet offset within -+ the invoking packet where the error was detected. -+ -+ -+ @retval TRUE The option is properly formatted. -+ @retval FALSE The option is malformatted. -+ -+**/ -+BOOLEAN -+Ip6IsOptionValid ( -+ IN IP6_SERVICE *IpSb, -+ IN NET_BUF *Packet, -+ IN UINT8 *Option, -+ IN UINT16 OptionLen, -+ IN UINT32 Pointer -+ ); -+ -+#endif // __IP6_OPTION_HEADER_GOOGLE_TEST_H__ --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch b/SOURCES/edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch deleted file mode 100644 index 92ddff3..0000000 --- a/SOURCES/edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch +++ /dev/null @@ -1,1252 +0,0 @@ -From 43f2ff1b06ea010f06cdef68eebc9e0280489477 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 11 Jun 2024 15:19:39 -0400 -Subject: [PATCH 24/31] NetworkPkg: SECURITY PATCH CVE-2023-45237 - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [24/31] 3fc9b5e3d0ab3a20c139601292fed66a6a089644 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 -Conflicts: Did not add NetworkPkg/SecurityFixes.yaml - -commit 4c4ceb2ceb80c42fd5545b2a4bd80321f07f4345 -Author: Doug Flick -Date: Wed May 8 22:56:28 2024 -0700 - - NetworkPkg: SECURITY PATCH CVE-2023-45237 - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4542 - - Bug Overview: - PixieFail Bug #9 - CVE-2023-45237 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N - CWE-338 Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) - - Use of a Weak PseudoRandom Number Generator - - Change Overview: - - Updates all Instances of NET_RANDOM (NetRandomInitSeed ()) to either - - > - > EFI_STATUS - > EFIAPI - > PseudoRandomU32 ( - > OUT UINT32 *Output - > ); - > - - or (depending on the use case) - - > - > EFI_STATUS - > EFIAPI - > PseudoRandom ( - > OUT VOID *Output, - > IN UINTN OutputLength - > ); - > - - This is because the use of - - Example: - - The following code snippet PseudoRandomU32 () function is used: - - > - > UINT32 Random; - > - > Status = PseudoRandomU32 (&Random); - > if (EFI_ERROR (Status)) { - > DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", - __func__, Status)); - > return Status; - > } - > - This also introduces a new PCD to enable/disable the use of the - secure implementation of algorithms for PseudoRandom () and - instead depend on the default implementation. This may be required for - some platforms where the UEFI Spec defined algorithms are not available. - - > - > PcdEnforceSecureRngAlgorithms - > - - If the platform does not have any one of the UEFI defined - secure RNG algorithms then the driver will assert. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c | 10 +- - NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c | 11 +- - NetworkPkg/DnsDxe/DnsDhcp.c | 10 +- - NetworkPkg/DnsDxe/DnsImpl.c | 11 +- - NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 10 +- - NetworkPkg/IScsiDxe/IScsiCHAP.c | 19 ++- - NetworkPkg/IScsiDxe/IScsiMisc.c | 14 +-- - NetworkPkg/IScsiDxe/IScsiMisc.h | 6 +- - NetworkPkg/Include/Library/NetLib.h | 40 +++++-- - NetworkPkg/Ip4Dxe/Ip4Driver.c | 10 +- - NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 9 +- - NetworkPkg/Ip6Dxe/Ip6Driver.c | 17 ++- - NetworkPkg/Ip6Dxe/Ip6If.c | 12 +- - NetworkPkg/Ip6Dxe/Ip6Mld.c | 12 +- - NetworkPkg/Ip6Dxe/Ip6Nd.c | 33 +++++- - NetworkPkg/Ip6Dxe/Ip6Nd.h | 8 +- - NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 130 ++++++++++++++++++--- - NetworkPkg/Library/DxeNetLib/DxeNetLib.inf | 14 ++- - NetworkPkg/NetworkPkg.dec | 7 ++ - NetworkPkg/TcpDxe/TcpDriver.c | 15 ++- - NetworkPkg/TcpDxe/TcpDxe.inf | 3 + - NetworkPkg/Udp4Dxe/Udp4Driver.c | 10 +- - NetworkPkg/Udp6Dxe/Udp6Driver.c | 11 +- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c | 9 +- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 11 +- - NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 12 +- - 26 files changed, 371 insertions(+), 83 deletions(-) - -diff --git a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -index 8c37e93be3..892caee368 100644 ---- a/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -+++ b/NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c -@@ -1,6 +1,7 @@ - /** @file - - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -189,6 +190,13 @@ Dhcp4CreateService ( - { - DHCP_SERVICE *DhcpSb; - EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - *Service = NULL; - DhcpSb = AllocateZeroPool (sizeof (DHCP_SERVICE)); -@@ -203,7 +211,7 @@ Dhcp4CreateService ( - DhcpSb->Image = ImageHandle; - InitializeListHead (&DhcpSb->Children); - DhcpSb->DhcpState = Dhcp4Stopped; -- DhcpSb->Xid = NET_RANDOM (NetRandomInitSeed ()); -+ DhcpSb->Xid = Random; - CopyMem ( - &DhcpSb->ServiceBinding, - &mDhcp4ServiceBindingTemplate, -diff --git a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -index b591a4605b..e7f2787a98 100644 ---- a/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -+++ b/NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c -@@ -3,7 +3,7 @@ - implementation for Dhcp6 Driver. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -123,6 +123,13 @@ Dhcp6CreateService ( - { - DHCP6_SERVICE *Dhcp6Srv; - EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - *Service = NULL; - Dhcp6Srv = AllocateZeroPool (sizeof (DHCP6_SERVICE)); -@@ -147,7 +154,7 @@ Dhcp6CreateService ( - Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE; - Dhcp6Srv->Controller = Controller; - Dhcp6Srv->Image = ImageHandle; -- Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ())); -+ Dhcp6Srv->Xid = (0xffffff & Random); - - CopyMem ( - &Dhcp6Srv->ServiceBinding, -diff --git a/NetworkPkg/DnsDxe/DnsDhcp.c b/NetworkPkg/DnsDxe/DnsDhcp.c -index 933565a32d..9eb3c1d2d8 100644 ---- a/NetworkPkg/DnsDxe/DnsDhcp.c -+++ b/NetworkPkg/DnsDxe/DnsDhcp.c -@@ -2,6 +2,7 @@ - Functions implementation related with DHCPv4/v6 for DNS driver. - - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -277,6 +278,7 @@ GetDns4ServerFromDhcp4 ( - EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token; - BOOLEAN IsDone; - UINTN Index; -+ UINT32 Random; - - Image = Instance->Service->ImageHandle; - Controller = Instance->Service->ControllerHandle; -@@ -292,6 +294,12 @@ GetDns4ServerFromDhcp4 ( - Data = NULL; - InterfaceInfo = NULL; - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - ZeroMem ((UINT8 *)ParaList, sizeof (ParaList)); - - ZeroMem (&MnpConfigData, sizeof (EFI_MANAGED_NETWORK_CONFIG_DATA)); -@@ -467,7 +475,7 @@ GetDns4ServerFromDhcp4 ( - - Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0, NULL, 2, ParaList, &Token.Packet); - -- Token.Packet->Dhcp4.Header.Xid = HTONL (NET_RANDOM (NetRandomInitSeed ())); -+ Token.Packet->Dhcp4.Header.Xid = Random; - - Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16)0x8000); - -diff --git a/NetworkPkg/DnsDxe/DnsImpl.c b/NetworkPkg/DnsDxe/DnsImpl.c -index d311812800..c2629bb8df 100644 ---- a/NetworkPkg/DnsDxe/DnsImpl.c -+++ b/NetworkPkg/DnsDxe/DnsImpl.c -@@ -2,6 +2,7 @@ - DnsDxe support functions implementation. - - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -1963,6 +1964,14 @@ ConstructDNSQuery ( - NET_FRAGMENT Frag; - DNS_HEADER *DnsHeader; - DNS_QUERY_SECTION *DnsQuery; -+ EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - // - // Messages carried by UDP are restricted to 512 bytes (not counting the IP -@@ -1977,7 +1986,7 @@ ConstructDNSQuery ( - // Fill header - // - DnsHeader = (DNS_HEADER *)Frag.Bulk; -- DnsHeader->Identification = (UINT16)NET_RANDOM (NetRandomInitSeed ()); -+ DnsHeader->Identification = (UINT16)Random; - DnsHeader->Flags.Uint16 = 0x0000; - DnsHeader->Flags.Bits.RD = 1; - DnsHeader->Flags.Bits.OpCode = DNS_FLAGS_OPCODE_STANDARD; -diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -index b22cef4ff5..f964515b0f 100644 ---- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c -@@ -2,6 +2,7 @@ - Functions implementation related with DHCPv6 for HTTP boot driver. - - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -951,6 +952,7 @@ HttpBootDhcp6Sarr ( - UINT32 OptCount; - UINT8 Buffer[HTTP_BOOT_DHCP6_OPTION_MAX_SIZE]; - EFI_STATUS Status; -+ UINT32 Random; - - Dhcp6 = Private->Dhcp6; - ASSERT (Dhcp6 != NULL); -@@ -961,6 +963,12 @@ HttpBootDhcp6Sarr ( - OptCount = HttpBootBuildDhcp6Options (Private, OptList, Buffer); - ASSERT (OptCount > 0); - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - Retransmit = AllocateZeroPool (sizeof (EFI_DHCP6_RETRANSMISSION)); - if (Retransmit == NULL) { - return EFI_OUT_OF_RESOURCES; -@@ -976,7 +984,7 @@ HttpBootDhcp6Sarr ( - Config.IaInfoEvent = NULL; - Config.RapidCommit = FALSE; - Config.ReconfigureAccept = FALSE; -- Config.IaDescriptor.IaId = NET_RANDOM (NetRandomInitSeed ()); -+ Config.IaDescriptor.IaId = Random; - Config.IaDescriptor.Type = EFI_DHCP6_IA_TYPE_NA; - Config.SolicitRetransmission = Retransmit; - Retransmit->Irt = 4; -diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.c b/NetworkPkg/IScsiDxe/IScsiCHAP.c -index b507f11cd4..bebb1ac29b 100644 ---- a/NetworkPkg/IScsiDxe/IScsiCHAP.c -+++ b/NetworkPkg/IScsiDxe/IScsiCHAP.c -@@ -3,6 +3,7 @@ - Configuration. - - Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -576,16 +577,24 @@ IScsiCHAPToSendReq ( - // - // CHAP_I= - // -- IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1); -+ Status = IScsiGenRandom ((UINT8 *)&AuthData->OutIdentifier, 1); -+ if (EFI_ERROR (Status)) { -+ break; -+ } -+ - AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", AuthData->OutIdentifier); - IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_IDENTIFIER, ValueStr); - // - // CHAP_C= - // -- IScsiGenRandom ( -- (UINT8 *)AuthData->OutChallenge, -- AuthData->Hash->DigestSize -- ); -+ Status = IScsiGenRandom ( -+ (UINT8 *)AuthData->OutChallenge, -+ AuthData->Hash->DigestSize -+ ); -+ if (EFI_ERROR (Status)) { -+ break; -+ } -+ - BinToHexStatus = IScsiBinToHex ( - (UINT8 *)AuthData->OutChallenge, - AuthData->Hash->DigestSize, -diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c -index b3ea90158f..cd77f1a13e 100644 ---- a/NetworkPkg/IScsiDxe/IScsiMisc.c -+++ b/NetworkPkg/IScsiDxe/IScsiMisc.c -@@ -2,6 +2,7 @@ - Miscellaneous routines for iSCSI driver. - - Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -474,20 +475,17 @@ IScsiNetNtoi ( - @param[in, out] Rand The buffer to contain random numbers. - @param[in] RandLength The length of the Rand buffer. - -+ @retval EFI_SUCCESS on success -+ @retval others on error -+ - **/ --VOID -+EFI_STATUS - IScsiGenRandom ( - IN OUT UINT8 *Rand, - IN UINTN RandLength - ) - { -- UINT32 Random; -- -- while (RandLength > 0) { -- Random = NET_RANDOM (NetRandomInitSeed ()); -- *Rand++ = (UINT8)(Random); -- RandLength--; -- } -+ return PseudoRandom (Rand, RandLength); - } - - /** -diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.h -index fddef4f466..a8f814f7b8 100644 ---- a/NetworkPkg/IScsiDxe/IScsiMisc.h -+++ b/NetworkPkg/IScsiDxe/IScsiMisc.h -@@ -2,6 +2,7 @@ - Miscellaneous definitions for iSCSI driver. - - Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -205,8 +206,11 @@ IScsiNetNtoi ( - @param[in, out] Rand The buffer to contain random numbers. - @param[in] RandLength The length of the Rand buffer. - -+ @retval EFI_SUCCESS on success -+ @retval others on error -+ - **/ --VOID -+EFI_STATUS - IScsiGenRandom ( - IN OUT UINT8 *Rand, - IN UINTN RandLength -diff --git a/NetworkPkg/Include/Library/NetLib.h b/NetworkPkg/Include/Library/NetLib.h -index 53495aa494..8c05e3da47 100644 ---- a/NetworkPkg/Include/Library/NetLib.h -+++ b/NetworkPkg/Include/Library/NetLib.h -@@ -3,6 +3,7 @@ - It provides basic functions for the UEFI network stack. - - Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -539,8 +540,6 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr; - #define TICKS_PER_MS 10000U - #define TICKS_PER_SECOND 10000000U - --#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL) -- - /** - Extract a UINT32 from a byte stream. - -@@ -580,19 +579,40 @@ NetPutUint32 ( - ); - - /** -- Initialize a random seed using current time and monotonic count. -+ Generate a Random output data given a length. - -- Get current time and monotonic count first. Then initialize a random seed -- based on some basic mathematics operation on the hour, day, minute, second, -- nanosecond and year of the current time and the monotonic count value. -+ @param[out] Output - The buffer to store the generated random data. -+ @param[in] OutputLength - The length of the output buffer. - -- @return The random seed initialized with current time. -+ @retval EFI_SUCCESS On Success -+ @retval EFI_INVALID_PARAMETER Pointer is null or size is zero -+ @retval EFI_NOT_FOUND RNG protocol not found -+ @retval Others Error from RngProtocol->GetRNG() - -+ @return Status code - **/ --UINT32 -+EFI_STATUS - EFIAPI --NetRandomInitSeed ( -- VOID -+PseudoRandom ( -+ OUT VOID *Output, -+ IN UINTN OutputLength -+ ); -+ -+/** -+ Generate a 32-bit pseudo-random number. -+ -+ @param[out] Output - The buffer to store the generated random number. -+ -+ @retval EFI_SUCCESS On Success -+ @retval EFI_NOT_FOUND RNG protocol not found -+ @retval Others Error from RngProtocol->GetRNG() -+ -+ @return Status code -+**/ -+EFI_STATUS -+EFIAPI -+PseudoRandomU32 ( -+ OUT UINT32 *Output - ); - - #define NET_LIST_USER_STRUCT(Entry, Type, Field) \ -diff --git a/NetworkPkg/Ip4Dxe/Ip4Driver.c b/NetworkPkg/Ip4Dxe/Ip4Driver.c -index ec483ff01f..683423f38d 100644 ---- a/NetworkPkg/Ip4Dxe/Ip4Driver.c -+++ b/NetworkPkg/Ip4Dxe/Ip4Driver.c -@@ -2,6 +2,7 @@ - The driver binding and service binding protocol for IP4 driver. - - Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- - SPDX-License-Identifier: BSD-2-Clause-Patent -@@ -549,11 +550,18 @@ Ip4DriverBindingStart ( - EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2; - UINTN Index; - IP4_CONFIG2_DATA_ITEM *DataItem; -+ UINT32 Random; - - IpSb = NULL; - Ip4Cfg2 = NULL; - DataItem = NULL; - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - // - // Test for the Ip4 service binding protocol - // -@@ -653,7 +661,7 @@ Ip4DriverBindingStart ( - // - // Initialize the IP4 ID - // -- mIp4Id = (UINT16)NET_RANDOM (NetRandomInitSeed ()); -+ mIp4Id = (UINT16)Random; - - return Status; - -diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c -index ab38013369..a79fc89821 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c -+++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c -@@ -2294,6 +2294,13 @@ Ip6ConfigInitInstance ( - UINTN Index; - UINT16 IfIndex; - IP6_CONFIG_DATA_ITEM *DataItem; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - IpSb = IP6_SERVICE_FROM_IP6_CONFIG_INSTANCE (Instance); - -@@ -2399,7 +2406,7 @@ Ip6ConfigInitInstance ( - // The NV variable is not set, so generate a random IAID, and write down the - // fresh new configuration as the NV variable now. - // -- Instance->IaId = NET_RANDOM (NetRandomInitSeed ()); -+ Instance->IaId = Random; - - for (Index = 0; Index < IpSb->SnpMode.HwAddressSize; Index++) { - Instance->IaId |= (IpSb->SnpMode.CurrentAddress.Addr[Index] << ((Index << 3) & 31)); -diff --git a/NetworkPkg/Ip6Dxe/Ip6Driver.c b/NetworkPkg/Ip6Dxe/Ip6Driver.c -index 7c13d6a3d4..b73fcb4828 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Driver.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Driver.c -@@ -3,7 +3,7 @@ - - Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -315,7 +315,11 @@ Ip6CreateService ( - IpSb->CurHopLimit = IP6_HOP_LIMIT; - IpSb->LinkMTU = IP6_MIN_LINK_MTU; - IpSb->BaseReachableTime = IP6_REACHABLE_TIME; -- Ip6UpdateReachableTime (IpSb); -+ Status = Ip6UpdateReachableTime (IpSb); -+ if (EFI_ERROR (Status)) { -+ goto ON_ERROR; -+ } -+ - // - // RFC4861 RETRANS_TIMER: 1,000 milliseconds - // -@@ -515,11 +519,18 @@ Ip6DriverBindingStart ( - EFI_STATUS Status; - EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg; - IP6_CONFIG_DATA_ITEM *DataItem; -+ UINT32 Random; - - IpSb = NULL; - Ip6Cfg = NULL; - DataItem = NULL; - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - // - // Test for the Ip6 service binding protocol - // -@@ -655,7 +666,7 @@ Ip6DriverBindingStart ( - // - // Initialize the IP6 ID - // -- mIp6Id = NET_RANDOM (NetRandomInitSeed ()); -+ mIp6Id = Random; - - return EFI_SUCCESS; - -diff --git a/NetworkPkg/Ip6Dxe/Ip6If.c b/NetworkPkg/Ip6Dxe/Ip6If.c -index 4629c05f25..f3d11c4d21 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6If.c -+++ b/NetworkPkg/Ip6Dxe/Ip6If.c -@@ -2,7 +2,7 @@ - Implement IP6 pseudo interface. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -89,6 +89,14 @@ Ip6SetAddress ( - IP6_PREFIX_LIST_ENTRY *PrefixEntry; - UINT64 Delay; - IP6_DELAY_JOIN_LIST *DelayNode; -+ EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - NET_CHECK_SIGNATURE (Interface, IP6_INTERFACE_SIGNATURE); - -@@ -164,7 +172,7 @@ Ip6SetAddress ( - // Thus queue the address to be processed in Duplicate Address Detection module - // after the delay time (in milliseconds). - // -- Delay = (UINT64)NET_RANDOM (NetRandomInitSeed ()); -+ Delay = (UINT64)Random; - Delay = MultU64x32 (Delay, IP6_ONE_SECOND_IN_MS); - Delay = RShiftU64 (Delay, 32); - -diff --git a/NetworkPkg/Ip6Dxe/Ip6Mld.c b/NetworkPkg/Ip6Dxe/Ip6Mld.c -index e6b2b653e2..498a118543 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Mld.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Mld.c -@@ -696,7 +696,15 @@ Ip6UpdateDelayTimer ( - IN OUT IP6_MLD_GROUP *Group - ) - { -- UINT32 Delay; -+ UINT32 Delay; -+ EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - // - // If the Query packet specifies a Maximum Response Delay of zero, perform timer -@@ -715,7 +723,7 @@ Ip6UpdateDelayTimer ( - // is less than the remaining value of the running timer. - // - if ((Group->DelayTimer == 0) || (Delay < Group->DelayTimer)) { -- Group->DelayTimer = Delay / 4294967295UL * NET_RANDOM (NetRandomInitSeed ()); -+ Group->DelayTimer = Delay / 4294967295UL * Random; - } - - return EFI_SUCCESS; -diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c -index c10c7017f8..72aa45c10f 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Nd.c -+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c -@@ -2,7 +2,7 @@ - Implementation of Neighbor Discovery support routines. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -16,17 +16,28 @@ EFI_MAC_ADDRESS mZeroMacAddress; - - @param[in, out] IpSb Points to the IP6_SERVICE. - -+ @retval EFI_SUCCESS ReachableTime Updated -+ @retval others Failed to update ReachableTime - **/ --VOID -+EFI_STATUS - Ip6UpdateReachableTime ( - IN OUT IP6_SERVICE *IpSb - ) - { -- UINT32 Random; -+ UINT32 Random; -+ EFI_STATUS Status; - -- Random = (NetRandomInitSeed () / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE; -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ -+ Random = (Random / 4294967295UL) * IP6_RANDOM_FACTOR_SCALE; - Random = Random + IP6_MIN_RANDOM_FACTOR_SCALED; - IpSb->ReachableTime = (IpSb->BaseReachableTime * Random) / IP6_RANDOM_FACTOR_SCALE; -+ -+ return EFI_SUCCESS; - } - - /** -@@ -972,10 +983,17 @@ Ip6InitDADProcess ( - IP6_SERVICE *IpSb; - EFI_STATUS Status; - UINT32 MaxDelayTick; -+ UINT32 Random; - - NET_CHECK_SIGNATURE (IpIf, IP6_INTERFACE_SIGNATURE); - ASSERT (AddressInfo != NULL); - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - // - // Do nothing if we have already started DAD on the address. - // -@@ -1014,7 +1032,7 @@ Ip6InitDADProcess ( - Entry->Transmit = 0; - Entry->Receive = 0; - MaxDelayTick = IP6_MAX_RTR_SOLICITATION_DELAY / IP6_TIMER_INTERVAL_IN_MS; -- Entry->RetransTick = (MaxDelayTick * ((NET_RANDOM (NetRandomInitSeed ()) % 5) + 1)) / 5; -+ Entry->RetransTick = (MaxDelayTick * ((Random % 5) + 1)) / 5; - Entry->AddressInfo = AddressInfo; - Entry->Callback = Callback; - Entry->Context = Context; -@@ -2078,7 +2096,10 @@ Ip6ProcessRouterAdvertise ( - // in BaseReachableTime and recompute a ReachableTime. - // - IpSb->BaseReachableTime = ReachableTime; -- Ip6UpdateReachableTime (IpSb); -+ Status = Ip6UpdateReachableTime (IpSb); -+ if (EFI_ERROR (Status)) { -+ goto Exit; -+ } - } - - if (RetransTimer != 0) { -diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.h b/NetworkPkg/Ip6Dxe/Ip6Nd.h -index bf64e9114e..5795e23c7d 100644 ---- a/NetworkPkg/Ip6Dxe/Ip6Nd.h -+++ b/NetworkPkg/Ip6Dxe/Ip6Nd.h -@@ -2,7 +2,7 @@ - Definition of Neighbor Discovery support routines. - - Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -780,10 +780,10 @@ Ip6OnArpResolved ( - /** - Update the ReachableTime in IP6 service binding instance data, in milliseconds. - -- @param[in, out] IpSb Points to the IP6_SERVICE. -- -+ @retval EFI_SUCCESS ReachableTime Updated -+ @retval others Failed to update ReachableTime - **/ --VOID -+EFI_STATUS - Ip6UpdateReachableTime ( - IN OUT IP6_SERVICE *IpSb - ); -diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -index 0428abdda0..0bc9aef8cd 100644 ---- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -+++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c -@@ -3,6 +3,7 @@ - - Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - -@@ -31,6 +32,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - #include -+#include - - #define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE) - #define DEFAULT_ZERO_START ((UINTN) ~0) -@@ -127,6 +129,25 @@ GLOBAL_REMOVE_IF_UNREFERENCED VLAN_DEVICE_PATH mNetVlanDevicePathTemplate = { - 0 - }; - -+// -+// These represent UEFI SPEC defined algorithms that should be supported by -+// the RNG protocol and are generally considered secure. -+// -+// The order of the algorithms in this array is important. This order is the order -+// in which the algorithms will be tried by the RNG protocol. -+// If your platform needs to use a specific algorithm for the random number generator, -+// then you should place that algorithm first in the array. -+// -+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID *mSecureHashAlgorithms[] = { -+ &gEfiRngAlgorithmSp80090Ctr256Guid, // SP800-90A DRBG CTR using AES-256 -+ &gEfiRngAlgorithmSp80090Hmac256Guid, // SP800-90A DRBG HMAC using SHA-256 -+ &gEfiRngAlgorithmSp80090Hash256Guid, // SP800-90A DRBG Hash using SHA-256 -+ &gEfiRngAlgorithmArmRndr, // unspecified SP800-90A DRBG via ARM RNDR register -+ &gEfiRngAlgorithmRaw, // Raw data from NRBG (or TRNG) -+}; -+ -+#define SECURE_HASH_ALGORITHMS_SIZE (sizeof (mSecureHashAlgorithms) / sizeof (EFI_GUID *)) -+ - /** - Locate the handles that support SNP, then open one of them - to send the syslog packets. The caller isn't required to close -@@ -884,34 +905,107 @@ Ip6Swap128 ( - } - - /** -- Initialize a random seed using current time and monotonic count. -+ Generate a Random output data given a length. - -- Get current time and monotonic count first. Then initialize a random seed -- based on some basic mathematics operation on the hour, day, minute, second, -- nanosecond and year of the current time and the monotonic count value. -+ @param[out] Output - The buffer to store the generated random data. -+ @param[in] OutputLength - The length of the output buffer. - -- @return The random seed initialized with current time. -+ @retval EFI_SUCCESS On Success -+ @retval EFI_INVALID_PARAMETER Pointer is null or size is zero -+ @retval EFI_NOT_FOUND RNG protocol not found -+ @retval Others Error from RngProtocol->GetRNG() - -+ @return Status code - **/ --UINT32 -+EFI_STATUS - EFIAPI --NetRandomInitSeed ( -- VOID -+PseudoRandom ( -+ OUT VOID *Output, -+ IN UINTN OutputLength - ) - { -- EFI_TIME Time; -- UINT32 Seed; -- UINT64 MonotonicCount; -+ EFI_RNG_PROTOCOL *RngProtocol; -+ EFI_STATUS Status; -+ UINTN AlgorithmIndex; -+ -+ if ((Output == NULL) || (OutputLength == 0)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Failed to locate EFI_RNG_PROTOCOL: %r\n", Status)); -+ ASSERT_EFI_ERROR (Status); -+ return Status; -+ } -+ -+ if (PcdGetBool (PcdEnforceSecureRngAlgorithms)) { -+ for (AlgorithmIndex = 0; AlgorithmIndex < SECURE_HASH_ALGORITHMS_SIZE; AlgorithmIndex++) { -+ Status = RngProtocol->GetRNG (RngProtocol, mSecureHashAlgorithms[AlgorithmIndex], OutputLength, (UINT8 *)Output); -+ if (!EFI_ERROR (Status)) { -+ // -+ // Secure Algorithm was supported on this platform -+ // -+ return EFI_SUCCESS; -+ } else if (Status == EFI_UNSUPPORTED) { -+ // -+ // Secure Algorithm was not supported on this platform -+ // -+ DEBUG ((DEBUG_ERROR, "Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); -+ -+ // -+ // Try the next secure algorithm -+ // -+ continue; -+ } else { -+ // -+ // Some other error occurred -+ // -+ DEBUG ((DEBUG_ERROR, "Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); -+ ASSERT_EFI_ERROR (Status); -+ return Status; -+ } -+ } -+ -+ // -+ // If we get here, we failed to generate random data using any secure algorithm -+ // Platform owner should ensure that at least one secure algorithm is supported -+ // -+ ASSERT_EFI_ERROR (Status); -+ return Status; -+ } -+ -+ // -+ // Lets try using the default algorithm (which may not be secure) -+ // -+ Status = RngProtocol->GetRNG (RngProtocol, NULL, OutputLength, (UINT8 *)Output); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random data: %r\n", __func__, Status)); -+ ASSERT_EFI_ERROR (Status); -+ return Status; -+ } - -- gRT->GetTime (&Time, NULL); -- Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); -- Seed ^= Time.Nanosecond; -- Seed ^= Time.Year << 7; -+ return EFI_SUCCESS; -+} -+ -+/** -+ Generate a 32-bit pseudo-random number. - -- gBS->GetNextMonotonicCount (&MonotonicCount); -- Seed += (UINT32)MonotonicCount; -+ @param[out] Output - The buffer to store the generated random number. - -- return Seed; -+ @retval EFI_SUCCESS On Success -+ @retval EFI_NOT_FOUND RNG protocol not found -+ @retval Others Error from RngProtocol->GetRNG() -+ -+ @return Status code -+**/ -+EFI_STATUS -+EFIAPI -+PseudoRandomU32 ( -+ OUT UINT32 *Output -+ ) -+{ -+ return PseudoRandom (Output, sizeof (*Output)); - } - - /** -diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.inf b/NetworkPkg/Library/DxeNetLib/DxeNetLib.inf -index 8145d256ec..a8f534a293 100644 ---- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.inf -+++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.inf -@@ -3,6 +3,7 @@ - # - # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
- # (C) Copyright 2015 Hewlett Packard Enterprise Development LP
-+# Copyright (c) Microsoft Corporation - # SPDX-License-Identifier: BSD-2-Clause-Patent - # - ## -@@ -49,7 +50,11 @@ - gEfiSmbiosTableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiSmbios3TableGuid ## SOMETIMES_CONSUMES ## SystemTable - gEfiAdapterInfoMediaStateGuid ## SOMETIMES_CONSUMES -- -+ gEfiRngAlgorithmRaw ## CONSUMES -+ gEfiRngAlgorithmSp80090Ctr256Guid ## CONSUMES -+ gEfiRngAlgorithmSp80090Hmac256Guid ## CONSUMES -+ gEfiRngAlgorithmSp80090Hash256Guid ## CONSUMES -+ gEfiRngAlgorithmArmRndr ## CONSUMES - - [Protocols] - gEfiSimpleNetworkProtocolGuid ## SOMETIMES_CONSUMES -@@ -59,3 +64,10 @@ - gEfiComponentNameProtocolGuid ## SOMETIMES_CONSUMES - gEfiComponentName2ProtocolGuid ## SOMETIMES_CONSUMES - gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES -+ gEfiRngProtocolGuid ## CONSUMES -+ -+[FixedPcd] -+ gEfiNetworkPkgTokenSpaceGuid.PcdEnforceSecureRngAlgorithms ## CONSUMES -+ -+[Depex] -+ gEfiRngProtocolGuid -diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec -index 928e84fec4..ff335e957c 100644 ---- a/NetworkPkg/NetworkPkg.dec -+++ b/NetworkPkg/NetworkPkg.dec -@@ -5,6 +5,7 @@ - # - # Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
- # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
-+# Copyright (c) Microsoft Corporation - # - # SPDX-License-Identifier: BSD-2-Clause-Patent - # -@@ -127,6 +128,12 @@ - # @Prompt Indicates whether SnpDxe creates event for ExitBootServices() call. - gEfiNetworkPkgTokenSpaceGuid.PcdSnpCreateExitBootServicesEvent|TRUE|BOOLEAN|0x1000000C - -+ ## Enforces the use of Secure UEFI spec defined RNG algorithms for all network connections. -+ # TRUE - Enforce the use of Secure UEFI spec defined RNG algorithms. -+ # FALSE - Do not enforce and depend on the default implementation of RNG algorithm from the provider. -+ # @Prompt Enforce the use of Secure UEFI spec defined RNG algorithms. -+ gEfiNetworkPkgTokenSpaceGuid.PcdEnforceSecureRngAlgorithms|TRUE|BOOLEAN|0x1000000D -+ - [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] - ## IPv6 DHCP Unique Identifier (DUID) Type configuration (From RFCs 3315 and 6355). - # 01 = DUID Based on Link-layer Address Plus Time [DUID-LLT] -diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c -index 8a75b4b55b..430911c2f4 100644 ---- a/NetworkPkg/TcpDxe/TcpDriver.c -+++ b/NetworkPkg/TcpDxe/TcpDriver.c -@@ -2,7 +2,7 @@ - The driver binding and service binding protocol for the TCP driver. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -163,7 +163,13 @@ TcpDriverEntryPoint ( - ) - { - EFI_STATUS Status; -- UINT32 Seed; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a Failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - // - // Install the TCP Driver Binding Protocol -@@ -203,9 +209,8 @@ TcpDriverEntryPoint ( - // - // Initialize ISS and random port. - // -- Seed = NetRandomInitSeed (); -- mTcpGlobalIss = NET_RANDOM (Seed) % mTcpGlobalIss; -- mTcp4RandomPort = (UINT16)(TCP_PORT_KNOWN + (NET_RANDOM (Seed) % TCP_PORT_KNOWN)); -+ mTcpGlobalIss = Random % mTcpGlobalIss; -+ mTcp4RandomPort = (UINT16)(TCP_PORT_KNOWN + (Random % TCP_PORT_KNOWN)); - mTcp6RandomPort = mTcp4RandomPort; - - return EFI_SUCCESS; -diff --git a/NetworkPkg/TcpDxe/TcpDxe.inf b/NetworkPkg/TcpDxe/TcpDxe.inf -index c0acbdca57..cf5423f4c5 100644 ---- a/NetworkPkg/TcpDxe/TcpDxe.inf -+++ b/NetworkPkg/TcpDxe/TcpDxe.inf -@@ -82,5 +82,8 @@ - gEfiTcp6ProtocolGuid ## BY_START - gEfiTcp6ServiceBindingProtocolGuid ## BY_START - -+[Depex] -+ gEfiHash2ServiceBindingProtocolGuid -+ - [UserExtensions.TianoCore."ExtraFiles"] - TcpDxeExtra.uni -diff --git a/NetworkPkg/Udp4Dxe/Udp4Driver.c b/NetworkPkg/Udp4Dxe/Udp4Driver.c -index cb917fcfc9..c7ea16f4cd 100644 ---- a/NetworkPkg/Udp4Dxe/Udp4Driver.c -+++ b/NetworkPkg/Udp4Dxe/Udp4Driver.c -@@ -1,6 +1,7 @@ - /** @file - - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
-+Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -555,6 +556,13 @@ Udp4DriverEntryPoint ( - ) - { - EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - // - // Install the Udp4DriverBinding and Udp4ComponentName protocols. -@@ -571,7 +579,7 @@ Udp4DriverEntryPoint ( - // - // Initialize the UDP random port. - // -- mUdp4RandomPort = (UINT16)(((UINT16)NetRandomInitSeed ()) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN); -+ mUdp4RandomPort = (UINT16)(((UINT16)Random) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN); - } - - return Status; -diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Driver.c -index ae96fb9966..edb758d57c 100644 ---- a/NetworkPkg/Udp6Dxe/Udp6Driver.c -+++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c -@@ -2,7 +2,7 @@ - Driver Binding functions and Service Binding functions for the Network driver module. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -596,6 +596,13 @@ Udp6DriverEntryPoint ( - ) - { - EFI_STATUS Status; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } - - // - // Install the Udp6DriverBinding and Udp6ComponentName protocols. -@@ -614,7 +621,7 @@ Udp6DriverEntryPoint ( - // Initialize the UDP random port. - // - mUdp6RandomPort = (UINT16)( -- ((UINT16)NetRandomInitSeed ()) % -+ ((UINT16)Random) % - UDP6_PORT_KNOWN + - UDP6_PORT_KNOWN - ); -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -index 874fc2c37b..5f13352566 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c -@@ -2,7 +2,7 @@ - Functions implementation related with DHCPv4 for UefiPxeBc Driver. - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -1381,6 +1381,12 @@ PxeBcDhcp4Discover ( - UINT8 VendorOptLen; - UINT32 Xid; - -+ Status = PseudoRandomU32 (&Xid); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - Mode = Private->PxeBc.Mode; - Dhcp4 = Private->Dhcp4; - Status = EFI_SUCCESS; -@@ -1470,7 +1476,6 @@ PxeBcDhcp4Discover ( - // - // Set fields of the token for the request packet. - // -- Xid = NET_RANDOM (NetRandomInitSeed ()); - Token.Packet->Dhcp4.Header.Xid = HTONL (Xid); - Token.Packet->Dhcp4.Header.Reserved = HTONS ((UINT16) ((IsBCast) ? 0x8000 : 0x0)); - CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS)); -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -index 7fd1281c11..bcabbd2219 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -@@ -2180,7 +2180,7 @@ PxeBcDhcp6Discover ( - UINTN ReadSize; - UINT16 OpCode; - UINT16 OpLen; -- UINT32 Xid; -+ UINT32 Random; - EFI_STATUS Status; - UINTN DiscoverLenNeeded; - -@@ -2198,6 +2198,12 @@ PxeBcDhcp6Discover ( - return EFI_DEVICE_ERROR; - } - -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ - DiscoverLenNeeded = sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET); - Discover = AllocateZeroPool (DiscoverLenNeeded); - if (Discover == NULL) { -@@ -2207,8 +2213,7 @@ PxeBcDhcp6Discover ( - // - // Build the discover packet by the cached request packet before. - // -- Xid = NET_RANDOM (NetRandomInitSeed ()); -- Discover->TransactionId = HTONL (Xid); -+ Discover->TransactionId = HTONL (Random); - Discover->MessageType = Request->Dhcp6.Header.MessageType; - RequestOpt = Request->Dhcp6.Option; - DiscoverOpt = Discover->DhcpOptions; -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -index d84aca7e85..4cd915b411 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c -@@ -3,6 +3,7 @@ - - (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
-+ Copyright (c) Microsoft Corporation - - SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -892,6 +893,13 @@ PxeBcCreateIp6Children ( - PXEBC_PRIVATE_PROTOCOL *Id; - EFI_SIMPLE_NETWORK_PROTOCOL *Snp; - UINTN Index; -+ UINT32 Random; -+ -+ Status = PseudoRandomU32 (&Random); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Failed to generate random number using EFI_RNG_PROTOCOL: %r\n", Status)); -+ return Status; -+ } - - if (Private->Ip6Nic != NULL) { - // -@@ -935,9 +943,9 @@ PxeBcCreateIp6Children ( - } - - // -- // Generate a random IAID for the Dhcp6 assigned address. -+ // Set a random IAID for the Dhcp6 assigned address. - // -- Private->IaId = NET_RANDOM (NetRandomInitSeed ()); -+ Private->IaId = Random; - if (Private->Snp != NULL) { - for (Index = 0; Index < Private->Snp->Mode->HwAddressSize; Index++) { - Private->IaId |= (Private->Snp->Mode->CurrentAddress.Addr[Index] << ((Index << 3) & 31)); --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch b/SOURCES/edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch deleted file mode 100644 index ad2adac..0000000 --- a/SOURCES/edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 6eceae607639b46ea46ba26a288270bd1c97dc0f Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 13 Jun 2024 18:35:46 -0400 -Subject: [PATCH 31/31] NetworkPkg TcpDxe: Fixed system stuck on PXE boot flow - in iPXE environment -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [31/31] 2088a79fef3d6dfec032f2f560ccf87ae42d786f - -JIRA: https://issues.redhat.com/browse/RHEL-21854 -Upstream: Merged -CVE: CVE-2023-45236 - -commit ced13b93afea87a8a1fe6ddbb67240a84cb2e3d3 -Author: Sam -Date: Wed May 29 07:46:03 2024 +0800 - - NetworkPkg TcpDxe: Fixed system stuck on PXE boot flow in iPXE environment - - This bug fix is based on the following commit "NetworkPkg TcpDxe: SECURITY PATCH" - REF: 1904a64 - - Issue Description: - An "Invalid handle" error was detected during runtime when attempting to destroy a child instance of the hashing protocol. The problematic code segment was: - - NetworkPkg\TcpDxe\TcpDriver.c - Status = Hash2ServiceBinding->DestroyChild(Hash2ServiceBinding, ​&mHash2ServiceHandle); - - Root Cause Analysis: - The root cause of the error was the passing of an incorrect parameter type, a pointer to an EFI_HANDLE instead of an EFI_HANDLE itself, to the DestroyChild function. This mismatch resulted in the function receiving an invalid handle. - - Implemented Solution: - To resolve this issue, the function call was corrected to pass mHash2ServiceHandle directly: - - NetworkPkg\TcpDxe\TcpDriver.c - Status = Hash2ServiceBinding->DestroyChild(Hash2ServiceBinding, mHash2ServiceHandle); - - This modification ensures the correct handle type is used, effectively rectifying the "Invalid handle" error. - - Verification: - Testing has been conducted, confirming the efficacy of the fix. Additionally, the BIOS can boot into the OS in an iPXE environment. - - Cc: Doug Flick [MSFT] - - Signed-off-by: Sam Tsai [Wiwynn] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/TcpDxe/TcpDriver.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c -index 34ae838ae0..1aec292501 100644 ---- a/NetworkPkg/TcpDxe/TcpDriver.c -+++ b/NetworkPkg/TcpDxe/TcpDriver.c -@@ -509,7 +509,7 @@ TcpDestroyService ( - // - // Destroy the instance of the hashing protocol for this controller. - // -- Status = Hash2ServiceBinding->DestroyChild (Hash2ServiceBinding, &mHash2ServiceHandle); -+ Status = Hash2ServiceBinding->DestroyChild (Hash2ServiceBinding, mHash2ServiceHandle); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch b/SOURCES/edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch deleted file mode 100644 index a0c6ccf..0000000 --- a/SOURCES/edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch +++ /dev/null @@ -1,808 +0,0 @@ -From 1e7f4034ddc0896e16c981d4220a1178813b4e86 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 11 Jun 2024 15:20:29 -0400 -Subject: [PATCH 30/31] NetworkPkg TcpDxe: SECURITY PATCH CVE-2023-45236 - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [30/31] 9ae15a2abf1d9bd0a0df1ff73a88446b9eb33602 - -JIRA: https://issues.redhat.com/browse/RHEL-21854 -Upstream: Merged -CVE: CVE-2023-45236 -Conflicts: Didn't add new file NetworkPkg/SecurityFixes.yaml - -commit 1904a64bcc18199738e5be183d28887ac5d837d7 -Author: Doug Flick -Date: Wed May 8 22:56:29 2024 -0700 - - NetworkPkg TcpDxe: SECURITY PATCH CVE-2023-45236 - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4541 - REF: https://www.rfc-editor.org/rfc/rfc1948.txt - REF: https://www.rfc-editor.org/rfc/rfc6528.txt - REF: https://www.rfc-editor.org/rfc/rfc9293.txt - - Bug Overview: - PixieFail Bug #8 - CVE-2023-45236 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:N - CWE-200 Exposure of Sensitive Information to an Unauthorized Actor - - Updates TCP ISN generation to use a cryptographic hash of the - connection's identifying parameters and a secret key. - This prevents an attacker from guessing the ISN used for some other - connection. - - This is follows the guidance in RFC 1948, RFC 6528, and RFC 9293. - - RFC: 9293 Section 3.4.1. Initial Sequence Number Selection - - A TCP implementation MUST use the above type of "clock" for clock- - driven selection of initial sequence numbers (MUST-8), and SHOULD - generate its initial sequence numbers with the expression: - - ISN = M + F(localip, localport, remoteip, remoteport, secretkey) - - where M is the 4 microsecond timer, and F() is a pseudorandom - function (PRF) of the connection's identifying parameters ("localip, - localport, remoteip, remoteport") and a secret key ("secretkey") - (SHLD-1). F() MUST NOT be computable from the outside (MUST-9), or - an attacker could still guess at sequence numbers from the ISN used - for some other connection. The PRF could be implemented as a - cryptographic hash of the concatenation of the TCP connection - parameters and some secret data. For discussion of the selection of - a specific hash algorithm and management of the secret key data, - please see Section 3 of [42]. - - For each connection there is a send sequence number and a receive - sequence number. The initial send sequence number (ISS) is chosen by - the data sending TCP peer, and the initial receive sequence number - (IRS) is learned during the connection-establishing procedure. - - For a connection to be established or initialized, the two TCP peers - must synchronize on each other's initial sequence numbers. This is - done in an exchange of connection-establishing segments carrying a - control bit called "SYN" (for synchronize) and the initial sequence - numbers. As a shorthand, segments carrying the SYN bit are also - called "SYNs". Hence, the solution requires a suitable mechanism for - picking an initial sequence number and a slightly involved handshake - to exchange the ISNs. - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar ---- - NetworkPkg/TcpDxe/TcpDriver.c | 92 ++++++++++++- - NetworkPkg/TcpDxe/TcpDxe.inf | 8 +- - NetworkPkg/TcpDxe/TcpFunc.h | 23 ++-- - NetworkPkg/TcpDxe/TcpInput.c | 13 +- - NetworkPkg/TcpDxe/TcpMain.h | 59 ++++++-- - NetworkPkg/TcpDxe/TcpMisc.c | 244 ++++++++++++++++++++++++++++++++-- - NetworkPkg/TcpDxe/TcpTimer.c | 3 +- - 7 files changed, 394 insertions(+), 48 deletions(-) - -diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c -index 430911c2f4..34ae838ae0 100644 ---- a/NetworkPkg/TcpDxe/TcpDriver.c -+++ b/NetworkPkg/TcpDxe/TcpDriver.c -@@ -83,6 +83,12 @@ EFI_SERVICE_BINDING_PROTOCOL gTcpServiceBinding = { - TcpServiceBindingDestroyChild - }; - -+// -+// This is the handle for the Hash2ServiceBinding Protocol instance this driver produces -+// if the platform does not provide one. -+// -+EFI_HANDLE mHash2ServiceHandle = NULL; -+ - /** - Create and start the heartbeat timer for the TCP driver. - -@@ -165,6 +171,23 @@ TcpDriverEntryPoint ( - EFI_STATUS Status; - UINT32 Random; - -+ // -+ // Initialize the Secret used for hashing TCP sequence numbers -+ // -+ // Normally this should be regenerated periodically, but since -+ // this is only used for UEFI networking and not a general purpose -+ // operating system, it is not necessary to regenerate it. -+ // -+ Status = PseudoRandomU32 (&mTcpGlobalSecret); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a failed to generate random number: %r\n", __func__, Status)); -+ return Status; -+ } -+ -+ // -+ // Get a random number used to generate a random port number -+ // Intentionally not linking this to mTcpGlobalSecret to avoid leaking information about the secret -+ // - Status = PseudoRandomU32 (&Random); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a Failed to generate random number: %r\n", __func__, Status)); -@@ -207,9 +230,8 @@ TcpDriverEntryPoint ( - } - - // -- // Initialize ISS and random port. -+ // Initialize the random port. - // -- mTcpGlobalIss = Random % mTcpGlobalIss; - mTcp4RandomPort = (UINT16)(TCP_PORT_KNOWN + (Random % TCP_PORT_KNOWN)); - mTcp6RandomPort = mTcp4RandomPort; - -@@ -224,6 +246,8 @@ TcpDriverEntryPoint ( - @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. - - @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources. -+ @retval EFI_UNSUPPORTED Service Binding Protocols are unavailable. -+ @retval EFI_ALREADY_STARTED The TCP driver is already started on the controller. - @retval EFI_SUCCESS A new IP6 service binding private was created. - - **/ -@@ -234,11 +258,13 @@ TcpCreateService ( - IN UINT8 IpVersion - ) - { -- EFI_STATUS Status; -- EFI_GUID *IpServiceBindingGuid; -- EFI_GUID *TcpServiceBindingGuid; -- TCP_SERVICE_DATA *TcpServiceData; -- IP_IO_OPEN_DATA OpenData; -+ EFI_STATUS Status; -+ EFI_GUID *IpServiceBindingGuid; -+ EFI_GUID *TcpServiceBindingGuid; -+ TCP_SERVICE_DATA *TcpServiceData; -+ IP_IO_OPEN_DATA OpenData; -+ EFI_SERVICE_BINDING_PROTOCOL *Hash2ServiceBinding; -+ EFI_HASH2_PROTOCOL *Hash2Protocol; - - if (IpVersion == IP_VERSION_4) { - IpServiceBindingGuid = &gEfiIp4ServiceBindingProtocolGuid; -@@ -272,6 +298,33 @@ TcpCreateService ( - return EFI_UNSUPPORTED; - } - -+ Status = gBS->LocateProtocol (&gEfiHash2ProtocolGuid, NULL, (VOID **)&Hash2Protocol); -+ if (EFI_ERROR (Status)) { -+ // -+ // If we can't find the Hashing protocol, then we need to create one. -+ // -+ -+ // -+ // Platform is expected to publish the hash service binding protocol to support TCP. -+ // -+ Status = gBS->LocateProtocol ( -+ &gEfiHash2ServiceBindingProtocolGuid, -+ NULL, -+ (VOID **)&Hash2ServiceBinding -+ ); -+ if (EFI_ERROR (Status) || (Hash2ServiceBinding == NULL) || (Hash2ServiceBinding->CreateChild == NULL)) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ // -+ // Create an instance of the hash protocol for this controller. -+ // -+ Status = Hash2ServiceBinding->CreateChild (Hash2ServiceBinding, &mHash2ServiceHandle); -+ if (EFI_ERROR (Status)) { -+ return EFI_UNSUPPORTED; -+ } -+ } -+ - // - // Create the TCP service data. - // -@@ -423,6 +476,7 @@ TcpDestroyService ( - EFI_STATUS Status; - LIST_ENTRY *List; - TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; -+ EFI_SERVICE_BINDING_PROTOCOL *Hash2ServiceBinding; - - ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6)); - -@@ -439,6 +493,30 @@ TcpDestroyService ( - return EFI_SUCCESS; - } - -+ // -+ // Destroy the Hash2ServiceBinding instance if it is created by Tcp driver. -+ // -+ if (mHash2ServiceHandle != NULL) { -+ Status = gBS->LocateProtocol ( -+ &gEfiHash2ServiceBindingProtocolGuid, -+ NULL, -+ (VOID **)&Hash2ServiceBinding -+ ); -+ if (EFI_ERROR (Status) || (Hash2ServiceBinding == NULL) || (Hash2ServiceBinding->DestroyChild == NULL)) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ // -+ // Destroy the instance of the hashing protocol for this controller. -+ // -+ Status = Hash2ServiceBinding->DestroyChild (Hash2ServiceBinding, &mHash2ServiceHandle); -+ if (EFI_ERROR (Status)) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ mHash2ServiceHandle = NULL; -+ } -+ - Status = gBS->OpenProtocol ( - NicHandle, - ServiceBindingGuid, -diff --git a/NetworkPkg/TcpDxe/TcpDxe.inf b/NetworkPkg/TcpDxe/TcpDxe.inf -index cf5423f4c5..76de4cf9ec 100644 ---- a/NetworkPkg/TcpDxe/TcpDxe.inf -+++ b/NetworkPkg/TcpDxe/TcpDxe.inf -@@ -6,6 +6,7 @@ - # stack has been loaded in system. This driver supports both IPv4 and IPv6 network stack. - # - # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-+# Copyright (c) Microsoft Corporation - # - # SPDX-License-Identifier: BSD-2-Clause-Patent - # -@@ -68,7 +69,6 @@ - NetLib - IpIoLib - -- - [Protocols] - ## SOMETIMES_CONSUMES - ## SOMETIMES_PRODUCES -@@ -81,6 +81,12 @@ - gEfiIp6ServiceBindingProtocolGuid ## TO_START - gEfiTcp6ProtocolGuid ## BY_START - gEfiTcp6ServiceBindingProtocolGuid ## BY_START -+ gEfiHash2ProtocolGuid ## BY_START -+ gEfiHash2ServiceBindingProtocolGuid ## BY_START -+ -+[Guids] -+ gEfiHashAlgorithmMD5Guid ## CONSUMES -+ gEfiHashAlgorithmSha256Guid ## CONSUMES - - [Depex] - gEfiHash2ServiceBindingProtocolGuid -diff --git a/NetworkPkg/TcpDxe/TcpFunc.h b/NetworkPkg/TcpDxe/TcpFunc.h -index 05cd3c75dc..e578b8bb29 100644 ---- a/NetworkPkg/TcpDxe/TcpFunc.h -+++ b/NetworkPkg/TcpDxe/TcpFunc.h -@@ -2,7 +2,7 @@ - Declaration of external functions shared in TCP driver. - - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -36,8 +36,11 @@ VOID - - @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance. - -+ @retval EFI_SUCCESS The operation completed successfully -+ @retval others The underlying functions failed and could not complete the operation -+ - **/ --VOID -+EFI_STATUS - TcpInitTcbLocal ( - IN OUT TCP_CB *Tcb - ); -@@ -128,17 +131,6 @@ TcpCloneTcb ( - IN TCP_CB *Tcb - ); - --/** -- Compute an ISS to be used by a new connection. -- -- @return The result ISS. -- --**/ --TCP_SEQNO --TcpGetIss ( -- VOID -- ); -- - /** - Get the local mss. - -@@ -202,8 +194,11 @@ TcpFormatNetbuf ( - @param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a - connection. - -+ @retval EFI_SUCCESS The operation completed successfully -+ @retval others The underlying functions failed and could not complete the operation -+ - **/ --VOID -+EFI_STATUS - TcpOnAppConnect ( - IN OUT TCP_CB *Tcb - ); -diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c -index 5e6c8c54ca..c0656ccd7d 100644 ---- a/NetworkPkg/TcpDxe/TcpInput.c -+++ b/NetworkPkg/TcpDxe/TcpInput.c -@@ -759,6 +759,7 @@ TcpInput ( - TCP_SEQNO Urg; - UINT16 Checksum; - INT32 Usable; -+ EFI_STATUS Status; - - ASSERT ((Version == IP_VERSION_4) || (Version == IP_VERSION_6)); - -@@ -908,7 +909,17 @@ TcpInput ( - Tcb->LocalEnd.Port = Head->DstPort; - Tcb->RemoteEnd.Port = Head->SrcPort; - -- TcpInitTcbLocal (Tcb); -+ Status = TcpInitTcbLocal (Tcb); -+ if (EFI_ERROR (Status)) { -+ DEBUG ( -+ (DEBUG_ERROR, -+ "TcpInput: discard a segment because failed to init local end for TCB %p\n", -+ Tcb) -+ ); -+ -+ goto DISCARD; -+ } -+ - TcpInitTcbPeer (Tcb, Seg, &Option); - - TcpSetState (Tcb, TCP_SYN_RCVD); -diff --git a/NetworkPkg/TcpDxe/TcpMain.h b/NetworkPkg/TcpDxe/TcpMain.h -index 0709298bbf..3fa572d3d4 100644 ---- a/NetworkPkg/TcpDxe/TcpMain.h -+++ b/NetworkPkg/TcpDxe/TcpMain.h -@@ -3,6 +3,7 @@ - It is the common head file for all Tcp*.c in TCP driver. - - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
-+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -12,6 +13,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -30,7 +32,7 @@ extern EFI_UNICODE_STRING_TABLE *gTcpControllerNameTable; - - extern LIST_ENTRY mTcpRunQue; - extern LIST_ENTRY mTcpListenQue; --extern TCP_SEQNO mTcpGlobalIss; -+extern TCP_SEQNO mTcpGlobalSecret; - extern UINT32 mTcpTick; - - /// -@@ -44,15 +46,6 @@ extern UINT32 mTcpTick; - - #define TCP_EXPIRE_TIME 65535 - --/// --/// The implementation selects the initial send sequence number and the unit to --/// be added when it is increased. --/// --#define TCP_BASE_ISS 0x4d7e980b --#define TCP_ISS_INCREMENT_1 2048 --#define TCP_ISS_INCREMENT_2 100 -- -- - typedef union { - EFI_TCP4_CONFIG_DATA Tcp4CfgData; - EFI_TCP6_CONFIG_DATA Tcp6CfgData; -@@ -774,4 +767,50 @@ Tcp6Poll ( - IN EFI_TCP6_PROTOCOL *This - ); - -+/** -+ Retrieves the Initial Sequence Number (ISN) for a TCP connection identified by local -+ and remote IP addresses and ports. -+ -+ This method is based on https://datatracker.ietf.org/doc/html/rfc9293#section-3.4.1 -+ Where the ISN is computed as follows: -+ ISN = TimeStamp + MD5(LocalIP, LocalPort, RemoteIP, RemotePort, Secret) -+ -+ Otherwise: -+ ISN = M + F(localip, localport, remoteip, remoteport, secretkey) -+ -+ "Here M is the 4 microsecond timer, and F() is a pseudorandom function (PRF) of the -+ connection's identifying parameters ("localip, localport, remoteip, remoteport") -+ and a secret key ("secretkey") (SHLD-1). F() MUST NOT be computable from the -+ outside (MUST-9), or an attacker could still guess at sequence numbers from the -+ ISN used for some other connection. The PRF could be implemented as a -+ cryptographic hash of the concatenation of the TCP connection parameters and some -+ secret data. For discussion of the selection of a specific hash algorithm and -+ management of the secret key data." -+ -+ @param[in] LocalIp A pointer to the local IP address of the TCP connection. -+ @param[in] LocalIpSize The size, in bytes, of the LocalIp buffer. -+ @param[in] LocalPort The local port number of the TCP connection. -+ @param[in] RemoteIp A pointer to the remote IP address of the TCP connection. -+ @param[in] RemoteIpSize The size, in bytes, of the RemoteIp buffer. -+ @param[in] RemotePort The remote port number of the TCP connection. -+ @param[out] Isn A pointer to the variable that will receive the Initial -+ Sequence Number (ISN). -+ -+ @retval EFI_SUCCESS The operation completed successfully, and the ISN was -+ retrieved. -+ @retval EFI_INVALID_PARAMETER One or more of the input parameters are invalid. -+ @retval EFI_UNSUPPORTED The operation is not supported. -+ -+**/ -+EFI_STATUS -+TcpGetIsn ( -+ IN UINT8 *LocalIp, -+ IN UINTN LocalIpSize, -+ IN UINT16 LocalPort, -+ IN UINT8 *RemoteIp, -+ IN UINTN RemoteIpSize, -+ IN UINT16 RemotePort, -+ OUT TCP_SEQNO *Isn -+ ); -+ - #endif -diff --git a/NetworkPkg/TcpDxe/TcpMisc.c b/NetworkPkg/TcpDxe/TcpMisc.c -index 3fa9d90d9f..42dc9fa941 100644 ---- a/NetworkPkg/TcpDxe/TcpMisc.c -+++ b/NetworkPkg/TcpDxe/TcpMisc.c -@@ -3,6 +3,7 @@ - - (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -19,7 +20,34 @@ LIST_ENTRY mTcpListenQue = { - &mTcpListenQue - }; - --TCP_SEQNO mTcpGlobalIss = TCP_BASE_ISS; -+// -+// The Session secret -+// This must be initialized to a random value at boot time -+// -+TCP_SEQNO mTcpGlobalSecret; -+ -+// -+// Union to hold either an IPv4 or IPv6 address -+// This is used to simplify the ISN hash computation -+// -+typedef union { -+ UINT8 IPv4[4]; -+ UINT8 IPv6[16]; -+} NETWORK_ADDRESS; -+ -+// -+// The ISN is computed by hashing this structure -+// It is initialized with the local and remote IP addresses and ports -+// and the secret -+// -+// -+typedef struct { -+ UINT16 LocalPort; -+ UINT16 RemotePort; -+ NETWORK_ADDRESS LocalAddress; -+ NETWORK_ADDRESS RemoteAddress; -+ TCP_SEQNO Secret; -+} ISN_HASH_CTX; - - CHAR16 *mTcpStateName[] = { - L"TCP_CLOSED", -@@ -40,12 +68,18 @@ CHAR16 *mTcpStateName[] = { - - @param[in, out] Tcb Pointer to the TCP_CB of this TCP instance. - -+ @retval EFI_SUCCESS The operation completed successfully -+ @retval others The underlying functions failed and could not complete the operation -+ - **/ --VOID -+EFI_STATUS - TcpInitTcbLocal ( - IN OUT TCP_CB *Tcb - ) - { -+ TCP_SEQNO Isn; -+ EFI_STATUS Status; -+ - // - // Compute the checksum of the fixed parts of pseudo header - // -@@ -56,6 +90,16 @@ TcpInitTcbLocal ( - 0x06, - 0 - ); -+ -+ Status = TcpGetIsn ( -+ Tcb->LocalEnd.Ip.v4.Addr, -+ sizeof (IPv4_ADDRESS), -+ Tcb->LocalEnd.Port, -+ Tcb->RemoteEnd.Ip.v4.Addr, -+ sizeof (IPv4_ADDRESS), -+ Tcb->RemoteEnd.Port, -+ &Isn -+ ); - } else { - Tcb->HeadSum = NetIp6PseudoHeadChecksum ( - &Tcb->LocalEnd.Ip.v6, -@@ -63,9 +107,25 @@ TcpInitTcbLocal ( - 0x06, - 0 - ); -+ -+ Status = TcpGetIsn ( -+ Tcb->LocalEnd.Ip.v6.Addr, -+ sizeof (IPv6_ADDRESS), -+ Tcb->LocalEnd.Port, -+ Tcb->RemoteEnd.Ip.v6.Addr, -+ sizeof (IPv6_ADDRESS), -+ Tcb->RemoteEnd.Port, -+ &Isn -+ ); -+ } -+ -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "TcpInitTcbLocal: failed to get isn\n")); -+ ASSERT (FALSE); -+ return Status; - } - -- Tcb->Iss = TcpGetIss (); -+ Tcb->Iss = Isn; - Tcb->SndUna = Tcb->Iss; - Tcb->SndNxt = Tcb->Iss; - -@@ -81,6 +141,8 @@ TcpInitTcbLocal ( - Tcb->RetxmitSeqMax = 0; - - Tcb->ProbeTimerOn = FALSE; -+ -+ return EFI_SUCCESS; - } - - /** -@@ -505,18 +567,162 @@ TcpCloneTcb ( - } - - /** -- Compute an ISS to be used by a new connection. -- -- @return The resulting ISS. -+ Retrieves the Initial Sequence Number (ISN) for a TCP connection identified by local -+ and remote IP addresses and ports. -+ -+ This method is based on https://datatracker.ietf.org/doc/html/rfc9293#section-3.4.1 -+ Where the ISN is computed as follows: -+ ISN = TimeStamp + MD5(LocalIP, LocalPort, RemoteIP, RemotePort, Secret) -+ -+ Otherwise: -+ ISN = M + F(localip, localport, remoteip, remoteport, secretkey) -+ -+ "Here M is the 4 microsecond timer, and F() is a pseudorandom function (PRF) of the -+ connection's identifying parameters ("localip, localport, remoteip, remoteport") -+ and a secret key ("secretkey") (SHLD-1). F() MUST NOT be computable from the -+ outside (MUST-9), or an attacker could still guess at sequence numbers from the -+ ISN used for some other connection. The PRF could be implemented as a -+ cryptographic hash of the concatenation of the TCP connection parameters and some -+ secret data. For discussion of the selection of a specific hash algorithm and -+ management of the secret key data." -+ -+ @param[in] LocalIp A pointer to the local IP address of the TCP connection. -+ @param[in] LocalIpSize The size, in bytes, of the LocalIp buffer. -+ @param[in] LocalPort The local port number of the TCP connection. -+ @param[in] RemoteIp A pointer to the remote IP address of the TCP connection. -+ @param[in] RemoteIpSize The size, in bytes, of the RemoteIp buffer. -+ @param[in] RemotePort The remote port number of the TCP connection. -+ @param[out] Isn A pointer to the variable that will receive the Initial -+ Sequence Number (ISN). -+ -+ @retval EFI_SUCCESS The operation completed successfully, and the ISN was -+ retrieved. -+ @retval EFI_INVALID_PARAMETER One or more of the input parameters are invalid. -+ @retval EFI_UNSUPPORTED The operation is not supported. - - **/ --TCP_SEQNO --TcpGetIss ( -- VOID -+EFI_STATUS -+TcpGetIsn ( -+ IN UINT8 *LocalIp, -+ IN UINTN LocalIpSize, -+ IN UINT16 LocalPort, -+ IN UINT8 *RemoteIp, -+ IN UINTN RemoteIpSize, -+ IN UINT16 RemotePort, -+ OUT TCP_SEQNO *Isn - ) - { -- mTcpGlobalIss += TCP_ISS_INCREMENT_1; -- return mTcpGlobalIss; -+ EFI_STATUS Status; -+ EFI_HASH2_PROTOCOL *Hash2Protocol; -+ EFI_HASH2_OUTPUT HashResult; -+ ISN_HASH_CTX IsnHashCtx; -+ EFI_TIME TimeStamp; -+ -+ // -+ // Check that the ISN pointer is valid -+ // -+ if (Isn == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // The local ip may be a v4 or v6 address and may not be NULL -+ // -+ if ((LocalIp == NULL) || (LocalIpSize == 0) || (RemoteIp == NULL) || (RemoteIpSize == 0)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // the local ip may be a v4 or v6 address -+ // -+ if ((LocalIpSize != sizeof (EFI_IPv4_ADDRESS)) && (LocalIpSize != sizeof (EFI_IPv6_ADDRESS))) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Locate the Hash Protocol -+ // -+ Status = gBS->LocateProtocol (&gEfiHash2ProtocolGuid, NULL, (VOID **)&Hash2Protocol); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_NET, "Failed to locate Hash Protocol: %r\n", Status)); -+ -+ // -+ // TcpCreateService(..) is expected to be called prior to this function -+ // -+ ASSERT_EFI_ERROR (Status); -+ return Status; -+ } -+ -+ // -+ // Initialize the hash algorithm -+ // -+ Status = Hash2Protocol->HashInit (Hash2Protocol, &gEfiHashAlgorithmSha256Guid); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_NET, "Failed to initialize sha256 hash algorithm: %r\n", Status)); -+ return Status; -+ } -+ -+ IsnHashCtx.LocalPort = LocalPort; -+ IsnHashCtx.RemotePort = RemotePort; -+ IsnHashCtx.Secret = mTcpGlobalSecret; -+ -+ // -+ // Check the IP address family and copy accordingly -+ // -+ if (LocalIpSize == sizeof (EFI_IPv4_ADDRESS)) { -+ CopyMem (&IsnHashCtx.LocalAddress.IPv4, LocalIp, LocalIpSize); -+ } else if (LocalIpSize == sizeof (EFI_IPv6_ADDRESS)) { -+ CopyMem (&IsnHashCtx.LocalAddress.IPv6, LocalIp, LocalIpSize); -+ } else { -+ return EFI_INVALID_PARAMETER; // Unsupported address size -+ } -+ -+ // -+ // Repeat the process for the remote IP address -+ // -+ if (RemoteIpSize == sizeof (EFI_IPv4_ADDRESS)) { -+ CopyMem (&IsnHashCtx.RemoteAddress.IPv4, RemoteIp, RemoteIpSize); -+ } else if (RemoteIpSize == sizeof (EFI_IPv6_ADDRESS)) { -+ CopyMem (&IsnHashCtx.RemoteAddress.IPv6, RemoteIp, RemoteIpSize); -+ } else { -+ return EFI_INVALID_PARAMETER; // Unsupported address size -+ } -+ -+ // -+ // Compute the hash -+ // Update the hash with the data -+ // -+ Status = Hash2Protocol->HashUpdate (Hash2Protocol, (UINT8 *)&IsnHashCtx, sizeof (IsnHashCtx)); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_NET, "Failed to update hash: %r\n", Status)); -+ return Status; -+ } -+ -+ // -+ // Finalize the hash and retrieve the result -+ // -+ Status = Hash2Protocol->HashFinal (Hash2Protocol, &HashResult); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_NET, "Failed to finalize hash: %r\n", Status)); -+ return Status; -+ } -+ -+ Status = gRT->GetTime (&TimeStamp, NULL); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ // -+ // copy the first 4 bytes of the hash result into the ISN -+ // -+ CopyMem (Isn, HashResult.Md5Hash, sizeof (*Isn)); -+ -+ // -+ // now add the timestamp to the ISN as 4 microseconds units (1000 / 4 = 250) -+ // -+ *Isn += (TCP_SEQNO)TimeStamp.Nanosecond * 250; -+ -+ return Status; - } - - /** -@@ -719,17 +925,29 @@ TcpFormatNetbuf ( - - @param[in, out] Tcb Pointer to the TCP_CB that wants to initiate a - connection. -+ -+ @retval EFI_SUCCESS The operation completed successfully -+ @retval others The underlying functions failed and could not complete the operation -+ - **/ --VOID -+EFI_STATUS - TcpOnAppConnect ( - IN OUT TCP_CB *Tcb - ) - { -- TcpInitTcbLocal (Tcb); -+ EFI_STATUS Status; -+ -+ Status = TcpInitTcbLocal (Tcb); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ - TcpSetState (Tcb, TCP_SYN_SENT); - - TcpSetTimer (Tcb, TCP_TIMER_CONNECT, Tcb->ConnectTimeout); - TcpToSendData (Tcb, 1); -+ -+ return EFI_SUCCESS; - } - - /** -diff --git a/NetworkPkg/TcpDxe/TcpTimer.c b/NetworkPkg/TcpDxe/TcpTimer.c -index 106d9470db..535d09d342 100644 ---- a/NetworkPkg/TcpDxe/TcpTimer.c -+++ b/NetworkPkg/TcpDxe/TcpTimer.c -@@ -2,7 +2,7 @@ - TCP timer related functions. - - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
-- -+ Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -@@ -497,7 +497,6 @@ TcpTickingDpc ( - INT16 Index; - - mTcpTick++; -- mTcpGlobalIss += TCP_ISS_INCREMENT_2; - - // - // Don't use LIST_FOR_EACH, which isn't delete safe. --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523.patch b/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523.patch deleted file mode 100644 index 8e6f603..0000000 --- a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 38baf93892ec464490b6fe611c23b014f574344b Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 07/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 - Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [7/15] c1baa0b2facbf0b63a90a0bfd55264af9f893098 - -JIRA: https://issues.redhat.com/browse/RHEL-21850 -CVE: CVE-2022-45234 -Upstream: Merged - -commit 1b53515d53d303166b2bbd31e2cc7f16fd0aecd7 -Author: Doug Flick -Date: Fri Jan 26 05:54:52 2024 +0800 - - NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 Patch - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4539 - - Bug Details: - PixieFail Bug #6 - CVE-2023-45234 - CVSS 8.3 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H - CWE-119 Improper Restriction of Operations within the Bounds of - a Memory Buffer - - Buffer overflow when processing DNS Servers option in a DHCPv6 - Advertise message - - Change Overview: - - Introduces a function to cache the Dns Server and perform sanitizing - on the incoming DnsServerLen to ensure that the length is valid - - > + EFI_STATUS - > + PxeBcCacheDnsServerAddresses ( - > + IN PXEBC_PRIVATE_DATA *Private, - > + IN PXEBC_DHCP6_PACKET_CACHE *Cache6 - > + ) - - Additional code cleanup - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 71 +++++++++++++++++++++++++--- - 1 file changed, 65 insertions(+), 6 deletions(-) - -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -index 425e0cf806..2b2d372889 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -@@ -3,6 +3,7 @@ - - (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-+ Copyright (c) Microsoft Corporation - - SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -1312,6 +1313,65 @@ PxeBcSelectDhcp6Offer ( - } - } - -+/** -+ Cache the DHCPv6 DNS Server addresses -+ -+ @param[in] Private The pointer to PXEBC_PRIVATE_DATA. -+ @param[in] Cache6 The pointer to PXEBC_DHCP6_PACKET_CACHE. -+ -+ @retval EFI_SUCCESS Cache the DHCPv6 DNS Server address successfully. -+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. -+ @retval EFI_DEVICE_ERROR The DNS Server Address Length provided by a untrusted -+ option is not a multiple of 16 bytes (sizeof (EFI_IPv6_ADDRESS)). -+**/ -+EFI_STATUS -+PxeBcCacheDnsServerAddresses ( -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN PXEBC_DHCP6_PACKET_CACHE *Cache6 -+ ) -+{ -+ UINT16 DnsServerLen; -+ -+ DnsServerLen = NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen); -+ // -+ // Make sure that the number is nonzero -+ // -+ if (DnsServerLen == 0) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // Make sure the DnsServerlen is a multiple of EFI_IPv6_ADDRESS (16) -+ // -+ if (DnsServerLen % sizeof (EFI_IPv6_ADDRESS) != 0) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // This code is currently written to only support a single DNS Server instead -+ // of multiple such as is spec defined (RFC3646, Section 3). The proper behavior -+ // would be to allocate the full space requested, CopyMem all of the data, -+ // and then add a DnsServerCount field to Private and update additional code -+ // that depends on this. -+ // -+ // To support multiple DNS servers the `AllocationSize` would need to be changed to DnsServerLen -+ // -+ // This is tracked in https://bugzilla.tianocore.org/show_bug.cgi?id=1886 -+ // -+ Private->DnsServer = AllocateZeroPool (sizeof (EFI_IPv6_ADDRESS)); -+ if (Private->DnsServer == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ // -+ // Intentionally only copy over the first server address. -+ // To support multiple DNS servers, the `Length` would need to be changed to DnsServerLen -+ // -+ CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); -+ -+ return EFI_SUCCESS; -+} -+ - /** - Handle the DHCPv6 offer packet. - -@@ -1335,6 +1395,7 @@ PxeBcHandleDhcp6Offer ( - UINT32 SelectIndex; - UINT32 Index; - -+ ASSERT (Private != NULL); - ASSERT (Private->SelectIndex > 0); - SelectIndex = (UINT32)(Private->SelectIndex - 1); - ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM); -@@ -1342,15 +1403,13 @@ PxeBcHandleDhcp6Offer ( - Status = EFI_SUCCESS; - - // -- // First try to cache DNS server address if DHCP6 offer provides. -+ // First try to cache DNS server addresses if DHCP6 offer provides. - // - if (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] != NULL) { -- Private->DnsServer = AllocateZeroPool (NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen)); -- if (Private->DnsServer == NULL) { -- return EFI_OUT_OF_RESOURCES; -+ Status = PxeBcCacheDnsServerAddresses (Private, Cache6); -+ if (EFI_ERROR (Status)) { -+ return Status; - } -- -- CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); - } - - if (Cache6->OfferType == PxeOfferTypeDhcpBinl) { --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p2.patch b/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p2.patch deleted file mode 100644 index aac0738..0000000 --- a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p2.patch +++ /dev/null @@ -1,511 +0,0 @@ -From fd1bc6ff10a45123b0ec7f9ae3354ad3713bc532 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 08/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 - Unit Tests - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [8/15] f88ebc7fa79ce4fe615dd79c42fedee0a0da7a0b - -JIRA: https://issues.redhat.com/browse/RHEL-21850 -CVE: CVE-2022-45234 -Upstream: Merged - -commit 458c582685fc0e8057d2511c5a0394078d988c17 -Author: Doug Flick -Date: Fri Jan 26 05:54:53 2024 +0800 - - NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45234 Unit Tests - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4539 - - Unit tests to that the bug.. - - Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise - message - - ..has been patched - - This contains tests for the following functions: - PxeBcHandleDhcp6Offer - PxeBcCacheDnsServerAddresses - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Test/NetworkPkgHostTest.dsc | 1 + - .../GoogleTest/PxeBcDhcp6GoogleTest.cpp | 300 ++++++++++++++++++ - .../GoogleTest/PxeBcDhcp6GoogleTest.h | 50 +++ - .../GoogleTest/UefiPxeBcDxeGoogleTest.cpp | 19 ++ - .../GoogleTest/UefiPxeBcDxeGoogleTest.inf | 48 +++ - 5 files changed, 418 insertions(+) - create mode 100644 NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp - create mode 100644 NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h - create mode 100644 NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.cpp - create mode 100644 NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf - -diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/NetworkPkgHostTest.dsc -index ab7c2857b6..c8a991e5c1 100644 ---- a/NetworkPkg/Test/NetworkPkgHostTest.dsc -+++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc -@@ -26,6 +26,7 @@ - # - NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf - NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -+ NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf - - # Despite these library classes being listed in [LibraryClasses] below, they are not needed for the host-based unit tests. - [LibraryClasses] -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp -new file mode 100644 -index 0000000000..8260eeee50 ---- /dev/null -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp -@@ -0,0 +1,300 @@ -+/** @file -+ Host based unit test for PxeBcDhcp6.c. -+ -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+extern "C" { -+ #include -+ #include -+ #include -+ #include "../PxeBcImpl.h" -+ #include "../PxeBcDhcp6.h" -+ #include "PxeBcDhcp6GoogleTest.h" -+} -+ -+/////////////////////////////////////////////////////////////////////////////// -+// Definitions -+/////////////////////////////////////////////////////////////////////////////// -+ -+#define PACKET_SIZE (1500) -+ -+typedef struct { -+ UINT16 OptionCode; // The option code for DHCP6_OPT_SERVER_ID (e.g., 0x03) -+ UINT16 OptionLen; // The length of the option (e.g., 16 bytes) -+ UINT8 ServerId[16]; // The 16-byte DHCPv6 Server Identifier -+} DHCP6_OPTION_SERVER_ID; -+ -+/////////////////////////////////////////////////////////////////////////////// -+/// Symbol Definitions -+/////////////////////////////////////////////////////////////////////////////// -+ -+EFI_STATUS -+MockUdpWrite ( -+ IN EFI_PXE_BASE_CODE_PROTOCOL *This, -+ IN UINT16 OpFlags, -+ IN EFI_IP_ADDRESS *DestIp, -+ IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, -+ IN EFI_IP_ADDRESS *GatewayIp OPTIONAL, -+ IN EFI_IP_ADDRESS *SrcIp OPTIONAL, -+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL, -+ IN UINTN *HeaderSize OPTIONAL, -+ IN VOID *HeaderPtr OPTIONAL, -+ IN UINTN *BufferSize, -+ IN VOID *BufferPtr -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+EFI_STATUS -+MockUdpRead ( -+ IN EFI_PXE_BASE_CODE_PROTOCOL *This, -+ IN UINT16 OpFlags, -+ IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL, -+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL, -+ IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL, -+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL, -+ IN UINTN *HeaderSize OPTIONAL, -+ IN VOID *HeaderPtr OPTIONAL, -+ IN OUT UINTN *BufferSize, -+ IN VOID *BufferPtr -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+EFI_STATUS -+MockConfigure ( -+ IN EFI_UDP6_PROTOCOL *This, -+ IN EFI_UDP6_CONFIG_DATA *UdpConfigData OPTIONAL -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+// Needed by PxeBcSupport -+EFI_STATUS -+EFIAPI -+QueueDpc ( -+ IN EFI_TPL DpcTpl, -+ IN EFI_DPC_PROCEDURE DpcProcedure, -+ IN VOID *DpcContext OPTIONAL -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+/////////////////////////////////////////////////////////////////////////////// -+// PxeBcHandleDhcp6OfferTest Tests -+/////////////////////////////////////////////////////////////////////////////// -+ -+class PxeBcHandleDhcp6OfferTest : public ::testing::Test { -+public: -+ PXEBC_PRIVATE_DATA Private = { 0 }; -+ EFI_UDP6_PROTOCOL Udp6Read; -+ EFI_PXE_BASE_CODE_MODE Mode = { 0 }; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ Private.Dhcp6Request = (EFI_DHCP6_PACKET *)AllocateZeroPool (PACKET_SIZE); -+ -+ // Need to setup the EFI_PXE_BASE_CODE_PROTOCOL -+ // The function under test really only needs the following: -+ // UdpWrite -+ // UdpRead -+ -+ Private.PxeBc.UdpWrite = (EFI_PXE_BASE_CODE_UDP_WRITE)MockUdpWrite; -+ Private.PxeBc.UdpRead = (EFI_PXE_BASE_CODE_UDP_READ)MockUdpRead; -+ -+ // Need to setup EFI_UDP6_PROTOCOL -+ // The function under test really only needs the following: -+ // Configure -+ -+ Udp6Read.Configure = (EFI_UDP6_CONFIGURE)MockConfigure; -+ Private.Udp6Read = &Udp6Read; -+ -+ // Need to setup the EFI_PXE_BASE_CODE_MODE -+ Private.PxeBc.Mode = &Mode; -+ -+ // for this test it doesn't really matter what the Dhcpv6 ack is set to -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ if (Private.Dhcp6Request != NULL) { -+ FreePool (Private.Dhcp6Request); -+ } -+ -+ // Clean up any resources or variables -+ } -+}; -+ -+// Note: -+// Testing PxeBcHandleDhcp6Offer() is difficult because it depends on a -+// properly setup Private structure. Attempting to properly test this function -+// without a signficant refactor is a fools errand. Instead, we will test -+// that we can prevent an overflow in the function. -+TEST_F (PxeBcHandleDhcp6OfferTest, BasicUsageTest) { -+ PXEBC_DHCP6_PACKET_CACHE *Cache6 = NULL; -+ EFI_DHCP6_PACKET_OPTION Option = { 0 }; -+ -+ Private.SelectIndex = 1; // SelectIndex is 1-based -+ Cache6 = &Private.OfferBuffer[Private.SelectIndex - 1].Dhcp6; -+ -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] = &Option; -+ // Setup the DHCPv6 offer packet -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpCode = DHCP6_OPT_SERVER_ID; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen = NTOHS (1337); -+ -+ ASSERT_EQ (PxeBcHandleDhcp6Offer (&(PxeBcHandleDhcp6OfferTest::Private)), EFI_DEVICE_ERROR); -+} -+ -+class PxeBcCacheDnsServerAddressesTest : public ::testing::Test { -+public: -+ PXEBC_PRIVATE_DATA Private = { 0 }; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ } -+}; -+ -+// Test Description -+// Test that we cache the DNS server address from the DHCPv6 offer packet -+TEST_F (PxeBcCacheDnsServerAddressesTest, BasicUsageTest) { -+ UINT8 SearchPattern[16] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF }; -+ EFI_DHCP6_PACKET_OPTION *Option; -+ PXEBC_DHCP6_PACKET_CACHE *Cache6 = NULL; -+ -+ Option = (EFI_DHCP6_PACKET_OPTION *)AllocateZeroPool (sizeof (EFI_DHCP6_PACKET_OPTION) + sizeof (SearchPattern)); -+ ASSERT_NE (Option, nullptr); -+ -+ Option->OpCode = DHCP6_OPT_SERVER_ID; -+ Option->OpLen = NTOHS (sizeof (SearchPattern)); -+ CopyMem (Option->Data, SearchPattern, sizeof (SearchPattern)); -+ -+ Private.SelectIndex = 1; // SelectIndex is 1-based -+ Cache6 = &Private.OfferBuffer[Private.SelectIndex - 1].Dhcp6; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] = Option; -+ -+ Private.DnsServer = nullptr; -+ -+ ASSERT_EQ (PxeBcCacheDnsServerAddresses (&(PxeBcCacheDnsServerAddressesTest::Private), Cache6), EFI_SUCCESS); -+ ASSERT_NE (Private.DnsServer, nullptr); -+ ASSERT_EQ (CompareMem (Private.DnsServer, SearchPattern, sizeof (SearchPattern)), 0); -+ -+ if (Private.DnsServer) { -+ FreePool (Private.DnsServer); -+ } -+ -+ if (Option) { -+ FreePool (Option); -+ } -+} -+// Test Description -+// Test that we can prevent an overflow in the function -+TEST_F (PxeBcCacheDnsServerAddressesTest, AttemptOverflowTest) { -+ EFI_DHCP6_PACKET_OPTION Option = { 0 }; -+ PXEBC_DHCP6_PACKET_CACHE *Cache6 = NULL; -+ -+ Private.SelectIndex = 1; // SelectIndex is 1-based -+ Cache6 = &Private.OfferBuffer[Private.SelectIndex - 1].Dhcp6; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] = &Option; -+ // Setup the DHCPv6 offer packet -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpCode = DHCP6_OPT_SERVER_ID; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen = NTOHS (1337); -+ -+ Private.DnsServer = NULL; -+ -+ ASSERT_EQ (PxeBcCacheDnsServerAddresses (&(PxeBcCacheDnsServerAddressesTest::Private), Cache6), EFI_DEVICE_ERROR); -+ ASSERT_EQ (Private.DnsServer, nullptr); -+ -+ if (Private.DnsServer) { -+ FreePool (Private.DnsServer); -+ } -+} -+ -+// Test Description -+// Test that we can prevent an underflow in the function -+TEST_F (PxeBcCacheDnsServerAddressesTest, AttemptUnderflowTest) { -+ EFI_DHCP6_PACKET_OPTION Option = { 0 }; -+ PXEBC_DHCP6_PACKET_CACHE *Cache6 = NULL; -+ -+ Private.SelectIndex = 1; // SelectIndex is 1-based -+ Cache6 = &Private.OfferBuffer[Private.SelectIndex - 1].Dhcp6; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] = &Option; -+ // Setup the DHCPv6 offer packet -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpCode = DHCP6_OPT_SERVER_ID; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen = NTOHS (2); -+ -+ Private.DnsServer = NULL; -+ -+ ASSERT_EQ (PxeBcCacheDnsServerAddresses (&(PxeBcCacheDnsServerAddressesTest::Private), Cache6), EFI_DEVICE_ERROR); -+ ASSERT_EQ (Private.DnsServer, nullptr); -+ -+ if (Private.DnsServer) { -+ FreePool (Private.DnsServer); -+ } -+} -+ -+// Test Description -+// Test that we can handle recursive dns (multiple dns entries) -+TEST_F (PxeBcCacheDnsServerAddressesTest, MultipleDnsEntries) { -+ EFI_DHCP6_PACKET_OPTION Option = { 0 }; -+ PXEBC_DHCP6_PACKET_CACHE *Cache6 = NULL; -+ -+ Private.SelectIndex = 1; // SelectIndex is 1-based -+ Cache6 = &Private.OfferBuffer[Private.SelectIndex - 1].Dhcp6; -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] = &Option; -+ // Setup the DHCPv6 offer packet -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpCode = DHCP6_OPT_SERVER_ID; -+ -+ EFI_IPv6_ADDRESS addresses[2] = { -+ // 2001:db8:85a3::8a2e:370:7334 -+ { 0x20, 0x01, 0x0d, 0xb8, 0x85, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x2e, 0x03, 0x70, 0x73, 0x34 }, -+ // fe80::d478:91c3:ecd7:4ff9 -+ { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x78, 0x91, 0xc3, 0xec, 0xd7, 0x4f, 0xf9 } -+ }; -+ -+ CopyMem (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, &addresses, sizeof (addresses)); -+ -+ Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen = NTOHS (sizeof (addresses)); -+ -+ Private.DnsServer = NULL; -+ -+ ASSERT_EQ (PxeBcCacheDnsServerAddresses (&(PxeBcCacheDnsServerAddressesTest::Private), Cache6), EFI_SUCCESS); -+ -+ ASSERT_NE (Private.DnsServer, nullptr); -+ -+ // -+ // This is expected to fail until DnsServer supports multiple DNS servers -+ // -+ // This is tracked in https://bugzilla.tianocore.org/show_bug.cgi?id=1886 -+ // -+ // Disabling: -+ // ASSERT_EQ (CompareMem(Private.DnsServer, &addresses, sizeof(addresses)), 0); -+ -+ if (Private.DnsServer) { -+ FreePool (Private.DnsServer); -+ } -+} -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h -new file mode 100644 -index 0000000000..b17c314791 ---- /dev/null -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h -@@ -0,0 +1,50 @@ -+/** @file -+ This file exposes the internal interfaces which may be unit tested -+ for the PxeBcDhcp6Dxe driver. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#ifndef PXE_BC_DHCP6_GOOGLE_TEST_H_ -+#define PXE_BC_DHCP6_GOOGLE_TEST_H_ -+ -+// -+// Minimal includes needed to compile -+// -+#include -+#include "../PxeBcImpl.h" -+ -+/** -+ Handle the DHCPv6 offer packet. -+ -+ @param[in] Private The pointer to PXEBC_PRIVATE_DATA. -+ -+ @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully. -+ @retval EFI_NO_RESPONSE No response to the following request packet. -+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. -+ @retval EFI_BUFFER_TOO_SMALL Can't cache the offer pacet. -+ -+**/ -+EFI_STATUS -+PxeBcHandleDhcp6Offer ( -+ IN PXEBC_PRIVATE_DATA *Private -+ ); -+ -+/** -+ Cache the DHCPv6 Server address -+ -+ @param[in] Private The pointer to PXEBC_PRIVATE_DATA. -+ @param[in] Cache6 The pointer to PXEBC_DHCP6_PACKET_CACHE. -+ -+ @retval EFI_SUCCESS Cache the DHCPv6 Server address successfully. -+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. -+ @retval EFI_DEVICE_ERROR Failed to cache the DHCPv6 Server address. -+**/ -+EFI_STATUS -+PxeBcCacheDnsServerAddresses ( -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN PXEBC_DHCP6_PACKET_CACHE *Cache6 -+ ); -+ -+#endif // PXE_BC_DHCP6_GOOGLE_TEST_H_ -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.cpp b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.cpp -new file mode 100644 -index 0000000000..cc4fdf525b ---- /dev/null -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.cpp -@@ -0,0 +1,19 @@ -+/** @file -+ Acts as the main entry point for the tests for the UefiPxeBcDxe module. -+ Copyright (c) Microsoft Corporation -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+ -+//////////////////////////////////////////////////////////////////////////////// -+// Run the tests -+//////////////////////////////////////////////////////////////////////////////// -+int -+main ( -+ int argc, -+ char *argv[] -+ ) -+{ -+ testing::InitGoogleTest (&argc, argv); -+ return RUN_ALL_TESTS (); -+} -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf -new file mode 100644 -index 0000000000..301dcdf611 ---- /dev/null -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf -@@ -0,0 +1,48 @@ -+## @file -+# Unit test suite for the UefiPxeBcDxe using Google Test -+# -+# Copyright (c) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+[Defines] -+INF_VERSION = 0x00010005 -+BASE_NAME = UefiPxeBcDxeGoogleTest -+FILE_GUID = 77D45C64-EC1E-4174-887B-886E89FD1EDF -+MODULE_TYPE = HOST_APPLICATION -+VERSION_STRING = 1.0 -+ -+# -+# The following information is for reference only and not required by the build tools. -+# -+# VALID_ARCHITECTURES = IA32 X64 -+# -+ -+[Sources] -+ UefiPxeBcDxeGoogleTest.cpp -+ PxeBcDhcp6GoogleTest.cpp -+ PxeBcDhcp6GoogleTest.h -+ ../PxeBcDhcp6.c -+ ../PxeBcSupport.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ MdeModulePkg/MdeModulePkg.dec -+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec -+ NetworkPkg/NetworkPkg.dec -+ -+[LibraryClasses] -+ GoogleTestLib -+ DebugLib -+ NetLib -+ PcdLib -+ -+[Protocols] -+ gEfiDhcp6ServiceBindingProtocolGuid -+ gEfiDns6ServiceBindingProtocolGuid -+ gEfiDns6ProtocolGuid -+ -+[Pcd] -+ gEfiNetworkPkgTokenSpaceGuid.PcdDhcp6UidType -+ -+[Guids] -+ gZeroGuid --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p3.patch b/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p3.patch deleted file mode 100644 index beaa36f..0000000 --- a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p3.patch +++ /dev/null @@ -1,257 +0,0 @@ -From 0016db53099ba979617f376fe1104fefada4fa29 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 09/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 - Patch - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [9/15] c48c060b87761537ee526e1f8a9e5993eb1a0381 - -JIRA: https://issues.redhat.com/browse/RHEL-21852 -CVE: CVE-2022-45235 -Upstream: Merged - -commit fac297724e6cc343430cd0104e55cd7a96d1151e -Author: Doug Flick -Date: Fri Jan 26 05:54:55 2024 +0800 - - NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 Patch - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4540 - - Bug Details: - PixieFail Bug #7 - CVE-2023-45235 - CVSS 8.3 : CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:H - CWE-119 Improper Restriction of Operations within the Bounds of - a Memory Buffer - - Buffer overflow when handling Server ID option from a DHCPv6 proxy - Advertise message - - Change Overview: - - Performs two checks - - 1. Checks that the length of the duid is accurate - > + // - > + // Check that the minimum and maximum requirements are met - > + // - > + if ((OpLen < PXEBC_MIN_SIZE_OF_DUID) || - (OpLen > PXEBC_MAX_SIZE_OF_DUID)) { - > + Status = EFI_INVALID_PARAMETER; - > + goto ON_ERROR; - > + } - - 2. Ensures that the amount of data written to the buffer is tracked and - never exceeds that - > + // - > + // Check that the option length is valid. - > + // - > + if ((DiscoverLen + OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN) - > DiscoverLenNeeded) { - > + Status = EFI_OUT_OF_RESOURCES; - > + goto ON_ERROR; - > + } - - Additional code clean up and fix for memory leak in case Option was NULL - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 77 ++++++++++++++++++++++------ - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h | 17 ++++++ - 2 files changed, 78 insertions(+), 16 deletions(-) - -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -index 2b2d372889..7fd1281c11 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c -@@ -887,6 +887,7 @@ PxeBcRequestBootService ( - EFI_STATUS Status; - EFI_DHCP6_PACKET *IndexOffer; - UINT8 *Option; -+ UINTN DiscoverLenNeeded; - - PxeBc = &Private->PxeBc; - Request = Private->Dhcp6Request; -@@ -899,7 +900,8 @@ PxeBcRequestBootService ( - return EFI_DEVICE_ERROR; - } - -- Discover = AllocateZeroPool (sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET)); -+ DiscoverLenNeeded = sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET); -+ Discover = AllocateZeroPool (DiscoverLenNeeded); - if (Discover == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -924,16 +926,34 @@ PxeBcRequestBootService ( - DHCP6_OPT_SERVER_ID - ); - if (Option == NULL) { -- return EFI_NOT_FOUND; -+ Status = EFI_NOT_FOUND; -+ goto ON_ERROR; - } - - // - // Add Server ID Option. - // - OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)Option)->OpLen); -- CopyMem (DiscoverOpt, Option, OpLen + 4); -- DiscoverOpt += (OpLen + 4); -- DiscoverLen += (OpLen + 4); -+ -+ // -+ // Check that the minimum and maximum requirements are met -+ // -+ if ((OpLen < PXEBC_MIN_SIZE_OF_DUID) || (OpLen > PXEBC_MAX_SIZE_OF_DUID)) { -+ Status = EFI_INVALID_PARAMETER; -+ goto ON_ERROR; -+ } -+ -+ // -+ // Check that the option length is valid. -+ // -+ if ((DiscoverLen + OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN) > DiscoverLenNeeded) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; -+ } -+ -+ CopyMem (DiscoverOpt, Option, OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverOpt += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverLen += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); - } - - while (RequestLen < Request->Length) { -@@ -944,16 +964,24 @@ PxeBcRequestBootService ( - (OpCode != DHCP6_OPT_SERVER_ID) - ) - { -+ // -+ // Check that the option length is valid. -+ // -+ if (DiscoverLen + OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN > DiscoverLenNeeded) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; -+ } -+ - // - // Copy all the options except IA option and Server ID - // -- CopyMem (DiscoverOpt, RequestOpt, OpLen + 4); -- DiscoverOpt += (OpLen + 4); -- DiscoverLen += (OpLen + 4); -+ CopyMem (DiscoverOpt, RequestOpt, OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverOpt += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverLen += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); - } - -- RequestOpt += (OpLen + 4); -- RequestLen += (OpLen + 4); -+ RequestOpt += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ RequestLen += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); - } - - // -@@ -2154,6 +2182,7 @@ PxeBcDhcp6Discover ( - UINT16 OpLen; - UINT32 Xid; - EFI_STATUS Status; -+ UINTN DiscoverLenNeeded; - - PxeBc = &Private->PxeBc; - Mode = PxeBc->Mode; -@@ -2169,7 +2198,8 @@ PxeBcDhcp6Discover ( - return EFI_DEVICE_ERROR; - } - -- Discover = AllocateZeroPool (sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET)); -+ DiscoverLenNeeded = sizeof (EFI_PXE_BASE_CODE_DHCPV6_PACKET); -+ Discover = AllocateZeroPool (DiscoverLenNeeded); - if (Discover == NULL) { - return EFI_OUT_OF_RESOURCES; - } -@@ -2185,22 +2215,37 @@ PxeBcDhcp6Discover ( - DiscoverLen = sizeof (EFI_DHCP6_HEADER); - RequestLen = DiscoverLen; - -+ // -+ // The request packet is generated by the UEFI network stack. In the DHCP4 DORA and DHCP6 SARR sequence, -+ // the first (discover in DHCP4 and solicit in DHCP6) and third (request in both DHCP4 and DHCP6) are -+ // generated by the DHCP client (the UEFI network stack in this case). By the time this function executes, -+ // the DHCP sequence already has been executed once (see UEFI Specification Figures 24.2 and 24.3), with -+ // Private->Dhcp6Request being a cached copy of the DHCP6 request packet that UEFI network stack previously -+ // generated and sent. -+ // -+ // Therefore while this code looks like it could overflow, in practice it's not possible. -+ // - while (RequestLen < Request->Length) { - OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpCode); - OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *)RequestOpt)->OpLen); - if ((OpCode != EFI_DHCP6_IA_TYPE_NA) && - (OpCode != EFI_DHCP6_IA_TYPE_TA)) - { -+ if (DiscoverLen + OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN > DiscoverLenNeeded) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto ON_ERROR; -+ } -+ - // - // Copy all the options except IA option. - // -- CopyMem (DiscoverOpt, RequestOpt, OpLen + 4); -- DiscoverOpt += (OpLen + 4); -- DiscoverLen += (OpLen + 4); -+ CopyMem (DiscoverOpt, RequestOpt, OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverOpt += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ DiscoverLen += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); - } - -- RequestOpt += (OpLen + 4); -- RequestLen += (OpLen + 4); -+ RequestOpt += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); -+ RequestLen += (OpLen + PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN); - } - - Status = PxeBc->UdpWrite ( -diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h -index ae4be775e8..47eb8cc0c0 100644 ---- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h -+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h -@@ -35,6 +35,23 @@ - #define PXEBC_ADDR_START_DELIMITER '[' - #define PXEBC_ADDR_END_DELIMITER ']' - -+// -+// A DUID consists of a 2-octet type code represented in network byte -+// order, followed by a variable number of octets that make up the -+// actual identifier. The length of the DUID (not including the type -+// code) is at least 1 octet and at most 128 octets. -+// -+#define PXEBC_MIN_SIZE_OF_DUID (sizeof(UINT16) + 1) -+#define PXEBC_MAX_SIZE_OF_DUID (sizeof(UINT16) + 128) -+ -+// -+// This define represents the combineds code and length field from -+// https://datatracker.ietf.org/doc/html/rfc3315#section-22.1 -+// -+#define PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN \ -+ (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpCode) + \ -+ sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpLen)) -+ - #define GET_NEXT_DHCP6_OPTION(Opt) \ - (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \ - sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1) --- -2.39.3 - diff --git a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p4.patch b/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p4.patch deleted file mode 100644 index 8380050..0000000 --- a/SOURCES/edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p4.patch +++ /dev/null @@ -1,409 +0,0 @@ -From 80b34c0f56228353c174f9ff739d0755c62d76cf Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Fri, 16 Feb 2024 10:48:05 -0500 -Subject: [PATCH 10/15] NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 - Unit Tests - -RH-Author: Jon Maloy -RH-MergeRequest: 56: Pixiefail issues in NetworkPkg package -RH-Jira: RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852 -RH-Acked-by: Gerd Hoffmann -RH-Acked-by: Oliver Steffen -RH-Commit: [10/15] 5dbf3f771506ff9a0c28827c568d04e825572658 - -JIRA: https://issues.redhat.com/browse/RHEL-21852 -CVE: CVE-2022-45235 -Upstream: Merged - -commit ff2986358f75d8f58ef08a66fe673539c9c48f41 -Author: Doug Flick -Date: Fri Jan 26 05:54:56 2024 +0800 - - NetworkPkg: UefiPxeBcDxe: SECURITY PATCH CVE-2023-45235 Unit Tests - - REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4540 - - Unit tests to confirm that the bug.. - - Buffer overflow when handling Server ID option from a DHCPv6 proxy - Advertise message - - ..has been patched. - - This patch contains unit tests for the following functions: - PxeBcRequestBootService - PxeBcDhcp6Discover - - Cc: Saloni Kasbekar - Cc: Zachary Clark-williams - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Saloni Kasbekar - -Signed-off-by: Jon Maloy ---- - NetworkPkg/Test/NetworkPkgHostTest.dsc | 5 +- - .../GoogleTest/PxeBcDhcp6GoogleTest.cpp | 278 +++++++++++++++++- - .../GoogleTest/PxeBcDhcp6GoogleTest.h | 18 ++ - 3 files changed, 298 insertions(+), 3 deletions(-) - -diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/NetworkPkgHostTest.dsc -index c8a991e5c1..1010a80a15 100644 ---- a/NetworkPkg/Test/NetworkPkgHostTest.dsc -+++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc -@@ -26,7 +26,10 @@ - # - NetworkPkg/Dhcp6Dxe/GoogleTest/Dhcp6DxeGoogleTest.inf - NetworkPkg/Ip6Dxe/GoogleTest/Ip6DxeGoogleTest.inf -- NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf -+ NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf { -+ -+ UefiRuntimeServicesTableLib|MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf -+ } - - # Despite these library classes being listed in [LibraryClasses] below, they are not needed for the host-based unit tests. - [LibraryClasses] -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp -index 8260eeee50..bd423ebadf 100644 ---- a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp -@@ -4,7 +4,9 @@ - Copyright (c) Microsoft Corporation - SPDX-License-Identifier: BSD-2-Clause-Patent - **/ --#include -+#include -+#include -+#include - - extern "C" { - #include -@@ -19,7 +21,8 @@ extern "C" { - // Definitions - /////////////////////////////////////////////////////////////////////////////// - --#define PACKET_SIZE (1500) -+#define PACKET_SIZE (1500) -+#define REQUEST_OPTION_LENGTH (120) - - typedef struct { - UINT16 OptionCode; // The option code for DHCP6_OPT_SERVER_ID (e.g., 0x03) -@@ -76,6 +79,26 @@ MockConfigure ( - } - - // Needed by PxeBcSupport -+EFI_STATUS -+PxeBcDns6 ( -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN CHAR16 *HostName, -+ OUT EFI_IPv6_ADDRESS *IpAddress -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+UINT32 -+PxeBcBuildDhcp6Options ( -+ IN PXEBC_PRIVATE_DATA *Private, -+ OUT EFI_DHCP6_PACKET_OPTION **OptList, -+ IN UINT8 *Buffer -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ - EFI_STATUS - EFIAPI - QueueDpc ( -@@ -159,6 +182,10 @@ TEST_F (PxeBcHandleDhcp6OfferTest, BasicUsageTest) { - ASSERT_EQ (PxeBcHandleDhcp6Offer (&(PxeBcHandleDhcp6OfferTest::Private)), EFI_DEVICE_ERROR); - } - -+/////////////////////////////////////////////////////////////////////////////// -+// PxeBcCacheDnsServerAddresses Tests -+/////////////////////////////////////////////////////////////////////////////// -+ - class PxeBcCacheDnsServerAddressesTest : public ::testing::Test { - public: - PXEBC_PRIVATE_DATA Private = { 0 }; -@@ -298,3 +325,250 @@ TEST_F (PxeBcCacheDnsServerAddressesTest, MultipleDnsEntries) { - FreePool (Private.DnsServer); - } - } -+ -+/////////////////////////////////////////////////////////////////////////////// -+// PxeBcRequestBootServiceTest Test Cases -+/////////////////////////////////////////////////////////////////////////////// -+ -+class PxeBcRequestBootServiceTest : public ::testing::Test { -+public: -+ PXEBC_PRIVATE_DATA Private = { 0 }; -+ EFI_UDP6_PROTOCOL Udp6Read; -+ -+protected: -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ Private.Dhcp6Request = (EFI_DHCP6_PACKET *)AllocateZeroPool (PACKET_SIZE); -+ -+ // Need to setup the EFI_PXE_BASE_CODE_PROTOCOL -+ // The function under test really only needs the following: -+ // UdpWrite -+ // UdpRead -+ -+ Private.PxeBc.UdpWrite = (EFI_PXE_BASE_CODE_UDP_WRITE)MockUdpWrite; -+ Private.PxeBc.UdpRead = (EFI_PXE_BASE_CODE_UDP_READ)MockUdpRead; -+ -+ // Need to setup EFI_UDP6_PROTOCOL -+ // The function under test really only needs the following: -+ // Configure -+ -+ Udp6Read.Configure = (EFI_UDP6_CONFIGURE)MockConfigure; -+ Private.Udp6Read = &Udp6Read; -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ if (Private.Dhcp6Request != NULL) { -+ FreePool (Private.Dhcp6Request); -+ } -+ -+ // Clean up any resources or variables -+ } -+}; -+ -+TEST_F (PxeBcRequestBootServiceTest, ServerDiscoverBasicUsageTest) { -+ PxeBcRequestBootServiceTest::Private.OfferBuffer[0].Dhcp6.OfferType = PxeOfferTypeProxyBinl; -+ -+ DHCP6_OPTION_SERVER_ID Server = { 0 }; -+ -+ Server.OptionCode = HTONS (DHCP6_OPT_SERVER_ID); -+ Server.OptionLen = HTONS (16); // valid length -+ UINT8 Index = 0; -+ -+ EFI_DHCP6_PACKET *Packet = (EFI_DHCP6_PACKET *)&Private.OfferBuffer[Index].Dhcp6.Packet.Offer; -+ -+ UINT8 *Cursor = (UINT8 *)(Packet->Dhcp6.Option); -+ -+ CopyMem (Cursor, &Server, sizeof (Server)); -+ Cursor += sizeof (Server); -+ -+ // Update the packet length -+ Packet->Length = (UINT16)(Cursor - (UINT8 *)Packet); -+ Packet->Size = PACKET_SIZE; -+ -+ ASSERT_EQ (PxeBcRequestBootService (&(PxeBcRequestBootServiceTest::Private), Index), EFI_SUCCESS); -+} -+ -+TEST_F (PxeBcRequestBootServiceTest, AttemptDiscoverOverFlowExpectFailure) { -+ PxeBcRequestBootServiceTest::Private.OfferBuffer[0].Dhcp6.OfferType = PxeOfferTypeProxyBinl; -+ -+ DHCP6_OPTION_SERVER_ID Server = { 0 }; -+ -+ Server.OptionCode = HTONS (DHCP6_OPT_SERVER_ID); -+ Server.OptionLen = HTONS (1500); // This length would overflow without a check -+ UINT8 Index = 0; -+ -+ EFI_DHCP6_PACKET *Packet = (EFI_DHCP6_PACKET *)&Private.OfferBuffer[Index].Dhcp6.Packet.Offer; -+ -+ UINT8 *Cursor = (UINT8 *)(Packet->Dhcp6.Option); -+ -+ CopyMem (Cursor, &Server, sizeof (Server)); -+ Cursor += sizeof (Server); -+ -+ // Update the packet length -+ Packet->Length = (UINT16)(Cursor - (UINT8 *)Packet); -+ Packet->Size = PACKET_SIZE; -+ -+ // This is going to be stopped by the duid overflow check -+ ASSERT_EQ (PxeBcRequestBootService (&(PxeBcRequestBootServiceTest::Private), Index), EFI_INVALID_PARAMETER); -+} -+ -+TEST_F (PxeBcRequestBootServiceTest, RequestBasicUsageTest) { -+ EFI_DHCP6_PACKET_OPTION RequestOpt = { 0 }; // the data section doesn't really matter -+ -+ RequestOpt.OpCode = HTONS (0x1337); -+ RequestOpt.OpLen = 0; // valid length -+ -+ UINT8 Index = 0; -+ -+ EFI_DHCP6_PACKET *Packet = (EFI_DHCP6_PACKET *)&Private.Dhcp6Request[Index]; -+ -+ UINT8 *Cursor = (UINT8 *)(Packet->Dhcp6.Option); -+ -+ CopyMem (Cursor, &RequestOpt, sizeof (RequestOpt)); -+ Cursor += sizeof (RequestOpt); -+ -+ // Update the packet length -+ Packet->Length = (UINT16)(Cursor - (UINT8 *)Packet); -+ Packet->Size = PACKET_SIZE; -+ -+ ASSERT_EQ (PxeBcRequestBootService (&(PxeBcRequestBootServiceTest::Private), Index), EFI_SUCCESS); -+} -+ -+TEST_F (PxeBcRequestBootServiceTest, AttemptRequestOverFlowExpectFailure) { -+ EFI_DHCP6_PACKET_OPTION RequestOpt = { 0 }; // the data section doesn't really matter -+ -+ RequestOpt.OpCode = HTONS (0x1337); -+ RequestOpt.OpLen = 1500; // this length would overflow without a check -+ -+ UINT8 Index = 0; -+ -+ EFI_DHCP6_PACKET *Packet = (EFI_DHCP6_PACKET *)&Private.Dhcp6Request[Index]; -+ -+ UINT8 *Cursor = (UINT8 *)(Packet->Dhcp6.Option); -+ -+ CopyMem (Cursor, &RequestOpt, sizeof (RequestOpt)); -+ Cursor += sizeof (RequestOpt); -+ -+ // Update the packet length -+ Packet->Length = (UINT16)(Cursor - (UINT8 *)Packet); -+ Packet->Size = PACKET_SIZE; -+ -+ ASSERT_EQ (PxeBcRequestBootService (&(PxeBcRequestBootServiceTest::Private), Index), EFI_OUT_OF_RESOURCES); -+} -+ -+/////////////////////////////////////////////////////////////////////////////// -+// PxeBcDhcp6Discover Test -+/////////////////////////////////////////////////////////////////////////////// -+ -+class PxeBcDhcp6DiscoverTest : public ::testing::Test { -+public: -+ PXEBC_PRIVATE_DATA Private = { 0 }; -+ EFI_UDP6_PROTOCOL Udp6Read; -+ -+protected: -+ MockUefiRuntimeServicesTableLib RtServicesMock; -+ -+ // Add any setup code if needed -+ virtual void -+ SetUp ( -+ ) -+ { -+ Private.Dhcp6Request = (EFI_DHCP6_PACKET *)AllocateZeroPool (PACKET_SIZE); -+ -+ // Need to setup the EFI_PXE_BASE_CODE_PROTOCOL -+ // The function under test really only needs the following: -+ // UdpWrite -+ // UdpRead -+ -+ Private.PxeBc.UdpWrite = (EFI_PXE_BASE_CODE_UDP_WRITE)MockUdpWrite; -+ Private.PxeBc.UdpRead = (EFI_PXE_BASE_CODE_UDP_READ)MockUdpRead; -+ -+ // Need to setup EFI_UDP6_PROTOCOL -+ // The function under test really only needs the following: -+ // Configure -+ -+ Udp6Read.Configure = (EFI_UDP6_CONFIGURE)MockConfigure; -+ Private.Udp6Read = &Udp6Read; -+ } -+ -+ // Add any cleanup code if needed -+ virtual void -+ TearDown ( -+ ) -+ { -+ if (Private.Dhcp6Request != NULL) { -+ FreePool (Private.Dhcp6Request); -+ } -+ -+ // Clean up any resources or variables -+ } -+}; -+ -+// Test Description -+// This will cause an overflow by an untrusted packet during the option parsing -+TEST_F (PxeBcDhcp6DiscoverTest, BasicOverflowTest) { -+ EFI_IPv6_ADDRESS DestIp = { 0 }; -+ EFI_DHCP6_PACKET_OPTION RequestOpt = { 0 }; // the data section doesn't really matter -+ -+ RequestOpt.OpCode = HTONS (0x1337); -+ RequestOpt.OpLen = HTONS (0xFFFF); // overflow -+ -+ UINT8 *Cursor = (UINT8 *)(Private.Dhcp6Request->Dhcp6.Option); -+ -+ CopyMem (Cursor, &RequestOpt, sizeof (RequestOpt)); -+ Cursor += sizeof (RequestOpt); -+ -+ Private.Dhcp6Request->Length = (UINT16)(Cursor - (UINT8 *)Private.Dhcp6Request); -+ -+ EXPECT_CALL (RtServicesMock, gRT_GetTime) -+ .WillOnce (::testing::Return (0)); -+ -+ ASSERT_EQ ( -+ PxeBcDhcp6Discover ( -+ &(PxeBcDhcp6DiscoverTest::Private), -+ 0, -+ NULL, -+ FALSE, -+ (EFI_IP_ADDRESS *)&DestIp -+ ), -+ EFI_OUT_OF_RESOURCES -+ ); -+} -+ -+// Test Description -+// This will test that we can handle a packet with a valid option length -+TEST_F (PxeBcDhcp6DiscoverTest, BasicUsageTest) { -+ EFI_IPv6_ADDRESS DestIp = { 0 }; -+ EFI_DHCP6_PACKET_OPTION RequestOpt = { 0 }; // the data section doesn't really matter -+ -+ RequestOpt.OpCode = HTONS (0x1337); -+ RequestOpt.OpLen = HTONS (0x30); -+ -+ UINT8 *Cursor = (UINT8 *)(Private.Dhcp6Request->Dhcp6.Option); -+ -+ CopyMem (Cursor, &RequestOpt, sizeof (RequestOpt)); -+ Cursor += sizeof (RequestOpt); -+ -+ Private.Dhcp6Request->Length = (UINT16)(Cursor - (UINT8 *)Private.Dhcp6Request); -+ -+ EXPECT_CALL (RtServicesMock, gRT_GetTime) -+ .WillOnce (::testing::Return (0)); -+ -+ ASSERT_EQ ( -+ PxeBcDhcp6Discover ( -+ &(PxeBcDhcp6DiscoverTest::Private), -+ 0, -+ NULL, -+ FALSE, -+ (EFI_IP_ADDRESS *)&DestIp -+ ), -+ EFI_SUCCESS -+ ); -+} -diff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h -index b17c314791..0d825e4425 100644 ---- a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h -+++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.h -@@ -47,4 +47,22 @@ PxeBcCacheDnsServerAddresses ( - IN PXEBC_DHCP6_PACKET_CACHE *Cache6 - ); - -+/** -+ Build and send out the request packet for the bootfile, and parse the reply. -+ -+ @param[in] Private The pointer to PxeBc private data. -+ @param[in] Index PxeBc option boot item type. -+ -+ @retval EFI_SUCCESS Successfully discovered the boot file. -+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. -+ @retval EFI_NOT_FOUND Can't get the PXE reply packet. -+ @retval Others Failed to discover the boot file. -+ -+**/ -+EFI_STATUS -+PxeBcRequestBootService ( -+ IN PXEBC_PRIVATE_DATA *Private, -+ IN UINT32 Index -+ ); -+ - #endif // PXE_BC_DHCP6_GOOGLE_TEST_H_ --- -2.39.3 - diff --git a/SOURCES/edk2-OvmfPkg-Add-Hash2DxeCrypto-to-OvmfPkg.patch b/SOURCES/edk2-OvmfPkg-Add-Hash2DxeCrypto-to-OvmfPkg.patch deleted file mode 100644 index c48a286..0000000 --- a/SOURCES/edk2-OvmfPkg-Add-Hash2DxeCrypto-to-OvmfPkg.patch +++ /dev/null @@ -1,202 +0,0 @@ -From d6cdd646e7d9c4cfc78a061d66ab9ba4d2f02cf3 Mon Sep 17 00:00:00 2001 -From: Doug Flick -Date: Wed, 8 May 2024 22:56:24 -0700 -Subject: [PATCH] OvmfPkg: Add Hash2DxeCrypto to OvmfPkg - -RH-Author: Oliver Steffen -RH-MergeRequest: 81: OvmfPkg: Add Hash2DxeCrypto to OvmfPkg -RH-Jira: RHEL-53009 -RH-Acked-by: Jon Maloy -RH-Commit: [1/1] 07d3c21a816826beefe963908284cc8b5dd0b075 - -JIRA: https://issues.redhat.com/browse/RHEL-53009 -Upstream: Merged - -Upstream commit 4c4ceb2ceb80 ("NetworkPkg: SECURITY PATCH CVE-2023-45237") -broke HTTP boot in OVMF. This fixes it. - -commit cb9d71189134e78efb00759eb9649ce92bf5b29a -Author: Doug Flick -Date: Wed May 8 22:56:24 2024 -0700 - - OvmfPkg: Add Hash2DxeCrypto to OvmfPkg - - This patch adds Hash2DxeCrypto to OvmfPkg. The Hash2DxeCrypto is - used to provide the hashing protocol services. - - Cc: Ard Biesheuvel - Cc: Jiewen Yao - Cc: Gerd Hoffmann - - Signed-off-by: Doug Flick [MSFT] - Tested-by: Gerd Hoffmann - Acked-by: Gerd Hoffmann - Reviewed-by: Ard Biesheuvel - -Signed-off-by: Oliver Steffen ---- - OvmfPkg/OvmfPkgIa32.dsc | 6 +++++- - OvmfPkg/OvmfPkgIa32.fdf | 5 +++++ - OvmfPkg/OvmfPkgIa32X64.dsc | 6 +++++- - OvmfPkg/OvmfPkgIa32X64.fdf | 5 +++++ - OvmfPkg/OvmfPkgX64.dsc | 6 +++++- - OvmfPkg/OvmfPkgX64.fdf | 5 +++++ - OvmfPkg/OvmfXen.dsc | 5 +++++ - OvmfPkg/OvmfXen.fdf | 5 +++++ - 8 files changed, 40 insertions(+), 3 deletions(-) - -diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index f03906a9ff..47c1732409 100644 ---- a/OvmfPkg/OvmfPkgIa32.dsc -+++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -213,7 +213,6 @@ - VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf - VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf - -- - # - # Network libraries - # -@@ -884,6 +883,11 @@ - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -+ # -+ # Hash2 Protocol producer -+ # -+ SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network Support - # -diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf -index 050148948c..71fb83b285 100644 ---- a/OvmfPkg/OvmfPkgIa32.fdf -+++ b/OvmfPkg/OvmfPkgIa32.fdf -@@ -300,6 +300,11 @@ INF ShellPkg/Application/Shell/Shell.inf - - INF MdeModulePkg/Logo/LogoDxe.inf - -+# -+# Hash2 Protocol producer -+# -+INF SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network modules - # -diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index 81145050c3..186f783ff5 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.dsc -+++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -217,7 +217,6 @@ - VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf - VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf - -- - # - # Network libraries - # -@@ -898,6 +897,11 @@ - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -+ # -+ # Hash2 Protocol producer -+ # -+ SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network Support - # -diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf -index 3e2373f225..6762627073 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.fdf -+++ b/OvmfPkg/OvmfPkgIa32X64.fdf -@@ -304,6 +304,11 @@ INF ShellPkg/Application/Shell/Shell.inf - - INF MdeModulePkg/Logo/LogoDxe.inf - -+# -+# Hash2 Protocol producer -+# -+INF SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network modules - # -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 1cb169b447..e968ab6be2 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -217,7 +217,6 @@ - VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf - VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf - -- - # - # Network libraries - # -@@ -896,6 +895,11 @@ - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -+ # -+ # Hash2 Protocol producer -+ # -+ SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network Support - # -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index 8ba0ca437a..95544c2bc5 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -320,6 +320,11 @@ INF ShellPkg/Application/Shell/Shell.inf - - INF MdeModulePkg/Logo/LogoDxe.inf - -+# -+# Hash2 Protocol producer -+# -+INF SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network modules - # -diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc -index e7c36d1b80..462e57ddcc 100644 ---- a/OvmfPkg/OvmfXen.dsc -+++ b/OvmfPkg/OvmfXen.dsc -@@ -660,6 +660,11 @@ - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf - MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf - -+ # -+ # Hash2 Protocol producer -+ # -+ SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network Support - # -diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf -index 8b58235559..3c64619e8e 100644 ---- a/OvmfPkg/OvmfXen.fdf -+++ b/OvmfPkg/OvmfXen.fdf -@@ -369,6 +369,11 @@ INF ShellPkg/Application/Shell/Shell.inf - - INF MdeModulePkg/Logo/LogoDxe.inf - -+# -+# Hash2 Protocol producer -+# -+INF SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf -+ - # - # Network modules - # --- -2.45.1 - diff --git a/SOURCES/edk2-OvmfPkg-AmdSev-SecretPei-Mark-SEV-launch-secret-area.patch b/SOURCES/edk2-OvmfPkg-AmdSev-SecretPei-Mark-SEV-launch-secret-area.patch deleted file mode 100644 index 94d6eb6..0000000 --- a/SOURCES/edk2-OvmfPkg-AmdSev-SecretPei-Mark-SEV-launch-secret-area.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e4a64ad230ff2906ec56d41b2a8dd7a0bb39a399 Mon Sep 17 00:00:00 2001 -From: Dov Murik -Date: Tue, 4 Jan 2022 15:16:40 +0800 -Subject: [PATCH] OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret area as - reserved - -RH-Author: Pawel Polawski -RH-MergeRequest: 11: OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret area as reserved -RH-Commit: [1/1] a14d34eb204387aae3446770a0e5fb95a9283ae3 (elkoniu/edk2) -RH-Bugzilla: 2041754 -RH-Acked-by: Oliver Steffen - -Mark the SEV launch secret MEMFD area as reserved, which will allow the -guest OS to use it during the lifetime of the OS, without creating -copies of the sensitive content. - -Cc: Ard Biesheuvel -Cc: Jordan Justen -Cc: Gerd Hoffmann -Cc: Brijesh Singh -Cc: Erdem Aktas -Cc: James Bottomley -Cc: Jiewen Yao -Cc: Min Xu -Cc: Tom Lendacky -Cc: Tobin Feldman-Fitzthum -Signed-off-by: Dov Murik -Acked-by: Gerd Hoffmann -Acked-by: Jiewen Yao -Reviewed-by: Brijesh Singh ---- - OvmfPkg/AmdSev/SecretPei/SecretPei.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/OvmfPkg/AmdSev/SecretPei/SecretPei.c b/OvmfPkg/AmdSev/SecretPei/SecretPei.c -index db94c26b54..6bf1a55dea 100644 ---- a/OvmfPkg/AmdSev/SecretPei/SecretPei.c -+++ b/OvmfPkg/AmdSev/SecretPei/SecretPei.c -@@ -19,7 +19,7 @@ InitializeSecretPei ( - BuildMemoryAllocationHob ( - PcdGet32 (PcdSevLaunchSecretBase), - ALIGN_VALUE (PcdGet32 (PcdSevLaunchSecretSize), EFI_PAGE_SIZE), -- EfiBootServicesData -+ EfiReservedMemoryType - ); - - return EFI_SUCCESS; --- -2.27.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-ValidateFvHeader-unwritten-s.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-ValidateFvHeader-unwritten-s.patch deleted file mode 100644 index adf5b38..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-ValidateFvHeader-unwritten-s.patch +++ /dev/null @@ -1,47 +0,0 @@ -From f2aeff31924f6d070d7f8b87550dc6d9820531ad Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:04 +0100 -Subject: [PATCH 15/18] OvmfPkg/VirtNorFlashDxe: ValidateFvHeader: unwritten - state is EOL too - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [17/20] 37220c700ea816c815e0612031e10b7d466b71a2 - -It is possible to find variable entries with State being 0xff, i.e. not -updated since flash block erase. This indicates the variable driver -could not complete the header write while appending a new entry, and -therefore State was not set to VAR_HEADER_VALID_ONLY. - -This can only happen at the end of the variable list, so treat this as -additional "end of variable list" condition. - -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240116171105.37831-6-kraxel@redhat.com> -(cherry picked from commit 735d0a5e2e25c1577bf9bea7826da937ca38169d) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -index acc4a413ee..f8e71f88c1 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -@@ -302,6 +302,11 @@ ValidateFvHeader ( - break; - } - -+ if (VarHeader->State == 0xff) { -+ DEBUG ((DEBUG_INFO, "%a: end of var list (unwritten state)\n", __func__)); -+ break; -+ } -+ - VarName = NULL; - switch (VarHeader->State) { - // usage: State = VAR_HEADER_VALID_ONLY --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-a-loop-for-NorFlashWrite.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-a-loop-for-NorFlashWrite.patch deleted file mode 100644 index 4fc7c3e..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-a-loop-for-NorFlashWrite.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 00d9e2d6cb03afeef5a1110d6f1fae1389a06f7a Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:02 +0100 -Subject: [PATCH 13/18] OvmfPkg/VirtNorFlashDxe: add a loop for - NorFlashWriteBuffer calls. - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [15/20] 72004a196ea61d627ab528573db657dd7db16de2 - -Replace the two NorFlashWriteBuffer() calls with a loop containing a -single NorFlashWriteBuffer() call. - -With the changes in place the code is able to handle updates larger -than two P30_MAX_BUFFER_SIZE_IN_BYTES blocks, even though the patch -does not actually change the size limit. - -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240116171105.37831-4-kraxel@redhat.com> -(cherry picked from commit 28ffd726894f11a587a6ac7f71a4c4af341e24d2) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 21 ++++++++------------- - 1 file changed, 8 insertions(+), 13 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 88a4d2c23f..3d1343b381 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -521,6 +521,7 @@ NorFlashWriteSingleBlock ( - UINTN BlockAddress; - UINT8 *OrigData; - UINTN Start, End; -+ UINT32 Index, Count; - - DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); - -@@ -621,23 +622,17 @@ NorFlashWriteSingleBlock ( - goto Exit; - } - -- Status = NorFlashWriteBuffer ( -- Instance, -- BlockAddress + Start, -- P30_MAX_BUFFER_SIZE_IN_BYTES, -- Instance->ShadowBuffer -- ); -- if (EFI_ERROR (Status)) { -- goto Exit; -- } -- -- if ((End - Start) > P30_MAX_BUFFER_SIZE_IN_BYTES) { -+ Count = (End - Start) / P30_MAX_BUFFER_SIZE_IN_BYTES; -+ for (Index = 0; Index < Count; Index++) { - Status = NorFlashWriteBuffer ( - Instance, -- BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES, -+ BlockAddress + Start + Index * P30_MAX_BUFFER_SIZE_IN_BYTES, - P30_MAX_BUFFER_SIZE_IN_BYTES, -- Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES -+ Instance->ShadowBuffer + Index * P30_MAX_BUFFER_SIZE_IN_BYTES - ); -+ if (EFI_ERROR (Status)) { -+ goto Exit; -+ } - } - - Exit: --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-casts-to-UINTN-and-UINT3.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-casts-to-UINTN-and-UINT3.patch deleted file mode 100644 index 2494899..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-add-casts-to-UINTN-and-UINT3.patch +++ /dev/null @@ -1,55 +0,0 @@ -From e8150ee7fdf1421d2e2801c901e0196496ef599e Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:00 +0100 -Subject: [PATCH 11/18] OvmfPkg/VirtNorFlashDxe: add casts to UINTN and UINT32 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [13/20] fa695acadb9d693242b5221d2bc1958b929718e7 - -This is needed to avoid bit operations being applied to signed integers. - -Suggested-by: László Érsek -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240116171105.37831-2-kraxel@redhat.com> -(cherry picked from commit 0395045ae307c43a41f72ca9a8bf4eb8f16b2fe0) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 2 +- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 1afd60ce66..7f4743b003 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -581,7 +581,7 @@ NorFlashWriteSingleBlock ( - // contents, while checking whether the old version had any bits cleared - // that we want to set. In that case, we will need to erase the block first. - for (CurOffset = 0; CurOffset < *NumBytes; CurOffset++) { -- if (~OrigData[CurOffset] & Buffer[CurOffset]) { -+ if (~(UINT32)OrigData[CurOffset] & (UINT32)Buffer[CurOffset]) { - goto DoErase; - } - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -index b7f5d208b2..455eafacc2 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -@@ -61,7 +61,7 @@ - #define P30_MAX_BUFFER_SIZE_IN_BYTES ((UINTN)128) - #define P30_MAX_BUFFER_SIZE_IN_WORDS (P30_MAX_BUFFER_SIZE_IN_BYTES/((UINTN)4)) - #define MAX_BUFFERED_PROG_ITERATIONS 10000000 --#define BOUNDARY_OF_32_WORDS 0x7F -+#define BOUNDARY_OF_32_WORDS ((UINTN)0x7F) - - // CFI Addresses - #define P30_CFI_ADDR_QUERY_UNIQUE_QRY 0x10 --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-allow-larger-writes-without-.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-allow-larger-writes-without-.patch deleted file mode 100644 index f30a257..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-allow-larger-writes-without-.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0193a89b0db837da31301bc1edb8382927842978 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:03 +0100 -Subject: [PATCH 14/18] OvmfPkg/VirtNorFlashDxe: allow larger writes without - block erase - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [16/20] 27ac63b90eb5e6fdc00cbc5a9105c3178ee559cd - -Raise the limit for writes without block erase from two to four -P30_MAX_BUFFER_SIZE_IN_BYTES blocks. With this in place almost all efi -variable updates are handled without block erase. With the old limit -some variable updates (with device paths) took the block erase code -path. - -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240116171105.37831-5-kraxel@redhat.com> -(cherry picked from commit b25733c97442513890ae6bb8e10fd340f13844a7) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 18 ++++++++++-------- - 1 file changed, 10 insertions(+), 8 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 3d1343b381..3d1d20daa1 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -550,13 +550,15 @@ NorFlashWriteSingleBlock ( - return EFI_BAD_BUFFER_SIZE; - } - -- // Pick P30_MAX_BUFFER_SIZE_IN_BYTES (== 128 bytes) as a good start for word -- // operations as opposed to erasing the block and writing the data regardless -- // if an erase is really needed. It looks like most individual NV variable -- // writes are smaller than 128 bytes. -- // To avoid pathological cases were a 2 byte write is disregarded because it -- // occurs right at a 128 byte buffered write alignment boundary, permit up to -- // twice the max buffer size, and perform two writes if needed. -+ // Pick 4 * P30_MAX_BUFFER_SIZE_IN_BYTES (== 512 bytes) as a good -+ // start for word operations as opposed to erasing the block and -+ // writing the data regardless if an erase is really needed. -+ // -+ // Many NV variable updates are small enough for a a single -+ // P30_MAX_BUFFER_SIZE_IN_BYTES block write. In case the update is -+ // larger than a single block, or the update crosses a -+ // P30_MAX_BUFFER_SIZE_IN_BYTES boundary (as shown in the diagram -+ // below), or both, we might have to write two or more blocks. - // - // 0 128 256 - // [----------------|----------------] -@@ -578,7 +580,7 @@ NorFlashWriteSingleBlock ( - Start = Offset & ~BOUNDARY_OF_32_WORDS; - End = ALIGN_VALUE (Offset + *NumBytes, P30_MAX_BUFFER_SIZE_IN_BYTES); - -- if ((End - Start) <= (2 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { -+ if ((End - Start) <= (4 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { - // Check to see if we need to erase before programming the data into NOR. - // If the destination bits are only changing from 1s to 0s we can just write. - // After a block is erased all bits in the block is set to 1. --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-array-mode-switch-afte.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-array-mode-switch-afte.patch deleted file mode 100644 index fc64a93..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-array-mode-switch-afte.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 20ba071dabad6b0f5663083a017799b7a6e684c5 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 17:34:09 +0200 -Subject: [PATCH 05/18] OvmfPkg/VirtNorFlashDxe: avoid array mode switch after - each word write - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [7/20] 274f2ed71a6d5d3f6497129ee3c62f494cc2f067 - -NorFlashWriteSingleWord() switches into programming mode and back into -array mode for every single word that it writes. Under KVM, this -involves tearing down the read-only memslot, and setting it up again, -which is costly and unnecessary. - -Instead, move the array mode switch into the callers, and only make the -switch when the writing is done. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit ca01e6216a8d1a26c69018e216d1dc3f88a819a4) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 12 +++--------- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 3 +++ - 2 files changed, 6 insertions(+), 9 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index f41d9d372f..0a5c5d48c7 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -205,9 +205,6 @@ NorFlashWriteSingleWord ( - SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER); - } - -- // Put device back into Read Array mode -- SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -- - return Status; - } - -@@ -286,8 +283,7 @@ NorFlashWriteBuffer ( - - // The buffer was not available for writing - if (WaitForBuffer == 0) { -- Status = EFI_DEVICE_ERROR; -- goto EXIT; -+ return EFI_DEVICE_ERROR; - } - - // From now on we work in 32-bit words -@@ -337,10 +333,6 @@ NorFlashWriteBuffer ( - SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER); - } - --EXIT: -- // Put device back into Read Array mode -- SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -- - return Status; - } - -@@ -739,6 +731,8 @@ NorFlashWriteSingleBlock ( - } - - TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite); -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); - if (EFI_ERROR (TempStatus)) { - return EFI_DEVICE_ERROR; - } -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -index 2ceda22635..f9a41f6aab 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -280,6 +280,9 @@ NorFlashWriteFullBlock ( - } - - EXIT: -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ - if (!EfiAtRuntime ()) { - // Interruptions can resume. - gBS->RestoreTPL (OriginalTPL); --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-switching-between-mode.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-switching-between-mode.patch deleted file mode 100644 index 783b96f..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-avoid-switching-between-mode.patch +++ /dev/null @@ -1,303 +0,0 @@ -From 67e26db39c0ec90c164634251da761f649546529 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 17:58:07 +0200 -Subject: [PATCH 06/18] OvmfPkg/VirtNorFlashDxe: avoid switching between modes - in a tight loop - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [8/20] 4923b0fb1586d7955be466b90dce5f790da704ff - -Currently, when dealing with small updates that can be written out -directly (i.e., if they only involve clearing bits and not setting bits, -as the latter requires a block level erase), we iterate over the data -one word at a time, read the old value, compare it, write the new value, -and repeat, unless we encountered a value that we cannot write (0->1 -transition), in which case we fall back to a block level operation. - -This is inefficient for two reasons: -- reading and writing a word at a time involves switching between array -and programming mode for every word of data, which is -disproportionately costly when running under KVM; -- we end up writing some data twice, as we may not notice that a block -erase is needed until after some data has been written to flash. - -So replace this sequence with a single read of up to twice the buffered -write maximum size, followed by one or two buffered writes if the data -can be written directly. Otherwise, fall back to the existing block -level sequence, but without writing out part of the data twice. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 25589c4a76e7e3668fd6f794dd1827e958b6719c) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 214 +++++++++---------------- - 1 file changed, 76 insertions(+), 138 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 0a5c5d48c7..0343131a54 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -576,23 +576,20 @@ NorFlashWriteSingleBlock ( - IN UINT8 *Buffer - ) - { -- EFI_STATUS TempStatus; -- UINT32 Tmp; -- UINT32 TmpBuf; -- UINT32 WordToWrite; -- UINT32 Mask; -- BOOLEAN DoErase; -- UINTN BytesToWrite; -+ EFI_STATUS Status; - UINTN CurOffset; -- UINTN WordAddr; - UINTN BlockSize; - UINTN BlockAddress; -- UINTN PrevBlockAddress; -- -- PrevBlockAddress = 0; -+ UINT8 *OrigData; - - DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); - -+ // Check we did get some memory. Buffer is BlockSize. -+ if (Instance->ShadowBuffer == NULL) { -+ DEBUG ((DEBUG_ERROR, "FvbWrite: ERROR - Buffer not ready\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ - // Cache the block size to avoid de-referencing pointers all the time - BlockSize = Instance->BlockSize; - -@@ -612,148 +609,89 @@ NorFlashWriteSingleBlock ( - return EFI_BAD_BUFFER_SIZE; - } - -- // Pick 128bytes as a good start for word operations as opposed to erasing the -- // block and writing the data regardless if an erase is really needed. -- // It looks like most individual NV variable writes are smaller than 128bytes. -- if (*NumBytes <= 128) { -+ // Pick P30_MAX_BUFFER_SIZE_IN_BYTES (== 128 bytes) as a good start for word -+ // operations as opposed to erasing the block and writing the data regardless -+ // if an erase is really needed. It looks like most individual NV variable -+ // writes are smaller than 128 bytes. -+ // To avoid pathological cases were a 2 byte write is disregarded because it -+ // occurs right at a 128 byte buffered write alignment boundary, permit up to -+ // twice the max buffer size, and perform two writes if needed. -+ if ((*NumBytes + (Offset & BOUNDARY_OF_32_WORDS)) <= (2 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { - // Check to see if we need to erase before programming the data into NOR. - // If the destination bits are only changing from 1s to 0s we can just write. - // After a block is erased all bits in the block is set to 1. - // If any byte requires us to erase we just give up and rewrite all of it. -- DoErase = FALSE; -- BytesToWrite = *NumBytes; -- CurOffset = Offset; -- -- while (BytesToWrite > 0) { -- // Read full word from NOR, splice as required. A word is the smallest -- // unit we can write. -- TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof (Tmp), &Tmp); -- if (EFI_ERROR (TempStatus)) { -- return EFI_DEVICE_ERROR; -- } - -- // Physical address of word in NOR to write. -- WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS ( -- Instance->RegionBaseAddress, -- Lba, -- BlockSize -- ); -- // The word of data that is to be written. -- TmpBuf = *((UINT32 *)(Buffer + (*NumBytes - BytesToWrite))); -- -- // First do word aligned chunks. -- if ((CurOffset & 0x3) == 0) { -- if (BytesToWrite >= 4) { -- // Is the destination still in 'erased' state? -- if (~Tmp != 0) { -- // Check to see if we are only changing bits to zero. -- if ((Tmp ^ TmpBuf) & TmpBuf) { -- DoErase = TRUE; -- break; -- } -- } -- -- // Write this word to NOR -- WordToWrite = TmpBuf; -- CurOffset += sizeof (TmpBuf); -- BytesToWrite -= sizeof (TmpBuf); -- } else { -- // BytesToWrite < 4. Do small writes and left-overs -- Mask = ~((~0) << (BytesToWrite * 8)); -- // Mask out the bytes we want. -- TmpBuf &= Mask; -- // Is the destination still in 'erased' state? -- if ((Tmp & Mask) != Mask) { -- // Check to see if we are only changing bits to zero. -- if ((Tmp ^ TmpBuf) & TmpBuf) { -- DoErase = TRUE; -- break; -- } -- } -- -- // Merge old and new data. Write merged word to NOR -- WordToWrite = (Tmp & ~Mask) | TmpBuf; -- CurOffset += BytesToWrite; -- BytesToWrite = 0; -- } -- } else { -- // Do multiple words, but starting unaligned. -- if (BytesToWrite > (4 - (CurOffset & 0x3))) { -- Mask = ((~0) << ((CurOffset & 0x3) * 8)); -- // Mask out the bytes we want. -- TmpBuf &= Mask; -- // Is the destination still in 'erased' state? -- if ((Tmp & Mask) != Mask) { -- // Check to see if we are only changing bits to zero. -- if ((Tmp ^ TmpBuf) & TmpBuf) { -- DoErase = TRUE; -- break; -- } -- } -- -- // Merge old and new data. Write merged word to NOR -- WordToWrite = (Tmp & ~Mask) | TmpBuf; -- BytesToWrite -= (4 - (CurOffset & 0x3)); -- CurOffset += (4 - (CurOffset & 0x3)); -- } else { -- // Unaligned and fits in one word. -- Mask = (~((~0) << (BytesToWrite * 8))) << ((CurOffset & 0x3) * 8); -- // Mask out the bytes we want. -- TmpBuf = (TmpBuf << ((CurOffset & 0x3) * 8)) & Mask; -- // Is the destination still in 'erased' state? -- if ((Tmp & Mask) != Mask) { -- // Check to see if we are only changing bits to zero. -- if ((Tmp ^ TmpBuf) & TmpBuf) { -- DoErase = TRUE; -- break; -- } -- } -- -- // Merge old and new data. Write merged word to NOR -- WordToWrite = (Tmp & ~Mask) | TmpBuf; -- CurOffset += BytesToWrite; -- BytesToWrite = 0; -- } -+ // Read the old version of the data into the shadow buffer -+ Status = NorFlashRead ( -+ Instance, -+ Lba, -+ Offset & ~BOUNDARY_OF_32_WORDS, -+ (*NumBytes | BOUNDARY_OF_32_WORDS) + 1, -+ Instance->ShadowBuffer -+ ); -+ if (EFI_ERROR (Status)) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Make OrigData point to the start of the old version of the data inside -+ // the word aligned buffer -+ OrigData = Instance->ShadowBuffer + (Offset & BOUNDARY_OF_32_WORDS); -+ -+ // Update the buffer containing the old version of the data with the new -+ // contents, while checking whether the old version had any bits cleared -+ // that we want to set. In that case, we will need to erase the block first. -+ for (CurOffset = 0; CurOffset < *NumBytes; CurOffset++) { -+ if (~OrigData[CurOffset] & Buffer[CurOffset]) { -+ goto DoErase; - } - -- // -- // Write the word to NOR. -- // -+ OrigData[CurOffset] = Buffer[CurOffset]; -+ } - -- BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, BlockSize); -- if (BlockAddress != PrevBlockAddress) { -- TempStatus = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress); -- if (EFI_ERROR (TempStatus)) { -- return EFI_DEVICE_ERROR; -- } -+ // -+ // Write the updated buffer to NOR. -+ // -+ BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, BlockSize); - -- PrevBlockAddress = BlockAddress; -- } -+ // Unlock the block if we have to -+ Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress); -+ if (EFI_ERROR (Status)) { -+ goto Exit; -+ } - -- TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite); -- // Put device back into Read Array mode -- SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -- if (EFI_ERROR (TempStatus)) { -- return EFI_DEVICE_ERROR; -- } -+ Status = NorFlashWriteBuffer ( -+ Instance, -+ BlockAddress + (Offset & ~BOUNDARY_OF_32_WORDS), -+ P30_MAX_BUFFER_SIZE_IN_BYTES, -+ Instance->ShadowBuffer -+ ); -+ if (EFI_ERROR (Status)) { -+ goto Exit; - } - -- // Exit if we got here and could write all the data. Otherwise do the -- // Erase-Write cycle. -- if (!DoErase) { -- return EFI_SUCCESS; -+ if ((*NumBytes + (Offset & BOUNDARY_OF_32_WORDS)) > P30_MAX_BUFFER_SIZE_IN_BYTES) { -+ BlockAddress += P30_MAX_BUFFER_SIZE_IN_BYTES; -+ -+ Status = NorFlashWriteBuffer ( -+ Instance, -+ BlockAddress + (Offset & ~BOUNDARY_OF_32_WORDS), -+ P30_MAX_BUFFER_SIZE_IN_BYTES, -+ Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES -+ ); - } -- } - -- // Check we did get some memory. Buffer is BlockSize. -- if (Instance->ShadowBuffer == NULL) { -- DEBUG ((DEBUG_ERROR, "FvbWrite: ERROR - Buffer not ready\n")); -- return EFI_DEVICE_ERROR; -+Exit: -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ return Status; - } - -+DoErase: - // Read NOR Flash data into shadow buffer -- TempStatus = NorFlashReadBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -- if (EFI_ERROR (TempStatus)) { -+ Status = NorFlashReadBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (Status)) { - // Return one of the pre-approved error statuses - return EFI_DEVICE_ERROR; - } -@@ -762,8 +700,8 @@ NorFlashWriteSingleBlock ( - CopyMem ((VOID *)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes); - - // Write the modified buffer back to the NorFlash -- TempStatus = NorFlashWriteBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -- if (EFI_ERROR (TempStatus)) { -+ Status = NorFlashWriteBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (Status)) { - // Return one of the pre-approved error statuses - return EFI_DEVICE_ERROR; - } --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clarify-block-write-logic-fi.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clarify-block-write-logic-fi.patch deleted file mode 100644 index 0ac5c14..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clarify-block-write-logic-fi.patch +++ /dev/null @@ -1,110 +0,0 @@ -From f136d4895b1477a56b916a76448ba76e67b08163 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:01 +0100 -Subject: [PATCH 12/18] OvmfPkg/VirtNorFlashDxe: clarify block write logic & - fix shadowbuffer reads - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [14/20] 38009625e5f189166f7a93e236576140a7ccb393 - -Introduce 'Start' and 'End' variables to make it easier to follow the -logic and code flow. Also add a ascii art diagram (based on a -suggestion by Laszlo). - -This also fixes the 'Size' calculation for the NorFlashRead() call. -Without this patch the code will read only one instead of two -P30_MAX_BUFFER_SIZE_IN_BYTES blocks in case '*NumBytes' is smaller than -P30_MAX_BUFFER_SIZE_IN_BYTES but 'Offset + *NumBytes' is not, i.e. the -update range crosses a P30_MAX_BUFFER_SIZE_IN_BYTES boundary. - -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240116171105.37831-3-kraxel@redhat.com> -(cherry picked from commit 35d8ea8097794b522149688b5cfaf8364bc44d54) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 36 ++++++++++++++++++++------ - 1 file changed, 28 insertions(+), 8 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 7f4743b003..88a4d2c23f 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -520,6 +520,7 @@ NorFlashWriteSingleBlock ( - UINTN BlockSize; - UINTN BlockAddress; - UINT8 *OrigData; -+ UINTN Start, End; - - DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); - -@@ -555,7 +556,28 @@ NorFlashWriteSingleBlock ( - // To avoid pathological cases were a 2 byte write is disregarded because it - // occurs right at a 128 byte buffered write alignment boundary, permit up to - // twice the max buffer size, and perform two writes if needed. -- if ((*NumBytes + (Offset & BOUNDARY_OF_32_WORDS)) <= (2 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { -+ // -+ // 0 128 256 -+ // [----------------|----------------] -+ // ^ ^ ^ ^ -+ // | | | | -+ // | | | End, the next "word" boundary beyond -+ // | | | the (logical) update -+ // | | | -+ // | | (Offset & BOUNDARY_OF_32_WORDS) + NumBytes; -+ // | | i.e., the relative offset inside (or just past) -+ // | | the *double-word* such that it is the -+ // | | *exclusive* end of the (logical) update. -+ // | | -+ // | Offset & BOUNDARY_OF_32_WORDS; i.e., Offset within the "word"; -+ // | this is where the (logical) update is supposed to start -+ // | -+ // Start = Offset & ~BOUNDARY_OF_32_WORDS; i.e., Offset truncated to "word" boundary -+ -+ Start = Offset & ~BOUNDARY_OF_32_WORDS; -+ End = ALIGN_VALUE (Offset + *NumBytes, P30_MAX_BUFFER_SIZE_IN_BYTES); -+ -+ if ((End - Start) <= (2 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { - // Check to see if we need to erase before programming the data into NOR. - // If the destination bits are only changing from 1s to 0s we can just write. - // After a block is erased all bits in the block is set to 1. -@@ -565,8 +587,8 @@ NorFlashWriteSingleBlock ( - Status = NorFlashRead ( - Instance, - Lba, -- Offset & ~BOUNDARY_OF_32_WORDS, -- (*NumBytes | BOUNDARY_OF_32_WORDS) + 1, -+ Start, -+ End - Start, - Instance->ShadowBuffer - ); - if (EFI_ERROR (Status)) { -@@ -601,7 +623,7 @@ NorFlashWriteSingleBlock ( - - Status = NorFlashWriteBuffer ( - Instance, -- BlockAddress + (Offset & ~BOUNDARY_OF_32_WORDS), -+ BlockAddress + Start, - P30_MAX_BUFFER_SIZE_IN_BYTES, - Instance->ShadowBuffer - ); -@@ -609,12 +631,10 @@ NorFlashWriteSingleBlock ( - goto Exit; - } - -- if ((*NumBytes + (Offset & BOUNDARY_OF_32_WORDS)) > P30_MAX_BUFFER_SIZE_IN_BYTES) { -- BlockAddress += P30_MAX_BUFFER_SIZE_IN_BYTES; -- -+ if ((End - Start) > P30_MAX_BUFFER_SIZE_IN_BYTES) { - Status = NorFlashWriteBuffer ( - Instance, -- BlockAddress + (Offset & ~BOUNDARY_OF_32_WORDS), -+ BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES, - P30_MAX_BUFFER_SIZE_IN_BYTES, - Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES - ); --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clone-ArmPlatformPkg-s-NOR-f.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clone-ArmPlatformPkg-s-NOR-f.patch deleted file mode 100644 index 41975ab..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-clone-ArmPlatformPkg-s-NOR-f.patch +++ /dev/null @@ -1,2973 +0,0 @@ -From 3d6a0e0d3323c8b98a56e69ed01b6634dd480f25 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 16:41:43 +0200 -Subject: [PATCH 01/18] OvmfPkg/VirtNorFlashDxe: clone ArmPlatformPkg's NOR - flash driver - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [3/20] f78caae529b7f943a5d4838cb906546373de4c54 - -QEMU's mach-virt is loosely based on ARM Versatile Express, and inherits -its NOR flash driver, which is now being used on other QEMU emulated -architectures as well. - -In order to permit ourselves the freedom to optimize this driver for -use under KVM emulation, let's clone it into OvmfPkg, so we have a -version we can hack without the risk of regressing bare metal platforms. - -The cloned version is mostly identical to the original, but it depends -on the newly added VirtNorFlashPlatformLib library class instead of the -original one from ArmPlatformPkg. Beyond that, only cosmetic changes -related to #include order etc were made. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit c1ff81f7990be88c9e98ca3be65178057d8aae77) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 991 ++++++++++++++++++ - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h | 422 ++++++++ - .../VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c | 123 +++ - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 506 +++++++++ - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf | 72 ++ - OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 777 ++++++++++++++ - 6 files changed, 2891 insertions(+) - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf - create mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -new file mode 100644 -index 0000000000..12fa720dad ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -0,0 +1,991 @@ -+/** @file NorFlash.c -+ -+ Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.
-+ Copyright (c) 2020, Linaro, Ltd. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#include -+ -+#include "VirtNorFlash.h" -+ -+// -+// Global variable declarations -+// -+extern NOR_FLASH_INSTANCE **mNorFlashInstances; -+extern UINT32 mNorFlashDeviceCount; -+ -+UINT32 -+NorFlashReadStatusRegister ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN SR_Address -+ ) -+{ -+ // Prepare to read the status register -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_STATUS_REGISTER); -+ return MmioRead32 (Instance->DeviceBaseAddress); -+} -+ -+STATIC -+BOOLEAN -+NorFlashBlockIsLocked ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ) -+{ -+ UINT32 LockStatus; -+ -+ // Send command for reading device id -+ SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID); -+ -+ // Read block lock status -+ LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2)); -+ -+ // Decode block lock status -+ LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus); -+ -+ if ((LockStatus & 0x2) != 0) { -+ DEBUG ((DEBUG_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED DOWN\n")); -+ } -+ -+ return ((LockStatus & 0x1) != 0); -+} -+ -+STATIC -+EFI_STATUS -+NorFlashUnlockSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ) -+{ -+ UINT32 LockStatus; -+ -+ // Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations -+ // and to protect shared data structures. -+ -+ if (FeaturePcdGet (PcdNorFlashCheckBlockLocked) == TRUE) { -+ do { -+ // Request a lock setup -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP); -+ -+ // Request an unlock -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK); -+ -+ // Send command for reading device id -+ SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID); -+ -+ // Read block lock status -+ LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2)); -+ -+ // Decode block lock status -+ LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus); -+ } while ((LockStatus & 0x1) == 1); -+ } else { -+ // Request a lock setup -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP); -+ -+ // Request an unlock -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK); -+ -+ // Wait until the status register gives us the all clear -+ do { -+ LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress); -+ } while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); -+ } -+ -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY); -+ -+ DEBUG ((DEBUG_BLKIO, "UnlockSingleBlock: BlockAddress=0x%08x\n", BlockAddress)); -+ -+ return EFI_SUCCESS; -+} -+ -+EFI_STATUS -+NorFlashUnlockSingleBlockIfNecessary ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ) -+{ -+ EFI_STATUS Status; -+ -+ Status = EFI_SUCCESS; -+ -+ if (NorFlashBlockIsLocked (Instance, BlockAddress)) { -+ Status = NorFlashUnlockSingleBlock (Instance, BlockAddress); -+ } -+ -+ return Status; -+} -+ -+/** -+ * The following function presumes that the block has already been unlocked. -+ **/ -+EFI_STATUS -+NorFlashEraseSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 StatusRegister; -+ -+ Status = EFI_SUCCESS; -+ -+ // Request a block erase and then confirm it -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_SETUP); -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_BLOCK_ERASE_CONFIRM); -+ -+ // Wait until the status register gives us the all clear -+ do { -+ StatusRegister = NorFlashReadStatusRegister (Instance, BlockAddress); -+ } while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); -+ -+ if (StatusRegister & P30_SR_BIT_VPP) { -+ DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: VPP Range Error\n", BlockAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if ((StatusRegister & (P30_SR_BIT_ERASE | P30_SR_BIT_PROGRAM)) == (P30_SR_BIT_ERASE | P30_SR_BIT_PROGRAM)) { -+ DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Command Sequence Error\n", BlockAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_ERASE) { -+ DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Block Erase Error StatusRegister:0x%X\n", BlockAddress, StatusRegister)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) { -+ // The debug level message has been reduced because a device lock might happen. In this case we just retry it ... -+ DEBUG ((DEBUG_INFO, "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error\n", BlockAddress)); -+ Status = EFI_WRITE_PROTECTED; -+ } -+ -+ if (EFI_ERROR (Status)) { -+ // Clear the Status Register -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER); -+ } -+ -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ return Status; -+} -+ -+EFI_STATUS -+NorFlashWriteSingleWord ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN WordAddress, -+ IN UINT32 WriteData -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 StatusRegister; -+ -+ Status = EFI_SUCCESS; -+ -+ // Request a write single word command -+ SEND_NOR_COMMAND (WordAddress, 0, P30_CMD_WORD_PROGRAM_SETUP); -+ -+ // Store the word into NOR Flash; -+ MmioWrite32 (WordAddress, WriteData); -+ -+ // Wait for the write to complete and then check for any errors; i.e. check the Status Register -+ do { -+ // Prepare to read the status register -+ StatusRegister = NorFlashReadStatusRegister (Instance, WordAddress); -+ // The chip is busy while the WRITE bit is not asserted -+ } while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); -+ -+ // Perform a full status check: -+ // Mask the relevant bits of Status Register. -+ // Everything should be zero, if not, we have a problem -+ -+ if (StatusRegister & P30_SR_BIT_VPP) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): VPP Range Error\n", WordAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_PROGRAM) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): Program Error\n", WordAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleWord(WordAddress:0x%X): Device Protect Error\n", WordAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (!EFI_ERROR (Status)) { -+ // Clear the Status Register -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER); -+ } -+ -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ return Status; -+} -+ -+/* -+ * Writes data to the NOR Flash using the Buffered Programming method. -+ * -+ * The maximum size of the on-chip buffer is 32-words, because of hardware restrictions. -+ * Therefore this function will only handle buffers up to 32 words or 128 bytes. -+ * To deal with larger buffers, call this function again. -+ * -+ * This function presumes that both the TargetAddress and the TargetAddress+BufferSize -+ * exist entirely within the NOR Flash. Therefore these conditions will not be checked here. -+ * -+ * In buffered programming, if the target address not at the beginning of a 32-bit word boundary, -+ * then programming time is doubled and power consumption is increased. -+ * Therefore, it is a requirement to align buffer writes to 32-bit word boundaries. -+ * i.e. the last 4 bits of the target start address must be zero: 0x......00 -+ */ -+EFI_STATUS -+NorFlashWriteBuffer ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN TargetAddress, -+ IN UINTN BufferSizeInBytes, -+ IN UINT32 *Buffer -+ ) -+{ -+ EFI_STATUS Status; -+ UINTN BufferSizeInWords; -+ UINTN Count; -+ volatile UINT32 *Data; -+ UINTN WaitForBuffer; -+ BOOLEAN BufferAvailable; -+ UINT32 StatusRegister; -+ -+ WaitForBuffer = MAX_BUFFERED_PROG_ITERATIONS; -+ BufferAvailable = FALSE; -+ -+ // Check that the target address does not cross a 32-word boundary. -+ if ((TargetAddress & BOUNDARY_OF_32_WORDS) != 0) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Check there are some data to program -+ if (BufferSizeInBytes == 0) { -+ return EFI_BUFFER_TOO_SMALL; -+ } -+ -+ // Check that the buffer size does not exceed the maximum hardware buffer size on chip. -+ if (BufferSizeInBytes > P30_MAX_BUFFER_SIZE_IN_BYTES) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Check that the buffer size is a multiple of 32-bit words -+ if ((BufferSizeInBytes % 4) != 0) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Pre-programming conditions checked, now start the algorithm. -+ -+ // Prepare the data destination address -+ Data = (UINT32 *)TargetAddress; -+ -+ // Check the availability of the buffer -+ do { -+ // Issue the Buffered Program Setup command -+ SEND_NOR_COMMAND (TargetAddress, 0, P30_CMD_BUFFERED_PROGRAM_SETUP); -+ -+ // Read back the status register bit#7 from the same address -+ if (((*Data) & P30_SR_BIT_WRITE) == P30_SR_BIT_WRITE) { -+ BufferAvailable = TRUE; -+ } -+ -+ // Update the loop counter -+ WaitForBuffer--; -+ } while ((WaitForBuffer > 0) && (BufferAvailable == FALSE)); -+ -+ // The buffer was not available for writing -+ if (WaitForBuffer == 0) { -+ Status = EFI_DEVICE_ERROR; -+ goto EXIT; -+ } -+ -+ // From now on we work in 32-bit words -+ BufferSizeInWords = BufferSizeInBytes / (UINTN)4; -+ -+ // Write the word count, which is (buffer_size_in_words - 1), -+ // because word count 0 means one word. -+ SEND_NOR_COMMAND (TargetAddress, 0, (BufferSizeInWords - 1)); -+ -+ // Write the data to the NOR Flash, advancing each address by 4 bytes -+ for (Count = 0; Count < BufferSizeInWords; Count++, Data++, Buffer++) { -+ MmioWrite32 ((UINTN)Data, *Buffer); -+ } -+ -+ // Issue the Buffered Program Confirm command, to start the programming operation -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_BUFFERED_PROGRAM_CONFIRM); -+ -+ // Wait for the write to complete and then check for any errors; i.e. check the Status Register -+ do { -+ StatusRegister = NorFlashReadStatusRegister (Instance, TargetAddress); -+ // The chip is busy while the WRITE bit is not asserted -+ } while ((StatusRegister & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); -+ -+ // Perform a full status check: -+ // Mask the relevant bits of Status Register. -+ // Everything should be zero, if not, we have a problem -+ -+ Status = EFI_SUCCESS; -+ -+ if (StatusRegister & P30_SR_BIT_VPP) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): VPP Range Error\n", TargetAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_PROGRAM) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): Program Error\n", TargetAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (StatusRegister & P30_SR_BIT_BLOCK_LOCKED) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteBuffer(TargetAddress:0x%X): Device Protect Error\n", TargetAddress)); -+ Status = EFI_DEVICE_ERROR; -+ } -+ -+ if (!EFI_ERROR (Status)) { -+ // Clear the Status Register -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_CLEAR_STATUS_REGISTER); -+ } -+ -+EXIT: -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ return Status; -+} -+ -+EFI_STATUS -+NorFlashWriteBlocks ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ IN VOID *Buffer -+ ) -+{ -+ UINT32 *pWriteBuffer; -+ EFI_STATUS Status; -+ EFI_LBA CurrentBlock; -+ UINT32 BlockSizeInWords; -+ UINT32 NumBlocks; -+ UINT32 BlockCount; -+ -+ Status = EFI_SUCCESS; -+ -+ // The buffer must be valid -+ if (Buffer == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (Instance->Media.ReadOnly == TRUE) { -+ return EFI_WRITE_PROTECTED; -+ } -+ -+ // We must have some bytes to read -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", BufferSizeInBytes)); -+ if (BufferSizeInBytes == 0) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // The size of the buffer must be a multiple of the block size -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", Instance->Media.BlockSize)); -+ if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // All blocks must be within the device -+ NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize; -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, Instance->Media.LastBlock, Lba)); -+ -+ if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ BlockSizeInWords = Instance->Media.BlockSize / 4; -+ -+ // Because the target *Buffer is a pointer to VOID, we must put all the data into a pointer -+ // to a proper data type, so use *ReadBuffer -+ pWriteBuffer = (UINT32 *)Buffer; -+ -+ CurrentBlock = Lba; -+ for (BlockCount = 0; BlockCount < NumBlocks; BlockCount++, CurrentBlock++, pWriteBuffer = pWriteBuffer + BlockSizeInWords) { -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Writing block #%d\n", (UINTN)CurrentBlock)); -+ -+ Status = NorFlashWriteFullBlock (Instance, CurrentBlock, pWriteBuffer, BlockSizeInWords); -+ -+ if (EFI_ERROR (Status)) { -+ break; -+ } -+ } -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: Exit Status = \"%r\".\n", Status)); -+ return Status; -+} -+ -+#define BOTH_ALIGNED(a, b, align) ((((UINTN)(a) | (UINTN)(b)) & ((align) - 1)) == 0) -+ -+/** -+ Copy Length bytes from Source to Destination, using aligned accesses only. -+ Note that this implementation uses memcpy() semantics rather then memmove() -+ semantics, i.e., SourceBuffer and DestinationBuffer should not overlap. -+ -+ @param DestinationBuffer The target of the copy request. -+ @param SourceBuffer The place to copy from. -+ @param Length The number of bytes to copy. -+ -+ @return Destination -+ -+**/ -+STATIC -+VOID * -+AlignedCopyMem ( -+ OUT VOID *DestinationBuffer, -+ IN CONST VOID *SourceBuffer, -+ IN UINTN Length -+ ) -+{ -+ UINT8 *Destination8; -+ CONST UINT8 *Source8; -+ UINT32 *Destination32; -+ CONST UINT32 *Source32; -+ UINT64 *Destination64; -+ CONST UINT64 *Source64; -+ -+ if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 8) && (Length >= 8)) { -+ Destination64 = DestinationBuffer; -+ Source64 = SourceBuffer; -+ while (Length >= 8) { -+ *Destination64++ = *Source64++; -+ Length -= 8; -+ } -+ -+ Destination8 = (UINT8 *)Destination64; -+ Source8 = (CONST UINT8 *)Source64; -+ } else if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 4) && (Length >= 4)) { -+ Destination32 = DestinationBuffer; -+ Source32 = SourceBuffer; -+ while (Length >= 4) { -+ *Destination32++ = *Source32++; -+ Length -= 4; -+ } -+ -+ Destination8 = (UINT8 *)Destination32; -+ Source8 = (CONST UINT8 *)Source32; -+ } else { -+ Destination8 = DestinationBuffer; -+ Source8 = SourceBuffer; -+ } -+ -+ while (Length-- != 0) { -+ *Destination8++ = *Source8++; -+ } -+ -+ return DestinationBuffer; -+} -+ -+EFI_STATUS -+NorFlashReadBlocks ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ) -+{ -+ UINT32 NumBlocks; -+ UINTN StartAddress; -+ -+ DEBUG (( -+ DEBUG_BLKIO, -+ "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n", -+ BufferSizeInBytes, -+ Instance->Media.BlockSize, -+ Instance->Media.LastBlock, -+ Lba -+ )); -+ -+ // The buffer must be valid -+ if (Buffer == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Return if we have not any byte to read -+ if (BufferSizeInBytes == 0) { -+ return EFI_SUCCESS; -+ } -+ -+ // The size of the buffer must be a multiple of the block size -+ if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // All blocks must be within the device -+ NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize; -+ -+ if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { -+ DEBUG ((DEBUG_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Get the address to start reading from -+ StartAddress = GET_NOR_BLOCK_ADDRESS ( -+ Instance->RegionBaseAddress, -+ Lba, -+ Instance->Media.BlockSize -+ ); -+ -+ // Put the device into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ // Readout the data -+ AlignedCopyMem (Buffer, (VOID *)StartAddress, BufferSizeInBytes); -+ -+ return EFI_SUCCESS; -+} -+ -+EFI_STATUS -+NorFlashRead ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ) -+{ -+ UINTN StartAddress; -+ -+ // The buffer must be valid -+ if (Buffer == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Return if we have not any byte to read -+ if (BufferSizeInBytes == 0) { -+ return EFI_SUCCESS; -+ } -+ -+ if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > Instance->Size) { -+ DEBUG ((DEBUG_ERROR, "NorFlashRead: ERROR - Read will exceed device size.\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Get the address to start reading from -+ StartAddress = GET_NOR_BLOCK_ADDRESS ( -+ Instance->RegionBaseAddress, -+ Lba, -+ Instance->Media.BlockSize -+ ); -+ -+ // Put the device into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ -+ // Readout the data -+ AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes); -+ -+ return EFI_SUCCESS; -+} -+ -+/* -+ Write a full or portion of a block. It must not span block boundaries; that is, -+ Offset + *NumBytes <= Instance->Media.BlockSize. -+*/ -+EFI_STATUS -+NorFlashWriteSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ) -+{ -+ EFI_STATUS TempStatus; -+ UINT32 Tmp; -+ UINT32 TmpBuf; -+ UINT32 WordToWrite; -+ UINT32 Mask; -+ BOOLEAN DoErase; -+ UINTN BytesToWrite; -+ UINTN CurOffset; -+ UINTN WordAddr; -+ UINTN BlockSize; -+ UINTN BlockAddress; -+ UINTN PrevBlockAddress; -+ -+ PrevBlockAddress = 0; -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); -+ -+ // Detect WriteDisabled state -+ if (Instance->Media.ReadOnly == TRUE) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - Can not write: Device is in WriteDisabled state.\n")); -+ // It is in WriteDisabled state, return an error right away -+ return EFI_ACCESS_DENIED; -+ } -+ -+ // Cache the block size to avoid de-referencing pointers all the time -+ BlockSize = Instance->Media.BlockSize; -+ -+ // The write must not span block boundaries. -+ // We need to check each variable individually because adding two large values together overflows. -+ if ((Offset >= BlockSize) || -+ (*NumBytes > BlockSize) || -+ ((Offset + *NumBytes) > BlockSize)) -+ { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize)); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // We must have some bytes to write -+ if (*NumBytes == 0) { -+ DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize)); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Pick 128bytes as a good start for word operations as opposed to erasing the -+ // block and writing the data regardless if an erase is really needed. -+ // It looks like most individual NV variable writes are smaller than 128bytes. -+ if (*NumBytes <= 128) { -+ // Check to see if we need to erase before programming the data into NOR. -+ // If the destination bits are only changing from 1s to 0s we can just write. -+ // After a block is erased all bits in the block is set to 1. -+ // If any byte requires us to erase we just give up and rewrite all of it. -+ DoErase = FALSE; -+ BytesToWrite = *NumBytes; -+ CurOffset = Offset; -+ -+ while (BytesToWrite > 0) { -+ // Read full word from NOR, splice as required. A word is the smallest -+ // unit we can write. -+ TempStatus = NorFlashRead (Instance, Lba, CurOffset & ~(0x3), sizeof (Tmp), &Tmp); -+ if (EFI_ERROR (TempStatus)) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Physical address of word in NOR to write. -+ WordAddr = (CurOffset & ~(0x3)) + GET_NOR_BLOCK_ADDRESS ( -+ Instance->RegionBaseAddress, -+ Lba, -+ BlockSize -+ ); -+ // The word of data that is to be written. -+ TmpBuf = *((UINT32 *)(Buffer + (*NumBytes - BytesToWrite))); -+ -+ // First do word aligned chunks. -+ if ((CurOffset & 0x3) == 0) { -+ if (BytesToWrite >= 4) { -+ // Is the destination still in 'erased' state? -+ if (~Tmp != 0) { -+ // Check to see if we are only changing bits to zero. -+ if ((Tmp ^ TmpBuf) & TmpBuf) { -+ DoErase = TRUE; -+ break; -+ } -+ } -+ -+ // Write this word to NOR -+ WordToWrite = TmpBuf; -+ CurOffset += sizeof (TmpBuf); -+ BytesToWrite -= sizeof (TmpBuf); -+ } else { -+ // BytesToWrite < 4. Do small writes and left-overs -+ Mask = ~((~0) << (BytesToWrite * 8)); -+ // Mask out the bytes we want. -+ TmpBuf &= Mask; -+ // Is the destination still in 'erased' state? -+ if ((Tmp & Mask) != Mask) { -+ // Check to see if we are only changing bits to zero. -+ if ((Tmp ^ TmpBuf) & TmpBuf) { -+ DoErase = TRUE; -+ break; -+ } -+ } -+ -+ // Merge old and new data. Write merged word to NOR -+ WordToWrite = (Tmp & ~Mask) | TmpBuf; -+ CurOffset += BytesToWrite; -+ BytesToWrite = 0; -+ } -+ } else { -+ // Do multiple words, but starting unaligned. -+ if (BytesToWrite > (4 - (CurOffset & 0x3))) { -+ Mask = ((~0) << ((CurOffset & 0x3) * 8)); -+ // Mask out the bytes we want. -+ TmpBuf &= Mask; -+ // Is the destination still in 'erased' state? -+ if ((Tmp & Mask) != Mask) { -+ // Check to see if we are only changing bits to zero. -+ if ((Tmp ^ TmpBuf) & TmpBuf) { -+ DoErase = TRUE; -+ break; -+ } -+ } -+ -+ // Merge old and new data. Write merged word to NOR -+ WordToWrite = (Tmp & ~Mask) | TmpBuf; -+ BytesToWrite -= (4 - (CurOffset & 0x3)); -+ CurOffset += (4 - (CurOffset & 0x3)); -+ } else { -+ // Unaligned and fits in one word. -+ Mask = (~((~0) << (BytesToWrite * 8))) << ((CurOffset & 0x3) * 8); -+ // Mask out the bytes we want. -+ TmpBuf = (TmpBuf << ((CurOffset & 0x3) * 8)) & Mask; -+ // Is the destination still in 'erased' state? -+ if ((Tmp & Mask) != Mask) { -+ // Check to see if we are only changing bits to zero. -+ if ((Tmp ^ TmpBuf) & TmpBuf) { -+ DoErase = TRUE; -+ break; -+ } -+ } -+ -+ // Merge old and new data. Write merged word to NOR -+ WordToWrite = (Tmp & ~Mask) | TmpBuf; -+ CurOffset += BytesToWrite; -+ BytesToWrite = 0; -+ } -+ } -+ -+ // -+ // Write the word to NOR. -+ // -+ -+ BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, BlockSize); -+ if (BlockAddress != PrevBlockAddress) { -+ TempStatus = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress); -+ if (EFI_ERROR (TempStatus)) { -+ return EFI_DEVICE_ERROR; -+ } -+ -+ PrevBlockAddress = BlockAddress; -+ } -+ -+ TempStatus = NorFlashWriteSingleWord (Instance, WordAddr, WordToWrite); -+ if (EFI_ERROR (TempStatus)) { -+ return EFI_DEVICE_ERROR; -+ } -+ } -+ -+ // Exit if we got here and could write all the data. Otherwise do the -+ // Erase-Write cycle. -+ if (!DoErase) { -+ return EFI_SUCCESS; -+ } -+ } -+ -+ // Check we did get some memory. Buffer is BlockSize. -+ if (Instance->ShadowBuffer == NULL) { -+ DEBUG ((DEBUG_ERROR, "FvbWrite: ERROR - Buffer not ready\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Read NOR Flash data into shadow buffer -+ TempStatus = NorFlashReadBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (TempStatus)) { -+ // Return one of the pre-approved error statuses -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Put the data at the appropriate location inside the buffer area -+ CopyMem ((VOID *)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes); -+ -+ // Write the modified buffer back to the NorFlash -+ TempStatus = NorFlashWriteBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (TempStatus)) { -+ // Return one of the pre-approved error statuses -+ return EFI_DEVICE_ERROR; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/* -+ Although DiskIoDxe will automatically install the DiskIO protocol whenever -+ we install the BlockIO protocol, its implementation is sub-optimal as it reads -+ and writes entire blocks using the BlockIO protocol. In fact we can access -+ NOR flash with a finer granularity than that, so we can improve performance -+ by directly producing the DiskIO protocol. -+*/ -+ -+/** -+ Read BufferSize bytes from Offset into Buffer. -+ -+ @param This Protocol instance pointer. -+ @param MediaId Id of the media, changes every time the media is replaced. -+ @param Offset The starting byte offset to read from -+ @param BufferSize Size of Buffer -+ @param Buffer Buffer containing read data -+ -+ @retval EFI_SUCCESS The data was read correctly from the device. -+ @retval EFI_DEVICE_ERROR The device reported an error while performing the read. -+ @retval EFI_NO_MEDIA There is no media in the device. -+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. -+ @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not -+ valid for the device. -+ -+**/ -+EFI_STATUS -+EFIAPI -+NorFlashDiskIoReadDisk ( -+ IN EFI_DISK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN UINT64 DiskOffset, -+ IN UINTN BufferSize, -+ OUT VOID *Buffer -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ UINT32 BlockSize; -+ UINT32 BlockOffset; -+ EFI_LBA Lba; -+ -+ Instance = INSTANCE_FROM_DISKIO_THIS (This); -+ -+ if (MediaId != Instance->Media.MediaId) { -+ return EFI_MEDIA_CHANGED; -+ } -+ -+ BlockSize = Instance->Media.BlockSize; -+ Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); -+ -+ return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer); -+} -+ -+/** -+ Writes a specified number of bytes to a device. -+ -+ @param This Indicates a pointer to the calling context. -+ @param MediaId ID of the medium to be written. -+ @param Offset The starting byte offset on the logical block I/O device to write. -+ @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device. -+ @param Buffer A pointer to the buffer containing the data to be written. -+ -+ @retval EFI_SUCCESS The data was written correctly to the device. -+ @retval EFI_WRITE_PROTECTED The device can not be written to. -+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write. -+ @retval EFI_NO_MEDIA There is no media in the device. -+ @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. -+ @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not -+ valid for the device. -+ -+**/ -+EFI_STATUS -+EFIAPI -+NorFlashDiskIoWriteDisk ( -+ IN EFI_DISK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN UINT64 DiskOffset, -+ IN UINTN BufferSize, -+ IN VOID *Buffer -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ UINT32 BlockSize; -+ UINT32 BlockOffset; -+ EFI_LBA Lba; -+ UINTN RemainingBytes; -+ UINTN WriteSize; -+ EFI_STATUS Status; -+ -+ Instance = INSTANCE_FROM_DISKIO_THIS (This); -+ -+ if (MediaId != Instance->Media.MediaId) { -+ return EFI_MEDIA_CHANGED; -+ } -+ -+ BlockSize = Instance->Media.BlockSize; -+ Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); -+ -+ RemainingBytes = BufferSize; -+ -+ // Write either all the remaining bytes, or the number of bytes that bring -+ // us up to a block boundary, whichever is less. -+ // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the next -+ // block boundary (even if it is already on one). -+ WriteSize = MIN (RemainingBytes, ((DiskOffset | (BlockSize - 1)) + 1) - DiskOffset); -+ -+ do { -+ if (WriteSize == BlockSize) { -+ // Write a full block -+ Status = NorFlashWriteFullBlock (Instance, Lba, Buffer, BlockSize / sizeof (UINT32)); -+ } else { -+ // Write a partial block -+ Status = NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &WriteSize, Buffer); -+ } -+ -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ // Now continue writing either all the remaining bytes or single blocks. -+ RemainingBytes -= WriteSize; -+ Buffer = (UINT8 *)Buffer + WriteSize; -+ Lba++; -+ BlockOffset = 0; -+ WriteSize = MIN (RemainingBytes, BlockSize); -+ } while (RemainingBytes); -+ -+ return Status; -+} -+ -+EFI_STATUS -+NorFlashReset ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ) -+{ -+ // As there is no specific RESET to perform, ensure that the devices is in the default Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -+ return EFI_SUCCESS; -+} -+ -+/** -+ Fixup internal data so that EFI can be call in virtual mode. -+ Call the passed in Child Notify event and convert any pointers in -+ lib to virtual mode. -+ -+ @param[in] Event The Event that is being processed -+ @param[in] Context Event Context -+**/ -+VOID -+EFIAPI -+NorFlashVirtualNotifyEvent ( -+ IN EFI_EVENT Event, -+ IN VOID *Context -+ ) -+{ -+ UINTN Index; -+ -+ for (Index = 0; Index < mNorFlashDeviceCount; Index++) { -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->DeviceBaseAddress); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->RegionBaseAddress); -+ -+ // Convert BlockIo protocol -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.Reset); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks); -+ -+ // Convert Fvb -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetAttributes); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetBlockSize); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetPhysicalAddress); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.Read); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.SetAttributes); -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.Write); -+ -+ if (mNorFlashInstances[Index]->ShadowBuffer != NULL) { -+ EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->ShadowBuffer); -+ } -+ } -+ -+ return; -+} -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -new file mode 100644 -index 0000000000..e46522a198 ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -@@ -0,0 +1,422 @@ -+/** @file NorFlash.h -+ -+ Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#ifndef __VIRT_NOR_FLASH__ -+#define __VIRT_NOR_FLASH__ -+ -+#include -+#include -+ -+#include -+ -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+ -+#define NOR_FLASH_ERASE_RETRY 10 -+ -+// Device access macros -+// These are necessary because we use 2 x 16bit parts to make up 32bit data -+ -+#define HIGH_16_BITS 0xFFFF0000 -+#define LOW_16_BITS 0x0000FFFF -+#define LOW_8_BITS 0x000000FF -+ -+#define FOLD_32BIT_INTO_16BIT(value) ( ( value >> 16 ) | ( value & LOW_16_BITS ) ) -+ -+#define GET_LOW_BYTE(value) ( value & LOW_8_BITS ) -+#define GET_HIGH_BYTE(value) ( GET_LOW_BYTE( value >> 16 ) ) -+ -+// Each command must be sent simultaneously to both chips, -+// i.e. at the lower 16 bits AND at the higher 16 bits -+#define CREATE_NOR_ADDRESS(BaseAddr, OffsetAddr) ((BaseAddr) + ((OffsetAddr) << 2)) -+#define CREATE_DUAL_CMD(Cmd) ( ( Cmd << 16) | ( Cmd & LOW_16_BITS) ) -+#define SEND_NOR_COMMAND(BaseAddr, Offset, Cmd) MmioWrite32 (CREATE_NOR_ADDRESS(BaseAddr,Offset), CREATE_DUAL_CMD(Cmd)) -+#define GET_NOR_BLOCK_ADDRESS(BaseAddr, Lba, LbaSize) ( BaseAddr + (UINTN)((Lba) * LbaSize) ) -+ -+// Status Register Bits -+#define P30_SR_BIT_WRITE (BIT7 << 16 | BIT7) -+#define P30_SR_BIT_ERASE_SUSPEND (BIT6 << 16 | BIT6) -+#define P30_SR_BIT_ERASE (BIT5 << 16 | BIT5) -+#define P30_SR_BIT_PROGRAM (BIT4 << 16 | BIT4) -+#define P30_SR_BIT_VPP (BIT3 << 16 | BIT3) -+#define P30_SR_BIT_PROGRAM_SUSPEND (BIT2 << 16 | BIT2) -+#define P30_SR_BIT_BLOCK_LOCKED (BIT1 << 16 | BIT1) -+#define P30_SR_BIT_BEFP (BIT0 << 16 | BIT0) -+ -+// Device Commands for Intel StrataFlash(R) Embedded Memory (P30) Family -+ -+// On chip buffer size for buffered programming operations -+// There are 2 chips, each chip can buffer up to 32 (16-bit)words, and each word is 2 bytes. -+// Therefore the total size of the buffer is 2 x 32 x 2 = 128 bytes -+#define P30_MAX_BUFFER_SIZE_IN_BYTES ((UINTN)128) -+#define P30_MAX_BUFFER_SIZE_IN_WORDS (P30_MAX_BUFFER_SIZE_IN_BYTES/((UINTN)4)) -+#define MAX_BUFFERED_PROG_ITERATIONS 10000000 -+#define BOUNDARY_OF_32_WORDS 0x7F -+ -+// CFI Addresses -+#define P30_CFI_ADDR_QUERY_UNIQUE_QRY 0x10 -+#define P30_CFI_ADDR_VENDOR_ID 0x13 -+ -+// CFI Data -+#define CFI_QRY 0x00595251 -+ -+// READ Commands -+#define P30_CMD_READ_DEVICE_ID 0x0090 -+#define P30_CMD_READ_STATUS_REGISTER 0x0070 -+#define P30_CMD_CLEAR_STATUS_REGISTER 0x0050 -+#define P30_CMD_READ_ARRAY 0x00FF -+#define P30_CMD_READ_CFI_QUERY 0x0098 -+ -+// WRITE Commands -+#define P30_CMD_WORD_PROGRAM_SETUP 0x0040 -+#define P30_CMD_ALTERNATE_WORD_PROGRAM_SETUP 0x0010 -+#define P30_CMD_BUFFERED_PROGRAM_SETUP 0x00E8 -+#define P30_CMD_BUFFERED_PROGRAM_CONFIRM 0x00D0 -+#define P30_CMD_BEFP_SETUP 0x0080 -+#define P30_CMD_BEFP_CONFIRM 0x00D0 -+ -+// ERASE Commands -+#define P30_CMD_BLOCK_ERASE_SETUP 0x0020 -+#define P30_CMD_BLOCK_ERASE_CONFIRM 0x00D0 -+ -+// SUSPEND Commands -+#define P30_CMD_PROGRAM_OR_ERASE_SUSPEND 0x00B0 -+#define P30_CMD_SUSPEND_RESUME 0x00D0 -+ -+// BLOCK LOCKING / UNLOCKING Commands -+#define P30_CMD_LOCK_BLOCK_SETUP 0x0060 -+#define P30_CMD_LOCK_BLOCK 0x0001 -+#define P30_CMD_UNLOCK_BLOCK 0x00D0 -+#define P30_CMD_LOCK_DOWN_BLOCK 0x002F -+ -+// PROTECTION Commands -+#define P30_CMD_PROGRAM_PROTECTION_REGISTER_SETUP 0x00C0 -+ -+// CONFIGURATION Commands -+#define P30_CMD_READ_CONFIGURATION_REGISTER_SETUP 0x0060 -+#define P30_CMD_READ_CONFIGURATION_REGISTER 0x0003 -+ -+#define NOR_FLASH_SIGNATURE SIGNATURE_32('n', 'o', 'r', '0') -+#define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE) -+#define INSTANCE_FROM_BLKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, BlockIoProtocol, NOR_FLASH_SIGNATURE) -+#define INSTANCE_FROM_DISKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, DiskIoProtocol, NOR_FLASH_SIGNATURE) -+ -+typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; -+ -+#pragma pack (1) -+typedef struct { -+ VENDOR_DEVICE_PATH Vendor; -+ UINT8 Index; -+ EFI_DEVICE_PATH_PROTOCOL End; -+} NOR_FLASH_DEVICE_PATH; -+#pragma pack () -+ -+struct _NOR_FLASH_INSTANCE { -+ UINT32 Signature; -+ EFI_HANDLE Handle; -+ -+ UINTN DeviceBaseAddress; -+ UINTN RegionBaseAddress; -+ UINTN Size; -+ EFI_LBA StartLba; -+ -+ EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; -+ EFI_BLOCK_IO_MEDIA Media; -+ EFI_DISK_IO_PROTOCOL DiskIoProtocol; -+ -+ EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; -+ VOID *ShadowBuffer; -+ -+ NOR_FLASH_DEVICE_PATH DevicePath; -+}; -+ -+EFI_STATUS -+NorFlashReadCfiData ( -+ IN UINTN DeviceBaseAddress, -+ IN UINTN CFI_Offset, -+ IN UINT32 NumberOfBytes, -+ OUT UINT32 *Data -+ ); -+ -+EFI_STATUS -+NorFlashWriteBuffer ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN TargetAddress, -+ IN UINTN BufferSizeInBytes, -+ IN UINT32 *Buffer -+ ); -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoReset ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN BOOLEAN ExtendedVerification -+ ); -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoReadBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ); -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoWriteBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ IN VOID *Buffer -+ ); -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoFlushBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This -+ ); -+ -+// -+// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.ReadDisk -+// -+EFI_STATUS -+EFIAPI -+NorFlashDiskIoReadDisk ( -+ IN EFI_DISK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN UINT64 Offset, -+ IN UINTN BufferSize, -+ OUT VOID *Buffer -+ ); -+ -+// -+// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.WriteDisk -+// -+EFI_STATUS -+EFIAPI -+NorFlashDiskIoWriteDisk ( -+ IN EFI_DISK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN UINT64 Offset, -+ IN UINTN BufferSize, -+ IN VOID *Buffer -+ ); -+ -+// -+// NorFlashFvbDxe.c -+// -+ -+EFI_STATUS -+EFIAPI -+FvbGetAttributes ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbSetAttributes ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbGetPhysicalAddress ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ OUT EFI_PHYSICAL_ADDRESS *Address -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbGetBlockSize ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ OUT UINTN *BlockSize, -+ OUT UINTN *NumberOfBlocks -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbRead ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN OUT UINT8 *Buffer -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbWrite ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ); -+ -+EFI_STATUS -+EFIAPI -+FvbEraseBlocks ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ ... -+ ); -+ -+EFI_STATUS -+ValidateFvHeader ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ); -+ -+EFI_STATUS -+InitializeFvAndVariableStoreHeaders ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ); -+ -+VOID -+EFIAPI -+FvbVirtualNotifyEvent ( -+ IN EFI_EVENT Event, -+ IN VOID *Context -+ ); -+ -+// -+// NorFlashDxe.c -+// -+ -+EFI_STATUS -+NorFlashWriteFullBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINT32 *DataBuffer, -+ IN UINT32 BlockSizeInWords -+ ); -+ -+EFI_STATUS -+NorFlashUnlockAndEraseSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ); -+ -+EFI_STATUS -+NorFlashCreateInstance ( -+ IN UINTN NorFlashDeviceBase, -+ IN UINTN NorFlashRegionBase, -+ IN UINTN NorFlashSize, -+ IN UINT32 Index, -+ IN UINT32 BlockSize, -+ IN BOOLEAN SupportFvb, -+ OUT NOR_FLASH_INSTANCE **NorFlashInstance -+ ); -+ -+EFI_STATUS -+EFIAPI -+NorFlashFvbInitialize ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ); -+ -+// -+// NorFlash.c -+// -+EFI_STATUS -+NorFlashWriteSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ); -+ -+EFI_STATUS -+NorFlashWriteBlocks ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ IN VOID *Buffer -+ ); -+ -+EFI_STATUS -+NorFlashReadBlocks ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ); -+ -+EFI_STATUS -+NorFlashRead ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ); -+ -+EFI_STATUS -+NorFlashWrite ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ); -+ -+EFI_STATUS -+NorFlashReset ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ); -+ -+EFI_STATUS -+NorFlashEraseSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ); -+ -+EFI_STATUS -+NorFlashUnlockSingleBlockIfNecessary ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ); -+ -+EFI_STATUS -+NorFlashWriteSingleWord ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN WordAddress, -+ IN UINT32 WriteData -+ ); -+ -+VOID -+EFIAPI -+NorFlashVirtualNotifyEvent ( -+ IN EFI_EVENT Event, -+ IN VOID *Context -+ ); -+ -+#endif /* __VIRT_NOR_FLASH__ */ -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c -new file mode 100644 -index 0000000000..ecf152e355 ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c -@@ -0,0 +1,123 @@ -+/** @file NorFlashBlockIoDxe.c -+ -+ Copyright (c) 2011-2013, ARM Ltd. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#include -+#include -+ -+#include "VirtNorFlash.h" -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoReset ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN BOOLEAN ExtendedVerification -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_BLKIO_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n", This->Media->MediaId)); -+ -+ return NorFlashReset (Instance); -+} -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoReadBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ OUT VOID *Buffer -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ EFI_STATUS Status; -+ EFI_BLOCK_IO_MEDIA *Media; -+ -+ if (This == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ Instance = INSTANCE_FROM_BLKIO_THIS (This); -+ Media = This->Media; -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, BufferSizeInBytes, Buffer)); -+ -+ if (!Media) { -+ Status = EFI_INVALID_PARAMETER; -+ } else if (!Media->MediaPresent) { -+ Status = EFI_NO_MEDIA; -+ } else if (Media->MediaId != MediaId) { -+ Status = EFI_MEDIA_CHANGED; -+ } else if ((Media->IoAlign > 2) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) { -+ Status = EFI_INVALID_PARAMETER; -+ } else { -+ Status = NorFlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer); -+ } -+ -+ return Status; -+} -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoWriteBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This, -+ IN UINT32 MediaId, -+ IN EFI_LBA Lba, -+ IN UINTN BufferSizeInBytes, -+ IN VOID *Buffer -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ EFI_STATUS Status; -+ -+ Instance = INSTANCE_FROM_BLKIO_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes, BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer)); -+ -+ if ( !This->Media->MediaPresent ) { -+ Status = EFI_NO_MEDIA; -+ } else if ( This->Media->MediaId != MediaId ) { -+ Status = EFI_MEDIA_CHANGED; -+ } else if ( This->Media->ReadOnly ) { -+ Status = EFI_WRITE_PROTECTED; -+ } else { -+ Status = NorFlashWriteBlocks (Instance, Lba, BufferSizeInBytes, Buffer); -+ } -+ -+ return Status; -+} -+ -+// -+// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks -+// -+EFI_STATUS -+EFIAPI -+NorFlashBlockIoFlushBlocks ( -+ IN EFI_BLOCK_IO_PROTOCOL *This -+ ) -+{ -+ // No Flush required for the NOR Flash driver -+ // because cache operations are not permitted. -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoFlushBlocks: Function NOT IMPLEMENTED (not required).\n")); -+ -+ // Nothing to do so just return without error -+ return EFI_SUCCESS; -+} -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -new file mode 100644 -index 0000000000..819425545e ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -0,0 +1,506 @@ -+/** @file NorFlashDxe.c -+ -+ Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "VirtNorFlash.h" -+ -+STATIC EFI_EVENT mNorFlashVirtualAddrChangeEvent; -+ -+// -+// Global variable declarations -+// -+NOR_FLASH_INSTANCE **mNorFlashInstances; -+UINT32 mNorFlashDeviceCount; -+UINTN mFlashNvStorageVariableBase; -+EFI_EVENT mFvbVirtualAddrChangeEvent; -+ -+NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { -+ NOR_FLASH_SIGNATURE, // Signature -+ NULL, // Handle ... NEED TO BE FILLED -+ -+ 0, // DeviceBaseAddress ... NEED TO BE FILLED -+ 0, // RegionBaseAddress ... NEED TO BE FILLED -+ 0, // Size ... NEED TO BE FILLED -+ 0, // StartLba -+ -+ { -+ EFI_BLOCK_IO_PROTOCOL_REVISION2, // Revision -+ NULL, // Media ... NEED TO BE FILLED -+ NorFlashBlockIoReset, // Reset; -+ NorFlashBlockIoReadBlocks, // ReadBlocks -+ NorFlashBlockIoWriteBlocks, // WriteBlocks -+ NorFlashBlockIoFlushBlocks // FlushBlocks -+ }, // BlockIoProtocol -+ -+ { -+ 0, // MediaId ... NEED TO BE FILLED -+ FALSE, // RemovableMedia -+ TRUE, // MediaPresent -+ FALSE, // LogicalPartition -+ FALSE, // ReadOnly -+ FALSE, // WriteCaching; -+ 0, // BlockSize ... NEED TO BE FILLED -+ 4, // IoAlign -+ 0, // LastBlock ... NEED TO BE FILLED -+ 0, // LowestAlignedLba -+ 1, // LogicalBlocksPerPhysicalBlock -+ }, // Media; -+ -+ { -+ EFI_DISK_IO_PROTOCOL_REVISION, // Revision -+ NorFlashDiskIoReadDisk, // ReadDisk -+ NorFlashDiskIoWriteDisk // WriteDisk -+ }, -+ -+ { -+ FvbGetAttributes, // GetAttributes -+ FvbSetAttributes, // SetAttributes -+ FvbGetPhysicalAddress, // GetPhysicalAddress -+ FvbGetBlockSize, // GetBlockSize -+ FvbRead, // Read -+ FvbWrite, // Write -+ FvbEraseBlocks, // EraseBlocks -+ NULL, // ParentHandle -+ }, // FvbProtoccol; -+ NULL, // ShadowBuffer -+ { -+ { -+ { -+ HARDWARE_DEVICE_PATH, -+ HW_VENDOR_DP, -+ { -+ (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)), -+ (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8) -+ } -+ }, -+ { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } -+ }, // GUID ... NEED TO BE FILLED -+ }, -+ 0, // Index -+ { -+ END_DEVICE_PATH_TYPE, -+ END_ENTIRE_DEVICE_PATH_SUBTYPE, -+ { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } -+ } -+ } // DevicePath -+}; -+ -+EFI_STATUS -+NorFlashCreateInstance ( -+ IN UINTN NorFlashDeviceBase, -+ IN UINTN NorFlashRegionBase, -+ IN UINTN NorFlashSize, -+ IN UINT32 Index, -+ IN UINT32 BlockSize, -+ IN BOOLEAN SupportFvb, -+ OUT NOR_FLASH_INSTANCE **NorFlashInstance -+ ) -+{ -+ EFI_STATUS Status; -+ NOR_FLASH_INSTANCE *Instance; -+ -+ ASSERT (NorFlashInstance != NULL); -+ -+ Instance = AllocateRuntimeCopyPool (sizeof (NOR_FLASH_INSTANCE), &mNorFlashInstanceTemplate); -+ if (Instance == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ Instance->DeviceBaseAddress = NorFlashDeviceBase; -+ Instance->RegionBaseAddress = NorFlashRegionBase; -+ Instance->Size = NorFlashSize; -+ -+ Instance->BlockIoProtocol.Media = &Instance->Media; -+ Instance->Media.MediaId = Index; -+ Instance->Media.BlockSize = BlockSize; -+ Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; -+ -+ CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid); -+ Instance->DevicePath.Index = (UINT8)Index; -+ -+ Instance->ShadowBuffer = AllocateRuntimePool (BlockSize); -+ if (Instance->ShadowBuffer == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ if (SupportFvb) { -+ NorFlashFvbInitialize (Instance); -+ -+ Status = gBS->InstallMultipleProtocolInterfaces ( -+ &Instance->Handle, -+ &gEfiDevicePathProtocolGuid, -+ &Instance->DevicePath, -+ &gEfiBlockIoProtocolGuid, -+ &Instance->BlockIoProtocol, -+ &gEfiFirmwareVolumeBlockProtocolGuid, -+ &Instance->FvbProtocol, -+ NULL -+ ); -+ if (EFI_ERROR (Status)) { -+ FreePool (Instance); -+ return Status; -+ } -+ } else { -+ Status = gBS->InstallMultipleProtocolInterfaces ( -+ &Instance->Handle, -+ &gEfiDevicePathProtocolGuid, -+ &Instance->DevicePath, -+ &gEfiBlockIoProtocolGuid, -+ &Instance->BlockIoProtocol, -+ &gEfiDiskIoProtocolGuid, -+ &Instance->DiskIoProtocol, -+ NULL -+ ); -+ if (EFI_ERROR (Status)) { -+ FreePool (Instance); -+ return Status; -+ } -+ } -+ -+ *NorFlashInstance = Instance; -+ return Status; -+} -+ -+/** -+ * This function unlock and erase an entire NOR Flash block. -+ **/ -+EFI_STATUS -+NorFlashUnlockAndEraseSingleBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN UINTN BlockAddress -+ ) -+{ -+ EFI_STATUS Status; -+ UINTN Index; -+ EFI_TPL OriginalTPL; -+ -+ if (!EfiAtRuntime ()) { -+ // Raise TPL to TPL_HIGH to stop anyone from interrupting us. -+ OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); -+ } else { -+ // This initialization is only to prevent the compiler to complain about the -+ // use of uninitialized variables -+ OriginalTPL = TPL_HIGH_LEVEL; -+ } -+ -+ Index = 0; -+ // The block erase might fail a first time (SW bug ?). Retry it ... -+ do { -+ // Unlock the block if we have to -+ Status = NorFlashUnlockSingleBlockIfNecessary (Instance, BlockAddress); -+ if (EFI_ERROR (Status)) { -+ break; -+ } -+ -+ Status = NorFlashEraseSingleBlock (Instance, BlockAddress); -+ Index++; -+ } while ((Index < NOR_FLASH_ERASE_RETRY) && (Status == EFI_WRITE_PROTECTED)); -+ -+ if (Index == NOR_FLASH_ERASE_RETRY) { -+ DEBUG ((DEBUG_ERROR, "EraseSingleBlock(BlockAddress=0x%08x: Block Locked Error (try to erase %d times)\n", BlockAddress, Index)); -+ } -+ -+ if (!EfiAtRuntime ()) { -+ // Interruptions can resume. -+ gBS->RestoreTPL (OriginalTPL); -+ } -+ -+ return Status; -+} -+ -+EFI_STATUS -+NorFlashWriteFullBlock ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINT32 *DataBuffer, -+ IN UINT32 BlockSizeInWords -+ ) -+{ -+ EFI_STATUS Status; -+ UINTN WordAddress; -+ UINT32 WordIndex; -+ UINTN BufferIndex; -+ UINTN BlockAddress; -+ UINTN BuffersInBlock; -+ UINTN RemainingWords; -+ EFI_TPL OriginalTPL; -+ UINTN Cnt; -+ -+ Status = EFI_SUCCESS; -+ -+ // Get the physical address of the block -+ BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba, BlockSizeInWords * 4); -+ -+ // Start writing from the first address at the start of the block -+ WordAddress = BlockAddress; -+ -+ if (!EfiAtRuntime ()) { -+ // Raise TPL to TPL_HIGH to stop anyone from interrupting us. -+ OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); -+ } else { -+ // This initialization is only to prevent the compiler to complain about the -+ // use of uninitialized variables -+ OriginalTPL = TPL_HIGH_LEVEL; -+ } -+ -+ Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "WriteSingleBlock: ERROR - Failed to Unlock and Erase the single block at 0x%X\n", BlockAddress)); -+ goto EXIT; -+ } -+ -+ // To speed up the programming operation, NOR Flash is programmed using the Buffered Programming method. -+ -+ // Check that the address starts at a 32-word boundary, i.e. last 7 bits must be zero -+ if ((WordAddress & BOUNDARY_OF_32_WORDS) == 0x00) { -+ // First, break the entire block into buffer-sized chunks. -+ BuffersInBlock = (UINTN)(BlockSizeInWords * 4) / P30_MAX_BUFFER_SIZE_IN_BYTES; -+ -+ // Then feed each buffer chunk to the NOR Flash -+ // If a buffer does not contain any data, don't write it. -+ for (BufferIndex = 0; -+ BufferIndex < BuffersInBlock; -+ BufferIndex++, WordAddress += P30_MAX_BUFFER_SIZE_IN_BYTES, DataBuffer += P30_MAX_BUFFER_SIZE_IN_WORDS -+ ) -+ { -+ // Check the buffer to see if it contains any data (not set all 1s). -+ for (Cnt = 0; Cnt < P30_MAX_BUFFER_SIZE_IN_WORDS; Cnt++) { -+ if (~DataBuffer[Cnt] != 0 ) { -+ // Some data found, write the buffer. -+ Status = NorFlashWriteBuffer ( -+ Instance, -+ WordAddress, -+ P30_MAX_BUFFER_SIZE_IN_BYTES, -+ DataBuffer -+ ); -+ if (EFI_ERROR (Status)) { -+ goto EXIT; -+ } -+ -+ break; -+ } -+ } -+ } -+ -+ // Finally, finish off any remaining words that are less than the maximum size of the buffer -+ RemainingWords = BlockSizeInWords % P30_MAX_BUFFER_SIZE_IN_WORDS; -+ -+ if (RemainingWords != 0) { -+ Status = NorFlashWriteBuffer (Instance, WordAddress, (RemainingWords * 4), DataBuffer); -+ if (EFI_ERROR (Status)) { -+ goto EXIT; -+ } -+ } -+ } else { -+ // For now, use the single word programming algorithm -+ // It is unlikely that the NOR Flash will exist in an address which falls within a 32 word boundary range, -+ // i.e. which ends in the range 0x......01 - 0x......7F. -+ for (WordIndex = 0; WordIndex < BlockSizeInWords; WordIndex++, DataBuffer++, WordAddress = WordAddress + 4) { -+ Status = NorFlashWriteSingleWord (Instance, WordAddress, *DataBuffer); -+ if (EFI_ERROR (Status)) { -+ goto EXIT; -+ } -+ } -+ } -+ -+EXIT: -+ if (!EfiAtRuntime ()) { -+ // Interruptions can resume. -+ gBS->RestoreTPL (OriginalTPL); -+ } -+ -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NOR FLASH Programming [WriteSingleBlock] failed at address 0x%08x. Exit Status = \"%r\".\n", WordAddress, Status)); -+ } -+ -+ return Status; -+} -+ -+EFI_STATUS -+EFIAPI -+NorFlashInitialise ( -+ IN EFI_HANDLE ImageHandle, -+ IN EFI_SYSTEM_TABLE *SystemTable -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 Index; -+ VIRT_NOR_FLASH_DESCRIPTION *NorFlashDevices; -+ BOOLEAN ContainVariableStorage; -+ -+ Status = VirtNorFlashPlatformInitialization (); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to initialize Nor Flash devices\n")); -+ return Status; -+ } -+ -+ Status = VirtNorFlashPlatformGetDevices (&NorFlashDevices, &mNorFlashDeviceCount); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to get Nor Flash devices\n")); -+ return Status; -+ } -+ -+ mNorFlashInstances = AllocateRuntimePool (sizeof (NOR_FLASH_INSTANCE *) * mNorFlashDeviceCount); -+ -+ for (Index = 0; Index < mNorFlashDeviceCount; Index++) { -+ // Check if this NOR Flash device contain the variable storage region -+ -+ if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) { -+ ContainVariableStorage = -+ (NorFlashDevices[Index].RegionBaseAddress <= PcdGet64 (PcdFlashNvStorageVariableBase64)) && -+ (PcdGet64 (PcdFlashNvStorageVariableBase64) + PcdGet32 (PcdFlashNvStorageVariableSize) <= -+ NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].Size); -+ } else { -+ ContainVariableStorage = -+ (NorFlashDevices[Index].RegionBaseAddress <= PcdGet32 (PcdFlashNvStorageVariableBase)) && -+ (PcdGet32 (PcdFlashNvStorageVariableBase) + PcdGet32 (PcdFlashNvStorageVariableSize) <= -+ NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].Size); -+ } -+ -+ Status = NorFlashCreateInstance ( -+ NorFlashDevices[Index].DeviceBaseAddress, -+ NorFlashDevices[Index].RegionBaseAddress, -+ NorFlashDevices[Index].Size, -+ Index, -+ NorFlashDevices[Index].BlockSize, -+ ContainVariableStorage, -+ &mNorFlashInstances[Index] -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NorFlashInitialise: Fail to create instance for NorFlash[%d]\n", Index)); -+ } -+ } -+ -+ // -+ // Register for the virtual address change event -+ // -+ Status = gBS->CreateEventEx ( -+ EVT_NOTIFY_SIGNAL, -+ TPL_NOTIFY, -+ NorFlashVirtualNotifyEvent, -+ NULL, -+ &gEfiEventVirtualAddressChangeGuid, -+ &mNorFlashVirtualAddrChangeEvent -+ ); -+ ASSERT_EFI_ERROR (Status); -+ -+ return Status; -+} -+ -+EFI_STATUS -+EFIAPI -+NorFlashFvbInitialize ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 FvbNumLba; -+ EFI_BOOT_MODE BootMode; -+ UINTN RuntimeMmioRegionSize; -+ -+ DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n")); -+ ASSERT ((Instance != NULL)); -+ -+ // -+ // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME -+ // -+ -+ // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory; -+ // even if we only use the small block region at the top of the NOR Flash. -+ // The reason is when the NOR Flash memory is set into program mode, the command -+ // is written as the base of the flash region (ie: Instance->DeviceBaseAddress) -+ RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size; -+ -+ Status = gDS->AddMemorySpace ( -+ EfiGcdMemoryTypeMemoryMappedIo, -+ Instance->DeviceBaseAddress, -+ RuntimeMmioRegionSize, -+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME -+ ); -+ ASSERT_EFI_ERROR (Status); -+ -+ Status = gDS->SetMemorySpaceAttributes ( -+ Instance->DeviceBaseAddress, -+ RuntimeMmioRegionSize, -+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME -+ ); -+ ASSERT_EFI_ERROR (Status); -+ -+ mFlashNvStorageVariableBase = (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ? -+ PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStorageVariableBase); -+ -+ // Set the index of the first LBA for the FVB -+ Instance->StartLba = (mFlashNvStorageVariableBase - Instance->RegionBaseAddress) / Instance->Media.BlockSize; -+ -+ BootMode = GetBootModeHob (); -+ if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) { -+ Status = EFI_INVALID_PARAMETER; -+ } else { -+ // Determine if there is a valid header at the beginning of the NorFlash -+ Status = ValidateFvHeader (Instance); -+ } -+ -+ // Install the Default FVB header if required -+ if (EFI_ERROR (Status)) { -+ // There is no valid header, so time to install one. -+ DEBUG ((DEBUG_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__)); -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: Installing a correct one for this volume.\n", -+ __FUNCTION__ -+ )); -+ -+ // Erase all the NorFlash that is reserved for variable storage -+ FvbNumLba = (PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize; -+ -+ Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, EFI_LBA_LIST_TERMINATOR); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ // Install all appropriate headers -+ Status = InitializeFvAndVariableStoreHeaders (Instance); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ } -+ -+ // -+ // The driver implementing the variable read service can now be dispatched; -+ // the varstore headers are in place. -+ // -+ Status = gBS->InstallProtocolInterface ( -+ &gImageHandle, -+ &gEdkiiNvVarStoreFormattedGuid, -+ EFI_NATIVE_INTERFACE, -+ NULL -+ ); -+ ASSERT_EFI_ERROR (Status); -+ -+ // -+ // Register for the virtual address change event -+ // -+ Status = gBS->CreateEventEx ( -+ EVT_NOTIFY_SIGNAL, -+ TPL_NOTIFY, -+ FvbVirtualNotifyEvent, -+ NULL, -+ &gEfiEventVirtualAddressChangeGuid, -+ &mFvbVirtualAddrChangeEvent -+ ); -+ ASSERT_EFI_ERROR (Status); -+ -+ return Status; -+} -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -new file mode 100644 -index 0000000000..1bf50e4823 ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -@@ -0,0 +1,72 @@ -+#/** @file -+# -+# Component description file for NorFlashDxe module -+# -+# Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
-+# -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+#**/ -+ -+[Defines] -+ INF_VERSION = 1.29 -+ BASE_NAME = VirtNorFlashDxe -+ FILE_GUID = e452cabd-5fe1-4d97-8161-e80ed6a409a8 -+ MODULE_TYPE = DXE_RUNTIME_DRIVER -+ VERSION_STRING = 1.0 -+ ENTRY_POINT = NorFlashInitialise -+ -+[Sources.common] -+ VirtNorFlash.c -+ VirtNorFlash.h -+ VirtNorFlashBlockIoDxe.c -+ VirtNorFlashDxe.c -+ VirtNorFlashFvb.c -+ -+[Packages] -+ ArmPlatformPkg/ArmPlatformPkg.dec -+ EmbeddedPkg/EmbeddedPkg.dec -+ MdePkg/MdePkg.dec -+ MdeModulePkg/MdeModulePkg.dec -+ OvmfPkg/OvmfPkg.dec -+ -+[LibraryClasses] -+ BaseLib -+ DebugLib -+ DxeServicesTableLib -+ HobLib -+ IoLib -+ UefiBootServicesTableLib -+ UefiDriverEntryPoint -+ UefiLib -+ UefiRuntimeLib -+ VirtNorFlashPlatformLib -+ -+[Guids] -+ gEdkiiNvVarStoreFormattedGuid ## PRODUCES ## PROTOCOL -+ gEfiAuthenticatedVariableGuid -+ gEfiEventVirtualAddressChangeGuid -+ gEfiSystemNvDataFvGuid -+ gEfiVariableGuid -+ -+[Protocols] -+ gEfiBlockIoProtocolGuid -+ gEfiDevicePathProtocolGuid -+ gEfiDiskIoProtocolGuid -+ gEfiFirmwareVolumeBlockProtocolGuid -+ -+[Pcd.common] -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase -+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize -+ -+ gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked -+ -+[Depex] -+ gEfiCpuArchProtocolGuid -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -new file mode 100644 -index 0000000000..c824e0a0fb ---- /dev/null -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -@@ -0,0 +1,777 @@ -+/*++ @file NorFlashFvbDxe.c -+ -+ Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+ --*/ -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include "VirtNorFlash.h" -+ -+extern UINTN mFlashNvStorageVariableBase; -+/// -+/// The Firmware Volume Block Protocol is the low-level interface -+/// to a firmware volume. File-level access to a firmware volume -+/// should not be done using the Firmware Volume Block Protocol. -+/// Normal access to a firmware volume must use the Firmware -+/// Volume Protocol. Typically, only the file system driver that -+/// produces the Firmware Volume Protocol will bind to the -+/// Firmware Volume Block Protocol. -+/// -+ -+/** -+ Initialises the FV Header and Variable Store Header -+ to support variable operations. -+ -+ @param[in] Ptr - Location to initialise the headers -+ -+**/ -+EFI_STATUS -+InitializeFvAndVariableStoreHeaders ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ) -+{ -+ EFI_STATUS Status; -+ VOID *Headers; -+ UINTN HeadersLength; -+ EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader; -+ VARIABLE_STORE_HEADER *VariableStoreHeader; -+ UINT32 NvStorageFtwSpareSize; -+ UINT32 NvStorageFtwWorkingSize; -+ UINT32 NvStorageVariableSize; -+ UINT64 NvStorageFtwSpareBase; -+ UINT64 NvStorageFtwWorkingBase; -+ UINT64 NvStorageVariableBase; -+ -+ HeadersLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY) + sizeof (VARIABLE_STORE_HEADER); -+ Headers = AllocateZeroPool (HeadersLength); -+ -+ NvStorageFtwWorkingSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize); -+ NvStorageFtwSpareSize = PcdGet32 (PcdFlashNvStorageFtwSpareSize); -+ NvStorageVariableSize = PcdGet32 (PcdFlashNvStorageVariableSize); -+ -+ NvStorageFtwSpareBase = (PcdGet64 (PcdFlashNvStorageFtwSpareBase64) != 0) ? -+ PcdGet64 (PcdFlashNvStorageFtwSpareBase64) : PcdGet32 (PcdFlashNvStorageFtwSpareBase); -+ NvStorageFtwWorkingBase = (PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) != 0) ? -+ PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) : PcdGet32 (PcdFlashNvStorageFtwWorkingBase); -+ NvStorageVariableBase = (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) ? -+ PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStorageVariableBase); -+ -+ // FirmwareVolumeHeader->FvLength is declared to have the Variable area AND the FTW working area AND the FTW Spare contiguous. -+ if ((NvStorageVariableBase + NvStorageVariableSize) != NvStorageFtwWorkingBase) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: NvStorageFtwWorkingBase is not contiguous with NvStorageVariableBase region\n", -+ __FUNCTION__ -+ )); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((NvStorageFtwWorkingBase + NvStorageFtwWorkingSize) != NvStorageFtwSpareBase) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: NvStorageFtwSpareBase is not contiguous with NvStorageFtwWorkingBase region\n", -+ __FUNCTION__ -+ )); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Check if the size of the area is at least one block size -+ if ((NvStorageVariableSize <= 0) || (NvStorageVariableSize / Instance->Media.BlockSize <= 0)) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: NvStorageVariableSize is 0x%x, should be atleast one block size\n", -+ __FUNCTION__, -+ NvStorageVariableSize -+ )); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((NvStorageFtwWorkingSize <= 0) || (NvStorageFtwWorkingSize / Instance->Media.BlockSize <= 0)) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: NvStorageFtwWorkingSize is 0x%x, should be atleast one block size\n", -+ __FUNCTION__, -+ NvStorageFtwWorkingSize -+ )); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((NvStorageFtwSpareSize <= 0) || (NvStorageFtwSpareSize / Instance->Media.BlockSize <= 0)) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: NvStorageFtwSpareSize is 0x%x, should be atleast one block size\n", -+ __FUNCTION__, -+ NvStorageFtwSpareSize -+ )); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Ensure the Variable area Base Addresses are aligned on a block size boundaries -+ if ((NvStorageVariableBase % Instance->Media.BlockSize != 0) || -+ (NvStorageFtwWorkingBase % Instance->Media.BlockSize != 0) || -+ (NvStorageFtwSpareBase % Instance->Media.BlockSize != 0)) -+ { -+ DEBUG ((DEBUG_ERROR, "%a: NvStorage Base addresses must be aligned to block size boundaries", __FUNCTION__)); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // EFI_FIRMWARE_VOLUME_HEADER -+ // -+ FirmwareVolumeHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Headers; -+ CopyGuid (&FirmwareVolumeHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid); -+ FirmwareVolumeHeader->FvLength = -+ PcdGet32 (PcdFlashNvStorageVariableSize) + -+ PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + -+ PcdGet32 (PcdFlashNvStorageFtwSpareSize); -+ FirmwareVolumeHeader->Signature = EFI_FVH_SIGNATURE; -+ FirmwareVolumeHeader->Attributes = (EFI_FVB_ATTRIBUTES_2)( -+ EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled -+ EFI_FVB2_READ_STATUS | // Reads are currently enabled -+ EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY -+ EFI_FVB2_MEMORY_MAPPED | // It is memory mapped -+ EFI_FVB2_ERASE_POLARITY | // After erasure all bits take this value (i.e. '1') -+ EFI_FVB2_WRITE_STATUS | // Writes are currently enabled -+ EFI_FVB2_WRITE_ENABLED_CAP // Writes may be enabled -+ ); -+ FirmwareVolumeHeader->HeaderLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY); -+ FirmwareVolumeHeader->Revision = EFI_FVH_REVISION; -+ FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1; -+ FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize; -+ FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0; -+ FirmwareVolumeHeader->BlockMap[1].Length = 0; -+ FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16 *)FirmwareVolumeHeader, FirmwareVolumeHeader->HeaderLength); -+ -+ // -+ // VARIABLE_STORE_HEADER -+ // -+ VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)Headers + FirmwareVolumeHeader->HeaderLength); -+ CopyGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid); -+ VariableStoreHeader->Size = PcdGet32 (PcdFlashNvStorageVariableSize) - FirmwareVolumeHeader->HeaderLength; -+ VariableStoreHeader->Format = VARIABLE_STORE_FORMATTED; -+ VariableStoreHeader->State = VARIABLE_STORE_HEALTHY; -+ -+ // Install the combined super-header in the NorFlash -+ Status = FvbWrite (&Instance->FvbProtocol, 0, 0, &HeadersLength, Headers); -+ -+ FreePool (Headers); -+ return Status; -+} -+ -+/** -+ Check the integrity of firmware volume header. -+ -+ @param[in] FwVolHeader - A pointer to a firmware volume header -+ -+ @retval EFI_SUCCESS - The firmware volume is consistent -+ @retval EFI_NOT_FOUND - The firmware volume has been corrupted. -+ -+**/ -+EFI_STATUS -+ValidateFvHeader ( -+ IN NOR_FLASH_INSTANCE *Instance -+ ) -+{ -+ UINT16 Checksum; -+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; -+ VARIABLE_STORE_HEADER *VariableStoreHeader; -+ UINTN VariableStoreLength; -+ UINTN FvLength; -+ -+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress; -+ -+ FvLength = PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + -+ PcdGet32 (PcdFlashNvStorageFtwSpareSize); -+ -+ // -+ // Verify the header revision, header signature, length -+ // Length of FvBlock cannot be 2**64-1 -+ // HeaderLength cannot be an odd number -+ // -+ if ( (FwVolHeader->Revision != EFI_FVH_REVISION) -+ || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) -+ || (FwVolHeader->FvLength != FvLength) -+ ) -+ { -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: No Firmware Volume header present\n", -+ __FUNCTION__ -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ // Check the Firmware Volume Guid -+ if ( CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid) == FALSE ) { -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: Firmware Volume Guid non-compatible\n", -+ __FUNCTION__ -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ // Verify the header checksum -+ Checksum = CalculateSum16 ((UINT16 *)FwVolHeader, FwVolHeader->HeaderLength); -+ if (Checksum != 0) { -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: FV checksum is invalid (Checksum:0x%X)\n", -+ __FUNCTION__, -+ Checksum -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); -+ -+ // Check the Variable Store Guid -+ if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && -+ !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) -+ { -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: Variable Store Guid non-compatible\n", -+ __FUNCTION__ -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ VariableStoreLength = PcdGet32 (PcdFlashNvStorageVariableSize) - FwVolHeader->HeaderLength; -+ if (VariableStoreHeader->Size != VariableStoreLength) { -+ DEBUG (( -+ DEBUG_INFO, -+ "%a: Variable Store Length does not match\n", -+ __FUNCTION__ -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ The GetAttributes() function retrieves the attributes and -+ current settings of the block. -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the attributes and -+ current settings are returned. -+ Type EFI_FVB_ATTRIBUTES_2 is defined in EFI_FIRMWARE_VOLUME_HEADER. -+ -+ @retval EFI_SUCCESS The firmware volume attributes were returned. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbGetAttributes ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ OUT EFI_FVB_ATTRIBUTES_2 *Attributes -+ ) -+{ -+ EFI_FVB_ATTRIBUTES_2 FlashFvbAttributes; -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ FlashFvbAttributes = (EFI_FVB_ATTRIBUTES_2)( -+ -+ EFI_FVB2_READ_ENABLED_CAP | // Reads may be enabled -+ EFI_FVB2_READ_STATUS | // Reads are currently enabled -+ EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY -+ EFI_FVB2_MEMORY_MAPPED | // It is memory mapped -+ EFI_FVB2_ERASE_POLARITY // After erasure all bits take this value (i.e. '1') -+ -+ ); -+ -+ // Check if it is write protected -+ if (Instance->Media.ReadOnly != TRUE) { -+ FlashFvbAttributes = FlashFvbAttributes | -+ EFI_FVB2_WRITE_STATUS | // Writes are currently enabled -+ EFI_FVB2_WRITE_ENABLED_CAP; // Writes may be enabled -+ } -+ -+ *Attributes = FlashFvbAttributes; -+ -+ DEBUG ((DEBUG_BLKIO, "FvbGetAttributes(0x%X)\n", *Attributes)); -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ The SetAttributes() function sets configurable firmware volume attributes -+ and returns the new settings of the firmware volume. -+ -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2 -+ that contains the desired firmware volume settings. -+ On successful return, it contains the new settings of -+ the firmware volume. -+ Type EFI_FVB_ATTRIBUTES_2 is defined in EFI_FIRMWARE_VOLUME_HEADER. -+ -+ @retval EFI_SUCCESS The firmware volume attributes were returned. -+ -+ @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with the capabilities -+ as declared in the firmware volume header. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbSetAttributes ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes -+ ) -+{ -+ DEBUG ((DEBUG_BLKIO, "FvbSetAttributes(0x%X) is not supported\n", *Attributes)); -+ return EFI_UNSUPPORTED; -+} -+ -+/** -+ The GetPhysicalAddress() function retrieves the base address of -+ a memory-mapped firmware volume. This function should be called -+ only for memory-mapped firmware volumes. -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Address Pointer to a caller-allocated -+ EFI_PHYSICAL_ADDRESS that, on successful -+ return from GetPhysicalAddress(), contains the -+ base address of the firmware volume. -+ -+ @retval EFI_SUCCESS The firmware volume base address was returned. -+ -+ @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbGetPhysicalAddress ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ OUT EFI_PHYSICAL_ADDRESS *Address -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "FvbGetPhysicalAddress(BaseAddress=0x%08x)\n", Instance->RegionBaseAddress)); -+ -+ ASSERT (Address != NULL); -+ -+ *Address = mFlashNvStorageVariableBase; -+ return EFI_SUCCESS; -+} -+ -+/** -+ The GetBlockSize() function retrieves the size of the requested -+ block. It also returns the number of additional blocks with -+ the identical size. The GetBlockSize() function is used to -+ retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER). -+ -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Lba Indicates the block for which to return the size. -+ -+ @param BlockSize Pointer to a caller-allocated UINTN in which -+ the size of the block is returned. -+ -+ @param NumberOfBlocks Pointer to a caller-allocated UINTN in -+ which the number of consecutive blocks, -+ starting with Lba, is returned. All -+ blocks in this range have a size of -+ BlockSize. -+ -+ -+ @retval EFI_SUCCESS The firmware volume base address was returned. -+ -+ @retval EFI_INVALID_PARAMETER The requested LBA is out of range. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbGetBlockSize ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ OUT UINTN *BlockSize, -+ OUT UINTN *NumberOfBlocks -+ ) -+{ -+ EFI_STATUS Status; -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, Instance->Media.BlockSize, Instance->Media.LastBlock)); -+ -+ if (Lba > Instance->Media.LastBlock) { -+ DEBUG ((DEBUG_ERROR, "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba (%ld).\n", Lba, Instance->Media.LastBlock)); -+ Status = EFI_INVALID_PARAMETER; -+ } else { -+ // This is easy because in this platform each NorFlash device has equal sized blocks. -+ *BlockSize = (UINTN)Instance->Media.BlockSize; -+ *NumberOfBlocks = (UINTN)(Instance->Media.LastBlock - Lba + 1); -+ -+ DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize, *NumberOfBlocks)); -+ -+ Status = EFI_SUCCESS; -+ } -+ -+ return Status; -+} -+ -+/** -+ Reads the specified number of bytes into a buffer from the specified block. -+ -+ The Read() function reads the requested number of bytes from the -+ requested block and stores them in the provided buffer. -+ Implementations should be mindful that the firmware volume -+ might be in the ReadDisabled state. If it is in this state, -+ the Read() function must return the status code -+ EFI_ACCESS_DENIED without modifying the contents of the -+ buffer. The Read() function must also prevent spanning block -+ boundaries. If a read is requested that would span a block -+ boundary, the read must read up to the boundary but not -+ beyond. The output parameter NumBytes must be set to correctly -+ indicate the number of bytes actually read. The caller must be -+ aware that a read may be partially completed. -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Lba The starting logical block index from which to read. -+ -+ @param Offset Offset into the block at which to begin reading. -+ -+ @param NumBytes Pointer to a UINTN. -+ At entry, *NumBytes contains the total size of the buffer. -+ At exit, *NumBytes contains the total number of bytes read. -+ -+ @param Buffer Pointer to a caller-allocated buffer that will be used -+ to hold the data that is read. -+ -+ @retval EFI_SUCCESS The firmware volume was read successfully, and contents are -+ in Buffer. -+ -+ @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. -+ On output, NumBytes contains the total number of bytes -+ returned in Buffer. -+ -+ @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state. -+ -+ @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbRead ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN OUT UINT8 *Buffer -+ ) -+{ -+ EFI_STATUS TempStatus; -+ UINTN BlockSize; -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "FvbRead(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Instance->StartLba + Lba, Offset, *NumBytes, Buffer)); -+ -+ TempStatus = EFI_SUCCESS; -+ -+ // Cache the block size to avoid de-referencing pointers all the time -+ BlockSize = Instance->Media.BlockSize; -+ -+ DEBUG ((DEBUG_BLKIO, "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", Offset, *NumBytes, BlockSize)); -+ -+ // The read must not span block boundaries. -+ // We need to check each variable individually because adding two large values together overflows. -+ if ((Offset >= BlockSize) || -+ (*NumBytes > BlockSize) || -+ ((Offset + *NumBytes) > BlockSize)) -+ { -+ DEBUG ((DEBUG_ERROR, "FvbRead: ERROR - EFI_BAD_BUFFER_SIZE: (Offset=0x%x + NumBytes=0x%x) > BlockSize=0x%x\n", Offset, *NumBytes, BlockSize)); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // We must have some bytes to read -+ if (*NumBytes == 0) { -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Decide if we are doing full block reads or not. -+ if (*NumBytes % BlockSize != 0) { -+ TempStatus = NorFlashRead (Instance, Instance->StartLba + Lba, Offset, *NumBytes, Buffer); -+ if (EFI_ERROR (TempStatus)) { -+ return EFI_DEVICE_ERROR; -+ } -+ } else { -+ // Read NOR Flash data into shadow buffer -+ TempStatus = NorFlashReadBlocks (Instance, Instance->StartLba + Lba, BlockSize, Buffer); -+ if (EFI_ERROR (TempStatus)) { -+ // Return one of the pre-approved error statuses -+ return EFI_DEVICE_ERROR; -+ } -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ Writes the specified number of bytes from the input buffer to the block. -+ -+ The Write() function writes the specified number of bytes from -+ the provided buffer to the specified block and offset. If the -+ firmware volume is sticky write, the caller must ensure that -+ all the bits of the specified range to write are in the -+ EFI_FVB_ERASE_POLARITY state before calling the Write() -+ function, or else the result will be unpredictable. This -+ unpredictability arises because, for a sticky-write firmware -+ volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY -+ state but cannot flip it back again. Before calling the -+ Write() function, it is recommended for the caller to first call -+ the EraseBlocks() function to erase the specified block to -+ write. A block erase cycle will transition bits from the -+ (NOT)EFI_FVB_ERASE_POLARITY state back to the -+ EFI_FVB_ERASE_POLARITY state. Implementations should be -+ mindful that the firmware volume might be in the WriteDisabled -+ state. If it is in this state, the Write() function must -+ return the status code EFI_ACCESS_DENIED without modifying the -+ contents of the firmware volume. The Write() function must -+ also prevent spanning block boundaries. If a write is -+ requested that spans a block boundary, the write must store up -+ to the boundary but not beyond. The output parameter NumBytes -+ must be set to correctly indicate the number of bytes actually -+ written. The caller must be aware that a write may be -+ partially completed. All writes, partial or otherwise, must be -+ fully flushed to the hardware before the Write() service -+ returns. -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance. -+ -+ @param Lba The starting logical block index to write to. -+ -+ @param Offset Offset into the block at which to begin writing. -+ -+ @param NumBytes The pointer to a UINTN. -+ At entry, *NumBytes contains the total size of the buffer. -+ At exit, *NumBytes contains the total number of bytes actually written. -+ -+ @param Buffer The pointer to a caller-allocated buffer that contains the source for the write. -+ -+ @retval EFI_SUCCESS The firmware volume was written successfully. -+ -+ @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. -+ On output, NumBytes contains the total number of bytes -+ actually written. -+ -+ @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. -+ -+ @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written. -+ -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbWrite ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ) -+{ -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ return NorFlashWriteSingleBlock (Instance, Instance->StartLba + Lba, Offset, NumBytes, Buffer); -+} -+ -+/** -+ Erases and initialises a firmware volume block. -+ -+ The EraseBlocks() function erases one or more blocks as denoted -+ by the variable argument list. The entire parameter list of -+ blocks must be verified before erasing any blocks. If a block is -+ requested that does not exist within the associated firmware -+ volume (it has a larger index than the last block of the -+ firmware volume), the EraseBlocks() function must return the -+ status code EFI_INVALID_PARAMETER without modifying the contents -+ of the firmware volume. Implementations should be mindful that -+ the firmware volume might be in the WriteDisabled state. If it -+ is in this state, the EraseBlocks() function must return the -+ status code EFI_ACCESS_DENIED without modifying the contents of -+ the firmware volume. All calls to EraseBlocks() must be fully -+ flushed to the hardware before the EraseBlocks() service -+ returns. -+ -+ @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL -+ instance. -+ -+ @param ... The variable argument list is a list of tuples. -+ Each tuple describes a range of LBAs to erase -+ and consists of the following: -+ - An EFI_LBA that indicates the starting LBA -+ - A UINTN that indicates the number of blocks to erase. -+ -+ The list is terminated with an EFI_LBA_LIST_TERMINATOR. -+ For example, the following indicates that two ranges of blocks -+ (5-7 and 10-11) are to be erased: -+ EraseBlocks (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR); -+ -+ @retval EFI_SUCCESS The erase request successfully completed. -+ -+ @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state. -+ -+ @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be written. -+ The firmware device may have been partially erased. -+ -+ @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable argument list do -+ not exist in the firmware volume. -+ -+ **/ -+EFI_STATUS -+EFIAPI -+FvbEraseBlocks ( -+ IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, -+ ... -+ ) -+{ -+ EFI_STATUS Status; -+ VA_LIST Args; -+ UINTN BlockAddress; // Physical address of Lba to erase -+ EFI_LBA StartingLba; // Lba from which we start erasing -+ UINTN NumOfLba; // Number of Lba blocks to erase -+ NOR_FLASH_INSTANCE *Instance; -+ -+ Instance = INSTANCE_FROM_FVB_THIS (This); -+ -+ DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks()\n")); -+ -+ Status = EFI_SUCCESS; -+ -+ // Detect WriteDisabled state -+ if (Instance->Media.ReadOnly == TRUE) { -+ // Firmware volume is in WriteDisabled state -+ DEBUG ((DEBUG_ERROR, "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n")); -+ return EFI_ACCESS_DENIED; -+ } -+ -+ // Before erasing, check the entire list of parameters to ensure all specified blocks are valid -+ -+ VA_START (Args, This); -+ do { -+ // Get the Lba from which we start erasing -+ StartingLba = VA_ARG (Args, EFI_LBA); -+ -+ // Have we reached the end of the list? -+ if (StartingLba == EFI_LBA_LIST_TERMINATOR) { -+ // Exit the while loop -+ break; -+ } -+ -+ // How many Lba blocks are we requested to erase? -+ NumOfLba = VA_ARG (Args, UINTN); -+ -+ // All blocks must be within range -+ DEBUG (( -+ DEBUG_BLKIO, -+ "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%Lu - 1 ) > LastBlock=%ld.\n", -+ Instance->StartLba + StartingLba, -+ (UINT64)NumOfLba, -+ Instance->Media.LastBlock -+ )); -+ if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->Media.LastBlock)) { -+ VA_END (Args); -+ DEBUG ((DEBUG_ERROR, "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n")); -+ Status = EFI_INVALID_PARAMETER; -+ goto EXIT; -+ } -+ } while (TRUE); -+ -+ VA_END (Args); -+ -+ // -+ // To get here, all must be ok, so start erasing -+ // -+ VA_START (Args, This); -+ do { -+ // Get the Lba from which we start erasing -+ StartingLba = VA_ARG (Args, EFI_LBA); -+ -+ // Have we reached the end of the list? -+ if (StartingLba == EFI_LBA_LIST_TERMINATOR) { -+ // Exit the while loop -+ break; -+ } -+ -+ // How many Lba blocks are we requested to erase? -+ NumOfLba = VA_ARG (Args, UINTN); -+ -+ // Go through each one and erase it -+ while (NumOfLba > 0) { -+ // Get the physical address of Lba to erase -+ BlockAddress = GET_NOR_BLOCK_ADDRESS ( -+ Instance->RegionBaseAddress, -+ Instance->StartLba + StartingLba, -+ Instance->Media.BlockSize -+ ); -+ -+ // Erase it -+ DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n", Instance->StartLba + StartingLba, BlockAddress)); -+ Status = NorFlashUnlockAndEraseSingleBlock (Instance, BlockAddress); -+ if (EFI_ERROR (Status)) { -+ VA_END (Args); -+ Status = EFI_DEVICE_ERROR; -+ goto EXIT; -+ } -+ -+ // Move to the next Lba -+ StartingLba++; -+ NumOfLba--; -+ } -+ } while (TRUE); -+ -+ VA_END (Args); -+ -+EXIT: -+ return Status; -+} -+ -+/** -+ Fixup internal data so that EFI can be call in virtual mode. -+ Call the passed in Child Notify event and convert any pointers in -+ lib to virtual mode. -+ -+ @param[in] Event The Event that is being processed -+ @param[in] Context Event Context -+**/ -+VOID -+EFIAPI -+FvbVirtualNotifyEvent ( -+ IN EFI_EVENT Event, -+ IN VOID *Context -+ ) -+{ -+ EfiConvertPointer (0x0, (VOID **)&mFlashNvStorageVariableBase); -+ return; -+} --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-drop-block-I-O-protocol-impl.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-drop-block-I-O-protocol-impl.patch deleted file mode 100644 index e8c0128..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-drop-block-I-O-protocol-impl.patch +++ /dev/null @@ -1,504 +0,0 @@ -From 8cf16599ade30de07c9b51f90d2208046f74fee6 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 17:12:08 +0200 -Subject: [PATCH 04/18] OvmfPkg/VirtNorFlashDxe: drop block I/O protocol - implementation - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [6/20] 6843078997a30c2818e0d53a90fb7f6accb89aaf - -We never boot from NOR flash, and generally rely on the firmware volume -PI protocols to expose the contents. So drop the block I/O protocol -implementation from VirtNorFlashDxe. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 83f11f957240ead9b135a778316330762b0a3acb) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 49 ++++++------------ - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h | 54 ++------------------ - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 40 +++------------ - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf | 1 - - OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 55 ++++++++------------- - 5 files changed, 45 insertions(+), 154 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 1094d48f7d..f41d9d372f 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -366,10 +366,6 @@ NorFlashWriteBlocks ( - return EFI_INVALID_PARAMETER; - } - -- if (Instance->Media.ReadOnly == TRUE) { -- return EFI_WRITE_PROTECTED; -- } -- - // We must have some bytes to read - DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n", BufferSizeInBytes)); - if (BufferSizeInBytes == 0) { -@@ -377,22 +373,22 @@ NorFlashWriteBlocks ( - } - - // The size of the buffer must be a multiple of the block size -- DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", Instance->Media.BlockSize)); -- if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n", Instance->BlockSize)); -+ if ((BufferSizeInBytes % Instance->BlockSize) != 0) { - return EFI_BAD_BUFFER_SIZE; - } - - // All blocks must be within the device -- NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize; -+ NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize; - -- DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, Instance->Media.LastBlock, Lba)); -+ DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks, Instance->LastBlock, Lba)); - -- if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { -+ if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) { - DEBUG ((DEBUG_ERROR, "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n")); - return EFI_INVALID_PARAMETER; - } - -- BlockSizeInWords = Instance->Media.BlockSize / 4; -+ BlockSizeInWords = Instance->BlockSize / 4; - - // Because the target *Buffer is a pointer to VOID, we must put all the data into a pointer - // to a proper data type, so use *ReadBuffer -@@ -489,8 +485,8 @@ NorFlashReadBlocks ( - DEBUG_BLKIO, - "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, Lba=%ld.\n", - BufferSizeInBytes, -- Instance->Media.BlockSize, -- Instance->Media.LastBlock, -+ Instance->BlockSize, -+ Instance->LastBlock, - Lba - )); - -@@ -505,14 +501,14 @@ NorFlashReadBlocks ( - } - - // The size of the buffer must be a multiple of the block size -- if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) { -+ if ((BufferSizeInBytes % Instance->BlockSize) != 0) { - return EFI_BAD_BUFFER_SIZE; - } - - // All blocks must be within the device -- NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize; -+ NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize; - -- if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { -+ if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) { - DEBUG ((DEBUG_ERROR, "NorFlashReadBlocks: ERROR - Read will exceed last block\n")); - return EFI_INVALID_PARAMETER; - } -@@ -521,7 +517,7 @@ NorFlashReadBlocks ( - StartAddress = GET_NOR_BLOCK_ADDRESS ( - Instance->RegionBaseAddress, - Lba, -- Instance->Media.BlockSize -+ Instance->BlockSize - ); - - // Put the device into Read Array mode -@@ -554,7 +550,7 @@ NorFlashRead ( - return EFI_SUCCESS; - } - -- if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > Instance->Size) { -+ if (((Lba * Instance->BlockSize) + Offset + BufferSizeInBytes) > Instance->Size) { - DEBUG ((DEBUG_ERROR, "NorFlashRead: ERROR - Read will exceed device size.\n")); - return EFI_INVALID_PARAMETER; - } -@@ -563,7 +559,7 @@ NorFlashRead ( - StartAddress = GET_NOR_BLOCK_ADDRESS ( - Instance->RegionBaseAddress, - Lba, -- Instance->Media.BlockSize -+ Instance->BlockSize - ); - - // Put the device into Read Array mode -@@ -577,7 +573,7 @@ NorFlashRead ( - - /* - Write a full or portion of a block. It must not span block boundaries; that is, -- Offset + *NumBytes <= Instance->Media.BlockSize. -+ Offset + *NumBytes <= Instance->BlockSize. - */ - EFI_STATUS - NorFlashWriteSingleBlock ( -@@ -605,15 +601,8 @@ NorFlashWriteSingleBlock ( - - DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); - -- // Detect WriteDisabled state -- if (Instance->Media.ReadOnly == TRUE) { -- DEBUG ((DEBUG_ERROR, "NorFlashWriteSingleBlock: ERROR - Can not write: Device is in WriteDisabled state.\n")); -- // It is in WriteDisabled state, return an error right away -- return EFI_ACCESS_DENIED; -- } -- - // Cache the block size to avoid de-referencing pointers all the time -- BlockSize = Instance->Media.BlockSize; -+ BlockSize = Instance->BlockSize; - - // The write must not span block boundaries. - // We need to check each variable individually because adding two large values together overflows. -@@ -819,12 +808,6 @@ NorFlashVirtualNotifyEvent ( - EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->DeviceBaseAddress); - EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->RegionBaseAddress); - -- // Convert BlockIo protocol -- EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks); -- EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks); -- EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.Reset); -- EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks); -- - // Convert Fvb - EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks); - EfiConvertPointer (0x0, (VOID **)&mNorFlashInstances[Index]->FvbProtocol.GetAttributes); -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -index 7733ee02ee..b7f5d208b2 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -@@ -14,7 +14,6 @@ - - #include - --#include - #include - - #include -@@ -108,8 +107,7 @@ - #define P30_CMD_READ_CONFIGURATION_REGISTER 0x0003 - - #define NOR_FLASH_SIGNATURE SIGNATURE_32('n', 'o', 'r', '0') --#define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE) --#define INSTANCE_FROM_BLKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, BlockIoProtocol, NOR_FLASH_SIGNATURE) -+#define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE) - - typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; - -@@ -129,9 +127,8 @@ struct _NOR_FLASH_INSTANCE { - UINTN RegionBaseAddress; - UINTN Size; - EFI_LBA StartLba; -- -- EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; -- EFI_BLOCK_IO_MEDIA Media; -+ EFI_LBA LastBlock; -+ UINT32 BlockSize; - - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; - VOID *ShadowBuffer; -@@ -155,51 +152,6 @@ NorFlashWriteBuffer ( - IN UINT32 *Buffer - ); - --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset --// --EFI_STATUS --EFIAPI --NorFlashBlockIoReset ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN BOOLEAN ExtendedVerification -- ); -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoReadBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN EFI_LBA Lba, -- IN UINTN BufferSizeInBytes, -- OUT VOID *Buffer -- ); -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoWriteBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN EFI_LBA Lba, -- IN UINTN BufferSizeInBytes, -- IN VOID *Buffer -- ); -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoFlushBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This -- ); -- - // - // NorFlashFvbDxe.c - // -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -index 4875b057d5..2ceda22635 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -34,29 +34,8 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { - 0, // RegionBaseAddress ... NEED TO BE FILLED - 0, // Size ... NEED TO BE FILLED - 0, // StartLba -- -- { -- EFI_BLOCK_IO_PROTOCOL_REVISION2, // Revision -- NULL, // Media ... NEED TO BE FILLED -- NorFlashBlockIoReset, // Reset; -- NorFlashBlockIoReadBlocks, // ReadBlocks -- NorFlashBlockIoWriteBlocks, // WriteBlocks -- NorFlashBlockIoFlushBlocks // FlushBlocks -- }, // BlockIoProtocol -- -- { -- 0, // MediaId ... NEED TO BE FILLED -- FALSE, // RemovableMedia -- TRUE, // MediaPresent -- FALSE, // LogicalPartition -- FALSE, // ReadOnly -- FALSE, // WriteCaching; -- 0, // BlockSize ... NEED TO BE FILLED -- 4, // IoAlign -- 0, // LastBlock ... NEED TO BE FILLED -- 0, // LowestAlignedLba -- 1, // LogicalBlocksPerPhysicalBlock -- }, // Media; -+ 0, // LastBlock -+ 0, // BlockSize - - { - FvbGetAttributes, // GetAttributes -@@ -115,11 +94,8 @@ NorFlashCreateInstance ( - Instance->DeviceBaseAddress = NorFlashDeviceBase; - Instance->RegionBaseAddress = NorFlashRegionBase; - Instance->Size = NorFlashSize; -- -- Instance->BlockIoProtocol.Media = &Instance->Media; -- Instance->Media.MediaId = Index; -- Instance->Media.BlockSize = BlockSize; -- Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1; -+ Instance->BlockSize = BlockSize; -+ Instance->LastBlock = (NorFlashSize / BlockSize) - 1; - - CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid); - Instance->DevicePath.Index = (UINT8)Index; -@@ -136,8 +112,6 @@ NorFlashCreateInstance ( - &Instance->Handle, - &gEfiDevicePathProtocolGuid, - &Instance->DevicePath, -- &gEfiBlockIoProtocolGuid, -- &Instance->BlockIoProtocol, - &gEfiFirmwareVolumeBlockProtocolGuid, - &Instance->FvbProtocol, - NULL -@@ -151,8 +125,6 @@ NorFlashCreateInstance ( - &Instance->Handle, - &gEfiDevicePathProtocolGuid, - &Instance->DevicePath, -- &gEfiBlockIoProtocolGuid, -- &Instance->BlockIoProtocol, - NULL - ); - if (EFI_ERROR (Status)) { -@@ -434,7 +406,7 @@ NorFlashFvbInitialize ( - PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStorageVariableBase); - - // Set the index of the first LBA for the FVB -- Instance->StartLba = (mFlashNvStorageVariableBase - Instance->RegionBaseAddress) / Instance->Media.BlockSize; -+ Instance->StartLba = (mFlashNvStorageVariableBase - Instance->RegionBaseAddress) / Instance->BlockSize; - - BootMode = GetBootModeHob (); - if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) { -@@ -455,7 +427,7 @@ NorFlashFvbInitialize ( - )); - - // Erase all the NorFlash that is reserved for variable storage -- FvbNumLba = (PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize; -+ FvbNumLba = (PcdGet32 (PcdFlashNvStorageVariableSize) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize) + PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / Instance->BlockSize; - - Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba, EFI_LBA_LIST_TERMINATOR); - if (EFI_ERROR (Status)) { -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -index 53e9d58204..2a3d4a218e 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -@@ -19,7 +19,6 @@ - [Sources.common] - VirtNorFlash.c - VirtNorFlash.h -- VirtNorFlashBlockIoDxe.c - VirtNorFlashDxe.c - VirtNorFlashFvb.c - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -index c824e0a0fb..cc5eefaaf3 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -@@ -89,7 +89,7 @@ InitializeFvAndVariableStoreHeaders ( - } - - // Check if the size of the area is at least one block size -- if ((NvStorageVariableSize <= 0) || (NvStorageVariableSize / Instance->Media.BlockSize <= 0)) { -+ if ((NvStorageVariableSize <= 0) || (NvStorageVariableSize / Instance->BlockSize <= 0)) { - DEBUG (( - DEBUG_ERROR, - "%a: NvStorageVariableSize is 0x%x, should be atleast one block size\n", -@@ -99,7 +99,7 @@ InitializeFvAndVariableStoreHeaders ( - return EFI_INVALID_PARAMETER; - } - -- if ((NvStorageFtwWorkingSize <= 0) || (NvStorageFtwWorkingSize / Instance->Media.BlockSize <= 0)) { -+ if ((NvStorageFtwWorkingSize <= 0) || (NvStorageFtwWorkingSize / Instance->BlockSize <= 0)) { - DEBUG (( - DEBUG_ERROR, - "%a: NvStorageFtwWorkingSize is 0x%x, should be atleast one block size\n", -@@ -109,7 +109,7 @@ InitializeFvAndVariableStoreHeaders ( - return EFI_INVALID_PARAMETER; - } - -- if ((NvStorageFtwSpareSize <= 0) || (NvStorageFtwSpareSize / Instance->Media.BlockSize <= 0)) { -+ if ((NvStorageFtwSpareSize <= 0) || (NvStorageFtwSpareSize / Instance->BlockSize <= 0)) { - DEBUG (( - DEBUG_ERROR, - "%a: NvStorageFtwSpareSize is 0x%x, should be atleast one block size\n", -@@ -120,9 +120,9 @@ InitializeFvAndVariableStoreHeaders ( - } - - // Ensure the Variable area Base Addresses are aligned on a block size boundaries -- if ((NvStorageVariableBase % Instance->Media.BlockSize != 0) || -- (NvStorageFtwWorkingBase % Instance->Media.BlockSize != 0) || -- (NvStorageFtwSpareBase % Instance->Media.BlockSize != 0)) -+ if ((NvStorageVariableBase % Instance->BlockSize != 0) || -+ (NvStorageFtwWorkingBase % Instance->BlockSize != 0) || -+ (NvStorageFtwSpareBase % Instance->BlockSize != 0)) - { - DEBUG ((DEBUG_ERROR, "%a: NvStorage Base addresses must be aligned to block size boundaries", __FUNCTION__)); - return EFI_INVALID_PARAMETER; -@@ -149,8 +149,8 @@ InitializeFvAndVariableStoreHeaders ( - ); - FirmwareVolumeHeader->HeaderLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY); - FirmwareVolumeHeader->Revision = EFI_FVH_REVISION; -- FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1; -- FirmwareVolumeHeader->BlockMap[0].Length = Instance->Media.BlockSize; -+ FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->LastBlock + 1; -+ FirmwareVolumeHeader->BlockMap[0].Length = Instance->BlockSize; - FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0; - FirmwareVolumeHeader->BlockMap[1].Length = 0; - FirmwareVolumeHeader->Checksum = CalculateCheckSum16 ((UINT16 *)FirmwareVolumeHeader, FirmwareVolumeHeader->HeaderLength); -@@ -284,9 +284,6 @@ FvbGetAttributes ( - ) - { - EFI_FVB_ATTRIBUTES_2 FlashFvbAttributes; -- NOR_FLASH_INSTANCE *Instance; -- -- Instance = INSTANCE_FROM_FVB_THIS (This); - - FlashFvbAttributes = (EFI_FVB_ATTRIBUTES_2)( - -@@ -294,17 +291,12 @@ FvbGetAttributes ( - EFI_FVB2_READ_STATUS | // Reads are currently enabled - EFI_FVB2_STICKY_WRITE | // A block erase is required to flip bits into EFI_FVB2_ERASE_POLARITY - EFI_FVB2_MEMORY_MAPPED | // It is memory mapped -- EFI_FVB2_ERASE_POLARITY // After erasure all bits take this value (i.e. '1') -+ EFI_FVB2_ERASE_POLARITY | // After erasure all bits take this value (i.e. '1') -+ EFI_FVB2_WRITE_STATUS | // Writes are currently enabled -+ EFI_FVB2_WRITE_ENABLED_CAP // Writes may be enabled - - ); - -- // Check if it is write protected -- if (Instance->Media.ReadOnly != TRUE) { -- FlashFvbAttributes = FlashFvbAttributes | -- EFI_FVB2_WRITE_STATUS | // Writes are currently enabled -- EFI_FVB2_WRITE_ENABLED_CAP; // Writes may be enabled -- } -- - *Attributes = FlashFvbAttributes; - - DEBUG ((DEBUG_BLKIO, "FvbGetAttributes(0x%X)\n", *Attributes)); -@@ -418,15 +410,15 @@ FvbGetBlockSize ( - - Instance = INSTANCE_FROM_FVB_THIS (This); - -- DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, Instance->Media.BlockSize, Instance->Media.LastBlock)); -+ DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba, Instance->BlockSize, Instance->LastBlock)); - -- if (Lba > Instance->Media.LastBlock) { -- DEBUG ((DEBUG_ERROR, "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba (%ld).\n", Lba, Instance->Media.LastBlock)); -+ if (Lba > Instance->LastBlock) { -+ DEBUG ((DEBUG_ERROR, "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba (%ld).\n", Lba, Instance->LastBlock)); - Status = EFI_INVALID_PARAMETER; - } else { - // This is easy because in this platform each NorFlash device has equal sized blocks. -- *BlockSize = (UINTN)Instance->Media.BlockSize; -- *NumberOfBlocks = (UINTN)(Instance->Media.LastBlock - Lba + 1); -+ *BlockSize = (UINTN)Instance->BlockSize; -+ *NumberOfBlocks = (UINTN)(Instance->LastBlock - Lba + 1); - - DEBUG ((DEBUG_BLKIO, "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize, *NumberOfBlocks)); - -@@ -498,7 +490,7 @@ FvbRead ( - TempStatus = EFI_SUCCESS; - - // Cache the block size to avoid de-referencing pointers all the time -- BlockSize = Instance->Media.BlockSize; -+ BlockSize = Instance->BlockSize; - - DEBUG ((DEBUG_BLKIO, "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n", Offset, *NumBytes, BlockSize)); - -@@ -669,13 +661,6 @@ FvbEraseBlocks ( - - Status = EFI_SUCCESS; - -- // Detect WriteDisabled state -- if (Instance->Media.ReadOnly == TRUE) { -- // Firmware volume is in WriteDisabled state -- DEBUG ((DEBUG_ERROR, "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n")); -- return EFI_ACCESS_DENIED; -- } -- - // Before erasing, check the entire list of parameters to ensure all specified blocks are valid - - VA_START (Args, This); -@@ -698,9 +683,9 @@ FvbEraseBlocks ( - "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%Lu - 1 ) > LastBlock=%ld.\n", - Instance->StartLba + StartingLba, - (UINT64)NumOfLba, -- Instance->Media.LastBlock -+ Instance->LastBlock - )); -- if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->Media.LastBlock)) { -+ if ((NumOfLba == 0) || ((Instance->StartLba + StartingLba + NumOfLba - 1) > Instance->LastBlock)) { - VA_END (Args); - DEBUG ((DEBUG_ERROR, "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n")); - Status = EFI_INVALID_PARAMETER; -@@ -733,7 +718,7 @@ FvbEraseBlocks ( - BlockAddress = GET_NOR_BLOCK_ADDRESS ( - Instance->RegionBaseAddress, - Instance->StartLba + StartingLba, -- Instance->Media.BlockSize -+ Instance->BlockSize - ); - - // Erase it --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch deleted file mode 100644 index 8eff08e..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 15415de9a228e74ff1847777a29f1531754b03b0 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Wed, 11 Jan 2023 19:00:23 +0100 -Subject: [PATCH 08/18] OvmfPkg/VirtNorFlashDxe: map flash memory as - uncacheable - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [10/20] 40ca967bead9ec5c98c528bfe0757f75f3d3352f - -Switching from the ArmPlatformPkg/NorFlashDxe driver to the -OvmfPkg/VirtNorFlashDxe driver had the side effect that flash address -space got registered as EFI_MEMORY_WC instead of EFI_MEMORY_UC. - -That confuses the linux kernel's numa code, seems this makes kernel -consider the flash being node memory. "lsmem" changes from ... - - RANGE SIZE STATE REMOVABLE BLOCK - 0x0000000040000000-0x000000013fffffff 4G online yes 8-39 - -... to ... - - RANGE SIZE STATE REMOVABLE BLOCK - 0x0000000000000000-0x0000000007ffffff 128M online yes 0 - 0x0000000040000000-0x000000013fffffff 4G online yes 8-39 - -... and in the kernel log got new error lines: - - NUMA: Warning: invalid memblk node 512 [mem 0x0000000004000000-0x0000000007ffffff] - NUMA: Faking a node at [mem 0x0000000004000000-0x000000013fffffff] - -Changing the attributes back to EFI_MEMORY_UC fixes this. - -Fixes: b92298af8218 ("ArmVirtPkg/ArmVirtQemu: migrate to OVMF's VirtNorFlashDxe") -Signed-off-by: Gerd Hoffmann -Reviewed-by: Ard Biesheuvel -(cherry picked from commit e5ec3ba409b5baa9cf429cc25fdf3c8d1b8dcef0) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -index ff3121af2a..f9a41f6aab 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -394,14 +394,14 @@ NorFlashFvbInitialize ( - EfiGcdMemoryTypeMemoryMappedIo, - Instance->DeviceBaseAddress, - RuntimeMmioRegionSize, -- EFI_MEMORY_WC | EFI_MEMORY_RUNTIME -+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->SetMemorySpaceAttributes ( - Instance->DeviceBaseAddress, - RuntimeMmioRegionSize, -- EFI_MEMORY_WC | EFI_MEMORY_RUNTIME -+ EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-move-DoErase-code-block-into.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-move-DoErase-code-block-into.patch deleted file mode 100644 index da9eafb..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-move-DoErase-code-block-into.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 791c26a4a172b4a609a708db8018411ab653de4a Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 16 Jan 2024 18:11:05 +0100 -Subject: [PATCH 16/18] OvmfPkg/VirtNorFlashDxe: move DoErase code block into - new function - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [18/20] 10f4685bfcb0c5423e392b4cf0e8633cd25b46b4 - -Move the DoErase code block into a separate function, call the function -instead of jumping around with goto. - -Signed-off-by: Gerd Hoffmann -Message-Id: <20240116171105.37831-7-kraxel@redhat.com> -Reviewed-by: Laszlo Ersek -(cherry picked from commit b481b00f593ef37695ee14271453320ed02a1256) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 76 ++++++++++++++++++-------- - 1 file changed, 52 insertions(+), 24 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 3d1d20daa1..e6aaed27ce 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -502,6 +502,38 @@ NorFlashRead ( - return EFI_SUCCESS; - } - -+STATIC -+EFI_STATUS -+NorFlashWriteSingleBlockWithErase ( -+ IN NOR_FLASH_INSTANCE *Instance, -+ IN EFI_LBA Lba, -+ IN UINTN Offset, -+ IN OUT UINTN *NumBytes, -+ IN UINT8 *Buffer -+ ) -+{ -+ EFI_STATUS Status; -+ -+ // Read NOR Flash data into shadow buffer -+ Status = NorFlashReadBlocks (Instance, Lba, Instance->BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (Status)) { -+ // Return one of the pre-approved error statuses -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Put the data at the appropriate location inside the buffer area -+ CopyMem ((VOID *)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes); -+ -+ // Write the modified buffer back to the NorFlash -+ Status = NorFlashWriteBlocks (Instance, Lba, Instance->BlockSize, Instance->ShadowBuffer); -+ if (EFI_ERROR (Status)) { -+ // Return one of the pre-approved error statuses -+ return EFI_DEVICE_ERROR; -+ } -+ -+ return EFI_SUCCESS; -+} -+ - /* - Write a full or portion of a block. It must not span block boundaries; that is, - Offset + *NumBytes <= Instance->BlockSize. -@@ -607,7 +639,14 @@ NorFlashWriteSingleBlock ( - // that we want to set. In that case, we will need to erase the block first. - for (CurOffset = 0; CurOffset < *NumBytes; CurOffset++) { - if (~(UINT32)OrigData[CurOffset] & (UINT32)Buffer[CurOffset]) { -- goto DoErase; -+ Status = NorFlashWriteSingleBlockWithErase ( -+ Instance, -+ Lba, -+ Offset, -+ NumBytes, -+ Buffer -+ ); -+ return Status; - } - - OrigData[CurOffset] = Buffer[CurOffset]; -@@ -636,33 +675,22 @@ NorFlashWriteSingleBlock ( - goto Exit; - } - } -- --Exit: -- // Put device back into Read Array mode -- SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); -- -+ } else { -+ Status = NorFlashWriteSingleBlockWithErase ( -+ Instance, -+ Lba, -+ Offset, -+ NumBytes, -+ Buffer -+ ); - return Status; - } - --DoErase: -- // Read NOR Flash data into shadow buffer -- Status = NorFlashReadBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -- if (EFI_ERROR (Status)) { -- // Return one of the pre-approved error statuses -- return EFI_DEVICE_ERROR; -- } -- -- // Put the data at the appropriate location inside the buffer area -- CopyMem ((VOID *)((UINTN)Instance->ShadowBuffer + Offset), Buffer, *NumBytes); -- -- // Write the modified buffer back to the NorFlash -- Status = NorFlashWriteBlocks (Instance, Lba, BlockSize, Instance->ShadowBuffer); -- if (EFI_ERROR (Status)) { -- // Return one of the pre-approved error statuses -- return EFI_DEVICE_ERROR; -- } -+Exit: -+ // Put device back into Read Array mode -+ SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); - -- return EFI_SUCCESS; -+ return Status; - } - - EFI_STATUS --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-CheckBlockLocked-feat.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-CheckBlockLocked-feat.patch deleted file mode 100644 index 2fdee8e..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-CheckBlockLocked-feat.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 03e0a729a5c3ebcab8806d136cd8908627bd91c9 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 16:45:02 +0200 -Subject: [PATCH 02/18] OvmfPkg/VirtNorFlashDxe: remove CheckBlockLocked - feature - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [4/20] 990bdf373801df8107d8a6ec4db3fb93e5a6ad68 - -We inherited a feature from the ArmPlatformPkg version of this driver -that never gets enabled. Let's remove it. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 0a64106c566273ff8ef951d56ddfa972fe65bd6c) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 35 +++++---------------- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf | 3 -- - 2 files changed, 8 insertions(+), 30 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 12fa720dad..59a562efdf 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -65,35 +65,16 @@ NorFlashUnlockSingleBlock ( - // Raise the Task Priority Level to TPL_NOTIFY to serialise all its operations - // and to protect shared data structures. - -- if (FeaturePcdGet (PcdNorFlashCheckBlockLocked) == TRUE) { -- do { -- // Request a lock setup -- SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP); -+ // Request a lock setup -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP); - -- // Request an unlock -- SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK); -+ // Request an unlock -+ SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK); - -- // Send command for reading device id -- SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID); -- -- // Read block lock status -- LockStatus = MmioRead32 (CREATE_NOR_ADDRESS (BlockAddress, 2)); -- -- // Decode block lock status -- LockStatus = FOLD_32BIT_INTO_16BIT (LockStatus); -- } while ((LockStatus & 0x1) == 1); -- } else { -- // Request a lock setup -- SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_LOCK_BLOCK_SETUP); -- -- // Request an unlock -- SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_UNLOCK_BLOCK); -- -- // Wait until the status register gives us the all clear -- do { -- LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress); -- } while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); -- } -+ // Wait until the status register gives us the all clear -+ do { -+ LockStatus = NorFlashReadStatusRegister (Instance, BlockAddress); -+ } while ((LockStatus & P30_SR_BIT_WRITE) != P30_SR_BIT_WRITE); - - // Put device back into Read Array mode - SEND_NOR_COMMAND (BlockAddress, 0, P30_CMD_READ_ARRAY); -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -index 1bf50e4823..53e9d58204 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -@@ -24,7 +24,6 @@ - VirtNorFlashFvb.c - - [Packages] -- ArmPlatformPkg/ArmPlatformPkg.dec - EmbeddedPkg/EmbeddedPkg.dec - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec -@@ -66,7 +65,5 @@ - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize - -- gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked -- - [Depex] - gEfiCpuArchProtocolGuid --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-disk-I-O-protocol-imp.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-disk-I-O-protocol-imp.patch deleted file mode 100644 index 9319925..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-remove-disk-I-O-protocol-imp.patch +++ /dev/null @@ -1,386 +0,0 @@ -From 56041232238e4e4d3c8d703b27f51b0bc70fd5c8 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 16:50:05 +0200 -Subject: [PATCH 03/18] OvmfPkg/VirtNorFlashDxe: remove disk I/O protocol - implementation - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [5/20] 0551c3f56f43396cfdc380127565e89d69eb29a3 - -We only use NOR flash for firmware volumes, either for executable images -or for the variable store. So we have no need for exposing disk I/O on -top of the NOR flash partitions so let's remove it. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 68d234989b2d6bd8f255577e08bf8be0b1d197bb) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 129 ------------------ - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h | 29 ---- - .../VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c | 123 ----------------- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 8 -- - 4 files changed, 289 deletions(-) - delete mode 100644 OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 59a562efdf..1094d48f7d 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -788,135 +788,6 @@ NorFlashWriteSingleBlock ( - return EFI_SUCCESS; - } - --/* -- Although DiskIoDxe will automatically install the DiskIO protocol whenever -- we install the BlockIO protocol, its implementation is sub-optimal as it reads -- and writes entire blocks using the BlockIO protocol. In fact we can access -- NOR flash with a finer granularity than that, so we can improve performance -- by directly producing the DiskIO protocol. --*/ -- --/** -- Read BufferSize bytes from Offset into Buffer. -- -- @param This Protocol instance pointer. -- @param MediaId Id of the media, changes every time the media is replaced. -- @param Offset The starting byte offset to read from -- @param BufferSize Size of Buffer -- @param Buffer Buffer containing read data -- -- @retval EFI_SUCCESS The data was read correctly from the device. -- @retval EFI_DEVICE_ERROR The device reported an error while performing the read. -- @retval EFI_NO_MEDIA There is no media in the device. -- @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. -- @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not -- valid for the device. -- --**/ --EFI_STATUS --EFIAPI --NorFlashDiskIoReadDisk ( -- IN EFI_DISK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN UINT64 DiskOffset, -- IN UINTN BufferSize, -- OUT VOID *Buffer -- ) --{ -- NOR_FLASH_INSTANCE *Instance; -- UINT32 BlockSize; -- UINT32 BlockOffset; -- EFI_LBA Lba; -- -- Instance = INSTANCE_FROM_DISKIO_THIS (This); -- -- if (MediaId != Instance->Media.MediaId) { -- return EFI_MEDIA_CHANGED; -- } -- -- BlockSize = Instance->Media.BlockSize; -- Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); -- -- return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer); --} -- --/** -- Writes a specified number of bytes to a device. -- -- @param This Indicates a pointer to the calling context. -- @param MediaId ID of the medium to be written. -- @param Offset The starting byte offset on the logical block I/O device to write. -- @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device. -- @param Buffer A pointer to the buffer containing the data to be written. -- -- @retval EFI_SUCCESS The data was written correctly to the device. -- @retval EFI_WRITE_PROTECTED The device can not be written to. -- @retval EFI_DEVICE_ERROR The device reported an error while performing the write. -- @retval EFI_NO_MEDIA There is no media in the device. -- @retval EFI_MEDIA_CHANGED The MediaId does not match the current device. -- @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not -- valid for the device. -- --**/ --EFI_STATUS --EFIAPI --NorFlashDiskIoWriteDisk ( -- IN EFI_DISK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN UINT64 DiskOffset, -- IN UINTN BufferSize, -- IN VOID *Buffer -- ) --{ -- NOR_FLASH_INSTANCE *Instance; -- UINT32 BlockSize; -- UINT32 BlockOffset; -- EFI_LBA Lba; -- UINTN RemainingBytes; -- UINTN WriteSize; -- EFI_STATUS Status; -- -- Instance = INSTANCE_FROM_DISKIO_THIS (This); -- -- if (MediaId != Instance->Media.MediaId) { -- return EFI_MEDIA_CHANGED; -- } -- -- BlockSize = Instance->Media.BlockSize; -- Lba = (EFI_LBA)DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset); -- -- RemainingBytes = BufferSize; -- -- // Write either all the remaining bytes, or the number of bytes that bring -- // us up to a block boundary, whichever is less. -- // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the next -- // block boundary (even if it is already on one). -- WriteSize = MIN (RemainingBytes, ((DiskOffset | (BlockSize - 1)) + 1) - DiskOffset); -- -- do { -- if (WriteSize == BlockSize) { -- // Write a full block -- Status = NorFlashWriteFullBlock (Instance, Lba, Buffer, BlockSize / sizeof (UINT32)); -- } else { -- // Write a partial block -- Status = NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, &WriteSize, Buffer); -- } -- -- if (EFI_ERROR (Status)) { -- return Status; -- } -- -- // Now continue writing either all the remaining bytes or single blocks. -- RemainingBytes -= WriteSize; -- Buffer = (UINT8 *)Buffer + WriteSize; -- Lba++; -- BlockOffset = 0; -- WriteSize = MIN (RemainingBytes, BlockSize); -- } while (RemainingBytes); -- -- return Status; --} -- - EFI_STATUS - NorFlashReset ( - IN NOR_FLASH_INSTANCE *Instance -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -index e46522a198..7733ee02ee 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.h -@@ -15,7 +15,6 @@ - #include - - #include --#include - #include - - #include -@@ -111,7 +110,6 @@ - #define NOR_FLASH_SIGNATURE SIGNATURE_32('n', 'o', 'r', '0') - #define INSTANCE_FROM_FVB_THIS(a) CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE) - #define INSTANCE_FROM_BLKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, BlockIoProtocol, NOR_FLASH_SIGNATURE) --#define INSTANCE_FROM_DISKIO_THIS(a) CR(a, NOR_FLASH_INSTANCE, DiskIoProtocol, NOR_FLASH_SIGNATURE) - - typedef struct _NOR_FLASH_INSTANCE NOR_FLASH_INSTANCE; - -@@ -134,7 +132,6 @@ struct _NOR_FLASH_INSTANCE { - - EFI_BLOCK_IO_PROTOCOL BlockIoProtocol; - EFI_BLOCK_IO_MEDIA Media; -- EFI_DISK_IO_PROTOCOL DiskIoProtocol; - - EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol; - VOID *ShadowBuffer; -@@ -203,32 +200,6 @@ NorFlashBlockIoFlushBlocks ( - IN EFI_BLOCK_IO_PROTOCOL *This - ); - --// --// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.ReadDisk --// --EFI_STATUS --EFIAPI --NorFlashDiskIoReadDisk ( -- IN EFI_DISK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN UINT64 Offset, -- IN UINTN BufferSize, -- OUT VOID *Buffer -- ); -- --// --// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.WriteDisk --// --EFI_STATUS --EFIAPI --NorFlashDiskIoWriteDisk ( -- IN EFI_DISK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN UINT64 Offset, -- IN UINTN BufferSize, -- IN VOID *Buffer -- ); -- - // - // NorFlashFvbDxe.c - // -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c -deleted file mode 100644 -index ecf152e355..0000000000 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashBlockIoDxe.c -+++ /dev/null -@@ -1,123 +0,0 @@ --/** @file NorFlashBlockIoDxe.c -- -- Copyright (c) 2011-2013, ARM Ltd. All rights reserved.
-- -- SPDX-License-Identifier: BSD-2-Clause-Patent -- --**/ -- --#include --#include -- --#include "VirtNorFlash.h" -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset --// --EFI_STATUS --EFIAPI --NorFlashBlockIoReset ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN BOOLEAN ExtendedVerification -- ) --{ -- NOR_FLASH_INSTANCE *Instance; -- -- Instance = INSTANCE_FROM_BLKIO_THIS (This); -- -- DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n", This->Media->MediaId)); -- -- return NorFlashReset (Instance); --} -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoReadBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN EFI_LBA Lba, -- IN UINTN BufferSizeInBytes, -- OUT VOID *Buffer -- ) --{ -- NOR_FLASH_INSTANCE *Instance; -- EFI_STATUS Status; -- EFI_BLOCK_IO_MEDIA *Media; -- -- if (This == NULL) { -- return EFI_INVALID_PARAMETER; -- } -- -- Instance = INSTANCE_FROM_BLKIO_THIS (This); -- Media = This->Media; -- -- DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes (%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, BufferSizeInBytes, Buffer)); -- -- if (!Media) { -- Status = EFI_INVALID_PARAMETER; -- } else if (!Media->MediaPresent) { -- Status = EFI_NO_MEDIA; -- } else if (Media->MediaId != MediaId) { -- Status = EFI_MEDIA_CHANGED; -- } else if ((Media->IoAlign > 2) && (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) { -- Status = EFI_INVALID_PARAMETER; -- } else { -- Status = NorFlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer); -- } -- -- return Status; --} -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoWriteBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This, -- IN UINT32 MediaId, -- IN EFI_LBA Lba, -- IN UINTN BufferSizeInBytes, -- IN VOID *Buffer -- ) --{ -- NOR_FLASH_INSTANCE *Instance; -- EFI_STATUS Status; -- -- Instance = INSTANCE_FROM_BLKIO_THIS (This); -- -- DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes, BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, Buffer)); -- -- if ( !This->Media->MediaPresent ) { -- Status = EFI_NO_MEDIA; -- } else if ( This->Media->MediaId != MediaId ) { -- Status = EFI_MEDIA_CHANGED; -- } else if ( This->Media->ReadOnly ) { -- Status = EFI_WRITE_PROTECTED; -- } else { -- Status = NorFlashWriteBlocks (Instance, Lba, BufferSizeInBytes, Buffer); -- } -- -- return Status; --} -- --// --// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks --// --EFI_STATUS --EFIAPI --NorFlashBlockIoFlushBlocks ( -- IN EFI_BLOCK_IO_PROTOCOL *This -- ) --{ -- // No Flush required for the NOR Flash driver -- // because cache operations are not permitted. -- -- DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoFlushBlocks: Function NOT IMPLEMENTED (not required).\n")); -- -- // Nothing to do so just return without error -- return EFI_SUCCESS; --} -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -index 819425545e..4875b057d5 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -58,12 +58,6 @@ NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = { - 1, // LogicalBlocksPerPhysicalBlock - }, // Media; - -- { -- EFI_DISK_IO_PROTOCOL_REVISION, // Revision -- NorFlashDiskIoReadDisk, // ReadDisk -- NorFlashDiskIoWriteDisk // WriteDisk -- }, -- - { - FvbGetAttributes, // GetAttributes - FvbSetAttributes, // SetAttributes -@@ -159,8 +153,6 @@ NorFlashCreateInstance ( - &Instance->DevicePath, - &gEfiBlockIoProtocolGuid, - &Instance->BlockIoProtocol, -- &gEfiDiskIoProtocolGuid, -- &Instance->DiskIoProtocol, - NULL - ); - if (EFI_ERROR (Status)) { --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variable2.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variable2.patch deleted file mode 100644 index 106b9db..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variable2.patch +++ /dev/null @@ -1,216 +0,0 @@ -From c4d2144caff4eddb7021752fce6c2dec6d5e1632 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 9 Jan 2024 12:29:02 +0100 -Subject: [PATCH 10/18] OvmfPkg/VirtNorFlashDxe: sanity-check variables - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [12/20] 2ad3957478b82a4ca29249ceb9620f97c591a1fe - -Extend the ValidateFvHeader function, additionally to the header checks -walk over the list of variables and sanity check them. - -In case we find inconsistencies indicating variable store corruption -return EFI_NOT_FOUND so the variable store will be re-initialized. - -Signed-off-by: Gerd Hoffmann -Message-Id: <20240109112902.30002-4-kraxel@redhat.com> -Reviewed-by: Laszlo Ersek -[lersek@redhat.com: fix StartId initialization/assignment coding style] -(cherry picked from commit 4a443f73fd67ca8caaf0a3e1a01f8231b330d2e0) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf | 1 + - OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 149 +++++++++++++++++++- - 2 files changed, 145 insertions(+), 5 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -index 2a3d4a218e..f549400280 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf -@@ -34,6 +34,7 @@ - DxeServicesTableLib - HobLib - IoLib -+ SafeIntLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiLib -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -index c503272a2b..acc4a413ee 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -@@ -12,6 +12,7 @@ - #include - #include - #include -+#include - #include - - #include -@@ -185,11 +186,12 @@ ValidateFvHeader ( - IN NOR_FLASH_INSTANCE *Instance - ) - { -- UINT16 Checksum; -- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; -- VARIABLE_STORE_HEADER *VariableStoreHeader; -- UINTN VariableStoreLength; -- UINTN FvLength; -+ UINT16 Checksum; -+ CONST EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; -+ CONST VARIABLE_STORE_HEADER *VariableStoreHeader; -+ UINTN VarOffset; -+ UINTN VariableStoreLength; -+ UINTN FvLength; - - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)Instance->RegionBaseAddress; - -@@ -258,6 +260,143 @@ ValidateFvHeader ( - return EFI_NOT_FOUND; - } - -+ // -+ // check variables -+ // -+ DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__)); -+ VarOffset = sizeof (*VariableStoreHeader); -+ for ( ; ;) { -+ UINTN VarHeaderEnd; -+ UINTN VarNameEnd; -+ UINTN VarEnd; -+ UINTN VarPadding; -+ CONST AUTHENTICATED_VARIABLE_HEADER *VarHeader; -+ CONST CHAR16 *VarName; -+ CONST CHAR8 *VarState; -+ RETURN_STATUS Status; -+ -+ Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), &VarHeaderEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarHeaderEnd >= VariableStoreHeader->Size) { -+ if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) { -+ CONST UINT16 *StartId; -+ -+ StartId = (VOID *)((UINTN)VariableStoreHeader + VarOffset); -+ if (*StartId == 0x55aa) { -+ DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", __func__)); -+ break; -+ } -+ -+ VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset); -+ if (VarHeader->StartId != 0x55aa) { -+ DEBUG ((DEBUG_INFO, "%a: end of var list (no startid)\n", __func__)); -+ break; -+ } -+ -+ VarName = NULL; -+ switch (VarHeader->State) { -+ // usage: State = VAR_HEADER_VALID_ONLY -+ case VAR_HEADER_VALID_ONLY: -+ VarState = "header-ok"; -+ VarName = L""; -+ break; -+ -+ // usage: State = VAR_ADDED -+ case VAR_ADDED: -+ VarState = "ok"; -+ break; -+ -+ // usage: State &= VAR_IN_DELETED_TRANSITION -+ case VAR_ADDED &VAR_IN_DELETED_TRANSITION: -+ VarState = "del-in-transition"; -+ break; -+ -+ // usage: State &= VAR_DELETED -+ case VAR_ADDED &VAR_DELETED: -+ case VAR_ADDED &VAR_DELETED &VAR_IN_DELETED_TRANSITION: -+ VarState = "deleted"; -+ break; -+ -+ default: -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: invalid variable state: 0x%x\n", -+ __func__, -+ VarHeader->State -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ Status = SafeUintnAdd (VarHeaderEnd, VarHeader->NameSize, &VarNameEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ Status = SafeUintnAdd (VarNameEnd, VarHeader->DataSize, &VarEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarEnd > VariableStoreHeader->Size) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: invalid variable size: 0x%Lx + 0x%Lx + 0x%x + 0x%x > 0x%x\n", -+ __func__, -+ (UINT64)VarOffset, -+ (UINT64)(sizeof (*VarHeader)), -+ VarHeader->NameSize, -+ VarHeader->DataSize, -+ VariableStoreHeader->Size -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (((VarHeader->NameSize & 1) != 0) || -+ (VarHeader->NameSize < 4)) -+ { -+ DEBUG ((DEBUG_ERROR, "%a: invalid name size\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarName == NULL) { -+ VarName = (VOID *)((UINTN)VariableStoreHeader + VarHeaderEnd); -+ if (VarName[VarHeader->NameSize / 2 - 1] != L'\0') { -+ DEBUG ((DEBUG_ERROR, "%a: name is not null terminated\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ -+ DEBUG (( -+ DEBUG_VERBOSE, -+ "%a: +0x%04Lx: name=0x%x data=0x%x guid=%g '%s' (%a)\n", -+ __func__, -+ (UINT64)VarOffset, -+ VarHeader->NameSize, -+ VarHeader->DataSize, -+ &VarHeader->VendorGuid, -+ VarName, -+ VarState -+ )); -+ -+ VarPadding = (4 - (VarEnd & 3)) & 3; -+ Status = SafeUintnAdd (VarEnd, VarPadding, &VarOffset); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ - return EFI_SUCCESS; - } - --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variables.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variables.patch deleted file mode 100644 index f94ca10..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variables.patch +++ /dev/null @@ -1,216 +0,0 @@ -From c4eef747624d41aaa09dc64ccafdb84bf1fe656e Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 9 Jan 2024 12:29:02 +0100 -Subject: [PATCH 2/2] OvmfPkg/VirtNorFlashDxe: sanity-check variables - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 42: OvmfPkg/VirtNorFlashDxe: sanity-check variables -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [2/2] 56ff961f754d517c0e27ccf46a95b228efe7ab4b - -Extend the ValidateFvHeader function, additionally to the header checks -walk over the list of variables and sanity check them. - -In case we find inconsistencies indicating variable store corruption -return EFI_NOT_FOUND so the variable store will be re-initialized. - -Signed-off-by: Gerd Hoffmann -Message-Id: <20240109112902.30002-4-kraxel@redhat.com> -Reviewed-by: Laszlo Ersek -[lersek@redhat.com: fix StartId initialization/assignment coding style] -(cherry picked from commit 4a443f73fd67ca8caaf0a3e1a01f8231b330d2e0) ---- - .../Drivers/NorFlashDxe/NorFlashDxe.inf | 1 + - .../Drivers/NorFlashDxe/NorFlashFvb.c | 149 +++++++++++++++++- - 2 files changed, 145 insertions(+), 5 deletions(-) - -diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -index f8d4c27031..10388880a1 100644 ---- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf -@@ -35,6 +35,7 @@ - DebugLib - HobLib - NorFlashPlatformLib -+ SafeIntLib - UefiLib - UefiDriverEntryPoint - UefiBootServicesTableLib -diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -index 904605cbbc..2a166c94a6 100644 ---- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -@@ -13,6 +13,7 @@ - #include - #include - #include -+#include - - #include - #include -@@ -166,11 +167,12 @@ ValidateFvHeader ( - IN NOR_FLASH_INSTANCE *Instance - ) - { -- UINT16 Checksum; -- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; -- VARIABLE_STORE_HEADER *VariableStoreHeader; -- UINTN VariableStoreLength; -- UINTN FvLength; -+ UINT16 Checksum; -+ CONST EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; -+ CONST VARIABLE_STORE_HEADER *VariableStoreHeader; -+ UINTN VarOffset; -+ UINTN VariableStoreLength; -+ UINTN FvLength; - - FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Instance->RegionBaseAddress; - -@@ -223,6 +225,143 @@ ValidateFvHeader ( - return EFI_NOT_FOUND; - } - -+ // -+ // check variables -+ // -+ DEBUG ((DEBUG_INFO, "%a: checking variables\n", __func__)); -+ VarOffset = sizeof (*VariableStoreHeader); -+ for ( ; ;) { -+ UINTN VarHeaderEnd; -+ UINTN VarNameEnd; -+ UINTN VarEnd; -+ UINTN VarPadding; -+ CONST AUTHENTICATED_VARIABLE_HEADER *VarHeader; -+ CONST CHAR16 *VarName; -+ CONST CHAR8 *VarState; -+ RETURN_STATUS Status; -+ -+ Status = SafeUintnAdd (VarOffset, sizeof (*VarHeader), &VarHeaderEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarHeaderEnd >= VariableStoreHeader->Size) { -+ if (VarOffset <= VariableStoreHeader->Size - sizeof (UINT16)) { -+ CONST UINT16 *StartId; -+ -+ StartId = (VOID *)((UINTN)VariableStoreHeader + VarOffset); -+ if (*StartId == 0x55aa) { -+ DEBUG ((DEBUG_ERROR, "%a: startid at invalid location\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: end of var list (no space left)\n", __func__)); -+ break; -+ } -+ -+ VarHeader = (VOID *)((UINTN)VariableStoreHeader + VarOffset); -+ if (VarHeader->StartId != 0x55aa) { -+ DEBUG ((DEBUG_INFO, "%a: end of var list (no startid)\n", __func__)); -+ break; -+ } -+ -+ VarName = NULL; -+ switch (VarHeader->State) { -+ // usage: State = VAR_HEADER_VALID_ONLY -+ case VAR_HEADER_VALID_ONLY: -+ VarState = "header-ok"; -+ VarName = L""; -+ break; -+ -+ // usage: State = VAR_ADDED -+ case VAR_ADDED: -+ VarState = "ok"; -+ break; -+ -+ // usage: State &= VAR_IN_DELETED_TRANSITION -+ case VAR_ADDED &VAR_IN_DELETED_TRANSITION: -+ VarState = "del-in-transition"; -+ break; -+ -+ // usage: State &= VAR_DELETED -+ case VAR_ADDED &VAR_DELETED: -+ case VAR_ADDED &VAR_DELETED &VAR_IN_DELETED_TRANSITION: -+ VarState = "deleted"; -+ break; -+ -+ default: -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: invalid variable state: 0x%x\n", -+ __func__, -+ VarHeader->State -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ Status = SafeUintnAdd (VarHeaderEnd, VarHeader->NameSize, &VarNameEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ Status = SafeUintnAdd (VarNameEnd, VarHeader->DataSize, &VarEnd); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarEnd > VariableStoreHeader->Size) { -+ DEBUG (( -+ DEBUG_ERROR, -+ "%a: invalid variable size: 0x%Lx + 0x%Lx + 0x%x + 0x%x > 0x%x\n", -+ __func__, -+ (UINT64)VarOffset, -+ (UINT64)(sizeof (*VarHeader)), -+ VarHeader->NameSize, -+ VarHeader->DataSize, -+ VariableStoreHeader->Size -+ )); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (((VarHeader->NameSize & 1) != 0) || -+ (VarHeader->NameSize < 4)) -+ { -+ DEBUG ((DEBUG_ERROR, "%a: invalid name size\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ -+ if (VarName == NULL) { -+ VarName = (VOID *)((UINTN)VariableStoreHeader + VarHeaderEnd); -+ if (VarName[VarHeader->NameSize / 2 - 1] != L'\0') { -+ DEBUG ((DEBUG_ERROR, "%a: name is not null terminated\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ -+ DEBUG (( -+ DEBUG_VERBOSE, -+ "%a: +0x%04Lx: name=0x%x data=0x%x guid=%g '%s' (%a)\n", -+ __func__, -+ (UINT64)VarOffset, -+ VarHeader->NameSize, -+ VarHeader->DataSize, -+ &VarHeader->VendorGuid, -+ VarName, -+ VarState -+ )); -+ -+ VarPadding = (4 - (VarEnd & 3)) & 3; -+ Status = SafeUintnAdd (VarEnd, VarPadding, &VarOffset); -+ if (RETURN_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: integer overflow\n", __func__)); -+ return EFI_NOT_FOUND; -+ } -+ } -+ - return EFI_SUCCESS; - } - --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariable2.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariable2.patch deleted file mode 100644 index a735619..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariable2.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 1444157aad1b98ce9c1193ef109011b084113890 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 9 Jan 2024 12:29:01 +0100 -Subject: [PATCH 09/18] OvmfPkg/VirtNorFlashDxe: stop accepting - gEfiVariableGuid -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [11/20] c7b9cd1b716e1b8163b8094fbea8117241901815 - -Only accept gEfiAuthenticatedVariableGuid when checking the variable -store header in ValidateFvHeader(). - -The edk2 code base has been switched to use the authenticated varstore -format unconditionally (even in case secure boot is not used or -supported) a few years ago. - -Suggested-by: László Érsek -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240109112902.30002-3-kraxel@redhat.com> -(cherry picked from commit ae22b2f136bcbd27135a5f4dd76d3a68a172d00e) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -index cc5eefaaf3..c503272a2b 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashFvb.c -@@ -239,9 +239,7 @@ ValidateFvHeader ( - VariableStoreHeader = (VARIABLE_STORE_HEADER *)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); - - // Check the Variable Store Guid -- if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && -- !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) -- { -+ if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { - DEBUG (( - DEBUG_INFO, - "%a: Variable Store Guid non-compatible\n", --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariableG.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariableG.patch deleted file mode 100644 index a3b6933..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariableG.patch +++ /dev/null @@ -1,47 +0,0 @@ -From abe5b633eaae333190fb742af3fa15968f02a92e Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Tue, 9 Jan 2024 12:29:01 +0100 -Subject: [PATCH 1/2] OvmfPkg/VirtNorFlashDxe: stop accepting gEfiVariableGuid -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 42: OvmfPkg/VirtNorFlashDxe: sanity-check variables -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [1/2] 790f895bd180bc2c4b957a7a3c7d07e9107dd74b - -Only accept gEfiAuthenticatedVariableGuid when checking the variable -store header in ValidateFvHeader(). - -The edk2 code base has been switched to use the authenticated varstore -format unconditionally (even in case secure boot is not used or -supported) a few years ago. - -Suggested-by: László Érsek -Signed-off-by: Gerd Hoffmann -Reviewed-by: Laszlo Ersek -Message-Id: <20240109112902.30002-3-kraxel@redhat.com> -(cherry picked from commit ae22b2f136bcbd27135a5f4dd76d3a68a172d00e) ---- - ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -index db8eb595f4..904605cbbc 100644 ---- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvb.c -@@ -210,8 +210,7 @@ ValidateFvHeader ( - VariableStoreHeader = (VARIABLE_STORE_HEADER*)((UINTN)FwVolHeader + FwVolHeader->HeaderLength); - - // Check the Variable Store Guid -- if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiVariableGuid) && -- !CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { -+ if (!CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid)) { - DEBUG ((EFI_D_INFO, "%a: Variable Store Guid non-compatible\n", - __FUNCTION__)); - return EFI_NOT_FOUND; --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-use-EFI_MEMORY_WC-and-drop-A.patch b/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-use-EFI_MEMORY_WC-and-drop-A.patch deleted file mode 100644 index a61f223..0000000 --- a/SOURCES/edk2-OvmfPkg-VirtNorFlashDxe-use-EFI_MEMORY_WC-and-drop-A.patch +++ /dev/null @@ -1,150 +0,0 @@ -From e65da48afdabc9a5cba1c212b4323898b91ef2a4 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 18:16:18 +0200 -Subject: [PATCH 07/18] OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and drop - AlignedCopyMem() - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [9/20] 0c01619eff8282d08e05fae8c37175b944449f59 - -NOR flash emulation under KVM involves switching between two modes, -where array mode is backed by a read-only memslot, and programming mode -is fully emulated, i.e., the memory region is not backed by anything, -and the faulting accesses are forwarded to the VMM by the hypervisor, -which translates them into NOR flash programming commands. - -Normally, we are limited to the use of device attributes when mapping -such regions, given that the programming mode has MMIO semantics. -However, when running under KVM, the chosen memory attributes only take -effect when in array mode, since no memory mapping exists otherwise. - -This means we can tune the memory mapping so it behaves a bit more like -a ROM, by switching to EFI_MEMORY_WC attributes. This means we no longer -need a special CopyMem() implementation that avoids unaligned accesses -at all cost. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 789a723285533f35652ebd6029976e2ddc955655) ---- - OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 65 +---------------------- - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 4 +- - 2 files changed, 4 insertions(+), 65 deletions(-) - -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -index 0343131a54..1afd60ce66 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c -@@ -401,67 +401,6 @@ NorFlashWriteBlocks ( - return Status; - } - --#define BOTH_ALIGNED(a, b, align) ((((UINTN)(a) | (UINTN)(b)) & ((align) - 1)) == 0) -- --/** -- Copy Length bytes from Source to Destination, using aligned accesses only. -- Note that this implementation uses memcpy() semantics rather then memmove() -- semantics, i.e., SourceBuffer and DestinationBuffer should not overlap. -- -- @param DestinationBuffer The target of the copy request. -- @param SourceBuffer The place to copy from. -- @param Length The number of bytes to copy. -- -- @return Destination -- --**/ --STATIC --VOID * --AlignedCopyMem ( -- OUT VOID *DestinationBuffer, -- IN CONST VOID *SourceBuffer, -- IN UINTN Length -- ) --{ -- UINT8 *Destination8; -- CONST UINT8 *Source8; -- UINT32 *Destination32; -- CONST UINT32 *Source32; -- UINT64 *Destination64; -- CONST UINT64 *Source64; -- -- if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 8) && (Length >= 8)) { -- Destination64 = DestinationBuffer; -- Source64 = SourceBuffer; -- while (Length >= 8) { -- *Destination64++ = *Source64++; -- Length -= 8; -- } -- -- Destination8 = (UINT8 *)Destination64; -- Source8 = (CONST UINT8 *)Source64; -- } else if (BOTH_ALIGNED (DestinationBuffer, SourceBuffer, 4) && (Length >= 4)) { -- Destination32 = DestinationBuffer; -- Source32 = SourceBuffer; -- while (Length >= 4) { -- *Destination32++ = *Source32++; -- Length -= 4; -- } -- -- Destination8 = (UINT8 *)Destination32; -- Source8 = (CONST UINT8 *)Source32; -- } else { -- Destination8 = DestinationBuffer; -- Source8 = SourceBuffer; -- } -- -- while (Length-- != 0) { -- *Destination8++ = *Source8++; -- } -- -- return DestinationBuffer; --} -- - EFI_STATUS - NorFlashReadBlocks ( - IN NOR_FLASH_INSTANCE *Instance, -@@ -516,7 +455,7 @@ NorFlashReadBlocks ( - SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); - - // Readout the data -- AlignedCopyMem (Buffer, (VOID *)StartAddress, BufferSizeInBytes); -+ CopyMem (Buffer, (VOID *)StartAddress, BufferSizeInBytes); - - return EFI_SUCCESS; - } -@@ -558,7 +497,7 @@ NorFlashRead ( - SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY); - - // Readout the data -- AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes); -+ CopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes); - - return EFI_SUCCESS; - } -diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -index f9a41f6aab..ff3121af2a 100644 ---- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -+++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c -@@ -394,14 +394,14 @@ NorFlashFvbInitialize ( - EfiGcdMemoryTypeMemoryMappedIo, - Instance->DeviceBaseAddress, - RuntimeMmioRegionSize, -- EFI_MEMORY_UC | EFI_MEMORY_RUNTIME -+ EFI_MEMORY_WC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->SetMemorySpaceAttributes ( - Instance->DeviceBaseAddress, - RuntimeMmioRegionSize, -- EFI_MEMORY_UC | EFI_MEMORY_RUNTIME -+ EFI_MEMORY_WC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-clone-NorFlashPlatformLib-into-VirtNorFlashP.patch b/SOURCES/edk2-OvmfPkg-clone-NorFlashPlatformLib-into-VirtNorFlashP.patch deleted file mode 100644 index 178b1e7..0000000 --- a/SOURCES/edk2-OvmfPkg-clone-NorFlashPlatformLib-into-VirtNorFlashP.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 59fb955aa77b75345f7828bf9f83764adf4bed46 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Mon, 24 Oct 2022 18:35:10 +0200 -Subject: [PATCH 18/18] OvmfPkg: clone NorFlashPlatformLib into - VirtNorFlashPlatformLib - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 43: OvmfPkg/VirtNorFlashDxe backport -RH-Jira: RHEL-17587 -RH-Acked-by: Laszlo Ersek -RH-Commit: [20/20] 50ea104b99a997d7d08c1fdef617df1d930ffae6 - -Create a new library class in Ovmf that duplicates the existing -NorFlashPlatformLib, but which will be tied to the VirtNorFlashDxe -driver that will be introduced in a subsequent patch. This allows us to -retire the original from ArmPlatformPkg. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Sunil V L -(cherry picked from commit 16bf588b604a9f190accb71ada715b81756c94e2) ---- - .../Include/Library/VirtNorFlashPlatformLib.h | 30 +++++++++++++++++++ - OvmfPkg/OvmfPkg.dec | 4 +++ - 2 files changed, 34 insertions(+) - create mode 100644 OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h - -diff --git a/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h b/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h -new file mode 100644 -index 0000000000..8f5b5e972d ---- /dev/null -+++ b/OvmfPkg/Include/Library/VirtNorFlashPlatformLib.h -@@ -0,0 +1,30 @@ -+/** @file -+ -+ Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+ **/ -+ -+#ifndef __VIRT_NOR_FLASH_PLATFORM_LIB__ -+#define __VIRT_NOR_FLASH_PLATFORM_LIB__ -+ -+typedef struct { -+ UINTN DeviceBaseAddress; // Start address of the Device Base Address (DBA) -+ UINTN RegionBaseAddress; // Start address of one single region -+ UINTN Size; -+ UINTN BlockSize; -+} VIRT_NOR_FLASH_DESCRIPTION; -+ -+EFI_STATUS -+VirtNorFlashPlatformInitialization ( -+ VOID -+ ); -+ -+EFI_STATUS -+VirtNorFlashPlatformGetDevices ( -+ OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions, -+ OUT UINT32 *Count -+ ); -+ -+#endif /* __VIRT_NOR_FLASH_PLATFORM_LIB__ */ -diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec -index 340d83f794..e65ebd81c8 100644 ---- a/OvmfPkg/OvmfPkg.dec -+++ b/OvmfPkg/OvmfPkg.dec -@@ -97,6 +97,10 @@ - # transports. - VirtioMmioDeviceLib|Include/Library/VirtioMmioDeviceLib.h - -+ ## @libraryclass Provides a Nor flash interface. -+ # -+ VirtNorFlashPlatformLib|Include/Library/VirtNorFlashPlatformLib.h -+ - ## @libraryclass Invoke Xen hypercalls - # - XenHypercallLib|Include/Library/XenHypercallLib.h --- -2.41.0 - diff --git a/SOURCES/edk2-OvmfPkg-wire-up-RngDxe.patch b/SOURCES/edk2-OvmfPkg-wire-up-RngDxe.patch deleted file mode 100644 index 22ada98..0000000 --- a/SOURCES/edk2-OvmfPkg-wire-up-RngDxe.patch +++ /dev/null @@ -1,318 +0,0 @@ -From c74cced5adaab44edf1bbfae63010b3fa31d4c69 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Sun, 23 Jun 2024 19:20:44 -0400 -Subject: [PATCH 27/31] OvmfPkg: wire up RngDxe - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [27/31] 90226f6630261d2823bed33c4e2f6c96a4125027 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 -Conflicts: - Needed to apply 9 earlier commits from Pierre Gondois - to make this one apply and build. - - Cherry pick wanted to add include files from the - missing 'add ShellComponents' (commit 2cb466cc2cbf...) - series. This had to be handled manually. - - There are no Dsc and Fdf subdirectories under - OvmfPkg/Include/ in this version. We adjust includes - and move files to OvmfPkg/ where needed. - -commit 712797cf19acd292bf203522a79e40e7e13d268b -Author: Gerd Hoffmann -Date: Fri May 24 12:51:17 2024 +0200 - - OvmfPkg: wire up RngDxe - - Add OvmfRng include snippets with the random number generator - configuration for OVMF. Include RngDxe, build with BaseRngLib, - so the rdrand instruction is used (if available). - - Also move VirtioRng to the include snippets. - - Use the new include snippets for OVMF builds. - - Signed-off-by: Gerd Hoffmann - -Signed-off-by: Jon Maloy ---- - OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +- - OvmfPkg/AmdSev/AmdSevX64.fdf | 3 ++- - OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 +- - OvmfPkg/Microvm/MicrovmX64.dsc | 2 +- - OvmfPkg/Microvm/MicrovmX64.fdf | 3 ++- - OvmfPkg/OvmfPkgIa32.dsc | 2 +- - OvmfPkg/OvmfPkgIa32.fdf | 3 ++- - OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- - OvmfPkg/OvmfPkgIa32X64.fdf | 2 +- - OvmfPkg/OvmfPkgX64.dsc | 2 +- - OvmfPkg/OvmfPkgX64.fdf | 2 +- - OvmfPkg/OvmfRngComponents.dsc.inc | 9 +++++++++ - OvmfPkg/OvmfRngDxe.fdf.inc | 6 ++++++ - 13 files changed, 29 insertions(+), 11 deletions(-) - create mode 100644 OvmfPkg/OvmfRngComponents.dsc.inc - create mode 100644 OvmfPkg/OvmfRngDxe.fdf.inc - -diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc -index a1a6897bc2..499ad2e6e8 100644 ---- a/OvmfPkg/AmdSev/AmdSevX64.dsc -+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc -@@ -707,7 +707,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -824,6 +823,7 @@ - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } - !endif -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - OvmfPkg/PlatformDxe/Platform.inf - OvmfPkg/AmdSevDxe/AmdSevDxe.inf -diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf -index 5662609886..06ff2f1d30 100644 ---- a/OvmfPkg/AmdSev/AmdSevX64.fdf -+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf -@@ -222,7 +222,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - INF OvmfPkg/Virtio10Dxe/Virtio10.inf - INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf --INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -327,6 +326,8 @@ INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf - !endif - !endif - -+!include OvmfPkg/OvmfRngDxe.fdf.inc -+ - ################################################################################ - - [FV.FVMAIN_COMPACT] -diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc -index d08b77ff25..4f2909b76e 100644 ---- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc -+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc -@@ -635,7 +635,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -744,6 +743,7 @@ - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - !if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc -index afd4bf3e98..0efb0b456d 100644 ---- a/OvmfPkg/Microvm/MicrovmX64.dsc -+++ b/OvmfPkg/Microvm/MicrovmX64.dsc -@@ -694,7 +694,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf - MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf -@@ -820,6 +819,7 @@ - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - OvmfPkg/PlatformDxe/Platform.inf - OvmfPkg/IoMmuDxe/IoMmuDxe.inf -diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf -index 6314014f3d..bd5afdafe0 100644 ---- a/OvmfPkg/Microvm/MicrovmX64.fdf -+++ b/OvmfPkg/Microvm/MicrovmX64.fdf -@@ -230,7 +230,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - INF OvmfPkg/Virtio10Dxe/Virtio10.inf - INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf --INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - - INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf - INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf -@@ -322,6 +321,8 @@ INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf - INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf - INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf - -+!include OvmfPkg/OvmfRngDxe.fdf.inc -+ - ################################################################################ - - [FV.FVMAIN_COMPACT] -diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc -index 47426c5cd2..f03906a9ff 100644 ---- a/OvmfPkg/OvmfPkgIa32.dsc -+++ b/OvmfPkg/OvmfPkgIa32.dsc -@@ -801,7 +801,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -958,6 +957,7 @@ - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - !if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf -index 00ea14adf0..050148948c 100644 ---- a/OvmfPkg/OvmfPkgIa32.fdf -+++ b/OvmfPkg/OvmfPkgIa32.fdf -@@ -228,7 +228,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - INF OvmfPkg/Virtio10Dxe/Virtio10.inf - INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf --INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -363,6 +362,7 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf - # - # TPM support - # -+ - !if $(TPM_ENABLE) == TRUE - INF SecurityPkg/Tcg/TcgDxe/TcgDxe.inf - INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf -@@ -371,6 +371,7 @@ INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf - INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf - !endif - !endif -+!include OvmfPkg/OvmfRngDxe.fdf.inc - - !if $(LOAD_X64_ON_IA32_ENABLE) == TRUE - INF OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf -diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc -index d4b30e8133..81145050c3 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.dsc -+++ b/OvmfPkg/OvmfPkgIa32X64.dsc -@@ -815,7 +815,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -972,6 +971,7 @@ - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - !if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf -index e33a40c44e..3e2373f225 100644 ---- a/OvmfPkg/OvmfPkgIa32X64.fdf -+++ b/OvmfPkg/OvmfPkgIa32X64.fdf -@@ -232,7 +232,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - INF OvmfPkg/Virtio10Dxe/Virtio10.inf - INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf --INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -381,6 +380,7 @@ INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf - INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf - !endif - !endif -+!include OvmfPkg/OvmfRngDxe.fdf.inc - - ################################################################################ - -diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc -index 5b0f6c8747..1cb169b447 100644 ---- a/OvmfPkg/OvmfPkgX64.dsc -+++ b/OvmfPkg/OvmfPkgX64.dsc -@@ -813,7 +813,6 @@ - OvmfPkg/Virtio10Dxe/Virtio10.inf - OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - OvmfPkg/VirtioScsiDxe/VirtioScsi.inf -- OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -970,6 +969,7 @@ - gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE - gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 - } -+!include OvmfPkg/OvmfRngComponents.dsc.inc - - !if $(SECURE_BOOT_ENABLE) == TRUE - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf -diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf -index 85b4b23857..8ba0ca437a 100644 ---- a/OvmfPkg/OvmfPkgX64.fdf -+++ b/OvmfPkg/OvmfPkgX64.fdf -@@ -248,7 +248,6 @@ INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf - INF OvmfPkg/Virtio10Dxe/Virtio10.inf - INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf - INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf --INF OvmfPkg/VirtioRngDxe/VirtioRng.inf - !if $(PVSCSI_ENABLE) == TRUE - INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf - !endif -@@ -397,6 +396,7 @@ INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf - INF SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf - !endif - !endif -+!include OvmfPkg/OvmfRngDxe.fdf.inc - - ################################################################################ - -diff --git a/OvmfPkg/OvmfRngComponents.dsc.inc b/OvmfPkg/OvmfRngComponents.dsc.inc -new file mode 100644 -index 0000000000..68839a0caa ---- /dev/null -+++ b/OvmfPkg/OvmfRngComponents.dsc.inc -@@ -0,0 +1,9 @@ -+## -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+ -+ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf { -+ -+ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf -+ } -+ OvmfPkg/VirtioRngDxe/VirtioRng.inf -diff --git a/OvmfPkg/OvmfRngDxe.fdf.inc b/OvmfPkg/OvmfRngDxe.fdf.inc -new file mode 100644 -index 0000000000..99cb4a32b1 ---- /dev/null -+++ b/OvmfPkg/OvmfRngDxe.fdf.inc -@@ -0,0 +1,6 @@ -+## -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+ -+INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+INF OvmfPkg/VirtioRngDxe/VirtioRng.inf --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-Adding-CVE-2022-36763-to-SecurityFixes.y.patch b/SOURCES/edk2-SecurityPkg-Adding-CVE-2022-36763-to-SecurityFixes.y.patch deleted file mode 100644 index f2f31b7..0000000 --- a/SOURCES/edk2-SecurityPkg-Adding-CVE-2022-36763-to-SecurityFixes.y.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 2794a967f43f2bbdfcd2cb5197ac8cad4b13c3de Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 17 Jan 2024 12:20:52 -0500 -Subject: [PATCH 08/17] SecurityPkg: Adding CVE 2022-36763 to - SecurityFixes.yaml - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [8/13] 74117caf760e403566f6511332b2c0f41483f28c (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -Upstream: Merged -CVE: CVE-2022-36763 - -commit 1ddcb9fc6b4164e882687b031e8beacfcf7df29e -Author: Douglas Flick [MSFT] -Date: Fri Jan 12 02:16:03 2024 +0800 - - SecurityPkg: : Adding CVE 2022-36763 to SecurityFixes.yaml - - This creates / adds a security file that tracks the security fixes - found in this package and can be used to find the fixes that were - applied. - - Cc: Jiewen Yao - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - SecurityPkg/SecurityFixes.yaml | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - create mode 100644 SecurityPkg/SecurityFixes.yaml - -diff --git a/SecurityPkg/SecurityFixes.yaml b/SecurityPkg/SecurityFixes.yaml -new file mode 100644 -index 0000000000..f9e3e7be74 ---- /dev/null -+++ b/SecurityPkg/SecurityFixes.yaml -@@ -0,0 +1,22 @@ -+## @file -+# Security Fixes for SecurityPkg -+# -+# Copyright (c) Microsoft Corporation -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+CVE_2022_36763: -+ commit_titles: -+ - "SecurityPkg: DxeTpm2Measurement: SECURITY PATCH 4117 - CVE 2022-36763" -+ - "SecurityPkg: DxeTpmMeasurement: SECURITY PATCH 4117 - CVE 2022-36763" -+ - "SecurityPkg: : Adding CVE 2022-36763 to SecurityFixes.yaml" -+ cve: CVE-2022-36763 -+ date_reported: 2022-10-25 11:31 UTC -+ description: (CVE-2022-36763) - Heap Buffer Overflow in Tcg2MeasureGptTable() -+ note: This patch is related to and supersedes TCBZ2168 -+ files_impacted: -+ - Library\DxeTpm2MeasureBootLib\DxeTpm2MeasureBootLib.c -+ - Library\DxeTpmMeasureBootLib\DxeTpmMeasureBootLib.c -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4117 -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=2168 -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=1990 --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-Change-OPTIONAL-keyword-usage-style.patch b/SOURCES/edk2-SecurityPkg-Change-OPTIONAL-keyword-usage-style.patch deleted file mode 100644 index bc3723f..0000000 --- a/SOURCES/edk2-SecurityPkg-Change-OPTIONAL-keyword-usage-style.patch +++ /dev/null @@ -1,403 +0,0 @@ -From e2ccaef3baa2eb045019558c325bb94cabf65e1a Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 7 Feb 2024 11:56:37 -0500 -Subject: [PATCH 02/17] SecurityPkg: Change OPTIONAL keyword usage style - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [2/13] 6a2141d871e3efc3aeea1994ab9c325614ddce57 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged - -commit 948f4003ee399241a40dc147a738f05ad2e37375 -Author: Michael D Kinney -Date: Thu Dec 2 18:00:56 2021 -0800 - - SecurityPkg: Change OPTIONAL keyword usage style - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3760 - - Update all use of ', OPTIONAL' to ' OPTIONAL,' for function params. - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael Kubacki - Signed-off-by: Michael D Kinney - Reviewed-by: Jian J Wang - -Signed-off-by: Jon Maloy ---- - SecurityPkg/Include/Library/Tcg2PpVendorLib.h | 2 +- - SecurityPkg/Include/Library/Tpm2CommandLib.h | 14 +++++++------- - SecurityPkg/Library/AuthVariableLib/AuthService.c | 6 +++--- - .../DxeImageAuthenticationStatusLib.c | 2 +- - .../DxeImageVerificationLib.c | 2 +- - .../DxeRsa2048Sha256GuidedSectionExtractLib.c | 2 +- - .../DxeTcg2PhysicalPresenceLib.c | 4 ++-- - .../DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c | 2 +- - .../DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c | 2 +- - .../PeiRsa2048Sha256GuidedSectionExtractLib.c | 2 +- - .../Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.c | 2 +- - .../Tpm2CommandLib/Tpm2EnhancedAuthorization.c | 2 +- - SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 2 +- - SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c | 2 +- - SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c | 2 +- - SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c | 6 +++--- - .../RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 2 +- - .../RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 2 +- - .../RandomNumberGenerator/RngDxe/RngDxeInternals.h | 2 +- - SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c | 2 +- - 20 files changed, 31 insertions(+), 31 deletions(-) - -diff --git a/SecurityPkg/Include/Library/Tcg2PpVendorLib.h b/SecurityPkg/Include/Library/Tcg2PpVendorLib.h -index 569eba6874..914517f034 100644 ---- a/SecurityPkg/Include/Library/Tcg2PpVendorLib.h -+++ b/SecurityPkg/Include/Library/Tcg2PpVendorLib.h -@@ -40,7 +40,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - UINT32 - EFIAPI - Tcg2PpVendorLibExecutePendingRequest ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN UINT32 OperationRequest, - IN OUT UINT32 *ManagementFlags, - OUT BOOLEAN *ResetRequired -diff --git a/SecurityPkg/Include/Library/Tpm2CommandLib.h b/SecurityPkg/Include/Library/Tpm2CommandLib.h -index ee8eb62295..ad3b982d48 100644 ---- a/SecurityPkg/Include/Library/Tpm2CommandLib.h -+++ b/SecurityPkg/Include/Library/Tpm2CommandLib.h -@@ -186,7 +186,7 @@ EFI_STATUS - EFIAPI - Tpm2ClearControl ( - IN TPMI_RH_CLEAR AuthHandle, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPMI_YES_NO Disable - ); - -@@ -340,7 +340,7 @@ EFI_STATUS - EFIAPI - Tpm2NvDefineSpace ( - IN TPMI_RH_PROVISION AuthHandle, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_AUTH *Auth, - IN TPM2B_NV_PUBLIC *NvPublic - ); -@@ -383,7 +383,7 @@ EFIAPI - Tpm2NvRead ( - IN TPMI_RH_NV_AUTH AuthHandle, - IN TPMI_RH_NV_INDEX NvIndex, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN UINT16 Size, - IN UINT16 Offset, - IN OUT TPM2B_MAX_BUFFER *OutData -@@ -407,7 +407,7 @@ EFIAPI - Tpm2NvWrite ( - IN TPMI_RH_NV_AUTH AuthHandle, - IN TPMI_RH_NV_INDEX NvIndex, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_MAX_BUFFER *InData, - IN UINT16 Offset - ); -@@ -566,7 +566,7 @@ Tpm2PcrAllocate ( - EFI_STATUS - EFIAPI - Tpm2PcrAllocateBanks ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN UINT32 SupportedPCRBanks, - IN UINT32 PCRBanks - ); -@@ -908,7 +908,7 @@ EFIAPI - Tpm2PolicySecret ( - IN TPMI_DH_ENTITY AuthHandle, - IN TPMI_SH_POLICY PolicySession, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_NONCE *NonceTPM, - IN TPM2B_DIGEST *CpHashA, - IN TPM2B_NONCE *PolicyRef, -@@ -1004,7 +1004,7 @@ Tpm2ReadPublic ( - UINT32 - EFIAPI - CopyAuthSessionCommand ( -- IN TPMS_AUTH_COMMAND *AuthSessionIn, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSessionIn OPTIONAL, - OUT UINT8 *AuthSessionOut - ); - -diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c -index aa9ebaf3be..3059e5d256 100644 ---- a/SecurityPkg/Library/AuthVariableLib/AuthService.c -+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c -@@ -1183,9 +1183,9 @@ FindCertsFromDb ( - IN EFI_GUID *VendorGuid, - IN UINT8 *Data, - IN UINTN DataSize, -- OUT UINT32 *CertOffset, OPTIONAL -- OUT UINT32 *CertDataSize, OPTIONAL -- OUT UINT32 *CertNodeOffset,OPTIONAL -+ OUT UINT32 *CertOffset OPTIONAL, -+ OUT UINT32 *CertDataSize OPTIONAL, -+ OUT UINT32 *CertNodeOffset OPTIONAL, - OUT UINT32 *CertNodeSize OPTIONAL - ) - { -diff --git a/SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.c b/SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.c -index ec77151c9c..9acff2ae7d 100644 ---- a/SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.c -+++ b/SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.c -@@ -32,7 +32,7 @@ EFI_STATUS - EFIAPI - DxeImageAuthenticationStatusHandler ( - IN UINT32 AuthenticationStatus, -- IN CONST EFI_DEVICE_PATH_PROTOCOL *File, OPTIONAL -+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, - IN VOID *FileBuffer, - IN UINTN FileSize, - IN BOOLEAN BootPolicy -diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -index 1252927664..0a12692454 100644 ---- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -@@ -1636,7 +1636,7 @@ EFI_STATUS - EFIAPI - DxeImageVerificationHandler ( - IN UINT32 AuthenticationStatus, -- IN CONST EFI_DEVICE_PATH_PROTOCOL *File, OPTIONAL -+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, - IN VOID *FileBuffer, - IN UINTN FileSize, - IN BOOLEAN BootPolicy -diff --git a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c -index 28807d4d98..5124b884c9 100644 ---- a/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c -+++ b/SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.c -@@ -123,7 +123,7 @@ EFIAPI - Rsa2048Sha256GuidedSectionHandler ( - IN CONST VOID *InputSection, - OUT VOID **OutputBuffer, -- IN VOID *ScratchBuffer, OPTIONAL -+ IN VOID *ScratchBuffer OPTIONAL, - OUT UINT32 *AuthenticationStatus - ) - { -diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -index fce5c0af50..d92658f80d 100644 ---- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -+++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -@@ -147,7 +147,7 @@ Tpm2CommandChangeEps ( - **/ - UINT32 - Tcg2ExecutePhysicalPresence ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN UINT32 CommandCode, - IN UINT32 CommandParameter, - IN OUT EFI_TCG2_PHYSICAL_PRESENCE_FLAGS *PpiFlags -@@ -720,7 +720,7 @@ Tcg2HaveValidTpmRequest ( - **/ - VOID - Tcg2ExecutePendingTpmRequest ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN OUT EFI_TCG2_PHYSICAL_PRESENCE *TcgPpData, - IN OUT EFI_TCG2_PHYSICAL_PRESENCE_FLAGS *Flags - ) -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index a531385f81..95682ac567 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -416,7 +416,7 @@ EFI_STATUS - EFIAPI - DxeTpm2MeasureBootHandler ( - IN UINT32 AuthenticationStatus, -- IN CONST EFI_DEVICE_PATH_PROTOCOL *File, OPTIONAL -+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, - IN VOID *FileBuffer, - IN UINTN FileSize, - IN BOOLEAN BootPolicy -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -index 4e74cd9db6..27c0ea48ca 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -@@ -710,7 +710,7 @@ EFI_STATUS - EFIAPI - DxeTpmMeasureBootHandler ( - IN UINT32 AuthenticationStatus, -- IN CONST EFI_DEVICE_PATH_PROTOCOL *File, OPTIONAL -+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, - IN VOID *FileBuffer, - IN UINTN FileSize, - IN BOOLEAN BootPolicy -diff --git a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c -index a759183d20..96638e26aa 100644 ---- a/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c -+++ b/SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.c -@@ -121,7 +121,7 @@ EFIAPI - Rsa2048Sha256GuidedSectionHandler ( - IN CONST VOID *InputSection, - OUT VOID **OutputBuffer, -- IN VOID *ScratchBuffer, OPTIONAL -+ IN VOID *ScratchBuffer OPTIONAL, - OUT UINT32 *AuthenticationStatus - ) - { -diff --git a/SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.c b/SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.c -index 895d05a28d..aa3dcb6beb 100644 ---- a/SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.c -+++ b/SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.c -@@ -30,7 +30,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - UINT32 - EFIAPI - Tcg2PpVendorLibExecutePendingRequest ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN UINT32 OperationRequest, - IN OUT UINT32 *ManagementFlags, - OUT BOOLEAN *ResetRequired -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -index 0404c0f321..53983d745b 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -@@ -90,7 +90,7 @@ EFIAPI - Tpm2PolicySecret ( - IN TPMI_DH_ENTITY AuthHandle, - IN TPMI_SH_POLICY PolicySession, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_NONCE *NonceTPM, - IN TPM2B_DIGEST *CpHashA, - IN TPM2B_NONCE *PolicyRef, -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -index 13eeb6ec18..44115cded3 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -@@ -84,7 +84,7 @@ GetHashMaskFromAlgo ( - UINT32 - EFIAPI - CopyAuthSessionCommand ( -- IN TPMS_AUTH_COMMAND *AuthSessionIn, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSessionIn OPTIONAL, - OUT UINT8 *AuthSessionOut - ) - { -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -index 043d358a06..957d694431 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -@@ -305,7 +305,7 @@ EFI_STATUS - EFIAPI - Tpm2ClearControl ( - IN TPMI_RH_CLEAR AuthHandle, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPMI_YES_NO Disable - ) - { -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -index 8c87de0b0c..d232fe725d 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -@@ -566,7 +566,7 @@ Done: - EFI_STATUS - EFIAPI - Tpm2PcrAllocateBanks ( -- IN TPM2B_AUTH *PlatformAuth, OPTIONAL -+ IN TPM2B_AUTH *PlatformAuth OPTIONAL, - IN UINT32 SupportedPCRBanks, - IN UINT32 PCRBanks - ) -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -index fb46af0fed..d9171fb9a0 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -@@ -281,7 +281,7 @@ EFI_STATUS - EFIAPI - Tpm2NvDefineSpace ( - IN TPMI_RH_PROVISION AuthHandle, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_AUTH *Auth, - IN TPM2B_NV_PUBLIC *NvPublic - ) -@@ -525,7 +525,7 @@ EFIAPI - Tpm2NvRead ( - IN TPMI_RH_NV_AUTH AuthHandle, - IN TPMI_RH_NV_INDEX NvIndex, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN UINT16 Size, - IN UINT16 Offset, - IN OUT TPM2B_MAX_BUFFER *OutData -@@ -670,7 +670,7 @@ EFIAPI - Tpm2NvWrite ( - IN TPMI_RH_NV_AUTH AuthHandle, - IN TPMI_RH_NV_INDEX NvIndex, -- IN TPMS_AUTH_COMMAND *AuthSession, OPTIONAL -+ IN TPMS_AUTH_COMMAND *AuthSession OPTIONAL, - IN TPM2B_MAX_BUFFER *InData, - IN UINT16 Offset - ) -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index 282fdca9d3..1cdc842966 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -53,7 +53,7 @@ EFI_STATUS - EFIAPI - RngGetRNG ( - IN EFI_RNG_PROTOCOL *This, -- IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL -+ IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, - IN UINTN RNGValueLength, - OUT UINT8 *RNGValue - ) -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index d0e6b7de06..834123b945 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -49,7 +49,7 @@ EFI_STATUS - EFIAPI - RngGetRNG ( - IN EFI_RNG_PROTOCOL *This, -- IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL -+ IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, - IN UINTN RNGValueLength, - OUT UINT8 *RNGValue - ) -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -index 2660ed5875..25cccbe92c 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -@@ -67,7 +67,7 @@ EFI_STATUS - EFIAPI - RngGetRNG ( - IN EFI_RNG_PROTOCOL *This, -- IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL -+ IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, - IN UINTN RNGValueLength, - OUT UINT8 *RNGValue - ); -diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c -index 68cd62307c..09cb4b0ee9 100644 ---- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c -+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c -@@ -56,7 +56,7 @@ HII_VENDOR_DEVICE_PATH mTcgHiiVendorDevicePath = { - EFI_STATUS - GetTpmState ( - IN EFI_TCG_PROTOCOL *TcgProtocol, -- OUT BOOLEAN *TpmEnable, OPTIONAL -+ OUT BOOLEAN *TpmEnable OPTIONAL, - OUT BOOLEAN *TpmActivate OPTIONAL - ) - { --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-Change-use-of-EFI_D_-to-DEBUG_.patch b/SOURCES/edk2-SecurityPkg-Change-use-of-EFI_D_-to-DEBUG_.patch deleted file mode 100644 index 1d2659d..0000000 --- a/SOURCES/edk2-SecurityPkg-Change-use-of-EFI_D_-to-DEBUG_.patch +++ /dev/null @@ -1,2923 +0,0 @@ -From a026f3bb9ee971b281638b5d4e6daf0bddf32103 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 7 Feb 2024 11:56:37 -0500 -Subject: [PATCH 01/17] SecurityPkg: Change use of EFI_D_* to DEBUG_* - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [1/13] 651bdf05edd106945ec4d5e18b4f08dc0e28055c (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged - -commit 292b44b682d88e6605645ec61ca7081c0a31b059 -Author: Michael D Kinney -Date: Tue Nov 16 19:21:36 2021 -0800 - - SecurityPkg: Change use of EFI_D_* to DEBUG_* - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3739 - - Update all use of EFI_D_* defines in DEBUG() macros to DEBUG_* defines. - - Cc: Andrew Fish - Cc: Leif Lindholm - Cc: Michael Kubacki - Signed-off-by: Michael D Kinney - Reviewed-by: Jian J Wang - -Signed-off-by: Jon Maloy ---- - SecurityPkg/Hash2DxeCrypto/Driver.c | 2 +- - .../Library/AuthVariableLib/AuthService.c | 2 +- - .../Library/AuthVariableLib/AuthVariableLib.c | 16 +- - .../DxeImageVerificationLib/Measurement.c | 8 +- - .../DxeTcg2PhysicalPresenceLib.c | 36 ++-- - .../DxeTcgPhysicalPresenceLib.c | 13 +- - .../DxeTpm2MeasureBootLib.c | 14 +- - .../DxeTpmMeasureBootLib.c | 4 +- - SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c | 12 +- - .../Library/Tpm12CommandLib/Tpm12Pcr.c | 2 +- - .../Tpm12CommandLib/Tpm12PhysicalPresence.c | 2 +- - .../Library/Tpm12DeviceLibDTpm/Tpm12Tis.c | 24 +-- - .../Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c | 4 +- - .../Library/Tpm2CommandLib/Tpm2Context.c | 5 +- - .../Tpm2CommandLib/Tpm2DictionaryAttack.c | 8 +- - .../Tpm2EnhancedAuthorization.c | 16 +- - SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c | 2 +- - .../Library/Tpm2CommandLib/Tpm2Hierarchy.c | 40 ++-- - .../Library/Tpm2CommandLib/Tpm2Integrity.c | 42 ++-- - .../Tpm2CommandLib/Tpm2Miscellaneous.c | 4 +- - .../Library/Tpm2CommandLib/Tpm2NVStorage.c | 36 ++-- - .../Library/Tpm2CommandLib/Tpm2Sequences.c | 26 +-- - .../Library/Tpm2CommandLib/Tpm2Session.c | 6 +- - .../Library/Tpm2CommandLib/Tpm2Startup.c | 4 +- - .../Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c | 50 ++--- - .../Library/Tpm2DeviceLibDTpm/Tpm2Tis.c | 24 +-- - .../Tpm2DeviceLibRouterPei.c | 2 +- - .../Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.c | 4 +- - .../Tcg/MemoryOverwriteControl/TcgMor.c | 20 +- - .../TcgMorLockSmm.c | 3 +- - SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c | 4 +- - SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c | 2 +- - SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c | 6 +- - SecurityPkg/Tcg/Tcg2Config/TpmDetection.c | 6 +- - SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | 188 +++++++++--------- - SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 22 +- - SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 9 +- - .../Tcg/TcgConfigDxe/TcgConfigDriver.c | 4 +- - SecurityPkg/Tcg/TcgDxe/TcgDxe.c | 28 +-- - SecurityPkg/Tcg/TcgPei/TcgPei.c | 8 +- - SecurityPkg/Tcg/TcgSmm/TcgSmm.c | 19 +- - .../SecureBootConfigImpl.c | 16 +- - 42 files changed, 368 insertions(+), 375 deletions(-) - -diff --git a/SecurityPkg/Hash2DxeCrypto/Driver.c b/SecurityPkg/Hash2DxeCrypto/Driver.c -index 4627061a28..0d123b2a2f 100644 ---- a/SecurityPkg/Hash2DxeCrypto/Driver.c -+++ b/SecurityPkg/Hash2DxeCrypto/Driver.c -@@ -142,7 +142,7 @@ Hash2ServiceBindingDestroyChild ( - } - } - if (Instance == NULL) { -- DEBUG ((EFI_D_ERROR, "Hash2ServiceBindingDestroyChild - Invalid handle\n")); -+ DEBUG ((DEBUG_ERROR, "Hash2ServiceBindingDestroyChild - Invalid handle\n")); - return EFI_UNSUPPORTED; - } - -diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c -index 4fb609504d..aa9ebaf3be 100644 ---- a/SecurityPkg/Library/AuthVariableLib/AuthService.c -+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c -@@ -1752,7 +1752,7 @@ CleanCertsFromDb ( - AuthVariableInfo.Attributes | EFI_VARIABLE_NON_VOLATILE - ); - CertCleaned = TRUE; -- DEBUG((EFI_D_INFO, "Recovery!! Cert for Auth Variable %s Guid %g is removed for consistency\n", VariableName, &AuthVarGuid)); -+ DEBUG((DEBUG_INFO, "Recovery!! Cert for Auth Variable %s Guid %g is removed for consistency\n", VariableName, &AuthVarGuid)); - FreePool(VariableName); - break; - } -diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c -index 122b3b0bf4..7f31458edb 100644 ---- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c -+++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.c -@@ -153,9 +153,9 @@ AuthVariableLibInitialize ( - - Status = AuthServiceInternalFindVariable (EFI_PLATFORM_KEY_NAME, &gEfiGlobalVariableGuid, (VOID **) &Data, &DataSize); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Variable %s does not exist.\n", EFI_PLATFORM_KEY_NAME)); -+ DEBUG ((DEBUG_INFO, "Variable %s does not exist.\n", EFI_PLATFORM_KEY_NAME)); - } else { -- DEBUG ((EFI_D_INFO, "Variable %s exists.\n", EFI_PLATFORM_KEY_NAME)); -+ DEBUG ((DEBUG_INFO, "Variable %s exists.\n", EFI_PLATFORM_KEY_NAME)); - } - - // -@@ -238,9 +238,9 @@ AuthVariableLibInitialize ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_SETUP_MODE_NAME, mPlatformMode)); -- DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_SECURE_BOOT_MODE_NAME, SecureBootMode)); -- DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_SECURE_BOOT_ENABLE_NAME, SecureBootEnable)); -+ DEBUG ((DEBUG_INFO, "Variable %s is %x\n", EFI_SETUP_MODE_NAME, mPlatformMode)); -+ DEBUG ((DEBUG_INFO, "Variable %s is %x\n", EFI_SECURE_BOOT_MODE_NAME, SecureBootMode)); -+ DEBUG ((DEBUG_INFO, "Variable %s is %x\n", EFI_SECURE_BOOT_ENABLE_NAME, SecureBootEnable)); - - // - // Initialize "CustomMode" in STANDARD_SECURE_BOOT_MODE state. -@@ -257,7 +257,7 @@ AuthVariableLibInitialize ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_CUSTOM_MODE_NAME, CustomMode)); -+ DEBUG ((DEBUG_INFO, "Variable %s is %x\n", EFI_CUSTOM_MODE_NAME, CustomMode)); - - // - // Check "certdb" variable's existence. -@@ -289,7 +289,7 @@ AuthVariableLibInitialize ( - // - Status = CleanCertsFromDb(); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Clean up CertDB fail! Status %x\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Clean up CertDB fail! Status %x\n", Status)); - return Status; - } - } -@@ -347,7 +347,7 @@ AuthVariableLibInitialize ( - return Status; - } - -- DEBUG ((EFI_D_INFO, "Variable %s is %x\n", EFI_VENDOR_KEYS_VARIABLE_NAME, mVendorKeyState)); -+ DEBUG ((DEBUG_INFO, "Variable %s is %x\n", EFI_VENDOR_KEYS_VARIABLE_NAME, mVendorKeyState)); - - AuthVarLibContextOut->StructVersion = AUTH_VAR_LIB_CONTEXT_OUT_STRUCT_VERSION; - AuthVarLibContextOut->StructSize = sizeof (AUTH_VAR_LIB_CONTEXT_OUT); -diff --git a/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c b/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c -index 86d8eb4840..351107785d 100644 ---- a/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c -+++ b/SecurityPkg/Library/DxeImageVerificationLib/Measurement.c -@@ -253,8 +253,8 @@ MeasureVariable ( - VarSize - ); - -- DEBUG ((EFI_D_INFO, "DxeImageVerification: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_AUTHORITY)); -- DEBUG ((EFI_D_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); -+ DEBUG ((DEBUG_INFO, "DxeImageVerification: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)7, (UINTN)EV_EFI_VARIABLE_AUTHORITY)); -+ DEBUG ((DEBUG_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); - - Status = TpmMeasureAndLogData ( - 7, -@@ -295,7 +295,7 @@ SecureBootHook ( - } - - if (IsDataMeasured (VariableName, VendorGuid, Data, DataSize)) { -- DEBUG ((EFI_D_ERROR, "MeasureSecureAuthorityVariable - IsDataMeasured\n")); -+ DEBUG ((DEBUG_ERROR, "MeasureSecureAuthorityVariable - IsDataMeasured\n")); - return ; - } - -@@ -305,7 +305,7 @@ SecureBootHook ( - Data, - DataSize - ); -- DEBUG ((EFI_D_INFO, "MeasureBootPolicyVariable - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "MeasureBootPolicyVariable - %r\n", Status)); - - if (!EFI_ERROR (Status)) { - AddDataMeasured (VariableName, VendorGuid, Data, DataSize); -diff --git a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -index 1e00476509..fce5c0af50 100644 ---- a/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -+++ b/SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.c -@@ -84,15 +84,15 @@ Tpm2CommandClear ( - CopyMem (LocalAuthSession.hmac.buffer, PlatformAuth->buffer, PlatformAuth->size); - } - -- DEBUG ((EFI_D_INFO, "Tpm2ClearControl ... \n")); -+ DEBUG ((DEBUG_INFO, "Tpm2ClearControl ... \n")); - Status = Tpm2ClearControl (TPM_RH_PLATFORM, AuthSession, NO); -- DEBUG ((EFI_D_INFO, "Tpm2ClearControl - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tpm2ClearControl - %r\n", Status)); - if (EFI_ERROR (Status)) { - goto Done; - } -- DEBUG ((EFI_D_INFO, "Tpm2Clear ... \n")); -+ DEBUG ((DEBUG_INFO, "Tpm2Clear ... \n")); - Status = Tpm2Clear (TPM_RH_PLATFORM, AuthSession); -- DEBUG ((EFI_D_INFO, "Tpm2Clear - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tpm2Clear - %r\n", Status)); - - Done: - ZeroMem (&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac)); -@@ -126,7 +126,7 @@ Tpm2CommandChangeEps ( - } - - Status = Tpm2ChangeEPS (TPM_RH_PLATFORM, AuthSession); -- DEBUG ((EFI_D_INFO, "Tpm2ChangeEPS - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tpm2ChangeEPS - %r\n", Status)); - - ZeroMem(&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac)); - return Status; -@@ -913,7 +913,7 @@ Tcg2PhysicalPresenceLibProcessRequest ( - &gEfiTcg2PhysicalPresenceGuid - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM2] Error when lock variable %s, Status = %r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Error when lock variable %s, Status = %r\n", TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); - ASSERT_EFI_ERROR (Status); - } - } -@@ -922,7 +922,7 @@ Tcg2PhysicalPresenceLibProcessRequest ( - // Check S4 resume - // - if (GetBootModeHob () == BOOT_ON_S4_RESUME) { -- DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n")); -+ DEBUG ((DEBUG_INFO, "S4 Resume, Skip TPM PP process!\n")); - return ; - } - -@@ -947,7 +947,7 @@ Tcg2PhysicalPresenceLibProcessRequest ( - &PpiFlags - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM2] Set physical presence flag failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Set physical presence flag failed, Status = %r\n", Status)); - return ; - } - DEBUG((DEBUG_INFO, "[TPM2] Initial physical presence flags value is 0x%x\n", PpiFlags.PPFlags)); -@@ -975,18 +975,18 @@ Tcg2PhysicalPresenceLibProcessRequest ( - &TcgPpData - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM2] Set physical presence variable failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Set physical presence variable failed, Status = %r\n", Status)); - return ; - } - } - -- DEBUG ((EFI_D_INFO, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest)); -+ DEBUG ((DEBUG_INFO, "[TPM2] Flags=%x, PPRequest=%x (LastPPRequest=%x)\n", PpiFlags.PPFlags, TcgPpData.PPRequest, TcgPpData.LastPPRequest)); - - // - // Execute pending TPM request. - // - Tcg2ExecutePendingTpmRequest (PlatformAuth, &TcgPpData, &PpiFlags); -- DEBUG ((EFI_D_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags)); -+ DEBUG ((DEBUG_INFO, "[TPM2] PPResponse = %x (LastPPRequest=%x, Flags=%x)\n", TcgPpData.PPResponse, TcgPpData.LastPPRequest, PpiFlags.PPFlags)); - - } - -@@ -1016,7 +1016,7 @@ Tcg2PhysicalPresenceLibNeedUserConfirm( - // Check S4 resume - // - if (GetBootModeHob () == BOOT_ON_S4_RESUME) { -- DEBUG ((EFI_D_INFO, "S4 Resume, Skip TPM PP process!\n")); -+ DEBUG ((DEBUG_INFO, "S4 Resume, Skip TPM PP process!\n")); - return FALSE; - } - -@@ -1092,7 +1092,7 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction ( - UINTN DataSize; - EFI_TCG2_PHYSICAL_PRESENCE PpData; - -- DEBUG ((EFI_D_INFO, "[TPM2] ReturnOperationResponseToOsFunction\n")); -+ DEBUG ((DEBUG_INFO, "[TPM2] ReturnOperationResponseToOsFunction\n")); - - // - // Get the Physical Presence variable -@@ -1108,7 +1108,7 @@ Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction ( - if (EFI_ERROR (Status)) { - *MostRecentRequest = 0; - *Response = 0; -- DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); - return TCG_PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE; - } - -@@ -1143,7 +1143,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction ( - EFI_TCG2_PHYSICAL_PRESENCE PpData; - EFI_TCG2_PHYSICAL_PRESENCE_FLAGS Flags; - -- DEBUG ((EFI_D_INFO, "[TPM2] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter)); -+ DEBUG ((DEBUG_INFO, "[TPM2] SubmitRequestToPreOSFunction, Request = %x, %x\n", OperationRequest, RequestParameter)); - - // - // Get the Physical Presence variable -@@ -1157,7 +1157,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction ( - &PpData - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Get PP variable failure! Status = %r\n", Status)); - return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE; - } - -@@ -1179,7 +1179,7 @@ Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction ( - &PpData - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM2] Set PP variable failure! Status = %r\n", Status)); - return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE; - } - } -@@ -1217,7 +1217,7 @@ Tcg2PhysicalPresenceLibGetManagementFlags ( - EFI_TCG2_PHYSICAL_PRESENCE_FLAGS PpiFlags; - UINTN DataSize; - -- DEBUG ((EFI_D_INFO, "[TPM2] GetManagementFlags\n")); -+ DEBUG ((DEBUG_INFO, "[TPM2] GetManagementFlags\n")); - - DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE_FLAGS); - Status = gRT->GetVariable ( -diff --git a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c -index ba1abe9e08..ab7f664c7a 100644 ---- a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c -+++ b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c -@@ -1203,11 +1203,11 @@ TcgPhysicalPresenceLibProcessRequest ( - &PpiFlags - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM] Set physical presence flag failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Set physical presence flag failed, Status = %r\n", Status)); - return ; - } - } -- DEBUG ((EFI_D_INFO, "[TPM] PpiFlags = %x\n", PpiFlags.PPFlags)); -+ DEBUG ((DEBUG_INFO, "[TPM] PpiFlags = %x\n", PpiFlags.PPFlags)); - - // - // This flags variable controls whether physical presence is required for TPM command. -@@ -1221,7 +1221,7 @@ TcgPhysicalPresenceLibProcessRequest ( - &gEfiPhysicalPresenceGuid - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM] Error when lock variable %s, Status = %r\n", PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Error when lock variable %s, Status = %r\n", PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status)); - ASSERT_EFI_ERROR (Status); - } - } -@@ -1248,12 +1248,12 @@ TcgPhysicalPresenceLibProcessRequest ( - &TcgPpData - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "[TPM] Set physical presence variable failed, Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Set physical presence variable failed, Status = %r\n", Status)); - return; - } - } - -- DEBUG ((EFI_D_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, TcgPpData.PPRequest)); -+ DEBUG ((DEBUG_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, TcgPpData.PPRequest)); - - if (TcgPpData.PPRequest == PHYSICAL_PRESENCE_NO_ACTION) { - // -@@ -1292,7 +1292,7 @@ TcgPhysicalPresenceLibProcessRequest ( - // Execute pending TPM request. - // - ExecutePendingTpmRequest (TcgProtocol, &TcgPpData, PpiFlags); -- DEBUG ((EFI_D_INFO, "[TPM] PPResponse = %x\n", TcgPpData.PPResponse)); -+ DEBUG ((DEBUG_INFO, "[TPM] PPResponse = %x\n", TcgPpData.PPResponse)); - - // - // Lock physical presence. -@@ -1397,4 +1397,3 @@ TcgPhysicalPresenceLibNeedUserConfirm( - - return FALSE; - } -- -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index 92eac71580..a531385f81 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -164,7 +164,7 @@ Tcg2MeasureGptTable ( - (UINT8 *)PrimaryHeader - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Failed to Read Partition Table Header!\n")); -+ DEBUG ((DEBUG_ERROR, "Failed to Read Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; - } -@@ -334,7 +334,7 @@ Tcg2MeasurePeImage ( - break; - default: - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "Tcg2MeasurePeImage: Unknown subsystem type %d", - ImageType - )); -@@ -441,7 +441,7 @@ DxeTpm2MeasureBootHandler ( - // Tcg2 protocol is not installed. So, TPM2 is not present. - // Don't do any measurement, and directly return EFI_SUCCESS. - // -- DEBUG ((EFI_D_VERBOSE, "DxeTpm2MeasureBootHandler - Tcg2 - %r\n", Status)); -+ DEBUG ((DEBUG_VERBOSE, "DxeTpm2MeasureBootHandler - Tcg2 - %r\n", Status)); - return EFI_SUCCESS; - } - -@@ -454,7 +454,7 @@ DxeTpm2MeasureBootHandler ( - // - // TPM device doesn't work or activate. - // -- DEBUG ((EFI_D_ERROR, "DxeTpm2MeasureBootHandler (%r) - TPMPresentFlag - %x\n", Status, ProtocolCapability.TPMPresentFlag)); -+ DEBUG ((DEBUG_ERROR, "DxeTpm2MeasureBootHandler (%r) - TPMPresentFlag - %x\n", Status, ProtocolCapability.TPMPresentFlag)); - return EFI_SUCCESS; - } - -@@ -503,7 +503,7 @@ DxeTpm2MeasureBootHandler ( - // Measure GPT disk. - // - Status = Tcg2MeasureGptTable (Tcg2Protocol, Handle); -- DEBUG ((EFI_D_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasureGptTable - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasureGptTable - %r\n", Status)); - if (!EFI_ERROR (Status)) { - // - // GPT disk check done. -@@ -654,7 +654,7 @@ DxeTpm2MeasureBootHandler ( - ImageContext.ImageType, - DevicePathNode - ); -- DEBUG ((EFI_D_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasurePeImage - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasurePeImage - %r\n", Status)); - } - - // -@@ -665,7 +665,7 @@ Finish: - FreePool (OrigDevicePathNode); - } - -- DEBUG ((EFI_D_INFO, "DxeTpm2MeasureBootHandler - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - %r\n", Status)); - - return Status; - } -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -index d990eb2ad3..4e74cd9db6 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -@@ -164,7 +164,7 @@ TcgMeasureGptTable ( - (UINT8 *)PrimaryHeader - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Failed to Read Partition Table Header!\n")); -+ DEBUG ((DEBUG_ERROR, "Failed to Read Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; - } -@@ -355,7 +355,7 @@ TcgMeasurePeImage ( - break; - default: - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "TcgMeasurePeImage: Unknown subsystem type %d", - ImageType - )); -diff --git a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c -index bd24958505..876b15fad4 100644 ---- a/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c -+++ b/SecurityPkg/Library/HashLibTpm2/HashLibTpm2.c -@@ -237,7 +237,7 @@ HashAndExtend ( - TPM2B_EVENT EventData; - TPM2B_DIGEST Result; - -- DEBUG((EFI_D_VERBOSE, "\n HashAndExtend Entry \n")); -+ DEBUG((DEBUG_VERBOSE, "\n HashAndExtend Entry \n")); - - SequenceHandle = 0xFFFFFFFF; // Know bad value - -@@ -257,7 +257,7 @@ HashAndExtend ( - if (EFI_ERROR(Status)) { - return EFI_DEVICE_ERROR; - } -- DEBUG((EFI_D_VERBOSE, "\n Tpm2HashSequenceStart Success \n")); -+ DEBUG((DEBUG_VERBOSE, "\n Tpm2HashSequenceStart Success \n")); - - Buffer = (UINT8 *)(UINTN)DataToHash; - for (HashLen = DataToHashLen; HashLen > sizeof(HashBuffer.buffer); HashLen -= sizeof(HashBuffer.buffer)) { -@@ -271,7 +271,7 @@ HashAndExtend ( - return EFI_DEVICE_ERROR; - } - } -- DEBUG((EFI_D_VERBOSE, "\n Tpm2SequenceUpdate Success \n")); -+ DEBUG((DEBUG_VERBOSE, "\n Tpm2SequenceUpdate Success \n")); - - HashBuffer.size = (UINT16)HashLen; - CopyMem(HashBuffer.buffer, Buffer, (UINTN)HashLen); -@@ -289,7 +289,7 @@ HashAndExtend ( - if (EFI_ERROR(Status)) { - return EFI_DEVICE_ERROR; - } -- DEBUG((EFI_D_VERBOSE, "\n Tpm2EventSequenceComplete Success \n")); -+ DEBUG((DEBUG_VERBOSE, "\n Tpm2EventSequenceComplete Success \n")); - } else { - Status = Tpm2SequenceComplete ( - SequenceHandle, -@@ -299,7 +299,7 @@ HashAndExtend ( - if (EFI_ERROR(Status)) { - return EFI_DEVICE_ERROR; - } -- DEBUG((EFI_D_VERBOSE, "\n Tpm2SequenceComplete Success \n")); -+ DEBUG((DEBUG_VERBOSE, "\n Tpm2SequenceComplete Success \n")); - - DigestList->count = 1; - DigestList->digests[0].hashAlg = AlgoId; -@@ -311,7 +311,7 @@ HashAndExtend ( - if (EFI_ERROR(Status)) { - return EFI_DEVICE_ERROR; - } -- DEBUG((EFI_D_VERBOSE, "\n Tpm2PcrExtend Success \n")); -+ DEBUG((DEBUG_VERBOSE, "\n Tpm2PcrExtend Success \n")); - } - - return EFI_SUCCESS; -diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c -index 562cf582de..4fbcb3617c 100644 ---- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c -+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12Pcr.c -@@ -69,7 +69,7 @@ Tpm12Extend ( - } - - if (SwapBytes32(Response.Hdr.returnCode) != TPM_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm12Extend: Response Code error! 0x%08x\r\n", SwapBytes32(Response.Hdr.returnCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm12Extend: Response Code error! 0x%08x\r\n", SwapBytes32(Response.Hdr.returnCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c b/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c -index 208bff594d..6714d17d8e 100644 ---- a/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c -+++ b/SecurityPkg/Library/Tpm12CommandLib/Tpm12PhysicalPresence.c -@@ -58,7 +58,7 @@ Tpm12PhysicalPresence ( - } - - if (SwapBytes32(Response.returnCode) != TPM_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm12PhysicalPresence: Response Code error! 0x%08x\r\n", SwapBytes32(Response.returnCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm12PhysicalPresence: Response Code error! 0x%08x\r\n", SwapBytes32(Response.returnCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c -index f858090479..b8218f122d 100644 ---- a/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c -+++ b/SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12Tis.c -@@ -266,22 +266,22 @@ Tpm12TisTpmCommand ( - DEBUG_CODE ( - UINTN DebugSize; - -- DEBUG ((EFI_D_VERBOSE, "Tpm12TisTpmCommand Send - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm12TisTpmCommand Send - ")); - if (SizeIn > 0x100) { - DebugSize = 0x40; - } else { - DebugSize = SizeIn; - } - for (Index = 0; Index < DebugSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - if (DebugSize != SizeIn) { -- DEBUG ((EFI_D_VERBOSE, "...... ")); -+ DEBUG ((DEBUG_VERBOSE, "...... ")); - for (Index = SizeIn - 0x20; Index < SizeIn; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - TpmOutSize = 0; - -@@ -352,11 +352,11 @@ Tpm12TisTpmCommand ( - } - } - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "Tpm12TisTpmCommand ReceiveHeader - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm12TisTpmCommand ReceiveHeader - ")); - for (Index = 0; Index < sizeof (TPM_RSP_COMMAND_HDR); Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - // - // Check the response data header (tag, parasize and returncode) -@@ -364,7 +364,7 @@ Tpm12TisTpmCommand ( - CopyMem (&Data16, BufferOut, sizeof (UINT16)); - RspTag = SwapBytes16 (Data16); - if (RspTag != TPM_TAG_RSP_COMMAND && RspTag != TPM_TAG_RSP_AUTH1_COMMAND && RspTag != TPM_TAG_RSP_AUTH2_COMMAND) { -- DEBUG ((EFI_D_ERROR, "TPM12: Response tag error - current tag value is %x\n", RspTag)); -+ DEBUG ((DEBUG_ERROR, "TPM12: Response tag error - current tag value is %x\n", RspTag)); - Status = EFI_UNSUPPORTED; - goto Exit; - } -@@ -396,11 +396,11 @@ Tpm12TisTpmCommand ( - } - Exit: - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "Tpm12TisTpmCommand Receive - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm12TisTpmCommand Receive - ")); - for (Index = 0; Index < TpmOutSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY); - return Status; -diff --git a/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c -index f975b1bc8a..2869f9ec83 100644 ---- a/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c -+++ b/SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.c -@@ -47,7 +47,7 @@ Tpm12SubmitCommand ( - // - // TCG protocol is not installed. So, TPM12 is not present. - // -- DEBUG ((EFI_D_ERROR, "Tpm12SubmitCommand - TCG - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Tpm12SubmitCommand - TCG - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -@@ -91,7 +91,7 @@ Tpm12RequestUseTpm ( - // - // TCG protocol is not installed. So, TPM12 is not present. - // -- DEBUG ((EFI_D_ERROR, "Tpm12RequestUseTpm - TCG - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Tpm12RequestUseTpm - TCG - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Context.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Context.c -index 80b15a51f0..f284f8d21a 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Context.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Context.c -@@ -67,14 +67,13 @@ Tpm2FlushContext ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2FlushContext - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2FlushContext - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2FlushContext - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2FlushContext - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - - return EFI_SUCCESS; - } -- -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c -index f502113873..2f830e0aea 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2DictionaryAttack.c -@@ -102,12 +102,12 @@ Tpm2DictionaryAttackLockReset ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackLockReset - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2DictionaryAttackLockReset - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackLockReset - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2DictionaryAttackLockReset - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -193,12 +193,12 @@ Tpm2DictionaryAttackParameters ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackParameters - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2DictionaryAttackParameters - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2DictionaryAttackParameters - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2DictionaryAttackParameters - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -index 61c6367262..0404c0f321 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2EnhancedAuthorization.c -@@ -159,12 +159,12 @@ Tpm2PolicySecret ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicySecret - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicySecret - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicySecret - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicySecret - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -263,11 +263,11 @@ Tpm2PolicyOR ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyOR - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyOR - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyOR - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyOR - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -318,11 +318,11 @@ Tpm2PolicyCommandCode ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyCommandCode - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyCommandCode - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyCommandCode - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyCommandCode - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -373,11 +373,11 @@ Tpm2PolicyGetDigest ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyGetDigest - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyGetDigest - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PolicyGetDigest - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PolicyGetDigest - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -index 36c240d122..13eeb6ec18 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Help.c -@@ -266,7 +266,7 @@ CopyDigestListToBuffer ( - Buffer = (UINT8 *)Buffer + sizeof(DigestList->count); - for (Index = 0; Index < DigestList->count; Index++) { - if (!IsHashAlgSupportedInHashAlgorithmMask(DigestList->digests[Index].hashAlg, HashAlgorithmMask)) { -- DEBUG ((EFI_D_ERROR, "WARNING: TPM2 Event log has HashAlg unsupported by PCR bank (0x%x)\n", DigestList->digests[Index].hashAlg)); -+ DEBUG ((DEBUG_ERROR, "WARNING: TPM2 Event log has HashAlg unsupported by PCR bank (0x%x)\n", DigestList->digests[Index].hashAlg)); - continue; - } - CopyMem (Buffer, &DigestList->digests[Index].hashAlg, sizeof(DigestList->digests[Index].hashAlg)); -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -index dc36963c0e..043d358a06 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Hierarchy.c -@@ -184,12 +184,12 @@ Tpm2SetPrimaryPolicy ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2SetPrimaryPolicy - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2SetPrimaryPolicy - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2SetPrimaryPolicy - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2SetPrimaryPolicy - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -252,7 +252,7 @@ Tpm2Clear ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Clear: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "Clear: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -262,7 +262,7 @@ Tpm2Clear ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Clear: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "Clear: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -271,7 +271,7 @@ Tpm2Clear ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Clear: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Clear: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -346,7 +346,7 @@ Tpm2ClearControl ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ClearControl: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "ClearControl: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -356,7 +356,7 @@ Tpm2ClearControl ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ClearControl: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "ClearControl: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -365,7 +365,7 @@ Tpm2ClearControl ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "ClearControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "ClearControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -459,7 +459,7 @@ Tpm2HierarchyChangeAuth ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HierarchyChangeAuth: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "HierarchyChangeAuth: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -469,7 +469,7 @@ Tpm2HierarchyChangeAuth ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HierarchyChangeAuth: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "HierarchyChangeAuth: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -478,7 +478,7 @@ Tpm2HierarchyChangeAuth ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG((EFI_D_ERROR,"HierarchyChangeAuth: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG((DEBUG_ERROR,"HierarchyChangeAuth: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -557,7 +557,7 @@ Tpm2ChangeEPS ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ChangeEPS: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "ChangeEPS: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -567,7 +567,7 @@ Tpm2ChangeEPS ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ChangeEPS: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "ChangeEPS: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -576,7 +576,7 @@ Tpm2ChangeEPS ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG((EFI_D_ERROR,"ChangeEPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG((DEBUG_ERROR,"ChangeEPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -655,7 +655,7 @@ Tpm2ChangePPS ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ChangePPS: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "ChangePPS: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -665,7 +665,7 @@ Tpm2ChangePPS ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "ChangePPS: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "ChangePPS: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -674,7 +674,7 @@ Tpm2ChangePPS ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG((EFI_D_ERROR,"ChangePPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG((DEBUG_ERROR,"ChangePPS: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -763,7 +763,7 @@ Tpm2HierarchyControl ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HierarchyControl: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "HierarchyControl: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -773,7 +773,7 @@ Tpm2HierarchyControl ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HierarchyControl: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "HierarchyControl: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -782,7 +782,7 @@ Tpm2HierarchyControl ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG((EFI_D_ERROR,"HierarchyControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG((DEBUG_ERROR,"HierarchyControl: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -index ddb15178fb..8c87de0b0c 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Integrity.c -@@ -130,7 +130,7 @@ Tpm2PcrExtend ( - Buffer += sizeof(UINT16); - DigestSize = GetHashSizeFromAlgo (Digests->digests[Index].hashAlg); - if (DigestSize == 0) { -- DEBUG ((EFI_D_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg)); -+ DEBUG ((DEBUG_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg)); - return EFI_DEVICE_ERROR; - } - CopyMem( -@@ -151,7 +151,7 @@ Tpm2PcrExtend ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrExtend: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -160,7 +160,7 @@ Tpm2PcrExtend ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrExtend: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -168,7 +168,7 @@ Tpm2PcrExtend ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrExtend: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrExtend: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -246,7 +246,7 @@ Tpm2PcrEvent ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrEvent: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -255,7 +255,7 @@ Tpm2PcrEvent ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrEvent: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -263,7 +263,7 @@ Tpm2PcrEvent ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrEvent: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrEvent: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -284,7 +284,7 @@ Tpm2PcrEvent ( - Buffer += sizeof(UINT16); - DigestSize = GetHashSizeFromAlgo (Digests->digests[Index].hashAlg); - if (DigestSize == 0) { -- DEBUG ((EFI_D_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg)); -+ DEBUG ((DEBUG_ERROR, "Unknown hash algorithm %d\r\n", Digests->digests[Index].hashAlg)); - return EFI_DEVICE_ERROR; - } - CopyMem( -@@ -353,11 +353,11 @@ Tpm2PcrRead ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrRead - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_NOT_FOUND; - } - -@@ -369,7 +369,7 @@ Tpm2PcrRead ( - // PcrUpdateCounter - // - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - *PcrUpdateCounter = SwapBytes32(RecvBuffer.PcrUpdateCounter); -@@ -378,7 +378,7 @@ Tpm2PcrRead ( - // PcrSelectionOut - // - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter) + sizeof(RecvBuffer.PcrSelectionOut.count)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - PcrSelectionOut->count = SwapBytes32(RecvBuffer.PcrSelectionOut.count); -@@ -388,7 +388,7 @@ Tpm2PcrRead ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER) + sizeof(RecvBuffer.PcrUpdateCounter) + sizeof(RecvBuffer.PcrSelectionOut.count) + sizeof(RecvBuffer.PcrSelectionOut.pcrSelections[0]) * PcrSelectionOut->count) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrRead - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - for (Index = 0; Index < PcrSelectionOut->count; Index++) { -@@ -513,7 +513,7 @@ Tpm2PcrAllocate ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrAllocate: Failed ExecuteCommand: Buffer Too Small\r\n")); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -523,7 +523,7 @@ Tpm2PcrAllocate ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "Tpm2PcrAllocate: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2PcrAllocate: Response size too large! %d\r\n", RespSize)); - Status = EFI_BUFFER_TOO_SMALL; - goto Done; - } -@@ -532,7 +532,7 @@ Tpm2PcrAllocate ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG((EFI_D_ERROR,"Tpm2PcrAllocate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG((DEBUG_ERROR,"Tpm2PcrAllocate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -@@ -673,15 +673,15 @@ Tpm2PcrAllocateBanks ( - &SizeNeeded, - &SizeAvailable - ); -- DEBUG ((EFI_D_INFO, "Tpm2PcrAllocateBanks call Tpm2PcrAllocate - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tpm2PcrAllocateBanks call Tpm2PcrAllocate - %r\n", Status)); - if (EFI_ERROR (Status)) { - goto Done; - } - -- DEBUG ((EFI_D_INFO, "AllocationSuccess - %02x\n", AllocationSuccess)); -- DEBUG ((EFI_D_INFO, "MaxPCR - %08x\n", MaxPCR)); -- DEBUG ((EFI_D_INFO, "SizeNeeded - %08x\n", SizeNeeded)); -- DEBUG ((EFI_D_INFO, "SizeAvailable - %08x\n", SizeAvailable)); -+ DEBUG ((DEBUG_INFO, "AllocationSuccess - %02x\n", AllocationSuccess)); -+ DEBUG ((DEBUG_INFO, "MaxPCR - %08x\n", MaxPCR)); -+ DEBUG ((DEBUG_INFO, "SizeNeeded - %08x\n", SizeNeeded)); -+ DEBUG ((DEBUG_INFO, "SizeAvailable - %08x\n", SizeAvailable)); - - Done: - ZeroMem(&LocalAuthSession.hmac, sizeof(LocalAuthSession.hmac)); -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c -index 32bff45844..1afc562998 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Miscellaneous.c -@@ -96,12 +96,12 @@ Tpm2SetAlgorithmSet ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2SetAlgorithmSet - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2SetAlgorithmSet - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2SetAlgorithmSet - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2SetAlgorithmSet - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - Status = EFI_DEVICE_ERROR; - goto Done; - } -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -index 87572de201..fb46af0fed 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2NVStorage.c -@@ -200,12 +200,12 @@ Tpm2NvReadPublic ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadPublic - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -220,7 +220,7 @@ Tpm2NvReadPublic ( - } - - if (RecvBufferSize <= sizeof (TPM2_RESPONSE_HEADER) + sizeof (UINT16) + sizeof(UINT16)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_NOT_FOUND; - } - -@@ -240,7 +240,7 @@ Tpm2NvReadPublic ( - } - - if (RecvBufferSize != sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize + sizeof(UINT16) + NvNameSize) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - NvPublicSize %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - NvPublicSize %x\n", RecvBufferSize)); - return EFI_NOT_FOUND; - } - -@@ -354,14 +354,14 @@ Tpm2NvDefineSpace ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvDefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvDefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -462,14 +462,14 @@ Tpm2NvUndefineSpace ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvUndefineSpace - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvUndefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvUndefineSpace - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -577,13 +577,13 @@ Tpm2NvRead ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvRead - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvRead - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvRead - responseCode - %x\n", ResponseCode)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvRead - responseCode - %x\n", ResponseCode)); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -723,13 +723,13 @@ Tpm2NvWrite ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvWrite - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvWrite - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvWrite - responseCode - %x\n", ResponseCode)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvWrite - responseCode - %x\n", ResponseCode)); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -843,14 +843,14 @@ Tpm2NvReadLock ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadLock - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadLock - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvReadLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvReadLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -930,14 +930,14 @@ Tpm2NvWriteLock ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -@@ -1014,14 +1014,14 @@ Tpm2NvGlobalWriteLock ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvGlobalWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvGlobalWriteLock - RecvBufferSize Error - %x\n", RecvBufferSize)); - Status = EFI_DEVICE_ERROR; - goto Done; - } - - ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode); - if (ResponseCode != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2NvGlobalWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2NvGlobalWriteLock - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - } - switch (ResponseCode) { - case TPM_RC_SUCCESS: -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c -index 201c2170fc..3d99f0615c 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Sequences.c -@@ -134,7 +134,7 @@ Tpm2HashSequenceStart ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HashSequenceStart: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "HashSequenceStart: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -143,7 +143,7 @@ Tpm2HashSequenceStart ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "HashSequenceStart: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "HashSequenceStart: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -151,7 +151,7 @@ Tpm2HashSequenceStart ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "HashSequenceStart: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "HashSequenceStart: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -231,7 +231,7 @@ Tpm2SequenceUpdate ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "SequenceUpdate: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "SequenceUpdate: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -240,7 +240,7 @@ Tpm2SequenceUpdate ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "SequenceUpdate: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "SequenceUpdate: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -248,7 +248,7 @@ Tpm2SequenceUpdate ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "SequenceUpdate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "SequenceUpdate: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -340,7 +340,7 @@ Tpm2EventSequenceComplete ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "EventSequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -349,7 +349,7 @@ Tpm2EventSequenceComplete ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "EventSequenceComplete: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -357,7 +357,7 @@ Tpm2EventSequenceComplete ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "EventSequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -@@ -382,7 +382,7 @@ Tpm2EventSequenceComplete ( - - DigestSize = GetHashSizeFromAlgo (Results->digests[Index].hashAlg); - if (DigestSize == 0) { -- DEBUG ((EFI_D_ERROR, "EventSequenceComplete: Unknown hash algorithm %d\r\n", Results->digests[Index].hashAlg)); -+ DEBUG ((DEBUG_ERROR, "EventSequenceComplete: Unknown hash algorithm %d\r\n", Results->digests[Index].hashAlg)); - return EFI_DEVICE_ERROR; - } - CopyMem( -@@ -466,7 +466,7 @@ Tpm2SequenceComplete ( - } - - if (ResultBufSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "SequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n")); -+ DEBUG ((DEBUG_ERROR, "SequenceComplete: Failed ExecuteCommand: Buffer Too Small\r\n")); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -475,7 +475,7 @@ Tpm2SequenceComplete ( - // - RespSize = SwapBytes32(Res.Header.paramSize); - if (RespSize > sizeof(Res)) { -- DEBUG ((EFI_D_ERROR, "SequenceComplete: Response size too large! %d\r\n", RespSize)); -+ DEBUG ((DEBUG_ERROR, "SequenceComplete: Response size too large! %d\r\n", RespSize)); - return EFI_BUFFER_TOO_SMALL; - } - -@@ -483,7 +483,7 @@ Tpm2SequenceComplete ( - // Fail if command failed - // - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "SequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "SequenceComplete: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Session.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Session.c -index 57367432df..4ca616188c 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Session.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Session.c -@@ -124,7 +124,7 @@ Tpm2StartAuthSession ( - break; - default: - ASSERT (FALSE); -- DEBUG ((EFI_D_ERROR, "Tpm2StartAuthSession - Symmetric->algorithm - %x\n", Symmetric->algorithm)); -+ DEBUG ((DEBUG_ERROR, "Tpm2StartAuthSession - Symmetric->algorithm - %x\n", Symmetric->algorithm)); - return EFI_UNSUPPORTED; - } - -@@ -144,11 +144,11 @@ Tpm2StartAuthSession ( - } - - if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) { -- DEBUG ((EFI_D_ERROR, "Tpm2StartAuthSession - RecvBufferSize Error - %x\n", RecvBufferSize)); -+ DEBUG ((DEBUG_ERROR, "Tpm2StartAuthSession - RecvBufferSize Error - %x\n", RecvBufferSize)); - return EFI_DEVICE_ERROR; - } - if (SwapBytes32(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2StartAuthSession - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2StartAuthSession - responseCode - %x\n", SwapBytes32(RecvBuffer.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c -index 41f2367ba2..645ac49b87 100644 ---- a/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c -+++ b/SecurityPkg/Library/Tpm2CommandLib/Tpm2Startup.c -@@ -77,7 +77,7 @@ Tpm2Startup ( - DEBUG ((DEBUG_INFO, "TPM2Startup: TPM_RC_INITIALIZE\n")); - return EFI_SUCCESS; - default: -- DEBUG ((EFI_D_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", ResponseCode)); -+ DEBUG ((DEBUG_ERROR, "Tpm2Startup: Response Code error! 0x%08x\r\n", ResponseCode)); - return EFI_DEVICE_ERROR; - } - } -@@ -113,7 +113,7 @@ Tpm2Shutdown ( - } - - if (SwapBytes32(Res.Header.responseCode) != TPM_RC_SUCCESS) { -- DEBUG ((EFI_D_ERROR, "Tpm2Shutdown: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); -+ DEBUG ((DEBUG_ERROR, "Tpm2Shutdown: Response Code error! 0x%08x\r\n", SwapBytes32(Res.Header.responseCode))); - return EFI_DEVICE_ERROR; - } - -diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c -index f1f8091683..edde7f8e15 100644 ---- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c -+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Ptp.c -@@ -154,22 +154,22 @@ PtpCrbTpmCommand ( - DEBUG_CODE ( - UINTN DebugSize; - -- DEBUG ((EFI_D_VERBOSE, "PtpCrbTpmCommand Send - ")); -+ DEBUG ((DEBUG_VERBOSE, "PtpCrbTpmCommand Send - ")); - if (SizeIn > 0x100) { - DebugSize = 0x40; - } else { - DebugSize = SizeIn; - } - for (Index = 0; Index < DebugSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - if (DebugSize != SizeIn) { -- DEBUG ((EFI_D_VERBOSE, "...... ")); -+ DEBUG ((DEBUG_VERBOSE, "...... ")); - for (Index = SizeIn - 0x20; Index < SizeIn; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - TpmOutSize = 0; - -@@ -286,11 +286,11 @@ PtpCrbTpmCommand ( - BufferOut[Index] = MmioRead8 ((UINTN)&CrbReg->CrbDataBuffer[Index]); - } - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "PtpCrbTpmCommand ReceiveHeader - ")); -+ DEBUG ((DEBUG_VERBOSE, "PtpCrbTpmCommand ReceiveHeader - ")); - for (Index = 0; Index < sizeof (TPM2_RESPONSE_HEADER); Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - // - // Check the response data header (tag, parasize and returncode) -@@ -298,7 +298,7 @@ PtpCrbTpmCommand ( - CopyMem (&Data16, BufferOut, sizeof (UINT16)); - // TPM2 should not use this RSP_COMMAND - if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) { -- DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND)); -+ DEBUG ((DEBUG_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND)); - Status = EFI_UNSUPPORTED; - goto GoIdle_Exit; - } -@@ -321,11 +321,11 @@ PtpCrbTpmCommand ( - } - - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "PtpCrbTpmCommand Receive - ")); -+ DEBUG ((DEBUG_VERBOSE, "PtpCrbTpmCommand Receive - ")); - for (Index = 0; Index < TpmOutSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - - GoReady_Exit: -@@ -494,36 +494,36 @@ DumpPtpInfo ( - // - // Dump InterfaceId Register for PTP - // -- DEBUG ((EFI_D_INFO, "InterfaceId - 0x%08x\n", InterfaceId.Uint32)); -- DEBUG ((EFI_D_INFO, " InterfaceType - 0x%02x\n", InterfaceId.Bits.InterfaceType)); -+ DEBUG ((DEBUG_INFO, "InterfaceId - 0x%08x\n", InterfaceId.Uint32)); -+ DEBUG ((DEBUG_INFO, " InterfaceType - 0x%02x\n", InterfaceId.Bits.InterfaceType)); - if (InterfaceId.Bits.InterfaceType != PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_TIS) { -- DEBUG ((EFI_D_INFO, " InterfaceVersion - 0x%02x\n", InterfaceId.Bits.InterfaceVersion)); -- DEBUG ((EFI_D_INFO, " CapFIFO - 0x%x\n", InterfaceId.Bits.CapFIFO)); -- DEBUG ((EFI_D_INFO, " CapCRB - 0x%x\n", InterfaceId.Bits.CapCRB)); -+ DEBUG ((DEBUG_INFO, " InterfaceVersion - 0x%02x\n", InterfaceId.Bits.InterfaceVersion)); -+ DEBUG ((DEBUG_INFO, " CapFIFO - 0x%x\n", InterfaceId.Bits.CapFIFO)); -+ DEBUG ((DEBUG_INFO, " CapCRB - 0x%x\n", InterfaceId.Bits.CapCRB)); - } - - // - // Dump Capability Register for TIS and FIFO - // -- DEBUG ((EFI_D_INFO, "InterfaceCapability - 0x%08x\n", InterfaceCapability.Uint32)); -+ DEBUG ((DEBUG_INFO, "InterfaceCapability - 0x%08x\n", InterfaceCapability.Uint32)); - if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_TIS) || - (InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO)) { -- DEBUG ((EFI_D_INFO, " InterfaceVersion - 0x%x\n", InterfaceCapability.Bits.InterfaceVersion)); -+ DEBUG ((DEBUG_INFO, " InterfaceVersion - 0x%x\n", InterfaceCapability.Bits.InterfaceVersion)); - } - - // - // Dump StatusEx Register for PTP FIFO - // -- DEBUG ((EFI_D_INFO, "StatusEx - 0x%02x\n", StatusEx)); -+ DEBUG ((DEBUG_INFO, "StatusEx - 0x%02x\n", StatusEx)); - if (InterfaceCapability.Bits.InterfaceVersion == INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP) { -- DEBUG ((EFI_D_INFO, " TpmFamily - 0x%x\n", (StatusEx & PTP_FIFO_STS_EX_TPM_FAMILY) >> PTP_FIFO_STS_EX_TPM_FAMILY_OFFSET)); -+ DEBUG ((DEBUG_INFO, " TpmFamily - 0x%x\n", (StatusEx & PTP_FIFO_STS_EX_TPM_FAMILY) >> PTP_FIFO_STS_EX_TPM_FAMILY_OFFSET)); - } - - Vid = 0xFFFF; - Did = 0xFFFF; - Rid = 0xFF; - PtpInterface = GetCachedPtpInterface (); -- DEBUG ((EFI_D_INFO, "PtpInterface - %x\n", PtpInterface)); -+ DEBUG ((DEBUG_INFO, "PtpInterface - %x\n", PtpInterface)); - switch (PtpInterface) { - case Tpm2PtpInterfaceCrb: - Vid = MmioRead16 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->Vid); -@@ -539,9 +539,9 @@ DumpPtpInfo ( - default: - break; - } -- DEBUG ((EFI_D_INFO, "VID - 0x%04x\n", Vid)); -- DEBUG ((EFI_D_INFO, "DID - 0x%04x\n", Did)); -- DEBUG ((EFI_D_INFO, "RID - 0x%02x\n", Rid)); -+ DEBUG ((DEBUG_INFO, "VID - 0x%04x\n", Vid)); -+ DEBUG ((DEBUG_INFO, "DID - 0x%04x\n", Did)); -+ DEBUG ((DEBUG_INFO, "RID - 0x%02x\n", Rid)); - } - - /** -diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c -index 9a809612b3..e3bef8dfe4 100644 ---- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c -+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2Tis.c -@@ -221,22 +221,22 @@ Tpm2TisTpmCommand ( - DEBUG_CODE ( - UINTN DebugSize; - -- DEBUG ((EFI_D_VERBOSE, "Tpm2TisTpmCommand Send - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm2TisTpmCommand Send - ")); - if (SizeIn > 0x100) { - DebugSize = 0x40; - } else { - DebugSize = SizeIn; - } - for (Index = 0; Index < DebugSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - if (DebugSize != SizeIn) { -- DEBUG ((EFI_D_VERBOSE, "...... ")); -+ DEBUG ((DEBUG_VERBOSE, "...... ")); - for (Index = SizeIn - 0x20; Index < SizeIn; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferIn[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferIn[Index])); - } - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - TpmOutSize = 0; - -@@ -333,11 +333,11 @@ Tpm2TisTpmCommand ( - } - } - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "Tpm2TisTpmCommand ReceiveHeader - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm2TisTpmCommand ReceiveHeader - ")); - for (Index = 0; Index < sizeof (TPM2_RESPONSE_HEADER); Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - // - // Check the response data header (tag,parasize and returncode ) -@@ -345,7 +345,7 @@ Tpm2TisTpmCommand ( - CopyMem (&Data16, BufferOut, sizeof (UINT16)); - // TPM2 should not use this RSP_COMMAND - if (SwapBytes16 (Data16) == TPM_ST_RSP_COMMAND) { -- DEBUG ((EFI_D_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND)); -+ DEBUG ((DEBUG_ERROR, "TPM2: TPM_ST_RSP error - %x\n", TPM_ST_RSP_COMMAND)); - Status = EFI_UNSUPPORTED; - goto Exit; - } -@@ -377,11 +377,11 @@ Tpm2TisTpmCommand ( - } - Exit: - DEBUG_CODE ( -- DEBUG ((EFI_D_VERBOSE, "Tpm2TisTpmCommand Receive - ")); -+ DEBUG ((DEBUG_VERBOSE, "Tpm2TisTpmCommand Receive - ")); - for (Index = 0; Index < TpmOutSize; Index++) { -- DEBUG ((EFI_D_VERBOSE, "%02x ", BufferOut[Index])); -+ DEBUG ((DEBUG_VERBOSE, "%02x ", BufferOut[Index])); - } -- DEBUG ((EFI_D_VERBOSE, "\n")); -+ DEBUG ((DEBUG_VERBOSE, "\n")); - ); - MmioWrite8((UINTN)&TisReg->Status, TIS_PC_STS_READY); - return Status; -diff --git a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c -index 2e77d35433..e24ef08515 100644 ---- a/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c -+++ b/SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.c -@@ -123,7 +123,7 @@ Tpm2RegisterTpm2DeviceLib ( - // - // In PEI phase, there will be shadow driver dispatched again. - // -- DEBUG ((EFI_D_INFO, "Tpm2RegisterTpm2DeviceLib - Override\n")); -+ DEBUG ((DEBUG_INFO, "Tpm2RegisterTpm2DeviceLib - Override\n")); - CopyMem (Tpm2DeviceInterface, Tpm2Device, sizeof(*Tpm2Device)); - return EFI_SUCCESS; - } else { -diff --git a/SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.c b/SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.c -index c34c417093..9d12695a62 100644 ---- a/SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.c -+++ b/SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.c -@@ -46,7 +46,7 @@ Tpm2SubmitCommand ( - // - // Tcg2 protocol is not installed. So, TPM2 is not present. - // -- DEBUG ((EFI_D_ERROR, "Tpm2SubmitCommand - Tcg2 - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Tpm2SubmitCommand - Tcg2 - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -@@ -90,7 +90,7 @@ Tpm2RequestUseTpm ( - // - // Tcg2 protocol is not installed. So, TPM2 is not present. - // -- DEBUG ((EFI_D_ERROR, "Tpm2RequestUseTpm - Tcg2 - %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "Tpm2RequestUseTpm - Tcg2 - %r\n", Status)); - return EFI_NOT_FOUND; - } - } -diff --git a/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c b/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c -index 32b64a31d1..e5dd06ebcf 100644 ---- a/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c -+++ b/SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c -@@ -40,7 +40,7 @@ OnReadyToBoot ( - // - // Clear MOR_CLEAR_MEMORY_BIT - // -- DEBUG ((EFI_D_INFO, "TcgMor: Clear MorClearMemory bit\n")); -+ DEBUG ((DEBUG_INFO, "TcgMor: Clear MorClearMemory bit\n")); - mMorControl &= 0xFE; - - DataSize = sizeof (mMorControl); -@@ -168,7 +168,7 @@ InitiateTPerReset ( - // Found a TCG device. - // - TcgFlag = TRUE; -- DEBUG ((EFI_D_INFO, "This device is a TCG protocol device\n")); -+ DEBUG ((DEBUG_INFO, "This device is a TCG protocol device\n")); - break; - } - -@@ -177,13 +177,13 @@ InitiateTPerReset ( - // Found a IEEE 1667 device. - // - IeeeFlag = TRUE; -- DEBUG ((EFI_D_INFO, "This device is a IEEE 1667 protocol device\n")); -+ DEBUG ((DEBUG_INFO, "This device is a IEEE 1667 protocol device\n")); - break; - } - } - - if (!TcgFlag && !IeeeFlag) { -- DEBUG ((EFI_D_INFO, "Neither a TCG nor IEEE 1667 protocol device is found\n")); -+ DEBUG ((DEBUG_INFO, "Neither a TCG nor IEEE 1667 protocol device is found\n")); - goto Exit; - } - -@@ -203,9 +203,9 @@ InitiateTPerReset ( - ); - - if (!EFI_ERROR (Status)) { -- DEBUG ((EFI_D_INFO, "Send TPer Reset Command Successfully !\n")); -+ DEBUG ((DEBUG_INFO, "Send TPer Reset Command Successfully !\n")); - } else { -- DEBUG ((EFI_D_INFO, "Send TPer Reset Command Fail !\n")); -+ DEBUG ((DEBUG_INFO, "Send TPer Reset Command Fail !\n")); - } - } - -@@ -213,7 +213,7 @@ InitiateTPerReset ( - // - // TBD : Perform a TPer Reset via IEEE 1667 Protocol - // -- DEBUG ((EFI_D_INFO, "IEEE 1667 Protocol didn't support yet!\n")); -+ DEBUG ((DEBUG_INFO, "IEEE 1667 Protocol didn't support yet!\n")); - } - - Exit: -@@ -336,7 +336,7 @@ MorDriverEntryPoint ( - DataSize, - &mMorControl - ); -- DEBUG ((EFI_D_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status)); - } else { - // - // Create a Ready To Boot Event and Clear the MorControl bit in the call back function. -@@ -355,7 +355,7 @@ MorDriverEntryPoint ( - // - // Register EFI_END_OF_DXE_EVENT_GROUP_GUID event. - // -- DEBUG ((EFI_D_INFO, "TcgMor: Create EndofDxe Event for Mor TPer Reset!\n")); -+ DEBUG ((DEBUG_INFO, "TcgMor: Create EndofDxe Event for Mor TPer Reset!\n")); - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, -@@ -371,5 +371,3 @@ MorDriverEntryPoint ( - - return Status; - } -- -- -diff --git a/SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.c b/SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.c -index 8c92317313..8e775cb96c 100644 ---- a/SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.c -+++ b/SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.c -@@ -123,7 +123,7 @@ MorLockDriverEntryPointSmm ( - // - // This driver link to Smm Variable driver - // -- DEBUG ((EFI_D_INFO, "MorLockDriverEntryPointSmm\n")); -+ DEBUG ((DEBUG_INFO, "MorLockDriverEntryPointSmm\n")); - - Status = gSmst->SmmLocateProtocol ( - &gEfiSmmVariableProtocolGuid, -@@ -149,4 +149,3 @@ MorLockDriverEntryPointSmm ( - - return Status; - } -- -diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c -index 10d1c5cc78..fca5ae2645 100644 ---- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c -+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c -@@ -355,7 +355,7 @@ Tcg2ConfigDriverEntryPoint ( - &Tcg2DeviceDetection - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_DEVICE_DETECTION_NAME\n")); -+ DEBUG ((DEBUG_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_DEVICE_DETECTION_NAME\n")); - Status = gRT->SetVariable ( - TCG2_DEVICE_DETECTION_NAME, - &gTcg2ConfigFormSetGuid, -@@ -377,7 +377,7 @@ Tcg2ConfigDriverEntryPoint ( - &Tcg2Configuration - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_NAME\n")); -+ DEBUG ((DEBUG_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_NAME\n")); - } - - // -diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c -index 2946f95db0..a7446ef2f6 100644 ---- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c -+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c -@@ -960,7 +960,7 @@ InstallTcg2ConfigForm ( - &Tcg2ConfigInfo - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_INFO_NAME\n")); -+ DEBUG ((DEBUG_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_INFO_NAME\n")); - } - - return EFI_SUCCESS; -diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c -index 0f9bad724e..8abc33efd4 100644 ---- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c -+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c -@@ -104,11 +104,11 @@ Tcg2ConfigPeimEntryPoint ( - // - // Although we have SetupVariable info, we still need detect TPM device manually. - // -- DEBUG ((EFI_D_INFO, "Tcg2Configuration.TpmDevice from Setup: %x\n", Tcg2Configuration.TpmDevice)); -+ DEBUG ((DEBUG_INFO, "Tcg2Configuration.TpmDevice from Setup: %x\n", Tcg2Configuration.TpmDevice)); - - if (PcdGetBool (PcdTpmAutoDetection)) { - TpmDevice = DetectTpmDevice (Tcg2Configuration.TpmDevice); -- DEBUG ((EFI_D_INFO, "TpmDevice final: %x\n", TpmDevice)); -+ DEBUG ((DEBUG_INFO, "TpmDevice final: %x\n", TpmDevice)); - if (TpmDevice != TPM_DEVICE_NULL) { - Tcg2Configuration.TpmDevice = TpmDevice; - } -@@ -129,7 +129,7 @@ Tcg2ConfigPeimEntryPoint ( - Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid); - Status = PcdSetPtrS (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid); - ASSERT_EFI_ERROR (Status); -- DEBUG ((EFI_D_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid)); -+ DEBUG ((DEBUG_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid)); - break; - } - } -diff --git a/SecurityPkg/Tcg/Tcg2Config/TpmDetection.c b/SecurityPkg/Tcg/Tcg2Config/TpmDetection.c -index eeaadc5e2f..57d3638f0c 100644 ---- a/SecurityPkg/Tcg/Tcg2Config/TpmDetection.c -+++ b/SecurityPkg/Tcg/Tcg2Config/TpmDetection.c -@@ -47,7 +47,7 @@ DetectTpmDevice ( - // In S3, we rely on normal boot Detection, because we save to ReadOnly Variable in normal boot. - // - if (BootMode == BOOT_ON_S3_RESUME) { -- DEBUG ((EFI_D_INFO, "DetectTpmDevice: S3 mode\n")); -+ DEBUG ((DEBUG_INFO, "DetectTpmDevice: S3 mode\n")); - - Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi); - ASSERT_EFI_ERROR (Status); -@@ -65,12 +65,12 @@ DetectTpmDevice ( - if (!EFI_ERROR (Status) && - (Tcg2DeviceDetection.TpmDeviceDetected >= TPM_DEVICE_MIN) && - (Tcg2DeviceDetection.TpmDeviceDetected <= TPM_DEVICE_MAX)) { -- DEBUG ((EFI_D_ERROR, "TpmDevice from DeviceDetection: %x\n", Tcg2DeviceDetection.TpmDeviceDetected)); -+ DEBUG ((DEBUG_ERROR, "TpmDevice from DeviceDetection: %x\n", Tcg2DeviceDetection.TpmDeviceDetected)); - return Tcg2DeviceDetection.TpmDeviceDetected; - } - } - -- DEBUG ((EFI_D_INFO, "DetectTpmDevice:\n")); -+ DEBUG ((DEBUG_INFO, "DetectTpmDevice:\n")); - - // dTPM available and not disabled by setup - // We need check if it is TPM1.2 or TPM2.0 -diff --git a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c -index f1a97d4b2d..c26be18338 100644 ---- a/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c -+++ b/SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c -@@ -159,7 +159,7 @@ InternalDumpData ( - { - UINTN Index; - for (Index = 0; Index < Size; Index++) { -- DEBUG ((EFI_D_INFO, "%02x", (UINTN)Data[Index])); -+ DEBUG ((DEBUG_INFO, "%02x", (UINTN)Data[Index])); - } - } - -@@ -262,15 +262,15 @@ InternalDumpHex ( - Count = Size / COLUME_SIZE; - Left = Size % COLUME_SIZE; - for (Index = 0; Index < Count; Index++) { -- DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE)); -+ DEBUG ((DEBUG_INFO, "%04x: ", Index * COLUME_SIZE)); - InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE); -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - - if (Left != 0) { -- DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE)); -+ DEBUG ((DEBUG_INFO, "%04x: ", Index * COLUME_SIZE)); - InternalDumpData (Data + Index * COLUME_SIZE, Left); -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - } - -@@ -403,7 +403,7 @@ Tcg2GetCapability ( - ProtocolCapability->StructureVersion.Minor = 0; - ProtocolCapability->ProtocolVersion.Major = 1; - ProtocolCapability->ProtocolVersion.Minor = 0; -- DEBUG ((EFI_D_ERROR, "TreeGetCapability (Compatible) - %r\n", EFI_SUCCESS)); -+ DEBUG ((DEBUG_ERROR, "TreeGetCapability (Compatible) - %r\n", EFI_SUCCESS)); - return EFI_SUCCESS; - } - } -@@ -428,15 +428,15 @@ DumpEvent ( - { - UINTN Index; - -- DEBUG ((EFI_D_INFO, " Event:\n")); -- DEBUG ((EFI_D_INFO, " PCRIndex - %d\n", EventHdr->PCRIndex)); -- DEBUG ((EFI_D_INFO, " EventType - 0x%08x\n", EventHdr->EventType)); -- DEBUG ((EFI_D_INFO, " Digest - ")); -+ DEBUG ((DEBUG_INFO, " Event:\n")); -+ DEBUG ((DEBUG_INFO, " PCRIndex - %d\n", EventHdr->PCRIndex)); -+ DEBUG ((DEBUG_INFO, " EventType - 0x%08x\n", EventHdr->EventType)); -+ DEBUG ((DEBUG_INFO, " Digest - ")); - for (Index = 0; Index < sizeof(TCG_DIGEST); Index++) { -- DEBUG ((EFI_D_INFO, "%02x ", EventHdr->Digest.digest[Index])); -+ DEBUG ((DEBUG_INFO, "%02x ", EventHdr->Digest.digest[Index])); - } -- DEBUG ((EFI_D_INFO, "\n")); -- DEBUG ((EFI_D_INFO, " EventSize - 0x%08x\n", EventHdr->EventSize)); -+ DEBUG ((DEBUG_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, " EventSize - 0x%08x\n", EventHdr->EventSize)); - InternalDumpHex ((UINT8 *)(EventHdr + 1), EventHdr->EventSize); - } - -@@ -456,33 +456,33 @@ DumpTcgEfiSpecIdEventStruct ( - UINT8 *VendorInfo; - UINT32 NumberOfAlgorithms; - -- DEBUG ((EFI_D_INFO, " TCG_EfiSpecIDEventStruct:\n")); -- DEBUG ((EFI_D_INFO, " signature - '")); -+ DEBUG ((DEBUG_INFO, " TCG_EfiSpecIDEventStruct:\n")); -+ DEBUG ((DEBUG_INFO, " signature - '")); - for (Index = 0; Index < sizeof(TcgEfiSpecIdEventStruct->signature); Index++) { -- DEBUG ((EFI_D_INFO, "%c", TcgEfiSpecIdEventStruct->signature[Index])); -+ DEBUG ((DEBUG_INFO, "%c", TcgEfiSpecIdEventStruct->signature[Index])); - } -- DEBUG ((EFI_D_INFO, "'\n")); -- DEBUG ((EFI_D_INFO, " platformClass - 0x%08x\n", TcgEfiSpecIdEventStruct->platformClass)); -- DEBUG ((EFI_D_INFO, " specVersion - %d.%d%d\n", TcgEfiSpecIdEventStruct->specVersionMajor, TcgEfiSpecIdEventStruct->specVersionMinor, TcgEfiSpecIdEventStruct->specErrata)); -- DEBUG ((EFI_D_INFO, " uintnSize - 0x%02x\n", TcgEfiSpecIdEventStruct->uintnSize)); -+ DEBUG ((DEBUG_INFO, "'\n")); -+ DEBUG ((DEBUG_INFO, " platformClass - 0x%08x\n", TcgEfiSpecIdEventStruct->platformClass)); -+ DEBUG ((DEBUG_INFO, " specVersion - %d.%d%d\n", TcgEfiSpecIdEventStruct->specVersionMajor, TcgEfiSpecIdEventStruct->specVersionMinor, TcgEfiSpecIdEventStruct->specErrata)); -+ DEBUG ((DEBUG_INFO, " uintnSize - 0x%02x\n", TcgEfiSpecIdEventStruct->uintnSize)); - - CopyMem (&NumberOfAlgorithms, TcgEfiSpecIdEventStruct + 1, sizeof(NumberOfAlgorithms)); -- DEBUG ((EFI_D_INFO, " NumberOfAlgorithms - 0x%08x\n", NumberOfAlgorithms)); -+ DEBUG ((DEBUG_INFO, " NumberOfAlgorithms - 0x%08x\n", NumberOfAlgorithms)); - - DigestSize = (TCG_EfiSpecIdEventAlgorithmSize *)((UINT8 *)TcgEfiSpecIdEventStruct + sizeof(*TcgEfiSpecIdEventStruct) + sizeof(NumberOfAlgorithms)); - for (Index = 0; Index < NumberOfAlgorithms; Index++) { -- DEBUG ((EFI_D_INFO, " digest(%d)\n", Index)); -- DEBUG ((EFI_D_INFO, " algorithmId - 0x%04x\n", DigestSize[Index].algorithmId)); -- DEBUG ((EFI_D_INFO, " digestSize - 0x%04x\n", DigestSize[Index].digestSize)); -+ DEBUG ((DEBUG_INFO, " digest(%d)\n", Index)); -+ DEBUG ((DEBUG_INFO, " algorithmId - 0x%04x\n", DigestSize[Index].algorithmId)); -+ DEBUG ((DEBUG_INFO, " digestSize - 0x%04x\n", DigestSize[Index].digestSize)); - } - VendorInfoSize = (UINT8 *)&DigestSize[NumberOfAlgorithms]; -- DEBUG ((EFI_D_INFO, " VendorInfoSize - 0x%02x\n", *VendorInfoSize)); -+ DEBUG ((DEBUG_INFO, " VendorInfoSize - 0x%02x\n", *VendorInfoSize)); - VendorInfo = VendorInfoSize + 1; -- DEBUG ((EFI_D_INFO, " VendorInfo - ")); -+ DEBUG ((DEBUG_INFO, " VendorInfo - ")); - for (Index = 0; Index < *VendorInfoSize; Index++) { -- DEBUG ((EFI_D_INFO, "%02x ", VendorInfo[Index])); -+ DEBUG ((DEBUG_INFO, "%02x ", VendorInfo[Index])); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - } - - /** -@@ -525,34 +525,34 @@ DumpEvent2 ( - UINT32 EventSize; - UINT8 *EventBuffer; - -- DEBUG ((EFI_D_INFO, " Event:\n")); -- DEBUG ((EFI_D_INFO, " PCRIndex - %d\n", TcgPcrEvent2->PCRIndex)); -- DEBUG ((EFI_D_INFO, " EventType - 0x%08x\n", TcgPcrEvent2->EventType)); -+ DEBUG ((DEBUG_INFO, " Event:\n")); -+ DEBUG ((DEBUG_INFO, " PCRIndex - %d\n", TcgPcrEvent2->PCRIndex)); -+ DEBUG ((DEBUG_INFO, " EventType - 0x%08x\n", TcgPcrEvent2->EventType)); - -- DEBUG ((EFI_D_INFO, " DigestCount: 0x%08x\n", TcgPcrEvent2->Digest.count)); -+ DEBUG ((DEBUG_INFO, " DigestCount: 0x%08x\n", TcgPcrEvent2->Digest.count)); - - DigestCount = TcgPcrEvent2->Digest.count; - HashAlgo = TcgPcrEvent2->Digest.digests[0].hashAlg; - DigestBuffer = (UINT8 *)&TcgPcrEvent2->Digest.digests[0].digest; - for (DigestIndex = 0; DigestIndex < DigestCount; DigestIndex++) { -- DEBUG ((EFI_D_INFO, " HashAlgo : 0x%04x\n", HashAlgo)); -- DEBUG ((EFI_D_INFO, " Digest(%d): ", DigestIndex)); -+ DEBUG ((DEBUG_INFO, " HashAlgo : 0x%04x\n", HashAlgo)); -+ DEBUG ((DEBUG_INFO, " Digest(%d): ", DigestIndex)); - DigestSize = GetHashSizeFromAlgo (HashAlgo); - for (Index = 0; Index < DigestSize; Index++) { -- DEBUG ((EFI_D_INFO, "%02x ", DigestBuffer[Index])); -+ DEBUG ((DEBUG_INFO, "%02x ", DigestBuffer[Index])); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - // - // Prepare next - // - CopyMem (&HashAlgo, DigestBuffer + DigestSize, sizeof(TPMI_ALG_HASH)); - DigestBuffer = DigestBuffer + DigestSize + sizeof(TPMI_ALG_HASH); - } -- DEBUG ((EFI_D_INFO, "\n")); -+ DEBUG ((DEBUG_INFO, "\n")); - DigestBuffer = DigestBuffer - sizeof(TPMI_ALG_HASH); - - CopyMem (&EventSize, DigestBuffer, sizeof(TcgPcrEvent2->EventSize)); -- DEBUG ((EFI_D_INFO, " EventSize - 0x%08x\n", EventSize)); -+ DEBUG ((DEBUG_INFO, " EventSize - 0x%08x\n", EventSize)); - EventBuffer = DigestBuffer + sizeof(TcgPcrEvent2->EventSize); - InternalDumpHex (EventBuffer, EventSize); - } -@@ -618,7 +618,7 @@ DumpEventLog ( - TCG_EfiSpecIDEventStruct *TcgEfiSpecIdEventStruct; - UINTN NumberOfEvents; - -- DEBUG ((EFI_D_INFO, "EventLogFormat: (0x%x)\n", EventLogFormat)); -+ DEBUG ((DEBUG_INFO, "EventLogFormat: (0x%x)\n", EventLogFormat)); - - switch (EventLogFormat) { - case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2: -@@ -628,11 +628,11 @@ DumpEventLog ( - EventHdr = (TCG_PCR_EVENT_HDR *)((UINTN)EventHdr + sizeof(TCG_PCR_EVENT_HDR) + EventHdr->EventSize); - } - if (FinalEventsTable == NULL) { -- DEBUG ((EFI_D_INFO, "FinalEventsTable: NOT FOUND\n")); -+ DEBUG ((DEBUG_INFO, "FinalEventsTable: NOT FOUND\n")); - } else { -- DEBUG ((EFI_D_INFO, "FinalEventsTable: (0x%x)\n", FinalEventsTable)); -- DEBUG ((EFI_D_INFO, " Version: (0x%x)\n", FinalEventsTable->Version)); -- DEBUG ((EFI_D_INFO, " NumberOfEvents: (0x%x)\n", FinalEventsTable->NumberOfEvents)); -+ DEBUG ((DEBUG_INFO, "FinalEventsTable: (0x%x)\n", FinalEventsTable)); -+ DEBUG ((DEBUG_INFO, " Version: (0x%x)\n", FinalEventsTable->Version)); -+ DEBUG ((DEBUG_INFO, " NumberOfEvents: (0x%x)\n", FinalEventsTable->NumberOfEvents)); - - EventHdr = (TCG_PCR_EVENT_HDR *)(UINTN)(FinalEventsTable + 1); - for (NumberOfEvents = 0; NumberOfEvents < FinalEventsTable->NumberOfEvents; NumberOfEvents++) { -@@ -658,11 +658,11 @@ DumpEventLog ( - } - - if (FinalEventsTable == NULL) { -- DEBUG ((EFI_D_INFO, "FinalEventsTable: NOT FOUND\n")); -+ DEBUG ((DEBUG_INFO, "FinalEventsTable: NOT FOUND\n")); - } else { -- DEBUG ((EFI_D_INFO, "FinalEventsTable: (0x%x)\n", FinalEventsTable)); -- DEBUG ((EFI_D_INFO, " Version: (0x%x)\n", FinalEventsTable->Version)); -- DEBUG ((EFI_D_INFO, " NumberOfEvents: (0x%x)\n", FinalEventsTable->NumberOfEvents)); -+ DEBUG ((DEBUG_INFO, "FinalEventsTable: (0x%x)\n", FinalEventsTable)); -+ DEBUG ((DEBUG_INFO, " Version: (0x%x)\n", FinalEventsTable->Version)); -+ DEBUG ((DEBUG_INFO, " NumberOfEvents: (0x%x)\n", FinalEventsTable->NumberOfEvents)); - - TcgPcrEvent2 = (TCG_PCR_EVENT2 *)(UINTN)(FinalEventsTable + 1); - for (NumberOfEvents = 0; NumberOfEvents < FinalEventsTable->NumberOfEvents; NumberOfEvents++) { -@@ -705,7 +705,7 @@ Tcg2GetEventLog ( - { - UINTN Index; - -- DEBUG ((EFI_D_INFO, "Tcg2GetEventLog ... (0x%x)\n", EventLogFormat)); -+ DEBUG ((DEBUG_INFO, "Tcg2GetEventLog ... (0x%x)\n", EventLogFormat)); - - if (This == NULL) { - return EFI_INVALID_PARAMETER; -@@ -740,7 +740,7 @@ Tcg2GetEventLog ( - - if (EventLogLocation != NULL) { - *EventLogLocation = mTcgDxeData.EventLogAreaStruct[Index].Lasa; -- DEBUG ((EFI_D_INFO, "Tcg2GetEventLog (EventLogLocation - %x)\n", *EventLogLocation)); -+ DEBUG ((DEBUG_INFO, "Tcg2GetEventLog (EventLogLocation - %x)\n", *EventLogLocation)); - } - - if (EventLogLastEntry != NULL) { -@@ -749,15 +749,15 @@ Tcg2GetEventLog ( - } else { - *EventLogLastEntry = (EFI_PHYSICAL_ADDRESS)(UINTN)mTcgDxeData.EventLogAreaStruct[Index].LastEvent; - } -- DEBUG ((EFI_D_INFO, "Tcg2GetEventLog (EventLogLastEntry - %x)\n", *EventLogLastEntry)); -+ DEBUG ((DEBUG_INFO, "Tcg2GetEventLog (EventLogLastEntry - %x)\n", *EventLogLastEntry)); - } - - if (EventLogTruncated != NULL) { - *EventLogTruncated = mTcgDxeData.EventLogAreaStruct[Index].EventLogTruncated; -- DEBUG ((EFI_D_INFO, "Tcg2GetEventLog (EventLogTruncated - %x)\n", *EventLogTruncated)); -+ DEBUG ((DEBUG_INFO, "Tcg2GetEventLog (EventLogTruncated - %x)\n", *EventLogTruncated)); - } - -- DEBUG ((EFI_D_INFO, "Tcg2GetEventLog - %r\n", EFI_SUCCESS)); -+ DEBUG ((DEBUG_INFO, "Tcg2GetEventLog - %r\n", EFI_SUCCESS)); - - // Dump Event Log for debug purpose - if ((EventLogLocation != NULL) && (EventLogLastEntry != NULL)) { -@@ -980,8 +980,8 @@ TcgDxeLogEvent ( - // Increase the NumberOfEvents in FinalEventsTable - // - (mTcgDxeData.FinalEventsTable[Index])->NumberOfEvents ++; -- DEBUG ((EFI_D_INFO, "FinalEventsTable->NumberOfEvents - 0x%x\n", (mTcgDxeData.FinalEventsTable[Index])->NumberOfEvents)); -- DEBUG ((EFI_D_INFO, " Size - 0x%x\n", (UINTN)EventLogAreaStruct->EventLogSize)); -+ DEBUG ((DEBUG_INFO, "FinalEventsTable->NumberOfEvents - 0x%x\n", (mTcgDxeData.FinalEventsTable[Index])->NumberOfEvents)); -+ DEBUG ((DEBUG_INFO, " Size - 0x%x\n", (UINTN)EventLogAreaStruct->EventLogSize)); - } - } - -@@ -1101,12 +1101,12 @@ TcgDxeLogHashEvent ( - UINT8 *DigestBuffer; - UINT32 *EventSizePtr; - -- DEBUG ((EFI_D_INFO, "SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs)); -+ DEBUG ((DEBUG_INFO, "SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs)); - - RetStatus = EFI_SUCCESS; - for (Index = 0; Index < sizeof(mTcg2EventInfo)/sizeof(mTcg2EventInfo[0]); Index++) { - if ((mTcgDxeData.BsCap.SupportedEventLogs & mTcg2EventInfo[Index].LogFormat) != 0) { -- DEBUG ((EFI_D_INFO, " LogFormat - 0x%08x\n", mTcg2EventInfo[Index].LogFormat)); -+ DEBUG ((DEBUG_INFO, " LogFormat - 0x%08x\n", mTcg2EventInfo[Index].LogFormat)); - switch (mTcg2EventInfo[Index].LogFormat) { - case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2: - Status = GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest); -@@ -1224,7 +1224,7 @@ TcgDxeHashLogExtendEvent ( - } - - if (Status == EFI_DEVICE_ERROR) { -- DEBUG ((EFI_D_ERROR, "TcgDxeHashLogExtendEvent - %r. Disable TPM.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "TcgDxeHashLogExtendEvent - %r. Disable TPM.\n", Status)); - mTcgDxeData.BsCap.TPMPresentFlag = FALSE; - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -1308,7 +1308,7 @@ Tcg2HashLogExtendEvent ( - } - } - if (Status == EFI_DEVICE_ERROR) { -- DEBUG ((EFI_D_ERROR, "MeasurePeImageAndExtend - %r. Disable TPM.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "MeasurePeImageAndExtend - %r. Disable TPM.\n", Status)); - mTcgDxeData.BsCap.TPMPresentFlag = FALSE; - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -1354,7 +1354,7 @@ Tcg2SubmitCommand ( - { - EFI_STATUS Status; - -- DEBUG ((EFI_D_INFO, "Tcg2SubmitCommand ...\n")); -+ DEBUG ((DEBUG_INFO, "Tcg2SubmitCommand ...\n")); - - if ((This == NULL) || - (InputParameterBlockSize == 0) || (InputParameterBlock == NULL) || -@@ -1379,7 +1379,7 @@ Tcg2SubmitCommand ( - &OutputParameterBlockSize, - OutputParameterBlock - ); -- DEBUG ((EFI_D_INFO, "Tcg2SubmitCommand - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tcg2SubmitCommand - %r\n", Status)); - return Status; - } - -@@ -1425,7 +1425,7 @@ Tcg2SetActivePCRBanks ( - EFI_STATUS Status; - UINT32 ReturnCode; - -- DEBUG ((EFI_D_INFO, "Tcg2SetActivePCRBanks ... (0x%x)\n", ActivePcrBanks)); -+ DEBUG ((DEBUG_INFO, "Tcg2SetActivePCRBanks ... (0x%x)\n", ActivePcrBanks)); - - if (ActivePcrBanks == 0) { - return EFI_INVALID_PARAMETER; -@@ -1452,7 +1452,7 @@ Tcg2SetActivePCRBanks ( - Status = EFI_DEVICE_ERROR; - } - -- DEBUG ((EFI_D_INFO, "Tcg2SetActivePCRBanks - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "Tcg2SetActivePCRBanks - %r\n", Status)); - - return Status; - } -@@ -1533,7 +1533,7 @@ SetupEventLog ( - UINT32 NumberOfAlgorithms; - TCG_EfiStartupLocalityEvent StartupLocalityEvent; - -- DEBUG ((EFI_D_INFO, "SetupEventLog\n")); -+ DEBUG ((DEBUG_INFO, "SetupEventLog\n")); - - // - // 1. Create Log Area -@@ -1940,7 +1940,7 @@ MeasureSeparatorEvent ( - TCG_PCR_EVENT_HDR TcgEvent; - UINT32 EventData; - -- DEBUG ((EFI_D_INFO, "MeasureSeparatorEvent Pcr - %x\n", PCRIndex)); -+ DEBUG ((DEBUG_INFO, "MeasureSeparatorEvent Pcr - %x\n", PCRIndex)); - - EventData = 0; - TcgEvent.PCRIndex = PCRIndex; -@@ -1985,8 +1985,8 @@ MeasureVariable ( - UINTN VarNameLength; - UEFI_VARIABLE_DATA *VarLog; - -- DEBUG ((EFI_D_INFO, "Tcg2Dxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)PCRIndex, (UINTN)EventType)); -- DEBUG ((EFI_D_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); -+ DEBUG ((DEBUG_INFO, "Tcg2Dxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)PCRIndex, (UINTN)EventType)); -+ DEBUG ((DEBUG_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid)); - - VarNameLength = StrLen (VarName); - TcgEvent.PCRIndex = PCRIndex; -@@ -2336,11 +2336,11 @@ MeasureSecureBootPolicy ( - - if (PcdGetBool (PcdFirmwareDebuggerInitialized)) { - Status = MeasureLaunchOfFirmwareDebugger (); -- DEBUG ((EFI_D_INFO, "MeasureLaunchOfFirmwareDebugger - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "MeasureLaunchOfFirmwareDebugger - %r\n", Status)); - } - - Status = MeasureAllSecureVariables (); -- DEBUG ((EFI_D_INFO, "MeasureAllSecureVariables - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "MeasureAllSecureVariables - %r\n", Status)); - - // - // We need measure Separator(7) here, because this event must be between SecureBootPolicy (Configure) -@@ -2349,7 +2349,7 @@ MeasureSecureBootPolicy ( - // the Authority measurement happen before ReadToBoot event. - // - Status = MeasureSeparatorEvent (7); -- DEBUG ((EFI_D_INFO, "MeasureSeparatorEvent - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "MeasureSeparatorEvent - %r\n", Status)); - return ; - } - -@@ -2380,7 +2380,7 @@ OnReadyToBoot ( - // - Status = MeasureHandoffTables (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "HOBs not Measured. Error!\n")); -+ DEBUG ((DEBUG_ERROR, "HOBs not Measured. Error!\n")); - } - - // -@@ -2388,7 +2388,7 @@ OnReadyToBoot ( - // - Status = MeasureAllBootVariables (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Boot Variables not Measured. Error!\n")); -+ DEBUG ((DEBUG_ERROR, "Boot Variables not Measured. Error!\n")); - } - - // -@@ -2399,7 +2399,7 @@ OnReadyToBoot ( - EFI_CALLING_EFI_APPLICATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); - } - - // -@@ -2433,7 +2433,7 @@ OnReadyToBoot ( - EFI_RETURNING_FROM_EFI_APPLICATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATION)); - } - - // -@@ -2445,11 +2445,11 @@ OnReadyToBoot ( - EFI_CALLING_EFI_APPLICATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); - } - } - -- DEBUG ((EFI_D_INFO, "TPM2 Tcg2Dxe Measure Data when ReadyToBoot\n")); -+ DEBUG ((DEBUG_INFO, "TPM2 Tcg2Dxe Measure Data when ReadyToBoot\n")); - // - // Increase boot attempt counter. - // -@@ -2483,7 +2483,7 @@ OnExitBootServices ( - EFI_EXIT_BOOT_SERVICES_INVOCATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION)); - } - - // -@@ -2494,7 +2494,7 @@ OnExitBootServices ( - EFI_EXIT_BOOT_SERVICES_SUCCEEDED - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED)); - } - } - -@@ -2524,7 +2524,7 @@ OnExitBootServicesFailed ( - EFI_EXIT_BOOT_SERVICES_FAILED - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED)); - } - - } -@@ -2663,13 +2663,13 @@ DriverEntry ( - } - - if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) { -- DEBUG ((EFI_D_ERROR, "TPM2 error!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM2 error!\n")); - return EFI_DEVICE_ERROR; - } - - Status = Tpm2RequestUseTpm (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "TPM2 not detected!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM2 not detected!\n")); - return Status; - } - -@@ -2684,14 +2684,14 @@ DriverEntry ( - mTcgDxeData.BsCap.StructureVersion.Major = 1; - mTcgDxeData.BsCap.StructureVersion.Minor = 1; - -- DEBUG ((EFI_D_INFO, "Tcg2.ProtocolVersion - %02x.%02x\n", mTcgDxeData.BsCap.ProtocolVersion.Major, mTcgDxeData.BsCap.ProtocolVersion.Minor)); -- DEBUG ((EFI_D_INFO, "Tcg2.StructureVersion - %02x.%02x\n", mTcgDxeData.BsCap.StructureVersion.Major, mTcgDxeData.BsCap.StructureVersion.Minor)); -+ DEBUG ((DEBUG_INFO, "Tcg2.ProtocolVersion - %02x.%02x\n", mTcgDxeData.BsCap.ProtocolVersion.Major, mTcgDxeData.BsCap.ProtocolVersion.Minor)); -+ DEBUG ((DEBUG_INFO, "Tcg2.StructureVersion - %02x.%02x\n", mTcgDxeData.BsCap.StructureVersion.Major, mTcgDxeData.BsCap.StructureVersion.Minor)); - - Status = Tpm2GetCapabilityManufactureID (&mTcgDxeData.BsCap.ManufacturerID); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityManufactureID fail!\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityManufactureID fail!\n")); - } else { -- DEBUG ((EFI_D_INFO, "Tpm2GetCapabilityManufactureID - %08x\n", mTcgDxeData.BsCap.ManufacturerID)); -+ DEBUG ((DEBUG_INFO, "Tpm2GetCapabilityManufactureID - %08x\n", mTcgDxeData.BsCap.ManufacturerID)); - } - - DEBUG_CODE ( -@@ -2700,19 +2700,19 @@ DriverEntry ( - - Status = Tpm2GetCapabilityFirmwareVersion (&FirmwareVersion1, &FirmwareVersion2); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityFirmwareVersion fail!\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityFirmwareVersion fail!\n")); - } else { -- DEBUG ((EFI_D_INFO, "Tpm2GetCapabilityFirmwareVersion - %08x %08x\n", FirmwareVersion1, FirmwareVersion2)); -+ DEBUG ((DEBUG_INFO, "Tpm2GetCapabilityFirmwareVersion - %08x %08x\n", FirmwareVersion1, FirmwareVersion2)); - } - ); - - Status = Tpm2GetCapabilityMaxCommandResponseSize (&MaxCommandSize, &MaxResponseSize); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Tpm2GetCapabilityMaxCommandResponseSize fail!\n")); -+ DEBUG ((DEBUG_ERROR, "Tpm2GetCapabilityMaxCommandResponseSize fail!\n")); - } else { - mTcgDxeData.BsCap.MaxCommandSize = (UINT16)MaxCommandSize; - mTcgDxeData.BsCap.MaxResponseSize = (UINT16)MaxResponseSize; -- DEBUG ((EFI_D_INFO, "Tpm2GetCapabilityMaxCommandResponseSize - %08x, %08x\n", MaxCommandSize, MaxResponseSize)); -+ DEBUG ((DEBUG_INFO, "Tpm2GetCapabilityMaxCommandResponseSize - %08x, %08x\n", MaxCommandSize, MaxResponseSize)); - } - - // -@@ -2739,7 +2739,7 @@ DriverEntry ( - } else { - mTcgDxeData.BsCap.NumberOfPCRBanks = PcdGet32 (PcdTcg2NumberOfPCRBanks); - if (PcdGet32 (PcdTcg2NumberOfPCRBanks) > NumberOfPCRBanks) { -- DEBUG ((EFI_D_ERROR, "ERROR: PcdTcg2NumberOfPCRBanks(0x%x) > NumberOfPCRBanks(0x%x)\n", PcdGet32 (PcdTcg2NumberOfPCRBanks), NumberOfPCRBanks)); -+ DEBUG ((DEBUG_ERROR, "ERROR: PcdTcg2NumberOfPCRBanks(0x%x) > NumberOfPCRBanks(0x%x)\n", PcdGet32 (PcdTcg2NumberOfPCRBanks), NumberOfPCRBanks)); - mTcgDxeData.BsCap.NumberOfPCRBanks = NumberOfPCRBanks; - } - } -@@ -2752,10 +2752,10 @@ DriverEntry ( - mTcgDxeData.BsCap.SupportedEventLogs &= ~EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2; - } - -- DEBUG ((EFI_D_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs)); -- DEBUG ((EFI_D_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", mTcgDxeData.BsCap.HashAlgorithmBitmap)); -- DEBUG ((EFI_D_INFO, "Tcg2.NumberOfPCRBanks - 0x%08x\n", mTcgDxeData.BsCap.NumberOfPCRBanks)); -- DEBUG ((EFI_D_INFO, "Tcg2.ActivePcrBanks - 0x%08x\n", mTcgDxeData.BsCap.ActivePcrBanks)); -+ DEBUG ((DEBUG_INFO, "Tcg2.SupportedEventLogs - 0x%08x\n", mTcgDxeData.BsCap.SupportedEventLogs)); -+ DEBUG ((DEBUG_INFO, "Tcg2.HashAlgorithmBitmap - 0x%08x\n", mTcgDxeData.BsCap.HashAlgorithmBitmap)); -+ DEBUG ((DEBUG_INFO, "Tcg2.NumberOfPCRBanks - 0x%08x\n", mTcgDxeData.BsCap.NumberOfPCRBanks)); -+ DEBUG ((DEBUG_INFO, "Tcg2.ActivePcrBanks - 0x%08x\n", mTcgDxeData.BsCap.ActivePcrBanks)); - - if (mTcgDxeData.BsCap.TPMPresentFlag) { - // -@@ -2812,7 +2812,7 @@ DriverEntry ( - // Install Tcg2Protocol - // - Status = InstallTcg2 (); -- DEBUG ((EFI_D_INFO, "InstallTcg2 - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "InstallTcg2 - %r\n", Status)); - - return Status; - } -diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c -index 93a8803ff6..7eb02f08f9 100644 ---- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c -+++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c -@@ -267,7 +267,7 @@ SyncPcrAllocationsAndPcrMask ( - UINT32 Tpm2PcrMask; - UINT32 NewTpm2PcrMask; - -- DEBUG ((EFI_D_ERROR, "SyncPcrAllocationsAndPcrMask!\n")); -+ DEBUG ((DEBUG_ERROR, "SyncPcrAllocationsAndPcrMask!\n")); - - // - // Determine the current TPM support and the Platform PCR mask. -@@ -297,9 +297,9 @@ SyncPcrAllocationsAndPcrMask ( - if ((TpmActivePcrBanks & Tpm2PcrMask) != TpmActivePcrBanks) { - NewTpmActivePcrBanks = TpmActivePcrBanks & Tpm2PcrMask; - -- DEBUG ((EFI_D_INFO, "%a - Reallocating PCR banks from 0x%X to 0x%X.\n", __FUNCTION__, TpmActivePcrBanks, NewTpmActivePcrBanks)); -+ DEBUG ((DEBUG_INFO, "%a - Reallocating PCR banks from 0x%X to 0x%X.\n", __FUNCTION__, TpmActivePcrBanks, NewTpmActivePcrBanks)); - if (NewTpmActivePcrBanks == 0) { -- DEBUG ((EFI_D_ERROR, "%a - No viable PCRs active! Please set a less restrictive value for PcdTpm2HashMask!\n", __FUNCTION__)); -+ DEBUG ((DEBUG_ERROR, "%a - No viable PCRs active! Please set a less restrictive value for PcdTpm2HashMask!\n", __FUNCTION__)); - ASSERT (FALSE); - } else { - Status = Tpm2PcrAllocateBanks (NULL, (UINT32)TpmHashAlgorithmBitmap, NewTpmActivePcrBanks); -@@ -307,7 +307,7 @@ SyncPcrAllocationsAndPcrMask ( - // - // We can't do much here, but we hope that this doesn't happen. - // -- DEBUG ((EFI_D_ERROR, "%a - Failed to reallocate PCRs!\n", __FUNCTION__)); -+ DEBUG ((DEBUG_ERROR, "%a - Failed to reallocate PCRs!\n", __FUNCTION__)); - ASSERT_EFI_ERROR (Status); - } - // -@@ -324,9 +324,9 @@ SyncPcrAllocationsAndPcrMask ( - if ((Tpm2PcrMask & TpmHashAlgorithmBitmap) != Tpm2PcrMask) { - NewTpm2PcrMask = Tpm2PcrMask & TpmHashAlgorithmBitmap; - -- DEBUG ((EFI_D_INFO, "%a - Updating PcdTpm2HashMask from 0x%X to 0x%X.\n", __FUNCTION__, Tpm2PcrMask, NewTpm2PcrMask)); -+ DEBUG ((DEBUG_INFO, "%a - Updating PcdTpm2HashMask from 0x%X to 0x%X.\n", __FUNCTION__, Tpm2PcrMask, NewTpm2PcrMask)); - if (NewTpm2PcrMask == 0) { -- DEBUG ((EFI_D_ERROR, "%a - No viable PCRs supported! Please set a less restrictive value for PcdTpm2HashMask!\n", __FUNCTION__)); -+ DEBUG ((DEBUG_ERROR, "%a - No viable PCRs supported! Please set a less restrictive value for PcdTpm2HashMask!\n", __FUNCTION__)); - ASSERT (FALSE); - } - -@@ -365,7 +365,7 @@ LogHashEvent ( - RetStatus = EFI_SUCCESS; - for (Index = 0; Index < sizeof(mTcg2EventInfo)/sizeof(mTcg2EventInfo[0]); Index++) { - if ((SupportedEventLogs & mTcg2EventInfo[Index].LogFormat) != 0) { -- DEBUG ((EFI_D_INFO, " LogFormat - 0x%08x\n", mTcg2EventInfo[Index].LogFormat)); -+ DEBUG ((DEBUG_INFO, " LogFormat - 0x%08x\n", mTcg2EventInfo[Index].LogFormat)); - switch (mTcg2EventInfo[Index].LogFormat) { - case EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2: - Status = GetDigestFromDigestList (TPM_ALG_SHA1, DigestList, &NewEventHdr->Digest); -@@ -476,7 +476,7 @@ HashLogExtendEvent ( - } - - if (Status == EFI_DEVICE_ERROR) { -- DEBUG ((EFI_D_ERROR, "HashLogExtendEvent - %r. Disable TPM.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "HashLogExtendEvent - %r. Disable TPM.\n", Status)); - BuildGuidHob (&gTpmErrorHobGuid,0); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -1011,7 +1011,7 @@ PeimEntryMA ( - } - - if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) { -- DEBUG ((EFI_D_ERROR, "TPM2 error!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM2 error!\n")); - return EFI_DEVICE_ERROR; - } - -@@ -1075,7 +1075,7 @@ PeimEntryMA ( - for (PcrIndex = 0; PcrIndex < 8; PcrIndex++) { - Status = MeasureSeparatorEventWithError (PcrIndex); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Separator Event with Error not Measured. Error!\n")); -+ DEBUG ((DEBUG_ERROR, "Separator Event with Error not Measured. Error!\n")); - } - } - } -@@ -1106,7 +1106,7 @@ PeimEntryMA ( - - Done: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "TPM2 error! Build Hob\n")); -+ DEBUG ((DEBUG_ERROR, "TPM2 error! Build Hob\n")); - BuildGuidHob (&gTpmErrorHobGuid,0); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c -index f49eccb0bd..9f5111552b 100644 ---- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c -+++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c -@@ -203,7 +203,7 @@ MemoryClearCallback ( - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - -@@ -213,7 +213,7 @@ MemoryClearCallback ( - MorControl &= ~MOR_CLEAR_MEMORY_BIT_MASK; - } else { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter)); -+ DEBUG ((DEBUG_ERROR, "[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter)); - return EFI_SUCCESS; - } - -@@ -227,7 +227,7 @@ MemoryClearCallback ( - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status)); - } - - return EFI_SUCCESS; -@@ -285,7 +285,7 @@ InitializeTcgCommon ( - EFI_HANDLE NotifyHandle; - - if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm20DtpmGuid)){ -- DEBUG ((EFI_D_ERROR, "No TPM2 DTPM instance required!\n")); -+ DEBUG ((DEBUG_ERROR, "No TPM2 DTPM instance required!\n")); - return EFI_UNSUPPORTED; - } - -@@ -372,4 +372,3 @@ Cleanup: - - return Status; - } -- -diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c -index 8210548077..4bc6086454 100644 ---- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c -+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c -@@ -33,13 +33,13 @@ TcgConfigDriverEntryPoint ( - EFI_TCG_PROTOCOL *TcgProtocol; - - if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ -- DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n")); -+ DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n")); - return EFI_UNSUPPORTED; - } - - Status = Tpm12RequestUseTpm (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "TPM not detected!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM not detected!\n")); - return Status; - } - -diff --git a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c -index 3990d1e937..7019c666b1 100644 ---- a/SecurityPkg/Tcg/TcgDxe/TcgDxe.c -+++ b/SecurityPkg/Tcg/TcgDxe/TcgDxe.c -@@ -588,7 +588,7 @@ TcgDxeHashLogExtendEventI ( - - Done: - if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_TIMEOUT)) { -- DEBUG ((EFI_D_ERROR, "TcgDxeHashLogExtendEventI - %r. Disable TPM.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "TcgDxeHashLogExtendEventI - %r. Disable TPM.\n", Status)); - TcgData->BsCap.TPMPresentFlag = FALSE; - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -1127,7 +1127,7 @@ OnReadyToBoot ( - // - Status = MeasureHandoffTables (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "HOBs not Measured. Error!\n")); -+ DEBUG ((DEBUG_ERROR, "HOBs not Measured. Error!\n")); - } - - // -@@ -1135,7 +1135,7 @@ OnReadyToBoot ( - // - Status = MeasureAllBootVariables (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Boot Variables not Measured. Error!\n")); -+ DEBUG ((DEBUG_ERROR, "Boot Variables not Measured. Error!\n")); - } - - // -@@ -1145,7 +1145,7 @@ OnReadyToBoot ( - EFI_CALLING_EFI_APPLICATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_CALLING_EFI_APPLICATION)); - } - - // -@@ -1177,11 +1177,11 @@ OnReadyToBoot ( - EFI_RETURNING_FROM_EFI_APPLICATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_RETURNING_FROM_EFI_APPLICATION)); - } - } - -- DEBUG ((EFI_D_INFO, "TPM TcgDxe Measure Data when ReadyToBoot\n")); -+ DEBUG ((DEBUG_INFO, "TPM TcgDxe Measure Data when ReadyToBoot\n")); - // - // Increase boot attempt counter. - // -@@ -1260,7 +1260,7 @@ InstallAcpiTable ( - } - - if (EFI_ERROR (Status)) { -- DEBUG((EFI_D_ERROR, "Tcg Acpi Table installation failure")); -+ DEBUG((DEBUG_ERROR, "Tcg Acpi Table installation failure")); - } - } - -@@ -1289,7 +1289,7 @@ OnExitBootServices ( - EFI_EXIT_BOOT_SERVICES_INVOCATION - ); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_INVOCATION)); - } - - // -@@ -1299,7 +1299,7 @@ OnExitBootServices ( - EFI_EXIT_BOOT_SERVICES_SUCCEEDED - ); - if (EFI_ERROR (Status)){ -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_SUCCEEDED)); - } - } - -@@ -1328,7 +1328,7 @@ OnExitBootServicesFailed ( - EFI_EXIT_BOOT_SERVICES_FAILED - ); - if (EFI_ERROR (Status)){ -- DEBUG ((EFI_D_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED)); -+ DEBUG ((DEBUG_ERROR, "%a not Measured. Error!\n", EFI_EXIT_BOOT_SERVICES_FAILED)); - } - } - -@@ -1381,25 +1381,25 @@ DriverEntry ( - VOID *Registration; - - if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ -- DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n")); -+ DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n")); - return EFI_UNSUPPORTED; - } - - if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) { -- DEBUG ((EFI_D_ERROR, "TPM error!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM error!\n")); - return EFI_DEVICE_ERROR; - } - - Status = Tpm12RequestUseTpm (); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "TPM not detected!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM not detected!\n")); - return Status; - } - - Status = GetTpmStatus (&mTcgDxeData.BsCap.TPMDeactivatedFlag); - if (EFI_ERROR (Status)) { - DEBUG (( -- EFI_D_ERROR, -+ DEBUG_ERROR, - "DriverEntry: TPM not working properly\n" - )); - return Status; -diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPei.c -index db33daed37..536bd5a408 100644 ---- a/SecurityPkg/Tcg/TcgPei/TcgPei.c -+++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c -@@ -351,7 +351,7 @@ HashLogExtendEvent ( - - Done: - if ((Status == EFI_DEVICE_ERROR) || (Status == EFI_TIMEOUT)) { -- DEBUG ((EFI_D_ERROR, "HashLogExtendEvent - %r. Disable TPM.\n", Status)); -+ DEBUG ((DEBUG_ERROR, "HashLogExtendEvent - %r. Disable TPM.\n", Status)); - BuildGuidHob (&gTpmErrorHobGuid,0); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -@@ -844,12 +844,12 @@ PeimEntryMA ( - EFI_BOOT_MODE BootMode; - - if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ -- DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n")); -+ DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n")); - return EFI_UNSUPPORTED; - } - - if (GetFirstGuidHob (&gTpmErrorHobGuid) != NULL) { -- DEBUG ((EFI_D_ERROR, "TPM error!\n")); -+ DEBUG ((DEBUG_ERROR, "TPM error!\n")); - return EFI_DEVICE_ERROR; - } - -@@ -913,7 +913,7 @@ PeimEntryMA ( - - Done: - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "TPM error! Build Hob\n")); -+ DEBUG ((DEBUG_ERROR, "TPM error! Build Hob\n")); - BuildGuidHob (&gTpmErrorHobGuid,0); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, -diff --git a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c -index a60efc7d69..25f443c04f 100644 ---- a/SecurityPkg/Tcg/TcgSmm/TcgSmm.c -+++ b/SecurityPkg/Tcg/TcgSmm/TcgSmm.c -@@ -62,13 +62,13 @@ PhysicalPresenceCallback ( - &PpData - ); - -- DEBUG ((EFI_D_INFO, "[TPM] PP callback, Parameter = %x\n", mTcgNvs->PhysicalPresence.Parameter)); -+ DEBUG ((DEBUG_INFO, "[TPM] PP callback, Parameter = %x\n", mTcgNvs->PhysicalPresence.Parameter)); - if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_RETURN_REQUEST_RESPONSE_TO_OS) { - if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_FAILURE; - mTcgNvs->PhysicalPresence.LastRequest = 0; - mTcgNvs->PhysicalPresence.Response = 0; -- DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - mTcgNvs->PhysicalPresence.ReturnCode = PP_RETURN_TPM_OPERATION_RESPONSE_SUCCESS; -@@ -78,7 +78,7 @@ PhysicalPresenceCallback ( - || (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_SUBMIT_REQUEST_TO_BIOS_2)) { - if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - if (mTcgNvs->PhysicalPresence.Request == PHYSICAL_PRESENCE_SET_OPERATOR_AUTH) { -@@ -124,7 +124,7 @@ PhysicalPresenceCallback ( - } else if (mTcgNvs->PhysicalPresence.Parameter == ACPI_FUNCTION_GET_USER_CONFIRMATION_STATUS_FOR_REQUEST) { - if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION; -- DEBUG ((EFI_D_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - // -@@ -140,7 +140,7 @@ PhysicalPresenceCallback ( - ); - if (EFI_ERROR (Status)) { - mTcgNvs->PhysicalPresence.ReturnCode = TCG_PP_GET_USER_CONFIRMATION_BLOCKED_BY_BIOS_CONFIGURATION; -- DEBUG ((EFI_D_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP flags failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - -@@ -257,7 +257,7 @@ MemoryClearCallback ( - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Get MOR variable failure! Status = %r\n", Status)); - return EFI_SUCCESS; - } - -@@ -267,7 +267,7 @@ MemoryClearCallback ( - MorControl &= ~MOR_CLEAR_MEMORY_BIT_MASK; - } else { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter)); -+ DEBUG ((DEBUG_ERROR, "[TPM] MOR Parameter error! Parameter = %x\n", mTcgNvs->MemoryClear.Parameter)); - return EFI_SUCCESS; - } - -@@ -281,7 +281,7 @@ MemoryClearCallback ( - ); - if (EFI_ERROR (Status)) { - mTcgNvs->MemoryClear.ReturnCode = MOR_REQUEST_GENERAL_FAILURE; -- DEBUG ((EFI_D_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status)); -+ DEBUG ((DEBUG_ERROR, "[TPM] Set MOR variable failure! Status = %r\n", Status)); - } - - return EFI_SUCCESS; -@@ -424,7 +424,7 @@ InitializeTcgSmm ( - EFI_HANDLE SwHandle; - - if (!CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)){ -- DEBUG ((EFI_D_ERROR, "No TPM12 instance required!\n")); -+ DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n")); - return EFI_UNSUPPORTED; - } - -@@ -460,4 +460,3 @@ InitializeTcgSmm ( - - return EFI_SUCCESS; - } -- -diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c -index 65a8188d6d..c19f9e7b90 100644 ---- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c -+++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c -@@ -458,7 +458,7 @@ EnrollPlatformKey ( - DataSize = PkCert->SignatureListSize; - Status = CreateTimeBasedPayload (&DataSize, (UINT8**) &PkCert); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - -@@ -471,7 +471,7 @@ EnrollPlatformKey ( - ); - if (EFI_ERROR (Status)) { - if (Status == EFI_OUT_OF_RESOURCES) { -- DEBUG ((EFI_D_ERROR, "Enroll PK failed with out of resource.\n")); -+ DEBUG ((DEBUG_ERROR, "Enroll PK failed with out of resource.\n")); - } - goto ON_EXIT; - } -@@ -600,7 +600,7 @@ EnrollRsa2048ToKek ( - | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; - Status = CreateTimeBasedPayload (&KekSigListSize, (UINT8**) &KekSigList); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - -@@ -724,7 +724,7 @@ EnrollX509ToKek ( - | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; - Status = CreateTimeBasedPayload (&KekSigListSize, (UINT8**) &KekSigList); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - -@@ -897,7 +897,7 @@ EnrollX509toSigDB ( - | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; - Status = CreateTimeBasedPayload (&SigDBSize, (UINT8**) &Data); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - -@@ -2243,7 +2243,7 @@ EnrollImageSignatureToSigDB ( - | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS; - Status = CreateTimeBasedPayload (&SigDBSize, (UINT8**) &Data); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - -@@ -2700,7 +2700,7 @@ DeleteKeyExchangeKey ( - if ((Attr & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) { - Status = CreateTimeBasedPayload (&DataSize, &OldData); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - } -@@ -2901,7 +2901,7 @@ DeleteSignature ( - if ((Attr & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) { - Status = CreateTimeBasedPayload (&DataSize, &OldData); - if (EFI_ERROR (Status)) { -- DEBUG ((EFI_D_ERROR, "Fail to create time-based data payload: %r", Status)); -+ DEBUG ((DEBUG_ERROR, "Fail to create time-based data payload: %r", Status)); - goto ON_EXIT; - } - } --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeImageVerificationLib-Check-result-of-.patch b/SOURCES/edk2-SecurityPkg-DxeImageVerificationLib-Check-result-of-.patch deleted file mode 100644 index e2d7ed3..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeImageVerificationLib-Check-result-of-.patch +++ /dev/null @@ -1,109 +0,0 @@ -From bb0f29580825e60a5dc5c67e260dd20258eb71b0 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 29 Mar 2023 11:52:52 -0400 -Subject: [PATCH] SecurityPkg/DxeImageVerificationLib: Check result of - GetEfiGlobalVariable2 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -RH-Author: Jon Maloy -RH-MergeRequest: 22: SecurityPkg/DxeImageVerificationLib: Check result of GetEfiGlobalVariable2 -RH-Bugzilla: 1861743 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [1/1] 70e1ae5e2c7c148fc23160acdd360c044df5f4ff - -Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1861743 -Upstream: Merged -CVE: CVE-2019-14560 - -commit 494127613b36e870250649b02cd4ce5f1969d9bd -Author: Gerd Hoffmann -Date: Fri Mar 3 18:35:53 2023 +0800 - - SecurityPkg/DxeImageVerificationLib: Check result of GetEfiGlobalVariable2 - - Call gRT->GetVariable() directly to read the SecureBoot variable. It is - one byte in size so we can easily place it on the stack instead of - having GetEfiGlobalVariable2() allocate it for us, which avoids a few - possible error cases. - - Skip secure boot checks if (and only if): - - (a) the SecureBoot variable is not present (EFI_NOT_FOUND) according to - the return value, or - (b) the SecureBoot variable was read successfully and is set to - SECURE_BOOT_MODE_DISABLE. - - Previously the code skipped the secure boot checks on *any* - gRT->GetVariable() error (GetEfiGlobalVariable2 sets the variable - value to NULL in that case) and also on memory allocation failures. - - Fixes: CVE-2019-14560 - Signed-off-by: Gerd Hoffmann - Suggested-by: Marvin Häuser - Reviewed-by: Min Xu - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeImageVerificationLib.c | 18 ++++++++++++------ - 1 file changed, 12 insertions(+), 6 deletions(-) - -diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -index c48861cd64..1252927664 100644 ---- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c -@@ -1650,7 +1650,8 @@ DxeImageVerificationHandler ( - EFI_IMAGE_EXECUTION_ACTION Action; - WIN_CERTIFICATE *WinCertificate; - UINT32 Policy; -- UINT8 *SecureBoot; -+ UINT8 SecureBoot; -+ UINTN SecureBootSize; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - UINT32 NumberOfRvaAndSizes; - WIN_CERTIFICATE_EFI_PKCS *PkcsCertData; -@@ -1665,6 +1666,8 @@ DxeImageVerificationHandler ( - RETURN_STATUS PeCoffStatus; - EFI_STATUS HashStatus; - EFI_STATUS DbStatus; -+ EFI_STATUS VarStatus; -+ UINT32 VarAttr; - BOOLEAN IsFound; - - SignatureList = NULL; -@@ -1720,22 +1723,25 @@ DxeImageVerificationHandler ( - CpuDeadLoop (); - } - -- GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID**)&SecureBoot, NULL); -+ SecureBootSize = sizeof (SecureBoot); -+ VarStatus = gRT->GetVariable (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, &VarAttr, &SecureBootSize, &SecureBoot); - // - // Skip verification if SecureBoot variable doesn't exist. - // -- if (SecureBoot == NULL) { -+ if (VarStatus == EFI_NOT_FOUND) { - return EFI_SUCCESS; - } - - // - // Skip verification if SecureBoot is disabled but not AuditMode - // -- if (*SecureBoot == SECURE_BOOT_MODE_DISABLE) { -- FreePool (SecureBoot); -+ if ((VarStatus == EFI_SUCCESS) && -+ (VarAttr == (EFI_VARIABLE_BOOTSERVICE_ACCESS | -+ EFI_VARIABLE_RUNTIME_ACCESS)) && -+ (SecureBoot == SECURE_BOOT_MODE_DISABLE)) -+ { - return EFI_SUCCESS; - } -- FreePool (SecureBoot); - - // - // Read the Dos header. --- -2.39.1 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SEC-PATCH-4118-2.patch b/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SEC-PATCH-4118-2.patch deleted file mode 100644 index 464b257..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SEC-PATCH-4118-2.patch +++ /dev/null @@ -1,272 +0,0 @@ -From 7b5040e857f1a16bed935f7944bda8bc6f6999ac Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 13 Feb 2024 16:30:10 -0500 -Subject: [PATCH 11/17] SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH - 4117/4118 symbol rename - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [11/13] 45fc2658aaa726b57219789bb1af64f5c4e2cfdc (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21156 -CVE: CVE-2022-36764 -Upstream: Merged - -commit 40adbb7f628dee79156c679fb0857968b61b7620 -Author: Doug Flick -Date: Wed Jan 17 14:47:20 2024 -0800 - - SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117/4118 symbol rename - - Updates the sanitation function names to be lib unique names - - Cc: Jiewen Yao - Cc: Rahul Kumar - - Signed-off-by: Doug Flick [MSFT] - Message-Id: <7b18434c8a8b561654efd40ced3becb8b378c8f1.1705529990.git.doug.edk2@gmail.com> - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeTpm2MeasureBootLib.c | 8 +++--- - .../DxeTpm2MeasureBootLibSanitization.c | 8 +++--- - .../DxeTpm2MeasureBootLibSanitization.h | 8 +++--- - .../DxeTpm2MeasureBootLibSanitizationTest.c | 26 +++++++++---------- - 4 files changed, 25 insertions(+), 25 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index f06926e631..8f8bef1d0b 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -197,7 +197,7 @@ Tcg2MeasureGptTable ( - BlockIo->Media->BlockSize, - (UINT8 *)PrimaryHeader - ); -- if (EFI_ERROR (Status) || EFI_ERROR (SanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { -+ if (EFI_ERROR (Status) || EFI_ERROR (Tpm2SanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { - DEBUG ((DEBUG_ERROR, "Failed to read Partition Table Header or invalid Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; -@@ -206,7 +206,7 @@ Tcg2MeasureGptTable ( - // - // Read the partition entry. - // -- Status = SanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); -+ Status = Tpm2SanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); - if (EFI_ERROR (Status)) { - FreePool (PrimaryHeader); - return EFI_BAD_BUFFER_SIZE; -@@ -245,7 +245,7 @@ Tcg2MeasureGptTable ( - // - // Prepare Data for Measurement (CcProtocol and Tcg2Protocol) - // -- Status = SanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &TcgEventSize); -+ Status = Tpm2SanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &TcgEventSize); - if (EFI_ERROR (Status)) { - FreePool (PrimaryHeader); - FreePool (EntryPtr); -@@ -414,7 +414,7 @@ Tcg2MeasurePeImage ( - } - - FilePathSize = (UINT32)GetDevicePathSize (FilePath); -- Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ Status = Tpm2SanitizePeImageEventSize (FilePathSize, &EventSize); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -index 2a4d52c6d5..809a3bfd89 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -@@ -63,7 +63,7 @@ - **/ - EFI_STATUS - EFIAPI --SanitizeEfiPartitionTableHeader ( -+Tpm2SanitizeEfiPartitionTableHeader ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo - ) -@@ -169,7 +169,7 @@ SanitizeEfiPartitionTableHeader ( - **/ - EFI_STATUS - EFIAPI --SanitizePrimaryHeaderAllocationSize ( -+Tpm2SanitizePrimaryHeaderAllocationSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - OUT UINT32 *AllocationSize - ) -@@ -221,7 +221,7 @@ SanitizePrimaryHeaderAllocationSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePrimaryHeaderGptEventSize ( -+Tpm2SanitizePrimaryHeaderGptEventSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN UINTN NumberOfPartition, - OUT UINT32 *EventSize -@@ -292,7 +292,7 @@ SanitizePrimaryHeaderGptEventSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePeImageEventSize ( -+Tpm2SanitizePeImageEventSize ( - IN UINT32 FilePathSize, - OUT UINT32 *EventSize - ) -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -index 8f72ba4240..8526bc7537 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -@@ -54,7 +54,7 @@ - **/ - EFI_STATUS - EFIAPI --SanitizeEfiPartitionTableHeader ( -+Tpm2SanitizeEfiPartitionTableHeader ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo - ); -@@ -78,7 +78,7 @@ SanitizeEfiPartitionTableHeader ( - **/ - EFI_STATUS - EFIAPI --SanitizePrimaryHeaderAllocationSize ( -+Tpm2SanitizePrimaryHeaderAllocationSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - OUT UINT32 *AllocationSize - ); -@@ -107,7 +107,7 @@ SanitizePrimaryHeaderAllocationSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePrimaryHeaderGptEventSize ( -+Tpm2SanitizePrimaryHeaderGptEventSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN UINTN NumberOfPartition, - OUT UINT32 *EventSize -@@ -131,7 +131,7 @@ SanitizePrimaryHeaderGptEventSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePeImageEventSize ( -+Tpm2SanitizePeImageEventSize ( - IN UINT32 FilePathSize, - OUT UINT32 *EventSize - ); -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -index 820e99aeb9..50a68e1076 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -@@ -84,27 +84,27 @@ TestSanitizeEfiPartitionTableHeader ( - PrimaryHeader.Header.CRC32 = CalculateCrc32 ((UINT8 *)&PrimaryHeader, PrimaryHeader.Header.HeaderSize); - - // Test that a normal PrimaryHeader passes validation -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = Tpm2SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Test that when number of partition entries is 0, the function returns EFI_DEVICE_ERROR - // Should print "Invalid Partition Table Header NumberOfPartitionEntries!"" - PrimaryHeader.NumberOfPartitionEntries = 0; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = Tpm2SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; - - // Test that when the header size is too small, the function returns EFI_DEVICE_ERROR - // Should print "Invalid Partition Table Header Size!" - PrimaryHeader.Header.HeaderSize = 0; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = Tpm2SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); - - // Test that when the SizeOfPartitionEntry is too small, the function returns EFI_DEVICE_ERROR - // should print: "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!" - PrimaryHeader.SizeOfPartitionEntry = 1; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = Tpm2SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -137,7 +137,7 @@ TestSanitizePrimaryHeaderAllocationSize ( - PrimaryHeader.NumberOfPartitionEntries = 5; - PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; - -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = Tpm2SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Test that the allocation size is correct compared to the existing logic -@@ -146,19 +146,19 @@ TestSanitizePrimaryHeaderAllocationSize ( - // Test that an overflow is detected - PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; - PrimaryHeader.SizeOfPartitionEntry = 5; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = Tpm2SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test the inverse - PrimaryHeader.NumberOfPartitionEntries = 5; - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = Tpm2SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test the worst case scenario - PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = Tpm2SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -196,7 +196,7 @@ TestSanitizePrimaryHeaderGptEventSize ( - NumberOfPartition = 13; - - // that the primary event size is correct -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ Status = Tpm2SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Calculate the existing logic event size -@@ -207,12 +207,12 @@ TestSanitizePrimaryHeaderGptEventSize ( - UT_ASSERT_EQUAL (EventSize, ExistingLogicEventSize); - - // Tests that the primary event size may not overflow -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); -+ Status = Tpm2SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test that the size of partition entries may not overflow - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ Status = Tpm2SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -245,7 +245,7 @@ TestSanitizePeImageEventSize ( - FilePathSize = 255; - - // Test that a normal PE image passes validation -- Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ Status = Tpm2SanitizePeImageEventSize (FilePathSize, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_SUCCESS); - - // Test that the event size is correct compared to the existing logic -@@ -258,7 +258,7 @@ TestSanitizePeImageEventSize ( - } - - // Test that the event size may not overflow -- Status = SanitizePeImageEventSize (MAX_UINT32, &EventSize); -+ Status = Tpm2SanitizePeImageEventSize (MAX_UINT32, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-411.patch b/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-411.patch deleted file mode 100644 index 372ad1f..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-411.patch +++ /dev/null @@ -1,1066 +0,0 @@ -From dd30c6c8f2a47b46d514eb413c8c96aedc951297 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 17 Jan 2024 12:20:52 -0500 -Subject: [PATCH 06/17] SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117 - - CVE 2022-36763 - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [6/13] d8e42e23d4215506de05ed540644545a4dd65f44 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged -Conflicts: Only cosmetic conflicts. - -commit 224446543206450ddb5830e6abd026d61d3c7f4b -Author: Douglas Flick [MSFT] -Date: Fri Jan 12 02:16:01 2024 +0800 - - SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117 - CVE 2022-36763 - - This commit contains the patch files and tests for DxeTpm2MeasureBootLib - CVE 2022-36763. - - Cc: Jiewen Yao - - Signed-off-by: Doug Flick [MSFT] - -Signed-off-by: Jon Maloy ---- - .../DxeTpm2MeasureBootLib.c | 81 ++--- - .../DxeTpm2MeasureBootLib.inf | 4 +- - .../DxeTpm2MeasureBootLibSanitization.c | 275 ++++++++++++++++ - .../DxeTpm2MeasureBootLibSanitization.h | 113 +++++++ - .../DxeTpm2MeasureBootLibSanitizationTest.c | 303 ++++++++++++++++++ - ...Tpm2MeasureBootLibSanitizationTestHost.inf | 28 ++ - SecurityPkg/SecurityPkg.ci.yaml | 2 + - SecurityPkg/Test/SecurityPkgHostTest.dsc | 47 +++ - 8 files changed, 815 insertions(+), 38 deletions(-) - create mode 100644 SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c - create mode 100644 SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h - create mode 100644 SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c - create mode 100644 SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf - create mode 100644 SecurityPkg/Test/SecurityPkgHostTest.dsc - -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index 7abacdbc0a..476c8d543f 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -20,6 +20,8 @@ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- SPDX-License-Identifier: BSD-2-Clause-Patent - -+Copyright (c) Microsoft Corporation.
-+SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - - #include -@@ -44,6 +46,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - -+#include "DxeTpm2MeasureBootLibSanitization.h" -+ - typedef struct { - EFI_TCG2_PROTOCOL *Tcg2Protocol; - EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; -@@ -144,10 +148,11 @@ Tcg2MeasureGptTable ( - EFI_TCG2_EVENT *Tcg2Event; - EFI_CC_EVENT *CcEvent; - EFI_GPT_DATA *GptData; -- UINT32 EventSize; -+ UINT32 TcgEventSize; - EFI_TCG2_PROTOCOL *Tcg2Protocol; - EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; - EFI_CC_MR_INDEX MrIndex; -+ UINT32 AllocSize; - - if (mTcg2MeasureGptCount > 0) { - return EFI_SUCCESS; -@@ -192,25 +197,22 @@ Tcg2MeasureGptTable ( - BlockIo->Media->BlockSize, - (UINT8 *)PrimaryHeader - ); -- if (EFI_ERROR (Status)) { -- DEBUG ((DEBUG_ERROR, "Failed to Read Partition Table Header!\n")); -+ if (EFI_ERROR (Status) || EFI_ERROR (SanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { -+ DEBUG ((DEBUG_ERROR, "Failed to read Partition Table Header or invalid Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; - } - - // -- // PrimaryHeader->SizeOfPartitionEntry should not be zero -+ // Read the partition entry. - // -- if (PrimaryHeader->SizeOfPartitionEntry == 0) { -- DEBUG ((DEBUG_ERROR, "SizeOfPartitionEntry should not be zero!\n")); -+ Status = SanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); -+ if (EFI_ERROR (Status)) { - FreePool (PrimaryHeader); - return EFI_BAD_BUFFER_SIZE; - } - -- // -- // Read the partition entry. -- // -- EntryPtr = (UINT8 *)AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry); -+ EntryPtr = (UINT8 *)AllocatePool (AllocSize); - if (EntryPtr == NULL) { - FreePool (PrimaryHeader); - return EFI_OUT_OF_RESOURCES; -@@ -218,8 +220,8 @@ Tcg2MeasureGptTable ( - Status = DiskIo->ReadDisk ( - DiskIo, - BlockIo->Media->MediaId, -- MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize), -- PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry, -+ MultU64x32 (PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize), -+ AllocSize, - EntryPtr - ); - if (EFI_ERROR (Status)) { -@@ -243,23 +245,22 @@ Tcg2MeasureGptTable ( - // - // Prepare Data for Measurement (CcProtocol and Tcg2Protocol) - // -- EventSize = (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions) -- + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry); -- EventPtr = (UINT8 *)AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)); -+ Status = SanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &TcgEventSize); -+ if (EFI_ERROR (Status)) { -+ FreePool (PrimaryHeader); -+ FreePool (EntryPtr); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ EventPtr = (UINT8 *)AllocateZeroPool (TcgEventSize); - if (EventPtr == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Exit; - } - - Tcg2Event = (EFI_TCG2_EVENT *)EventPtr; -- if (Tcg2Event == NULL) { -- FreePool (PrimaryHeader); -- FreePool (EntryPtr); -- return EFI_OUT_OF_RESOURCES; -- } -- -- Tcg2Event->Size = EventSize + sizeof (EFI_TCG2_EVENT) - sizeof(Tcg2Event->Event); -- Tcg2Event->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER); -+ Tcg2Event->Size = TcgEventSize; -+ Tcg2Event->Header.HeaderSize = sizeof (EFI_TCG2_EVENT_HEADER); - Tcg2Event->Header.HeaderVersion = EFI_TCG2_EVENT_HEADER_VERSION; - Tcg2Event->Header.PCRIndex = 5; - Tcg2Event->Header.EventType = EV_EFI_GPT_EVENT; -@@ -310,7 +311,7 @@ Tcg2MeasureGptTable ( - CcProtocol, - 0, - (EFI_PHYSICAL_ADDRESS)(UINTN)(VOID *)GptData, -- (UINT64)EventSize, -+ (UINT64)TcgEventSize - OFFSET_OF (EFI_TCG2_EVENT, Event), - CcEvent - ); - if (!EFI_ERROR (Status)) { -@@ -326,7 +327,7 @@ Tcg2MeasureGptTable ( - Tcg2Protocol, - 0, - (EFI_PHYSICAL_ADDRESS)(UINTN)(VOID *)GptData, -- (UINT64)EventSize, -+ (UINT64)TcgEventSize - OFFSET_OF (EFI_TCG2_EVENT, Event), - Tcg2Event - ); - if (!EFI_ERROR (Status)) { -@@ -442,11 +443,13 @@ Tcg2MeasurePeImage ( - Tcg2Event->Header.PCRIndex = 2; - break; - default: -- DEBUG (( -- DEBUG_ERROR, -- "Tcg2MeasurePeImage: Unknown subsystem type %d", -- ImageType -- )); -+ DEBUG ( -+ ( -+ DEBUG_ERROR, -+ "Tcg2MeasurePeImage: Unknown subsystem type %d", -+ ImageType -+ ) -+ ); - goto Finish; - } - -@@ -514,7 +517,7 @@ Finish: - - @param MeasureBootProtocols Pointer to the located measure boot protocol instances. - -- @retval EFI_SUCCESS Sucessfully locate the measure boot protocol instances (at least one instance). -+ @retval EFI_SUCCESS Successfully locate the measure boot protocol instances (at least one instance). - @retval EFI_UNSUPPORTED Measure boot is not supported. - **/ - EFI_STATUS -@@ -644,12 +647,16 @@ DxeTpm2MeasureBootHandler ( - DEBUG ((DEBUG_INFO, "None of Tcg2Protocol/CcMeasurementProtocol is installed.\n")); - return EFI_SUCCESS; - } -- DEBUG (( -- DEBUG_INFO, -- "Tcg2Protocol = %p, CcMeasurementProtocol = %p\n", -- MeasureBootProtocols.Tcg2Protocol, -- MeasureBootProtocols.CcProtocol -- )); -+ -+ DEBUG ( -+ ( -+ DEBUG_INFO, -+ "Tcg2Protocol = %p, CcMeasurementProtocol = %p\n", -+ MeasureBootProtocols.Tcg2Protocol, -+ MeasureBootProtocols.CcProtocol -+ ) -+ ); -+ - // - // Copy File Device Path - // -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -index 6dca79a20c..28995f438d 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -@@ -37,6 +37,8 @@ - - [Sources] - DxeTpm2MeasureBootLib.c -+ DxeTpm2MeasureBootLibSanitization.c -+ DxeTpm2MeasureBootLibSanitization.h - - [Packages] - MdePkg/MdePkg.dec -@@ -46,6 +48,7 @@ - - [LibraryClasses] - BaseMemoryLib -+ SafeIntLib - DebugLib - MemoryAllocationLib - DevicePathLib -@@ -65,4 +68,3 @@ - gEfiFirmwareVolumeBlockProtocolGuid ## SOMETIMES_CONSUMES - gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES - gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES -- -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -new file mode 100644 -index 0000000000..e2309655d3 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -@@ -0,0 +1,275 @@ -+/** @file -+ The library instance provides security service of TPM2 measure boot and -+ Confidential Computing (CC) measure boot. -+ -+ Caution: This file requires additional review when modified. -+ This library will have external input - PE/COFF image and GPT partition. -+ This external input must be validated carefully to avoid security issue like -+ buffer overflow, integer overflow. -+ -+ This file will pull out the validation logic from the following functions, in an -+ attempt to validate the untrusted input in the form of unit tests -+ -+ These are those functions: -+ -+ DxeTpm2MeasureBootLibImageRead() function will make sure the PE/COFF image content -+ read is within the image buffer. -+ -+ Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse -+ partition data carefully. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "DxeTpm2MeasureBootLibSanitization.h" -+ -+#define GPT_HEADER_REVISION_V1 0x00010000 -+ -+/** -+ This function will validate the EFI_PARTITION_TABLE_HEADER structure is safe to parse -+ However this function will not attempt to verify the validity of the GPT partition -+ It will check the following: -+ - Signature -+ - Revision -+ - AlternateLBA -+ - FirstUsableLBA -+ - LastUsableLBA -+ - PartitionEntryLBA -+ - NumberOfPartitionEntries -+ - SizeOfPartitionEntry -+ - BlockIo -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[in] BlockIo -+ Pointer to the EFI_BLOCK_IO_PROTOCOL structure. -+ -+ @retval EFI_SUCCESS -+ The EFI_PARTITION_TABLE_HEADER structure is valid. -+ -+ @retval EFI_INVALID_PARAMETER -+ The EFI_PARTITION_TABLE_HEADER structure is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizeEfiPartitionTableHeader ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo -+ ) -+{ -+ // -+ // Verify that the input parameters are safe to use -+ // -+ if (PrimaryHeader == NULL) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((BlockIo == NULL) || (BlockIo->Media == NULL)) { -+ DEBUG ((DEBUG_ERROR, "Invalid BlockIo!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // The signature must be EFI_PTAB_HEADER_ID ("EFI PART" in ASCII) -+ // -+ if (PrimaryHeader->Header.Signature != EFI_PTAB_HEADER_ID) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // The version must be GPT_HEADER_REVISION_V1 (0x00010000) -+ // -+ if (PrimaryHeader->Header.Revision != GPT_HEADER_REVISION_V1) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header Revision!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // The HeaderSize must be greater than or equal to 92 and must be less than or equal to the logical block size -+ // -+ if ((PrimaryHeader->Header.HeaderSize < sizeof (EFI_PARTITION_TABLE_HEADER)) || (PrimaryHeader->Header.HeaderSize > BlockIo->Media->BlockSize)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header HeaderSize!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // The partition entries should all be before the first usable block -+ // -+ if (PrimaryHeader->FirstUsableLBA <= PrimaryHeader->PartitionEntryLBA) { -+ DEBUG ((DEBUG_ERROR, "GPT PartitionEntryLBA is not less than FirstUsableLBA!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // Check that the PartitionEntryLBA greater than the Max LBA -+ // This will be used later for multiplication -+ // -+ if (PrimaryHeader->PartitionEntryLBA > DivU64x32 (MAX_UINT64, BlockIo->Media->BlockSize)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header PartitionEntryLBA!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // Check that the number of partition entries is greater than zero -+ // -+ if (PrimaryHeader->NumberOfPartitionEntries == 0) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header NumberOfPartitionEntries!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // SizeOfPartitionEntry must be 128, 256, 512... improper size may lead to accessing uninitialized memory -+ // -+ if ((PrimaryHeader->SizeOfPartitionEntry < 128) || ((PrimaryHeader->SizeOfPartitionEntry & (PrimaryHeader->SizeOfPartitionEntry - 1)) != 0)) { -+ DEBUG ((DEBUG_ERROR, "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // -+ // This check is to prevent overflow when calculating the allocation size for the partition entries -+ // This check will be used later for multiplication -+ // -+ if (PrimaryHeader->NumberOfPartitionEntries > DivU64x32 (MAX_UINT64, PrimaryHeader->SizeOfPartitionEntry)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header NumberOfPartitionEntries!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ This function will validate that the allocation size from the primary header is sane -+ It will check the following: -+ - AllocationSize does not overflow -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[out] AllocationSize -+ Pointer to the allocation size. -+ -+ @retval EFI_SUCCESS -+ The allocation size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ The allocation size is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizePrimaryHeaderAllocationSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ OUT UINT32 *AllocationSize -+ ) -+{ -+ EFI_STATUS Status; -+ -+ if (PrimaryHeader == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (AllocationSize == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Replacing logic: -+ // PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry; -+ // -+ Status = SafeUint32Mult (PrimaryHeader->NumberOfPartitionEntries, PrimaryHeader->SizeOfPartitionEntry, AllocationSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Allocation Size would have overflowed!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ This function will validate that the Gpt Event Size calculated from the primary header is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ Important: This function includes the entire length of the allocated space, including -+ (sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)) . When hashing the buffer allocated with this -+ size, the caller must subtract the size of the (sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)) -+ from the size of the buffer before hashing. -+ -+ @param[in] PrimaryHeader - Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ @param[in] NumberOfPartition - Number of partitions. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePrimaryHeaderGptEventSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN UINTN NumberOfPartition, -+ OUT UINT32 *EventSize -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 SafeNumberOfPartitions; -+ -+ if (PrimaryHeader == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (EventSize == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // We shouldn't even attempt to perform the multiplication if the number of partitions is greater than the maximum value of UINT32 -+ // -+ Status = SafeUintnToUint32 (NumberOfPartition, &SafeNumberOfPartitions); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NumberOfPartition would have overflowed!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // -+ // Replacing logic: -+ // (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions) + NumberOfPartition * PrimaryHeader.SizeOfPartitionEntry); -+ // -+ Status = SafeUint32Mult (SafeNumberOfPartitions, PrimaryHeader->SizeOfPartitionEntry, EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Event Size would have overflowed!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // -+ // Replacing logic: -+ // *EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event); -+ // -+ Status = SafeUint32Add ( -+ OFFSET_OF (EFI_TCG2_EVENT, Event) + OFFSET_OF (EFI_GPT_DATA, Partitions), -+ *EventSize, -+ EventSize -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Event Size would have overflowed because of GPTData!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -new file mode 100644 -index 0000000000..048b738987 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -@@ -0,0 +1,113 @@ -+/** @file -+ This file includes the function prototypes for the sanitization functions. -+ -+ These are those functions: -+ -+ DxeTpm2MeasureBootLibImageRead() function will make sure the PE/COFF image content -+ read is within the image buffer. -+ -+ Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse -+ partition data carefully. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#ifndef DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_ -+#define DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_ -+ -+#include -+#include -+#include -+#include -+#include -+ -+/** -+ This function will validate the EFI_PARTITION_TABLE_HEADER structure is safe to parse -+ However this function will not attempt to verify the validity of the GPT partition -+ It will check the following: -+ - Signature -+ - Revision -+ - AlternateLBA -+ - FirstUsableLBA -+ - LastUsableLBA -+ - PartitionEntryLBA -+ - NumberOfPartitionEntries -+ - SizeOfPartitionEntry -+ - BlockIo -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[in] BlockIo -+ Pointer to the EFI_BLOCK_IO_PROTOCOL structure. -+ -+ @retval EFI_SUCCESS -+ The EFI_PARTITION_TABLE_HEADER structure is valid. -+ -+ @retval EFI_INVALID_PARAMETER -+ The EFI_PARTITION_TABLE_HEADER structure is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizeEfiPartitionTableHeader ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo -+ ); -+ -+/** -+ This function will validate that the allocation size from the primary header is sane -+ It will check the following: -+ - AllocationSize does not overflow -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[out] AllocationSize -+ Pointer to the allocation size. -+ -+ @retval EFI_SUCCESS -+ The allocation size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ The allocation size is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizePrimaryHeaderAllocationSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ OUT UINT32 *AllocationSize -+ ); -+ -+/** -+ This function will validate that the Gpt Event Size calculated from the primary header is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ Important: This function includes the entire length of the allocated space, including -+ (sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)) . When hashing the buffer allocated with this -+ size, the caller must subtract the size of the (sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)) -+ from the size of the buffer before hashing. -+ -+ @param[in] PrimaryHeader - Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ @param[in] NumberOfPartition - Number of partitions. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePrimaryHeaderGptEventSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN UINTN NumberOfPartition, -+ OUT UINT32 *EventSize -+ ); -+ -+#endif // DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_ -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -new file mode 100644 -index 0000000000..3eb9763e3c ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -@@ -0,0 +1,303 @@ -+/** @file -+ This file includes the unit test cases for the DxeTpm2MeasureBootLibSanitizationTest.c. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "../DxeTpm2MeasureBootLibSanitization.h" -+ -+#define UNIT_TEST_NAME "DxeTpm2MeasureBootLibSanitizationTest" -+#define UNIT_TEST_VERSION "1.0" -+ -+#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION 0x00010000 -+#define DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES 1 -+#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY 128 -+ -+/** -+ This function tests the SanitizeEfiPartitionTableHeader function. -+ It's intent is to test that a malicious EFI_PARTITION_TABLE_HEADER -+ structure will not cause undefined or unexpected behavior. -+ -+ In general the TPM should still be able to measure the data, but -+ be the header should be sanitized to prevent any unexpected behavior. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizeEfiPartitionTableHeader ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ EFI_BLOCK_IO_PROTOCOL BlockIo; -+ EFI_BLOCK_IO_MEDIA BlockMedia; -+ -+ // Generate EFI_BLOCK_IO_MEDIA test data -+ BlockMedia.MediaId = 1; -+ BlockMedia.RemovableMedia = FALSE; -+ BlockMedia.MediaPresent = TRUE; -+ BlockMedia.LogicalPartition = FALSE; -+ BlockMedia.ReadOnly = FALSE; -+ BlockMedia.WriteCaching = FALSE; -+ BlockMedia.BlockSize = 512; -+ BlockMedia.IoAlign = 1; -+ BlockMedia.LastBlock = 0; -+ -+ // Generate EFI_BLOCK_IO_PROTOCOL test data -+ BlockIo.Revision = 1; -+ BlockIo.Media = &BlockMedia; -+ BlockIo.Reset = NULL; -+ BlockIo.ReadBlocks = NULL; -+ BlockIo.WriteBlocks = NULL; -+ BlockIo.FlushBlocks = NULL; -+ -+ // Geneate EFI_PARTITION_TABLE_HEADER test data -+ PrimaryHeader.Header.Signature = EFI_PTAB_HEADER_ID; -+ PrimaryHeader.Header.Revision = DEFAULT_PRIMARY_TABLE_HEADER_REVISION; -+ PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); -+ PrimaryHeader.MyLBA = 1; -+ PrimaryHeader.AlternateLBA = 2; -+ PrimaryHeader.FirstUsableLBA = 3; -+ PrimaryHeader.LastUsableLBA = 4; -+ PrimaryHeader.PartitionEntryLBA = 5; -+ PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ PrimaryHeader.PartitionEntryArrayCRC32 = 0; // Purposely invalid -+ -+ // Calculate the CRC32 of the PrimaryHeader -+ PrimaryHeader.Header.CRC32 = CalculateCrc32 ((UINT8 *)&PrimaryHeader, PrimaryHeader.Header.HeaderSize); -+ -+ // Test that a normal PrimaryHeader passes validation -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Test that when number of partition entries is 0, the function returns EFI_DEVICE_ERROR -+ // Should print "Invalid Partition Table Header NumberOfPartitionEntries!"" -+ PrimaryHeader.NumberOfPartitionEntries = 0; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ // Test that when the header size is too small, the function returns EFI_DEVICE_ERROR -+ // Should print "Invalid Partition Table Header Size!" -+ PrimaryHeader.Header.HeaderSize = 0; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); -+ -+ // Test that when the SizeOfPartitionEntry is too small, the function returns EFI_DEVICE_ERROR -+ // should print: "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!" -+ PrimaryHeader.SizeOfPartitionEntry = 1; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+/** -+ This function tests the SanitizePrimaryHeaderAllocationSize function. -+ It's intent is to test that the untrusted input from a EFI_PARTITION_TABLE_HEADER -+ structure will not cause an overflow when calculating the allocation size. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePrimaryHeaderAllocationSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 AllocationSize; -+ -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ -+ // Test that a normal PrimaryHeader passes validation -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Test that the allocation size is correct compared to the existing logic -+ UT_ASSERT_EQUAL (AllocationSize, PrimaryHeader.NumberOfPartitionEntries * PrimaryHeader.SizeOfPartitionEntry); -+ -+ // Test that an overflow is detected -+ PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; -+ PrimaryHeader.SizeOfPartitionEntry = 5; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test the inverse -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test the worst case scenario -+ PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+/** -+ This function tests the SanitizePrimaryHeaderGptEventSize function. -+ It's intent is to test that the untrusted input from a EFI_GPT_DATA structure -+ will not cause an overflow when calculating the event size. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePrimaryHeaderGptEventSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 EventSize; -+ UINT32 ExistingLogicEventSize; -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ UINTN NumberOfPartition; -+ EFI_GPT_DATA *GptData; -+ EFI_TCG2_EVENT *Tcg2Event; -+ -+ Tcg2Event = NULL; -+ GptData = NULL; -+ -+ // Test that a normal PrimaryHeader passes validation -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ // set the number of partitions -+ NumberOfPartition = 13; -+ -+ // that the primary event size is correct -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Calculate the existing logic event size -+ ExistingLogicEventSize = (UINT32)(OFFSET_OF (EFI_TCG2_EVENT, Event) + OFFSET_OF (EFI_GPT_DATA, Partitions) -+ + NumberOfPartition * PrimaryHeader.SizeOfPartitionEntry); -+ -+ // Check that the event size is correct -+ UT_ASSERT_EQUAL (EventSize, ExistingLogicEventSize); -+ -+ // Tests that the primary event size may not overflow -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test that the size of partition entries may not overflow -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+// *--------------------------------------------------------------------* -+// * Unit Test Code Main Function -+// *--------------------------------------------------------------------* -+ -+/** -+ This function acts as the entry point for the unit tests. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+ @retval others The test failed. -+**/ -+EFI_STATUS -+EFIAPI -+UefiTestMain ( -+ VOID -+ ) -+{ -+ EFI_STATUS Status; -+ UNIT_TEST_FRAMEWORK_HANDLE Framework; -+ UNIT_TEST_SUITE_HANDLE Tcg2MeasureBootLibValidationTestSuite; -+ -+ Framework = NULL; -+ -+ DEBUG ((DEBUG_INFO, "%a: TestMain() - Start\n", UNIT_TEST_NAME)); -+ -+ Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: Failed in InitUnitTestFramework. Status = %r\n", UNIT_TEST_NAME, Status)); -+ goto EXIT; -+ } -+ -+ Status = CreateUnitTestSuite (&Tcg2MeasureBootLibValidationTestSuite, Framework, "Tcg2MeasureBootLibValidationTestSuite", "Common.Tcg2MeasureBootLibValidation", NULL, NULL); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%s: Failed in CreateUnitTestSuite for Tcg2MeasureBootLibValidationTestSuite\n", UNIT_TEST_NAME)); -+ Status = EFI_OUT_OF_RESOURCES; -+ goto EXIT; -+ } -+ -+ // -----------Suite---------------------------------Description----------------------------Class----------------------------------Test Function------------------------Pre---Clean-Context -+ AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Validating EFI Partition Table", "Common.Tcg2MeasureBootLibValidation", TestSanitizeEfiPartitionTableHeader, NULL, NULL, NULL); -+ AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Primary header gpt event checks for overflow", "Common.Tcg2MeasureBootLibValidation", TestSanitizePrimaryHeaderAllocationSize, NULL, NULL, NULL); -+ AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Primary header allocation size checks for overflow", "Common.Tcg2MeasureBootLibValidation", TestSanitizePrimaryHeaderGptEventSize, NULL, NULL, NULL); -+ -+ Status = RunAllTestSuites (Framework); -+ -+EXIT: -+ if (Framework != NULL) { -+ FreeUnitTestFramework (Framework); -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: TestMain() - End\n", UNIT_TEST_NAME)); -+ return Status; -+} -+ -+/// -+/// Avoid ECC error for function name that starts with lower case letter -+/// -+#define DxeTpm2MeasureBootLibUnitTestMain main -+ -+/** -+ Standard POSIX C entry point for host based unit test execution. -+ -+ @param[in] Argc Number of arguments -+ @param[in] Argv Array of pointers to arguments -+ -+ @retval 0 Success -+ @retval other Error -+**/ -+INT32 -+DxeTpm2MeasureBootLibUnitTestMain ( -+ IN INT32 Argc, -+ IN CHAR8 *Argv[] -+ ) -+{ -+ return (INT32)UefiTestMain (); -+} -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf -new file mode 100644 -index 0000000000..2999aa2a44 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf -@@ -0,0 +1,28 @@ -+## @file -+# This file builds the unit tests for DxeTpm2MeasureBootLib -+# -+# Copyright (C) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+ -+[Defines] -+ INF_VERSION = 0x00010006 -+ BASE_NAME = DxeTpm2MeasuredBootLibTest -+ FILE_GUID = 144d757f-d423-484e-9309-a23695fad5bd -+ MODULE_TYPE = HOST_APPLICATION -+ VERSION_STRING = 1.0 -+ ENTRY_POINT = main -+ -+[Sources] -+ DxeTpm2MeasureBootLibSanitizationTest.c -+ ../DxeTpm2MeasureBootLibSanitization.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ -+[LibraryClasses] -+ BaseLib -+ DebugLib -+ UnitTestLib -+ PrintLib -+ SafeIntLib -diff --git a/SecurityPkg/SecurityPkg.ci.yaml b/SecurityPkg/SecurityPkg.ci.yaml -index d7b9e1f4e2..aa8496d6d9 100644 ---- a/SecurityPkg/SecurityPkg.ci.yaml -+++ b/SecurityPkg/SecurityPkg.ci.yaml -@@ -15,6 +15,8 @@ - ## "", "" - ## ] - "ExceptionList": [ -+ "8005", "gRT", -+ "8001", "DxeTpm2MeasureBootLibUnitTestMain", - ], - ## Both file path and directory path are accepted. - "IgnoreFiles": [ -diff --git a/SecurityPkg/Test/SecurityPkgHostTest.dsc b/SecurityPkg/Test/SecurityPkgHostTest.dsc -new file mode 100644 -index 0000000000..788c1ab6fe ---- /dev/null -+++ b/SecurityPkg/Test/SecurityPkgHostTest.dsc -@@ -0,0 +1,47 @@ -+## @file -+# SecurityPkg DSC file used to build host-based unit tests. -+# -+# Copyright (C) Microsoft Corporation. -+# SPDX-License-Identifier: BSD-2-Clause-Patent -+# -+## -+ -+[Defines] -+ PLATFORM_NAME = SecurityPkgHostTest -+ PLATFORM_GUID = 9D78A9B4-00CD-477E-A5BF-90CC793EEFB0 -+ PLATFORM_VERSION = 0.1 -+ DSC_SPECIFICATION = 0x00010005 -+ OUTPUT_DIRECTORY = Build/SecurityPkg/HostTest -+ SUPPORTED_ARCHITECTURES = IA32|X64 -+ BUILD_TARGETS = NOOPT -+ SKUID_IDENTIFIER = DEFAULT -+ -+!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc -+ -+[LibraryClasses] -+ SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf -+ -+[Components] -+ SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeServicesTableLib.inf -+ SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProtectionLib.inf -+ SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf -+ SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf -+ SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf -+ -+ # -+ # Build SecurityPkg HOST_APPLICATION Tests -+ # -+ SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLibUnitTest.inf { -+ -+ SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf -+ UefiRuntimeServicesTableLib|SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeServicesTableLib.inf -+ PlatformPKProtectionLib|SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProtectionLib.inf -+ UefiLib|SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf -+ } -+ SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGoogleTest.inf { -+ -+ SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf -+ UefiRuntimeServicesTableLib|MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf -+ PlatformPKProtectionLib|SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf -+ UefiLib|MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf -+ } --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-418.patch b/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-418.patch deleted file mode 100644 index f01c9a1..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-418.patch +++ /dev/null @@ -1,286 +0,0 @@ -From 7c3fefb0c857acb9e7e14b150c4c3131e78fbb63 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 7 Feb 2024 15:43:10 -0500 -Subject: [PATCH 09/17] SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4118 - - CVE 2022-36764 - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [9/13] c7890fc5c5d7fef2fc1daa931ea2d48f3a76b9e3 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21156 -CVE: CVE-2022-36764 -Upstream: Merged - -commit c7b27944218130cca3bbb20314ba5b88b5de4aa4 -Author: Douglas Flick [MSFT] -Date: Fri Jan 12 02:16:04 2024 +0800 - - SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4118 - CVE 2022-36764 - - This commit contains the patch files and tests for DxeTpm2MeasureBootLib - CVE 2022-36764. - - Cc: Jiewen Yao - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeTpm2MeasureBootLib.c | 15 +++-- - .../DxeTpm2MeasureBootLibSanitization.c | 46 +++++++++++++- - .../DxeTpm2MeasureBootLibSanitization.h | 28 ++++++++- - .../DxeTpm2MeasureBootLibSanitizationTest.c | 60 ++++++++++++++++--- - 4 files changed, 133 insertions(+), 16 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index 476c8d543f..f06926e631 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -372,7 +372,6 @@ Exit: - @retval EFI_OUT_OF_RESOURCES No enough resource to measure image. - @retval EFI_UNSUPPORTED ImageType is unsupported or PE image is mal-format. - @retval other error value -- - **/ - EFI_STATUS - EFIAPI -@@ -399,6 +398,7 @@ Tcg2MeasurePeImage ( - Status = EFI_UNSUPPORTED; - ImageLoad = NULL; - EventPtr = NULL; -+ Tcg2Event = NULL; - - Tcg2Protocol = MeasureBootProtocols->Tcg2Protocol; - CcProtocol = MeasureBootProtocols->CcProtocol; -@@ -413,19 +413,24 @@ Tcg2MeasurePeImage ( - return EFI_UNSUPPORTED; - } - -- FilePathSize = (UINT32) GetDevicePathSize (FilePath); -+ FilePathSize = (UINT32)GetDevicePathSize (FilePath); -+ Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ if (EFI_ERROR (Status)) { -+ return EFI_UNSUPPORTED; -+ } - - // - // Determine destination PCR by BootPolicy - // -- EventSize = sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize; -- EventPtr = AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)); -+ // from a malicious GPT disk partition -+ EventPtr = AllocateZeroPool (EventSize); - if (EventPtr == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Tcg2Event = (EFI_TCG2_EVENT *)EventPtr; -- Tcg2Event->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER); -+ Tcg2Event->Size = EventSize; -+ Tcg2Event->Header.HeaderSize = sizeof (EFI_TCG2_EVENT_HEADER); - Tcg2Event->Header.HeaderVersion = EFI_TCG2_EVENT_HEADER_VERSION; - ImageLoad = (EFI_IMAGE_LOAD_EVENT *) Tcg2Event->Event; - -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -index e2309655d3..2a4d52c6d5 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.c -@@ -151,7 +151,7 @@ SanitizeEfiPartitionTableHeader ( - } - - /** -- This function will validate that the allocation size from the primary header is sane -+ This function will validate that the allocation size from the primary header is sane - It will check the following: - - AllocationSize does not overflow - -@@ -273,3 +273,47 @@ SanitizePrimaryHeaderGptEventSize ( - - return EFI_SUCCESS; - } -+ -+/** -+ This function will validate that the PeImage Event Size from the loaded image is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ @param[in] FilePathSize - Size of the file path. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePeImageEventSize ( -+ IN UINT32 FilePathSize, -+ OUT UINT32 *EventSize -+ ) -+{ -+ EFI_STATUS Status; -+ -+ // Replacing logic: -+ // sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize; -+ Status = SafeUint32Add (OFFSET_OF (EFI_IMAGE_LOAD_EVENT, DevicePath), FilePathSize, EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "EventSize would overflow!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Replacing logic: -+ // EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event) -+ Status = SafeUint32Add (*EventSize, OFFSET_OF (EFI_TCG2_EVENT, Event), EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "EventSize would overflow!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -index 048b738987..8f72ba4240 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitization.h -@@ -9,6 +9,9 @@ - Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse - partition data carefully. - -+ Tcg2MeasurePeImage() function will accept untrusted PE/COFF image and validate its -+ data structure within this image buffer before use. -+ - Copyright (c) Microsoft Corporation.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -110,4 +113,27 @@ SanitizePrimaryHeaderGptEventSize ( - OUT UINT32 *EventSize - ); - --#endif // DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_ -+/** -+ This function will validate that the PeImage Event Size from the loaded image is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ @param[in] FilePathSize - Size of the file path. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePeImageEventSize ( -+ IN UINT32 FilePathSize, -+ OUT UINT32 *EventSize -+ ); -+ -+#endif // DXE_TPM2_MEASURE_BOOT_LIB_VALIDATION_ -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -index 3eb9763e3c..820e99aeb9 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTest.c -@@ -72,10 +72,10 @@ TestSanitizeEfiPartitionTableHeader ( - PrimaryHeader.Header.Revision = DEFAULT_PRIMARY_TABLE_HEADER_REVISION; - PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); - PrimaryHeader.MyLBA = 1; -- PrimaryHeader.AlternateLBA = 2; -- PrimaryHeader.FirstUsableLBA = 3; -- PrimaryHeader.LastUsableLBA = 4; -- PrimaryHeader.PartitionEntryLBA = 5; -+ PrimaryHeader.PartitionEntryLBA = 2; -+ PrimaryHeader.AlternateLBA = 3; -+ PrimaryHeader.FirstUsableLBA = 4; -+ PrimaryHeader.LastUsableLBA = 5; - PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES; - PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; - PrimaryHeader.PartitionEntryArrayCRC32 = 0; // Purposely invalid -@@ -187,11 +187,6 @@ TestSanitizePrimaryHeaderGptEventSize ( - EFI_STATUS Status; - EFI_PARTITION_TABLE_HEADER PrimaryHeader; - UINTN NumberOfPartition; -- EFI_GPT_DATA *GptData; -- EFI_TCG2_EVENT *Tcg2Event; -- -- Tcg2Event = NULL; -- GptData = NULL; - - // Test that a normal PrimaryHeader passes validation - PrimaryHeader.NumberOfPartitionEntries = 5; -@@ -225,6 +220,52 @@ TestSanitizePrimaryHeaderGptEventSize ( - return UNIT_TEST_PASSED; - } - -+/** -+ This function tests the SanitizePeImageEventSize function. -+ It's intent is to test that the untrusted input from a file path when generating a -+ EFI_IMAGE_LOAD_EVENT structure will not cause an overflow when calculating -+ the event size when allocating space -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePeImageEventSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 EventSize; -+ UINTN ExistingLogicEventSize; -+ UINT32 FilePathSize; -+ EFI_STATUS Status; -+ -+ FilePathSize = 255; -+ -+ // Test that a normal PE image passes validation -+ Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_SUCCESS); -+ -+ // Test that the event size is correct compared to the existing logic -+ ExistingLogicEventSize = OFFSET_OF (EFI_IMAGE_LOAD_EVENT, DevicePath) + FilePathSize; -+ ExistingLogicEventSize += OFFSET_OF (EFI_TCG2_EVENT, Event); -+ -+ if (EventSize != ExistingLogicEventSize) { -+ UT_LOG_ERROR ("SanitizePeImageEventSize returned an incorrect event size. Expected %u, got %u\n", ExistingLogicEventSize, EventSize); -+ return UNIT_TEST_ERROR_TEST_FAILED; -+ } -+ -+ // Test that the event size may not overflow -+ Status = SanitizePeImageEventSize (MAX_UINT32, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ - // *--------------------------------------------------------------------* - // * Unit Test Code Main Function - // *--------------------------------------------------------------------* -@@ -267,6 +308,7 @@ UefiTestMain ( - AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Validating EFI Partition Table", "Common.Tcg2MeasureBootLibValidation", TestSanitizeEfiPartitionTableHeader, NULL, NULL, NULL); - AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Primary header gpt event checks for overflow", "Common.Tcg2MeasureBootLibValidation", TestSanitizePrimaryHeaderAllocationSize, NULL, NULL, NULL); - AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests Primary header allocation size checks for overflow", "Common.Tcg2MeasureBootLibValidation", TestSanitizePrimaryHeaderGptEventSize, NULL, NULL, NULL); -+ AddTestCase (Tcg2MeasureBootLibValidationTestSuite, "Tests PE Image and FileSize checks for overflow", "Common.Tcg2MeasureBootLibValidation", TestSanitizePeImageEventSize, NULL, NULL, NULL); - - Status = RunAllTestSuites (Framework); - --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SEC-PATCH-4117-2.patch b/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SEC-PATCH-4117-2.patch deleted file mode 100644 index b9629c0..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SEC-PATCH-4117-2.patch +++ /dev/null @@ -1,279 +0,0 @@ -From ac25c501c8d97c7520a7c75ae708fb4c43bae035 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 13 Feb 2024 16:30:10 -0500 -Subject: [PATCH 12/17] SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH - 4117/4118 symbol rename - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [12/13] 6ef41050fb68f984a5ae6104ccc102afb5290f9f (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21156 -CVE: CVE-2022-36764 -Upstream: Merged - -commit 326db0c9072004dea89427ea3a44393a84966f2b -Author: Doug Flick -Date: Wed Jan 17 14:47:21 2024 -0800 - - SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4117/4118 symbol rename - - Updates the sanitation function names to be lib unique names - - Cc: Jiewen Yao - Cc: Rahul Kumar - - Signed-off-by: Doug Flick [MSFT] - Message-Id: <355aa846a99ca6ac0f7574cf5982661da0d9fea6.1705529990.git.doug.edk2@gmail.com> - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeTpmMeasureBootLib.c | 8 +++--- - .../DxeTpmMeasureBootLibSanitization.c | 10 +++---- - .../DxeTpmMeasureBootLibSanitization.h | 8 +++--- - .../DxeTpmMeasureBootLibSanitizationTest.c | 26 +++++++++---------- - 4 files changed, 26 insertions(+), 26 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -index 1598015176..c39018d7e4 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -@@ -171,7 +171,7 @@ TcgMeasureGptTable ( - BlockIo->Media->BlockSize, - (UINT8 *)PrimaryHeader - ); -- if (EFI_ERROR (Status) || EFI_ERROR (SanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { -+ if (EFI_ERROR (Status) || EFI_ERROR (TpmSanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { - DEBUG ((DEBUG_ERROR, "Failed to read Partition Table Header or invalid Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; -@@ -179,7 +179,7 @@ TcgMeasureGptTable ( - // - // Read the partition entry. - // -- Status = SanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); -+ Status = TpmSanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); - if (EFI_ERROR (Status)) { - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; -@@ -218,7 +218,7 @@ TcgMeasureGptTable ( - // - // Prepare Data for Measurement - // -- Status = SanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &EventSize); -+ Status = TpmSanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &EventSize); - TcgEvent = (TCG_PCR_EVENT *)AllocateZeroPool (EventSize); - if (TcgEvent == NULL) { - FreePool (PrimaryHeader); -@@ -344,7 +344,7 @@ TcgMeasurePeImage ( - - // Determine destination PCR by BootPolicy - // -- Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ Status = TpmSanitizePeImageEventSize (FilePathSize, &EventSize); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -index bcf8c6de6f..7f17af56cd 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -@@ -1,5 +1,5 @@ - /** @file -- The library instance provides security service of TPM2 measure boot and -+ The library instance provides security service of TPM measure boot and - Confidential Computing (CC) measure boot. - - Caution: This file requires additional review when modified. -@@ -63,7 +63,7 @@ - **/ - EFI_STATUS - EFIAPI --SanitizeEfiPartitionTableHeader ( -+TpmSanitizeEfiPartitionTableHeader ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo - ) -@@ -145,7 +145,7 @@ SanitizeEfiPartitionTableHeader ( - **/ - EFI_STATUS - EFIAPI --SanitizePrimaryHeaderAllocationSize ( -+TpmSanitizePrimaryHeaderAllocationSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - OUT UINT32 *AllocationSize - ) -@@ -194,7 +194,7 @@ SanitizePrimaryHeaderAllocationSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePrimaryHeaderGptEventSize ( -+TpmSanitizePrimaryHeaderGptEventSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN UINTN NumberOfPartition, - OUT UINT32 *EventSize -@@ -258,7 +258,7 @@ SanitizePrimaryHeaderGptEventSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePeImageEventSize ( -+TpmSanitizePeImageEventSize ( - IN UINT32 FilePathSize, - OUT UINT32 *EventSize - ) -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -index 2248495813..db6e9c3752 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -@@ -53,7 +53,7 @@ - **/ - EFI_STATUS - EFIAPI --SanitizeEfiPartitionTableHeader ( -+TpmSanitizeEfiPartitionTableHeader ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo - ); -@@ -77,7 +77,7 @@ SanitizeEfiPartitionTableHeader ( - **/ - EFI_STATUS - EFIAPI --SanitizePrimaryHeaderAllocationSize ( -+TpmSanitizePrimaryHeaderAllocationSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - OUT UINT32 *AllocationSize - ); -@@ -105,7 +105,7 @@ SanitizePrimaryHeaderAllocationSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePrimaryHeaderGptEventSize ( -+TpmSanitizePrimaryHeaderGptEventSize ( - IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, - IN UINTN NumberOfPartition, - OUT UINT32 *EventSize -@@ -129,7 +129,7 @@ SanitizePrimaryHeaderGptEventSize ( - One of the passed parameters was invalid. - **/ - EFI_STATUS --SanitizePeImageEventSize ( -+TpmSanitizePeImageEventSize ( - IN UINT32 FilePathSize, - OUT UINT32 *EventSize - ); -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -index c41498be45..de1740af41 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -@@ -83,27 +83,27 @@ TestSanitizeEfiPartitionTableHeader ( - PrimaryHeader.Header.CRC32 = CalculateCrc32 ((UINT8 *)&PrimaryHeader, PrimaryHeader.Header.HeaderSize); - - // Test that a normal PrimaryHeader passes validation -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = TpmSanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Test that when number of partition entries is 0, the function returns EFI_DEVICE_ERROR - // Should print "Invalid Partition Table Header NumberOfPartitionEntries!"" - PrimaryHeader.NumberOfPartitionEntries = 0; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = TpmSanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; - - // Test that when the header size is too small, the function returns EFI_DEVICE_ERROR - // Should print "Invalid Partition Table Header Size!" - PrimaryHeader.Header.HeaderSize = 0; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = TpmSanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); - - // Test that when the SizeOfPartitionEntry is too small, the function returns EFI_DEVICE_ERROR - // should print: "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!" - PrimaryHeader.SizeOfPartitionEntry = 1; -- Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ Status = TpmSanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); - UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -136,7 +136,7 @@ TestSanitizePrimaryHeaderAllocationSize ( - PrimaryHeader.NumberOfPartitionEntries = 5; - PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; - -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = TpmSanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Test that the allocation size is correct compared to the existing logic -@@ -145,19 +145,19 @@ TestSanitizePrimaryHeaderAllocationSize ( - // Test that an overflow is detected - PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; - PrimaryHeader.SizeOfPartitionEntry = 5; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = TpmSanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test the inverse - PrimaryHeader.NumberOfPartitionEntries = 5; - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = TpmSanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test the worst case scenario - PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ Status = TpmSanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -195,7 +195,7 @@ TestSanitizePrimaryHeaderGptEventSize ( - NumberOfPartition = 13; - - // that the primary event size is correct -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ Status = TpmSanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); - UT_ASSERT_NOT_EFI_ERROR (Status); - - // Calculate the existing logic event size -@@ -206,12 +206,12 @@ TestSanitizePrimaryHeaderGptEventSize ( - UT_ASSERT_EQUAL (EventSize, ExistingLogicEventSize); - - // Tests that the primary event size may not overflow -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); -+ Status = TpmSanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - // Test that the size of partition entries may not overflow - PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -- Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ Status = TpmSanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); - UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); - - DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -@@ -269,7 +269,7 @@ TestSanitizePeImageEventSize ( - FilePathSize = 255; - - // Test that a normal PE image passes validation -- Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ Status = TpmSanitizePeImageEventSize (FilePathSize, &EventSize); - if (EFI_ERROR (Status)) { - UT_LOG_ERROR ("SanitizePeImageEventSize failed with %r\n", Status); - goto Exit; -@@ -285,7 +285,7 @@ TestSanitizePeImageEventSize ( - } - - // Test that the event size may not overflow -- Status = SanitizePeImageEventSize (MAX_UINT32, &EventSize); -+ Status = TpmSanitizePeImageEventSize (MAX_UINT32, &EventSize); - if (Status != EFI_BAD_BUFFER_SIZE) { - UT_LOG_ERROR ("SanitizePeImageEventSize succeded when it was supposed to fail with %r\n", Status); - goto Exit; --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4117.patch b/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4117.patch deleted file mode 100644 index 499abda..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4117.patch +++ /dev/null @@ -1,960 +0,0 @@ -From cb36d95002013ae8d4e5120383cd756a2a6c4124 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 17 Jan 2024 12:20:52 -0500 -Subject: [PATCH 07/17] SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4117 - - CVE 2022-36763 - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [7/13] f5a5d2b0a33dc1efdb83e501eda2716df0e904a0 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged -Conflicts: We get function definiton clash for the following three functions: - - SanitizeEfiPartitionTableHeader() - - SanitizePrimaryHeaderAllocationSize() - - SanitizePrimaryHeaderGptEventSize() - Those are are defined both in - - SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitazion.c - and - - SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitazion.c - Closer investigation reveals that they are identical in functionality (although - not in comment style). - I chose to leave them as is now, meaning that this package will be - unbuildable until I add a commit renaming these symbols later in - this series. - -commit 4776a1b39ee08fc45c70c1eab5a0195f325000d3 -Author: Douglas Flick [MSFT] -Date: Fri Jan 12 02:16:02 2024 +0800 - - SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4117 - CVE 2022-36763 - - This commit contains the patch files and tests for DxeTpmMeasureBootLib - CVE 2022-36763. - - Cc: Jiewen Yao - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeTpmMeasureBootLib.c | 74 +++-- - .../DxeTpmMeasureBootLib.inf | 4 +- - .../DxeTpmMeasureBootLibSanitization.c | 242 ++++++++++++++ - .../DxeTpmMeasureBootLibSanitization.h | 114 +++++++ - .../DxeTpmMeasureBootLibSanitizationTest.c | 301 ++++++++++++++++++ - ...eTpmMeasureBootLibSanitizationTestHost.inf | 28 ++ - SecurityPkg/SecurityPkg.ci.yaml | 1 + - SecurityPkg/Test/SecurityPkgHostTest.dsc | 1 + - 8 files changed, 734 insertions(+), 31 deletions(-) - create mode 100644 SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c - create mode 100644 SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h - create mode 100644 SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c - create mode 100644 SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTestHost.inf - -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -index 27c0ea48ca..d44422dee8 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -@@ -18,6 +18,8 @@ - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -+Copyright (c) Microsoft Corporation.
-+SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - - #include -@@ -40,6 +42,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - -+#include "DxeTpmMeasureBootLibSanitization.h" -+ - // - // Flag to check GPT partition. It only need be measured once. - // -@@ -123,19 +127,22 @@ TcgMeasureGptTable ( - IN EFI_HANDLE GptHandle - ) - { -- EFI_STATUS Status; -- EFI_BLOCK_IO_PROTOCOL *BlockIo; -- EFI_DISK_IO_PROTOCOL *DiskIo; -- EFI_PARTITION_TABLE_HEADER *PrimaryHeader; -- EFI_PARTITION_ENTRY *PartitionEntry; -- UINT8 *EntryPtr; -- UINTN NumberOfPartition; -- UINT32 Index; -- TCG_PCR_EVENT *TcgEvent; -- EFI_GPT_DATA *GptData; -- UINT32 EventSize; -- UINT32 EventNumber; -- EFI_PHYSICAL_ADDRESS EventLogLastEntry; -+ EFI_STATUS Status; -+ EFI_BLOCK_IO_PROTOCOL *BlockIo; -+ EFI_DISK_IO_PROTOCOL *DiskIo; -+ EFI_PARTITION_TABLE_HEADER *PrimaryHeader; -+ EFI_PARTITION_ENTRY *PartitionEntry; -+ UINT8 *EntryPtr; -+ UINTN NumberOfPartition; -+ UINT32 Index; -+ TCG_PCR_EVENT *TcgEvent; -+ EFI_GPT_DATA *GptData; -+ UINT32 EventSize; -+ UINT32 EventNumber; -+ EFI_PHYSICAL_ADDRESS EventLogLastEntry; -+ UINT32 AllocSize; -+ -+ GptData = NULL; - - if (mMeasureGptCount > 0) { - return EFI_SUCCESS; -@@ -163,15 +170,21 @@ TcgMeasureGptTable ( - BlockIo->Media->BlockSize, - (UINT8 *)PrimaryHeader - ); -- if (EFI_ERROR (Status)) { -- DEBUG ((DEBUG_ERROR, "Failed to Read Partition Table Header!\n")); -+ if (EFI_ERROR (Status) || EFI_ERROR (SanitizeEfiPartitionTableHeader (PrimaryHeader, BlockIo))) { -+ DEBUG ((DEBUG_ERROR, "Failed to read Partition Table Header or invalid Partition Table Header!\n")); - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; - } - // - // Read the partition entry. - // -- EntryPtr = (UINT8 *)AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry); -+ Status = SanitizePrimaryHeaderAllocationSize (PrimaryHeader, &AllocSize); -+ if (EFI_ERROR (Status)) { -+ FreePool (PrimaryHeader); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ EntryPtr = (UINT8 *)AllocatePool (AllocSize); - if (EntryPtr == NULL) { - FreePool (PrimaryHeader); - return EFI_OUT_OF_RESOURCES; -@@ -179,8 +192,8 @@ TcgMeasureGptTable ( - Status = DiskIo->ReadDisk ( - DiskIo, - BlockIo->Media->MediaId, -- MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize), -- PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry, -+ MultU64x32 (PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize), -+ AllocSize, - EntryPtr - ); - if (EFI_ERROR (Status)) { -@@ -204,19 +217,18 @@ TcgMeasureGptTable ( - // - // Prepare Data for Measurement - // -- EventSize = (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions) -- + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry); -- TcgEvent = (TCG_PCR_EVENT *) AllocateZeroPool (EventSize + sizeof (TCG_PCR_EVENT_HDR)); -+ Status = SanitizePrimaryHeaderGptEventSize (PrimaryHeader, NumberOfPartition, &EventSize); -+ TcgEvent = (TCG_PCR_EVENT *)AllocateZeroPool (EventSize); - if (TcgEvent == NULL) { - FreePool (PrimaryHeader); - FreePool (EntryPtr); - return EFI_OUT_OF_RESOURCES; - } - -- TcgEvent->PCRIndex = 5; -- TcgEvent->EventType = EV_EFI_GPT_EVENT; -- TcgEvent->EventSize = EventSize; -- GptData = (EFI_GPT_DATA *) TcgEvent->Event; -+ TcgEvent->PCRIndex = 5; -+ TcgEvent->EventType = EV_EFI_GPT_EVENT; -+ TcgEvent->EventSize = EventSize - sizeof (TCG_PCR_EVENT_HDR); -+ GptData = (EFI_GPT_DATA *)TcgEvent->Event; - - // - // Copy the EFI_PARTITION_TABLE_HEADER and NumberOfPartition -@@ -354,11 +366,13 @@ TcgMeasurePeImage ( - TcgEvent->PCRIndex = 2; - break; - default: -- DEBUG (( -- DEBUG_ERROR, -- "TcgMeasurePeImage: Unknown subsystem type %d", -- ImageType -- )); -+ DEBUG ( -+ ( -+ DEBUG_ERROR, -+ "TcgMeasurePeImage: Unknown subsystem type %d", -+ ImageType -+ ) -+ ); - goto Finish; - } - -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf -index ebab6f7c1e..414c654d15 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf -@@ -32,6 +32,8 @@ - - [Sources] - DxeTpmMeasureBootLib.c -+ DxeTpmMeasureBootLibSanitization.c -+ DxeTpmMeasureBootLibSanitization.h - - [Packages] - MdePkg/MdePkg.dec -@@ -41,6 +43,7 @@ - - [LibraryClasses] - BaseMemoryLib -+ SafeIntLib - DebugLib - MemoryAllocationLib - DevicePathLib -@@ -59,4 +62,3 @@ - gEfiFirmwareVolumeBlockProtocolGuid ## SOMETIMES_CONSUMES - gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES - gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES -- -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -new file mode 100644 -index 0000000000..37cd3ed0ea ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -@@ -0,0 +1,242 @@ -+/** @file -+ The library instance provides security service of TPM2 measure boot and -+ Confidential Computing (CC) measure boot. -+ -+ Caution: This file requires additional review when modified. -+ This library will have external input - PE/COFF image and GPT partition. -+ This external input must be validated carefully to avoid security issue like -+ buffer overflow, integer overflow. -+ -+ This file will pull out the validation logic from the following functions, in an -+ attempt to validate the untrusted input in the form of unit tests -+ -+ These are those functions: -+ -+ DxeTpmMeasureBootLibImageRead() function will make sure the PE/COFF image content -+ read is within the image buffer. -+ -+ Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse -+ partition data carefully. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "DxeTpmMeasureBootLibSanitization.h" -+ -+#define GPT_HEADER_REVISION_V1 0x00010000 -+ -+/** -+ This function will validate the EFI_PARTITION_TABLE_HEADER structure is safe to parse -+ However this function will not attempt to verify the validity of the GPT partition -+ It will check the following: -+ - Signature -+ - Revision -+ - AlternateLBA -+ - FirstUsableLBA -+ - LastUsableLBA -+ - PartitionEntryLBA -+ - NumberOfPartitionEntries -+ - SizeOfPartitionEntry -+ - BlockIo -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[in] BlockIo -+ Pointer to the EFI_BLOCK_IO_PROTOCOL structure. -+ -+ @retval EFI_SUCCESS -+ The EFI_PARTITION_TABLE_HEADER structure is valid. -+ -+ @retval EFI_INVALID_PARAMETER -+ The EFI_PARTITION_TABLE_HEADER structure is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizeEfiPartitionTableHeader ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo -+ ) -+{ -+ // Verify that the input parameters are safe to use -+ if (PrimaryHeader == NULL) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if ((BlockIo == NULL) || (BlockIo->Media == NULL)) { -+ DEBUG ((DEBUG_ERROR, "Invalid BlockIo!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // The signature must be EFI_PTAB_HEADER_ID ("EFI PART" in ASCII) -+ if (PrimaryHeader->Header.Signature != EFI_PTAB_HEADER_ID) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // The version must be GPT_HEADER_REVISION_V1 (0x00010000) -+ if (PrimaryHeader->Header.Revision != GPT_HEADER_REVISION_V1) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header Revision!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // The HeaderSize must be greater than or equal to 92 and must be less than or equal to the logical block size -+ if ((PrimaryHeader->Header.HeaderSize < sizeof (EFI_PARTITION_TABLE_HEADER)) || (PrimaryHeader->Header.HeaderSize > BlockIo->Media->BlockSize)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header HeaderSize!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // check that the PartitionEntryLBA greater than the Max LBA -+ // This will be used later for multiplication -+ if (PrimaryHeader->PartitionEntryLBA > DivU64x32 (MAX_UINT64, BlockIo->Media->BlockSize)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header PartitionEntryLBA!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // Check that the number of partition entries is greater than zero -+ if (PrimaryHeader->NumberOfPartitionEntries == 0) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header NumberOfPartitionEntries!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // SizeOfPartitionEntry must be 128, 256, 512... improper size may lead to accessing uninitialized memory -+ if ((PrimaryHeader->SizeOfPartitionEntry < 128) || ((PrimaryHeader->SizeOfPartitionEntry & (PrimaryHeader->SizeOfPartitionEntry - 1)) != 0)) { -+ DEBUG ((DEBUG_ERROR, "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ // This check is to prevent overflow when calculating the allocation size for the partition entries -+ // This check will be used later for multiplication -+ if (PrimaryHeader->NumberOfPartitionEntries > DivU64x32 (MAX_UINT64, PrimaryHeader->SizeOfPartitionEntry)) { -+ DEBUG ((DEBUG_ERROR, "Invalid Partition Table Header NumberOfPartitionEntries!\n")); -+ return EFI_DEVICE_ERROR; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ This function will validate that the allocation size from the primary header is sane -+ It will check the following: -+ - AllocationSize does not overflow -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[out] AllocationSize -+ Pointer to the allocation size. -+ -+ @retval EFI_SUCCESS -+ The allocation size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ The allocation size is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizePrimaryHeaderAllocationSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ OUT UINT32 *AllocationSize -+ ) -+{ -+ EFI_STATUS Status; -+ -+ if (PrimaryHeader == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (AllocationSize == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Replacing logic: -+ // PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry; -+ Status = SafeUint32Mult (PrimaryHeader->NumberOfPartitionEntries, PrimaryHeader->SizeOfPartitionEntry, AllocationSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Allocation Size would have overflowed!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** -+ This function will validate that the Gpt Event Size calculated from the primary header is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ Important: This function includes the entire length of the allocated space, including the -+ TCG_PCR_EVENT_HDR. When hashing the buffer allocated with this size, the caller must subtract -+ the size of the TCG_PCR_EVENT_HDR from the size of the buffer before hashing. -+ -+ @param[in] PrimaryHeader - Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ @param[in] NumberOfPartition - Number of partitions. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePrimaryHeaderGptEventSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN UINTN NumberOfPartition, -+ OUT UINT32 *EventSize -+ ) -+{ -+ EFI_STATUS Status; -+ UINT32 SafeNumberOfPartitions; -+ -+ if (PrimaryHeader == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ if (EventSize == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // We shouldn't even attempt to perform the multiplication if the number of partitions is greater than the maximum value of UINT32 -+ Status = SafeUintnToUint32 (NumberOfPartition, &SafeNumberOfPartitions); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "NumberOfPartition would have overflowed!\n")); -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ // Replacing logic: -+ // (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions) + NumberOfPartition * PrimaryHeader.SizeOfPartitionEntry + sizeof (TCG_PCR_EVENT_HDR)); -+ Status = SafeUint32Mult (SafeNumberOfPartitions, PrimaryHeader->SizeOfPartitionEntry, EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Event Size would have overflowed!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ Status = SafeUint32Add ( -+ sizeof (TCG_PCR_EVENT_HDR) + -+ OFFSET_OF (EFI_GPT_DATA, Partitions), -+ *EventSize, -+ EventSize -+ ); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Event Size would have overflowed because of GPTData!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -new file mode 100644 -index 0000000000..0d9d00c281 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -@@ -0,0 +1,114 @@ -+/** @file -+ This file includes the function prototypes for the sanitization functions. -+ -+ These are those functions: -+ -+ DxeTpmMeasureBootLibImageRead() function will make sure the PE/COFF image content -+ read is within the image buffer. -+ -+ TcgMeasurePeImage() function will accept untrusted PE/COFF image and validate its -+ data structure within this image buffer before use. -+ -+ TcgMeasureGptTable() function will receive untrusted GPT partition table, and parse -+ partition data carefully. -+ -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#ifndef DXE_TPM_MEASURE_BOOT_LIB_VALIDATION_ -+#define DXE_TPM_MEASURE_BOOT_LIB_VALIDATION_ -+ -+#include -+#include -+#include -+#include -+ -+/** -+ This function will validate the EFI_PARTITION_TABLE_HEADER structure is safe to parse -+ However this function will not attempt to verify the validity of the GPT partition -+ It will check the following: -+ - Signature -+ - Revision -+ - AlternateLBA -+ - FirstUsableLBA -+ - LastUsableLBA -+ - PartitionEntryLBA -+ - NumberOfPartitionEntries -+ - SizeOfPartitionEntry -+ - BlockIo -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[in] BlockIo -+ Pointer to the EFI_BLOCK_IO_PROTOCOL structure. -+ -+ @retval EFI_SUCCESS -+ The EFI_PARTITION_TABLE_HEADER structure is valid. -+ -+ @retval EFI_INVALID_PARAMETER -+ The EFI_PARTITION_TABLE_HEADER structure is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizeEfiPartitionTableHeader ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo -+ ); -+ -+/** -+ This function will validate that the allocation size from the primary header is sane -+ It will check the following: -+ - AllocationSize does not overflow -+ -+ @param[in] PrimaryHeader -+ Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ -+ @param[out] AllocationSize -+ Pointer to the allocation size. -+ -+ @retval EFI_SUCCESS -+ The allocation size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ The allocation size is invalid. -+**/ -+EFI_STATUS -+EFIAPI -+SanitizePrimaryHeaderAllocationSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ OUT UINT32 *AllocationSize -+ ); -+ -+/** -+ This function will validate that the Gpt Event Size calculated from the primary header is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ Important: This function includes the entire length of the allocated space, including the -+ TCG_PCR_EVENT_HDR. When hashing the buffer allocated with this size, the caller must subtract -+ the size of the TCG_PCR_EVENT_HDR from the size of the buffer before hashing. -+ -+ @param[in] PrimaryHeader - Pointer to the EFI_PARTITION_TABLE_HEADER structure. -+ @param[in] NumberOfPartition - Number of partitions. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePrimaryHeaderGptEventSize ( -+ IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, -+ IN UINTN NumberOfPartition, -+ OUT UINT32 *EventSize -+ ); -+ -+#endif // DXE_TPM_MEASURE_BOOT_LIB_VALIDATION_ -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -new file mode 100644 -index 0000000000..eeb928cdb0 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -@@ -0,0 +1,301 @@ -+/** @file -+This file includes the unit test cases for the DxeTpmMeasureBootLibSanitizationTest.c. -+ -+Copyright (c) Microsoft Corporation.
-+SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "../DxeTpmMeasureBootLibSanitization.h" -+ -+#define UNIT_TEST_NAME "DxeTpmMeasureBootLibSanitizationTest" -+#define UNIT_TEST_VERSION "1.0" -+ -+#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION 0x00010000 -+#define DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES 1 -+#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY 128 -+ -+/** -+ This function tests the SanitizeEfiPartitionTableHeader function. -+ It's intent is to test that a malicious EFI_PARTITION_TABLE_HEADER -+ structure will not cause undefined or unexpected behavior. -+ -+ In general the TPM should still be able to measure the data, but -+ be the header should be sanitized to prevent any unexpected behavior. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizeEfiPartitionTableHeader ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ EFI_BLOCK_IO_PROTOCOL BlockIo; -+ EFI_BLOCK_IO_MEDIA BlockMedia; -+ -+ // Generate EFI_BLOCK_IO_MEDIA test data -+ BlockMedia.MediaId = 1; -+ BlockMedia.RemovableMedia = FALSE; -+ BlockMedia.MediaPresent = TRUE; -+ BlockMedia.LogicalPartition = FALSE; -+ BlockMedia.ReadOnly = FALSE; -+ BlockMedia.WriteCaching = FALSE; -+ BlockMedia.BlockSize = 512; -+ BlockMedia.IoAlign = 1; -+ BlockMedia.LastBlock = 0; -+ -+ // Generate EFI_BLOCK_IO_PROTOCOL test data -+ BlockIo.Revision = 1; -+ BlockIo.Media = &BlockMedia; -+ BlockIo.Reset = NULL; -+ BlockIo.ReadBlocks = NULL; -+ BlockIo.WriteBlocks = NULL; -+ BlockIo.FlushBlocks = NULL; -+ -+ // Geneate EFI_PARTITION_TABLE_HEADER test data -+ PrimaryHeader.Header.Signature = EFI_PTAB_HEADER_ID; -+ PrimaryHeader.Header.Revision = DEFAULT_PRIMARY_TABLE_HEADER_REVISION; -+ PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); -+ PrimaryHeader.MyLBA = 1; -+ PrimaryHeader.AlternateLBA = 2; -+ PrimaryHeader.FirstUsableLBA = 3; -+ PrimaryHeader.LastUsableLBA = 4; -+ PrimaryHeader.PartitionEntryLBA = 5; -+ PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ PrimaryHeader.PartitionEntryArrayCRC32 = 0; // Purposely invalid -+ -+ // Calculate the CRC32 of the PrimaryHeader -+ PrimaryHeader.Header.CRC32 = CalculateCrc32 ((UINT8 *)&PrimaryHeader, PrimaryHeader.Header.HeaderSize); -+ -+ // Test that a normal PrimaryHeader passes validation -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Test that when number of partition entries is 0, the function returns EFI_DEVICE_ERROR -+ // Should print "Invalid Partition Table Header NumberOfPartitionEntries!"" -+ PrimaryHeader.NumberOfPartitionEntries = 0; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ PrimaryHeader.NumberOfPartitionEntries = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ // Test that when the header size is too small, the function returns EFI_DEVICE_ERROR -+ // Should print "Invalid Partition Table Header Size!" -+ PrimaryHeader.Header.HeaderSize = 0; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ PrimaryHeader.Header.HeaderSize = sizeof (EFI_PARTITION_TABLE_HEADER); -+ -+ // Test that when the SizeOfPartitionEntry is too small, the function returns EFI_DEVICE_ERROR -+ // should print: "SizeOfPartitionEntry shall be set to a value of 128 x 2^n where n is an integer greater than or equal to zero (e.g., 128, 256, 512, etc.)!" -+ PrimaryHeader.SizeOfPartitionEntry = 1; -+ Status = SanitizeEfiPartitionTableHeader (&PrimaryHeader, &BlockIo); -+ UT_ASSERT_EQUAL (Status, EFI_DEVICE_ERROR); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+/** -+ This function tests the SanitizePrimaryHeaderAllocationSize function. -+ It's intent is to test that the untrusted input from a EFI_PARTITION_TABLE_HEADER -+ structure will not cause an overflow when calculating the allocation size. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePrimaryHeaderAllocationSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 AllocationSize; -+ -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ -+ // Test that a normal PrimaryHeader passes validation -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Test that the allocation size is correct compared to the existing logic -+ UT_ASSERT_EQUAL (AllocationSize, PrimaryHeader.NumberOfPartitionEntries * PrimaryHeader.SizeOfPartitionEntry); -+ -+ // Test that an overflow is detected -+ PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; -+ PrimaryHeader.SizeOfPartitionEntry = 5; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test the inverse -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test the worst case scenario -+ PrimaryHeader.NumberOfPartitionEntries = MAX_UINT32; -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderAllocationSize (&PrimaryHeader, &AllocationSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+/** -+ This function tests the SanitizePrimaryHeaderGptEventSize function. -+ It's intent is to test that the untrusted input from a EFI_GPT_DATA structure -+ will not cause an overflow when calculating the event size. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePrimaryHeaderGptEventSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 EventSize; -+ UINT32 ExistingLogicEventSize; -+ EFI_STATUS Status; -+ EFI_PARTITION_TABLE_HEADER PrimaryHeader; -+ UINTN NumberOfPartition; -+ EFI_GPT_DATA *GptData; -+ -+ GptData = NULL; -+ -+ // Test that a normal PrimaryHeader passes validation -+ PrimaryHeader.NumberOfPartitionEntries = 5; -+ PrimaryHeader.SizeOfPartitionEntry = DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY; -+ -+ // set the number of partitions -+ NumberOfPartition = 13; -+ -+ // that the primary event size is correct -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ UT_ASSERT_NOT_EFI_ERROR (Status); -+ -+ // Calculate the existing logic event size -+ ExistingLogicEventSize = (UINT32)(sizeof (TCG_PCR_EVENT_HDR) + OFFSET_OF (EFI_GPT_DATA, Partitions) -+ + NumberOfPartition * PrimaryHeader.SizeOfPartitionEntry); -+ -+ // Check that the event size is correct -+ UT_ASSERT_EQUAL (EventSize, ExistingLogicEventSize); -+ -+ // Tests that the primary event size may not overflow -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, MAX_UINT32, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ // Test that the size of partition entries may not overflow -+ PrimaryHeader.SizeOfPartitionEntry = MAX_UINT32; -+ Status = SanitizePrimaryHeaderGptEventSize (&PrimaryHeader, NumberOfPartition, &EventSize); -+ UT_ASSERT_EQUAL (Status, EFI_BAD_BUFFER_SIZE); -+ -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ -+ return UNIT_TEST_PASSED; -+} -+ -+// *--------------------------------------------------------------------* -+// * Unit Test Code Main Function -+// *--------------------------------------------------------------------* -+ -+/** -+ This function acts as the entry point for the unit tests. -+ -+ @param argc - The number of command line arguments -+ @param argv - The command line arguments -+ -+ @return int - The status of the test -+**/ -+EFI_STATUS -+EFIAPI -+UefiTestMain ( -+ VOID -+ ) -+{ -+ EFI_STATUS Status; -+ UNIT_TEST_FRAMEWORK_HANDLE Framework; -+ UNIT_TEST_SUITE_HANDLE TcgMeasureBootLibValidationTestSuite; -+ -+ Framework = NULL; -+ -+ DEBUG ((DEBUG_INFO, "%a: TestMain() - Start\n", UNIT_TEST_NAME)); -+ -+ Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%a: Failed in InitUnitTestFramework. Status = %r\n", UNIT_TEST_NAME, Status)); -+ goto EXIT; -+ } -+ -+ Status = CreateUnitTestSuite (&TcgMeasureBootLibValidationTestSuite, Framework, "TcgMeasureBootLibValidationTestSuite", "Common.TcgMeasureBootLibValidation", NULL, NULL); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "%s: Failed in CreateUnitTestSuite for TcgMeasureBootLibValidationTestSuite\n", UNIT_TEST_NAME)); -+ Status = EFI_OUT_OF_RESOURCES; -+ goto EXIT; -+ } -+ -+ // -----------Suite---------------------------------Description----------------------------Class----------------------------------Test Function------------------------Pre---Clean-Context -+ AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Validating EFI Partition Table", "Common.TcgMeasureBootLibValidation", TestSanitizeEfiPartitionTableHeader, NULL, NULL, NULL); -+ AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Primary header gpt event checks for overflow", "Common.TcgMeasureBootLibValidation", TestSanitizePrimaryHeaderAllocationSize, NULL, NULL, NULL); -+ AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Primary header allocation size checks for overflow", "Common.TcgMeasureBootLibValidation", TestSanitizePrimaryHeaderGptEventSize, NULL, NULL, NULL); -+ -+ Status = RunAllTestSuites (Framework); -+ -+EXIT: -+ if (Framework != NULL) { -+ FreeUnitTestFramework (Framework); -+ } -+ -+ DEBUG ((DEBUG_INFO, "%a: TestMain() - End\n", UNIT_TEST_NAME)); -+ return Status; -+} -+ -+/// -+/// Avoid ECC error for function name that starts with lower case letter -+/// -+#define DxeTpmMeasureBootLibUnitTestMain main -+ -+/** -+ Standard POSIX C entry point for host based unit test execution. -+ -+ @param[in] Argc Number of arguments -+ @param[in] Argv Array of pointers to arguments -+ -+ @retval 0 Success -+ @retval other Error -+**/ -+INT32 -+DxeTpmMeasureBootLibUnitTestMain ( -+ IN INT32 Argc, -+ IN CHAR8 *Argv[] -+ ) -+{ -+ return (INT32)UefiTestMain (); -+} -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTestHost.inf b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTestHost.inf -new file mode 100644 -index 0000000000..47b0811b00 ---- /dev/null -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTestHost.inf -@@ -0,0 +1,28 @@ -+## @file -+# This file builds the unit tests for DxeTpmMeasureBootLib -+# -+# Copyright (C) Microsoft Corporation.
-+# SPDX-License-Identifier: BSD-2-Clause-Patent -+## -+ -+[Defines] -+ INF_VERSION = 0x00010006 -+ BASE_NAME = DxeTpmMeasuredBootLibTest -+ FILE_GUID = eb01bc38-309c-4d3e-967e-9f078c90772f -+ MODULE_TYPE = HOST_APPLICATION -+ VERSION_STRING = 1.0 -+ ENTRY_POINT = main -+ -+[Sources] -+ DxeTpmMeasureBootLibSanitizationTest.c -+ ../DxeTpmMeasureBootLibSanitization.c -+ -+[Packages] -+ MdePkg/MdePkg.dec -+ -+[LibraryClasses] -+ BaseLib -+ DebugLib -+ UnitTestLib -+ PrintLib -+ SafeIntLib -diff --git a/SecurityPkg/SecurityPkg.ci.yaml b/SecurityPkg/SecurityPkg.ci.yaml -index aa8496d6d9..26865cb15a 100644 ---- a/SecurityPkg/SecurityPkg.ci.yaml -+++ b/SecurityPkg/SecurityPkg.ci.yaml -@@ -17,6 +17,7 @@ - "ExceptionList": [ - "8005", "gRT", - "8001", "DxeTpm2MeasureBootLibUnitTestMain", -+ "8001", "DxeTpmMeasureBootLibUnitTestMain" - ], - ## Both file path and directory path are accepted. - "IgnoreFiles": [ -diff --git a/SecurityPkg/Test/SecurityPkgHostTest.dsc b/SecurityPkg/Test/SecurityPkgHostTest.dsc -index 788c1ab6fe..1655e573ea 100644 ---- a/SecurityPkg/Test/SecurityPkgHostTest.dsc -+++ b/SecurityPkg/Test/SecurityPkgHostTest.dsc -@@ -27,6 +27,7 @@ - SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf - SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf - SecurityPkg/Library/DxeTpm2MeasureBootLib/InternalUnitTest/DxeTpm2MeasureBootLibSanitizationTestHost.inf -+ SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTestHost.inf - - # - # Build SecurityPkg HOST_APPLICATION Tests --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4118.patch b/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4118.patch deleted file mode 100644 index 8586c39..0000000 --- a/SOURCES/edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4118.patch +++ /dev/null @@ -1,307 +0,0 @@ -From f6f72373630d901f331df719a0fb55e8f1143c4f Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Wed, 7 Feb 2024 15:43:10 -0500 -Subject: [PATCH 10/17] SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4118 - - CVE 2022-36764 - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [10/13] 5ed702e16f390c79d1abb0ec0b04d886e0094c0b (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21156 -CVE: CVE-2022-36764 -Upstream: Merged -Conflicts: We get function definiton clash for the following three functions: - - SanitizePeImageEventSize() - This is defined both in - - SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitazion.c - and - - SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLibSanitazion.c - Closer investigation reveals that they are identical in functionality (although - not in comment style). - I chose to leave them as is now, meaning that this package will be - unbuildable until I add a commit renaming these symbols later in - this series. - -commit 0d341c01eeabe0ab5e76693b36e728b8f538a40e -Author: Douglas Flick [MSFT] -Date: Fri Jan 12 02:16:05 2024 +0800 - - SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4118 - CVE 2022-36764 - - This commit contains the patch files and tests for DxeTpmMeasureBootLib - CVE 2022-36764. - - Cc: Jiewen Yao - - Signed-off-by: Doug Flick [MSFT] - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../DxeTpmMeasureBootLib.c | 17 ++-- - .../DxeTpmMeasureBootLibSanitization.c | 44 +++++++++ - .../DxeTpmMeasureBootLibSanitization.h | 23 +++++ - .../DxeTpmMeasureBootLibSanitizationTest.c | 98 +++++++++++++++++-- - 4 files changed, 170 insertions(+), 12 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -index d44422dee8..1598015176 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c -@@ -17,6 +17,7 @@ - - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent -+Copyright (c) Microsoft Corporation.
- - Copyright (c) Microsoft Corporation.
- SPDX-License-Identifier: BSD-2-Clause-Patent -@@ -338,19 +339,23 @@ TcgMeasurePeImage ( - ImageLoad = NULL; - SectionHeader = NULL; - Sha1Ctx = NULL; -- FilePathSize = (UINT32) GetDevicePathSize (FilePath); -+ TcgEvent = NULL; -+ FilePathSize = (UINT32)GetDevicePathSize (FilePath); - -- // - // Determine destination PCR by BootPolicy - // -- EventSize = sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize; -- TcgEvent = AllocateZeroPool (EventSize + sizeof (TCG_PCR_EVENT)); -+ Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ if (EFI_ERROR (Status)) { -+ return EFI_UNSUPPORTED; -+ } -+ -+ TcgEvent = AllocateZeroPool (EventSize); - if (TcgEvent == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- TcgEvent->EventSize = EventSize; -- ImageLoad = (EFI_IMAGE_LOAD_EVENT *) TcgEvent->Event; -+ TcgEvent->EventSize = EventSize - sizeof (TCG_PCR_EVENT_HDR); -+ ImageLoad = (EFI_IMAGE_LOAD_EVENT *)TcgEvent->Event; - - switch (ImageType) { - case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION: -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -index 37cd3ed0ea..bcf8c6de6f 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.c -@@ -240,3 +240,47 @@ SanitizePrimaryHeaderGptEventSize ( - return EFI_SUCCESS; - } - -+/** -+ This function will validate that the PeImage Event Size from the loaded image is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ @param[in] FilePathSize - Size of the file path. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePeImageEventSize ( -+ IN UINT32 FilePathSize, -+ OUT UINT32 *EventSize -+ ) -+{ -+ EFI_STATUS Status; -+ -+ // Replacing logic: -+ // sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize; -+ Status = SafeUint32Add (OFFSET_OF (EFI_IMAGE_LOAD_EVENT, DevicePath), FilePathSize, EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "EventSize would overflow!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ // Replacing logic: -+ // EventSize + sizeof (TCG_PCR_EVENT_HDR) -+ Status = SafeUint32Add (*EventSize, sizeof (TCG_PCR_EVENT_HDR), EventSize); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "EventSize would overflow!\n")); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -index 0d9d00c281..2248495813 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLibSanitization.h -@@ -111,4 +111,27 @@ SanitizePrimaryHeaderGptEventSize ( - OUT UINT32 *EventSize - ); - -+/** -+ This function will validate that the PeImage Event Size from the loaded image is sane -+ It will check the following: -+ - EventSize does not overflow -+ -+ @param[in] FilePathSize - Size of the file path. -+ @param[out] EventSize - Pointer to the event size. -+ -+ @retval EFI_SUCCESS -+ The event size is valid. -+ -+ @retval EFI_OUT_OF_RESOURCES -+ Overflow would have occurred. -+ -+ @retval EFI_INVALID_PARAMETER -+ One of the passed parameters was invalid. -+**/ -+EFI_STATUS -+SanitizePeImageEventSize ( -+ IN UINT32 FilePathSize, -+ OUT UINT32 *EventSize -+ ); -+ - #endif // DXE_TPM_MEASURE_BOOT_LIB_VALIDATION_ -diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -index eeb928cdb0..c41498be45 100644 ---- a/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -+++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/InternalUnitTest/DxeTpmMeasureBootLibSanitizationTest.c -@@ -1,8 +1,8 @@ - /** @file --This file includes the unit test cases for the DxeTpmMeasureBootLibSanitizationTest.c. -+ This file includes the unit test cases for the DxeTpmMeasureBootLibSanitizationTest.c. - --Copyright (c) Microsoft Corporation.
--SPDX-License-Identifier: BSD-2-Clause-Patent -+ Copyright (c) Microsoft Corporation.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent - **/ - - #include -@@ -186,9 +186,6 @@ TestSanitizePrimaryHeaderGptEventSize ( - EFI_STATUS Status; - EFI_PARTITION_TABLE_HEADER PrimaryHeader; - UINTN NumberOfPartition; -- EFI_GPT_DATA *GptData; -- -- GptData = NULL; - - // Test that a normal PrimaryHeader passes validation - PrimaryHeader.NumberOfPartitionEntries = 5; -@@ -222,6 +219,94 @@ TestSanitizePrimaryHeaderGptEventSize ( - return UNIT_TEST_PASSED; - } - -+/** -+ This function tests the SanitizePeImageEventSize function. -+ It's intent is to test that the untrusted input from a file path for an -+ EFI_IMAGE_LOAD_EVENT structure will not cause an overflow when calculating -+ the event size when allocating space. -+ -+ @param[in] Context The unit test context. -+ -+ @retval UNIT_TEST_PASSED The test passed. -+ @retval UNIT_TEST_ERROR_TEST_FAILED The test failed. -+**/ -+UNIT_TEST_STATUS -+EFIAPI -+TestSanitizePeImageEventSize ( -+ IN UNIT_TEST_CONTEXT Context -+ ) -+{ -+ UINT32 EventSize; -+ UINTN ExistingLogicEventSize; -+ UINT32 FilePathSize; -+ EFI_STATUS Status; -+ EFI_DEVICE_PATH_PROTOCOL DevicePath; -+ EFI_IMAGE_LOAD_EVENT *ImageLoadEvent; -+ UNIT_TEST_STATUS TestStatus; -+ -+ TestStatus = UNIT_TEST_ERROR_TEST_FAILED; -+ -+ // Generate EFI_DEVICE_PATH_PROTOCOL test data -+ DevicePath.Type = 0; -+ DevicePath.SubType = 0; -+ DevicePath.Length[0] = 0; -+ DevicePath.Length[1] = 0; -+ -+ // Generate EFI_IMAGE_LOAD_EVENT test data -+ ImageLoadEvent = AllocateZeroPool (sizeof (EFI_IMAGE_LOAD_EVENT) + sizeof (EFI_DEVICE_PATH_PROTOCOL)); -+ if (ImageLoadEvent == NULL) { -+ DEBUG ((DEBUG_ERROR, "%a: AllocateZeroPool failed\n", __func__)); -+ goto Exit; -+ } -+ -+ // Populate EFI_IMAGE_LOAD_EVENT54 test data -+ ImageLoadEvent->ImageLocationInMemory = (EFI_PHYSICAL_ADDRESS)0x12345678; -+ ImageLoadEvent->ImageLengthInMemory = 0x1000; -+ ImageLoadEvent->ImageLinkTimeAddress = (UINTN)ImageLoadEvent; -+ ImageLoadEvent->LengthOfDevicePath = sizeof (EFI_DEVICE_PATH_PROTOCOL); -+ CopyMem (ImageLoadEvent->DevicePath, &DevicePath, sizeof (EFI_DEVICE_PATH_PROTOCOL)); -+ -+ FilePathSize = 255; -+ -+ // Test that a normal PE image passes validation -+ Status = SanitizePeImageEventSize (FilePathSize, &EventSize); -+ if (EFI_ERROR (Status)) { -+ UT_LOG_ERROR ("SanitizePeImageEventSize failed with %r\n", Status); -+ goto Exit; -+ } -+ -+ // Test that the event size is correct compared to the existing logic -+ ExistingLogicEventSize = OFFSET_OF (EFI_IMAGE_LOAD_EVENT, DevicePath) + FilePathSize; -+ ExistingLogicEventSize += sizeof (TCG_PCR_EVENT_HDR); -+ -+ if (EventSize != ExistingLogicEventSize) { -+ UT_LOG_ERROR ("SanitizePeImageEventSize returned an incorrect event size. Expected %u, got %u\n", ExistingLogicEventSize, EventSize); -+ goto Exit; -+ } -+ -+ // Test that the event size may not overflow -+ Status = SanitizePeImageEventSize (MAX_UINT32, &EventSize); -+ if (Status != EFI_BAD_BUFFER_SIZE) { -+ UT_LOG_ERROR ("SanitizePeImageEventSize succeded when it was supposed to fail with %r\n", Status); -+ goto Exit; -+ } -+ -+ TestStatus = UNIT_TEST_PASSED; -+Exit: -+ -+ if (ImageLoadEvent != NULL) { -+ FreePool (ImageLoadEvent); -+ } -+ -+ if (TestStatus == UNIT_TEST_ERROR_TEST_FAILED) { -+ DEBUG ((DEBUG_ERROR, "%a: Test failed\n", __func__)); -+ } else { -+ DEBUG ((DEBUG_INFO, "%a: Test passed\n", __func__)); -+ } -+ -+ return TestStatus; -+} -+ - // *--------------------------------------------------------------------* - // * Unit Test Code Main Function - // *--------------------------------------------------------------------* -@@ -265,6 +350,7 @@ UefiTestMain ( - AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Validating EFI Partition Table", "Common.TcgMeasureBootLibValidation", TestSanitizeEfiPartitionTableHeader, NULL, NULL, NULL); - AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Primary header gpt event checks for overflow", "Common.TcgMeasureBootLibValidation", TestSanitizePrimaryHeaderAllocationSize, NULL, NULL, NULL); - AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests Primary header allocation size checks for overflow", "Common.TcgMeasureBootLibValidation", TestSanitizePrimaryHeaderGptEventSize, NULL, NULL, NULL); -+ AddTestCase (TcgMeasureBootLibValidationTestSuite, "Tests PE Image and FileSize checks for overflow", "Common.TcgMeasureBootLibValidation", TestSanitizePeImageEventSize, NULL, NULL, NULL); - - Status = RunAllTestSuites (Framework); - --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch deleted file mode 100644 index dc9a102..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch +++ /dev/null @@ -1,246 +0,0 @@ -From 660ffc1753c84e89281d54059c0cb73eef7200d0 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:27:16 -0400 -Subject: [PATCH 09/31] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support - through ArmTrngLib - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [9/31] 34f5db557b893a686c382a09ceacda728dbd4ad9 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 863fe9e191fb3d90c3283062183692c04cd71975 -Author: Sami Mujawar -Date: Fri Oct 28 17:32:55 2022 +0200 - - SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through ArmTrngLib - - Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668) - - RawAlgorithm is used to provide access to entropy that is suitable - for cryptographic applications. Therefore, add RawAlgorithm support - that provides access to entropy using the ArmTrngLib. - - Also remove unused UefiBootServicesTableLib library inclusion - and Status variable. - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/AArch64/RngDxe.c | 28 ++++++-- - .../RandomNumberGenerator/RngDxe/ArmTrng.c | 71 +++++++++++++++++++ - .../RandomNumberGenerator/RngDxe/RngDxe.inf | 5 ++ - SecurityPkg/SecurityPkg.dsc | 4 ++ - 4 files changed, 104 insertions(+), 4 deletions(-) - create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index c9d66d9777..c0b0d28d48 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -1,11 +1,13 @@ - /** @file - RNG Driver to produce the UEFI Random Number Generator protocol. - -- The driver will use the RNDR instruction to produce random numbers. -+ The driver can use RNDR instruction (through the RngLib and if FEAT_RNG is -+ present) to produce random numbers. It also uses the Arm FW-TRNG interface -+ to implement EFI_RNG_ALGORITHM_RAW. - - RNG Algorithms defined in UEFI 2.4: - - EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID -- - EFI_RNG_ALGORITHM_RAW - Unsupported -+ - EFI_RNG_ALGORITHM_RAW - - EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID - - EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID - - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported -@@ -26,12 +28,14 @@ - #include - #include - #include -+#include -+#include - #include - - #include "RngDxeInternals.h" - - // Maximum number of Rng algorithms. --#define RNG_AVAILABLE_ALGO_MAX 1 -+#define RNG_AVAILABLE_ALGO_MAX 2 - - /** Allocate and initialize mAvailableAlgoArray with the available - Rng algorithms. Also update mAvailableAlgoArrayCount. -@@ -46,8 +50,9 @@ GetAvailableAlgorithms ( - ) - { - UINT64 DummyRand; -+ UINT16 MajorRevision; -+ UINT16 MinorRevision; - -- // Allocate RNG_AVAILABLE_ALGO_MAX entries to avoid evaluating - // Rng algorithms 2 times, one for the allocation, one to populate. - mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); - if (mAvailableAlgoArray == NULL) { -@@ -64,6 +69,16 @@ GetAvailableAlgorithms ( - mAvailableAlgoArrayCount++; - } - -+ // Raw algorithm (Trng) -+ if (!EFI_ERROR (GetArmTrngVersion (&MajorRevision, &MinorRevision))) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ &gEfiRngAlgorithmRaw, -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ } -+ - return EFI_SUCCESS; - } - -@@ -141,6 +156,11 @@ FoundAlgo: - return Status; - } - -+ // Raw algorithm (Trng) -+ if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) { -+ return GenerateEntropy (RNGValueLength, RNGValue); -+ } -+ - // - // Other algorithms are unsupported by this driver. - // -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c -new file mode 100644 -index 0000000000..ffe557b692 ---- /dev/null -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c -@@ -0,0 +1,71 @@ -+/** @file -+ RNG Driver to produce the UEFI Random Number Generator protocol. -+ -+ The driver implements the EFI_RNG_ALGORITHM_RAW using the FW-TRNG -+ interface to provide entropy. -+ -+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
-+ -+ SPDX-License-Identifier: BSD-2-Clause-Patent -+ -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "RngDxeInternals.h" -+ -+/** -+ Generate high-quality entropy source using a TRNG or through RDRAND. -+ -+ @param[in] Length Size of the buffer, in bytes, to fill with. -+ @param[out] Entropy Pointer to the buffer to store the entropy data. -+ -+ @retval RETURN_SUCCESS The function completed successfully. -+ @retval RETURN_INVALID_PARAMETER Invalid parameter. -+ @retval RETURN_UNSUPPORTED Function not implemented. -+ @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. -+ @retval RETURN_NOT_READY No Entropy available. -+**/ -+EFI_STATUS -+EFIAPI -+GenerateEntropy ( -+ IN UINTN Length, -+ OUT UINT8 *Entropy -+ ) -+{ -+ EFI_STATUS Status; -+ UINTN CollectedEntropyBits; -+ UINTN RequiredEntropyBits; -+ UINTN EntropyBits; -+ UINTN Index; -+ UINTN MaxBits; -+ -+ ZeroMem (Entropy, Length); -+ -+ RequiredEntropyBits = (Length << 3); -+ Index = 0; -+ CollectedEntropyBits = 0; -+ MaxBits = GetArmTrngMaxSupportedEntropyBits (); -+ while (CollectedEntropyBits < RequiredEntropyBits) { -+ EntropyBits = MIN ((RequiredEntropyBits - CollectedEntropyBits), MaxBits); -+ Status = GetArmTrngEntropy ( -+ EntropyBits, -+ (Length - Index), -+ &Entropy[Index] -+ ); -+ if (EFI_ERROR (Status)) { -+ // Discard the collected bits. -+ ZeroMem (Entropy, Length); -+ return Status; -+ } -+ -+ CollectedEntropyBits += EntropyBits; -+ Index += (EntropyBits >> 3); -+ } // while -+ -+ return Status; -+} -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index 1985dfbb46..e0e767cbf3 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -43,8 +43,10 @@ - - [Sources.AARCH64] - AArch64/RngDxe.c -+ ArmTrng.c - - [Packages] -+ MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec - SecurityPkg/SecurityPkg.dec - -@@ -57,6 +59,9 @@ - TimerLib - RngLib - -+[LibraryClasses.AARCH64] -+ ArmTrngLib -+ - [Guids] - gEfiRngAlgorithmSp80090Hash256Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG - gEfiRngAlgorithmSp80090Hmac256Guid ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG -diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc -index 73a93c2285..9f58cc2333 100644 ---- a/SecurityPkg/SecurityPkg.dsc -+++ b/SecurityPkg/SecurityPkg.dsc -@@ -3,6 +3,8 @@ - # - # Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
- # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
-+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
-+# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
- # SPDX-License-Identifier: BSD-2-Clause-Patent - # - ## -@@ -86,6 +88,8 @@ - - ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf - -+ ArmTrngLib|MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf -+ - [LibraryClasses.ARM] - RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf - --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch deleted file mode 100644 index 39d41c2..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch +++ /dev/null @@ -1,311 +0,0 @@ -From 0c6e925403e5aa50a77797af59308e6fee4be6b1 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:31:58 -0400 -Subject: [PATCH 12/31] SecurityPkg/RngDxe: Add Arm support of RngDxe - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [12/31] 11b72f6d69392c7b2e8565025a576e76877fe7ed - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 9eb5ccda505917f6ee80284ed6fb5b51aa7152f9 -Author: Pierre Gondois -Date: Fri Oct 28 17:32:58 2022 +0200 - - SecurityPkg/RngDxe: Add Arm support of RngDxe - - Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668) - - Add RngDxe support for Arm. This implementation uses the ArmTrngLib - to support the RawAlgorithm and doens't support the RNDR instruction. - - To re-use the RngGetRNG(), RngGetInfo() and FreeAvailableAlgorithms() - functions, create Arm/AArch64 files which implement the arch specific - function GetAvailableAlgorithms(). Indeed, FEAT_RNG instruction is not - supported on Arm. - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/AArch64/AArch64Algo.c | 72 +++++++++++++++++++ - .../RngDxe/Arm/ArmAlgo.c | 51 +++++++++++++ - .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 60 ---------------- - .../RandomNumberGenerator/RngDxe/RngDxe.inf | 12 +++- - SecurityPkg/SecurityPkg.dsc | 2 +- - 5 files changed, 133 insertions(+), 64 deletions(-) - create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c - create mode 100644 SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c -new file mode 100644 -index 0000000000..e8be217f8a ---- /dev/null -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c -@@ -0,0 +1,72 @@ -+/** @file -+ Aarch64 specific code. -+ -+ Copyright (c) 2022, Arm Limited. All rights reserved.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "RngDxeInternals.h" -+ -+// Maximum number of Rng algorithms. -+#define RNG_AVAILABLE_ALGO_MAX 2 -+ -+/** Allocate and initialize mAvailableAlgoArray with the available -+ Rng algorithms. Also update mAvailableAlgoArrayCount. -+ -+ @retval EFI_SUCCESS The function completed successfully. -+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -+**/ -+EFI_STATUS -+EFIAPI -+GetAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ UINT64 DummyRand; -+ UINT16 MajorRevision; -+ UINT16 MinorRevision; -+ -+ // Rng algorithms 2 times, one for the allocation, one to populate. -+ mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); -+ if (mAvailableAlgoArray == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. -+ if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ PcdGetPtr (PcdCpuRngSupportedAlgorithm), -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ -+ DEBUG_CODE_BEGIN (); -+ if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { -+ DEBUG (( -+ DEBUG_WARN, -+ "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" -+ )); -+ } -+ -+ DEBUG_CODE_END (); -+ } -+ -+ // Raw algorithm (Trng) -+ if (!EFI_ERROR (GetArmTrngVersion (&MajorRevision, &MinorRevision))) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ &gEfiRngAlgorithmRaw, -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ } -+ -+ return EFI_SUCCESS; -+} -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c -new file mode 100644 -index 0000000000..4b24f5c4a6 ---- /dev/null -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c -@@ -0,0 +1,51 @@ -+/** @file -+ Arm specific code. -+ -+ Copyright (c) 2022, Arm Limited. All rights reserved.
-+ SPDX-License-Identifier: BSD-2-Clause-Patent -+**/ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "RngDxeInternals.h" -+ -+// Maximum number of Rng algorithms. -+#define RNG_AVAILABLE_ALGO_MAX 1 -+ -+/** Allocate and initialize mAvailableAlgoArray with the available -+ Rng algorithms. Also update mAvailableAlgoArrayCount. -+ -+ @retval EFI_SUCCESS The function completed successfully. -+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -+**/ -+EFI_STATUS -+EFIAPI -+GetAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ UINT16 MajorRevision; -+ UINT16 MinorRevision; -+ -+ // Rng algorithms 2 times, one for the allocation, one to populate. -+ mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); -+ if (mAvailableAlgoArray == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ // Raw algorithm (Trng) -+ if (!EFI_ERROR (GetArmTrngVersion (&MajorRevision, &MinorRevision))) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ &gEfiRngAlgorithmRaw, -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ } -+ -+ return EFI_SUCCESS; -+} -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -index a800a85792..5e7d9ef681 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -@@ -28,70 +28,10 @@ - #include - #include - #include --#include --#include - #include - - #include "RngDxeInternals.h" - --// Maximum number of Rng algorithms. --#define RNG_AVAILABLE_ALGO_MAX 2 -- --/** Allocate and initialize mAvailableAlgoArray with the available -- Rng algorithms. Also update mAvailableAlgoArrayCount. -- -- @retval EFI_SUCCESS The function completed successfully. -- @retval EFI_OUT_OF_RESOURCES Could not allocate memory. --**/ --EFI_STATUS --EFIAPI --GetAvailableAlgorithms ( -- VOID -- ) --{ -- UINT64 DummyRand; -- UINT16 MajorRevision; -- UINT16 MinorRevision; -- -- // Rng algorithms 2 times, one for the allocation, one to populate. -- mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); -- if (mAvailableAlgoArray == NULL) { -- return EFI_OUT_OF_RESOURCES; -- } -- -- // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. -- if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { -- CopyMem ( -- &mAvailableAlgoArray[mAvailableAlgoArrayCount], -- PcdGetPtr (PcdCpuRngSupportedAlgorithm), -- sizeof (EFI_RNG_ALGORITHM) -- ); -- mAvailableAlgoArrayCount++; -- -- DEBUG_CODE_BEGIN (); -- if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { -- DEBUG (( -- DEBUG_WARN, -- "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" -- )); -- } -- -- DEBUG_CODE_END (); -- } -- -- // Raw algorithm (Trng) -- if (!EFI_ERROR (GetArmTrngVersion (&MajorRevision, &MinorRevision))) { -- CopyMem ( -- &mAvailableAlgoArray[mAvailableAlgoArrayCount], -- &gEfiRngAlgorithmRaw, -- sizeof (EFI_RNG_ALGORITHM) -- ); -- mAvailableAlgoArrayCount++; -- } -- -- return EFI_SUCCESS; --} -- - /** Free mAvailableAlgoArray. - **/ - VOID -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index 1d0bdef57d..c8e0ee4ae5 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -28,7 +28,7 @@ - # - # The following information is for reference only and not required by the build tools. - # --# VALID_ARCHITECTURES = IA32 X64 AARCH64 -+# VALID_ARCHITECTURES = IA32 X64 AARCH64 ARM - # - - [Sources.common] -@@ -41,10 +41,16 @@ - Rand/AesCore.c - Rand/AesCore.h - --[Sources.AARCH64] -+[Sources.AARCH64, Sources.ARM] - ArmRngDxe.c - ArmTrng.c - -+[Sources.AARCH64] -+ AArch64/AArch64Algo.c -+ -+[Sources.ARM] -+ Arm/ArmAlgo.c -+ - [Packages] - MdeModulePkg/MdeModulePkg.dec - MdePkg/MdePkg.dec -@@ -59,7 +65,7 @@ - TimerLib - RngLib - --[LibraryClasses.AARCH64] -+[LibraryClasses.AARCH64, LibraryClasses.ARM] - ArmTrngLib - - [Guids] -diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc -index 9f58cc2333..36493f04ee 100644 ---- a/SecurityPkg/SecurityPkg.dsc -+++ b/SecurityPkg/SecurityPkg.dsc -@@ -281,7 +281,7 @@ - SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf - SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf - --[Components.IA32, Components.X64, Components.AARCH64] -+[Components.IA32, Components.X64, Components.AARCH64, Components.ARM] - # - # Random Number Generator - # --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch deleted file mode 100644 index e146890..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 8b78800fed2a4af7c08eebd20d1bf764e8e10c84 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:28:58 -0400 -Subject: [PATCH 10/31] SecurityPkg/RngDxe: Add debug warning for NULL - PcdCpuRngSupportedAlgorithm - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [10/31] 66b888e9b1e2be0c79784e02b4821854bd80432d - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 6cdddccf0085cf2929f8ae710515e4e53663dfb2 -Author: Pierre Gondois -Date: Fri Oct 28 17:32:56 2022 +0200 - - SecurityPkg/RngDxe: Add debug warning for NULL PcdCpuRngSupportedAlgorithm - - PcdCpuRngSupportedAlgorithm should allow to identify the the algorithm - used by the RNDR CPU instruction to generate a random number. - Add a debug warning if the Pcd is not set. - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index c0b0d28d48..a800a85792 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -67,6 +67,16 @@ GetAvailableAlgorithms ( - sizeof (EFI_RNG_ALGORITHM) - ); - mAvailableAlgoArrayCount++; -+ -+ DEBUG_CODE_BEGIN (); -+ if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { -+ DEBUG (( -+ DEBUG_WARN, -+ "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" -+ )); -+ } -+ -+ DEBUG_CODE_END (); - } - - // Raw algorithm (Trng) --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch deleted file mode 100644 index b285fca..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch +++ /dev/null @@ -1,336 +0,0 @@ -From 5bd27a5a923c8880a06d52fca48e304becbbb8f6 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:25:23 -0400 -Subject: [PATCH 08/31] SecurityPkg/RngDxe: Check before advertising Cpu Rng - algo - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [8/31] 5417b276749a2d1b1afa9465b5b7a501def26a12 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 4b3e9d80bedf5909a4ec901425ed9c0a738fc76f -Author: Pierre Gondois -Date: Fri Oct 28 17:32:54 2022 +0200 - - SecurityPkg/RngDxe: Check before advertising Cpu Rng algo - - RngGetBytes() relies on the RngLib. The RngLib might use the RNDR - instruction if the FEAT_RNG feature is present. RngGetInfo and - RngGetRNG both must check that RngGetBytes() is working before - advertising/using it. - - To do so, allocate an array storing the available algorithms. - The Rng algorithm at the lowest index will be the default Rng - algorithm. The array is shared between RngGetInfo and RngGetRNG. - - This array is allocated when the driver is loaded, and freed - when unloaded. - - This patch also prevents from having PcdCpuRngSupportedAlgorithm - let to a zero GUID, but let the possibility to have no valid Rng - algorithm in such case. - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/AArch64/RngDxe.c | 87 +++++++++++++++++-- - .../RngDxe/Rand/RngDxe.c | 26 ++++++ - .../RandomNumberGenerator/RngDxe/RngDxe.c | 40 ++++++++- - .../RandomNumberGenerator/RngDxe/RngDxe.inf | 1 + - .../RngDxe/RngDxeInternals.h | 27 ++++++ - 5 files changed, 172 insertions(+), 9 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index 8c6ad4ed43..c9d66d9777 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -22,11 +22,63 @@ - - #include - #include -+#include -+#include - #include -+#include - #include - - #include "RngDxeInternals.h" - -+// Maximum number of Rng algorithms. -+#define RNG_AVAILABLE_ALGO_MAX 1 -+ -+/** Allocate and initialize mAvailableAlgoArray with the available -+ Rng algorithms. Also update mAvailableAlgoArrayCount. -+ -+ @retval EFI_SUCCESS The function completed successfully. -+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -+**/ -+EFI_STATUS -+EFIAPI -+GetAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ UINT64 DummyRand; -+ -+ // Allocate RNG_AVAILABLE_ALGO_MAX entries to avoid evaluating -+ // Rng algorithms 2 times, one for the allocation, one to populate. -+ mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); -+ if (mAvailableAlgoArray == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. -+ if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ PcdGetPtr (PcdCpuRngSupportedAlgorithm), -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ } -+ -+ return EFI_SUCCESS; -+} -+ -+/** Free mAvailableAlgoArray. -+**/ -+VOID -+EFIAPI -+FreeAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ FreePool (mAvailableAlgoArray); -+ return; -+} -+ - /** - Produces and returns an RNG value using either the default or specified RNG algorithm. - -@@ -59,6 +111,7 @@ RngGetRNG ( - ) - { - EFI_STATUS Status; -+ UINTN Index; - - if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -68,9 +121,21 @@ RngGetRNG ( - // - // Use the default RNG algorithm if RNGAlgorithm is NULL. - // -- RNGAlgorithm = PcdGetPtr (PcdCpuRngSupportedAlgorithm); -+ for (Index = 0; Index < mAvailableAlgoArrayCount; Index++) { -+ if (!IsZeroGuid (&mAvailableAlgoArray[Index])) { -+ RNGAlgorithm = &mAvailableAlgoArray[Index]; -+ goto FoundAlgo; -+ } -+ } -+ -+ if (Index == mAvailableAlgoArrayCount) { -+ // No algorithm available. -+ ASSERT (Index != mAvailableAlgoArrayCount); -+ return EFI_DEVICE_ERROR; -+ } - } - -+FoundAlgo: - if (CompareGuid (RNGAlgorithm, PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { - Status = RngGetBytes (RNGValueLength, RNGValue); - return Status; -@@ -113,24 +178,30 @@ RngGetInfo ( - OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ) - { -- UINTN RequiredSize; -- EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; -- -- RequiredSize = sizeof (EFI_RNG_ALGORITHM); -+ UINTN RequiredSize; - - if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { - return EFI_INVALID_PARAMETER; - } - -+ RequiredSize = mAvailableAlgoArrayCount * sizeof (EFI_RNG_ALGORITHM); -+ -+ if (RequiredSize == 0) { -+ // No supported algorithms found. -+ return EFI_UNSUPPORTED; -+ } -+ - if (*RNGAlgorithmListSize < RequiredSize) { - *RNGAlgorithmListSize = RequiredSize; - return EFI_BUFFER_TOO_SMALL; - } - -- CpuRngSupportedAlgorithm = PcdGetPtr (PcdCpuRngSupportedAlgorithm); -- -- CopyMem(&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG_ALGORITHM)); -+ if (RNGAlgorithmList == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } - -+ // There is no gap in the array, so copy the block. -+ CopyMem (RNGAlgorithmList, mAvailableAlgoArray, RequiredSize); - *RNGAlgorithmListSize = RequiredSize; - return EFI_SUCCESS; - } -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 70b6ac20c9..7caa64a4ff 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -26,6 +26,32 @@ - - #include "RngDxeInternals.h" - -+/** Allocate and initialize mAvailableAlgoArray with the available -+ Rng algorithms. Also update mAvailableAlgoArrayCount. -+ -+ @retval EFI_SUCCESS The function completed successfully. -+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -+**/ -+EFI_STATUS -+EFIAPI -+GetAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ return EFI_SUCCESS; -+} -+ -+/** Free mAvailableAlgoArray. -+**/ -+VOID -+EFIAPI -+FreeAvailableAlgorithms ( -+ VOID -+ ) -+{ -+ return; -+} -+ - /** - Produces and returns an RNG value using either the default or specified RNG algorithm. - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -index 4599728889..cc2ddfcc06 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -@@ -27,6 +27,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - #include "RngDxeInternals.h" - -+// -+// Array containing the validated Rng algorithm. -+// The entry with the lowest index will be the default algorithm. -+// -+UINTN mAvailableAlgoArrayCount; -+EFI_RNG_ALGORITHM *mAvailableAlgoArray; -+ - // - // The Random Number Generator (RNG) protocol - // -@@ -66,8 +73,39 @@ RngDriverEntry ( - &mRngRdRand, - NULL - ); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ // -+ // Get the list of available algorithm. -+ // -+ return GetAvailableAlgorithms (); -+} -+ -+/** -+ This is the unload handle for RndgDxe module. -+ -+ Disconnect the driver specified by ImageHandle from all the devices in the handle database. -+ Uninstall all the protocols installed in the driver entry point. - -- return Status; -+ @param[in] ImageHandle The drivers' driver image. -+ -+ @retval EFI_SUCCESS The image is unloaded. -+ @retval Others Failed to unload the image. -+ -+**/ -+EFI_STATUS -+EFIAPI -+RngDriverUnLoad ( -+ IN EFI_HANDLE ImageHandle -+ ) -+{ -+ // -+ // Free the list of available algorithm. -+ // -+ FreeAvailableAlgorithms (); -+ return EFI_SUCCESS; - } - - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index 60efb5562e..1985dfbb46 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -22,6 +22,7 @@ - MODULE_TYPE = DXE_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = RngDriverEntry -+ UNLOAD_IMAGE = RngDriverUnLoad - MODULE_UNI_FILE = RngDxe.uni - - # -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -index f17adb83fb..0ef5e6522f 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -@@ -12,6 +12,33 @@ - - #include - -+// -+// Array containing the validated Rng algorithm. -+// The entry with the lowest index will be the default algorithm. -+// -+extern UINTN mAvailableAlgoArrayCount; -+extern EFI_RNG_ALGORITHM *mAvailableAlgoArray; -+ -+/** Allocate and initialize mAvailableAlgoArray with the available -+ Rng algorithms. Also update mAvailableAlgoArrayCount. -+ -+ @retval EFI_SUCCESS The function completed successfully. -+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -+**/ -+EFI_STATUS -+EFIAPI -+GetAvailableAlgorithms ( -+ VOID -+ ); -+ -+/** Free mAvailableAlgoArray. -+**/ -+VOID -+EFIAPI -+FreeAvailableAlgorithms ( -+ VOID -+ ); -+ - /** - Returns information about the random number generation implementation. - --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch deleted file mode 100644 index 918fe39..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch +++ /dev/null @@ -1,79 +0,0 @@ -From e7444d0b84a8fd41aa63ecb083e65fd56b32fd38 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Sun, 23 Jun 2024 14:21:01 -0400 -Subject: [PATCH 14/31] SecurityPkg/RngDxe: Conditionally install - EFI_RNG_PROTOCOL - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [14/31] bc64d4cad6c30353723d674ef9f10eb10aeb1cac - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 75fb0cfc82376906243386514be0e4067d702117 -Author: Pierre Gondois -Date: Thu Nov 24 17:17:55 2022 +0100 - - SecurityPkg/RngDxe: Conditionally install EFI_RNG_PROTOCOL - - On Arm platforms, the number of available RNG algorithms is - dynamically detected and can be 0 in the absence of FEAT_RNG - and firmware TRNG. - In this case, the EFI_RNG_PROTOCOL should not be installed to - prevent from installing an empty protocol. - - Signed-off-by: Pierre Gondois - [ardb: return EFI_REQUEST_UNLOAD_IMAGE instead of an error] - Reviewed-by: Ard Biesheuvel - -Signed-off-by: Jon Maloy ---- - .../RandomNumberGenerator/RngDxe/RngDxe.c | 19 ++++++++++++++----- - 1 file changed, 14 insertions(+), 5 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -index cc2ddfcc06..55e8dd49d0 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -@@ -63,6 +63,18 @@ RngDriverEntry ( - EFI_STATUS Status; - EFI_HANDLE Handle; - -+ // -+ // Get the list of available algorithm. -+ // -+ Status = GetAvailableAlgorithms (); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ if (mAvailableAlgoArrayCount == 0) { -+ return EFI_REQUEST_UNLOAD_IMAGE; -+ } -+ - // - // Install UEFI RNG (Random Number Generator) Protocol - // -@@ -74,13 +86,10 @@ RngDriverEntry ( - NULL - ); - if (EFI_ERROR (Status)) { -- return Status; -+ FreeAvailableAlgorithms (); - } - -- // -- // Get the list of available algorithm. -- // -- return GetAvailableAlgorithms (); -+ return Status; - } - - /** --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch deleted file mode 100644 index 8384f2f..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch +++ /dev/null @@ -1,105 +0,0 @@ -From b9a937603080bfada6c224a6e9da046a8a33f868 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Sun, 23 Jun 2024 14:18:18 -0400 -Subject: [PATCH 13/31] SecurityPkg/RngDxe: Correctly update - mAvailableAlgoArrayCount - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [13/31] 3e06e270cad90038537305a4cb7828fcc45251fb - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit bfb574db110899471fe09db819587b3151c7b7b5 -Author: Pierre Gondois -Date: Thu Nov 24 17:17:54 2022 +0100 - - SecurityPkg/RngDxe: Correctly update mAvailableAlgoArrayCount - - mAvailableAlgoArrayCount holds the count of available RNG algorithms. - In a following patch, its value will be used to prevent the - EFI_RNG_PROTOCOL to be installed if no RNG algorithm is available. - - Correctly set/reset the value for all implementations. - - Signed-off-by: Pierre Gondois - Reviewed-by: Ard Biesheuvel - -Signed-off-by: Jon Maloy ---- - .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 1 + - .../RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 16 ++++++++++++++-- - 2 files changed, 15 insertions(+), 2 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -index 5e7d9ef681..0e44d0c931 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -@@ -40,6 +40,7 @@ FreeAvailableAlgorithms ( - VOID - ) - { -+ mAvailableAlgoArrayCount = 0; - FreePool (mAvailableAlgoArray); - return; - } -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 7caa64a4ff..149de875ce 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -26,6 +26,11 @@ - - #include "RngDxeInternals.h" - -+// -+// Count of Rng algorithms. -+// -+#define RNG_ALGORITHM_COUNT 2 -+ - /** Allocate and initialize mAvailableAlgoArray with the available - Rng algorithms. Also update mAvailableAlgoArrayCount. - -@@ -38,6 +43,13 @@ GetAvailableAlgorithms ( - VOID - ) - { -+ -+ UINT64 RngTest; -+ -+ if (GetRandomNumber64 (&RngTest)) { -+ mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT; -+ } -+ - return EFI_SUCCESS; - } - -@@ -49,6 +61,7 @@ FreeAvailableAlgorithms ( - VOID - ) - { -+ mAvailableAlgoArrayCount = 0; - return; - } - -@@ -159,13 +172,12 @@ RngGetInfo ( - ) - { - UINTN RequiredSize; -- EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; - - if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { - return EFI_INVALID_PARAMETER; - } - -- RequiredSize = 2 * sizeof (EFI_RNG_ALGORITHM); -+ RequiredSize = RNG_ALGORITHM_COUNT * sizeof (EFI_RNG_ALGORITHM); - - if (*RNGAlgorithmListSize < RequiredSize) { - *RNGAlgorithmListSize = RequiredSize; --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch deleted file mode 100644 index 7f87bbc..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 0f8890578f46bc791d007b19dbbfa0dd2805032d Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:23:42 -0400 -Subject: [PATCH 07/31] SecurityPkg/RngDxe: Documentation/include/parameter - cleanup - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [7/31] 19a0a13d18fc7f92c7b05e8da08f4d83df77ea6c - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 199031b2b0233652ad5d5fdf73f0f44c0f264d55 -Author: Pierre Gondois -Date: Fri Oct 28 17:32:53 2022 +0200 - - SecurityPkg/RngDxe: Documentation/include/parameter cleanup - - This patch: - -Update RngGetBytes() documentation to align the function - definition and declaration. - -Improve input parameter checking. Even though 'This' - it is not used, the parameter should always point to the - current EFI_RNG_PROTOCOL. - -Removes TimerLib inclusion as unused. - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 3 +-- - SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 2 +- - SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 3 +-- - 3 files changed, 3 insertions(+), 5 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index f6a0bf7b2b..8c6ad4ed43 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -23,7 +23,6 @@ - #include - #include - #include --#include - #include - - #include "RngDxeInternals.h" -@@ -61,7 +60,7 @@ RngGetRNG ( - { - EFI_STATUS Status; - -- if ((RNGValueLength == 0) || (RNGValue == NULL)) { -+ if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { - return EFI_INVALID_PARAMETER; - } - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 5a649ecf24..70b6ac20c9 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -59,7 +59,7 @@ RngGetRNG ( - { - EFI_STATUS Status; - -- if ((RNGValueLength == 0) || (RNGValue == NULL)) { -+ if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { - return EFI_INVALID_PARAMETER; - } - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -index 7b8ecfc70d..4599728889 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -@@ -23,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - #include --#include - #include - - #include "RngDxeInternals.h" -@@ -73,7 +72,7 @@ RngDriverEntry ( - - - /** -- Calls RDRAND to fill a buffer of arbitrary size with random bytes. -+ Runs CPU RNG instruction to fill a buffer of arbitrary size with random bytes. - - @param[in] Length Size of the buffer, in bytes, to fill with. - @param[out] RandBuffer Pointer to the buffer to store the random result. --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch deleted file mode 100644 index 4c5f254..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch +++ /dev/null @@ -1,258 +0,0 @@ -From df912b4c93cd848991d9a9439d3aba441bae1d67 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:21:09 -0400 -Subject: [PATCH 06/31] SecurityPkg/RngDxe: Remove - ArchGetSupportedRngAlgorithms() - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [6/31] 4066cb1503b5c5a29b6d45a4b671d0829f2671ae - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 922bf317f1731554b3e77a0a48033a38fdc75a77 -Author: Pierre Gondois -Date: Fri Oct 28 17:32:52 2022 +0200 - - SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() - - RngGetInfo() is one of the 2 functions of the EFI_RNG_PROTOCOL. - RngGetInfo() is currently a mere wrapper around - ArchGetSupportedRngAlgorithms() which is implemented differently - depending on the architecture used. - - RngGetInfo() does nothing more than calling - ArchGetSupportedRngAlgorithms(). So remove it, and let RngGetInfo() - be implemented differently according to the architecture. - - This follows the implementation of the other function of the - EFI_RNG_PROTOCOL, RngGetRNG(). - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/AArch64/RngDxe.c | 19 +++++-- - .../RngDxe/Rand/RngDxe.c | 24 ++++++--- - .../RandomNumberGenerator/RngDxe/RngDxe.c | 49 ------------------- - .../RngDxe/RngDxeInternals.h | 25 ---------- - 4 files changed, 33 insertions(+), 84 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -index 1cdc842966..f6a0bf7b2b 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -@@ -14,6 +14,7 @@ - Copyright (c) 2021, NUVIA Inc. All rights reserved.
- Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
-+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -@@ -85,6 +86,7 @@ RngGetRNG ( - /** - Returns information about the random number generation implementation. - -+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance. - @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList. - On output with a return code of EFI_SUCCESS, the size - in bytes of the data returned in RNGAlgorithmList. On output -@@ -97,14 +99,19 @@ RngGetRNG ( - is the default algorithm for the driver. - - @retval EFI_SUCCESS The RNG algorithm list was returned successfully. -+ @retval EFI_UNSUPPORTED The services is not supported by this driver. -+ @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a -+ hardware or firmware error. -+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. - @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. - - **/ --UINTN -+EFI_STATUS - EFIAPI --ArchGetSupportedRngAlgorithms ( -- IN OUT UINTN *RNGAlgorithmListSize, -- OUT EFI_RNG_ALGORITHM *RNGAlgorithmList -+RngGetInfo ( -+ IN EFI_RNG_PROTOCOL *This, -+ IN OUT UINTN *RNGAlgorithmListSize, -+ OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ) - { - UINTN RequiredSize; -@@ -112,6 +119,10 @@ ArchGetSupportedRngAlgorithms ( - - RequiredSize = sizeof (EFI_RNG_ALGORITHM); - -+ if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ - if (*RNGAlgorithmListSize < RequiredSize) { - *RNGAlgorithmListSize = RequiredSize; - return EFI_BUFFER_TOO_SMALL; -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 19755b3bfd..5a649ecf24 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -104,6 +104,7 @@ RngGetRNG ( - /** - Returns information about the random number generation implementation. - -+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance. - @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList. - On output with a return code of EFI_SUCCESS, the size - in bytes of the data returned in RNGAlgorithmList. On output -@@ -116,19 +117,28 @@ RngGetRNG ( - is the default algorithm for the driver. - - @retval EFI_SUCCESS The RNG algorithm list was returned successfully. -+ @retval EFI_UNSUPPORTED No supported algorithms found. -+ @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a -+ hardware or firmware error. -+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. - @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. - - **/ --UINTN -+EFI_STATUS - EFIAPI --ArchGetSupportedRngAlgorithms ( -- IN OUT UINTN *RNGAlgorithmListSize, -- OUT EFI_RNG_ALGORITHM *RNGAlgorithmList -+RngGetInfo ( -+ IN EFI_RNG_PROTOCOL *This, -+ IN OUT UINTN *RNGAlgorithmListSize, -+ OUT EFI_RNG_ALGORITHM *RNGAlgorithmList - ) - { - UINTN RequiredSize; - EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; - -+ if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { -+ return EFI_INVALID_PARAMETER; -+ } -+ - RequiredSize = 2 * sizeof (EFI_RNG_ALGORITHM); - - if (*RNGAlgorithmListSize < RequiredSize) { -@@ -136,9 +146,11 @@ ArchGetSupportedRngAlgorithms ( - return EFI_BUFFER_TOO_SMALL; - } - -- CpuRngSupportedAlgorithm = PcdGetPtr (PcdCpuRngSupportedAlgorithm); -+ if (RNGAlgorithmList == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } - -- CopyMem(&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG_ALGORITHM)); -+ CopyMem (&RNGAlgorithmList[0], &gEfiRngAlgorithmSp80090Ctr256Guid, sizeof (EFI_RNG_ALGORITHM)); - - // x86 platforms also support EFI_RNG_ALGORITHM_RAW via RDSEED - CopyMem(&RNGAlgorithmList[1], &gEfiRngAlgorithmRaw, sizeof (EFI_RNG_ALGORITHM)); -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -index b959c70536..7b8ecfc70d 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c -@@ -28,55 +28,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - #include "RngDxeInternals.h" - --/** -- Returns information about the random number generation implementation. -- -- @param[in] This A pointer to the EFI_RNG_PROTOCOL instance. -- @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList. -- On output with a return code of EFI_SUCCESS, the size -- in bytes of the data returned in RNGAlgorithmList. On output -- with a return code of EFI_BUFFER_TOO_SMALL, -- the size of RNGAlgorithmList required to obtain the list. -- @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver -- with one EFI_RNG_ALGORITHM element for each supported -- RNG algorithm. The list must not change across multiple -- calls to the same driver. The first algorithm in the list -- is the default algorithm for the driver. -- -- @retval EFI_SUCCESS The RNG algorithm list was returned successfully. -- @retval EFI_UNSUPPORTED The services is not supported by this driver. -- @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a -- hardware or firmware error. -- @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect. -- @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. -- --**/ --EFI_STATUS --EFIAPI --RngGetInfo ( -- IN EFI_RNG_PROTOCOL *This, -- IN OUT UINTN *RNGAlgorithmListSize, -- OUT EFI_RNG_ALGORITHM *RNGAlgorithmList -- ) --{ -- EFI_STATUS Status; -- -- if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { -- return EFI_INVALID_PARAMETER; -- } -- -- // -- // Return algorithm list supported by driver. -- // -- if (RNGAlgorithmList != NULL) { -- Status = ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlgorithmList); -- } else { -- Status = EFI_INVALID_PARAMETER; -- } -- -- return Status; --} -- - // - // The Random Number Generator (RNG) protocol - // -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -index fcb8b69153..f17adb83fb 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -@@ -74,31 +74,6 @@ RngGetRNG ( - OUT UINT8 *RNGValue - ); - --/** -- Returns information about the random number generation implementation. -- -- @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList. -- On output with a return code of EFI_SUCCESS, the size -- in bytes of the data returned in RNGAlgorithmList. On output -- with a return code of EFI_BUFFER_TOO_SMALL, -- the size of RNGAlgorithmList required to obtain the list. -- @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver -- with one EFI_RNG_ALGORITHM element for each supported -- RNG algorithm. The list must not change across multiple -- calls to the same driver. The first algorithm in the list -- is the default algorithm for the driver. -- -- @retval EFI_SUCCESS The RNG algorithm list was returned successfully. -- @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. -- --**/ --UINTN --EFIAPI --ArchGetSupportedRngAlgorithms ( -- IN OUT UINTN *RNGAlgorithmListSize, -- OUT EFI_RNG_ALGORITHM *RNGAlgorithmList -- ); -- - /** - Runs CPU RNG instruction to fill a buffer of arbitrary size with random bytes. - --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch deleted file mode 100644 index 0033755..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 05ffe3749d73942cf4df7ed8f53ae239e62d5376 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:30:19 -0400 -Subject: [PATCH 11/31] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [11/31] 39c8a7a1e45c7c26f5d16f79d81abac1fbae4f22 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit ff29cdb968a1a4d7bd7ab4eba2597a77c0748dc2 -Author: Pierre Gondois -Date: Fri Oct 28 17:32:57 2022 +0200 - - SecurityPkg/RngDxe: Rename AArch64/RngDxe.c - - To re-use the AArch64/RngDxe.c for an Arm implementation, - rename AArch64/RngDxe.c to ArmRngDxe.c. - - Acked-by: Leif Lindholm - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/{AArch64/RngDxe.c => ArmRngDxe.c} | 0 - SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 2 +- - 2 files changed, 1 insertion(+), 1 deletion(-) - rename SecurityPkg/RandomNumberGenerator/RngDxe/{AArch64/RngDxe.c => ArmRngDxe.c} (100%) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -similarity index 100% -rename from SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c -rename to SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index e0e767cbf3..1d0bdef57d 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -42,7 +42,7 @@ - Rand/AesCore.h - - [Sources.AARCH64] -- AArch64/RngDxe.c -+ ArmRngDxe.c - ArmTrng.c - - [Packages] --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch deleted file mode 100644 index dea7b6e..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch +++ /dev/null @@ -1,176 +0,0 @@ -From 2a5e4e144cbea46784fde638765a9c9068ed2869 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 25 Jun 2024 22:19:10 -0400 -Subject: [PATCH 05/31] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to - generic name - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [5/31] 12b8646964435f1a70def57afb9f4565b11c5dc8 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -CVE: CVE-2022-45237 -Upstream: Merged - -commit 8a89747844a5061791e55a25daedcf895180a794 -Author: Sami Mujawar -Date: Fri Oct 28 17:32:50 2022 +0200 - - SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name - - Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668) - - Rename RdRandGenerateEntropy() to GenerateEntropy() to provide a - common interface to generate entropy on other architectures. - GenerateEntropy() is intended to generate high quality entropy. - - Also move the definition to RngDxeInternals.h - - Signed-off-by: Pierre Gondois - Acked-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - .../RngDxe/Rand/RdRand.c | 20 ++++++++++++----- - .../RngDxe/Rand/RngDxe.c | 7 ++++-- - .../RandomNumberGenerator/RngDxe/RngDxe.inf | 2 +- - .../RngDxe/RngDxeInternals.h | 22 ++++++++++++++++++- - 4 files changed, 41 insertions(+), 10 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c -index 83025a47d4..853bf43148 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c -@@ -1,15 +1,23 @@ - /** @file -- Support routines for RDRAND instruction access. -- -+ Support routines for RDRAND instruction access, which will leverage -+ Intel Secure Key technology to provide high-quality random numbers for use -+ in applications, or entropy for seeding other random number generators. -+ Refer to http://software.intel.com/en-us/articles/intel-digital-random-number -+ -generator-drng-software-implementation-guide/ for more information about Intel -+ Secure Key technology. -+ -+Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
- Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ -+#include -+#include - #include -+#include - - #include "AesCore.h" --#include "RdRand.h" - #include "RngDxeInternals.h" - - /** -@@ -87,9 +95,9 @@ RdRandGetSeed128 ( - **/ - EFI_STATUS - EFIAPI --RdRandGenerateEntropy ( -- IN UINTN Length, -- OUT UINT8 *Entropy -+GenerateEntropy ( -+ IN UINTN Length, -+ OUT UINT8 *Entropy - ) - { - EFI_STATUS Status; -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 834123b945..19755b3bfd 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -14,13 +14,16 @@ - - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported - - EFI_RNG_ALGORITHM_X9_31_AES_GUID - Unsupported - -+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
- Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
- SPDX-License-Identifier: BSD-2-Clause-Patent - - **/ - --#include "RdRand.h" -+#include -+#include -+ - #include "RngDxeInternals.h" - - /** -@@ -88,7 +91,7 @@ RngGetRNG ( - return EFI_INVALID_PARAMETER; - } - -- Status = RdRandGenerateEntropy (RNGValueLength, RNGValue); -+ Status = GenerateEntropy (RNGValueLength, RNGValue); - return Status; - } - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index f330097199..60efb5562e 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -10,6 +10,7 @@ - # - # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
- # (C) Copyright 2015 Hewlett Packard Enterprise Development LP
-+# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
- # SPDX-License-Identifier: BSD-2-Clause-Patent - # - ## -@@ -36,7 +37,6 @@ - [Sources.IA32, Sources.X64] - Rand/RngDxe.c - Rand/RdRand.c -- Rand/RdRand.h - Rand/AesCore.c - Rand/AesCore.h - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -index 25cccbe92c..fcb8b69153 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h -@@ -10,6 +10,8 @@ - #ifndef RNGDXE_INTERNALS_H_ - #define RNGDXE_INTERNALS_H_ - -+#include -+ - /** - Returns information about the random number generation implementation. - -@@ -114,4 +116,22 @@ RngGetBytes ( - OUT UINT8 *RandBuffer - ); - --#endif // RNGDXE_INTERNALS_H_ -+/** -+ Generate high-quality entropy source using a TRNG or through RDRAND. -+ -+ @param[in] Length Size of the buffer, in bytes, to fill with. -+ @param[out] Entropy Pointer to the buffer to store the entropy data. -+ -+ @retval EFI_SUCCESS Entropy generation succeeded. -+ @retval EFI_NOT_READY Failed to request random data. -+ -+**/ -+EFI_STATUS -+EFIAPI -+GenerateEntropy ( -+ IN UINTN Length, -+ OUT UINT8 *Entropy -+ ); -+ -+#endif // RNGDXE_INTERNALS_H_ -+ --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch deleted file mode 100644 index f00f461..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 1a0bf45b088e05f6eb7edaa0d24aec894ea3491b Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:11:16 -0400 -Subject: [PATCH 23/31] SecurityPkg/RngDxe: Simplify Rng algorithm selection - for Arm - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [23/31] 21b2854eed63bf5d406cfec5ac03b9ae3901a679 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit ff7ddc02b273f9159ef46fdb67d99062f8e598d9 -Author: Pierre Gondois -Date: Fri Aug 11 16:33:10 2023 +0200 - - SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm - - The first element of mAvailableAlgoArray is defined as the default - Rng algorithm to use. Don't go through the array at each RngGetRNG() - call and just return the first element of the array. - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Acked-by: Jiewen Yao - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 17 ++++------------- - 1 file changed, 4 insertions(+), 13 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -index 2fc36fc186..7249904413 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -@@ -77,7 +77,6 @@ RngGetRNG ( - ) - { - EFI_STATUS Status; -- UINTN Index; - GUID RngGuid; - - if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { -@@ -88,21 +87,13 @@ RngGetRNG ( - // - // Use the default RNG algorithm if RNGAlgorithm is NULL. - // -- for (Index = 0; Index < mAvailableAlgoArrayCount; Index++) { -- if (!IsZeroGuid (&mAvailableAlgoArray[Index])) { -- RNGAlgorithm = &mAvailableAlgoArray[Index]; -- goto FoundAlgo; -- } -- } -- -- if (Index == mAvailableAlgoArrayCount) { -- // No algorithm available. -- ASSERT (Index != mAvailableAlgoArrayCount); -- return EFI_DEVICE_ERROR; -+ if (mAvailableAlgoArrayCount != 0) { -+ RNGAlgorithm = &mAvailableAlgoArray[0]; -+ } else { -+ return EFI_UNSUPPORTED; - } - } - --FoundAlgo: - Status = GetRngGuid (&RngGuid); - if (!EFI_ERROR (Status) && - CompareGuid (RNGAlgorithm, &RngGuid)) --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch b/SOURCES/edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch deleted file mode 100644 index 79b5293..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 6b3795dcecf31b0d8aa7edabeffccf37b7259ff0 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:09:46 -0400 -Subject: [PATCH 22/31] SecurityPkg/RngDxe: Use GetRngGuid() when probing - RngLib - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [22/31] 17b40bc3daeba2ba8407826e17f3096c4a5151c6 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 19438cff973bfb35a1ef12fab45fabb28b63fe64 -Author: Pierre Gondois -Date: Fri Aug 11 16:33:09 2023 +0200 - - SecurityPkg/RngDxe: Use GetRngGuid() when probing RngLib - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4151 - - The EFI_RNG_PROTOCOL can rely on the RngLib. The RngLib has multiple - implementations, some of them are unsafe (e.g. BaseRngLibTimerLib). - To allow the RngDxe to detect when such implementation is used, - a GetRngGuid() function was added in a previous patch. - - The EFI_RNG_PROTOCOL can advertise multiple algorithms through - Guids. The PcdCpuRngSupportedAlgorithm is currently used to - advertise the RngLib in the Arm implementation. - - The issues of doing that are: - - the RngLib implementation might not use CPU instructions, - cf. the BaseRngLibTimerLib - - most platforms don't set PcdCpuRngSupportedAlgorithm - - A GetRngGuid() was added to the RngLib in a previous patch, - allowing to identify the algorithm implemented by the RngLib. - Make use of this function and place the unsage algorithm - at the last position in the mAvailableAlgoArray. - - Signed-off-by: Pierre Gondois - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Acked-by: Jiewen Yao - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - .../RngDxe/AArch64/AArch64Algo.c | 55 +++++++++++++------ - .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 8 ++- - .../RandomNumberGenerator/RngDxe/RngDxe.inf | 4 +- - 3 files changed, 45 insertions(+), 22 deletions(-) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c -index e8be217f8a..a270441ebb 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c -@@ -10,6 +10,8 @@ - #include - #include - #include -+#include -+#include - - #include "RngDxeInternals.h" - -@@ -28,9 +30,13 @@ GetAvailableAlgorithms ( - VOID - ) - { -- UINT64 DummyRand; -- UINT16 MajorRevision; -- UINT16 MinorRevision; -+ EFI_STATUS Status; -+ UINT16 MajorRevision; -+ UINT16 MinorRevision; -+ GUID RngGuid; -+ BOOLEAN UnSafeAlgo; -+ -+ UnSafeAlgo = FALSE; - - // Rng algorithms 2 times, one for the allocation, one to populate. - mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); -@@ -38,24 +44,29 @@ GetAvailableAlgorithms ( - return EFI_OUT_OF_RESOURCES; - } - -- // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. -- if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) { -- CopyMem ( -- &mAvailableAlgoArray[mAvailableAlgoArrayCount], -- PcdGetPtr (PcdCpuRngSupportedAlgorithm), -- sizeof (EFI_RNG_ALGORITHM) -- ); -- mAvailableAlgoArrayCount++; -- -- DEBUG_CODE_BEGIN (); -- if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { -+ // Identify RngLib algorithm. -+ Status = GetRngGuid (&RngGuid); -+ if (!EFI_ERROR (Status)) { -+ if (IsZeroGuid (&RngGuid) || -+ CompareGuid (&RngGuid, &gEdkiiRngAlgorithmUnSafe)) -+ { -+ // Treat zero GUID as an unsafe algorithm - DEBUG (( - DEBUG_WARN, -- "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n" -+ "RngLib uses an Unsafe algorithm and " -+ "must not be used for production builds.\n" - )); -+ // Set the UnSafeAlgo flag to indicate an unsafe algorithm was found -+ // so that it can be added at the end of the algorithm list. -+ UnSafeAlgo = TRUE; -+ } else { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ &RngGuid, -+ sizeof (RngGuid) -+ ); -+ mAvailableAlgoArrayCount++; - } -- -- DEBUG_CODE_END (); - } - - // Raw algorithm (Trng) -@@ -68,5 +79,15 @@ GetAvailableAlgorithms ( - mAvailableAlgoArrayCount++; - } - -+ // Add unsafe algorithm at the end of the list. -+ if (UnSafeAlgo) { -+ CopyMem ( -+ &mAvailableAlgoArray[mAvailableAlgoArrayCount], -+ &gEdkiiRngAlgorithmUnSafe, -+ sizeof (EFI_RNG_ALGORITHM) -+ ); -+ mAvailableAlgoArrayCount++; -+ } -+ - return EFI_SUCCESS; - } -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -index 0e44d0c931..2fc36fc186 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c -@@ -76,8 +76,9 @@ RngGetRNG ( - OUT UINT8 *RNGValue - ) - { -- EFI_STATUS Status; -+ EFI_STATUS Status; - UINTN Index; -+ GUID RngGuid; - - if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { - return EFI_INVALID_PARAMETER; -@@ -102,7 +103,10 @@ RngGetRNG ( - } - - FoundAlgo: -- if (CompareGuid (RNGAlgorithm, PcdGetPtr (PcdCpuRngSupportedAlgorithm))) { -+ Status = GetRngGuid (&RngGuid); -+ if (!EFI_ERROR (Status) && -+ CompareGuid (RNGAlgorithm, &RngGuid)) -+ { - Status = RngGetBytes (RNGValueLength, RNGValue); - return Status; - } -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index d6c2d30195..8704a64441 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -75,13 +75,11 @@ - gEfiRngAlgorithmX9313DesGuid ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG - gEfiRngAlgorithmX931AesGuid ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG - gEfiRngAlgorithmRaw ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG -+ gEdkiiRngAlgorithmUnSafe ## SOMETIMES_PRODUCES ## GUID # Unique ID of the algorithm for RNG - - [Protocols] - gEfiRngProtocolGuid ## PRODUCES - --[Pcd.AARCH64] -- gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm ## CONSUMES -- - [Depex] - TRUE - --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-RngDxe-add-rng-test.patch b/SOURCES/edk2-SecurityPkg-RngDxe-add-rng-test.patch deleted file mode 100644 index 0395b30..0000000 --- a/SOURCES/edk2-SecurityPkg-RngDxe-add-rng-test.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 5022087de4a4bcd113ef0325e657bd78b798d5f6 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 10:33:43 -0400 -Subject: [PATCH 26/31] SecurityPkg/RngDxe: add rng test - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [26/31] 97c8deefd351f2755cf458f10679dd1d859fb321 - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit a61bc0accb8a76edba4f073fdc7bafc908df045d -Author: Gerd Hoffmann -Date: Fri May 31 09:49:13 2024 +0200 - - SecurityPkg/RngDxe: add rng test - - Check whenever RngLib actually returns random numbers, only return - a non-zero number of Algorithms if that is the case. - - This has the effect that RndDxe loads and installs EFI_RNG_PROTOCOL - only in case it can actually deliver random numbers. - - Signed-off-by: Gerd Hoffmann - -Signed-off-by: Jon Maloy - -Check whenever RngLib actually returns random numbers, only return -a non-zero number of Algorithms if that is the case. - -This has the effect that RndDxe loads and installs EFI_RNG_PROTOCOL -only in case it can actually deliver random numbers. - -Signed-off-by: Gerd Hoffmann ---- - SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -index 149de875ce..e374b62208 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c -@@ -23,6 +23,7 @@ - - #include - #include -+#include - - #include "RngDxeInternals.h" - --- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch b/SOURCES/edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch deleted file mode 100644 index d0fb89e..0000000 --- a/SOURCES/edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 1548ea758f7d9d58fd61110f5719cc12786380d3 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Thu, 20 Jun 2024 16:01:08 -0400 -Subject: [PATCH 17/31] SecurityPkg/SecurityPkg.dec: Move - PcdCpuRngSupportedAlgorithm to MdePkg - -RH-Author: Jon Maloy -RH-MergeRequest: 77: UINT32 overflow in S3 ResumeCount and Pixiefail fixes -RH-Jira: RHEL-21854 RHEL-21856 RHEL-40099 -RH-Acked-by: Gerd Hoffmann -RH-Commit: [17/31] 01f31c97f800f3451072762c0e9a9eb59f1cc2ab - -JIRA: https://issues.redhat.com/browse/RHEL-21856 -Upstream: Merged -CVE: CVE-2023-45237 - -commit 65b5dd828ef2ea5056031b239a4e7a6642f771a3 -Author: Pierre Gondois -Date: Fri Aug 11 16:33:04 2023 +0200 - - SecurityPkg/SecurityPkg.dec: Move PcdCpuRngSupportedAlgorithm to MdePkg - - In order to use PcdCpuRngSupportedAlgorithm in the MdePkg in a - following patch and to avoid making the MdePkg dependent on another - package, move PcdCpuRngSupportedAlgorithm to the MdePkg. - - As the Pcd is only used for AARCH64, place it in an AARCH64 - specific sections. - - Signed-off-by: Pierre Gondois - Reviewed-by: Liming Gao - Reviewed-by: Sami Mujawar - Acked-by: Ard Biesheuvel - Acked-by: Jiewen Yao - Tested-by: Kun Qin - -Signed-off-by: Jon Maloy ---- - .../Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 2 +- - MdePkg/MdePkg.dec | 5 +++++ - SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 4 ++-- - SecurityPkg/SecurityPkg.dec | 2 -- - 4 files changed, 8 insertions(+), 5 deletions(-) - -diff --git a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -index f857290e82..f729001060 100644 ---- a/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -+++ b/MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf -@@ -19,7 +19,7 @@ - INF_VERSION = 1.27 - BASE_NAME = BaseRngLibTimerLib - MODULE_UNI_FILE = BaseRngLibTimerLib.uni -- FILE_GUID = 74950C45-10FC-4AB5-B114-49C87C17409B -+ FILE_GUID = B3E66B05-D218-4B9A-AC33-EF0F83D6A513 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = RngLib -diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec -index 6389a48338..8f05e822ac 100644 ---- a/MdePkg/MdePkg.dec -+++ b/MdePkg/MdePkg.dec -@@ -2306,6 +2306,11 @@ - # @Prompt Memory Address of GuidedExtractHandler Table. - gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000000|UINT64|0x30001015 - -+[PcdsFixedAtBuild.AARCH64, PcdsPatchableInModule.AARCH64] -+ ## GUID identifying the Rng algorithm implemented by CPU instruction. -+ # @Prompt CPU Rng algorithm's GUID. -+ gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00000037 -+ - [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] - ## This value is used to set the base address of PCI express hierarchy. - # @Prompt PCI Express Base Address. -diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -index c8e0ee4ae5..d6c2d30195 100644 ---- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf -@@ -79,8 +79,8 @@ - [Protocols] - gEfiRngProtocolGuid ## PRODUCES - --[Pcd] -- gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm ## CONSUMES -+[Pcd.AARCH64] -+ gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm ## CONSUMES - - [Depex] - TRUE -diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec -index 9f7a032d60..8cf80b1e84 100644 ---- a/SecurityPkg/SecurityPkg.dec -+++ b/SecurityPkg/SecurityPkg.dec -@@ -323,8 +323,6 @@ - gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationPass|0x0303100A|UINT32|0x00010030 - gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationFail|0x0303100B|UINT32|0x00010031 - -- gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00010032 -- - [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] - ## Image verification policy for OptionRom. Only following values are valid:

- # NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification and has been removed.
--- -2.39.3 - diff --git a/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpm2.patch b/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpm2.patch deleted file mode 100644 index 2ee9f81..0000000 --- a/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpm2.patch +++ /dev/null @@ -1,584 +0,0 @@ -From e138f66708415704ad1133938c0dce5243795656 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 13 Feb 2024 16:30:10 -0500 -Subject: [PATCH 04/17] SecurityPkg: Support CcMeasurementProtocol in - DxeTpm2MeasureBootLib - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [4/13] 8038fb605dbdaccfd40cb9d9d56db559ee9df639 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged -Conflicts: Only cosmetic, due to the uncrustify changes made - in the newer version. - -commit a124cd4ef92a349a6c823ea6701fcfd3a17db255 -Author: Min Xu -Date: Sat Dec 11 21:08:41 2021 +0800 - - SecurityPkg: Support CcMeasurementProtocol in DxeTpm2MeasureBootLib - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3625 - - DxeTpm2MeasureBootLib supports TPM2 based measure boot. After - CcMeasurementProtocol is introduced, CC based measure boot needs to - be supported in DxeTpm2MeasureBootLib as well. - - There are 2 major changes in this commit. - - 1. A platform should have only one RTS/RTR. Only one of (virtual)TPM1.2, - (virtual)TPM2.0 and CC MR exists. Then only one TCG_SERVICE_PROTOCOL, - TCG2_PROTOCOL, CC_MEASUREMENT_PROTOCOL is exposed. In this library when - do measure boot only one of TCG2_PROTOCOL / CC_MEASUREMENT_PROTOCOL - will be called. MEASURE_BOOT_PROTOCOLS is defined to store the instances - of TCG2 protocol and CC Measurement protocol. - - 2. CcEvent is similar to Tcg2Event except the MrIndex and PcrIndex. - So in the code Tcg2Event will be first created and intialized. If - CcMeasurementProtocol is called to do the measure boot, then CcEvent - points to Tcg2Event and the MrIndex is adjusted. - - Cc: Michael D Kinney - Cc: Liming Gao - Cc: Zhiguang Liu - Cc: Jiewen Yao - Cc: Jian J Wang - Cc: Sami Mujawar - Cc: Gerd Hoffmann - Reviewed-by: Sami Mujawar - Reviewed-by: Jiewen Yao - Signed-off-by: Min Xu - -Signed-off-by: Jon Maloy ---- - .../DxeTpm2MeasureBootLib.c | 347 ++++++++++++++---- - .../DxeTpm2MeasureBootLib.inf | 3 +- - 2 files changed, 271 insertions(+), 79 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -index 95682ac567..7abacdbc0a 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c -@@ -1,5 +1,6 @@ - /** @file -- The library instance provides security service of TPM2 measure boot. -+ The library instance provides security service of TPM2 measure boot and -+ Confidential Computing (CC) measure boot. - - Caution: This file requires additional review when modified. - This library will have external input - PE/COFF image and GPT partition. -@@ -41,6 +42,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - #include - #include - #include -+#include -+ -+typedef struct { -+ EFI_TCG2_PROTOCOL *Tcg2Protocol; -+ EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; -+} MEASURE_BOOT_PROTOCOLS; - - // - // Flag to check GPT partition. It only need be measured once. -@@ -109,7 +116,7 @@ DxeTpm2MeasureBootLibImageRead ( - Caution: This function may receive untrusted input. - The GPT partition table is external input, so this function should parse partition data carefully. - -- @param Tcg2Protocol Pointer to the located TCG2 protocol instance. -+ @param MeasureBootProtocols Pointer to the located MeasureBoot protocol instances (i.e. TCG2/CC protocol). - @param GptHandle Handle that GPT partition was installed. - - @retval EFI_SUCCESS Successfully measure GPT table. -@@ -121,26 +128,48 @@ DxeTpm2MeasureBootLibImageRead ( - EFI_STATUS - EFIAPI - Tcg2MeasureGptTable ( -- IN EFI_TCG2_PROTOCOL *Tcg2Protocol, -- IN EFI_HANDLE GptHandle -+ IN MEASURE_BOOT_PROTOCOLS *MeasureBootProtocols, -+ IN EFI_HANDLE GptHandle - ) - { -- EFI_STATUS Status; -- EFI_BLOCK_IO_PROTOCOL *BlockIo; -- EFI_DISK_IO_PROTOCOL *DiskIo; -- EFI_PARTITION_TABLE_HEADER *PrimaryHeader; -- EFI_PARTITION_ENTRY *PartitionEntry; -- UINT8 *EntryPtr; -- UINTN NumberOfPartition; -- UINT32 Index; -- EFI_TCG2_EVENT *Tcg2Event; -- EFI_GPT_DATA *GptData; -- UINT32 EventSize; -+ EFI_STATUS Status; -+ EFI_BLOCK_IO_PROTOCOL *BlockIo; -+ EFI_DISK_IO_PROTOCOL *DiskIo; -+ EFI_PARTITION_TABLE_HEADER *PrimaryHeader; -+ EFI_PARTITION_ENTRY *PartitionEntry; -+ UINT8 *EntryPtr; -+ UINTN NumberOfPartition; -+ UINT32 Index; -+ UINT8 *EventPtr; -+ EFI_TCG2_EVENT *Tcg2Event; -+ EFI_CC_EVENT *CcEvent; -+ EFI_GPT_DATA *GptData; -+ UINT32 EventSize; -+ EFI_TCG2_PROTOCOL *Tcg2Protocol; -+ EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; -+ EFI_CC_MR_INDEX MrIndex; - - if (mTcg2MeasureGptCount > 0) { - return EFI_SUCCESS; - } - -+ PrimaryHeader = NULL; -+ EntryPtr = NULL; -+ EventPtr = NULL; -+ -+ Tcg2Protocol = MeasureBootProtocols->Tcg2Protocol; -+ CcProtocol = MeasureBootProtocols->CcProtocol; -+ -+ if ((Tcg2Protocol == NULL) && (CcProtocol == NULL)) { -+ ASSERT (FALSE); -+ return EFI_UNSUPPORTED; -+ } -+ -+ if (sizeof (EFI_CC_EVENT) != sizeof (EFI_TCG2_EVENT)) { -+ ASSERT (FALSE); -+ return EFI_UNSUPPORTED; -+ } -+ - Status = gBS->HandleProtocol (GptHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; -@@ -168,6 +197,16 @@ Tcg2MeasureGptTable ( - FreePool (PrimaryHeader); - return EFI_DEVICE_ERROR; - } -+ -+ // -+ // PrimaryHeader->SizeOfPartitionEntry should not be zero -+ // -+ if (PrimaryHeader->SizeOfPartitionEntry == 0) { -+ DEBUG ((DEBUG_ERROR, "SizeOfPartitionEntry should not be zero!\n")); -+ FreePool (PrimaryHeader); -+ return EFI_BAD_BUFFER_SIZE; -+ } -+ - // - // Read the partition entry. - // -@@ -202,11 +241,17 @@ Tcg2MeasureGptTable ( - } - - // -- // Prepare Data for Measurement -+ // Prepare Data for Measurement (CcProtocol and Tcg2Protocol) - // - EventSize = (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions) - + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry); -- Tcg2Event = (EFI_TCG2_EVENT *) AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof(Tcg2Event->Event)); -+ EventPtr = (UINT8 *)AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)); -+ if (EventPtr == NULL) { -+ Status = EFI_OUT_OF_RESOURCES; -+ goto Exit; -+ } -+ -+ Tcg2Event = (EFI_TCG2_EVENT *)EventPtr; - if (Tcg2Event == NULL) { - FreePool (PrimaryHeader); - FreePool (EntryPtr); -@@ -243,22 +288,66 @@ Tcg2MeasureGptTable ( - } - - // -- // Measure the GPT data -+ // Only one of TCG2_PROTOCOL or CC_MEASUREMENT_PROTOCOL is exposed. -+ // So Measure the GPT data with one of the protocol. - // -- Status = Tcg2Protocol->HashLogExtendEvent ( -- Tcg2Protocol, -- 0, -- (EFI_PHYSICAL_ADDRESS) (UINTN) (VOID *) GptData, -- (UINT64) EventSize, -- Tcg2Event -- ); -- if (!EFI_ERROR (Status)) { -- mTcg2MeasureGptCount++; -+ if (CcProtocol != NULL) { -+ // -+ // EFI_CC_EVENT share the same data structure with EFI_TCG2_EVENT -+ // except the MrIndex and PCRIndex in Header. -+ // Tcg2Event has been created and initialized before. So only the MrIndex need -+ // be adjusted. -+ // -+ Status = CcProtocol->MapPcrToMrIndex (CcProtocol, Tcg2Event->Header.PCRIndex, &MrIndex); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Cannot map PcrIndex(%d) to MrIndex\n", Tcg2Event->Header.PCRIndex)); -+ goto Exit; -+ } -+ -+ CcEvent = (EFI_CC_EVENT *)EventPtr; -+ CcEvent->Header.MrIndex = MrIndex; -+ Status = CcProtocol->HashLogExtendEvent ( -+ CcProtocol, -+ 0, -+ (EFI_PHYSICAL_ADDRESS)(UINTN)(VOID *)GptData, -+ (UINT64)EventSize, -+ CcEvent -+ ); -+ if (!EFI_ERROR (Status)) { -+ mTcg2MeasureGptCount++; -+ } -+ -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Cc MeasureGptTable - %r\n", Status)); -+ } else if (Tcg2Protocol != NULL) { -+ // -+ // If Tcg2Protocol is installed, then Measure GPT data with this protocol. -+ // -+ Status = Tcg2Protocol->HashLogExtendEvent ( -+ Tcg2Protocol, -+ 0, -+ (EFI_PHYSICAL_ADDRESS)(UINTN)(VOID *)GptData, -+ (UINT64)EventSize, -+ Tcg2Event -+ ); -+ if (!EFI_ERROR (Status)) { -+ mTcg2MeasureGptCount++; -+ } -+ -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2 MeasureGptTable - %r\n", Status)); - } - -- FreePool (PrimaryHeader); -- FreePool (EntryPtr); -- FreePool (Tcg2Event); -+Exit: -+ if (PrimaryHeader != NULL) { -+ FreePool (PrimaryHeader); -+ } -+ -+ if (EntryPtr != NULL) { -+ FreePool (EntryPtr); -+ } -+ -+ if (EventPtr != NULL) { -+ FreePool (EventPtr); -+ } - - return Status; - } -@@ -271,12 +360,12 @@ Tcg2MeasureGptTable ( - PE/COFF image is external input, so this function will validate its data structure - within this image buffer before use. - -- @param[in] Tcg2Protocol Pointer to the located TCG2 protocol instance. -- @param[in] ImageAddress Start address of image buffer. -- @param[in] ImageSize Image size -- @param[in] LinkTimeBase Address that the image is loaded into memory. -- @param[in] ImageType Image subsystem type. -- @param[in] FilePath File path is corresponding to the input image. -+ @param[in] MeasureBootProtocols Pointer to the located MeasureBoot protocol instances. -+ @param[in] ImageAddress Start address of image buffer. -+ @param[in] ImageSize Image size -+ @param[in] LinkTimeBase Address that the image is loaded into memory. -+ @param[in] ImageType Image subsystem type. -+ @param[in] FilePath File path is corresponding to the input image. - - @retval EFI_SUCCESS Successfully measure image. - @retval EFI_OUT_OF_RESOURCES No enough resource to measure image. -@@ -287,7 +376,7 @@ Tcg2MeasureGptTable ( - EFI_STATUS - EFIAPI - Tcg2MeasurePeImage ( -- IN EFI_TCG2_PROTOCOL *Tcg2Protocol, -+ IN MEASURE_BOOT_PROTOCOLS *MeasureBootProtocols, - IN EFI_PHYSICAL_ADDRESS ImageAddress, - IN UINTN ImageSize, - IN UINTN LinkTimeBase, -@@ -295,26 +384,46 @@ Tcg2MeasurePeImage ( - IN EFI_DEVICE_PATH_PROTOCOL *FilePath - ) - { -- EFI_STATUS Status; -- EFI_TCG2_EVENT *Tcg2Event; -- EFI_IMAGE_LOAD_EVENT *ImageLoad; -- UINT32 FilePathSize; -- UINT32 EventSize; -+ EFI_STATUS Status; -+ EFI_TCG2_EVENT *Tcg2Event; -+ EFI_IMAGE_LOAD_EVENT *ImageLoad; -+ UINT32 FilePathSize; -+ UINT32 EventSize; -+ EFI_CC_EVENT *CcEvent; -+ EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; -+ EFI_TCG2_PROTOCOL *Tcg2Protocol; -+ UINT8 *EventPtr; -+ EFI_CC_MR_INDEX MrIndex; -+ -+ Status = EFI_UNSUPPORTED; -+ ImageLoad = NULL; -+ EventPtr = NULL; -+ -+ Tcg2Protocol = MeasureBootProtocols->Tcg2Protocol; -+ CcProtocol = MeasureBootProtocols->CcProtocol; -+ -+ if ((Tcg2Protocol == NULL) && (CcProtocol == NULL)) { -+ ASSERT (FALSE); -+ return EFI_UNSUPPORTED; -+ } -+ -+ if (sizeof (EFI_CC_EVENT) != sizeof (EFI_TCG2_EVENT)) { -+ ASSERT (FALSE); -+ return EFI_UNSUPPORTED; -+ } - -- Status = EFI_UNSUPPORTED; -- ImageLoad = NULL; - FilePathSize = (UINT32) GetDevicePathSize (FilePath); - - // - // Determine destination PCR by BootPolicy - // - EventSize = sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize; -- Tcg2Event = AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof(Tcg2Event->Event)); -- if (Tcg2Event == NULL) { -+ EventPtr = AllocateZeroPool (EventSize + sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)); -+ if (EventPtr == NULL) { - return EFI_OUT_OF_RESOURCES; - } - -- Tcg2Event->Size = EventSize + sizeof (EFI_TCG2_EVENT) - sizeof(Tcg2Event->Event); -+ Tcg2Event = (EFI_TCG2_EVENT *)EventPtr; - Tcg2Event->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER); - Tcg2Event->Header.HeaderVersion = EFI_TCG2_EVENT_HEADER_VERSION; - ImageLoad = (EFI_IMAGE_LOAD_EVENT *) Tcg2Event->Event; -@@ -352,13 +461,35 @@ Tcg2MeasurePeImage ( - // - // Log the PE data - // -- Status = Tcg2Protocol->HashLogExtendEvent ( -- Tcg2Protocol, -- PE_COFF_IMAGE, -- ImageAddress, -- ImageSize, -- Tcg2Event -- ); -+ if (CcProtocol != NULL) { -+ Status = CcProtocol->MapPcrToMrIndex (CcProtocol, Tcg2Event->Header.PCRIndex, &MrIndex); -+ if (EFI_ERROR (Status)) { -+ DEBUG ((DEBUG_ERROR, "Cannot map PcrIndex(%d) to MrIndex\n", Tcg2Event->Header.PCRIndex)); -+ goto Finish; -+ } -+ -+ CcEvent = (EFI_CC_EVENT *)EventPtr; -+ CcEvent->Header.MrIndex = MrIndex; -+ -+ Status = CcProtocol->HashLogExtendEvent ( -+ CcProtocol, -+ PE_COFF_IMAGE, -+ ImageAddress, -+ ImageSize, -+ CcEvent -+ ); -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Cc MeasurePeImage - %r\n", Status)); -+ } else if (Tcg2Protocol != NULL) { -+ Status = Tcg2Protocol->HashLogExtendEvent ( -+ Tcg2Protocol, -+ PE_COFF_IMAGE, -+ ImageAddress, -+ ImageSize, -+ Tcg2Event -+ ); -+ DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2 MeasurePeImage - %r\n", Status)); -+ } -+ - if (Status == EFI_VOLUME_FULL) { - // - // Volume full here means the image is hashed and its result is extended to PCR. -@@ -369,11 +500,77 @@ Tcg2MeasurePeImage ( - } - - Finish: -- FreePool (Tcg2Event); -+ if (EventPtr != NULL) { -+ FreePool (EventPtr); -+ } - - return Status; - } - -+/** -+ Get the measure boot protocols. -+ -+ There are 2 measure boot, TCG2 protocol based and Cc measurement protocol based. -+ -+ @param MeasureBootProtocols Pointer to the located measure boot protocol instances. -+ -+ @retval EFI_SUCCESS Sucessfully locate the measure boot protocol instances (at least one instance). -+ @retval EFI_UNSUPPORTED Measure boot is not supported. -+**/ -+EFI_STATUS -+EFIAPI -+GetMeasureBootProtocols ( -+ MEASURE_BOOT_PROTOCOLS *MeasureBootProtocols -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_TCG2_PROTOCOL *Tcg2Protocol; -+ EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; -+ EFI_TCG2_BOOT_SERVICE_CAPABILITY Tcg2ProtocolCapability; -+ EFI_CC_BOOT_SERVICE_CAPABILITY CcProtocolCapability; -+ -+ CcProtocol = NULL; -+ Status = gBS->LocateProtocol (&gEfiCcMeasurementProtocolGuid, NULL, (VOID **)&CcProtocol); -+ if (EFI_ERROR (Status)) { -+ // -+ // Cc Measurement protocol is not installed. -+ // -+ DEBUG ((DEBUG_VERBOSE, "CcMeasurementProtocol is not installed. - %r\n", Status)); -+ } else { -+ ZeroMem (&CcProtocolCapability, sizeof (CcProtocolCapability)); -+ CcProtocolCapability.Size = sizeof (CcProtocolCapability); -+ Status = CcProtocol->GetCapability (CcProtocol, &CcProtocolCapability); -+ if (EFI_ERROR (Status) || (CcProtocolCapability.CcType.Type == EFI_CC_TYPE_NONE)) { -+ DEBUG ((DEBUG_ERROR, " CcProtocol->GetCapability returns : %x, %r\n", CcProtocolCapability.CcType.Type, Status)); -+ CcProtocol = NULL; -+ } -+ } -+ -+ Tcg2Protocol = NULL; -+ Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **)&Tcg2Protocol); -+ if (EFI_ERROR (Status)) { -+ // -+ // Tcg2 protocol is not installed. So, TPM2 is not present. -+ // -+ DEBUG ((DEBUG_VERBOSE, "Tcg2Protocol is not installed. - %r\n", Status)); -+ } else { -+ Tcg2ProtocolCapability.Size = (UINT8)sizeof (Tcg2ProtocolCapability); -+ Status = Tcg2Protocol->GetCapability (Tcg2Protocol, &Tcg2ProtocolCapability); -+ if (EFI_ERROR (Status) || (!Tcg2ProtocolCapability.TPMPresentFlag)) { -+ // -+ // TPM device doesn't work or activate. -+ // -+ DEBUG ((DEBUG_ERROR, "TPMPresentFlag=FALSE %r\n", Status)); -+ Tcg2Protocol = NULL; -+ } -+ } -+ -+ MeasureBootProtocols->Tcg2Protocol = Tcg2Protocol; -+ MeasureBootProtocols->CcProtocol = CcProtocol; -+ -+ return (Tcg2Protocol == NULL && CcProtocol == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS; -+} -+ - /** - The security handler is used to abstract platform-specific policy - from the DXE core response to an attempt to use a file that returns a -@@ -422,9 +619,8 @@ DxeTpm2MeasureBootHandler ( - IN BOOLEAN BootPolicy - ) - { -- EFI_TCG2_PROTOCOL *Tcg2Protocol; -+ MEASURE_BOOT_PROTOCOLS MeasureBootProtocols; - EFI_STATUS Status; -- EFI_TCG2_BOOT_SERVICE_CAPABILITY ProtocolCapability; - EFI_DEVICE_PATH_PROTOCOL *DevicePathNode; - EFI_DEVICE_PATH_PROTOCOL *OrigDevicePathNode; - EFI_HANDLE Handle; -@@ -435,29 +631,25 @@ DxeTpm2MeasureBootHandler ( - EFI_PHYSICAL_ADDRESS FvAddress; - UINT32 Index; - -- Status = gBS->LocateProtocol (&gEfiTcg2ProtocolGuid, NULL, (VOID **) &Tcg2Protocol); -+ MeasureBootProtocols.Tcg2Protocol = NULL; -+ MeasureBootProtocols.CcProtocol = NULL; -+ -+ Status = GetMeasureBootProtocols (&MeasureBootProtocols); -+ - if (EFI_ERROR (Status)) { - // -- // Tcg2 protocol is not installed. So, TPM2 is not present. -+ // None of Measured boot protocols (Tcg2, Cc) is installed. - // Don't do any measurement, and directly return EFI_SUCCESS. - // -- DEBUG ((DEBUG_VERBOSE, "DxeTpm2MeasureBootHandler - Tcg2 - %r\n", Status)); -+ DEBUG ((DEBUG_INFO, "None of Tcg2Protocol/CcMeasurementProtocol is installed.\n")); - return EFI_SUCCESS; - } -- -- ProtocolCapability.Size = (UINT8) sizeof (ProtocolCapability); -- Status = Tcg2Protocol->GetCapability ( -- Tcg2Protocol, -- &ProtocolCapability -- ); -- if (EFI_ERROR (Status) || (!ProtocolCapability.TPMPresentFlag)) { -- // -- // TPM device doesn't work or activate. -- // -- DEBUG ((DEBUG_ERROR, "DxeTpm2MeasureBootHandler (%r) - TPMPresentFlag - %x\n", Status, ProtocolCapability.TPMPresentFlag)); -- return EFI_SUCCESS; -- } -- -+ DEBUG (( -+ DEBUG_INFO, -+ "Tcg2Protocol = %p, CcMeasurementProtocol = %p\n", -+ MeasureBootProtocols.Tcg2Protocol, -+ MeasureBootProtocols.CcProtocol -+ )); - // - // Copy File Device Path - // -@@ -502,8 +694,8 @@ DxeTpm2MeasureBootHandler ( - // - // Measure GPT disk. - // -- Status = Tcg2MeasureGptTable (Tcg2Protocol, Handle); -- DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasureGptTable - %r\n", Status)); -+ Status = Tcg2MeasureGptTable (&MeasureBootProtocols, Handle); -+ - if (!EFI_ERROR (Status)) { - // - // GPT disk check done. -@@ -647,14 +839,13 @@ DxeTpm2MeasureBootHandler ( - // Measure PE image into TPM log. - // - Status = Tcg2MeasurePeImage ( -- Tcg2Protocol, -+ &MeasureBootProtocols, - (EFI_PHYSICAL_ADDRESS) (UINTN) FileBuffer, - FileSize, - (UINTN) ImageContext.ImageAddress, - ImageContext.ImageType, - DevicePathNode - ); -- DEBUG ((DEBUG_INFO, "DxeTpm2MeasureBootHandler - Tcg2MeasurePeImage - %r\n", Status)); - } - - // -diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -index 2506abbe7c..6dca79a20c 100644 ---- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf -@@ -1,5 +1,5 @@ - ## @file --# Provides security service for TPM 2.0 measured boot -+# Provides security service for TPM 2.0 measured boot and Confidential Computing measure boot. - # - # Spec Compliance Info: - # "TCG PC Client Platform Firmware Profile Specification for TPM Family 2.0 Level 00 Revision 1.03 v51" -@@ -61,6 +61,7 @@ - - [Protocols] - gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES -+ gEfiCcMeasurementProtocolGuid ## SOMETIMES_CONSUMES - gEfiFirmwareVolumeBlockProtocolGuid ## SOMETIMES_CONSUMES - gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES - gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpmM.patch b/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpmM.patch deleted file mode 100644 index 9764d7f..0000000 --- a/SOURCES/edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpmM.patch +++ /dev/null @@ -1,255 +0,0 @@ -From a35a08c5c8d9308ba2b63a15a40e4ddc3e265dbd Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 13 Feb 2024 16:30:10 -0500 -Subject: [PATCH 05/17] SecurityPkg: Support CcMeasurementProtocol in - DxeTpmMeasurementLib - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [5/13] fa844740ca589cabb52ae7dfa0dd329315dc168f (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21154 -CVE: CVE-2022-36763 -Upstream: Merged -Conflicts: Only cosmetic, due to the uncrustify changes made - in the newer version. - -commit 314ff1dc8c9a9597280b50e44a5c861cb6a58517 (HEAD -> CVE-2022-36763_RHEL-21154_rhel-8.10.0) -Author: Min Xu -Date: Sat Dec 11 21:08:42 2021 +0800 - - SecurityPkg: Support CcMeasurementProtocol in DxeTpmMeasurementLib - - BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3625 - - DxeTpmMeasurementLib supports TPM based measurement in DXE phase. - After CcMeasurementProtocol is introduced, CC based measurement needs - to be supported in DxeTpmMeasurementLib as well. - - A platform should have only one RTS/RTR. Only one of (virtual)TPM1.2, - (virtual)TPM2.0 and CC MR exists. Then only one TCG_SERVICE_PROTOCOL, - TCG2_PROTOCOL, CC_MEASUREMENT_PROTOCOL is exposed. - - In this library when do measurement only one of above 3 protocols will - be called. - - Cc: Michael D Kinney - Cc: Liming Gao - Cc: Zhiguang Liu - Cc: Jiewen Yao - Cc: Jian J Wang - Cc: Sami Mujawar - Cc: Gerd Hoffmann - Reviewed-by: Sami Mujawar - Reviewed-by: Jiewen Yao - Signed-off-by: Min Xu - -Signed-off-by: Jon Maloy ---- - .../DxeTpmMeasurementLib.c | 122 +++++++++++++++--- - .../DxeTpmMeasurementLib.inf | 9 +- - 2 files changed, 111 insertions(+), 20 deletions(-) - -diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c -index 061136ee78..802bc3c3cd 100644 ---- a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c -+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.c -@@ -1,5 +1,6 @@ - /** @file -- This library is used by other modules to measure data to TPM. -+ This library is used by other modules to measure data to TPM and Confidential -+ Computing (CC) measure registers. - - Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent -@@ -19,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - - #include - #include -+#include - - - -@@ -37,6 +39,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent - @retval EFI_OUT_OF_RESOURCES Out of memory. - @retval EFI_DEVICE_ERROR The operation was unsuccessful. - **/ -+STATIC - EFI_STATUS - Tpm12MeasureAndLogData ( - IN UINT32 PcrIndex, -@@ -103,6 +106,7 @@ Tpm12MeasureAndLogData ( - @retval EFI_OUT_OF_RESOURCES Out of memory. - @retval EFI_DEVICE_ERROR The operation was unsuccessful. - **/ -+STATIC - EFI_STATUS - Tpm20MeasureAndLogData ( - IN UINT32 PcrIndex, -@@ -149,6 +153,73 @@ Tpm20MeasureAndLogData ( - return Status; - } - -+/** -+ Cc measure and log data, and extend the measurement result into a -+ specific CC MR. -+ -+ @param[in] CcProtocol Instance of CC measurement protocol -+ @param[in] PcrIndex PCR Index. -+ @param[in] EventType Event type. -+ @param[in] EventLog Measurement event log. -+ @param[in] LogLen Event log length in bytes. -+ @param[in] HashData The start of the data buffer to be hashed, extended. -+ @param[in] HashDataLen The length, in bytes, of the buffer referenced by HashData -+ -+ @retval EFI_SUCCESS Operation completed successfully. -+ @retval EFI_UNSUPPORTED CC guest not available. -+ @retval EFI_OUT_OF_RESOURCES Out of memory. -+ @retval EFI_DEVICE_ERROR The operation was unsuccessful. -+ @retval EFI_INVALID_PARAMETER The input parameter is invalid. -+**/ -+STATIC -+EFI_STATUS -+CcMeasureAndLogData ( -+ IN EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol, -+ IN UINT32 PcrIndex, -+ IN UINT32 EventType, -+ IN VOID *EventLog, -+ IN UINT32 LogLen, -+ IN VOID *HashData, -+ IN UINT64 HashDataLen -+ ) -+{ -+ EFI_STATUS Status; -+ EFI_CC_EVENT *EfiCcEvent; -+ EFI_CC_MR_INDEX MrIndex; -+ -+ if (CcProtocol == NULL) { -+ return EFI_INVALID_PARAMETER; -+ } -+ -+ Status = CcProtocol->MapPcrToMrIndex (CcProtocol, PcrIndex, &MrIndex); -+ if (EFI_ERROR (Status)) { -+ return Status; -+ } -+ -+ EfiCcEvent = (EFI_CC_EVENT *)AllocateZeroPool (LogLen + sizeof (EFI_CC_EVENT)); -+ if (EfiCcEvent == NULL) { -+ return EFI_OUT_OF_RESOURCES; -+ } -+ -+ EfiCcEvent->Size = (UINT32)LogLen + sizeof (EFI_CC_EVENT) - sizeof (EfiCcEvent->Event); -+ EfiCcEvent->Header.HeaderSize = sizeof (EFI_CC_EVENT_HEADER); -+ EfiCcEvent->Header.HeaderVersion = EFI_CC_EVENT_HEADER_VERSION; -+ EfiCcEvent->Header.MrIndex = MrIndex; -+ EfiCcEvent->Header.EventType = EventType; -+ CopyMem (&EfiCcEvent->Event[0], EventLog, LogLen); -+ -+ Status = CcProtocol->HashLogExtendEvent ( -+ CcProtocol, -+ 0, -+ (EFI_PHYSICAL_ADDRESS)(UINTN)HashData, -+ HashDataLen, -+ EfiCcEvent -+ ); -+ FreePool (EfiCcEvent); -+ -+ return Status; -+} -+ - /** - Tpm measure and log data, and extend the measurement result into a specific PCR. - -@@ -175,25 +246,16 @@ TpmMeasureAndLogData ( - IN UINT64 HashDataLen - ) - { -- EFI_STATUS Status; -- -- // -- // Try to measure using Tpm20 protocol -- // -- Status = Tpm20MeasureAndLogData( -- PcrIndex, -- EventType, -- EventLog, -- LogLen, -- HashData, -- HashDataLen -- ); -+ EFI_STATUS Status; -+ EFI_CC_MEASUREMENT_PROTOCOL *CcProtocol; - -- if (EFI_ERROR (Status)) { -+ Status = gBS->LocateProtocol (&gEfiCcMeasurementProtocolGuid, NULL, (VOID **)&CcProtocol); -+ if (!EFI_ERROR (Status)) { - // -- // Try to measure using Tpm1.2 protocol -+ // Try to measure using Cc measurement protocol - // -- Status = Tpm12MeasureAndLogData( -+ Status = CcMeasureAndLogData ( -+ CcProtocol, - PcrIndex, - EventType, - EventLog, -@@ -201,6 +263,32 @@ TpmMeasureAndLogData ( - HashData, - HashDataLen - ); -+ } else { -+ // -+ // Try to measure using Tpm20 protocol -+ // -+ Status = Tpm20MeasureAndLogData ( -+ PcrIndex, -+ EventType, -+ EventLog, -+ LogLen, -+ HashData, -+ HashDataLen -+ ); -+ -+ if (EFI_ERROR (Status)) { -+ // -+ // Try to measure using Tpm1.2 protocol -+ // -+ Status = Tpm12MeasureAndLogData ( -+ PcrIndex, -+ EventType, -+ EventLog, -+ LogLen, -+ HashData, -+ HashDataLen -+ ); -+ } - } - - return Status; -diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf -index 7d41bc41f9..3af3d4e33b 100644 ---- a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf -+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf -@@ -1,5 +1,7 @@ - ## @file --# Provides TPM measurement functions for TPM1.2 and TPM 2.0 -+# Provides below measurement functions: -+# 1. TPM measurement functions for TPM1.2 and TPM 2.0 -+# 2. Confidential Computing (CC) measurement functions - # - # This library provides TpmMeasureAndLogData() to measure and log data, and - # extend the measurement result into a specific PCR. -@@ -40,5 +42,6 @@ - UefiBootServicesTableLib - - [Protocols] -- gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES -- gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES -+ gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES -+ gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES -+ gEfiCcMeasurementProtocolGuid ## SOMETIMES_CONSUMES --- -2.41.0 - diff --git a/SOURCES/edk2-SecurityPkg-Updating-SecurityFixes.yaml-after-symbol.patch b/SOURCES/edk2-SecurityPkg-Updating-SecurityFixes.yaml-after-symbol.patch deleted file mode 100644 index ce0441b..0000000 --- a/SOURCES/edk2-SecurityPkg-Updating-SecurityFixes.yaml-after-symbol.patch +++ /dev/null @@ -1,84 +0,0 @@ -From fa892c7112cfb5aa742f358544da3788a831e431 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 13 Feb 2024 16:30:10 -0500 -Subject: [PATCH 13/17] SecurityPkg: : Updating SecurityFixes.yaml after symbol - rename - -RH-Author: Jon Maloy -RH-MergeRequest: 44: edk2: heap buffer overflow in Tcg2MeasureGptTable() -RH-Jira: RHEL-21154 RHEL-21156 -RH-Acked-by: Laszlo Ersek -RH-Commit: [13/13] 3bf59dbb583b67eddb54361781054cc650398309 (jmaloy/jons_fork) - -JIRA: https://issues.redhat.com/browse/RHEL-21156 -CVE: CVE-2022-36764 -Upstream: Merged - -commit 264636d8e6983e0f6dc6be2fca9d84ec81315954 -Author: Doug Flick -Date: Wed Jan 17 14:47:22 2024 -0800 - - SecurityPkg: : Updating SecurityFixes.yaml after symbol rename - - Adding the new commit titles for the symbol renames - - Cc: Jiewen Yao - Cc: Rahul Kumar - - Signed-off-by: Doug Flick [MSFT] - Message-Id: <5e0e851e97459e183420178888d4fcdadc2f1ae1.1705529990.git.doug.edk2@gmail.com> - Reviewed-by: Jiewen Yao - -Signed-off-by: Jon Maloy ---- - SecurityPkg/SecurityFixes.yaml | 31 ++++++++++++++++++++++++++----- - 1 file changed, 26 insertions(+), 5 deletions(-) - -diff --git a/SecurityPkg/SecurityFixes.yaml b/SecurityPkg/SecurityFixes.yaml -index f9e3e7be74..dc1bb83489 100644 ---- a/SecurityPkg/SecurityFixes.yaml -+++ b/SecurityPkg/SecurityFixes.yaml -@@ -9,14 +9,35 @@ CVE_2022_36763: - - "SecurityPkg: DxeTpm2Measurement: SECURITY PATCH 4117 - CVE 2022-36763" - - "SecurityPkg: DxeTpmMeasurement: SECURITY PATCH 4117 - CVE 2022-36763" - - "SecurityPkg: : Adding CVE 2022-36763 to SecurityFixes.yaml" -+ - "SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117/4118 symbol rename" -+ - "SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4117/4118 symbol rename" -+ - "SecurityPkg: : Updating SecurityFixes.yaml after symbol rename" - cve: CVE-2022-36763 - date_reported: 2022-10-25 11:31 UTC - description: (CVE-2022-36763) - Heap Buffer Overflow in Tcg2MeasureGptTable() - note: This patch is related to and supersedes TCBZ2168 - files_impacted: -- - Library\DxeTpm2MeasureBootLib\DxeTpm2MeasureBootLib.c -- - Library\DxeTpmMeasureBootLib\DxeTpmMeasureBootLib.c -+ - Library\DxeTpm2MeasureBootLib\DxeTpm2MeasureBootLib.c -+ - Library\DxeTpmMeasureBootLib\DxeTpmMeasureBootLib.c - links: -- - https://bugzilla.tianocore.org/show_bug.cgi?id=4117 -- - https://bugzilla.tianocore.org/show_bug.cgi?id=2168 -- - https://bugzilla.tianocore.org/show_bug.cgi?id=1990 -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4117 -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=2168 -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=1990 -+CVE_2022_36764: -+ commit_titles: -+ - "SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4118 - CVE 2022-36764" -+ - "SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4118 - CVE 2022-36764" -+ - "SecurityPkg: : Adding CVE 2022-36764 to SecurityFixes.yaml" -+ - "SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117/4118 symbol rename" -+ - "SecurityPkg: DxeTpmMeasureBootLib: SECURITY PATCH 4117/4118 symbol rename" -+ - "SecurityPkg: : Updating SecurityFixes.yaml after symbol rename" -+ cve: CVE-2022-36764 -+ date_reported: 2022-10-25 12:23 UTC -+ description: Heap Buffer Overflow in Tcg2MeasurePeImage() -+ note: -+ files_impacted: -+ - Library\DxeTpm2MeasureBootLib\DxeTpm2MeasureBootLib.c -+ - Library\DxeTpmMeasureBootLib\DxeTpmMeasureBootLib.c -+ links: -+ - https://bugzilla.tianocore.org/show_bug.cgi?id=4118 -+ --- -2.41.0 - diff --git a/SOURCES/edk2-StandaloneMmPkg-Hob-Integer-Overflow-in-CreateHob.patch b/SOURCES/edk2-StandaloneMmPkg-Hob-Integer-Overflow-in-CreateHob.patch deleted file mode 100644 index f5fdb5d..0000000 --- a/SOURCES/edk2-StandaloneMmPkg-Hob-Integer-Overflow-in-CreateHob.patch +++ /dev/null @@ -1,150 +0,0 @@ -From 155eceaf831492dcd77172833350072e4156e1c9 Mon Sep 17 00:00:00 2001 -From: Jon Maloy -Date: Tue, 5 Mar 2024 16:38:49 -0500 -Subject: [PATCH 2/2] StandaloneMmPkg/Hob: Integer Overflow in CreateHob() - -RH-Author: Jon Maloy -RH-MergeRequest: 66: EmbeddedPkg/Hob: Integer Overflow in CreateHob() -RH-Jira: RHEL-21158 -RH-Acked-by: Oliver Steffen -RH-Acked-by: Gerd Hoffmann -RH-Commit: [2/2] be7ee11a65a56faec07c249a35940cf9b95b9ec1 - -JIRA: https://issues.redhat.com/browse/RHEL-21158 -CVE: CVE-2022-36765 -Upstream: Merged - -commit 9a75b030cf27d2530444e9a2f9f11867f79bf679 -Author: Gua Guo -Date: Thu Jan 11 13:03:26 2024 +0800 - - StandaloneMmPkg/Hob: Integer Overflow in CreateHob() - - REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4166 - - Fix integer overflow in various CreateHob instances. - Fixes: CVE-2022-36765 - - The CreateHob() function aligns the requested size to 8 - performing the following operation: - ``` - HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); - ``` - - No checks are performed to ensure this value doesn't - overflow, and could lead to CreateHob() returning a smaller - HOB than requested, which could lead to OOB HOB accesses. - - Reported-by: Marc Beatove - Reviewed-by: Ard Biesheuvel - Cc: Sami Mujawar - Reviewed-by: Ray Ni - Cc: John Mathew - Authored-by: Gerd Hoffmann - Signed-off-by: Gua Guo - - Signed-off-by: Jon Maloy ---- - .../Arm/StandaloneMmCoreHobLib.c | 37 ++++++++++++++++++- - 1 file changed, 36 insertions(+), 1 deletion(-) - -diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c -index 0ec2d4ad6f..3b13249e33 100644 ---- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c -+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c -@@ -34,6 +34,13 @@ CreateHob ( - - HandOffHob = GetHobList (); - -+ // -+ // Check Length to avoid data overflow. -+ // -+ if (HobLength > MAX_UINT16 - 0x7) { -+ return NULL; -+ } -+ - HobLength = (UINT16)((HobLength + 0x7) & (~0x7)); - - FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom; -@@ -87,6 +94,10 @@ BuildModuleHob ( - ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)); - - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid); - Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule; -@@ -127,6 +138,9 @@ BuildResourceDescriptorHob ( - - Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR)); - ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->ResourceType = ResourceType; - Hob->ResourceAttribute = ResourceAttribute; -@@ -164,7 +178,12 @@ BuildGuidHob ( - // - ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE))); - -- Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength)); -+ Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return NULL; -+ } -+ - CopyGuid (&Hob->Name, Guid); - return Hob + 1; - } -@@ -225,6 +244,10 @@ BuildFvHob ( - EFI_HOB_FIRMWARE_VOLUME *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; -@@ -255,6 +278,10 @@ BuildFv2Hob ( - EFI_HOB_FIRMWARE_VOLUME2 *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->BaseAddress = BaseAddress; - Hob->Length = Length; -@@ -283,6 +310,10 @@ BuildCpuHob ( - EFI_HOB_CPU *Hob; - - Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - Hob->SizeOfMemorySpace = SizeOfMemorySpace; - Hob->SizeOfIoSpace = SizeOfIoSpace; -@@ -318,6 +349,10 @@ BuildMemoryAllocationHob ( - ((Length & (EFI_PAGE_SIZE - 1)) == 0)); - - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); -+ ASSERT (Hob != NULL); -+ if (Hob == NULL) { -+ return; -+ } - - ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); - Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress; --- -2.39.3 - diff --git a/SOURCES/edk2-rh-openssl-add-crypto-bn-rsa_sup_mul.c-to-file-list.patch b/SOURCES/edk2-rh-openssl-add-crypto-bn-rsa_sup_mul.c-to-file-list.patch deleted file mode 100644 index f0ee17f..0000000 --- a/SOURCES/edk2-rh-openssl-add-crypto-bn-rsa_sup_mul.c-to-file-list.patch +++ /dev/null @@ -1,42 +0,0 @@ -From ec7ff1612b2f5b0075545dc705b7c2610ec83748 Mon Sep 17 00:00:00 2001 -From: Gerd Hoffmann -Date: Fri, 10 Feb 2023 11:43:06 +0100 -Subject: [PATCH 2/2] rh openssl: add crypto/bn/rsa_sup_mul.c to file list - -RH-Author: Gerd Hoffmann -RH-MergeRequest: 21: openssl update -RH-Bugzilla: 2164531 2164543 2164558 2164581 -RH-Acked-by: Miroslav Rezanina -RH-Commit: [2/2] 61acf48e337f04b34c4f309241775b204ae2e54f (kraxel/rhel-edk-2) ---- - CryptoPkg/Library/OpensslLib/OpensslLib.inf | 1 + - CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 1 + - 2 files changed, 2 insertions(+) - -diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf -index 19913a4ac6..4eaa8a756d 100644 ---- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf -+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf -@@ -571,6 +571,7 @@ - $(OPENSSL_PATH)/ssl/statem/statem_local.h - # Autogenerated files list ends here - # RHEL8-specific OpenSSL file list starts here -+ $(OPENSSL_PATH)/crypto/bn/rsa_sup_mul.c - $(OPENSSL_PATH)/crypto/evp/kdf_lib.c - $(OPENSSL_PATH)/crypto/evp/pkey_kdf.c - $(OPENSSL_PATH)/crypto/kdf/kbkdf.c -diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -index 5057857e8d..eec4771f2c 100644 ---- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf -@@ -520,6 +520,7 @@ - $(OPENSSL_PATH)/crypto/x509v3/v3_admis.h - # Autogenerated files list ends here - # RHEL8-specific OpenSSL file list starts here -+ $(OPENSSL_PATH)/crypto/bn/rsa_sup_mul.c - $(OPENSSL_PATH)/crypto/evp/kdf_lib.c - $(OPENSSL_PATH)/crypto/evp/pkey_kdf.c - $(OPENSSL_PATH)/crypto/kdf/kbkdf.c --- -2.37.3 - diff --git a/SOURCES/ovmf-vars-generator b/SOURCES/ovmf-vars-generator deleted file mode 100755 index 111e438..0000000 --- a/SOURCES/ovmf-vars-generator +++ /dev/null @@ -1,295 +0,0 @@ -#!/bin/python3 -# Copyright (C) 2017 Red Hat -# Authors: -# - Patrick Uiterwijk -# - Kashyap Chamarthy -# -# Licensed under MIT License, for full text see LICENSE -# -# Purpose: Launch a QEMU guest and enroll ithe UEFI keys into an OVMF -# variables ("VARS") file. Then boot a Linux kernel with QEMU. -# Finally, perform a check to verify if Secure Boot -# is enabled. - -from __future__ import print_function - -import argparse -import os -import logging -import tempfile -import shutil -import string -import subprocess - - -def strip_special(line): - return ''.join([c for c in str(line) if c in string.printable]) - - -def generate_qemu_cmd(args, readonly, *extra_args): - if args.disable_smm: - machinetype = 'pc' - else: - machinetype = 'q35,smm=on' - machinetype += ',accel=%s' % ('kvm' if args.enable_kvm else 'tcg') - - if args.oem_string is None: - oemstrings = [] - else: - oemstring_values = [ - ",value=" + s.replace(",", ",,") for s in args.oem_string ] - oemstrings = [ - '-smbios', - "type=11" + ''.join(oemstring_values) ] - - return [ - args.qemu_binary, - '-machine', machinetype, - '-display', 'none', - '-no-user-config', - '-nodefaults', - '-m', '768', - '-smp', '2,sockets=2,cores=1,threads=1', - '-chardev', 'pty,id=charserial1', - '-device', 'isa-serial,chardev=charserial1,id=serial1', - '-global', 'driver=cfi.pflash01,property=secure,value=%s' % ( - 'off' if args.disable_smm else 'on'), - '-drive', - 'file=%s,if=pflash,format=raw,unit=0,readonly=on' % ( - args.ovmf_binary), - '-drive', - 'file=%s,if=pflash,format=raw,unit=1,readonly=%s' % ( - args.out_temp, 'on' if readonly else 'off'), - '-serial', 'stdio'] + oemstrings + list(extra_args) - - -def download(url, target, suffix, no_download): - istemp = False - if target and os.path.exists(target): - return target, istemp - if not target: - temped = tempfile.mkstemp(prefix='qosb.', suffix='.%s' % suffix) - os.close(temped[0]) - target = temped[1] - istemp = True - if no_download: - raise Exception('%s did not exist, but downloading was disabled' % - target) - import requests - logging.debug('Downloading %s to %s', url, target) - r = requests.get(url, stream=True) - with open(target, 'wb') as f: - for chunk in r.iter_content(chunk_size=1024): - if chunk: - f.write(chunk) - return target, istemp - - -def enroll_keys(args): - shutil.copy(args.ovmf_template_vars, args.out_temp) - - logging.info('Starting enrollment') - - cmd = generate_qemu_cmd( - args, - False, - '-drive', - 'file=%s,format=raw,if=none,media=cdrom,id=drive-cd1,' - 'readonly=on' % args.uefi_shell_iso, - '-device', - 'ide-cd,drive=drive-cd1,id=cd1,' - 'bootindex=1') - p = subprocess.Popen(cmd, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - logging.info('Performing enrollment') - # Wait until the UEFI shell starts (first line is printed) - read = p.stdout.readline() - if b'char device redirected' in read: - read = p.stdout.readline() - # Skip passed QEMU warnings, like the following one we see in Ubuntu: - # qemu-system-x86_64: warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5] - while b'qemu-system-x86_64: warning:' in read: - read = p.stdout.readline() - if args.print_output: - print(strip_special(read), end='') - print() - # Send the escape char to enter the UEFI shell early - p.stdin.write(b'\x1b') - p.stdin.flush() - # And then run the following three commands from the UEFI shell: - # change into the first file system device; install the default - # keys and certificates, and reboot - p.stdin.write(b'fs0:\r\n') - p.stdin.write(b'EnrollDefaultKeys.efi\r\n') - p.stdin.write(b'reset -s\r\n') - p.stdin.flush() - while True: - read = p.stdout.readline() - if args.print_output: - print('OUT: %s' % strip_special(read), end='') - print() - if b'info: success' in read: - break - p.wait() - if args.print_output: - print(strip_special(p.stdout.read()), end='') - logging.info('Finished enrollment') - - -def test_keys(args): - logging.info('Grabbing test kernel') - kernel, kerneltemp = download(args.kernel_url, args.kernel_path, - 'kernel', args.no_download) - - logging.info('Starting verification') - try: - cmd = generate_qemu_cmd( - args, - True, - '-append', 'console=tty0 console=ttyS0,115200n8', - '-kernel', kernel) - p = subprocess.Popen(cmd, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - logging.info('Performing verification') - while True: - read = p.stdout.readline() - if args.print_output: - print('OUT: %s' % strip_special(read), end='') - print() - if b'Secure boot disabled' in read: - raise Exception('Secure Boot was disabled') - elif b'Secure boot enabled' in read: - logging.info('Confirmed: Secure Boot is enabled') - break - elif b'Kernel is locked down from EFI secure boot' in read: - logging.info('Confirmed: Secure Boot is enabled') - break - p.kill() - if args.print_output: - print(strip_special(p.stdout.read()), end='') - logging.info('Finished verification') - finally: - if kerneltemp: - os.remove(kernel) - - -def parse_args(): - parser = argparse.ArgumentParser() - parser.add_argument('output', help='Filename for output vars file') - parser.add_argument('--out-temp', help=argparse.SUPPRESS) - parser.add_argument('--force', help='Overwrite existing output file', - action='store_true') - parser.add_argument('--print-output', help='Print the QEMU guest output', - action='store_true') - parser.add_argument('--verbose', '-v', help='Increase verbosity', - action='count') - parser.add_argument('--quiet', '-q', help='Decrease verbosity', - action='count') - parser.add_argument('--qemu-binary', help='QEMU binary path', - default='/usr/bin/qemu-system-x86_64') - parser.add_argument('--enable-kvm', help='Enable KVM acceleration', - action='store_true') - parser.add_argument('--ovmf-binary', help='OVMF secureboot code file', - default='/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd') - parser.add_argument('--ovmf-template-vars', help='OVMF empty vars file', - default='/usr/share/edk2/ovmf/OVMF_VARS.fd') - parser.add_argument('--uefi-shell-iso', help='Path to uefi shell iso', - default='/usr/share/edk2/ovmf/UefiShell.iso') - parser.add_argument('--skip-enrollment', - help='Skip enrollment, only test', action='store_true') - parser.add_argument('--skip-testing', - help='Skip testing generated "VARS" file', - action='store_true') - parser.add_argument('--kernel-path', - help='Specify a consistent path for kernel') - parser.add_argument('--no-download', action='store_true', - help='Never download a kernel') - parser.add_argument('--fedora-version', - help='Fedora version to get kernel for checking', - default='27') - parser.add_argument('--kernel-url', help='Kernel URL', - default='https://download.fedoraproject.org/pub/fedora' - '/linux/releases/%(version)s/Everything/x86_64' - '/os/images/pxeboot/vmlinuz') - parser.add_argument('--disable-smm', - help=('Don\'t restrict varstore pflash writes to ' - 'guest code that executes in SMM. Use this ' - 'option only if your OVMF binary doesn\'t have ' - 'the edk2 SMM driver stack built into it ' - '(possibly because your QEMU binary lacks SMM ' - 'emulation). Note that without restricting ' - 'varstore pflash writes to guest code that ' - 'executes in SMM, a malicious guest kernel, ' - 'used for testing, could undermine Secure ' - 'Boot.'), - action='store_true') - parser.add_argument('--oem-string', - help=('Pass the argument to the guest as a string in ' - 'the SMBIOS Type 11 (OEM Strings) table. ' - 'Multiple occurrences of this option are ' - 'collected into a single SMBIOS Type 11 table. ' - 'A pure ASCII string argument is strongly ' - 'suggested.'), - action='append') - args = parser.parse_args() - args.kernel_url = args.kernel_url % {'version': args.fedora_version} - - validate_args(args) - return args - - -def validate_args(args): - if (os.path.exists(args.output) - and not args.force - and not args.skip_enrollment): - raise Exception('%s already exists' % args.output) - - if args.skip_enrollment and not os.path.exists(args.output): - raise Exception('%s does not yet exist' % args.output) - - verbosity = (args.verbose or 1) - (args.quiet or 0) - if verbosity >= 2: - logging.basicConfig(level=logging.DEBUG) - elif verbosity == 1: - logging.basicConfig(level=logging.INFO) - elif verbosity < 0: - logging.basicConfig(level=logging.ERROR) - else: - logging.basicConfig(level=logging.WARN) - - if args.skip_enrollment: - args.out_temp = args.output - else: - temped = tempfile.mkstemp(prefix='qosb.', suffix='.vars') - os.close(temped[0]) - args.out_temp = temped[1] - logging.debug('Temp output: %s', args.out_temp) - - -def move_to_dest(args): - shutil.copy(args.out_temp, args.output) - os.remove(args.out_temp) - - -def main(): - args = parse_args() - if not args.skip_enrollment: - enroll_keys(args) - if not args.skip_testing: - test_keys(args) - if not args.skip_enrollment: - move_to_dest(args) - if args.skip_testing: - logging.info('Created %s' % args.output) - else: - logging.info('Created and verified %s' % args.output) - else: - logging.info('Verified %s', args.output) - - -if __name__ == '__main__': - main() diff --git a/SPECS/edk2.spec b/SPECS/edk2.spec deleted file mode 100644 index aac8878..0000000 --- a/SPECS/edk2.spec +++ /dev/null @@ -1,1706 +0,0 @@ -ExclusiveArch: x86_64 aarch64 - -%define GITDATE 20220126 -%define GITCOMMIT bb1bba3d77 -%define TOOLCHAIN GCC5 -%define OPENSSL_VER 1.1.1k - -Name: edk2 -Version: %{GITDATE}git%{GITCOMMIT} -Release: 13%{?dist}.3 -Summary: UEFI firmware for 64-bit virtual machines -Group: Applications/Emulators -License: BSD-2-Clause-Patent and OpenSSL and MIT -URL: http://www.tianocore.org - -# The source tarball is created using following commands: -# COMMIT=bb1bba3d77 -# git archive --format=tar --prefix=edk2-$COMMIT/ $COMMIT \ -# | xz -9ev >/tmp/edk2-$COMMIT.tar.xz -Source0: http://batcave.lab.eng.brq.redhat.com/www/edk2-%{GITCOMMIT}.tar.xz -Source1: ovmf-whitepaper-c770f8c.txt -Source2: openssl-rhel-cf317b2bb227899cb2e761b9163210f62cab1b1e.tar.xz -Source3: ovmf-vars-generator -Source4: LICENSE.qosb -Source5: RedHatSecureBootPkKek1.pem - -Source10: edk2-aarch64-verbose.json -Source11: edk2-aarch64.json -Source12: edk2-ovmf-sb.json -Source13: edk2-ovmf.json -Source14: edk2-ovmf-cc.json - -Patch0008: 0008-BaseTools-do-not-build-BrotliCompress-RH-only.patch -Patch0009: 0009-MdeModulePkg-remove-package-private-Brotli-include-p.patch -Patch0010: 0010-OvmfPkg-increase-max-debug-message-length-to-512-RHE.patch -Patch0011: 0011-MdeModulePkg-TerminalDxe-add-other-text-resolutions-.patch -Patch0012: 0012-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch -Patch0013: 0013-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch -Patch0014: 0014-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch -Patch0015: 0015-OvmfPkg-allow-exclusion-of-the-shell-from-the-firmwa.patch -Patch0016: 0016-ArmPlatformPkg-introduce-fixed-PCD-for-early-hello-m.patch -Patch0017: 0017-ArmPlatformPkg-PrePeiCore-write-early-hello-message-.patch -Patch0018: 0018-ArmVirtPkg-set-early-hello-message-RH-only.patch -Patch0019: 0019-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch -Patch0020: 0020-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch -Patch0021: 0021-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch -Patch0022: 0022-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch -Patch0023: 0023-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch -Patch0024: 0024-CryptoPkg-OpensslLib-list-RHEL8-specific-OpenSSL-fil.patch -Patch0025: 0025-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch -Patch0026: 0026-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch -# For bz#2112307 - Mark SEV launch secret area as reserved -Patch27: edk2-OvmfPkg-AmdSev-SecretPei-Mark-SEV-launch-secret-area.patch -# For bz#2164531 - CVE-2023-0286 edk2: openssl: X.400 address type confusion in X.509 GeneralName [rhel-8] -# For bz#2164543 - CVE-2022-4304 edk2: openssl: timing attack in RSA Decryption implementation [rhel-8] -# For bz#2164558 - CVE-2023-0215 edk2: openssl: use-after-free following BIO_new_NDEF [rhel-8] -# For bz#2164581 - CVE-2022-4450 edk2: openssl: double free after calling PEM_read_bio_ex [rhel-8] -Patch28: edk2-rh-openssl-add-crypto-bn-rsa_sup_mul.c-to-file-list.patch -# For bz#1861743 - CVE-2019-14560 edk2: Function GetEfiGlobalVariable2() return value not checked in DxeImageVerificationHandler() [rhel-8] -Patch29: edk2-SecurityPkg-DxeImageVerificationLib-Check-result-of-.patch -# For bz#2150267 - ovmf must consider max cpu count not boot cpu count for apic mode [rhel-8] -Patch30: edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch31: edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariableG.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch32: edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variables.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch33: edk2-OvmfPkg-VirtNorFlashDxe-clone-ArmPlatformPkg-s-NOR-f.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch34: edk2-OvmfPkg-VirtNorFlashDxe-remove-CheckBlockLocked-feat.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch35: edk2-OvmfPkg-VirtNorFlashDxe-remove-disk-I-O-protocol-imp.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch36: edk2-OvmfPkg-VirtNorFlashDxe-drop-block-I-O-protocol-impl.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch37: edk2-OvmfPkg-VirtNorFlashDxe-avoid-array-mode-switch-afte.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch38: edk2-OvmfPkg-VirtNorFlashDxe-avoid-switching-between-mode.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch39: edk2-OvmfPkg-VirtNorFlashDxe-use-EFI_MEMORY_WC-and-drop-A.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch40: edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch41: edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariable2.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch42: edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variable2.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch43: edk2-OvmfPkg-VirtNorFlashDxe-add-casts-to-UINTN-and-UINT3.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch44: edk2-OvmfPkg-VirtNorFlashDxe-clarify-block-write-logic-fi.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch45: edk2-OvmfPkg-VirtNorFlashDxe-add-a-loop-for-NorFlashWrite.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch46: edk2-OvmfPkg-VirtNorFlashDxe-allow-larger-writes-without-.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch47: edk2-OvmfPkg-VirtNorFlashDxe-ValidateFvHeader-unwritten-s.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch48: edk2-OvmfPkg-VirtNorFlashDxe-move-DoErase-code-block-into.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch49: edk2-ArmVirtPkg-ArmVirtQemu-migrate-to-OVMF-s-VirtNorFlas.patch -# For RHEL-17587 - [rhel8] guest fails to boot due to ASSERT error -Patch50: edk2-OvmfPkg-clone-NorFlashPlatformLib-into-VirtNorFlashP.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch51: edk2-SecurityPkg-Change-use-of-EFI_D_-to-DEBUG_.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch52: edk2-SecurityPkg-Change-OPTIONAL-keyword-usage-style.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch53: edk2-MdePkg-Introduce-CcMeasurementProtocol-for-CC-Guest-.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch54: edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpm2.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch55: edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpmM.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch56: edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-411.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch57: edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4117.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch58: edk2-SecurityPkg-Adding-CVE-2022-36763-to-SecurityFixes.y.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch59: edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-418.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch60: edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4118.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch61: edk2-SecurityPkg-DxeTpm2MeasureBootLib-SEC-PATCH-4118-2.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch62: edk2-SecurityPkg-DxeTpmMeasureBootLib-SEC-PATCH-4117-2.patch -# For RHEL-21154 - CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8] -# For RHEL-21156 - CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8] -Patch63: edk2-SecurityPkg-Updating-SecurityFixes.yaml-after-symbol.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21842 - CVE-2023-45230 edk2: Buffer overflow in the DHCPv6 client via a long Server ID option [rhel-8] -Patch64: edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Pa.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21842 - CVE-2023-45230 edk2: Buffer overflow in the DHCPv6 client via a long Server ID option [rhel-8] -Patch65: edk2-NetworkPkg-Add-Unit-tests-to-CI-and-create-Host-Test.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21842 - CVE-2023-45230 edk2: Buffer overflow in the DHCPv6 client via a long Server ID option [rhel-8] -Patch66: edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Un.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21842 - CVE-2023-45230 edk2: Buffer overflow in the DHCPv6 client via a long Server ID option [rhel-8] -Patch67: edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Pa.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch68: edk2-Apply-uncrustify-changes-to-.c-.h-files-in-the-Netwo.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch69: edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Patc.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch70: edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Unit.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch71: edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Patc.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch72: edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Unit.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch73: edk2-NetworkPkg-Apply-uncrustify-changes.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch74: edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch75: edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p2.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch76: edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p3.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch77: edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p4.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch78: edk2-NetworkPkg-Adds-a-SecurityFix.yaml-file.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch79: edk2-NetworkPkg-Apply-uncrustify-changes-p2.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch80: edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Re.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch81: edk2-NetworkPkg-Dhcp6Dxe-Removes-duplicate-check-and-repl.patch -# For RHEL-21840 - CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21844 - CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8] -# For RHEL-21846 - CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8] -# For RHEL-21848 - CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8] -# For RHEL-21850 - CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8] -# For RHEL-21852 - CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8] -Patch82: edk2-NetworkPkg-Dhcp6Dxe-Packet-Length-is-not-updated-bef.patch -# For RHEL-21158 - CVE-2022-36765 edk2: integer overflow in CreateHob() could lead to HOB OOB R/W [rhel-8] -Patch83: edk2-EmbeddedPkg-Hob-Integer-Overflow-in-CreateHob.patch -# For RHEL-21158 - CVE-2022-36765 edk2: integer overflow in CreateHob() could lead to HOB OOB R/W [rhel-8] -Patch84: edk2-StandaloneMmPkg-Hob-Integer-Overflow-in-CreateHob.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch85: edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch86: edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch87: edk2-MdePkg-Apply-uncrustify-changes.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch88: edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch89: edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch90: edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch91: edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch92: edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch93: edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch94: edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch95: edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch96: edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch97: edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch98: edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch99: edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch100: edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch101: edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch102: edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch103: edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch104: edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch105: edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch106: edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch107: edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch108: edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch109: edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch110: edk2-SecurityPkg-RngDxe-add-rng-test.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch111: edk2-OvmfPkg-wire-up-RngDxe.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch112: edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch113: edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch114: edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch -# For RHEL-21854 - CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8] -# For RHEL-21856 - CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8] -# For RHEL-40099 - CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z] -Patch115: edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch -# For RHEL-53009 - No http boot support on edk2-ovmf-20231122-6.el9_4.2 [rhel-8.10.z] -Patch116: edk2-OvmfPkg-Add-Hash2DxeCrypto-to-OvmfPkg.patch - - -# python3-devel and libuuid-devel are required for building tools. -# python3-devel is also needed for varstore template generation and -# verification with "ovmf-vars-generator". -BuildRequires: python3-devel -BuildRequires: libuuid-devel -BuildRequires: /usr/bin/iasl -BuildRequires: binutils gcc git - -%ifarch x86_64 -# Only OVMF includes 80x86 assembly files (*.nasm*). -BuildRequires: nasm - -# Only OVMF includes the Secure Boot feature, for which we need to separate out -# the UEFI shell. -BuildRequires: dosfstools -BuildRequires: mtools -BuildRequires: genisoimage - -# For generating the variable store template with the default certificates -# enrolled, we need the qemu-kvm executable. -BuildRequires: qemu-kvm-core >= 2.12.0-89 - -# For verifying SB enablement in the above variable store template, we need a -# guest kernel that prints "Secure boot enabled". -BuildRequires: kernel-core >= 4.18.0-161 -BuildRequires: rpmdevtools - -%package ovmf -Summary: UEFI firmware for x86_64 virtual machines -BuildArch: noarch -Provides: OVMF = %{version}-%{release} -Obsoletes: OVMF < 20180508-100.gitee3198e672e2.el7 - -# OVMF includes the Secure Boot and IPv6 features; it has a builtin OpenSSL -# library. -Provides: bundled(openssl) = %{OPENSSL_VER} -License: BSD-2-Clause-Patent and OpenSSL - -# URL taken from the Maintainers.txt file. -URL: http://www.tianocore.org/ovmf/ - -%description ovmf -OVMF (Open Virtual Machine Firmware) is a project to enable UEFI support for -Virtual Machines. This package contains a sample 64-bit UEFI firmware for QEMU -and KVM. - -%else -%package aarch64 -Summary: UEFI firmware for aarch64 virtual machines -BuildArch: noarch -Provides: AAVMF = %{version}-%{release} -Obsoletes: AAVMF < 20180508-100.gitee3198e672e2.el7 - -# No Secure Boot for AAVMF yet, but we include OpenSSL for the IPv6 stack. -Provides: bundled(openssl) = %{OPENSSL_VER} -License: BSD-2-Clause-Patent and OpenSSL - -# URL taken from the Maintainers.txt file. -URL: https://github.com/tianocore/tianocore.github.io/wiki/ArmVirtPkg - -%description aarch64 -AAVMF (ARM Architecture Virtual Machine Firmware) is an EFI Development Kit II -platform that enables UEFI support for QEMU/KVM ARM Virtual Machines. This -package contains a 64-bit build. -%endif - -%package tools -Summary: EFI Development Kit II Tools -Group: Development/Tools -License: BSD-2-Clause-Patent -URL: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools -%description tools -This package provides tools that are needed to -build EFI executables and ROMs using the GNU tools. - -%package tools-doc -Summary: Documentation for EFI Development Kit II Tools -Group: Development/Tools -BuildArch: noarch -License: BSD-2-Clause-Patent -URL: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools -%description tools-doc -This package documents the tools that are needed to -build EFI executables and ROMs using the GNU tools. - -%description -EDK II is a modern, feature-rich, cross-platform firmware development -environment for the UEFI and PI specifications. This package contains sample -64-bit UEFI firmware builds for QEMU and KVM. - -%prep -%setup -q -n edk2-%{GITCOMMIT} - -%{lua: - tmp = os.tmpname(); - f = io.open(tmp, "w+"); - count = 0; - for i, p in ipairs(patches) do - f:write(p.."\n"); - count = count + 1; - end; - f:close(); - print("PATCHCOUNT="..count.."\n") - print("PATCHLIST="..tmp.."\n") -} - -git init -q -git config user.name rpm-build -git config user.email rpm-build -git config core.whitespace cr-at-eol -git config am.keepcr true -git add -A . -git commit -q -a --author 'rpm-build ' \ - -m '%{name}-%{GITCOMMIT} base' - -COUNT=$(grep '\.patch$' $PATCHLIST | wc -l) -if [ $COUNT -ne $PATCHCOUNT ]; then - echo "Found $COUNT patches in $PATCHLIST, expected $PATCHCOUNT" - exit 1 -fi -if [ $COUNT -gt 0 ]; then - for pf in `cat $PATCHLIST`; do - git am $pf - done -fi -echo "Applied $COUNT patches" -rm -f $PATCHLIST - -cp -a -- %{SOURCE1} %{SOURCE3} . -cp -a -- %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} . -tar -C CryptoPkg/Library/OpensslLib -a -f %{SOURCE2} -x - -# Format the Red Hat-issued certificate that is to be enrolled as both Platform -# Key and first Key Exchange Key, as an SMBIOS OEM String. This means stripping -# the PEM header and footer, and prepending the textual representation of the -# GUID that identifies this particular OEM String to "EnrollDefaultKeys.efi", -# plus the separator ":". For details, see -# comments 2, 7, 14. -sed \ - -e 's/^-----BEGIN CERTIFICATE-----$/4e32566d-8e9e-4f52-81d3-5bb9715f9727:/' \ - -e '/^-----END CERTIFICATE-----$/d' \ - %{SOURCE5} \ - > PkKek1.oemstr - -# Hack to ensure git lock is removed before chmod starts to not fail -sleep 5 -# Done by %setup, but we do not use it for the auxiliary tarballs -chmod -Rf a+rX,u+w,g-w,o-w . - -%build -export PYTHON_COMMAND=%{__python3} -source ./edksetup.sh -make -C "$EDK_TOOLS_PATH" \ - %{?_smp_mflags} \ - EXTRA_OPTFLAGS="%{optflags}" \ - EXTRA_LDFLAGS="%{__global_ldflags}" - -SMP_MFLAGS="%{?_smp_mflags}" -if [[ x"$SMP_MFLAGS" = x-j* ]]; then - CC_FLAGS="$CC_FLAGS -n ${SMP_MFLAGS#-j}" -elif [ -n "%{?jobs}" ]; then - CC_FLAGS="$CC_FLAGS -n %{?jobs}" -fi - -CC_FLAGS="$CC_FLAGS --cmd-len=65536 -t %{TOOLCHAIN} -b DEBUG --hash" -CC_FLAGS="$CC_FLAGS -D NETWORK_IP6_ENABLE" -CC_FLAGS="$CC_FLAGS -D NETWORK_HTTP_BOOT_ENABLE -D NETWORK_TLS_ENABLE" - -%ifarch x86_64 -# Build with neither SB nor SMM; include UEFI shell. -build ${CC_FLAGS} -D TPM_ENABLE -D FD_SIZE_4MB -a X64 \ - -D PVSCSI_ENABLE=FALSE -D MPT_SCSI_ENABLE=FALSE \ - -p OvmfPkg/OvmfPkgX64.dsc - -# Build with SB and SMM; exclude UEFI shell. -build -D SECURE_BOOT_ENABLE -D EXCLUDE_SHELL_FROM_FD ${CC_FLAGS} \ - -a IA32 -a X64 -p OvmfPkg/OvmfPkgIa32X64.dsc -D SMM_REQUIRE \ - -D PVSCSI_ENABLE=FALSE -D MPT_SCSI_ENABLE=FALSE \ - -D TPM_ENABLE -D FD_SIZE_4MB - -# Sanity check: the varstore templates must be identical. -cmp Build/OvmfX64/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.fd \ - Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.fd - -# Prepare an ISO image that boots the UEFI shell. -( - UEFI_SHELL_BINARY=Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/X64/Shell.efi - ENROLLER_BINARY=Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/X64/EnrollDefaultKeys.efi - UEFI_SHELL_IMAGE=uefi_shell.img - ISO_IMAGE=UefiShell.iso - - UEFI_SHELL_BINARY_BNAME=$(basename -- "$UEFI_SHELL_BINARY") - UEFI_SHELL_SIZE=$(stat --format=%s -- "$UEFI_SHELL_BINARY") - ENROLLER_SIZE=$(stat --format=%s -- "$ENROLLER_BINARY") - - # add 1MB then 10% for metadata - UEFI_SHELL_IMAGE_KB=$(( - (UEFI_SHELL_SIZE + ENROLLER_SIZE + 1 * 1024 * 1024) * 11 / 10 / 1024 - )) - - # create non-partitioned FAT image - rm -f -- "$UEFI_SHELL_IMAGE" - mkdosfs -C "$UEFI_SHELL_IMAGE" -n UEFI_SHELL -- "$UEFI_SHELL_IMAGE_KB" - - # copy the shell binary into the FAT image - export MTOOLS_SKIP_CHECK=1 - mmd -i "$UEFI_SHELL_IMAGE" ::efi - mmd -i "$UEFI_SHELL_IMAGE" ::efi/boot - mcopy -i "$UEFI_SHELL_IMAGE" "$UEFI_SHELL_BINARY" ::efi/boot/bootx64.efi - mcopy -i "$UEFI_SHELL_IMAGE" "$ENROLLER_BINARY" :: - mdir -i "$UEFI_SHELL_IMAGE" -/ :: - - # build ISO with FAT image file as El Torito EFI boot image - genisoimage -input-charset ASCII -J -rational-rock \ - -efi-boot "$UEFI_SHELL_IMAGE" -no-emul-boot \ - -o "$ISO_IMAGE" -- "$UEFI_SHELL_IMAGE" -) - -# Enroll the default certificates in a separate variable store template. -%{__python3} ovmf-vars-generator --verbose --verbose \ - --qemu-binary /usr/libexec/qemu-kvm \ - --ovmf-binary Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_CODE.fd \ - --ovmf-template-vars Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.fd \ - --uefi-shell-iso UefiShell.iso \ - --oem-string "$(< PkKek1.oemstr)" \ - --skip-testing \ - OVMF_VARS.secboot.fd - -%else -# Build with a verbose debug mask first, and stash the binary. -build ${CC_FLAGS} -a AARCH64 \ - -p ArmVirtPkg/ArmVirtQemu.dsc \ - -D TPM2_ENABLE \ - -D DEBUG_PRINT_ERROR_LEVEL=0x8040004F -cp -a Build/ArmVirtQemu-AARCH64/DEBUG_%{TOOLCHAIN}/FV/QEMU_EFI.fd \ - QEMU_EFI.verbose.fd - -# Rebuild with a silent (errors only) debug mask. -build ${CC_FLAGS} -a AARCH64 \ - -p ArmVirtPkg/ArmVirtQemu.dsc \ - -D TPM2_ENABLE \ - -D DEBUG_PRINT_ERROR_LEVEL=0x80000000 -%endif - -%install - -cp -a OvmfPkg/License.txt License.OvmfPkg.txt -mkdir -p $RPM_BUILD_ROOT%{_datadir}/qemu/firmware - -%ifarch x86_64 -mkdir -p \ - $RPM_BUILD_ROOT%{_datadir}/OVMF \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf - -install -m 0644 Build/OvmfX64/DEBUG_%{TOOLCHAIN}/FV/OVMF_CODE.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/OVMF_CODE.cc.fd -install -m 0644 Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_CODE.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/OVMF_CODE.secboot.fd - -install -m 0644 Build/OvmfX64/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/OVMF_VARS.fd -install -m 0644 OVMF_VARS.secboot.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/OVMF_VARS.secboot.fd -install -m 0644 UefiShell.iso \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/UefiShell.iso - -ln -s ../%{name}/ovmf/OVMF_CODE.secboot.fd $RPM_BUILD_ROOT%{_datadir}/OVMF/ -ln -s ../%{name}/ovmf/OVMF_VARS.fd $RPM_BUILD_ROOT%{_datadir}/OVMF/ -ln -s ../%{name}/ovmf/OVMF_VARS.secboot.fd $RPM_BUILD_ROOT%{_datadir}/OVMF/ -ln -s ../%{name}/ovmf/UefiShell.iso $RPM_BUILD_ROOT%{_datadir}/OVMF/ - -install -m 0644 Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/X64/Shell.efi \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/Shell.efi -install -m 0644 Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/X64/EnrollDefaultKeys.efi \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/ovmf/EnrollDefaultKeys.efi - -install -m 0644 edk2-ovmf-sb.json \ - $RPM_BUILD_ROOT%{_datadir}/qemu/firmware/40-edk2-ovmf-sb.json -install -m 0644 edk2-ovmf.json \ - $RPM_BUILD_ROOT%{_datadir}/qemu/firmware/50-edk2-ovmf.json -install -m 0644 edk2-ovmf-cc.json \ - $RPM_BUILD_ROOT%{_datadir}/qemu/firmware/50-edk2-ovmf-cc.json - -%else -mkdir -p \ - $RPM_BUILD_ROOT%{_datadir}/AAVMF \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64 - -# Pad and install the verbose binary. -cat QEMU_EFI.verbose.fd \ - /dev/zero \ -| head -c 64m \ - > $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/QEMU_EFI-pflash.raw - -# Pad and install the silent (default) binary. -cat Build/ArmVirtQemu-AARCH64/DEBUG_%{TOOLCHAIN}/FV/QEMU_EFI.fd \ - /dev/zero \ -| head -c 64m \ - > $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/QEMU_EFI-silent-pflash.raw - -# Create varstore template. -cat Build/ArmVirtQemu-AARCH64/DEBUG_%{TOOLCHAIN}/FV/QEMU_VARS.fd \ - /dev/zero \ -| head -c 64m \ - > $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/vars-template-pflash.raw - -ln -s ../%{name}/aarch64/QEMU_EFI-pflash.raw \ - $RPM_BUILD_ROOT%{_datadir}/AAVMF/AAVMF_CODE.verbose.fd -ln -s ../%{name}/aarch64/QEMU_EFI-silent-pflash.raw \ - $RPM_BUILD_ROOT%{_datadir}/AAVMF/AAVMF_CODE.fd -ln -s ../%{name}/aarch64/vars-template-pflash.raw \ - $RPM_BUILD_ROOT%{_datadir}/AAVMF/AAVMF_VARS.fd - -chmod 0644 -- $RPM_BUILD_ROOT%{_datadir}/AAVMF/AAVMF_*.fd - -install -m 0644 QEMU_EFI.verbose.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/QEMU_EFI.fd -install -m 0644 Build/ArmVirtQemu-AARCH64/DEBUG_%{TOOLCHAIN}/FV/QEMU_EFI.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/QEMU_EFI.silent.fd -install -m 0644 Build/ArmVirtQemu-AARCH64/DEBUG_%{TOOLCHAIN}/FV/QEMU_VARS.fd \ - $RPM_BUILD_ROOT%{_datadir}/%{name}/aarch64/QEMU_VARS.fd - -install -m 0644 edk2-aarch64.json \ - $RPM_BUILD_ROOT%{_datadir}/qemu/firmware/60-edk2-aarch64.json -install -m 0644 edk2-aarch64-verbose.json \ - $RPM_BUILD_ROOT%{_datadir}/qemu/firmware/70-edk2-aarch64-verbose.json - -%endif - -cp -a CryptoPkg/Library/OpensslLib/openssl/LICENSE LICENSE.openssl - -# install the tools -mkdir -p %{buildroot}%{_bindir} \ - %{buildroot}%{_datadir}/%{name}/Conf \ - %{buildroot}%{_datadir}/%{name}/Scripts -install BaseTools/Source/C/bin/* \ - %{buildroot}%{_bindir} -install BaseTools/BinWrappers/PosixLike/LzmaF86Compress \ - %{buildroot}%{_bindir} -install BaseTools/BuildEnv \ - %{buildroot}%{_datadir}/%{name} -install BaseTools/Conf/*.template \ - %{buildroot}%{_datadir}/%{name}/Conf -install BaseTools/Scripts/GccBase.lds \ - %{buildroot}%{_datadir}/%{name}/Scripts - -%ifarch x86_64 -%files ovmf -%else -%files aarch64 -%endif - -%defattr(-,root,root,-) -%license License.txt -%license License.OvmfPkg.txt -%license License-History.txt -%license LICENSE.openssl -%dir %{_datadir}/%{name}/ -%dir %{_datadir}/qemu -%dir %{_datadir}/qemu/firmware - -%ifarch x86_64 -%doc OvmfPkg/README -%doc ovmf-whitepaper-c770f8c.txt -%dir %{_datadir}/OVMF/ -%dir %{_datadir}/%{name}/ovmf/ -%{_datadir}/%{name}/ovmf/OVMF_CODE.cc.fd -%{_datadir}/%{name}/ovmf/OVMF_CODE.secboot.fd -%{_datadir}/%{name}/ovmf/OVMF_VARS.fd -%{_datadir}/%{name}/ovmf/OVMF_VARS.secboot.fd -%{_datadir}/%{name}/ovmf/UefiShell.iso -%{_datadir}/OVMF/OVMF_CODE.secboot.fd -%{_datadir}/OVMF/OVMF_VARS.fd -%{_datadir}/OVMF/OVMF_VARS.secboot.fd -%{_datadir}/OVMF/UefiShell.iso -%{_datadir}/%{name}/ovmf/Shell.efi -%{_datadir}/%{name}/ovmf/EnrollDefaultKeys.efi -%{_datadir}/qemu/firmware/40-edk2-ovmf-sb.json -%{_datadir}/qemu/firmware/50-edk2-ovmf-cc.json -%{_datadir}/qemu/firmware/50-edk2-ovmf.json - -%else -%dir %{_datadir}/AAVMF/ -%dir %{_datadir}/%{name}/aarch64/ -%{_datadir}/%{name}/aarch64/QEMU_EFI-pflash.raw -%{_datadir}/%{name}/aarch64/QEMU_EFI-silent-pflash.raw -%{_datadir}/%{name}/aarch64/vars-template-pflash.raw -%{_datadir}/AAVMF/AAVMF_CODE.verbose.fd -%{_datadir}/AAVMF/AAVMF_CODE.fd -%{_datadir}/AAVMF/AAVMF_VARS.fd -%{_datadir}/%{name}/aarch64/QEMU_EFI.fd -%{_datadir}/%{name}/aarch64/QEMU_EFI.silent.fd -%{_datadir}/%{name}/aarch64/QEMU_VARS.fd -%{_datadir}/qemu/firmware/60-edk2-aarch64.json -%{_datadir}/qemu/firmware/70-edk2-aarch64-verbose.json -%endif - -%files tools -%license License.txt -%license License-History.txt -%{_bindir}/DevicePath -%{_bindir}/EfiRom -%{_bindir}/GenCrc32 -%{_bindir}/GenFfs -%{_bindir}/GenFv -%{_bindir}/GenFw -%{_bindir}/GenSec -%{_bindir}/LzmaCompress -%{_bindir}/LzmaF86Compress -%{_bindir}/TianoCompress -%{_bindir}/VfrCompile -%{_bindir}/VolInfo -%dir %{_datadir}/%{name} -%{_datadir}/%{name}/BuildEnv -%{_datadir}/%{name}/Conf -%{_datadir}/%{name}/Scripts - -%files tools-doc -%doc BaseTools/UserManuals/*.rtf - -%check - -%ifarch x86_64 -# Of the installed host kernels, boot the one with the highest Version-Release -# under OVMF, and check if it prints "Secure boot enabled". -KERNEL_PKG=$(rpm -q kernel-core | rpmdev-sort | tail -n 1) -KERNEL_IMG=$(rpm -q -l $KERNEL_PKG | egrep '^/lib/modules/[^/]+/vmlinuz$') - -%{__python3} ovmf-vars-generator --verbose --verbose \ - --qemu-binary /usr/libexec/qemu-kvm \ - --ovmf-binary Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_CODE.fd \ - --ovmf-template-vars Build/Ovmf3264/DEBUG_%{TOOLCHAIN}/FV/OVMF_VARS.fd \ - --uefi-shell-iso UefiShell.iso \ - --kernel-path $KERNEL_IMG \ - --skip-enrollment \ - --no-download \ - OVMF_VARS.secboot.fd - -%else -true - -%endif - -%changelog -* Mon Aug 26 2024 Jon Maloy - 20220126gitbb1bba3d77-13.el8.3 -- edk2-OvmfPkg-Add-Hash2DxeCrypto-to-OvmfPkg.patch [RHEL-53009] -- Resolves: RHEL-53009 - (No http boot support on edk2-ovmf-20231122-6.el9_4.2 [rhel-8.10.z]) - -* Wed Jul 10 2024 Jon Maloy - 20220126gitbb1bba3d77-13.el8_10.2 - -* Wed Jul 03 2024 Miroslav Rezanina - 20220126gitbb1bba3d77-13.el8_10.1 -- edk2-MdeModulePkg-Change-use-of-EFI_D_-to-DEBUG_.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdeModulePkg-Potential-UINT32-overflow-in-S3-ResumeC.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-Apply-uncrustify-changes.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-NetworkPkg-Apply-uncrustify-changes.p2.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Rename-RdRandGenerateEntropy-to-g.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Remove-ArchGetSupportedRngAlgorit.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Documentation-include-parameter-c.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Check-before-advertising-Cpu-Rng-.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Add-AArch64-RawAlgorithm-support-.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Add-debug-warning-for-NULL-PcdCpu.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Rename-AArch64-RngDxe.c.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Add-Arm-support-of-RngDxe.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Correctly-update-mAvailableAlgoAr.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Conditionally-install-EFI_RNG_PRO.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdeModulePkg-Duplicate-BaseRngLibTimerLib-to-MdeModu.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-Add-deprecated-warning-to-BaseRngLibTimer.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-SecurityPkg.dec-Move-PcdCpuRngSupportedA.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-DxeRngLib-Request-raw-algorithm-instead-of-de.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-Rng-Add-GUID-to-describe-Arm-Rndr-Rng-algorit.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdeModulePkg-Rng-Add-GUID-to-describe-unsafe-Rng-alg.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-Rng-Add-GetRngGuid-to-RngLib.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Use-GetRngGuid-when-probing-RngLi.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-Simplify-Rng-algorithm-selection-.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-NetworkPkg-SECURITY-PATCH-CVE-2023-45237.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-SecurityPkg-RngDxe-add-rng-test.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-OvmfPkg-wire-up-RngDxe.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-NetworkPkg-TcpDxe-SECURITY-PATCH-CVE-2023-45236.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- edk2-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch [RHEL-21854 RHEL-21856 RHEL-40099] -- Resolves: RHEL-21854 - (CVE-2023-45236 edk2: Predictable TCP Initial Sequence Numbers [rhel-8]) -- Resolves: RHEL-21856 - (CVE-2023-45237 edk2: Use of a Weak PseudoRandom Number Generator [rhel-8]) -- Resolves: RHEL-40099 - (CVE-2024-1298 edk2: Temporary DoS vulnerability [rhel-8.10.z]) - -* Thu Mar 14 2024 Miroslav Rezanina - 20220126gitbb1bba3d77-13 -- edk2-EmbeddedPkg-Hob-Integer-Overflow-in-CreateHob.patch [RHEL-21158] -- edk2-StandaloneMmPkg-Hob-Integer-Overflow-in-CreateHob.patch [RHEL-21158] -- Resolves: RHEL-21158 - (CVE-2022-36765 edk2: integer overflow in CreateHob() could lead to HOB OOB R/W [rhel-8]) - -* Tue Feb 27 2024 Miroslav Rezanina - 20220126gitbb1bba3d77-12 -- edk2-Apply-uncrustify-changes-to-.c-.h-files-in-the-Netwo.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Patc.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45231-Unit.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Patc.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Ip6Dxe-SECURITY-PATCH-CVE-2023-45232-Unit.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Apply-uncrustify-changes.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p2.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p3.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-UefiPxeBcDxe-SECURITY-PATCH-CVE-2023-4523p4.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Adds-a-SecurityFix.yaml-file.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Apply-uncrustify-changes-p2.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Re.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Dhcp6Dxe-Removes-duplicate-check-and-repl.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- edk2-NetworkPkg-Dhcp6Dxe-Packet-Length-is-not-updated-bef.patch [RHEL-21840 RHEL-21844 RHEL-21846 RHEL-21848 RHEL-21850 RHEL-21852] -- Resolves: RHEL-21840 - (CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8]) -- Resolves: RHEL-21844 - (CVE-2023-45231 edk2: Out of Bounds read when handling a ND Redirect message with truncated options [rhel-8]) -- Resolves: RHEL-21846 - (CVE-2023-45232 edk2: Infinite loop when parsing unknown options in the Destination Options header [rhel-8]) -- Resolves: RHEL-21848 - (CVE-2023-45233 edk2: Infinite loop when parsing a PadN option in the Destination Options header [rhel-8]) -- Resolves: RHEL-21850 - (CVE-2023-45234 edk2: Buffer overflow when processing DNS Servers option in a DHCPv6 Advertise message [rhel-8]) -- Resolves: RHEL-21852 - (CVE-2023-45235 edk2: Buffer overflow when handling Server ID option from a DHCPv6 proxy Advertise message [rhel-8]) - -* Wed Feb 14 2024 Jon Maloy - 20220126gitbb1bba3d77-11 -- edk2-SecurityPkg-Change-use-of-EFI_D_-to-DEBUG_.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-Change-OPTIONAL-keyword-usage-style.patch [RHEL-21154 RHEL-21156] -- edk2-MdePkg-Introduce-CcMeasurementProtocol-for-CC-Guest-.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpm2.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-Support-CcMeasurementProtocol-in-DxeTpmM.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-411.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4117.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-Adding-CVE-2022-36763-to-SecurityFixes.y.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpm2MeasureBootLib-SECURITY-PATCH-418.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpmMeasureBootLib-SECURITY-PATCH-4118.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpm2MeasureBootLib-SEC-PATCH-4118-2.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-DxeTpmMeasureBootLib-SEC-PATCH-4117-2.patch [RHEL-21154 RHEL-21156] -- edk2-SecurityPkg-Updating-SecurityFixes.yaml-after-symbol.patch [RHEL-21154 RHEL-21156] -- edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Pa.patch [RHEL-21840 RHEL-21842] -- edk2-NetworkPkg-Add-Unit-tests-to-CI-and-create-Host-Test.patch [RHEL-21840 RHEL-21842] -- edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45230-Un.patch [RHEL-21840 RHEL-21842] -- edk2-NetworkPkg-Dhcp6Dxe-SECURITY-PATCH-CVE-2023-45229-Pa.patch [RHEL-21840 RHEL-21842] -- Resolves: RHEL-21154 - (CVE-2022-36763 edk2: heap buffer overflow in Tcg2MeasureGptTable() [rhel-8]) -- Resolves: RHEL-21156 - (CVE-2022-36764 edk2: heap buffer overflow in Tcg2MeasurePeImage() [rhel-8]) -- Resolves: RHEL-21840 - (CVE-2023-45229 edk2: Integer underflow when processing IA_NA/IA_TA options in a DHCPv6 Advertise message [rhel-8]) -- Resolves: RHEL-21842 - (CVE-2023-45230 edk2: Buffer overflow in the DHCPv6 client via a long Server ID option [rhel-8]) - -* Sat Feb 03 2024 Jon Maloy - 20220126gitbb1bba3d77-10 -- edk2-OvmfPkg-VirtNorFlashDxe-clone-ArmPlatformPkg-s-NOR-f.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-remove-CheckBlockLocked-feat.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-remove-disk-I-O-protocol-imp.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-drop-block-I-O-protocol-impl.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-avoid-array-mode-switch-afte.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-avoid-switching-between-mode.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-use-EFI_MEMORY_WC-and-drop-A.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-map-flash-memory-as-uncachea.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariable2.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variable2.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-add-casts-to-UINTN-and-UINT3.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-clarify-block-write-logic-fi.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-add-a-loop-for-NorFlashWrite.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-allow-larger-writes-without-.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-ValidateFvHeader-unwritten-s.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-move-DoErase-code-block-into.patch [RHEL-17587] -- edk2-ArmVirtPkg-ArmVirtQemu-migrate-to-OVMF-s-VirtNorFlas.patch [RHEL-17587] -- edk2-OvmfPkg-clone-NorFlashPlatformLib-into-VirtNorFlashP.patch [RHEL-17587] -- Resolves: RHEL-17587 - ([rhel8] guest fails to boot due to ASSERT error) - -* Wed Jan 24 2024 Jon Maloy - 20220126gitbb1bba3d77-9 -- edk2-OvmfPkg-VirtNorFlashDxe-stop-accepting-gEfiVariableG.patch [RHEL-17587] -- edk2-OvmfPkg-VirtNorFlashDxe-sanity-check-variables.patch [RHEL-17587] -- Resolves: RHEL-17587 - ([rhel8] guest fails to boot due to ASSERT error) - -* Fri Jan 05 2024 Jon Maloy - 20220126gitbb1bba3d77-8 -- edk2-Bumped-openssl-submodule-version-to-cf317b2bb227.patch [RHEL-7560] -- Resolves: RHEL-7560 - (CVE-2023-3446 edk2: openssl: Excessive time spent checking DH keys and parameters [rhel-8]) - -* Wed Nov 22 2023 Miroslav Rezanina - 20220126gitbb1bba3d77-7 -- edk2-add-8.6-machine-type-to-edk2-ovmf-cc.json.patch [RHEL-12626] -- Resolves: RHEL-12626 - (Missing firmware descriptor with secureboot disabled in RHEL 8) - -* Fri Aug 04 2023 Jon Maloy - 20220126gitbb1bba3d77-6 -- edk2-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch [bz#2150267] -- Resolves: bz#2150267 - (ovmf must consider max cpu count not boot cpu count for apic mode [rhel-8]) - -* Thu Apr 06 2023 Miroslav Rezanina - 20220126gitbb1bba3d77-5 -- edk2-SecurityPkg-DxeImageVerificationLib-Check-result-of-.patch [bz#1861743] -- Resolves: bz#1861743 - (CVE-2019-14560 edk2: Function GetEfiGlobalVariable2() return value not checked in DxeImageVerificationHandler() [rhel-8]) - -* Wed Feb 15 2023 Jon Maloy - 20220126gitbb1bba3d77-4 -- edk2-openssl-update.patch [bz#2164531 bz#2164543 bz#2164558 bz#2164581] -- edk2-rh-openssl-add-crypto-bn-rsa_sup_mul.c-to-file-list.patch [bz#2164531 bz#2164543 bz#2164558 bz#2164581] -- Resolves: bz#2164531 - (CVE-2023-0286 edk2: openssl: X.400 address type confusion in X.509 GeneralName [rhel-8]) -- Resolves: bz#2164543 - (CVE-2022-4304 edk2: openssl: timing attack in RSA Decryption implementation [rhel-8]) -- Resolves: bz#2164558 - (CVE-2023-0215 edk2: openssl: use-after-free following BIO_new_NDEF [rhel-8]) -- Resolves: bz#2164581 - (CVE-2022-4450 edk2: openssl: double free after calling PEM_read_bio_ex [rhel-8]) - -* Tue Aug 02 2022 Camilla Conte - 20220126gitbb1bba3d77-3 -- Bumping OpenSSL version [bz# 2074834] -- Resolves: bz# 2074834 - (edk2: sync openssl sources with rhel openssl rpm) - -* Tue Mar 01 2022 Jon Maloy - 20220126gitbb1bba3d77-2 -- edk2-OvmfPkg-AmdSev-SecretPei-Mark-SEV-launch-secret-area.patch [bz#2112307] -- Resolves: bz#2112307 - (Mark SEV launch secret area as reserved) - -* Wed Feb 02 2022 Jon Maloy - 20220126gitbb1bba3d77-1.el8 -- Rebase to latest upstream release [bz#2018386] -- Resolves: bz#2018386 - ([rebase] update edk2 to nov '21 release (edk2-stable202111xx)) - -* Fri Aug 06 2021 Miroslav Rezanina - 20210527gite1999b264f1f-3 -- edk2-MdeModulePkg-PartitionDxe-Ignore-PMBR-BootIndicator-.patch [bz#1988762] -- Resolves: bz#1988762 - (edk2 does not ignore PMBR protective record BootIndicator as required by UEFI spec) - -* Fri Jul 02 2021 Miroslav Rezanina - 20210527gite1999b264f1f-2 -- edk2-NetworkPkg-IScsiDxe-wrap-IScsiCHAP-source-files-to-8.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-simplify-ISCSI_CHAP_AUTH_DATA.In.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-clean-up-ISCSI_CHAP_AUTH_DATA.Ou.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-clean-up-library-class-dependenc.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-fix-potential-integer-overflow-i.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-assert-that-IScsiBinToHex-always.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-reformat-IScsiHexToBin-leading-c.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-hex-parsing.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-buffer-overflo.patch [bz#1956408] -- edk2-NetworkPkg-IScsiDxe-check-IScsiHexToBin-return-value.patch [bz#1956408] -- Resolves: bz#1956408 - (edk2: remote buffer overflow in IScsiHexToBin function in NetworkPkg/IScsiDxe [rhel-8.5.0]) - -* Wed Jun 23 2021 Miroslav Rezanina - 20210527gite1999b264f1f-1 -- Rebase to edk2-stable202105 [bz#1938238] -- Resolves: bz#1938238 - ((edk2-rebase-rhel-8.5) - rebase edk2 to edk2-stable202105 for RHEL-8.5) - -* Wed May 12 2021 Miroslav Rezanina - 20200602gitca407c7246bf-5.el8 -- edk2-MdeModulePkg-LzmaCustomDecompressLib-catch-4GB-uncom.patch [bz#1892318] -- edk2-redhat-add-OVMF-binary-that-will-support-SEV-ES.patch [bz#1956837] -- Resolves: bz#1892318 - (edk2: possible heap corruption with LzmaUefiDecompressGetInfo [rhel-8]) -- Resolves: bz#1956837 - (Additional build of edk2 without SMM (dual build / sub-package) for SEV-ES) - -* Mon Nov 23 2020 Miroslav Rezanina - 20200602gitca407c7246bf-4.el8 -- edk2-OvmfPkg-SmmControl2Dxe-negotiate-ICH9_LPC_SMI_F_CPU_.patch [bz#1849177] -- edk2-OvmfPkg-CpuHotplugSmm-fix-CPU-hotplug-race-just-befo.patch [bz#1849177] -- edk2-OvmfPkg-CpuHotplugSmm-fix-CPU-hotplug-race-just-afte.patch [bz#1849177] -- edk2-CryptoPkg-OpensslLib-Upgrade-OpenSSL-to-1.1.1g.patch [bz#1893806] -- edk2-redhat-bump-OpenSSL-dist-git-submodule-to-1.1.1g-RHE.patch [bz#1893806] -- Resolves: bz#1849177 - (OVMF: negotiate "SMI on VCPU hotplug" with QEMU) -- Resolves: bz#1893806 - (attempt advancing RHEL8 edk2's OpenSSL submodule to RHEL8 OpenSSL 1.1.1g (or later)) - -* Mon Aug 10 2020 Miroslav Rezanina - 20200602gitca407c7246bf-3.el8 -- edk2-UefiCpuPkg-PiSmmCpuDxeSmm-pause-in-WaitForSemaphore-.patch [bz#1861718] -- Resolves: bz#1861718 - (Very slow boot when overcommitting CPU) - -* Wed Jun 24 2020 Miroslav Rezanina - 20200602gitca407c7246bf-2.el8 -- edk2-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch [bz#1844682] -- edk2-OvmfPkg-GenericQemuLoadImageLib-log-Not-Found-at-INF.patch [bz#1844682] -- edk2-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch [bz#1844682] -- Resolves: bz#1844682 - (silent build of edk2-aarch64 logs DEBUG_ERROR messages that don't actually report serious errors) - -* Sat Jun 13 2020 Miroslav Rezanina - 20200602gitca407c7246bf-1.el8 -- Rebase to edk2-stable202005 [bz#1817035] -- Resolves: bz#1817035 - ((edk2-rebase-rhel-8.3) - rebase edk2 to upstream tag edk2-stable202005 for RHEL-8.3) - -* Fri Mar 27 2020 Miroslav Rezanina - 20190829git37eef91017ad-9.el8 -- edk2-OvmfPkg-QemuVideoDxe-unbreak-secondary-vga-and-bochs.patch [bz#1806359] -- Resolves: bz#1806359 - (bochs-display cannot show graphic wihout driver attach) - -* Tue Feb 18 2020 Miroslav Rezanina - 20190829git37eef91017ad-8.el8 -- edk2-MdeModulePkg-Enable-Disable-S3BootScript-dynamically.patch [bz#1801274] -- edk2-MdeModulePkg-PiDxeS3BootScriptLib-Fix-potential-nume.patch [bz#1801274] -- Resolves: bz#1801274 - (CVE-2019-14563 edk2: numeric truncation in MdeModulePkg/PiDxeS3BootScriptLib [rhel-8]) - -* Tue Feb 11 2020 Miroslav Rezanina - 20190829git37eef91017ad-7.el8 -- edk2-SecurityPkg-Fix-spelling-errors-PARTIAL-PICK.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-simplify-Ver.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-remove-else-.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-keep-PE-COFF.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-narrow-down-.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-fix-retval-o.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-remove-super.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-unnest-AddIm.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-eliminate-St.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-fix-retval-f.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-fix-imgexec-.patch [bz#1751993] -- edk2-SecurityPkg-DxeImageVerificationHandler-fix-defer-vs.patch [bz#1751993] -- Resolves: bz#1751993 - (DxeImageVerificationLib handles "DENY execute on security violation" like "DEFER execute on security violation" [rhel8]) - -* Tue Jan 21 2020 Miroslav Rezanina - 20190829git37eef91017ad-6.el8 -- edk2-UefiCpuPkg-PiSmmCpuDxeSmm-fix-2M-4K-page-splitting-r.patch [bz#1789335] -- Resolves: bz#1789335 - (VM with edk2 can't boot when setting memory with '-m 2001') - -* Thu Jan 16 2020 Miroslav Rezanina - 20190829git37eef91017ad-5.el8 -- edk2-MdeModulePkg-UefiBootManagerLib-log-reserved-mem-all.patch [bz#1789797] -- edk2-NetworkPkg-HttpDxe-fix-32-bit-truncation-in-HTTPS-do.patch [bz#1789797] -- Resolves: bz#1789797 - (Backport upstream patch series: "UefiBootManagerLib, HttpDxe: tweaks for large HTTP(S) downloads" to improve HTTP(S) Boot experience with large (4GiB+) files) - -* Wed Dec 11 2019 Miroslav Rezanina - 20190829git37eef91017ad-4.el8 -- edk2-redhat-set-guest-RAM-size-to-768M-for-SB-varstore-te.patch [bz#1778301] -- edk2-redhat-re-enable-Secure-Boot-varstore-template-verif.patch [bz#1778301] -- Resolves: bz#1778301 - (re-enable Secure Boot (varstore template) verification in %check) - -* Thu Dec 05 2019 Miroslav Rezanina - 20190829git37eef91017ad-3.el8 -- Update used openssl version [bz#1616029] -- Resolves: bz#1616029 - (rebuild edk2 against the final RHEL-8.2.0 version of OpenSSL-1.1.1) - -* Mon Dec 02 2019 Miroslav Rezanina - 20190829git37eef91017ad-2.el8 -- edk2-MdePkg-Include-Protocol-Tls.h-Add-the-data-type-of-E.patch [bz#1536624] -- edk2-CryptoPkg-TlsLib-Add-the-new-API-TlsSetVerifyHost-CV.patch [bz#1536624] -- edk2-CryptoPkg-Crt-turn-strchr-into-a-function-CVE-2019-1.patch [bz#1536624] -- edk2-CryptoPkg-Crt-satisfy-inet_pton.c-dependencies-CVE-2.patch [bz#1536624] -- edk2-CryptoPkg-Crt-import-inet_pton.c-CVE-2019-14553.patch [bz#1536624] -- edk2-CryptoPkg-TlsLib-TlsSetVerifyHost-parse-IP-address-l.patch [bz#1536624] -- edk2-NetworkPkg-TlsDxe-Add-the-support-of-host-validation.patch [bz#1536624] -- edk2-NetworkPkg-HttpDxe-Set-the-HostName-for-the-verifica.patch [bz#1536624] -- edk2-redhat-enable-HTTPS-Boot.patch [bz#1536624] -- Resolves: bz#1536624 - (HTTPS enablement in OVMF) - -* Fri Nov 29 2019 Miroslav Rezanina - 20190829git37eef91017ad-1.el8 -- Rebase to edk2-stable201908 [bz#1748180] -- Resolves: bz#1748180 - ((edk2-rebase-rhel-8.2) - rebase edk2 to upstream tag edk2-stable201908 for RHEL-8.2) - -* Mon Aug 05 2019 Miroslav Rezanina - 20190308git89910a39dcfd-6.el8 -- edk2-ArmVirtPkg-silence-DEBUG_VERBOSE-masking-0x00400000-.patch [bz#1714446] -- edk2-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch [bz#1714446] -- edk2-ArmPkg-DebugPeCoffExtraActionLib-debugger-commands-a.patch [bz#1714446] -- Resolves: bz#1714446 - (edk2-aarch64 silent build is not silent enough) - -* Tue Jul 02 2019 Miroslav Rezanina - 20190308git89910a39dcfd-5.el8 -- edk2-redhat-add-D-TPM2_ENABLE-to-the-edk2-ovmf-build-flag.patch [bz#1693205] -- Resolves: bz#1693205 - (edk2: Enable TPM2 support) - -* Tue Jun 11 2019 Miroslav Rezanina - 20190308git89910a39dcfd-4.el8 -- edk2-OvmfPkg-raise-the-PCIEXBAR-base-to-2816-MB-on-Q35.patch [bz#1666941] -- edk2-OvmfPkg-PlatformPei-set-32-bit-UC-area-at-PciBase-Pc.patch [bz#1666941] -- Resolves: bz#1666941 - (UEFI guest cannot boot into os when setting some special memory size) - -* Tue Apr 09 2019 Danilo Cesar Lemes de Paula - 20190308git89910a39dcfd-2.el8 -- edk2-redhat-provide-firmware-descriptor-meta-files.patch [bz#1600230] -- Resolves: bz#1600230 - ([RHEL 8.1] RFE: provide firmware descriptor meta-files for the edk2-ovmf and edk2-aarch64 firmware images) - -* Mon Apr 08 2019 Danilo Cesar Lemes de Paula - 20190308git89910a39dcfd-1.el8 -- Rebase to edk2-20190308git89910a39dcfd - -* Mon Jan 21 2019 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-9.el8 -- edk2-BaseTools-Fix-UEFI-and-Tiano-Decompression-logic-iss.patch [bz#1662184] -- edk2-MdePkg-BaseUefiDecompressLib-Fix-UEFI-Decompression-.patch [bz#1662184] -- edk2-IntelFrameworkModulePkg-Fix-UEFI-and-Tiano-Decompres.patch [bz#1662184] -- edk2-git-Use-HTTPS-support.patch [] -- Resolves: bz#1662184 - (backport fix for (theoretical?) regression introduced by earlier CVE fixes) - -* Wed Nov 21 2018 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-8.el8 -- edk2-NetworkPkg-UefiPxeBcDxe-Add-EXCLUSIVE-attribute-when.patch [bz#1643377] -- Resolves: bz#1643377 - (Exception when grubx64.efi used for UEFI netboot) - -* Tue Nov 06 2018 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-5.el8 -- edk2-MdeModulePkg-Variable-Fix-Timestamp-zeroing-issue-on.patch [bz#1641436] -- edk2-MdePkg-Add-more-checker-in-UefiDecompressLib-to-acce.patch [bz#1641449 bz#1641453 bz#1641464 bz#1641469] -- edk2-IntelFrameworkModulePkg-Add-more-checker-in-UefiTian.patch [bz#1641453 bz#1641464 bz#1641469] -- edk2-BaseTools-Add-more-checker-in-Decompress-algorithm-t.patch [bz#1641445 bz#1641453 bz#1641464 bz#1641469] -- Resolves: bz#1641436 - (CVE-2018-3613 edk2: Logic error in MdeModulePkg in EDK II firmware allows for privilege escalation by authenticated users [rhel-8]) -- Resolves: bz#1641445 - (CVE-2017-5731 edk2: Privilege escalation via processing of malformed files in TianoCompress.c [rhel-8]) -- Resolves: bz#1641449 - (CVE-2017-5732 edk2: Privilege escalation via processing of malformed files in BaseUefiDecompressLib.c [rhel-8]) -- Resolves: bz#1641453 - (CVE-2017-5733 edk2: Privilege escalation via heap-based buffer overflow in MakeTable() function [rhel-8]) -- Resolves: bz#1641464 - (CVE-2017-5734 edk2: Privilege escalation via stack-based buffer overflow in MakeTable() function [rhel-8]) -- Resolves: bz#1641469 - (CVE-2017-5735 edk2: Privilege escalation via heap-based buffer overflow in Decode() function [rhel-8]) - -* Tue Sep 04 2018 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-5.el8 -- edk2-BaseTools-footer.makefile-expand-BUILD_CFLAGS-last-f.patch [bz#1607906] -- edk2-BaseTools-header.makefile-remove-c-from-BUILD_CFLAGS.patch [bz#1607906] -- edk2-BaseTools-Source-C-split-O2-to-BUILD_OPTFLAGS.patch [bz#1607906] -- edk2-BaseTools-Source-C-take-EXTRA_OPTFLAGS-from-the-call.patch [bz#1607906] -- edk2-BaseTools-Source-C-take-EXTRA_LDFLAGS-from-the-calle.patch [bz#1607906] -- edk2-BaseTools-VfrCompile-honor-EXTRA_LDFLAGS.patch [bz#1607906] -- edk2-redhat-inject-the-RPM-compile-and-link-options-to-th.patch [bz#1607906] -- Resolves: bz#1607906 - (edk2-tools: Does not use RPM build flags) - -* Wed Aug 08 2018 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-4.el8 -- edk2-redhat-provide-virtual-bundled-OpenSSL-in-edk2-ovmf-.patch [bz#1607801] -- Resolves: bz#1607801 - (add 'Provides: bundled(openssl) = 1.1.0h' to the spec file) - -* Tue Jul 24 2018 Danilo Cesar Lemes de Paula - 20180508gitee3198e672e2-3.el8 -- edk2-redhat-Provide-and-Obsolete-OVMF-and-AAVMF.patch [bz#1596148] -- edk2-ArmVirtPkg-unify-HttpLib-resolutions-in-ArmVirt.dsc..patch [bz#1536627] -- edk2-ArmVirtPkg-ArmVirtQemu-enable-the-IPv6-stack.patch [bz#1536627] -- edk2-advertise-OpenSSL-due-to-IPv6-enablement-too-RHEL-on.patch [bz#1536627] -- edk2-redhat-add-D-NETWORK_IP6_ENABLE-to-the-build-flags.patch [bz#1536627] -- edk2-redhat-update-license-fields-and-files-in-the-spec-f.patch [bz#1536627] -- Resolves: bz#1536627 - (IPv6 enablement in OVMF) -- Resolves: bz#1596148 - (restore Provides/Obsoletes macros for OVMF and AAVMF, from RHEL-8 Alpha) - -* Tue Jul 10 2018 Danilo C. L. de Paula - 20180508gitee3198e672e2-2.el8 -- Rebase edk2 on top of 20180508gitee3198e672e2 - -* Fri Jun 08 2018 Miroslav Rezanina - 20180508-2.gitee3198e672e2 -- OvmfPkg/PlatformBootManagerLib: connect consoles unconditionally [bz#1577546] -- build OVMF varstore template with SB enabled / certs enrolled [bz#1561128] -- connect Virtio RNG devices again [bz#1579518] -- Resolves: bz#1577546 - (no input consoles connected under certain circumstances) -- Resolves: bz#1561128 - (OVMF Secure boot enablement (enrollment of default keys)) -- Resolves: bz#1579518 - (EFI_RNG_PROTOCOL no longer produced for virtio-rng) -* Wed Dec 06 2017 Miroslav Rezanina - 20171011-4.git92d07e48907f.el7 -- ovmf-MdeModulePkg-Core-Dxe-log-informative-memprotect-msg.patch [bz#1520485] -- ovmf-MdeModulePkg-BdsDxe-fall-back-to-a-Boot-Manager-Menu.patch [bz#1515418] -- Resolves: bz#1515418 - (RFE: Provide diagnostics for failed boot) -- Resolves: bz#1520485 - (AAVMF: two new messages with silent build) - -* Fri Dec 01 2017 Miroslav Rezanina - 20171011-3.git92d07e48907f.el7 -- ovmf-UefiCpuPkg-CpuDxe-Fix-multiple-entries-of-RT_CODE-in.patch [bz#1518308] -- ovmf-MdeModulePkg-DxeCore-Filter-out-all-paging-capabilit.patch [bz#1518308] -- ovmf-MdeModulePkg-Core-Merge-memory-map-after-filtering-p.patch [bz#1518308] -- Resolves: bz#1518308 - (UEFI memory map regression (runtime code entry splitting) introduced by c1cab54ce57c) - -* Mon Nov 27 2017 Miroslav Rezanina - 20171011-2.git92d07e48907f.el7 -- ovmf-MdeModulePkg-Bds-Remove-assertion-in-BmCharToUint.patch [bz#1513632] -- ovmf-MdeModulePkg-Bds-Check-variable-name-even-if-OptionN.patch [bz#1513632] -- ovmf-MdeModulePkg-PciBus-Fix-bug-that-PCI-BUS-claims-too-.patch [bz#1514105] -- ovmf-OvmfPkg-make-it-a-proper-BASE-library.patch [bz#1488247] -- ovmf-OvmfPkg-create-a-separate-PlatformDebugLibIoPort-ins.patch [bz#1488247] -- ovmf-OvmfPkg-save-on-I-O-port-accesses-when-the-debug-por.patch [bz#1488247] -- ovmf-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch [bz#1488247] -- ovmf-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-QemuVide.patch [bz#1488247] -- ovmf-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch [bz#1488247] -- ovmf-Revert-redhat-introduce-separate-silent-and-verbose-.patch [bz#1488247] -- Resolves: bz#1488247 - (make debug logging no-op unless a debug console is active) -- Resolves: bz#1513632 - ([RHEL-ALT 7.5] AAVMF fails to boot after setting BootNext) -- Resolves: bz#1514105 - (backport edk2 commit 6e3287442774 so that PciBusDxe not over-claim resources) - -* Wed Oct 18 2017 Miroslav Rezanina - 20171011-1.git92d07e48907f.el7 -- Rebase to 92d07e48907f [bz#1469787] -- Resolves: bz#1469787 - ((ovmf-rebase-rhel-7.5) Rebase OVMF for RHEL-7.5) -- Resolves: bz#1434740 - (OvmfPkg/PciHotPlugInitDxe: don't reserve IO space when IO support is disabled) -- Resolves: bz#1434747 - ([Q35] code12 error when hotplug x710 device in win2016) -- Resolves: bz#1447027 - (Guest cannot boot with 240 or above vcpus when using ovmf) -- Resolves: bz#1458192 - ([Q35] recognize "usb-storage" devices in XHCI ports) -- Resolves: bz#1468526 - (>1TB RAM support) -- Resolves: bz#1488247 - (provide "OVMF_CODE.secboot.verbose.fd" for log capturing; silence "OVMF_CODE.secboot.fd") -- Resolves: bz#1496170 - (Inconsistent MOR control variables exposed by OVMF, breaks Windows Device Guard) - -* Fri May 12 2017 Miroslav Rezanina - 20170228-5.gitc325e41585e3.el7 -- ovmf-OvmfPkg-EnrollDefaultKeys-update-SignatureOwner-GUID.patch [bz#1443351] -- ovmf-OvmfPkg-EnrollDefaultKeys-expose-CertType-parameter-.patch [bz#1443351] -- ovmf-OvmfPkg-EnrollDefaultKeys-blacklist-empty-file-in-db.patch [bz#1443351] -- ovmf-OvmfPkg-introduce-the-FD_SIZE_IN_KB-macro-build-flag.patch [bz#1443351] -- ovmf-OvmfPkg-OvmfPkg.fdf.inc-extract-VARS_LIVE_SIZE-and-V.patch [bz#1443351] -- ovmf-OvmfPkg-introduce-4MB-flash-image-mainly-for-Windows.patch [bz#1443351] -- ovmf-OvmfPkg-raise-max-variable-size-auth-non-auth-to-33K.patch [bz#1443351] -- ovmf-OvmfPkg-PlatformPei-handle-non-power-of-two-spare-si.patch [bz#1443351] -- ovmf-redhat-update-local-build-instructions-with-D-FD_SIZ.patch [bz#1443351] -- ovmf-redhat-update-OVMF-build-commands-with-D-FD_SIZE_4MB.patch [bz#1443351] -- Resolves: bz#1443351 - ([svvp][ovmf] job "Secure Boot Logo Test" failed with q35&ovmf) - -* Fri Apr 28 2017 Miroslav Rezanina - 20170228-4.gitc325e41585e3.el7 -- ovmf-ShellPkg-Shell-clean-up-bogus-member-types-in-SPLIT_.patch [bz#1442908] -- ovmf-ShellPkg-Shell-eliminate-double-free-in-RunSplitComm.patch [bz#1442908] -- Resolves: bz#1442908 - (Guest hang when running a wrong command in Uefishell) - -* Tue Apr 04 2017 Miroslav Rezanina - 20170228-3.gitc325e41585e3.el7 -- ovmf-ArmVirtPkg-FdtClientDxe-supplement-missing-EFIAPI-ca.patch [bz#1430262] -- ovmf-ArmVirtPkg-ArmVirtPL031FdtClientLib-unconditionally-.patch [bz#1430262] -- ovmf-MdeModulePkg-RamDiskDxe-fix-C-string-literal-catenat.patch [bz#1430262] -- ovmf-EmbeddedPkg-introduce-EDKII-Platform-Has-ACPI-GUID.patch [bz#1430262] -- ovmf-EmbeddedPkg-introduce-PlatformHasAcpiLib.patch [bz#1430262] -- ovmf-EmbeddedPkg-introduce-EDKII-Platform-Has-Device-Tree.patch [bz#1430262] -- ovmf-ArmVirtPkg-add-PlatformHasAcpiDtDxe.patch [bz#1430262] -- ovmf-ArmVirtPkg-enable-AcpiTableDxe-and-EFI_ACPI_TABLE_PR.patch [bz#1430262] -- ovmf-ArmVirtPkg-FdtClientDxe-install-DT-as-sysconfig-tabl.patch [bz#1430262] -- ovmf-ArmVirtPkg-PlatformHasAcpiDtDxe-don-t-expose-DT-if-Q.patch [bz#1430262] -- ovmf-ArmVirtPkg-remove-PURE_ACPI_BOOT_ENABLE-and-PcdPureA.patch [bz#1430262] -- Resolves: bz#1430262 - (AAVMF: forward QEMU's DT to the guest OS only if ACPI payload is unavailable) - -* Mon Mar 27 2017 Miroslav Rezanina - 20170228-2.gitc325e41585e3.el7 -- ovmf-MdeModulePkg-Core-Dxe-downgrade-CodeSegmentCount-is-.patch [bz#1433428] -- Resolves: bz#1433428 - (AAVMF: Fix error message during ARM guest VM installation) - -* Wed Mar 08 2017 Laszlo Ersek - ovmf-20170228-1.gitc325e41585e3.el7 -- Rebase to upstream c325e41585e3 [bz#1416919] -- Resolves: bz#1373812 - (guest boot from network even set 'boot order=1' for virtio disk with OVMF) -- Resolves: bz#1380282 - (Update OVMF to openssl-1.0.2k-hobbled) -- Resolves: bz#1412313 - (select broadcast SMI if available) -- Resolves: bz#1416919 - (Rebase OVMF for RHEL-7.4) -- Resolves: bz#1426330 - (disable libssl in CryptoPkg) - -* Mon Sep 12 2016 Laszlo Ersek - ovmf-20160608b-1.git988715a.el7 -- rework downstream-only commit dde83a75b566 "setup the tree for the secure - boot feature (RHEL only)", excluding patent-encumbered files from the - upstream OpenSSL 1.0.2g tarball [bz#1374710] -- rework downstream-only commit dfc3ca1ee509 "CryptoPkg/OpensslLib: Upgrade - OpenSSL version to 1.0.2h", excluding patent-encumbered files from the - upstream OpenSSL 1.0.2h tarball [bz#1374710] - -* Thu Aug 04 2016 Miroslav Rezanina - OVMF-20160608-3.git988715a.el7 -- ovmf-MdePkg-PCI-Add-missing-PCI-PCIE-definitions.patch [bz#1332408] -- ovmf-ArmPlatformPkg-NorFlashDxe-accept-both-non-secure-an.patch [bz#1353494] -- ovmf-ArmVirtPkg-ArmVirtQemu-switch-secure-boot-build-to-N.patch [bz#1353494] -- ovmf-ArmPlatformPkg-NorFlashAuthenticatedDxe-remove-this-.patch [bz#1353494] -- ovmf-ArmVirtPkg-add-FDF-definition-for-empty-varstore.patch [bz#1353494] -- ovmf-redhat-package-the-varstore-template-produced-by-the.patch [bz#1353494] -- ovmf-ArmVirtPkg-Re-add-the-Driver-Health-Manager.patch [bz#1353494] -- ovmf-ArmVirtPkg-HighMemDxe-allow-patchable-PCD-for-PcdSys.patch [bz#1353494] -- ovmf-ArmVirtPkg-ArmVirtQemuKernel-make-ACPI-support-AARCH.patch [bz#1353494] -- ovmf-ArmVirtPkg-align-ArmVirtQemuKernel-with-ArmVirtQemu.patch [bz#1353494] -- ovmf-ArmVirtPkg-ArmVirtQemu-factor-out-shared-FV.FvMain-d.patch [bz#1353494] -- ovmf-ArmVirtPkg-factor-out-Rules-FDF-section.patch [bz#1353494] -- ovmf-ArmVirtPkg-add-name-GUIDs-to-FvMain-instances.patch [bz#1353494] -- ovmf-OvmfPkg-add-a-Name-GUID-to-each-Firmware-Volume.patch [bz#1353494] -- ovmf-OvmfPkg-PlatformBootManagerLib-remove-stale-FvFile-b.patch [bz#1353494] -- ovmf-MdePkg-IndustryStandard-introduce-EFI_PCI_CAPABILITY.patch [bz#1332408] -- ovmf-MdeModulePkg-PciBusDxe-look-for-the-right-capability.patch [bz#1332408] -- ovmf-MdeModulePkg-PciBusDxe-recognize-hotplug-capable-PCI.patch [bz#1332408] -- ovmf-OvmfPkg-add-PciHotPlugInitDxe.patch [bz#1332408] -- ovmf-ArmPkg-ArmGicLib-manage-GICv3-SPI-state-at-the-distr.patch [bz#1356655] -- ovmf-ArmVirtPkg-PlatformBootManagerLib-remove-stale-FvFil.patch [bz#1353494] -- ovmf-OvmfPkg-EnrollDefaultKeys-assign-Status-before-readi.patch [bz#1356913] -- ovmf-OvmfPkg-EnrollDefaultKeys-silence-VS2015x86-warning-.patch [bz#1356913] -- ovmf-CryptoPkg-update-openssl-to-ignore-RVCT-3079.patch [bz#1356184] -- ovmf-CryptoPkg-Fix-typos-in-comments.patch [bz#1356184] -- ovmf-CryptoPkg-BaseCryptLib-Avoid-passing-NULL-ptr-to-fun.patch [bz#1356184] -- ovmf-CryptoPkg-BaseCryptLib-Init-the-content-of-struct-Ce.patch [bz#1356184] -- ovmf-CryptoPkg-OpensslLib-Upgrade-OpenSSL-version-to-1.0..patch [bz#1356184] -- Resolves: bz#1332408 - (Q35 machine can not hot-plug scsi controller under switch) -- Resolves: bz#1353494 - ([OVMF] "EFI Internal Shell" should be removed from "Boot Manager") -- Resolves: bz#1356184 - (refresh embedded OpenSSL to 1.0.2h) -- Resolves: bz#1356655 - (AAVMF: stop accessing unmapped gicv3 registers) -- Resolves: bz#1356913 - (fix use-without-initialization in EnrollDefaultKeys.efi) - -* Tue Jul 12 2016 Miroslav Rezanina - OVMF-20160608-2.git988715a.el7 -- ovmf-ArmPkg-ArmGicV3Dxe-configure-all-interrupts-as-non-s.patch [bz#1349407] -- ovmf-ArmVirtPkg-PlatformBootManagerLib-Postpone-the-shell.patch [bz#1353689] -- Resolves: bz#1349407 - (AArch64: backport fix to run over gicv3 emulation) -- Resolves: bz#1353689 - (AAVMF: Drops to shell with uninitialized NVRAM file) - -* Thu Jun 9 2016 Laszlo Ersek - ovmf-20160608-1.git988715a.el7 -- Resolves: bz#1341733 - (prevent SMM stack overflow in OVMF while enrolling certificates in "db") -- Resolves: bz#1257882 - (FEAT: support to boot from virtio 1.0 modern devices) -- Resolves: bz#1333238 - (Q35 machine can not boot up successfully with more than 3 virtio-scsi - storage controller under switch) -- Resolves: bz#1330955 - (VM can not be booted up from hard disk successfully when with a passthrough - USB stick) - -* Thu May 19 2016 Laszlo Ersek - ovmf-20160419-2.git90bb4c5.el7 -- Submit scratch builds from the exploded tree again to - supp-rhel-7.3-candidate, despite FatPkg being OSS at this point; see - bz#1329559. - -* Wed Apr 20 2016 Laszlo Ersek - ovmf-20160419-1.git90bb4c5.el7 -- FatPkg is under the 2-clause BSDL now; "ovmf" has become OSS -- upgrade to openssl-1.0.2g -- Resolves: bz#1323363 - (remove "-D SECURE_BOOT_ENABLE" from AAVMF) -- Resolves: bz#1257882 - (FEAT: support to boot from virtio 1.0 modern devices) -- Resolves: bz#1308678 - (clearly separate SB-less, SMM-less OVMF binary from SB+SMM OVMF binary) - -* Fri Feb 19 2016 Miroslav Rezanina - OVMF-20160202-2.gitd7c0dfa.el7 -- ovmf-restore-TianoCore-splash-logo-without-OpenSSL-advert.patch [bz#1308678] -- ovmf-OvmfPkg-ArmVirtPkg-show-OpenSSL-less-logo-without-Se.patch [bz#1308678] -- ovmf-OvmfPkg-simplify-VARIABLE_STORE_HEADER-generation.patch [bz#1308678] -- ovmf-redhat-bring-back-OVMF_CODE.fd-but-without-SB-and-wi.patch [bz#1308678] -- ovmf-redhat-rename-OVMF_CODE.smm.fd-to-OVMF_CODE.secboot..patch [bz#1308678] - -* Tue Feb 2 2016 Laszlo Ersek - ovmf-20160202-1.gitd7c0dfa.el7 -- rebase to upstream d7c0dfa -- update OpenSSL to 1.0.2e (upstream) -- update FatPkg to SVN r97 (upstream) -- drive NVMe devices (upstream) -- resize xterm on serial console mode change, when requested with - -fw_cfg name=opt/(ovmf|aavmf)/PcdResizeXterm,string=y - (downstream) -- Resolves: bz#1259395 - (revert / roll back AAVMF fix for BZ 1188054) -- Resolves: bz#1202819 - (OVMF: secure boot limitations) -- Resolves: bz#1182495 - (OVMF rejects iPXE oprom when Secure Boot is enabled) - -* Thu Nov 5 2015 Laszlo Ersek - ovmf-20151104-1.gitb9ffeab.el7 -- rebase to upstream b9ffeab -- Resolves: bz#1207554 - ([AAVMF] AArch64: populate SMBIOS) -- Resolves: bz#1270279 - (AAVMF: output improvements) - -* Thu Jun 25 2015 Miroslav Rezanina - OVMF-20150414-2.gitc9e5618.el7 -- ovmf-OvmfPkg-PlatformPei-set-SMBIOS-entry-point-version-d.patch [bz#1232876] -- Resolves: bz#1232876 - (OVMF should install a version 2.8 SMBIOS entry point) - -* Sat Apr 18 2015 Laszlo Ersek - 20150414-1.gitc9e5618.el7 -- rebase from upstream 9ece15a to c9e5618 -- adapt .gitignore files -- update to openssl-0.9.8zf -- create Logo-OpenSSL.bmp rather than modifying Logo.bmp in-place -- update to FatPkg SVN r93 (git 8ff136aa) -- drop the following downstream-only patches (obviated by upstream - counterparts): - "tools_def.template: use forward slash with --add-gnu-debuglink (RHEL only)" - "tools_def.template: take GCC48 prefixes from environment (RHEL only)" - "OvmfPkg: set video resolution of text setup to 640x480 (RHEL only)" - "OvmfPkg: resolve OrderedCollectionLib with base red-black tree instance" - "OvmfPkg: AcpiPlatformDxe: actualize QemuLoader.h comments" - "OvmfPkg: AcpiPlatformDxe: remove current ACPI table loader" - "OvmfPkg: AcpiPlatformDxe: implement QEMU's full ACPI table loader interface" - "OvmfPkg: QemuVideoDxe: fix querying of QXL's drawable buffer size" - "OvmfPkg: disable stale fork of SecureBootConfigDxe" - "OvmfPkg: SecureBootConfigDxe: remove stale fork" - "Try to read key strike even when ..." - "OvmfPkg: BDS: remove dead call to PlatformBdsEnterFrontPage()" - "OvmfPkg: BDS: drop useless return statement" - "OvmfPkg: BDS: don't overwrite the BDS Front Page timeout" - "OvmfPkg: BDS: optimize second argument in PlatformBdsEnterFrontPage() call" - 'OvmfPkg: BDS: drop superfluous "connect first boot option" logic' - "OvmfPkg: BDS: drop custom boot timeout, revert to IntelFrameworkModulePkg's" - "Add comments to clarify mPubKeyStore buffer MemCopy. ..." - "MdeModulePkg/SecurityPkg Variable: Add boundary check..." - "OvmfPkg: AcpiPlatformDxe: make dependency on PCI enumeration explicit" - "MdePkg: UefiScsiLib: do not encode LUN in CDB for READ and WRITE" - "MdePkg: UefiScsiLib: do not encode LUN in CDB for other SCSI commands" -- merge downstream AAVMF patch "adapt packaging to Arm64", which forces us to - rename the main package from "OVMF" to "ovmf" -- drop the following ARM BDS specific tweaks (we'll only build the Intel BDS): - "ArmPlatformPkg/Bds: generate ESP Image boot option if user pref is unset - (Acadia)" - "ArmPlatformPkg/Bds: check for other defaults too if user pref is unset - (Acadia)" - "ArmPlatformPkg/ArmVirtualizationPkg: auto-detect boot path (Acadia)" - "ArmPlatformPkg/Bds: initialize ConIn/ConOut/ErrOut before connecting - terminals" - "ArmPlatformPkg/Bds: let FindCandidate() search all filesystems" - "ArmPlatformPkg/Bds: FindCandidateOnHandle(): log full device path" - "ArmPlatformPkg/Bds: fall back to Boot Menu when no default option was found" - "ArmPlatformPkg/Bds: always connect drivers before looking at boot options" -- drop patch "ArmPlatformPkg/ArmVirtualizationPkg: enable DEBUG_VERBOSE (Acadia - only)", obsoleted by fixed bug 1197141 -- tweak patch "write up build instructions (for interactive, local development) - (RHELSA)". The defaults in "BaseTools/Conf/target.template", ie. - ACTIVE_PLATFORM and TARGET_ARCH, are set for OVMF / X64. The AAVMF build - instructions now spell out the necessary override options (-p and -a, - respectively). -- extend patch "build FAT driver from source (RHELSA)" to the Xen build as well - (only for consistency; we don't build for Xen). -- drop the following downstream-only AAVMF patches, due to the 77d5dac -> - c9e5618 AAVMF rebase & join: - "redhat/process-rh-specific.sh: fix check for hunk-less filtered patches" - "redhat/process-rh-specific.sh: suppress missing files in final 'rm'" - "ArmVirtualizationQemu: build UEFI shell from source (Acadia only)" - "MdePkg: UefiScsiLib: do not encode LUN in CDB for READ and WRITE" - "MdePkg: UefiScsiLib: do not encode LUN in CDB for other SCSI commands" - "ArmVirtualizationPkg: work around cache incoherence on KVM affecting DTB" - "Changed build target to supp-rhel-7.1-candidate" - "ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs" - "ArmVirtualizationPkg: introduce QemuFwCfgLib instance for DXE drivers" - "ArmVirtualizationPkg: clone PlatformIntelBdsLib from ArmPlatformPkg" - "ArmVirtualizationPkg: PlatformIntelBdsLib: add basic policy" - "OvmfPkg: extract QemuBootOrderLib" - "OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation" - "OvmfPkg: introduce VIRTIO_MMIO_TRANSPORT_GUID" - "ArmVirtualizationPkg: VirtFdtDxe: use dedicated VIRTIO_MMIO_TRANSPORT_GUID" - "OvmfPkg: QemuBootOrderLib: widen ParseUnitAddressHexList() to UINT64" - "OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio" - "ArmVirtualizationPkg: PlatformIntelBdsLib: adhere to QEMU's boot order" - "ArmVirtualizationPkg: identify "new shell" as builtin shell for Intel BDS" - "ArmVirtualizationPkg: Intel BDS: load EFI-stubbed Linux kernel from fw_cfg" - 'Revert "ArmVirtualizationPkg: work around cache incoherence on KVM affecting - DTB"' - "OvmfPkg: QemuBootOrderLib: expose QEMU's "-boot menu=on[, splash-time=N]"" - "OvmfPkg: PlatformBdsLib: get front page timeout from QEMU" - "ArmVirtualizationPkg: PlatformIntelBdsLib: get front page timeout from QEMU" - "ArmPkg: ArmArchTimerLib: clean up comments" - "ArmPkg: ArmArchTimerLib: use edk2-conformant (UINT64 * UINT32) / UINT32" - "ArmPkg: ArmArchTimerLib: conditionally rebase to actual timer frequency" - "ArmVirtualizationQemu: ask the hardware for the timer frequency" - "ArmPkg: DebugPeCoffExtraActionLib: debugger commands are not errors" - "ArmPlatformPkg: PEIM startup is not an error" - "ArmVirtualizationPkg: PlatformIntelBdsLib: lack of QEMU kernel is no error" - "ArmVirtualizationPkg: expose debug message bitmask on build command line" -- tweak patch "rebase to upstream 77d5dac (Acadia only)": update spec changelog - only -- tweak patch "spec: build AAVMF with the Intel BDS driver (RHELSA only)": - apply "-D INTEL_BDS" to manual build instructions in redhat/README too -- tweak patch "spec: build and install verbose and silent (default) AAVMF - binaries": apply DEBUG_PRINT_ERROR_LEVEL setting to interactive build - instructions in redhat/README too -- install OVMF whitepaper as part of the OVMF build's documentation -- Resolves: bz#1211337 - (merge AAVMF into OVMF) -- Resolves: bz#1206523 - ([AAVMF] fix missing cache maintenance) - -* Fri Mar 06 2015 Miroslav Rezanina - AAVMF-20141113-5.git77d5dac.el7_1 -- aavmf-ArmPkg-DebugPeCoffExtraActionLib-debugger-commands-a.patch [bz#1197141] -- aavmf-ArmPlatformPkg-PEIM-startup-is-not-an-error.patch [bz#1197141] -- aavmf-ArmVirtualizationPkg-PlatformIntelBdsLib-lack-of-QEM.patch [bz#1197141] -- aavmf-ArmVirtualizationPkg-expose-debug-message-bitmask-on.patch [bz#1197141] -- aavmf-spec-build-and-install-verbose-and-silent-default-AA.patch [bz#1197141] -- Resolves: bz#1197141 - (create silent & verbose builds) - -* Tue Feb 10 2015 Miroslav Rezanina - AAVMF-20141113-4.git77d5dac.el7 -- aavmf-ArmPkg-ArmArchTimerLib-clean-up-comments.patch [bz#1188247] -- aavmf-ArmPkg-ArmArchTimerLib-use-edk2-conformant-UINT64-UI.patch [bz#1188247] -- aavmf-ArmPkg-ArmArchTimerLib-conditionally-rebase-to-actua.patch [bz#1188247] -- aavmf-ArmVirtualizationQemu-ask-the-hardware-for-the-timer.patch [bz#1188247] -- aavmf-ArmPkg-TimerDxe-smack-down-spurious-timer-interrupt-.patch [bz#1188054] -- Resolves: bz#1188054 - (guest reboot (asked from within AAVMF) regressed in 3.19.0-0.rc5.58.aa7a host kernel) -- Resolves: bz#1188247 - (backport "fix gBS->Stall()" series) - -* Mon Jan 19 2015 Miroslav Rezanina - AAVMF-20141113-3.git77d5dac.el7 -- aavmf-OvmfPkg-QemuBootOrderLib-expose-QEMU-s-boot-menu-on-.patch [bz#1172756] -- aavmf-OvmfPkg-PlatformBdsLib-get-front-page-timeout-from-Q.patch [bz#1172756] -- aavmf-ArmVirtualizationPkg-PlatformIntelBdsLib-get-front-p.patch [bz#1172756] -- Resolves: bz#1172756 - ([RFE]Expose boot-menu shortcut to domain via AAVMF) - -* Wed Jan 14 2015 Miroslav Rezanina - AAVMF-20141113-2.git77d5dac.el7 -- aavmf-ArmVirtualizationPkg-VirtFdtDxe-forward-FwCfg-addres.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-introduce-QemuFwCfgLib-instance.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-clone-PlatformIntelBdsLib-from-.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-PlatformIntelBdsLib-add-basic-p.patch [bz#1172749] -- aavmf-OvmfPkg-extract-QemuBootOrderLib.patch [bz#1172749] -- aavmf-OvmfPkg-QemuBootOrderLib-featurize-PCI-like-device-p.patch [bz#1172749] -- aavmf-OvmfPkg-introduce-VIRTIO_MMIO_TRANSPORT_GUID.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-VirtFdtDxe-use-dedicated-VIRTIO.patch [bz#1172749] -- aavmf-OvmfPkg-QemuBootOrderLib-widen-ParseUnitAddressHexLi.patch [bz#1172749] -- aavmf-OvmfPkg-QemuBootOrderLib-OFW-to-UEFI-translation-for.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-PlatformIntelBdsLib-adhere-to-Q.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-identify-new-shell-as-builtin-s.patch [bz#1172749] -- aavmf-ArmVirtualizationPkg-Intel-BDS-load-EFI-stubbed-Linu.patch [bz#1172749] -- aavmf-spec-build-AAVMF-with-the-Intel-BDS-driver-RHELSA-on.patch [bz#1172749] -- aavmf-Revert-ArmVirtualizationPkg-work-around-cache-incohe.patch [bz#1172910] -- Resolves: bz#1172749 - (implement fw_cfg, boot order handling, and -kernel booting in ArmVirtualizationQemu) -- Resolves: bz#1172910 - (revert Acadia-only workaround (commit df7bca4e) once Acadia host kernel (KVM) is fixed) - -* Fri Dec 05 2014 Miroslav Rezanina - OVMF-20140822-7.git9ece15a.el7 -- ovmf-MdePkg-UefiScsiLib-do-not-encode-LUN-in-CDB-for-READ.patch [bz#1166971] -- ovmf-MdePkg-UefiScsiLib-do-not-encode-LUN-in-CDB-for-othe.patch [bz#1166971] -- Resolves: bz#1166971 - (virtio-scsi disks and cd-roms with nonzero LUN are rejected with errors) - -* Tue Nov 25 2014 Miroslav Rezanina - OVMF-20140822-6.git9ece15a.el7 -- ovmf-OvmfPkg-AcpiPlatformDxe-make-dependency-on-PCI-enume.patch [bz#1166027] -- Resolves: bz#1166027 - (backport "OvmfPkg: AcpiPlatformDxe: make dependency on PCI enumeration explicit") - -* Tue Nov 18 2014 Miroslav Rezanina - OVMF-20140822-4.git9ece15a.el7 -- ovmf-Add-comments-to-clarify-mPubKeyStore-buffer-MemCopy.patch [bz#1162314] -- ovmf-MdeModulePkg-SecurityPkg-Variable-Add-boundary-check.patch [bz#1162314] -- Resolves: bz#1162314 - (EMBARGOED OVMF: uefi: INTEL-TA-201410-001 && INTEL-TA-201410-002 [rhel-7.1]) - -* Thu Nov 13 2014 Laszlo Ersek - AAVMF-20141113-1.git77d5dac -- rebased to upstream 77d5dac - -- patch "ArmVirtualizationPkg: FdtPL011SerialPortLib: support UEFI_APPLICATION" - is now upstream (SVN r16219, git edb5073) - -* Thu Nov 13 2014 Miroslav Rezanina - OVMF-20140822-3.git9ece15a.el7 -- ovmf-Revert-OvmfPkg-set-video-resolution-of-text-setup-to.patch [bz#1153927] -- ovmf-Try-to-read-key-strike-even-when-the-TimeOuts-value-.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-remove-dead-call-to-PlatformBdsEnterFron.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-drop-useless-return-statement.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-don-t-overwrite-the-BDS-Front-Page-timeo.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-optimize-second-argument-in-PlatformBdsE.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-drop-superfluous-connect-first-boot-opti.patch [bz#1153927] -- ovmf-OvmfPkg-BDS-drop-custom-boot-timeout-revert-to-Intel.patch [bz#1153927] -- ovmf-OvmfPkg-set-video-resolution-of-text-setup-to-640x48.patch [bz#1153927] -- Resolves: bz#1153927 - (set NEXTBOOT to uefi setting failed from Windows Recovery console) - -* Tue Nov 11 2014 Miroslav Rezanina - OVMF-20140822-2.git9ece15a -- ovmf-redhat-process-rh-specific.sh-suppress-missing-files.patch [bz#1145784] -- ovmf-Revert-RH-only-OvmfPkg-QemuVideoDxe-fix-querying-of-.patch [bz#1145784] -- ovmf-Revert-RH-only-OvmfPkg-AcpiPlatformDxe-implement-QEM.patch [bz#1145784] -- ovmf-Revert-RH-only-OvmfPkg-AcpiPlatformDxe-remove-curren.patch [bz#1145784] -- ovmf-Revert-RH-only-OvmfPkg-AcpiPlatformDxe-actualize-Qem.patch [bz#1145784] -- ovmf-Revert-RH-only-OvmfPkg-resolve-OrderedCollectionLib-.patch [bz#1145784] -- ovmf-OvmfPkg-QemuVideoDxe-work-around-misreported-QXL-fra.patch [bz#1145784] -- ovmf-OvmfPkg-resolve-OrderedCollectionLib-with-base-red-b.patch [bz#1145784] -- ovmf-OvmfPkg-AcpiPlatformDxe-actualize-QemuLoader.h-comme.patch [bz#1145784] -- ovmf-OvmfPkg-AcpiPlatformDxe-remove-current-ACPI-table-lo.patch [bz#1145784] -- ovmf-OvmfPkg-AcpiPlatformDxe-implement-QEMU-s-full-ACPI-t.patch [bz#1145784] -- ovmf-spec-build-small-bootable-ISO-with-standalone-UEFI-s.patch [bz#1147592] -- ovmf-OvmfPkg-allow-exclusion-of-the-shell-from-the-firmwa.patch [bz#1147592] -- ovmf-spec-exclude-the-UEFI-shell-from-the-SecureBoot-enab.patch [bz#1147592] -- ovmf-OvmfPkg-EnrollDefaultKeys-application-for-enrolling-.patch [bz#1148296] -- ovmf-spec-package-EnrollDefaultKeys.efi-on-UefiShell.iso-.patch [bz#1148296] -- ovmf-OvmfPkg-disable-stale-fork-of-SecureBootConfigDxe.patch [bz#1148294] -- ovmf-OvmfPkg-SecureBootConfigDxe-remove-stale-fork.patch [bz#1148294] -- Resolves: bz#1145784 - (OVMF sync with QXL and ACPI patches up to edk2 7a9612ce) -- Resolves: bz#1147592 - (the binary RPM should include a small ISO file with a directly bootable UEFI shell binary) -- Resolves: bz#1148294 - (drop OvmfPkg's stale fork of SecureBootConfigDxe) -- Resolves: bz#1148296 - (provide a non-interactive way to auto-enroll important SecureBoot certificates) - -* Wed Oct 15 2014 Laszlo Ersek - AAVMF-20141015-1.gitc373687 -- ported packaging to aarch64 / AAVMF - -* Fri Aug 22 2014 Laszlo Ersek - 20140822-1.git9ece15a.el7 -- rebase from upstream 3facc08 to 9ece15a -- update to openssl-0.9.8zb -- update to FatPkg SVN r86 (git 2355ea2c) -- the following patches of Paolo Bonzini have been merged in upstream; drop the - downstream-only copies: - 7bc1421 edksetup.sh: Look for BuildEnv under EDK_TOOLS_PATH - d549344 edksetup.sh: Ensure that WORKSPACE points to the top of an edk2 - checkout - 1c023eb BuildEnv: remove useless check before setting $WORKSPACE -- include the following patches that have been pending review on the upstream - list for a long time: - [PATCH 0/4] OvmfPkg: complete client for QEMU's ACPI loader interface - http://thread.gmane.org/gmane.comp.bios.tianocore.devel/8369 - [PATCH] OvmfPkg: QemuVideoDxe: fix querying of QXL's drawable buffer size - http://thread.gmane.org/gmane.comp.bios.tianocore.devel/8515 -- nasm is a build-time dependency now because upstream BuildTools has started - to call it directly - -* Wed Jul 23 2014 Laszlo Ersek - 20140723-1.git3facc08.el7 -- rebase from upstream a618eaa to 3facc08 -- update to openssl-0.9.8za -- drop downstream-only split varstore patch, rely on upstream's - -* Tue Jun 24 2014 Miroslav Rezanina - 20140619-1.gita618eaa.el7 -- Initial version diff --git a/edk2-AmdSevDxe-Fix-the-shim-fallback-reboot-workaround-fo.patch b/edk2-AmdSevDxe-Fix-the-shim-fallback-reboot-workaround-fo.patch new file mode 100644 index 0000000..302c577 --- /dev/null +++ b/edk2-AmdSevDxe-Fix-the-shim-fallback-reboot-workaround-fo.patch @@ -0,0 +1,63 @@ +From ebcdc6db77d338aa1054292d0c4b745bd482d9a2 Mon Sep 17 00:00:00 2001 +From: Oliver Steffen +Date: Mon, 26 Aug 2024 19:25:52 +0200 +Subject: [PATCH] AmdSevDxe: Fix the shim fallback reboot workaround for SNP + +RH-Author: Oliver Steffen +RH-MergeRequest: 69: AmdSevDxe: Fix the shim fallback reboot workaround for SNP +RH-Jira: RHEL-56082 +RH-Acked-by: Gerd Hoffmann +RH-Commit: [1/1] 55ae7744e57ea51e1f35f482dffc2dd2089c5f77 (osteffen/edk2) + +The shim fallback reboot workaround (introduced for SEV-ES) does +not always work for SEV-SNP, due to a conditional early return. + +Let's just register the workaround earlier in this function to +fix that. + +Signed-off-by: Oliver Steffen +--- + OvmfPkg/AmdSevDxe/AmdSevDxe.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c +index 0eb88e50ff..ca345e95da 100644 +--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c ++++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c +@@ -243,6 +243,17 @@ AmdSevDxeEntryPoint ( + return EFI_UNSUPPORTED; + } + ++ // Shim fallback reboot workaround ++ Status = gBS->CreateEventEx ( ++ EVT_NOTIFY_SIGNAL, ++ TPL_CALLBACK, ++ PopulateVarstore, ++ SystemTable, ++ &gEfiEndOfDxeEventGroupGuid, ++ &PopulateVarstoreEvent ++ ); ++ ASSERT_EFI_ERROR (Status); ++ + // + // Iterate through the GCD map and clear the C-bit from MMIO and NonExistent + // memory space. The NonExistent memory space will be used for mapping the +@@ -393,15 +404,5 @@ AmdSevDxeEntryPoint ( + ); + } + +- Status = gBS->CreateEventEx ( +- EVT_NOTIFY_SIGNAL, +- TPL_CALLBACK, +- PopulateVarstore, +- SystemTable, +- &gEfiEndOfDxeEventGroupGuid, +- &PopulateVarstoreEvent +- ); +- ASSERT_EFI_ERROR (Status); +- + return EFI_SUCCESS; + } +-- +2.39.3 + diff --git a/edk2-MdeModulePkg-Warn-if-out-of-flash-space-when-writing.patch b/edk2-MdeModulePkg-Warn-if-out-of-flash-space-when-writing.patch new file mode 100644 index 0000000..635a256 --- /dev/null +++ b/edk2-MdeModulePkg-Warn-if-out-of-flash-space-when-writing.patch @@ -0,0 +1,43 @@ +From b1b719573ff7410985fd502b3c30e6592229c3bd Mon Sep 17 00:00:00 2001 +From: Oliver Steffen +Date: Mon, 4 Mar 2024 15:32:58 +0100 +Subject: [PATCH] MdeModulePkg: Warn if out of flash space when writing + variables + +RH-Author: Oliver Steffen +RH-MergeRequest: 65: MdeModulePkg: Warn if out of flash space when writing variables +RH-Jira: RHEL-45261 +RH-Acked-by: Gerd Hoffmann +RH-Commit: [1/1] b1f6ac49f246cc6a670b9fdd583da3bb9556550d (osteffen/edk2) + +Emit a DEBUG_WARN message if there is not enough flash space left to +write/update a variable. This condition is currently not logged +appropriately in all cases, given that full variable store can easily +render the system unbootable. +This new message helps identifying this condition. + +Signed-off-by: Oliver Steffen +Reviewed-by: Laszlo Ersek +Reviewed-by: Gerd Hoffmann +(cherry picked from commit 80b59ff8320d1bd134bf689fe9c0ddf4e0473b88) +Signed-off-by: Oliver Steffen +--- + MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +index d394d237a5..1c7659031d 100644 +--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c ++++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +@@ -2364,6 +2364,8 @@ Done: + ); + ASSERT_EFI_ERROR (Status); + } ++ } else if (Status == EFI_OUT_OF_RESOURCES) { ++ DEBUG ((DEBUG_WARN, "UpdateVariable failed: Out of flash space\n")); + } + + return Status; +-- +2.39.3 + diff --git a/edk2-NetworkPkg-DxeNetLib-Reword-PseudoRandom-error-loggi.patch b/edk2-NetworkPkg-DxeNetLib-Reword-PseudoRandom-error-loggi.patch new file mode 100644 index 0000000..c751e0f --- /dev/null +++ b/edk2-NetworkPkg-DxeNetLib-Reword-PseudoRandom-error-loggi.patch @@ -0,0 +1,44 @@ +From 054d42879bba986d7b2c2568fe4459959a8fe38b Mon Sep 17 00:00:00 2001 +From: Oliver Steffen +Date: Wed, 14 Aug 2024 09:53:49 +0200 +Subject: [PATCH 2/2] NetworkPkg/DxeNetLib: Reword PseudoRandom error logging + +RH-Author: Oliver Steffen +RH-MergeRequest: 66: NetworkPkg/DxeNetLib: adjust PseudoRandom error logging +RH-Jira: RHEL-45829 +RH-Acked-by: Miroslav Rezanina +RH-Commit: [2/2] d1f24c14ccea7346d395c263ed577039f91debfd (osteffen/edk2) + +The word "Failed" is used when logging tired Rng algorithms. +These mostly non-critical messages confused some users. + +Reword it and also add a message confirming eventual success to +deescalate the importance somewhat. + +Signed-off-by: Oliver Steffen +--- + NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c +index 4dfbe91a55..905a944975 100644 +--- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c ++++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c +@@ -946,12 +946,13 @@ PseudoRandom ( + // + // Secure Algorithm was supported on this platform + // ++ DEBUG ((DEBUG_VERBOSE, "Generated random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); + return EFI_SUCCESS; + } else if (Status == EFI_UNSUPPORTED) { + // + // Secure Algorithm was not supported on this platform + // +- DEBUG ((DEBUG_VERBOSE, "Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); ++ DEBUG ((DEBUG_VERBOSE, "Unable to generate random data using secure algorithm %d not available: %r\n", AlgorithmIndex, Status)); + + // + // Try the next secure algorithm +-- +2.39.3 + diff --git a/edk2-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch b/edk2-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch new file mode 100644 index 0000000..9623683 --- /dev/null +++ b/edk2-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch @@ -0,0 +1,49 @@ +From a424c0877b38ffb3c9c2a29cf52efb78c19ea8f2 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Wed, 19 Jun 2024 09:07:56 +0200 +Subject: [PATCH 1/2] NetworkPkg/DxeNetLib: adjust PseudoRandom error logging + +RH-Author: Oliver Steffen +RH-MergeRequest: 66: NetworkPkg/DxeNetLib: adjust PseudoRandom error logging +RH-Jira: RHEL-45829 +RH-Acked-by: Miroslav Rezanina +RH-Commit: [1/2] 9cf7cc1e68e01c54ab6fae15e3b5cdef1c0b15bc (osteffen/edk2) + +There is a list of allowed rng algorithms, if /one/ of them is not +supported this is not a problem, only /all/ of them failing is an +error condition. + +Downgrade the message for a single unsupported algorithm from ERROR to +VERBOSE. Add an error message in case we finish the loop without +finding a supported algorithm. + +Signed-off-by: Gerd Hoffmann +(cherry picked from commit 6862b9d538d96363635677198899e1669e591259) +--- + NetworkPkg/Library/DxeNetLib/DxeNetLib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c +index 01c13c08d2..4dfbe91a55 100644 +--- a/NetworkPkg/Library/DxeNetLib/DxeNetLib.c ++++ b/NetworkPkg/Library/DxeNetLib/DxeNetLib.c +@@ -951,7 +951,7 @@ PseudoRandom ( + // + // Secure Algorithm was not supported on this platform + // +- DEBUG ((DEBUG_ERROR, "Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); ++ DEBUG ((DEBUG_VERBOSE, "Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status)); + + // + // Try the next secure algorithm +@@ -971,6 +971,7 @@ PseudoRandom ( + // If we get here, we failed to generate random data using any secure algorithm + // Platform owner should ensure that at least one secure algorithm is supported + // ++ DEBUG ((DEBUG_ERROR, "Failed to generate random data, no supported secure algorithm found\n")); + ASSERT_EFI_ERROR (Status); + return Status; + } +-- +2.39.3 + diff --git a/edk2-OvmfPkg-CpuHotplugSmm-delay-SMM-exit.patch b/edk2-OvmfPkg-CpuHotplugSmm-delay-SMM-exit.patch new file mode 100644 index 0000000..68fea42 --- /dev/null +++ b/edk2-OvmfPkg-CpuHotplugSmm-delay-SMM-exit.patch @@ -0,0 +1,46 @@ +From b2e458faf8603547bcdf578f465fdf777df44500 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Thu, 29 Aug 2024 09:20:29 +0200 +Subject: [PATCH] OvmfPkg/CpuHotplugSmm: delay SMM exit + +RH-Author: Gerd Hoffmann +RH-MergeRequest: 75: OvmfPkg/CpuHotplugSmm: delay SMM exit +RH-Jira: RHEL-56154 +RH-Acked-by: Oliver Steffen +RH-Commit: [1/1] 591189c9b119804cab4c48e9c27e428751993169 (kraxel.rh/centos-src-edk2) + +Let APs wait until the BSP has completed the register updates to remove +the CPU. This makes sure all APs stay in SMM mode until the CPU +hot-unplug operation is complete, which in turn makes sure the ACPI lock +is released only after the CPU hot-unplug operation is complete. + +Some background: The CPU hotplug SMI is triggered from an ACPI function +which is protected by an ACPI lock. The ACPI function is in the ACPI +tables generated by qemu. + +Signed-off-by: Gerd Hoffmann + +upstream: submitted (https://github.com/tianocore/edk2/pull/6138) +--- + OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +index d504163026..5af78211d3 100644 +--- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c ++++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +@@ -355,6 +355,11 @@ EjectCpu ( + // + QemuSelector = mCpuHotEjectData->QemuSelectorMap[ProcessorNum]; + if (QemuSelector == CPU_EJECT_QEMU_SELECTOR_INVALID) { ++ /* wait until BSP is done */ ++ while (mCpuHotEjectData->Handler != NULL) { ++ CpuPause (); ++ } ++ + return; + } + +-- +2.39.3 + diff --git a/edk2-UefiCpuPkg-PiSmmCpuDxeSmm-skip-PatchInstructionX86-c.patch b/edk2-UefiCpuPkg-PiSmmCpuDxeSmm-skip-PatchInstructionX86-c.patch new file mode 100644 index 0000000..e41d301 --- /dev/null +++ b/edk2-UefiCpuPkg-PiSmmCpuDxeSmm-skip-PatchInstructionX86-c.patch @@ -0,0 +1,143 @@ +From 6b26812cbf5a871d0a311036b6605635684ed3e1 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Tue, 27 Aug 2024 12:06:15 +0200 +Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: skip PatchInstructionX86 calls if + not needed. + +RH-Author: Oliver Steffen +RH-MergeRequest: 70: UefiCpuPkg/PiSmmCpuDxeSmm: skip PatchInstructionX86 calls if not needed. +RH-Jira: RHEL-50185 +RH-Acked-by: Gerd Hoffmann +RH-Commit: [1/1] a9c96249a5258e0902e38d4579079dfcc188b980 (osteffen/edk2) + +Add the new global mMsrIa32MiscEnableSupported variable to track +whenever support for the IA32_MISC_ENABLE MSR is present or not. + +Add new local PatchingNeeded variable to CheckFeatureSupported() +to track if patching the SMM setup code is needed or not. + +Issue PatchInstructionX86() calls only if needed, i.e. if one of +the *Supported variables has been updated. + +Result is that on a typical SMP machine where all processors are +identical the PatchInstructionX86() calls are issued only once, +when checking the first processor. Specifically this avoids +PatchInstructionX86() being called in OVMF on CPU hotplug. That +is important because instruction patching at runtime does not not +work and leads to page faults. + +This fixes CPU hotplug on OVMF not working with AMD cpus. + +Fixes: 6b3a89a9fdb5 ("OvmfPkg/PlatformPei: Relocate SmBases in PEI phase") +Signed-off-by: Gerd Hoffmann +(cherry picked from commit 17ff8960848b2cb2e49fffb3dfbacd08865786a4) +Signed-off-by: Oliver Steffen +--- + UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 49 +++++++++++++++++++++----- + 1 file changed, 40 insertions(+), 9 deletions(-) + +diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +index 8142d3ceac..8e299fd29a 100644 +--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c ++++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +@@ -40,6 +40,11 @@ BOOLEAN mXdEnabled = FALSE; + // + BOOLEAN mBtsSupported = TRUE; + ++// ++// The flag indicates if MSR_IA32_MISC_ENABLE is supported by processor ++// ++BOOLEAN mMsrIa32MiscEnableSupported = TRUE; ++ + // + // The flag indicates if SMM profile starts to record data. + // +@@ -904,18 +909,23 @@ CheckFeatureSupported ( + UINT32 RegEcx; + UINT32 RegEdx; + MSR_IA32_MISC_ENABLE_REGISTER MiscEnableMsr; ++ BOOLEAN PatchingNeeded = FALSE; + + if ((PcdGet32 (PcdControlFlowEnforcementPropertyMask) != 0) && mCetSupported) { + AsmCpuid (CPUID_SIGNATURE, &RegEax, NULL, NULL, NULL); + if (RegEax >= CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS) { + AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, NULL, NULL, &RegEcx, NULL); + if ((RegEcx & CPUID_CET_SS) == 0) { +- mCetSupported = FALSE; +- PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); ++ if (mCetSupported) { ++ mCetSupported = FALSE; ++ PatchingNeeded = TRUE; ++ } + } + } else { +- mCetSupported = FALSE; +- PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); ++ if (mCetSupported) { ++ mCetSupported = FALSE; ++ PatchingNeeded = TRUE; ++ } + } + } + +@@ -925,8 +935,10 @@ CheckFeatureSupported ( + // + // Extended CPUID functions are not supported on this processor. + // +- mXdSupported = FALSE; +- PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); ++ if (mXdSupported) { ++ mXdSupported = FALSE; ++ PatchingNeeded = TRUE; ++ } + } + + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); +@@ -934,15 +946,20 @@ CheckFeatureSupported ( + // + // Execute Disable Bit feature is not supported on this processor. + // +- mXdSupported = FALSE; +- PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); ++ if (mXdSupported) { ++ mXdSupported = FALSE; ++ PatchingNeeded = TRUE; ++ } + } + + if (StandardSignatureIsAuthenticAMD ()) { + // + // AMD processors do not support MSR_IA32_MISC_ENABLE + // +- PatchInstructionX86 (gPatchMsrIa32MiscEnableSupported, FALSE, 1); ++ if (mMsrIa32MiscEnableSupported) { ++ mMsrIa32MiscEnableSupported = FALSE; ++ PatchingNeeded = TRUE; ++ } + } + } + +@@ -966,6 +983,20 @@ CheckFeatureSupported ( + } + } + } ++ ++ if (PatchingNeeded) { ++ if (!mCetSupported) { ++ PatchInstructionX86 (mPatchCetSupported, mCetSupported, 1); ++ } ++ ++ if (!mXdSupported) { ++ PatchInstructionX86 (gPatchXdSupported, mXdSupported, 1); ++ } ++ ++ if (!mMsrIa32MiscEnableSupported) { ++ PatchInstructionX86 (gPatchMsrIa32MiscEnableSupported, FALSE, 1); ++ } ++ } + } + + /** +-- +2.39.3 + diff --git a/edk2-build.py b/edk2-build.py new file mode 100755 index 0000000..cee7541 --- /dev/null +++ b/edk2-build.py @@ -0,0 +1,447 @@ +#!/usr/bin/python3 +""" +build helper script for edk2, see +https://gitlab.com/kraxel/edk2-build-config + +""" +import os +import sys +import time +import shutil +import argparse +import subprocess +import configparser + +rebase_prefix = "" +version_override = None +release_date = None + +# pylint: disable=unused-variable +def check_rebase(): + """ detect 'git rebase -x edk2-build.py master' testbuilds """ + global rebase_prefix + global version_override + gitdir = '.git' + + if os.path.isfile(gitdir): + with open(gitdir, 'r', encoding = 'utf-8') as f: + (unused, gitdir) = f.read().split() + + if not os.path.exists(f'{gitdir}/rebase-merge/msgnum'): + return + with open(f'{gitdir}/rebase-merge/msgnum', 'r', encoding = 'utf-8') as f: + msgnum = int(f.read()) + with open(f'{gitdir}/rebase-merge/end', 'r', encoding = 'utf-8') as f: + end = int(f.read()) + with open(f'{gitdir}/rebase-merge/head-name', 'r', encoding = 'utf-8') as f: + head = f.read().strip().split('/') + + rebase_prefix = f'[ {int(msgnum/2)} / {int(end/2)} - {head[-1]} ] ' + if msgnum != end and not version_override: + # fixed version speeds up builds + version_override = "test-build-patch-series" + +def get_coredir(cfg): + if cfg.has_option('global', 'core'): + return os.path.abspath(cfg['global']['core']) + return os.getcwd() + +def get_toolchain(cfg, build): + if cfg.has_option(build, 'tool'): + return cfg[build]['tool'] + if cfg.has_option('global', 'tool'): + return cfg['global']['tool'] + return 'GCC5' + +def get_hostarch(): + mach = os.uname().machine + if mach == 'x86_64': + return 'X64' + if mach == 'aarch64': + return 'AARCH64' + if mach == 'riscv64': + return 'RISCV64' + return 'UNKNOWN' + +def get_version(cfg, silent = False): + coredir = get_coredir(cfg) + if version_override: + version = version_override + if not silent: + print('') + print(f'### version [override]: {version}') + return version + if os.environ.get('RPM_PACKAGE_NAME'): + version = os.environ.get('RPM_PACKAGE_NAME') + version += '-' + os.environ.get('RPM_PACKAGE_VERSION') + version += '-' + os.environ.get('RPM_PACKAGE_RELEASE') + if not silent: + print('') + print(f'### version [rpmbuild]: {version}') + return version + if os.path.exists(coredir + '/.git'): + cmdline = [ 'git', 'describe', '--tags', '--abbrev=8', + '--match=edk2-stable*' ] + result = subprocess.run(cmdline, cwd = coredir, + stdout = subprocess.PIPE, + check = True) + version = result.stdout.decode().strip() + if not silent: + print('') + print(f'### version [git]: {version}') + return version + return None + +def pcd_string(name, value): + return f'{name}=L{value}\\0' + +def pcd_version(cfg, silent = False): + version = get_version(cfg, silent) + if version is None: + return [] + return [ '--pcd', pcd_string('PcdFirmwareVersionString', version) ] + +def pcd_release_date(): + if release_date is None: + return [] + return [ '--pcd', pcd_string('PcdFirmwareReleaseDateString', release_date) ] + +def build_message(line, line2 = None, silent = False): + if os.environ.get('TERM') in [ 'xterm', 'xterm-256color' ]: + # setxterm title + start = '\x1b]2;' + end = '\x07' + print(f'{start}{rebase_prefix}{line}{end}', end = '') + + if silent: + print(f'### {rebase_prefix}{line}', flush = True) + else: + print('') + print('###') + print(f'### {rebase_prefix}{line}') + if line2: + print(f'### {line2}') + print('###', flush = True) + +def build_run(cmdline, name, section, silent = False, nologs = False): + if silent: + logfile = f'{section}.log' + if nologs: + print(f'### building in silent mode [no log] ...', flush = True) + else: + print(f'### building in silent mode [{logfile}] ...', flush = True) + start = time.time() + result = subprocess.run(cmdline, check = False, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT) + if not nologs: + with open(logfile, 'wb') as f: + f.write(result.stdout) + + if result.returncode: + print('### BUILD FAILURE') + print('### cmdline') + print(cmdline) + print('### output') + print(result.stdout.decode()) + print(f'### exit code: {result.returncode}') + else: + secs = int(time.time() - start) + print(f'### OK ({int(secs/60)}:{secs%60:02d})') + else: + print(cmdline, flush = True) + result = subprocess.run(cmdline, check = False) + if result.returncode: + print(f'ERROR: {cmdline[0]} exited with {result.returncode}' + f' while building {name}') + sys.exit(result.returncode) + +def build_copy(plat, tgt, toolchain, dstdir, copy): + srcdir = f'Build/{plat}/{tgt}_{toolchain}' + names = copy.split() + srcfile = names[0] + if len(names) > 1: + dstfile = names[1] + else: + dstfile = os.path.basename(srcfile) + print(f'# copy: {srcdir} / {srcfile} => {dstdir} / {dstfile}') + + src = srcdir + '/' + srcfile + dst = dstdir + '/' + dstfile + os.makedirs(os.path.dirname(dst), exist_ok = True) + shutil.copy(src, dst) + +def pad_file(dstdir, pad): + args = pad.split() + if len(args) < 2: + raise RuntimeError(f'missing arg for pad ({args})') + name = args[0] + size = args[1] + cmdline = [ + 'truncate', + '--size', size, + dstdir + '/' + name, + ] + print(f'# padding: {dstdir} / {name} => {size}') + subprocess.run(cmdline, check = True) + +# pylint: disable=too-many-branches +def build_one(cfg, build, jobs = None, silent = False, nologs = False): + b = cfg[build] + + cmdline = [ 'build' ] + cmdline += [ '-t', get_toolchain(cfg, build) ] + cmdline += [ '-p', b['conf'] ] + + if (b['conf'].startswith('OvmfPkg/') or + b['conf'].startswith('ArmVirtPkg/')): + cmdline += pcd_version(cfg, silent) + cmdline += pcd_release_date() + + if jobs: + cmdline += [ '-n', jobs ] + for arch in b['arch'].split(): + if arch == 'HOST': + cmdline += [ '-a', get_hostarch() ] + else: + cmdline += [ '-a', arch ] + if 'opts' in b: + for name in b['opts'].split(): + section = 'opts.' + name + for opt in cfg[section]: + cmdline += [ '-D', opt + '=' + cfg[section][opt] ] + if 'pcds' in b: + for name in b['pcds'].split(): + section = 'pcds.' + name + for pcd in cfg[section]: + cmdline += [ '--pcd', pcd + '=' + cfg[section][pcd] ] + if 'tgts' in b: + tgts = b['tgts'].split() + else: + tgts = [ 'DEBUG' ] + for tgt in tgts: + desc = None + if 'desc' in b: + desc = b['desc'] + build_message(f'building: {b["conf"]} ({b["arch"]}, {tgt})', + f'description: {desc}', + silent = silent) + build_run(cmdline + [ '-b', tgt ], + b['conf'], + build + '.' + tgt, + silent, + nologs) + + if 'plat' in b: + # copy files + for cpy in b: + if not cpy.startswith('cpy'): + continue + build_copy(b['plat'], tgt, + get_toolchain(cfg, build), + b['dest'], b[cpy]) + # pad builds + for pad in b: + if not pad.startswith('pad'): + continue + pad_file(b['dest'], b[pad]) + +def build_basetools(silent = False, nologs = False): + build_message('building: BaseTools', silent = silent) + basedir = os.environ['EDK_TOOLS_PATH'] + cmdline = [ 'make', '-C', basedir ] + build_run(cmdline, 'BaseTools', 'build.basetools', silent, nologs) + +def binary_exists(name): + for pdir in os.environ['PATH'].split(':'): + if os.path.exists(pdir + '/' + name): + return True + return False + +def prepare_env(cfg, silent = False): + """ mimic Conf/BuildEnv.sh """ + workspace = os.getcwd() + packages = [ workspace, ] + path = os.environ['PATH'].split(':') + dirs = [ + 'BaseTools/Bin/Linux-x86_64', + 'BaseTools/BinWrappers/PosixLike' + ] + + if cfg.has_option('global', 'pkgs'): + for pkgdir in cfg['global']['pkgs'].split(): + packages.append(os.path.abspath(pkgdir)) + coredir = get_coredir(cfg) + if coredir != workspace: + packages.append(coredir) + + # add basetools to path + for pdir in dirs: + p = coredir + '/' + pdir + if not os.path.exists(p): + continue + if p in path: + continue + path.insert(0, p) + + # run edksetup if needed + toolsdef = coredir + '/Conf/tools_def.txt' + if not os.path.exists(toolsdef): + os.makedirs(os.path.dirname(toolsdef), exist_ok = True) + build_message('running BaseTools/BuildEnv', silent = silent) + cmdline = [ 'bash', 'BaseTools/BuildEnv' ] + subprocess.run(cmdline, cwd = coredir, check = True) + + # set variables + os.environ['PATH'] = ':'.join(path) + os.environ['PACKAGES_PATH'] = ':'.join(packages) + os.environ['WORKSPACE'] = workspace + os.environ['EDK_TOOLS_PATH'] = coredir + '/BaseTools' + os.environ['CONF_PATH'] = coredir + '/Conf' + os.environ['PYTHON_COMMAND'] = '/usr/bin/python3' + os.environ['PYTHONHASHSEED'] = '1' + + # for cross builds + if binary_exists('arm-linux-gnueabi-gcc'): + # ubuntu + os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnueabi-' + os.environ['GCC_ARM_PREFIX'] = 'arm-linux-gnueabi-' + elif binary_exists('arm-linux-gnu-gcc'): + # fedora + os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-' + os.environ['GCC_ARM_PREFIX'] = 'arm-linux-gnu-' + if binary_exists('loongarch64-linux-gnu-gcc'): + os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' + os.environ['GCC_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' + + hostarch = os.uname().machine + if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64': + os.environ['GCC5_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' + os.environ['GCC_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' + if binary_exists('riscv64-linux-gnu-gcc') and hostarch != 'riscv64': + os.environ['GCC5_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' + os.environ['GCC_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' + if binary_exists('x86_64-linux-gnu-gcc') and hostarch != 'x86_64': + os.environ['GCC5_IA32_PREFIX'] = 'x86_64-linux-gnu-' + os.environ['GCC5_X64_PREFIX'] = 'x86_64-linux-gnu-' + os.environ['GCC5_BIN'] = 'x86_64-linux-gnu-' + os.environ['GCC_IA32_PREFIX'] = 'x86_64-linux-gnu-' + os.environ['GCC_X64_PREFIX'] = 'x86_64-linux-gnu-' + os.environ['GCC_BIN'] = 'x86_64-linux-gnu-' + +def build_list(cfg): + for build in cfg.sections(): + if not build.startswith('build.'): + continue + name = build.lstrip('build.') + desc = 'no description' + if 'desc' in cfg[build]: + desc = cfg[build]['desc'] + print(f'# {name:20s} - {desc}') + +def main(): + parser = argparse.ArgumentParser(prog = 'edk2-build', + description = 'edk2 build helper script') + parser.add_argument('-c', '--config', dest = 'configfile', + type = str, default = '.edk2.builds', metavar = 'FILE', + help = 'read configuration from FILE (default: .edk2.builds)') + parser.add_argument('-C', '--directory', dest = 'directory', type = str, + help = 'change to DIR before building', metavar = 'DIR') + parser.add_argument('-j', '--jobs', dest = 'jobs', type = str, + help = 'allow up to JOBS parallel build jobs', + metavar = 'JOBS') + parser.add_argument('-m', '--match', dest = 'match', + type = str, action = 'append', + help = 'only run builds matching INCLUDE (substring)', + metavar = 'INCLUDE') + parser.add_argument('-x', '--exclude', dest = 'exclude', + type = str, action = 'append', + help = 'skip builds matching EXCLUDE (substring)', + metavar = 'EXCLUDE') + parser.add_argument('-l', '--list', dest = 'list', + action = 'store_true', default = False, + help = 'list build configs available') + parser.add_argument('--silent', dest = 'silent', + action = 'store_true', default = False, + help = 'write build output to logfiles, ' + 'write to console only on errors') + parser.add_argument('--no-logs', dest = 'nologs', + action = 'store_true', default = False, + help = 'do not write build log files (with --silent)') + parser.add_argument('--core', dest = 'core', type = str, metavar = 'DIR', + help = 'location of the core edk2 repository ' + '(i.e. where BuildTools are located)') + parser.add_argument('--pkg', '--package', dest = 'pkgs', + type = str, action = 'append', metavar = 'DIR', + help = 'location(s) of additional packages ' + '(can be specified multiple times)') + parser.add_argument('-t', '--toolchain', dest = 'toolchain', + type = str, metavar = 'NAME', + help = 'tool chain to be used to build edk2') + parser.add_argument('--version-override', dest = 'version_override', + type = str, metavar = 'VERSION', + help = 'set firmware build version') + parser.add_argument('--release-date', dest = 'release_date', + type = str, metavar = 'DATE', + help = 'set firmware build release date (in MM/DD/YYYY format)') + options = parser.parse_args() + + if options.directory: + os.chdir(options.directory) + + if not os.path.exists(options.configfile): + print(f'config file "{options.configfile}" not found') + return 1 + + cfg = configparser.ConfigParser() + cfg.optionxform = str + cfg.read(options.configfile) + + if options.list: + build_list(cfg) + return 0 + + if not cfg.has_section('global'): + cfg.add_section('global') + if options.core: + cfg.set('global', 'core', options.core) + if options.pkgs: + cfg.set('global', 'pkgs', ' '.join(options.pkgs)) + if options.toolchain: + cfg.set('global', 'tool', options.toolchain) + + global version_override + global release_date + check_rebase() + if options.version_override: + version_override = options.version_override + if options.release_date: + release_date = options.release_date + + prepare_env(cfg, options.silent) + build_basetools(options.silent, options.nologs) + for build in cfg.sections(): + if not build.startswith('build.'): + continue + if options.match: + matching = False + for item in options.match: + if item in build: + matching = True + if not matching: + print(f'# skipping "{build}" (not matching "{"|".join(options.match)}")') + continue + if options.exclude: + exclude = False + for item in options.exclude: + if item in build: + print(f'# skipping "{build}" (matching "{item}")') + exclude = True + if exclude: + continue + build_one(cfg, build, options.jobs, options.silent, options.nologs) + + return 0 + +if __name__ == '__main__': + sys.exit(main()) diff --git a/edk2-build.rhel-9 b/edk2-build.rhel-9 new file mode 100644 index 0000000..9088bf8 --- /dev/null +++ b/edk2-build.rhel-9 @@ -0,0 +1,129 @@ + +[opts.ovmf.common] +NETWORK_HTTP_BOOT_ENABLE = TRUE +NETWORK_IP6_ENABLE = TRUE +NETWORK_TLS_ENABLE = TRUE +NETWORK_ISCSI_ENABLE = TRUE +NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE +TPM2_ENABLE = TRUE +TPM2_CONFIG_ENABLE = TRUE +TPM1_ENABLE = FALSE +CAVIUM_ERRATUM_27456 = TRUE + +[opts.ovmf.4m] +FD_SIZE_4MB = TRUE + +[opts.ovmf.sb.smm] +SECURE_BOOT_ENABLE = TRUE +SMM_REQUIRE = TRUE +# old downstream +EXCLUDE_SHELL_FROM_FD = TRUE +# new upstream +BUILD_SHELL = FALSE + +[opts.ovmf.sb.stateless] +SECURE_BOOT_ENABLE = TRUE +SMM_REQUIRE = FALSE + +[opts.armvirt.verbose] +DEBUG_PRINT_ERROR_LEVEL = 0x8040004F + +[opts.armvirt.silent] +DEBUG_PRINT_ERROR_LEVEL = 0x80000000 + + +[pcds.nx.strict] +PcdDxeNxMemoryProtectionPolicy = 0xC000000000007FD5 +PcdUninstallMemAttrProtocol = FALSE + +[pcds.nx.broken.shim.grub] +# grub.efi uses EfiLoaderData for code +PcdDxeNxMemoryProtectionPolicy = 0xC000000000007FD1 +# shim.efi has broken MemAttr code +PcdUninstallMemAttrProtocol = TRUE + + +##################################################################### +# stateful ovmf builds (with vars in flash) + +[build.ovmf.4m.default] +desc = ovmf build (64-bit, 4MB) +conf = OvmfPkg/OvmfPkgX64.dsc +arch = X64 +opts = ovmf.common + ovmf.4m +plat = OvmfX64 +dest = RHEL-9/ovmf +cpy1 = FV/OVMF_CODE.fd OVMF_CODE.fd +cpy2 = FV/OVMF_VARS.fd +cpy3 = X64/Shell.efi + +[build.ovmf.4m.sb.smm] +desc = ovmf build (64-bit, 4MB, q35 only, needs smm, secure boot) +conf = OvmfPkg/OvmfPkgX64.dsc +arch = X64 +opts = ovmf.common + ovmf.4m + ovmf.sb.smm +plat = OvmfX64 +dest = RHEL-9/ovmf +cpy1 = FV/OVMF_CODE.fd OVMF_CODE.secboot.fd +cpy2 = X64/EnrollDefaultKeys.efi + + +##################################################################### +# stateless ovmf builds (firmware in rom or r/o flash) + +[build.ovmf.amdsev] +desc = ovmf build for AmdSev (4MB) +conf = OvmfPkg/AmdSev/AmdSevX64.dsc +arch = X64 +opts = ovmf.common + ovmf.4m +plat = AmdSev +dest = RHEL-9/ovmf +cpy1 = FV/OVMF.fd OVMF.amdsev.fd + +[build.ovmf.inteltdx] +desc = ovmf build for IntelTdx (4MB) +conf = OvmfPkg/IntelTdx/IntelTdxX64.dsc +arch = X64 +opts = ovmf.common + ovmf.4m + ovmf.sb.stateless +plat = IntelTdx +dest = RHEL-9/ovmf +cpy1 = FV/OVMF.fd OVMF.inteltdx.fd + + +##################################################################### +# armvirt builds + +[build.armvirt.aa64.verbose] +desc = ArmVirt build for qemu, 64-bit (arm v8), verbose +conf = ArmVirtPkg/ArmVirtQemu.dsc +arch = AARCH64 +opts = ovmf.common + armvirt.verbose +pcds = nx.broken.shim.grub +plat = ArmVirtQemu-AARCH64 +dest = RHEL-9/aarch64 +cpy1 = FV/QEMU_EFI.fd +cpy2 = FV/QEMU_VARS.fd +cpy3 = FV/QEMU_EFI.fd QEMU_EFI-pflash.raw +cpy4 = FV/QEMU_VARS.fd vars-template-pflash.raw +pad3 = QEMU_EFI-pflash.raw 64m +pad4 = vars-template-pflash.raw 64m + +[build.armvirt.aa64.silent] +desc = ArmVirt build for qemu, 64-bit (arm v8), silent +conf = ArmVirtPkg/ArmVirtQemu.dsc +arch = AARCH64 +opts = ovmf.common + armvirt.silent +pcds = nx.broken.shim.grub +plat = ArmVirtQemu-AARCH64 +dest = RHEL-9/aarch64 +cpy1 = FV/QEMU_EFI.fd QEMU_EFI.silent.fd +cpy2 = FV/QEMU_EFI.fd QEMU_EFI-silent-pflash.raw +pad2 = QEMU_EFI-silent-pflash.raw 64m diff --git a/edk2.spec b/edk2.spec new file mode 100644 index 0000000..3eb9391 --- /dev/null +++ b/edk2.spec @@ -0,0 +1,479 @@ +ExclusiveArch: x86_64 aarch64 + +# edk2-stable202405 +%define GITDATE 20240524 +%define GITCOMMIT 3e722403cd +%define TOOLCHAIN GCC + +%define OPENSSL_VER 3.0.7 +%define OPENSSL_HASH 0205b589887203b065154ddc8e8107c4ac8625a1 + +%define DBXDATE 20230509 + +%define build_ovmf 0 +%define build_aarch64 0 +%ifarch x86_64 + %define build_ovmf 1 +%endif +%ifarch aarch64 + %define build_aarch64 1 +%endif + +Name: edk2 +Version: %{GITDATE} +Release: 8%{?dist} +Summary: UEFI firmware for 64-bit virtual machines +License: BSD-2-Clause-Patent and Apache-2.0 and MIT +URL: http://www.tianocore.org + +# The source tarball is created using following commands: +# COMMIT=ba91d0292e +# git archive --format=tar --prefix=edk2-$COMMIT/ $COMMIT \ +# | xz -9ev >/tmp/edk2-$COMMIT.tar.xz +Source0: edk2-%{GITCOMMIT}.tar.xz +Source1: ovmf-whitepaper-c770f8c.txt +Source2: openssl-rhel-%{OPENSSL_HASH}.tar.xz + +# json description files +Source10: 50-edk2-aarch64-qcow2.json +Source11: 51-edk2-aarch64-raw.json +Source12: 52-edk2-aarch64-verbose-qcow2.json +Source13: 53-edk2-aarch64-verbose-raw.json + +Source40: 30-edk2-ovmf-x64-sb-enrolled.json +Source41: 40-edk2-ovmf-x64-sb.json +Source43: 50-edk2-ovmf-x64-nosb.json +Source44: 60-edk2-ovmf-x64-amdsev.json +Source45: 60-edk2-ovmf-x64-inteltdx.json + +# https://gitlab.com/kraxel/edk2-build-config +Source80: edk2-build.py +Source82: edk2-build.rhel-9 + +Source90: DBXUpdate-%{DBXDATE}.x64.bin +Patch1: 0003-Remove-paths-leading-to-submodules.patch +Patch2: 0004-MdeModulePkg-TerminalDxe-set-xterm-resolution-on-mod.patch +Patch3: 0005-OvmfPkg-take-PcdResizeXterm-from-the-QEMU-command-li.patch +Patch4: 0006-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch +Patch5: 0007-OvmfPkg-enable-DEBUG_VERBOSE-RHEL-only.patch +Patch6: 0008-OvmfPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuVide.patch +Patch7: 0009-ArmVirtPkg-silence-DEBUG_VERBOSE-0x00400000-in-QemuR.patch +Patch8: 0010-OvmfPkg-QemuRamfbDxe-Do-not-report-DXE-failure-on-Aa.patch +Patch9: 0011-OvmfPkg-silence-EFI_D_VERBOSE-0x00400000-in-NvmExpre.patch +Patch10: 0012-OvmfPkg-QemuKernelLoaderFsDxe-suppress-error-on-no-k.patch +Patch11: 0013-SecurityPkg-Tcg2Dxe-suppress-error-on-no-swtpm-in-si.patch +Patch12: 0014-OvmfPkg-Remove-EbcDxe-RHEL-only.patch +Patch13: 0015-OvmfPkg-Remove-VirtioGpu-device-driver-RHEL-only.patch +Patch14: 0016-OvmfPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL-on.patch +Patch15: 0017-ArmVirtPkg-Remove-VirtioFsDxe-filesystem-driver-RHEL.patch +Patch16: 0018-OvmfPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch +Patch17: 0019-ArmVirtPkg-Remove-UdfDxe-filesystem-driver-RHEL-only.patch +Patch18: 0020-OvmfPkg-Remove-TftpDynamicCommand-from-shell-RHEL-on.patch +Patch19: 0021-ArmVirtPkg-Remove-TftpDynamicCommand-from-shell-RHEL.patch +Patch20: 0022-OvmfPkg-Remove-HttpDynamicCommand-from-shell-RHEL-on.patch +Patch21: 0023-ArmVirtPkg-Remove-HttpDynamicCommand-from-shell-RHEL.patch +Patch22: 0024-OvmfPkg-Remove-LinuxInitrdDynamicShellCommand-RHEL-o.patch +Patch23: 0025-ArmVirtPkg-Remove-LinuxInitrdDynamicShellCommand-RHE.patch +Patch24: 0026-UefiCpuPkg-MpInitLib-fix-apic-mode-for-cpu-hotplug.patch +Patch25: 0027-OvmfPkg-AmdSevDxe-Shim-Reboot-workaround-RHEL-only.patch +Patch26: 0028-CryptoPkg-CrtLib-add-stat.h-include-file.patch +Patch27: 0029-CryptoPkg-CrtLib-add-access-open-read-write-close-sy.patch +Patch28: 0030-OvmfPkg-Sec-Setup-MTRR-early-in-the-boot-process.patch +Patch29: 0031-MdePkg-ArchitecturalMsr.h-add-defines-for-MTRR-cache.patch +Patch30: 0032-UefiCpuPkg-MtrrLib.h-use-cache-type-defines-from-Arc.patch +Patch31: 0033-OvmfPkg-Sec-use-cache-type-defines-from-Architectura.patch +Patch32: 0034-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch +Patch33: 0035-OvmfPkg-add-morlock-support.patch +Patch34: 0036-MdePkg-BaseRngLib-Add-a-smoketest-for-RDRAND-and-che.patch +Patch35: 0037-SecurityPkg-RngDxe-add-rng-test.patch +Patch36: 0038-OvmfPkg-wire-up-RngDxe.patch +Patch37: 0039-CryptoPkg-Test-call-ProcessLibraryConstructorList.patch +Patch38: 0040-MdePkg-X86UnitTestHost-set-rdrand-cpuid-bit.patch +# For RHEL-45261 - [RHEL10] edk2 disconnects abnormally before loading the kernel +Patch39: edk2-MdeModulePkg-Warn-if-out-of-flash-space-when-writing.patch +# For RHEL-45829 - [RHEL-10.0] edk2 hit Failed to generate random data +Patch40: edk2-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch +# For RHEL-45829 - [RHEL-10.0] edk2 hit Failed to generate random data +Patch41: edk2-NetworkPkg-DxeNetLib-Reword-PseudoRandom-error-loggi.patch +# For RHEL-56082 - [EDK2] Shim fallback reboot workaround might not work on SNP [rhel-10] +Patch42: edk2-AmdSevDxe-Fix-the-shim-fallback-reboot-workaround-fo.patch +# For RHEL-50185 - [RHEL10] Hit soft lockup when hotplug vcpu +Patch43: edk2-UefiCpuPkg-PiSmmCpuDxeSmm-skip-PatchInstructionX86-c.patch +# For RHEL-56154 - qemu-kvm: warning: Blocked re-entrant IO on MemoryRegion: acpi-cpu-hotplug at addr: 0x0 [rhel-10] +Patch44: edk2-OvmfPkg-CpuHotplugSmm-delay-SMM-exit.patch + +# python3-devel and libuuid-devel are required for building tools. +# python3-devel is also needed for varstore template generation and +# verification with "ovmf-vars-generator". +BuildRequires: python3-devel +BuildRequires: libuuid-devel +BuildRequires: /usr/bin/iasl +BuildRequires: binutils gcc git gcc-c++ make +BuildRequires: perl perl(JSON) +BuildRequires: qemu-img + +%if %{build_ovmf} +# Only OVMF includes 80x86 assembly files (*.nasm*). +BuildRequires: nasm + +# Only OVMF includes the Secure Boot feature, for which we need to separate out +# the UEFI shell. +BuildRequires: dosfstools +BuildRequires: mtools +BuildRequires: xorriso + +# secure boot enrollment +BuildRequires: python3dist(virt-firmware) >= 23.4 + +# endif build_ovmf +%endif + + +%package ovmf +Summary: UEFI firmware for x86_64 virtual machines +BuildArch: noarch +Provides: OVMF = %{version}-%{release} +Obsoletes: OVMF < 20180508-100.gitee3198e672e2.el7 + +# OVMF includes the Secure Boot and IPv6 features; it has a builtin OpenSSL +# library. +Provides: bundled(openssl) = %{OPENSSL_VER} +License: BSD-2-Clause-Patent and Apache-2.0 + +# URL taken from the Maintainers.txt file. +URL: http://www.tianocore.org/ovmf/ + +%description ovmf +OVMF (Open Virtual Machine Firmware) is a project to enable UEFI support for +Virtual Machines. This package contains a sample 64-bit UEFI firmware for QEMU +and KVM. + + +%package aarch64 +Summary: UEFI firmware for aarch64 virtual machines +BuildArch: noarch +Provides: AAVMF = %{version}-%{release} +Obsoletes: AAVMF < 20180508-100.gitee3198e672e2.el7 + +# need libvirt version with qcow2 support +Conflicts: libvirt-daemon-driver-qemu < 9.2.0 + +# No Secure Boot for AAVMF yet, but we include OpenSSL for the IPv6 stack. +Provides: bundled(openssl) = %{OPENSSL_VER} +License: BSD-2-Clause-Patent and Apache-2.0 + +# URL taken from the Maintainers.txt file. +URL: https://github.com/tianocore/tianocore.github.io/wiki/ArmVirtPkg + +%description aarch64 +AAVMF (ARM Architecture Virtual Machine Firmware) is an EFI Development Kit II +platform that enables UEFI support for QEMU/KVM ARM Virtual Machines. This +package contains a 64-bit build. + + +%package tools +Summary: EFI Development Kit II Tools +License: BSD-2-Clause-Patent +URL: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools +%description tools +This package provides tools that are needed to +build EFI executables and ROMs using the GNU tools. + +%package tools-doc +Summary: Documentation for EFI Development Kit II Tools +BuildArch: noarch +License: BSD-2-Clause-Patent +URL: https://github.com/tianocore/tianocore.github.io/wiki/BaseTools +%description tools-doc +This package documents the tools that are needed to +build EFI executables and ROMs using the GNU tools. + +%description +EDK II is a modern, feature-rich, cross-platform firmware development +environment for the UEFI and PI specifications. This package contains sample +64-bit UEFI firmware builds for QEMU and KVM. + +%prep +# We needs some special git config options that %%autosetup won't give us. +# We init the git dir ourselves, then tell %%autosetup not to blow it away. +%setup -q -n edk2-%{GITCOMMIT} +git init -q +git config core.whitespace cr-at-eol +git config am.keepcr true +# -T is passed to %%setup to not re-extract the archive +# -D is passed to %%setup to not delete the existing archive dir +%autosetup -T -D -n edk2-%{GITCOMMIT} -S git_am + +cp -a -- %{SOURCE1} . +cp -a -- %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} . +cp -a -- %{SOURCE40} %{SOURCE41} %{SOURCE43} %{SOURCE44} %{SOURCE45} . +cp -a -- %{SOURCE80} %{SOURCE82} . +cp -a -- %{SOURCE90} . +tar -C CryptoPkg/Library/OpensslLib -a -f %{SOURCE2} -x + +# Done by %setup, but we do not use it for the auxiliary tarballs +chmod -Rf a+rX,u+w,g-w,o-w . + +%build + +build_iso() { + dir="$1" + UEFI_SHELL_BINARY=${dir}/Shell.efi + ENROLLER_BINARY=${dir}/EnrollDefaultKeys.efi + UEFI_SHELL_IMAGE=uefi_shell.img + ISO_IMAGE=${dir}/UefiShell.iso + + UEFI_SHELL_BINARY_BNAME=$(basename -- "$UEFI_SHELL_BINARY") + UEFI_SHELL_SIZE=$(stat --format=%s -- "$UEFI_SHELL_BINARY") + ENROLLER_SIZE=$(stat --format=%s -- "$ENROLLER_BINARY") + + # add 1MB then 10% for metadata + UEFI_SHELL_IMAGE_KB=$(( + (UEFI_SHELL_SIZE + ENROLLER_SIZE + 1 * 1024 * 1024) * 11 / 10 / 1024 + )) + + # create non-partitioned FAT image + rm -f -- "$UEFI_SHELL_IMAGE" + mkdosfs -C "$UEFI_SHELL_IMAGE" -n UEFI_SHELL -- "$UEFI_SHELL_IMAGE_KB" + + # copy the shell binary into the FAT image + export MTOOLS_SKIP_CHECK=1 + mmd -i "$UEFI_SHELL_IMAGE" ::efi + mmd -i "$UEFI_SHELL_IMAGE" ::efi/boot + mcopy -i "$UEFI_SHELL_IMAGE" "$UEFI_SHELL_BINARY" ::efi/boot/bootx64.efi + mcopy -i "$UEFI_SHELL_IMAGE" "$ENROLLER_BINARY" :: + mdir -i "$UEFI_SHELL_IMAGE" -/ :: + + # build ISO with FAT image file as El Torito EFI boot image + mkisofs -input-charset ASCII -J -rational-rock \ + -e "$UEFI_SHELL_IMAGE" -no-emul-boot \ + -o "$ISO_IMAGE" "$UEFI_SHELL_IMAGE" +} + +export EXTRA_OPTFLAGS="%{optflags}" +export EXTRA_LDFLAGS="%{__global_ldflags}" +export RELEASE_DATE="$(echo %{GITDATE} | sed -e 's|\(....\)\(..\)\(..\)|\2/\3/\1|')" + +touch OvmfPkg/AmdSev/Grub/grub.efi # dummy +python3 CryptoPkg/Library/OpensslLib/configure.py + +# include dirs of unused submodules +mkdir -p CryptoPkg/Library/MbedTlsLib/mbedtls/include +mkdir -p CryptoPkg/Library/MbedTlsLib/mbedtls/include/mbedtls +mkdir -p CryptoPkg/Library/MbedTlsLib/mbedtls/library +mkdir -p SecurityPkg/DeviceSecurity/SpdmLib/libspdm/include + +%if %{build_ovmf} +./edk2-build.py --config edk2-build.rhel-9 -m ovmf --release-date "$RELEASE_DATE" +build_iso RHEL-9/ovmf +cp DBXUpdate-%{DBXDATE}.x64.bin RHEL-9/ovmf +virt-fw-vars --input RHEL-9/ovmf/OVMF_VARS.fd \ + --output RHEL-9/ovmf/OVMF_VARS.secboot.fd \ + --set-dbx DBXUpdate-%{DBXDATE}.x64.bin \ + --enroll-redhat --secure-boot +virt-fw-vars --input RHEL-9/ovmf/OVMF.inteltdx.fd \ + --output RHEL-9/ovmf/OVMF.inteltdx.secboot.fd \ + --set-dbx DBXUpdate-%{DBXDATE}.x64.bin \ + --enroll-redhat --secure-boot \ + --set-fallback-no-reboot +%endif + +%if %{build_aarch64} +./edk2-build.py --config edk2-build.rhel-9 -m armvirt --release-date "$RELEASE_DATE" +for raw in */aarch64/*.raw; do + qcow2="${raw%.raw}.qcow2" + qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 "$raw" "$qcow2" +done +%endif + +%install + +cp -a OvmfPkg/License.txt License.OvmfPkg.txt +cp -a CryptoPkg/Library/OpensslLib/openssl/LICENSE.txt LICENSE.openssl +mkdir -p %{buildroot}%{_datadir}/qemu/firmware + +# install the tools +mkdir -p %{buildroot}%{_bindir} \ + %{buildroot}%{_datadir}/%{name}/Conf \ + %{buildroot}%{_datadir}/%{name}/Scripts +install BaseTools/Source/C/bin/* \ + %{buildroot}%{_bindir} +install BaseTools/BinWrappers/PosixLike/LzmaF86Compress \ + %{buildroot}%{_bindir} +install BaseTools/BuildEnv \ + %{buildroot}%{_datadir}/%{name} +install BaseTools/Conf/*.template \ + %{buildroot}%{_datadir}/%{name}/Conf +install BaseTools/Scripts/GccBase.lds \ + %{buildroot}%{_datadir}/%{name}/Scripts + +mkdir -p %{buildroot}%{_datadir}/%{name} +cp -av RHEL-9/* %{buildroot}%{_datadir}/%{name} + +%if %{build_ovmf} +mkdir -p %{buildroot}%{_datadir}/OVMF + +ln -s ../%{name}/ovmf/OVMF_CODE.secboot.fd %{buildroot}%{_datadir}/OVMF/ +ln -s ../%{name}/ovmf/OVMF_VARS.fd %{buildroot}%{_datadir}/OVMF/ +ln -s ../%{name}/ovmf/OVMF_VARS.secboot.fd %{buildroot}%{_datadir}/OVMF/ +ln -s ../%{name}/ovmf/UefiShell.iso %{buildroot}%{_datadir}/OVMF/ +ln -s OVMF_CODE.fd %{buildroot}%{_datadir}/%{name}/ovmf/OVMF_CODE.cc.fd + +install -m 0644 \ + 30-edk2-ovmf-x64-sb-enrolled.json \ + 40-edk2-ovmf-x64-sb.json \ + 50-edk2-ovmf-x64-nosb.json \ + 60-edk2-ovmf-x64-amdsev.json \ + 60-edk2-ovmf-x64-inteltdx.json \ + %{buildroot}%{_datadir}/qemu/firmware + +# endif build_ovmf +%endif + +%if %{build_aarch64} +mkdir -p %{buildroot}%{_datadir}/AAVMF + +ln -s ../%{name}/aarch64/QEMU_EFI-pflash.raw \ + %{buildroot}%{_datadir}/AAVMF/AAVMF_CODE.verbose.fd +ln -s ../%{name}/aarch64/QEMU_EFI-silent-pflash.raw \ + %{buildroot}%{_datadir}/AAVMF/AAVMF_CODE.fd +ln -s ../%{name}/aarch64/vars-template-pflash.raw \ + %{buildroot}%{_datadir}/AAVMF/AAVMF_VARS.fd + +install -m 0644 \ + 50-edk2-aarch64-qcow2.json \ + 51-edk2-aarch64-raw.json \ + 52-edk2-aarch64-verbose-qcow2.json \ + 53-edk2-aarch64-verbose-raw.json \ + %{buildroot}%{_datadir}/qemu/firmware + +# endif build_aarch64 +%endif + +%check + +%global common_files \ + %%license License.txt License.OvmfPkg.txt License-History.txt LICENSE.openssl \ + %%dir %%{_datadir}/%%{name}/ \ + %%dir %%{_datadir}/qemu \ + %%dir %%{_datadir}/qemu/firmware + +%if %{build_ovmf} +%files ovmf +%common_files +%doc OvmfPkg/README +%doc ovmf-whitepaper-c770f8c.txt +%dir %{_datadir}/OVMF/ +%dir %{_datadir}/%{name}/ovmf/ +%{_datadir}/%{name}/ovmf/OVMF_CODE.fd +%{_datadir}/%{name}/ovmf/OVMF_CODE.cc.fd +%{_datadir}/%{name}/ovmf/OVMF_CODE.secboot.fd +%{_datadir}/%{name}/ovmf/OVMF_VARS.fd +%{_datadir}/%{name}/ovmf/OVMF_VARS.secboot.fd +%{_datadir}/%{name}/ovmf/OVMF.amdsev.fd +%{_datadir}/%{name}/ovmf/OVMF.inteltdx.fd +%{_datadir}/%{name}/ovmf/OVMF.inteltdx.secboot.fd +%{_datadir}/%{name}/ovmf/DBXUpdate*.bin +%{_datadir}/%{name}/ovmf/UefiShell.iso +%{_datadir}/OVMF/OVMF_CODE.secboot.fd +%{_datadir}/OVMF/OVMF_VARS.fd +%{_datadir}/OVMF/OVMF_VARS.secboot.fd +%{_datadir}/OVMF/UefiShell.iso +%{_datadir}/%{name}/ovmf/Shell.efi +%{_datadir}/%{name}/ovmf/EnrollDefaultKeys.efi +%{_datadir}/qemu/firmware/30-edk2-ovmf-x64-sb-enrolled.json +%{_datadir}/qemu/firmware/40-edk2-ovmf-x64-sb.json +%{_datadir}/qemu/firmware/50-edk2-ovmf-x64-nosb.json +%{_datadir}/qemu/firmware/60-edk2-ovmf-x64-amdsev.json +%{_datadir}/qemu/firmware/60-edk2-ovmf-x64-inteltdx.json +# endif build_ovmf +%endif + +%if %{build_aarch64} +%files aarch64 +%common_files +%dir %{_datadir}/AAVMF/ +%dir %{_datadir}/%{name}/aarch64/ +%{_datadir}/%{name}/aarch64/QEMU_EFI-pflash.* +%{_datadir}/%{name}/aarch64/QEMU_EFI-silent-pflash.* +%{_datadir}/%{name}/aarch64/vars-template-pflash.* +%{_datadir}/AAVMF/AAVMF_CODE.verbose.fd +%{_datadir}/AAVMF/AAVMF_CODE.fd +%{_datadir}/AAVMF/AAVMF_VARS.fd +%{_datadir}/%{name}/aarch64/QEMU_EFI.fd +%{_datadir}/%{name}/aarch64/QEMU_EFI.silent.fd +%{_datadir}/%{name}/aarch64/QEMU_VARS.fd +%{_datadir}/qemu/firmware/50-edk2-aarch64-qcow2.json +%{_datadir}/qemu/firmware/51-edk2-aarch64-raw.json +%{_datadir}/qemu/firmware/52-edk2-aarch64-verbose-qcow2.json +%{_datadir}/qemu/firmware/53-edk2-aarch64-verbose-raw.json +# endif build_aarch64 +%endif + +%files tools +%license License.txt +%license License-History.txt +%{_bindir}/DevicePath +%{_bindir}/EfiRom +%{_bindir}/GenCrc32 +%{_bindir}/GenFfs +%{_bindir}/GenFv +%{_bindir}/GenFw +%{_bindir}/GenSec +%{_bindir}/LzmaCompress +%{_bindir}/LzmaF86Compress +%{_bindir}/TianoCompress +%{_bindir}/VfrCompile +%{_bindir}/VolInfo +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/BuildEnv +%{_datadir}/%{name}/Conf +%{_datadir}/%{name}/Scripts + +%files tools-doc +%doc BaseTools/UserManuals/*.rtf + + +%changelog +* Fri Sep 27 2024 Miroslav Rezanina - 20240524-8 +- edk2-Bumped-openssl-submodule-version-to-0205b5898872.patch [RHEL-55302] +- Resolves: RHEL-55302 + (CVE-2024-6119 edk2/openssl: Possible denial of service in X.509 name checks [rhel-10.0 beta]) + +* Fri Sep 13 2024 Miroslav Rezanina - 20240524-7 +- edk2-OvmfPkg-CpuHotplugSmm-delay-SMM-exit.patch [RHEL-56154] +- Resolves: RHEL-56154 + (qemu-kvm: warning: Blocked re-entrant IO on MemoryRegion: acpi-cpu-hotplug at addr: 0x0 [rhel-10]) + +* Mon Sep 09 2024 Miroslav Rezanina - 20240524-5 +- edk2-UefiCpuPkg-PiSmmCpuDxeSmm-skip-PatchInstructionX86-c.patch [RHEL-50185] +- Resolves: RHEL-50185 + ([RHEL10] Hit soft lockup when hotplug vcpu) + +* Mon Sep 02 2024 Miroslav Rezanina - 20240524-4 +- edk2-AmdSevDxe-Fix-the-shim-fallback-reboot-workaround-fo.patch [RHEL-56082] +- Resolves: RHEL-56082 + ([EDK2] Shim fallback reboot workaround might not work on SNP [rhel-10]) + +* Tue Aug 20 2024 Miroslav Rezanina - 20240524-3 +- edk2-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch [RHEL-45829] +- edk2-NetworkPkg-DxeNetLib-Reword-PseudoRandom-error-loggi.patch [RHEL-45829] +- Resolves: RHEL-45829 + ([RHEL-10.0] edk2 hit Failed to generate random data ) + +* Wed Jul 24 2024 Miroslav Rezanina - 20240524-2 +- edk2-MdeModulePkg-Warn-if-out-of-flash-space-when-writing.patch [RHEL-45261] +- Resolves: RHEL-45261 + ([RHEL10] edk2 disconnects abnormally before loading the kernel) + +* Fri Jun 28 2024 Miroslav Rezanina - 20240524-1 +- Rebase to edk2-stable202405 +- Resolves: RHEL-32487 + +* Mon Jun 24 2024 Troy Dawson - 20240214-2 +- Bump release for June 2024 mass rebuild + +* Tue Apr 02 2024 Miroslav Rezanina - 20240214-1 +- Imported edk2-202402 from RHEL 9 +- Resolves: RHEL-30180 + diff --git a/SOURCES/ovmf-whitepaper-c770f8c.txt b/ovmf-whitepaper-c770f8c.txt similarity index 100% rename from SOURCES/ovmf-whitepaper-c770f8c.txt rename to ovmf-whitepaper-c770f8c.txt diff --git a/sources b/sources new file mode 100644 index 0000000..3d96e18 --- /dev/null +++ b/sources @@ -0,0 +1,3 @@ +SHA512 (DBXUpdate-20230509.x64.bin) = 71fb6e8cd6918126b3acd78b95651913336df372e13fdfdfdd20d5d23f0e509050c6c88c8a2c43f8ac44f987df86bd45174bb3065d5a7a8c7e3b8772fd06d624 +SHA512 (edk2-3e722403cd.tar.xz) = 55afa1275a579c3c620c10fe78758f952e5f6c73425c56034e28f05ad6ae2d8b9480d6f0133e2320fb6d3bc3f016daf6e0cb1fbdb737176b9cfa51fce076207d +SHA512 (openssl-rhel-0205b589887203b065154ddc8e8107c4ac8625a1.tar.xz) = 07db9535df29873a3884a411e6ab5c3ea6783b9773cd0923f5b2be1273c0e3e984a2f3a80bd1a637995eda018fa6372b6d1eb41000be07cdf5972938c74f51e9