v2: - A one-line change in patch 3 was moved to patch 9 for correctness. Reference: https://github.com/tianocore/edk2/pull/4590 Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4492
The UEFI and SMM MAT logic contains duplicate logic for manipulating image properties records which is used to track runtime images. This patch series adds a new library, ImagePropertiesRecordLib, which consolidates this logic and fixes the bugs which currently exist in the MAT logic. The first patch adds the ImagePropertiesRecordLib implementation which is a copy of the UEFI MAT logic with minor modifications to remove the reliance on globabl variables and make the code unit testable. The second patch adds a unit test for the ImagePropertiesRecordLib. The logic tests various potential layouts of the EFI memory map and runtime images. 3/4 of these tests will fail which demonstrates the MAT logic bugs. The third patch fixes the logic in the ImagePropertiesRecordLib so that all of the unit tests pass and the MAT logic can be fixed by using the library. The remaining patches add library instances to DSC files and remove the image properties record logic from the SMM and UEFI MAT logic. Cc: Andrew Fish <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Dandan Bi <[email protected]> Cc: Eric Dong <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Guo Dong <[email protected]> Cc: Gua Guo <[email protected]> Cc: James Lu <[email protected]> Cc: Jian J Wang <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Jordan Justen <[email protected]> Cc: Leif Lindholm <[email protected]> Cc: Liming Gao <[email protected]> Cc: Rahul Kumar <[email protected]> Cc: Ray Ni <[email protected]> Cc: Sami Mujawar <[email protected]> Cc: Sean Rhodes <[email protected]> Taylor Beebe (9): MdeModulePkg: Add ImagePropertiesRecordLib MdeModulePkg: Add ImagePropertiesRecordLib Host-Based Unit Test MdeModulePkg: Fix Bugs in MAT Logic ArmVirtPkg: Add ImagePropertiesRecordLib Instance EmulatorPkg: Add ImagePropertiesRecordLib Instance OvmfPkg: Add ImagePropertiesRecordLib Instance UefiPayloadPkg: Add ImagePropertiesRecordLib Instance UefiCpuPkg: Use Attribute From SMM MemoryAttributesTable if Nonzero MdeModulePkg: Update UEFI and SMM MAT Logic To Use ImagePropertiesRecordLib MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 786 +--------------- MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 24 +- MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c | 785 +--------------- MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.c | 805 +++++++++++++++++ MdeModulePkg/Library/ImagePropertiesRecordLib/UnitTest/ImagePropertiesRecordLibUnitTestHost.c | 938 ++++++++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 19 +- ArmVirtPkg/ArmVirt.dsc.inc | 1 + EmulatorPkg/EmulatorPkg.dsc | 1 + MdeModulePkg/Core/Dxe/DxeMain.h | 20 - MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + MdeModulePkg/Include/Library/ImagePropertiesRecordLib.h | 151 ++++ MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf | 28 + MdeModulePkg/Library/ImagePropertiesRecordLib/UnitTest/ImagePropertiesRecordLibUnitTestHost.inf | 35 + MdeModulePkg/MdeModulePkg.dec | 5 + MdeModulePkg/MdeModulePkg.dsc | 2 + MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 5 + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + OvmfPkg/Microvm/MicrovmX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfXen.dsc | 1 + OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 1 + UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 28 files changed, 2039 insertions(+), 1579 deletions(-) create mode 100644 MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.c create mode 100644 MdeModulePkg/Library/ImagePropertiesRecordLib/UnitTest/ImagePropertiesRecordLibUnitTestHost.c create mode 100644 MdeModulePkg/Include/Library/ImagePropertiesRecordLib.h create mode 100644 MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf create mode 100644 MdeModulePkg/Library/ImagePropertiesRecordLib/UnitTest/ImagePropertiesRecordLibUnitTestHost.inf -- 2.41.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107066): https://edk2.groups.io/g/devel/message/107066 Mute This Topic: https://groups.io/mt/100246933/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
