From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E8A47AC148E for ; Tue, 18 Jul 2023 18:40:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=t5TBdcO4EolMbtAnq57xyBVJLL7bH9t5UNEN0aIyMms=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:X-Received:From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:Content-Transfer-Encoding; s=20140610; t=1689705620; v=1; b=adAQZYiEzoEJBS/udLwKL1hcPb7NGsCRsB7ocv0L/OYBnhEbM5EXXpYOdcWx0zznGtYubFad fnBdpi0gnYKoRzyprWI0za3mNvMxJeg7POyASJNKD+9Yvio4JRndHIklt3kQr0kPyNX7D6N0xZ0 S4iITblufj7oEfTEsSGM8KlI= X-Received: by 127.0.0.2 with SMTP id D5WHYY7687511xhy4cFbHF17; Tue, 18 Jul 2023 11:40:20 -0700 X-Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mx.groups.io with SMTP id smtpd.web11.3671.1689705619554128383 for ; Tue, 18 Jul 2023 11:40:20 -0700 X-Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6687096c6ddso3906177b3a.0 for ; Tue, 18 Jul 2023 11:40:19 -0700 (PDT) X-Gm-Message-State: hI24viHA1dZ1UASmbejpq1EMx7686176AA= X-Google-Smtp-Source: APBJJlEajyYdtnfUnyInow54DDTpXnn0BIAYXMqvWs1eOTQ8c5a86X36UnDfSF0szTvlyAYmsgnhsA== X-Received: by 2002:a05:6a00:1a16:b0:647:4dee:62b7 with SMTP id g22-20020a056a001a1600b006474dee62b7mr14191594pfv.29.1689705618493; Tue, 18 Jul 2023 11:40:18 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.230.135]) by smtp.gmail.com with ESMTPSA id d18-20020aa78692000000b006827d86ca0csm1863153pfo.55.2023.07.18.11.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 11:40:18 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Andrew Fish , Ard Biesheuvel , Dandan Bi , Eric Dong , Gerd Hoffmann , Guo Dong , Gua Guo , James Lu , Jian J Wang , Jiewen Yao , Jordan Justen , Leif Lindholm , Liming Gao , Rahul Kumar , Ray Ni , Sami Mujawar , Sean Rhodes Subject: [edk2-devel] [PATCH v1 0/9] Add ImagePropertiesRecordLib and Fix MAT Bugs Date: Tue, 18 Jul 2023 11:39:56 -0700 Message-ID: <20230718184006.534-1-t@taylorbeebe.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,t@taylorbeebe.com Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=adAQZYiE; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 Cc: Ard Biesheuvel Cc: Dandan Bi Cc: Eric Dong Cc: Gerd Hoffmann Cc: Guo Dong Cc: Gua Guo Cc: James Lu Cc: Jian J Wang Cc: Jiewen Yao Cc: Jordan Justen Cc: Leif Lindholm Cc: Liming Gao Cc: Rahul Kumar Cc: Ray Ni Cc: Sami Mujawar Cc: Sean Rhodes 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 (#107021): https://edk2.groups.io/g/devel/message/107021 Mute This Topic: https://groups.io/mt/100221556/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-