From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62825+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62825+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244631; cv=none; d=zohomail.com; s=zohoarc; b=fz81B/ZLtgAs7j/FYexetGpArNAdiqErnWgLidR7TfrM6BGWWQ4RuFE3aFqos+d7nxtVSHveyGEN24tzeb+vhfvhbRxQvvdBhcWcl30b3VLVQ8UE41ESYTA1v+Iaf114DGo98tE8100bucMHy+7PXLRL7SHafbD0ELqxWbxJ7ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244631; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=RZ/jgfB2O8I/F8XHmgmBd9k05mt54XPPiTTTqyoLqI0=; b=BdHtmeRgNFZmg2b+yqKQ2eXxC2ozLNJCXev898pHcS4EoUsvSaRPT4j9NPKoqZspf4yXo8Qnag4yNjpttU+jNV8aAh6k/ppIcEYBJqcuMdsOpoRGsCM8fIvN6OpHsP3aJD5OvDpcNy+SXIrkRjLulHTdRe59ycF2I86n4xNMuPQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62825+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244631320410.7352179074112; Mon, 20 Jul 2020 04:30:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 25VUYY1788612xFUyhlkSQxc; Mon, 20 Jul 2020 04:30:30 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:30 -0700 IronPort-SDR: EqL097cHxpd562xnlq7F+ySaozCsLalMs217+iTxHg3nWcujJaVcGx8YVJRn2bPB557sq+N+oj i+2OPOLdkK2A== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373120" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373120" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:29 -0700 IronPort-SDR: Q0vSDrffc5Ek9XS/rZLnEzz50N7nUJgqKNcsaQsfb3TxFmriO2gsBUTAh5rxkhC69okzFKpx2r fKNqCkXcrcqw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411111" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:28 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Laszlo Ersek Subject: [edk2-devel] [PATCH v6 01/10] MdeModulePkg: Add new PCD to control the evacuate temporary memory feature (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:13 +0800 Message-Id: <20200720113022.675-2-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: OT7ASvIYvyXrxwvI0OUdVQ5ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244630; bh=XUax5gUmyh5ut1SyUcJfO7To7VBSrHg/GJIPqOW2ZFg=; h=Cc:Date:From:Reply-To:Subject:To; b=OuqlC1sWqqaegxgZ8dgfmAbnQ8ibd6NbJ5cPBvqVlHYg4BLYI+Su7OVn+mQFX8pHxDv 64QDwJZ4B6n+UNTeTjt0Cn5tr1aViIR45kxgV+BQcoL/Jr78siGfFhfpHwD3H47ehgTds 5uW2ToOMzwg8bqQ2ujvPK/ECcauTQbMBq2E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 The security researcher found that we can get control after NEM disable. The reason is that the flash content reside in NEM at startup and the code will get the content from flash directly after disable NEM. To avoid this vulnerability, the feature will copy the PEIMs from temporary memory to permanent memory and only execute the code in permanent memory. The vulnerability is exist in physical platform and haven't report in virtual platform, so the virtual can disable the feature currently. Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Guomin Jiang Acked-by: Laszlo Ersek Reviewed-by: Jian J Wang --- MdeModulePkg/MdeModulePkg.dec | 8 ++++++++ MdeModulePkg/MdeModulePkg.uni | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 843e963ad34b..e88f22756d7f 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1220,6 +1220,14 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # @Prompt Shadow Peim and PeiCore on boot gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot|TRUE|BOOLEAN|0x300010= 29 =20 + ## Enable the feature that evacuate temporary memory to permanent memory= or not + # Set FALSE as default, if the developer need this feature to avoid thi= s vulnerability, please + # enable it in dsc file. + # TRUE - Evacuate temporary memory, the actions include copy memory, co= nvert PPI pointers and so on. + # FALSE - Do nothing, for example, no copy memory, no convert PPI point= ers and so on. + # @Prompt Evacuate temporary memory to permanent memory + gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes|FAL= SE|BOOLEAN|0x3000102A + ## The mask is used to control memory profile behavior.

# BIT0 - Enable UEFI memory profile.
# BIT1 - Enable SMRAM profile.
diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 2007e0596c4f..5235dee561ad 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -214,6 +214,12 @@ = "TRUE - Shadow PEIM on S3 boot path after memory is ready.\n" = "FALSE - Not shadow PEIM on S3 boot path after memory is ready= .
" =20 +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareV= olumes_HELP #language en-US "Enable the feature that evacuate temporary mem= ory to permanent memory or not.

\n" + = "It will allocate page to save the temporary PE= IMs resided in NEM(or CAR) to the permanent memory and change all pointers = pointed to the NEM(or CAR) to permanent memory.

\n" + = "After then, there are no pointer pointed to NE= M(or CAR) and TOCTOU volnerability can be avoid.

\n" + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMigrateTemporaryRamFirmwareV= olumes_PROMPT #language en-US "Enable the feature that evacuate temporary m= emory to permanent memory or not" + #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_PROMPT #la= nguage en-US "Default OEM ID for ACPI table creation" =20 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiDefaultOemId_HELP #lang= uage en-US "Default OEM ID for ACPI table creation, its length must be 0x6 = bytes to follow ACPI specification." --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62825): https://edk2.groups.io/g/devel/message/62825 Mute This Topic: https://groups.io/mt/75679700/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62826+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62826+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244633; cv=none; d=zohomail.com; s=zohoarc; b=AcinsjtnzHvdpthvRtUHG7F04c52tzFCdxknuQCRoKV+Ai5dvSrfB+WihgMMFvbMKyE0UX6KgzrTpFGZ0nZYBcz6L3AVafWo3uNA7vmbKWGxX3xPpMTkCeDwM92+H0Hy1JJsHMnBaqoH2f8OecjRbhED94JSV/oDglMViKk8Xoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244633; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NVifIG4927bO4jbpW7hLjdbQbgGMVlqcn+57VyJQ+hE=; b=Cs27yQAGdss7DrrWJqDmUx0PPkboMntxiS33vm39/LbAsLpP/0w5iudLmuq/Lx9shubDpJqzW6OhFh9gY5/bOoUSIaPhxQOLAo6Dpss9HtzLsfpIH/Sp0j9oQ8Ye7zIZJLaO1+J+KB3ZAR+BndsW11cFiv4I+fjw3rz2Ip5KJN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62826+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244633944761.5649022019733; Mon, 20 Jul 2020 04:30:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8dewYY1788612xbIctO8AlLR; Mon, 20 Jul 2020 04:30:33 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:33 -0700 IronPort-SDR: gN2bL6HIsusD11eLqOlJ/dU8/oagQVqQ+VLKMqGRiZZ3gLgHvvJGWEcFC2oDZm1EWK1TJSyUv8 Y60fRA71G72A== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373140" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373140" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:32 -0700 IronPort-SDR: WjWfN6uqW0kbFy0h7oSgx8+aV7px7MoyGlCypjmpt0r46FPOIXNGnoVUnQIN5torn3326zE50S 77lSqtXuYxYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411139" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:29 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Michael Kubacki , Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Debkumar De , Harry Han , Catharine West , Laszlo Ersek Subject: [edk2-devel] [PATCH v6 02/10] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:14 +0800 Message-Id: <20200720113022.675-3-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: 9HY6Gffb3Ya9L6YhSwJVRYzDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244633; bh=Me592aXkrVgb7Clj+wtg0xSp728lm4NuJcg3X3T5OQM=; h=Cc:Date:From:Reply-To:Subject:To; b=LBQUMn0B/2drOtbaAYuJyW9bwkZnz4kK44cmFsX6ndnSDTLWNQOneicwUMORAQG7b/M wgQTSsOWwVTX4W6rfPQDlTf2jgAfpMluJBXbcMQr5/gRYT3v41KG1ED1wjik/ZZNbhvFr zZofrRVBdslccQp+JG0Um3E5MVJ1QeIz1b0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 Introduces new changes to PeiCore to move the contents of temporary RAM visible to the PeiCore to permanent memory. This expands on pre-existing shadowing support in the PeiCore to perform the following additional actions: 1. Migrate pointers in PPIs installed in PeiCore to the permanent memory copy of PeiCore. 2. Copy all installed firmware volumes to permanent memory. 3. Relocate and fix up the PEIMs within the firmware volumes. 4. Convert all PPIs into the migrated firmware volume to the corresponding PPI address in the permanent memory location. This applies to PPIs and PEI notifications. 5. Convert all status code callbacks in the migrated firmware volume to the corresponding address in the permanent memory location. 6. Update the FV HOB to the corresponding firmware volume in permanent memory. 7. Add PcdMigrateTemporaryRamFirmwareVolumes to control if enable the feature or not. when the PCD disable, the EvacuateTempRam() will never be called. The function control flow as below: PeiCore() DumpPpiList() EvacuateTempRam() ConvertPeiCorePpiPointers() ConvertPpiPointersFv() MigratePeimsInFv() MigratePeim() PeiGetPe32Data() LoadAndRelocatePeCoffImageInPlace() MigrateSecModulesInFv() ConvertPpiPointersFv() ConvertStatusCodeCallbacks() ConvertFvHob() RemoveFvHobsInTemporaryMemory() DumpPpiList() Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Debkumar De Cc: Harry Han Cc: Catharine West Signed-off-by: Michael Kubacki Acked-by: Laszlo Ersek --- MdeModulePkg/Core/Pei/PeiMain.inf | 2 + MdeModulePkg/Core/Pei/PeiMain.h | 169 ++++++++ MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 392 ++++++++++++++++++ MdeModulePkg/Core/Pei/Image/Image.c | 116 ++++++ MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 82 ++++ MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 24 ++ MdeModulePkg/Core/Pei/Ppi/Ppi.c | 287 +++++++++++++ 7 files changed, 1072 insertions(+) diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiM= ain.inf index 6e25cc40232a..5b36d516b3fa 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -76,6 +76,7 @@ [Guids] ## CONSUMES ## UNDEFINED # Locate PPI ## CONSUMES ## GUID # Used to compare with FV's file system GUID = and get the FV's file system format gEfiFirmwareFileSystem3Guid + gStatusCodeCallbackGuid =20 [Ppis] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # Pe= iReportStatusService is not ready if this PPI doesn't exist @@ -109,6 +110,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnS3Boot = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdShadowPeimOnBoot = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes = ## CONSUMES =20 # [BootMode] # S3_RESUME ## SOMETIMES_CONSUMES diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMai= n.h index 56b3bd85793d..6d95a5d32c78 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -394,6 +394,41 @@ PeimDispatchReadiness ( IN VOID *DependencyExpression ); =20 +/** + Migrate a PEIM from temporary RAM to permanent memory. + + @param PeimFileHandle Pointer to the FFS file header of the image. + @param MigratedFileHandle Pointer to the FFS file header of the migrat= ed image. + + @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent m= emory. + +**/ +EFI_STATUS +EFIAPI +MigratePeim ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN EFI_PEI_FILE_HANDLE MigratedFileHandle + ); + +/** + Migrate FVs out of temporary RAM before the cache is flushed. + + @param Private PeiCore's private data structure + @param SecCoreData Points to a data structure containing information= about the PEI core's operating + environment, such as the size and location of tem= porary RAM, the stack location and + the BFV location. + + @retval EFI_SUCCESS Succesfully migrated installed FVs from te= mporary RAM to permanent memory. + @retval EFI_OUT_OF_RESOURCES Insufficient memory exists to allocate nee= ded pages. + +**/ +EFI_STATUS +EFIAPI +EvacuateTempRam ( + IN PEI_CORE_INSTANCE *Private, + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData + ); + /** Conduct PEIM dispatch. =20 @@ -477,6 +512,50 @@ ConvertPpiPointers ( IN PEI_CORE_INSTANCE *PrivateData ); =20 +/** + + Migrate Notify Pointers inside an FV from temporary memory to permanent = memory. + + @param PrivateData Pointer to PeiCore's private data structure. + @param OrgFvHandle Address of FV Handle in temporary memory. + @param FvHandle Address of FV Handle in permanent memory. + @param FvSize Size of the FV. + +**/ +VOID +ConvertPpiPointersFv ( + IN PEI_CORE_INSTANCE *PrivateData, + IN UINTN OrgFvHandle, + IN UINTN FvHandle, + IN UINTN FvSize + ); + +/** + + Migrate PPI Pointers of PEI_CORE from temporary memory to permanent memo= ry. + + @param PrivateData Pointer to PeiCore's private data structure. + @param CoreFvHandle Address of PEI_CORE FV Handle in temporary memor= y. + +**/ +VOID +ConvertPeiCorePpiPointers ( + IN PEI_CORE_INSTANCE *PrivateData, + PEI_CORE_FV_HANDLE CoreFvHandle + ); + +/** + + Dumps the PPI lists to debug output. + + @param PrivateData Points to PeiCore's private instance data. + +**/ +VOID +DumpPpiList ( + IN PEI_CORE_INSTANCE *PrivateData + ); + /** =20 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi. @@ -808,6 +887,37 @@ PeiFfsFindNextFile ( IN OUT EFI_PEI_FILE_HANDLE *FileHandle ); =20 +/** + Go through the file to search SectionType section. + Search within encapsulation sections (compression and GUIDed) recursivel= y, + until the match section is found. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES = table published by the PEI Foundation. + @param SectionType Filter to find only section of this type. + @param SectionInstance Pointer to the filter to find the specific i= nstance of section. + @param Section From where to search. + @param SectionSize The file size to search. + @param OutputBuffer A pointer to the discovered section, if succ= essful. + NULL if section not found. + @param AuthenticationStatus Updated upon return to point to the authenti= cation status for this section. + @param IsFfs3Fv Indicates the FV format. + + @return EFI_NOT_FOUND The match section is not found. + @return EFI_SUCCESS The match section is found. + +**/ +EFI_STATUS +ProcessSection ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_SECTION_TYPE SectionType, + IN OUT UINTN *SectionInstance, + IN EFI_COMMON_SECTION_HEADER *Section, + IN UINTN SectionSize, + OUT VOID **OutputBuffer, + OUT UINT32 *AuthenticationStatus, + IN BOOLEAN IsFfs3Fv + ); + /** Searches for the next matching section within the specified file. =20 @@ -931,6 +1041,33 @@ MigrateMemoryPages ( IN BOOLEAN TemporaryRamMigrated ); =20 +/** + Removes any FV HOBs whose base address is not in PEI installed memory. + + @param[in] Private Pointer to PeiCore's private data structure. + +**/ +VOID +RemoveFvHobsInTemporaryMemory ( + IN PEI_CORE_INSTANCE *Private + ); + +/** + Migrate the base address in firmware volume allocation HOBs + from temporary memory to PEI installed memory. + + @param[in] PrivateData Pointer to PeiCore's private data structure. + @param[in] OrgFvHandle Address of FV Handle in temporary memory. + @param[in] FvHandle Address of FV Handle in permanent memory. + +**/ +VOID +ConvertFvHob ( + IN PEI_CORE_INSTANCE *PrivateData, + IN UINTN OrgFvHandle, + IN UINTN FvHandle + ); + /** Migrate MemoryBaseAddress in memory allocation HOBs from the temporary memory to PEI installed memory. @@ -1249,6 +1386,38 @@ InitializeImageServices ( IN PEI_CORE_INSTANCE *OldCoreData ); =20 +/** + Loads and relocates a PE/COFF image in place. + + @param Pe32Data The base address of the PE/COFF file that is to = be loaded and relocated + @param ImageAddress The base address of the relocated PE/COFF image + + @retval EFI_SUCCESS The file was loaded and relocated + @retval Others The file not be loaded and error occurred. + +**/ +EFI_STATUS +LoadAndRelocatePeCoffImageInPlace ( + IN VOID *Pe32Data, + IN VOID *ImageAddress + ); + +/** + Find the PE32 Data for an FFS file. + + @param FileHandle Pointer to the FFS file header of the image. + @param Pe32Data Pointer to a (VOID *) PE32 Data pointer. + + @retval EFI_SUCCESS Image is successfully loaded. + @retval EFI_NOT_FOUND Fail to locate PE32 Data. + +**/ +EFI_STATUS +PeiGetPe32Data ( + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT VOID **Pe32Data + ); + /** The wrapper function of PeiLoadImageLoadImage(). =20 diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index 4c2eac1384e8..6cf32fdeeb14 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -952,6 +952,398 @@ PeiCheckAndSwitchStack ( } } =20 +/** + Migrate a PEIM from temporary RAM to permanent memory. + + @param PeimFileHandle Pointer to the FFS file header of the image. + @param MigratedFileHandle Pointer to the FFS file header of the migrat= ed image. + + @retval EFI_SUCCESS Sucessfully migrated the PEIM to permanent m= emory. + +**/ +EFI_STATUS +EFIAPI +MigratePeim ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN EFI_PEI_FILE_HANDLE MigratedFileHandle + ) +{ + EFI_STATUS Status; + EFI_FFS_FILE_HEADER *FileHeader; + VOID *Pe32Data; + VOID *ImageAddress; + CHAR8 *AsciiString; + UINTN Index; + + Status =3D EFI_SUCCESS; + + FileHeader =3D (EFI_FFS_FILE_HEADER *) FileHandle; + ASSERT (!IS_FFS_FILE2 (FileHeader)); + + ImageAddress =3D NULL; + PeiGetPe32Data (MigratedFileHandle, &ImageAddress); + if (ImageAddress !=3D NULL) { + DEBUG_CODE_BEGIN (); + AsciiString =3D PeCoffLoaderGetPdbPointer (ImageAddress); + for (Index =3D 0; AsciiString[Index] !=3D 0; Index++) { + if (AsciiString[Index] =3D=3D '\\' || AsciiString[Index] =3D=3D '/')= { + AsciiString =3D AsciiString + Index + 1; + Index =3D 0; + } else if (AsciiString[Index] =3D=3D '.') { + AsciiString[Index] =3D 0; + } + } + DEBUG ((DEBUG_INFO, "%a", AsciiString)); + DEBUG_CODE_END (); + + Pe32Data =3D (VOID *) ((UINTN) ImageAddress - (UINTN) MigratedFileHand= le + (UINTN) FileHandle); + Status =3D LoadAndRelocatePeCoffImageInPlace (Pe32Data, ImageAddress); + ASSERT_EFI_ERROR (Status); + } + + return Status; +} + +/** + Migrate Status Code Callback function pointers inside an FV from tempora= ry memory to permanent memory. + + @param OrgFvHandle Address of FV handle in temporary memory. + @param FvHandle Address of FV handle in permanent memory. + @param FvSize Size of the FV. + +**/ +VOID +ConvertStatusCodeCallbacks ( + IN UINTN OrgFvHandle, + IN UINTN FvHandle, + IN UINTN FvSize + ) +{ + EFI_PEI_HOB_POINTERS Hob; + UINTN *NumberOfEntries; + UINTN *CallbackEntry; + UINTN Index; + + Hob.Raw =3D GetFirstGuidHob (&gStatusCodeCallbackGuid); + while (Hob.Raw !=3D NULL) { + NumberOfEntries =3D GET_GUID_HOB_DATA (Hob); + CallbackEntry =3D NumberOfEntries + 1; + for (Index =3D 0; Index < *NumberOfEntries; Index++) { + if (((VOID *) CallbackEntry[Index]) !=3D NULL) { + if ((CallbackEntry[Index] >=3D OrgFvHandle) && (CallbackEntry[Inde= x] < (OrgFvHandle + FvSize))) { + DEBUG ((DEBUG_INFO, "Migrating CallbackEntry[%d] from 0x%p to ",= Index, CallbackEntry[Index])); + if (OrgFvHandle > FvHandle) { + CallbackEntry[Index] =3D CallbackEntry[Index] - (OrgFvHandle -= FvHandle); + } else { + CallbackEntry[Index] =3D CallbackEntry[Index] + (FvHandle - Or= gFvHandle); + } + DEBUG ((DEBUG_INFO, "0x%p\n", CallbackEntry[Index])); + } + } + } + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextGuidHob (&gStatusCodeCallbackGuid, Hob.Raw); + } +} + +/** + Migrates SEC modules in the given firmware volume. + + Migrating SECURITY_CORE files requires special treatment since they are = not tracked for PEI dispatch. + + This functioun should be called after the FV has been copied to its post= -memory location and the PEI Core FV list has + been updated. + + @param Private Pointer to the PeiCore's private data structure. + @param FvIndex The firmware volume index to migrate. + @param OrgFvHandle The handle to the firmware volume in temporary m= emory. + + @retval EFI_SUCCESS SEC modules were migrated successfully + @retval EFI_INVALID_PARAMETER The Private pointer is NULL or FvCount i= s invalid. + @retval EFI_NOT_FOUND Can't find valid FFS header. + +**/ +EFI_STATUS +EFIAPI +MigrateSecModulesInFv ( + IN PEI_CORE_INSTANCE *Private, + IN UINTN FvIndex, + IN UINTN OrgFvHandle + ) +{ + EFI_STATUS Status; + EFI_STATUS FindFileStatus; + EFI_PEI_FILE_HANDLE MigratedFileHandle; + EFI_PEI_FILE_HANDLE FileHandle; + UINT32 SectionAuthenticationStatus; + UINT32 FileSize; + VOID *OrgPe32SectionData; + VOID *Pe32SectionData; + EFI_FFS_FILE_HEADER *FfsFileHeader; + EFI_COMMON_SECTION_HEADER *Section; + BOOLEAN IsFfs3Fv; + UINTN SectionInstance; + + if (Private =3D=3D NULL || FvIndex >=3D Private->FvCount) { + return EFI_INVALID_PARAMETER; + } + + do { + FindFileStatus =3D PeiFfsFindNextFile ( + GetPeiServicesTablePointer (), + EFI_FV_FILETYPE_SECURITY_CORE, + Private->Fv[FvIndex].FvHandle, + &MigratedFileHandle + ); + if (!EFI_ERROR (FindFileStatus ) && MigratedFileHandle !=3D NULL) { + FileHandle =3D (EFI_PEI_FILE_HANDLE) ((UINTN) MigratedFileHandle - (= UINTN) Private->Fv[FvIndex].FvHandle + OrgFvHandle); + FfsFileHeader =3D (EFI_FFS_FILE_HEADER *) MigratedFileHandle; + + DEBUG ((DEBUG_VERBOSE, " Migrating SEC_CORE MigratedFileHandle at= 0x%x.\n", (UINTN) MigratedFileHandle)); + DEBUG ((DEBUG_VERBOSE, " FileHandle at 0x%x.\n= ", (UINTN) FileHandle)); + + IsFfs3Fv =3D CompareGuid (&Private->Fv[FvIndex].FvHeader->FileSystem= Guid, &gEfiFirmwareFileSystem3Guid); + if (IS_FFS_FILE2 (FfsFileHeader)) { + ASSERT (FFS_FILE2_SIZE (FfsFileHeader) > 0x00FFFFFF); + if (!IsFfs3Fv) { + DEBUG ((DEBUG_ERROR, "It is a FFS3 formatted file: %g in a non-F= FS3 formatted FV.\n", &FfsFileHeader->Name)); + return EFI_NOT_FOUND; + } + Section =3D (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) FfsFileHeader= + sizeof (EFI_FFS_FILE_HEADER2)); + FileSize =3D FFS_FILE2_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE= _HEADER2); + } else { + Section =3D (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) FfsFileHeader= + sizeof (EFI_FFS_FILE_HEADER)); + FileSize =3D FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_= HEADER); + } + + SectionInstance =3D 1; + SectionAuthenticationStatus =3D 0; + Status =3D ProcessSection ( + GetPeiServicesTablePointer (), + EFI_SECTION_PE32, + &SectionInstance, + Section, + FileSize, + &Pe32SectionData, + &SectionAuthenticationStatus, + IsFfs3Fv + ); + + if (!EFI_ERROR (Status)) { + OrgPe32SectionData =3D (VOID *) ((UINTN) Pe32SectionData - (UINTN)= MigratedFileHandle + (UINTN) FileHandle); + DEBUG ((DEBUG_VERBOSE, " PE32 section in migrated file at 0x%= x.\n", (UINTN) Pe32SectionData)); + DEBUG ((DEBUG_VERBOSE, " PE32 section in original file at 0x%= x.\n", (UINTN) OrgPe32SectionData)); + Status =3D LoadAndRelocatePeCoffImageInPlace (OrgPe32SectionData, = Pe32SectionData); + ASSERT_EFI_ERROR (Status); + } + } + } while (!EFI_ERROR (FindFileStatus)); + + return EFI_SUCCESS; +} + +/** + Migrates PEIMs in the given firmware volume. + + @param Private Pointer to the PeiCore's private data structure. + @param FvIndex The firmware volume index to migrate. + @param OrgFvHandle The handle to the firmware volume in temporary m= emory. + @param FvHandle The handle to the firmware volume in permanent m= emory. + + @retval EFI_SUCCESS The PEIMs in the FV were migrated succes= sfully + @retval EFI_INVALID_PARAMETER The Private pointer is NULL or FvCount i= s invalid. + +**/ +EFI_STATUS +EFIAPI +MigratePeimsInFv ( + IN PEI_CORE_INSTANCE *Private, + IN UINTN FvIndex, + IN UINTN OrgFvHandle, + IN UINTN FvHandle + ) +{ + EFI_STATUS Status; + volatile UINTN FileIndex; + EFI_PEI_FILE_HANDLE MigratedFileHandle; + EFI_PEI_FILE_HANDLE FileHandle; + + if (Private =3D=3D NULL || FvIndex >=3D Private->FvCount) { + return EFI_INVALID_PARAMETER; + } + + if (Private->Fv[FvIndex].ScanFv) { + for (FileIndex =3D 0; FileIndex < Private->Fv[FvIndex].PeimCount; File= Index++) { + if (Private->Fv[FvIndex].FvFileHandles[FileIndex] !=3D NULL) { + FileHandle =3D Private->Fv[FvIndex].FvFileHandles[FileIndex]; + + MigratedFileHandle =3D (EFI_PEI_FILE_HANDLE) ((UINTN) FileHandle -= OrgFvHandle + FvHandle); + + DEBUG ((DEBUG_VERBOSE, " Migrating FileHandle %2d ", FileIndex)= ); + Status =3D MigratePeim (FileHandle, MigratedFileHandle); + DEBUG ((DEBUG_VERBOSE, "\n")); + ASSERT_EFI_ERROR (Status); + + if (!EFI_ERROR (Status)) { + Private->Fv[FvIndex].FvFileHandles[FileIndex] =3D MigratedFileHa= ndle; + if (FvIndex =3D=3D Private->CurrentPeimFvCount) { + Private->CurrentFvFileHandles[FileIndex] =3D MigratedFileHandl= e; + } + } + } + } + } + + return EFI_SUCCESS; +} + +/** + Migrate FVs out of temporary RAM before the cache is flushed. + + @param Private PeiCore's private data structure + @param SecCoreData Points to a data structure containing information= about the PEI core's operating + environment, such as the size and location of tem= porary RAM, the stack location and + the BFV location. + + @retval EFI_SUCCESS Succesfully migrated installed FVs from te= mporary RAM to permanent memory. + @retval EFI_OUT_OF_RESOURCES Insufficient memory exists to allocate nee= ded pages. + +**/ +EFI_STATUS +EFIAPI +EvacuateTempRam ( + IN PEI_CORE_INSTANCE *Private, + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData + ) +{ + EFI_STATUS Status; + volatile UINTN FvIndex; + volatile UINTN FvChildIndex; + UINTN ChildFvOffset; + EFI_FIRMWARE_VOLUME_HEADER *FvHeader; + EFI_FIRMWARE_VOLUME_HEADER *ChildFvHeader; + EFI_FIRMWARE_VOLUME_HEADER *MigratedFvHeader; + EFI_FIRMWARE_VOLUME_HEADER *MigratedChildFvHeader; + + PEI_CORE_FV_HANDLE PeiCoreFvHandle; + EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; + + ASSERT (Private->PeiMemoryInstalled); + + DEBUG ((DEBUG_VERBOSE, "Beginning evacuation of content in temporary RAM= .\n")); + + // + // Migrate PPI Pointers of PEI_CORE from temporary memory to newly loade= d PEI_CORE in permanent memory. + // + Status =3D PeiLocatePpi ((CONST EFI_PEI_SERVICES **) &Private->Ps, &gEfi= PeiCoreFvLocationPpiGuid, 0, NULL, (VOID **) &PeiCoreFvLocationPpi); + if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation !=3D= NULL)) { + PeiCoreFvHandle.FvHandle =3D (EFI_PEI_FV_HANDLE) PeiCoreFvLocationPpi-= >PeiCoreFvLocation; + } else { + PeiCoreFvHandle.FvHandle =3D (EFI_PEI_FV_HANDLE) SecCoreData->BootFirm= wareVolumeBase; + } + for (FvIndex =3D 0; FvIndex < Private->FvCount; FvIndex++) { + if (Private->Fv[FvIndex].FvHandle =3D=3D PeiCoreFvHandle.FvHandle) { + PeiCoreFvHandle =3D Private->Fv[FvIndex]; + break; + } + } + Status =3D EFI_SUCCESS; + + ConvertPeiCorePpiPointers (Private, PeiCoreFvHandle); + + for (FvIndex =3D 0; FvIndex < Private->FvCount; FvIndex++) { + FvHeader =3D Private->Fv[FvIndex].FvHeader; + ASSERT (FvHeader !=3D NULL); + ASSERT (FvIndex < Private->FvCount); + + DEBUG ((DEBUG_VERBOSE, "FV[%02d] at 0x%x.\n", FvIndex, (UINTN) FvHeade= r)); + if ( + !( + ((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader >=3D Private->PhysicalMemo= ryBegin) && + (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1= )) < Private->FreePhysicalMemoryTop) + ) + ) { + Status =3D PeiServicesAllocatePages ( + EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength), + (EFI_PHYSICAL_ADDRESS *) &MigratedFvHeader + ); + ASSERT_EFI_ERROR (Status); + + DEBUG (( + DEBUG_VERBOSE, + " Migrating FV[%d] from 0x%08X to 0x%08X\n", + FvIndex, + (UINTN) FvHeader, + (UINTN) MigratedFvHeader + )); + + CopyMem (MigratedFvHeader, FvHeader, (UINTN) FvHeader->FvLength); + + // + // Migrate any children for this FV now + // + for (FvChildIndex =3D FvIndex; FvChildIndex < Private->FvCount; FvCh= ildIndex++) { + ChildFvHeader =3D Private->Fv[FvChildIndex].FvHeader; + if ( + ((UINTN) ChildFvHeader > (UINTN) FvHeader) && + (((UINTN) ChildFvHeader + ChildFvHeader->FvLength) < ((UINTN) Fv= Header) + FvHeader->FvLength) + ) { + DEBUG ((DEBUG_VERBOSE, " Child FV[%02d] is being migrated.\n"= , FvChildIndex)); + ChildFvOffset =3D (UINTN) ChildFvHeader - (UINTN) FvHeader; + DEBUG ((DEBUG_VERBOSE, " Child FV offset =3D 0x%x.\n", ChildF= vOffset)); + MigratedChildFvHeader =3D (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN= ) MigratedFvHeader + ChildFvOffset); + Private->Fv[FvChildIndex].FvHeader =3D MigratedChildFvHeader; + Private->Fv[FvChildIndex].FvHandle =3D (EFI_PEI_FV_HANDLE) Migra= tedChildFvHeader; + DEBUG ((DEBUG_VERBOSE, " Child migrated FV header at 0x%x.\n"= , (UINTN) MigratedChildFvHeader)); + + Status =3D MigratePeimsInFv (Private, FvChildIndex, (UINTN) Chi= ldFvHeader, (UINTN) MigratedChildFvHeader); + ASSERT_EFI_ERROR (Status); + + ConvertPpiPointersFv ( + Private, + (UINTN) ChildFvHeader, + (UINTN) MigratedChildFvHeader, + (UINTN) ChildFvHeader->FvLength - 1 + ); + + ConvertStatusCodeCallbacks ( + (UINTN) ChildFvHeader, + (UINTN) MigratedChildFvHeader, + (UINTN) ChildFvHeader->FvLength - 1 + ); + + ConvertFvHob (Private, (UINTN) ChildFvHeader, (UINTN) MigratedCh= ildFvHeader); + } + } + Private->Fv[FvIndex].FvHeader =3D MigratedFvHeader; + Private->Fv[FvIndex].FvHandle =3D (EFI_PEI_FV_HANDLE) MigratedFvHead= er; + + Status =3D MigratePeimsInFv (Private, FvIndex, (UINTN) FvHeader, (UI= NTN) MigratedFvHeader); + ASSERT_EFI_ERROR (Status); + + ConvertPpiPointersFv ( + Private, + (UINTN) FvHeader, + (UINTN) MigratedFvHeader, + (UINTN) FvHeader->FvLength - 1 + ); + + ConvertStatusCodeCallbacks ( + (UINTN) FvHeader, + (UINTN) MigratedFvHeader, + (UINTN) FvHeader->FvLength - 1 + ); + + ConvertFvHob (Private, (UINTN) FvHeader, (UINTN) MigratedFvHeader); + } + } + + RemoveFvHobsInTemporaryMemory (Private); + + return Status; +} + /** Conduct PEIM dispatch. =20 diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/Image.c index e3ee3699337f..0caeb63e26b4 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -444,6 +444,122 @@ LoadAndRelocatePeCoffImage ( return ReturnStatus; } =20 +/** + Loads and relocates a PE/COFF image in place. + + @param Pe32Data The base address of the PE/COFF file that is to = be loaded and relocated + @param ImageAddress The base address of the relocated PE/COFF image + + @retval EFI_SUCCESS The file was loaded and relocated. + @retval Others The file not be loaded and error occurred. + +**/ +EFI_STATUS +LoadAndRelocatePeCoffImageInPlace ( + IN VOID *Pe32Data, + IN VOID *ImageAddress + ) +{ + EFI_STATUS Status; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + + ZeroMem (&ImageContext, sizeof (ImageContext)); + ImageContext.Handle =3D Pe32Data; + ImageContext.ImageRead =3D PeiImageRead; + + Status =3D PeCoffLoaderGetImageInfo (&ImageContext); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + ImageContext.ImageAddress =3D (PHYSICAL_ADDRESS)(UINTN) ImageAddress; + + // + // Load the image in place + // + Status =3D PeCoffLoaderLoadImage (&ImageContext); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + // + // Relocate the image in place + // + Status =3D PeCoffLoaderRelocateImage (&ImageContext); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + // + // Flush the instruction cache so the image data is written before we ex= ecute it + // + if (ImageContext.ImageAddress !=3D (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Dat= a) { + InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddr= ess, (UINTN)ImageContext.ImageSize); + } + + return Status; +} + +/** + Find the PE32 Data for an FFS file. + + @param FileHandle Pointer to the FFS file header of the image. + @param Pe32Data Pointer to a (VOID *) PE32 Data pointer. + + @retval EFI_SUCCESS Image is successfully loaded. + @retval EFI_NOT_FOUND Fail to locate PE32 Data. + +**/ +EFI_STATUS +PeiGetPe32Data ( + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT VOID **Pe32Data + ) +{ + EFI_STATUS Status; + EFI_SECTION_TYPE SearchType1; + EFI_SECTION_TYPE SearchType2; + UINT32 AuthenticationState; + + *Pe32Data =3D NULL; + + if (FeaturePcdGet (PcdPeiCoreImageLoaderSearchTeSectionFirst)) { + SearchType1 =3D EFI_SECTION_TE; + SearchType2 =3D EFI_SECTION_PE32; + } else { + SearchType1 =3D EFI_SECTION_PE32; + SearchType2 =3D EFI_SECTION_TE; + } + + // + // Try to find a first exe section (if PcdPeiCoreImageLoaderSearchTeSect= ionFirst + // is true, TE will be searched first). + // + Status =3D PeiServicesFfsFindSectionData3 ( + SearchType1, + 0, + FileHandle, + Pe32Data, + &AuthenticationState + ); + // + // If we didn't find a first exe section, try to find the second exe sec= tion. + // + if (EFI_ERROR (Status)) { + Status =3D PeiServicesFfsFindSectionData3 ( + SearchType2, + 0, + FileHandle, + Pe32Data, + &AuthenticationState + ); + } + return Status; +} + /** Loads a PEIM into memory for subsequent execution. If there are compress= ed images or images that need to be relocated into memory for performance r= easons, diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/C= ore/Pei/Memory/MemoryServices.c index 6b3a64a811cd..9d933f0393a8 100644 --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c @@ -166,6 +166,88 @@ MigrateMemoryPages ( Private->FreePhysicalMemoryTop =3D NewMemPagesBase; } =20 +/** + Removes any FV HOBs whose base address is not in PEI installed memory. + + @param[in] Private Pointer to PeiCore's private data structure. + +**/ +VOID +RemoveFvHobsInTemporaryMemory ( + IN PEI_CORE_INSTANCE *Private + ) +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob; + + DEBUG ((DEBUG_INFO, "Removing FVs in FV HOB not already migrated to perm= anent memory.\n")); + + for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_= NEXT_HOB (Hob)) { + if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV || GET_HOB_TYPE (Hob) = =3D=3D EFI_HOB_TYPE_FV2 || GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV3) { + FirmwareVolumeHob =3D Hob.FirmwareVolume; + DEBUG ((DEBUG_INFO, " Found FV HOB.\n")); + DEBUG (( + DEBUG_INFO, + " BA=3D%016lx L=3D%016lx\n", + FirmwareVolumeHob->BaseAddress, + FirmwareVolumeHob->Length + )); + if ( + !( + ((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress >= =3D Private->PhysicalMemoryBegin) && + (((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress = + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop) + ) + ) { + DEBUG ((DEBUG_INFO, " Removing FV HOB to an FV in T-RAM (was = not migrated).\n")); + Hob.Header->HobType =3D EFI_HOB_TYPE_UNUSED; + } + } + } +} + +/** + Migrate the base address in firmware volume allocation HOBs + from temporary memory to PEI installed memory. + + @param[in] PrivateData Pointer to PeiCore's private data structure. + @param[in] OrgFvHandle Address of FV Handle in temporary memory. + @param[in] FvHandle Address of FV Handle in permanent memory. + +**/ +VOID +ConvertFvHob ( + IN PEI_CORE_INSTANCE *PrivateData, + IN UINTN OrgFvHandle, + IN UINTN FvHandle + ) +{ + EFI_PEI_HOB_POINTERS Hob; + EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob; + EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob; + EFI_HOB_FIRMWARE_VOLUME3 *FirmwareVolume3Hob; + + DEBUG ((DEBUG_INFO, "Converting FVs in FV HOB.\n")); + + for (Hob.Raw =3D GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw =3D GET_= NEXT_HOB (Hob)) { + if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV) { + FirmwareVolumeHob =3D Hob.FirmwareVolume; + if (FirmwareVolumeHob->BaseAddress =3D=3D OrgFvHandle) { + FirmwareVolumeHob->BaseAddress =3D FvHandle; + } + } else if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV2) { + FirmwareVolume2Hob =3D Hob.FirmwareVolume2; + if (FirmwareVolume2Hob->BaseAddress =3D=3D OrgFvHandle) { + FirmwareVolume2Hob->BaseAddress =3D FvHandle; + } + } else if (GET_HOB_TYPE (Hob) =3D=3D EFI_HOB_TYPE_FV3) { + FirmwareVolume3Hob =3D Hob.FirmwareVolume3; + if (FirmwareVolume3Hob->BaseAddress =3D=3D OrgFvHandle) { + FirmwareVolume3Hob->BaseAddress =3D FvHandle; + } + } + } +} + /** Migrate MemoryBaseAddress in memory allocation HOBs from the temporary memory to PEI installed memory. diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pe= i/PeiMain/PeiMain.c index cca57c4c0686..48605eeada86 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -176,6 +176,9 @@ PeiCore ( EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable; EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi; UINTN Index; + BOOLEAN TempRamEvacuation; + + TempRamEvacuation =3D FALSE; =20 // // Retrieve context passed into PEI Core @@ -418,6 +421,27 @@ PeiCore ( ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, = PpiList); } } else { + if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { + if (PrivateData.HobList.HandoffInformationTable->BootMode =3D=3D BOO= T_ON_S3_RESUME) { + TempRamEvacuation =3D PcdGetBool (PcdShadowPeimOnS3Boot); + } else { + TempRamEvacuation =3D PcdGetBool (PcdShadowPeimOnBoot); + } + } + + if (TempRamEvacuation) { + DEBUG ((DEBUG_VERBOSE, "PPI lists before temporary RAM evacuation:\n= ")); + DumpPpiList (&PrivateData); + + // + // Migrate installed content from Temporary RAM to Permanent RAM + // + EvacuateTempRam (&PrivateData, SecCoreData); + + DEBUG ((DEBUG_VERBOSE, "PPI lists after temporary RAM evacuation:\n"= )); + DumpPpiList (&PrivateData); + } + // // Try to locate Temporary RAM Done Ppi. // diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Pp= i.c index 1ffe718c4702..018b25f86470 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -198,6 +198,227 @@ ConvertPpiPointers ( } } =20 +/** + + Migrate Notify Pointers inside an FV from temporary memory to permanent = memory. + + @param PrivateData Pointer to PeiCore's private data structure. + @param OrgFvHandle Address of FV Handle in temporary memory. + @param FvHandle Address of FV Handle in permanent memory. + @param FvSize Size of the FV. + +**/ +VOID +ConvertPpiPointersFv ( + IN PEI_CORE_INSTANCE *PrivateData, + IN UINTN OrgFvHandle, + IN UINTN FvHandle, + IN UINTN FvSize + ) +{ + UINT8 Index; + UINTN Offset; + BOOLEAN OffsetPositive; + EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi; + UINT8 GuidIndex; + EFI_GUID *Guid; + EFI_GUID *GuidCheckList[2]; + + GuidCheckList[0] =3D &gEfiPeiFirmwareVolumeInfoPpiGuid; + GuidCheckList[1] =3D &gEfiPeiFirmwareVolumeInfo2PpiGuid; + + if (FvHandle > OrgFvHandle) { + OffsetPositive =3D TRUE; + Offset =3D FvHandle - OrgFvHandle; + } else { + OffsetPositive =3D FALSE; + Offset =3D OrgFvHandle - FvHandle; + } + + DEBUG ((DEBUG_VERBOSE, "Converting PPI pointers in FV.\n")); + DEBUG (( + DEBUG_VERBOSE, + " OrgFvHandle at 0x%08x. FvHandle at 0x%08x. FvSize =3D 0x%x\n", + (UINTN) OrgFvHandle, + (UINTN) FvHandle, + FvSize + )); + DEBUG (( + DEBUG_VERBOSE, + " OrgFvHandle range: 0x%08x - 0x%08x\n", + OrgFvHandle, + OrgFvHandle + FvSize + )); + + for (Index =3D 0; Index < PrivateData->PpiData.CallbackNotifyList.Curren= tCount; Index++) { + ConvertPointer ( + (VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Inde= x].Raw, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Inde= x].Notify->Guid, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Inde= x].Notify->Notify, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + } + + for (Index =3D 0; Index < PrivateData->PpiData.DispatchNotifyList.Curren= tCount; Index++) { + ConvertPointer ( + (VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]= .Raw, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]= .Notify->Guid, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]= .Notify->Notify, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + } + + for (Index =3D 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Ind= ex++) { + ConvertPointer ( + (VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + ConvertPointer ( + (VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + + Guid =3D PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid; + for (GuidIndex =3D 0; GuidIndex < ARRAY_SIZE (GuidCheckList); ++GuidIn= dex) { + // + // Don't use CompareGuid function here for performance reasons. + // Instead we compare the GUID as INT32 at a time and branch + // on the first failed comparison. + // + if ((((INT32 *)Guid)[0] =3D=3D ((INT32 *)GuidCheckList[GuidIndex])[0= ]) && + (((INT32 *)Guid)[1] =3D=3D ((INT32 *)GuidCheckList[GuidIndex])[1= ]) && + (((INT32 *)Guid)[2] =3D=3D ((INT32 *)GuidCheckList[GuidIndex])[2= ]) && + (((INT32 *)Guid)[3] =3D=3D ((INT32 *)GuidCheckList[GuidIndex])[3= ])) { + FvInfoPpi =3D PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi; + DEBUG ((DEBUG_VERBOSE, " FvInfo: %p -> ", FvInfoPpi->FvInfo)); + if ((UINTN)FvInfoPpi->FvInfo =3D=3D OrgFvHandle) { + ConvertPointer ( + (VOID **)&FvInfoPpi->FvInfo, + OrgFvHandle, + OrgFvHandle + FvSize, + Offset, + OffsetPositive + ); + DEBUG ((DEBUG_VERBOSE, "%p", FvInfoPpi->FvInfo)); + } + DEBUG ((DEBUG_VERBOSE, "\n")); + break; + } + } + } +} + +/** + + Dumps the PPI lists to debug output. + + @param PrivateData Points to PeiCore's private instance data. + +**/ +VOID +DumpPpiList ( + IN PEI_CORE_INSTANCE *PrivateData + ) +{ + DEBUG_CODE_BEGIN (); + UINTN Index; + + if (PrivateData =3D=3D NULL) { + return; + } + + for (Index =3D 0; Index < PrivateData->PpiData.CallbackNotifyList.Curren= tCount; Index++) { + DEBUG (( + DEBUG_VERBOSE, + "CallbackNotify[%2d] {%g} at 0x%x (%a)\n", + Index, + PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Gu= id, + (UINTN) PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Ra= w, + ( + !( + ((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.CallbackNot= ifyList.NotifyPtrs[Index].Raw >=3D PrivateData->PhysicalMemoryBegin) && + (((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.CallbackN= otifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < Pr= ivateData->FreePhysicalMemoryTop) + ) + ? "CAR" : "Post-Memory" + ) + )); + } + for (Index =3D 0; Index < PrivateData->PpiData.DispatchNotifyList.Curren= tCount; Index++) { + DEBUG ((DEBUG_VERBOSE, + "DispatchNotify[%2d] {%g} at 0x%x (%a)\n", + Index, + PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid, + (UINTN) PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw, + ( + !( + ((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.DispatchNotif= yList.NotifyPtrs[Index].Raw >=3DPrivateData->PhysicalMemoryBegin) && + (((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.DispatchNot= ifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < Priv= ateData->FreePhysicalMemoryTop) + ) + ? "CAR" : "Post-Memory" + ) + )); + } + for (Index =3D 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Ind= ex++) { + DEBUG ((DEBUG_VERBOSE, + "PPI[%2d] {%g} at 0x%x (%a)\n", + Index, + PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid, + (UINTN) PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw, + ( + !( + ((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.PpiList.PpiPt= rs[Index].Raw >=3D PrivateData->PhysicalMemoryBegin) && + (((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.PpiList.Ppi= Ptrs[Index].Raw) + sizeof (EFI_PEI_PPI_DESCRIPTOR)) < PrivateData->FreePhys= icalMemoryTop) + ) + ? "CAR" : "Post-Memory" + ) + )); + } + DEBUG_CODE_END (); +} + /** =20 This function installs an interface in the PEI PPI database by GUID. @@ -830,3 +1051,69 @@ ProcessPpiListFromSec ( } } =20 +/** + + Migrate PPI Pointers of PEI_CORE from temporary memory to permanent memo= ry. + + @param PrivateData Pointer to PeiCore's private data structure. + @param CoreFvHandle Address of PEI_CORE FV Handle in temporary memor= y. + +**/ + +VOID +ConvertPeiCorePpiPointers ( + IN PEI_CORE_INSTANCE *PrivateData, + PEI_CORE_FV_HANDLE CoreFvHandle + ) +{ + EFI_FV_FILE_INFO FileInfo; + EFI_PHYSICAL_ADDRESS OrgImageBase; + EFI_PHYSICAL_ADDRESS MigratedImageBase; + UINTN PeiCoreModuleSize; + EFI_PEI_FILE_HANDLE PeiCoreFileHandle; + VOID *PeiCoreImageBase; + VOID *PeiCoreEntryPoint; + EFI_STATUS Status; + + PeiCoreFileHandle =3D NULL; + + // + // Find the PEI Core in the BFV in temporary memory. + // + Status =3D CoreFvHandle.FvPpi->FindFileByType ( + CoreFvHandle.FvPpi, + EFI_FV_FILETYPE_PEI_CORE, + CoreFvHandle.FvHandle, + &PeiCoreFileHandle + ); + ASSERT_EFI_ERROR (Status); + + if (!EFI_ERROR (Status)) { + Status =3D CoreFvHandle.FvPpi->GetFileInfo (CoreFvHandle.FvPpi, PeiCor= eFileHandle, &FileInfo); + ASSERT_EFI_ERROR (Status); + + Status =3D PeiGetPe32Data (PeiCoreFileHandle, &PeiCoreImageBase); + ASSERT_EFI_ERROR (Status); + + // + // Find PEI Core EntryPoint in the BFV in temporary memory. + // + Status =3D PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBas= e, &PeiCoreEntryPoint); + ASSERT_EFI_ERROR (Status); + + OrgImageBase =3D (UINTN) PeiCoreImageBase; + MigratedImageBase =3D (UINTN) _ModuleEntryPoint - ((UINTN) PeiCoreEntr= yPoint - (UINTN) PeiCoreImageBase); + + // + // Size of loaded PEI_CORE in permanent memory. + // + PeiCoreModuleSize =3D (UINTN)FileInfo.BufferSize - ((UINTN) OrgImageBa= se - (UINTN) FileInfo.Buffer); + + // + // Migrate PEI_CORE PPI pointers from temporary memory to newly + // installed PEI_CORE in permanent memory. + // + ConvertPpiPointersFv (PrivateData, (UINTN) OrgImageBase, (UINTN) Migra= tedImageBase, PeiCoreModuleSize); + } +} + --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62826): https://edk2.groups.io/g/devel/message/62826 Mute This Topic: https://groups.io/mt/75679702/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62827+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62827+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244636; cv=none; d=zohomail.com; s=zohoarc; b=lP96Tme0WCuqvFJiIpQaJY4VvwAh5SFb/T2BVNiM8VgzLgc9r1i2rM9FWg6B3kh5cX77zZ90zZOn0Pb7OPQ98NsHBTmsG44CXT8TYzMPZ4XNTzhUObIIReOYrA/vxOsr3CHBv5Q2tvFvyegaADW6cIbeQ7z2QpRXOxPj1kubl9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244636; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=kCLsBqvK/wz6jAELu/8vT/jofQvSdy+U7984Sr6Zelo=; b=hte4nNV/1/4y0WO+YYy7EBPUYV1TLpRR1j5WYqd2jxsuGel8rMZpYk2MmqdkV1W2BuLYXBOFrwklaQzXX9vXqp9AnsqWHujXIKJYlzA9IkGfQgZO8vW691N6NFpuA/xlCgeU9bsHxbWGm8vrBYkETMHJJH8ZrBMyqQx1+gRt8vg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62827+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159524463606655.7195714500881; Mon, 20 Jul 2020 04:30:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id x2IRYY1788612xLhGYJewheL; Mon, 20 Jul 2020 04:30:35 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:35 -0700 IronPort-SDR: 93qs7raQ0r9k3fmMlE0Sxh+bNv3/cIfXC0m/C36pABFfd1IXEJB2hXCnWep0d5rFpTqnWwwSqg r7wYmJXv1G8w== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373156" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373156" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:34 -0700 IronPort-SDR: CLBbq0q8Amyrxq+qsx8ITmVcs6bT9frEb8ikSlPoLtdk+oTkSqU/xUCFFve5H4zRi416G8LNtN kNpmdeyICxIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411165" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:32 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Michael Kubacki , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v6 03/10] UefiCpuPkg/CpuMpPei: Add GDT migration support (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:15 +0800 Message-Id: <20200720113022.675-4-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: pV6sDBMZOGIGdWSvz7Iawx5Jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244635; bh=vHXHkuPrh43Ete0p0rQ/op1i/5lmz8K5fmdeRfbwg5E=; h=Cc:Date:From:Reply-To:Subject:To; b=Nh9XWtCp/iZgfLjfChbd5NF0DX5TxGa5+4k1xLjjXzZIDS7xY4DeRGemKEnR+o6FBUg GLvXOXqKEq1XBjrRiiPHcNv5mf49yMdFCcQjKPbBbKQ5Nt7demd17tiBm5DRdQq0x7hRB THSUxAInh6lx23FBdxY0NuCQHsiSG/6UUPc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 Moves the GDT to permanent memory in a memory discovered callback. This is done to ensure the GDT authenticated in pre-memory is not fetched from outside a verified location after the permanent memory transition. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Michael Kubacki Reviewed-by: Laszlo Ersek Reviewed-by: Jian J Wang --- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 1 + UefiCpuPkg/CpuMpPei/CpuMpPei.h | 12 +++++++++++ UefiCpuPkg/CpuMpPei/CpuMpPei.c | 37 ++++++++++++++++++++++++++++++++ UefiCpuPkg/CpuMpPei/CpuPaging.c | 12 +++++++++-- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPe= i.inf index caead3ce34d4..f4d11b861f77 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -63,6 +63,7 @@ [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList ##= SOMETIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize ##= SOMETIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ##= SOMETIMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes ##= CONSUMES =20 [Depex] TRUE diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index 7d5c527d6006..309478cbe14c 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -397,6 +397,18 @@ SecPlatformInformation2 ( OUT EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2 ); =20 +/** + Migrates the Global Descriptor Table (GDT) to permanent memory. + + @retval EFI_SUCCESS The GDT was migrated successfully. + @retval EFI_OUT_OF_RESOURCES The GDT could not be migrated due to lac= k of available memory. + +**/ +EFI_STATUS +MigrateGdt ( + VOID + ); + /** Initializes MP and exceptions handlers. =20 diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index 07ccbe7c6a91..d07540cf7471 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -429,6 +429,43 @@ GetGdtr ( AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer); } =20 +/** + Migrates the Global Descriptor Table (GDT) to permanent memory. + + @retval EFI_SUCCESS The GDT was migrated successfully. + @retval EFI_OUT_OF_RESOURCES The GDT could not be migrated due to lac= k of available memory. + +**/ +EFI_STATUS +MigrateGdt ( + VOID + ) +{ + EFI_STATUS Status; + UINTN GdtBufferSize; + IA32_DESCRIPTOR Gdtr; + VOID *GdtBuffer; + + AsmReadGdtr ((IA32_DESCRIPTOR *) &Gdtr); + GdtBufferSize =3D sizeof (IA32_SEGMENT_DESCRIPTOR) -1 + Gdtr.Limit + 1; + + Status =3D PeiServicesAllocatePool ( + GdtBufferSize, + &GdtBuffer + ); + ASSERT (GdtBuffer !=3D NULL); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + GdtBuffer =3D ALIGN_POINTER (GdtBuffer, sizeof (IA32_SEGMENT_DESCRIPTOR)= ); + CopyMem (GdtBuffer, (VOID *) Gdtr.Base, Gdtr.Limit + 1); + Gdtr.Base =3D (UINTN) GdtBuffer; + AsmWriteGdtr (&Gdtr); + + return EFI_SUCCESS; +} + /** Initializes CPU exceptions handlers for the sake of stack switch require= ment. =20 diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPagin= g.c index a462e7ee1e38..3bf0574b34c6 100644 --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c @@ -602,8 +602,16 @@ MemoryDiscoveredPpiNotifyCallback ( IN VOID *Ppi ) { - EFI_STATUS Status; - BOOLEAN InitStackGuard; + EFI_STATUS Status; + BOOLEAN InitStackGuard; + BOOLEAN InterruptState; + + if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { + InterruptState =3D SaveAndDisableInterrupts (); + Status =3D MigrateGdt (); + ASSERT_EFI_ERROR (Status); + SetInterruptState (InterruptState); + } =20 // // Paging must be setup first. Otherwise the exception TSS setup during = MP --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62827): https://edk2.groups.io/g/devel/message/62827 Mute This Topic: https://groups.io/mt/75679703/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62828+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62828+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244638; cv=none; d=zohomail.com; s=zohoarc; b=lkg+q5EC9rxrlarJlG8vwCQUWes6lPBFR2RclkUxDk7wN0C5T7h6x6OlLTkxlxPsnSbKgWxw97Di5l9AZg9yHpfs3ZlXgr8P1h1H/tfqyDVtFPIp7z7eHQjZFYCWBM77PBeMKPZIPncYaIzVDYoFbtn6Mn0VvI8B1RZd4DssvNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244638; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cwcZ6aMF5JkbFVXCzMcHTriv3TBQOYbAL8z9nIhBBZY=; b=k5CEZRetAkGWHza84ZdkYXI2jGXW3t7GDU3mETEPYtBOqHZcVXqxrDjIfK/uccDg6L12CyCRMCFrCc1UwJX9TbdB4LuyqoBUF+hkPWPGFykle3PdWFnlBiGfI0DSKmlFE88FPnmQQv+15ZZFuL6MUe/PulH+HVmhc/tdzvPIgTE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62828+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244638489747.5912586673302; Mon, 20 Jul 2020 04:30:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xf3RYY1788612xLkglatv1Gi; Mon, 20 Jul 2020 04:30:38 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:37 -0700 IronPort-SDR: SBzyDhFgJ7jubbs6SUUlYHy6ZhHELEaVo7b4C2Kvl3Z7l3hM2e4aeADbp9VRiIGvMLNZ/p5O3B PrBevoVOHNFg== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373177" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373177" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:37 -0700 IronPort-SDR: DBZM68zqR8lzyO9P0xvbWBLWtTHe5ffLk5HIxKaL+gS+gwkVFNpxKlAVmxXvHbTcFnK8zH+fAf tbbZ+JvwYjEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411198" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:34 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Michael Kubacki , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Debkumar De , Harry Han , Catharine West Subject: [edk2-devel] [PATCH v6 04/10] UefiCpuPkg/SecMigrationPei: Add initial PEIM (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:16 +0800 Message-Id: <20200720113022.675-5-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: wahpFRz4BPdbUbvaMVdVDf72x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244638; bh=UGgXd1rV5f5x+iT1UUh/pwtOUHwYKsX8zZ1qTBJKMs0=; h=Cc:Date:From:Reply-To:Subject:To; b=csEq+GAxVsT2BDCu5BT39kfThIt02OuyjvAXhzOecrS8GyK9Wl0X+llez1zVFWV5nyb Kt6chxiq7RJkAq6He7t0Tz9vLMlBVet9aCCxqIR0i/9PE+Ma4b2aAMbKd86T/1hI781tV obkU9yXYi22PLgMzzqF887+OhamZcOVmOg0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 Adds a PEIM that republishes structures produced in SEC. This is done because SEC modules may not be shadowed in some platforms due to space constraints or special alignment requirements. The SecMigrationPei module locates interfaces that may be published in SEC and reinstalls the interface with permanent memory addresses. This is important if pre-memory address access is forbidden after memory initialization and data such as a PPI descriptor, PPI GUID, or PPI inteface reside in pre-memory. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Debkumar De Cc: Harry Han Cc: Catharine West Signed-off-by: Michael Kubacki Acked-by: Laszlo Ersek --- UefiCpuPkg/UefiCpuPkg.dec | 3 + UefiCpuPkg/UefiCpuPkg.dsc | 1 + UefiCpuPkg/SecCore/SecCore.inf | 2 + .../SecMigrationPei/SecMigrationPei.inf | 67 +++ UefiCpuPkg/Include/Ppi/RepublishSecPpi.h | 54 +++ UefiCpuPkg/SecCore/SecMain.h | 1 + UefiCpuPkg/SecMigrationPei/SecMigrationPei.h | 154 +++++++ UefiCpuPkg/SecCore/SecMain.c | 26 +- UefiCpuPkg/SecMigrationPei/SecMigrationPei.c | 381 ++++++++++++++++++ .../SecMigrationPei/SecMigrationPei.uni | 13 + 10 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf create mode 100644 UefiCpuPkg/Include/Ppi/RepublishSecPpi.h create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.h create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.c create mode 100644 UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 762badf5d239..8b2e03d49d07 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -84,6 +84,9 @@ [Ppis] ## Include/Ppi/ShadowMicrocode.h gEdkiiPeiShadowMicrocodePpiGuid =3D { 0x430f6965, 0x9a69, 0x41c5, { 0x93= , 0xed, 0x8b, 0xf0, 0x64, 0x35, 0xc1, 0xc6 }} =20 + ## Include/Ppi/RepublishSecPpi.h + gRepublishSecPpiPpiGuid =3D { 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3= , 0x52, 0x1a, 0x2d, 0xc5, 0xd0, 0x92 }} + [PcdsFeatureFlag] ## Indicates if SMM Profile will be enabled. # If enabled, instruction executions in and data accesses to memory out= side of SMRAM will be logged. diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index afa304128221..964720048dd7 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -146,6 +146,7 @@ [Components.IA32, Components.X64] UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf UefiCpuPkg/SecCore/SecCore.inf + UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf { diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf index 0562820c95e0..545781d6b4b3 100644 --- a/UefiCpuPkg/SecCore/SecCore.inf +++ b/UefiCpuPkg/SecCore/SecCore.inf @@ -68,6 +68,8 @@ [Ppis] ## SOMETIMES_CONSUMES gPeiSecPerformancePpiGuid gEfiPeiCoreFvLocationPpiGuid + ## CONSUMES + gRepublishSecPpiPpiGuid =20 [Guids] ## SOMETIMES_PRODUCES ## HOB diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf b/UefiCpuPkg/Se= cMigrationPei/SecMigrationPei.inf new file mode 100644 index 000000000000..f4c2f6b658fb --- /dev/null +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf @@ -0,0 +1,67 @@ +## @file +# Migrates SEC structures after permanent memory is installed. +# +# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SecMigrationPei + MODULE_UNI_FILE =3D SecMigrationPei.uni + FILE_GUID =3D 58B35361-8922-41BC-B313-EF7ED9ADFDF7 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D SecMigrationPeiInitialize + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + SecMigrationPei.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + HobLib + MemoryAllocationLib + PeimEntryPoint + PeiServicesLib + PeiServicesTablePointerLib + +[Ppis] + ## PRODUCES + gRepublishSecPpiPpiGuid + + ## SOMETIMES_PRODUCES + gEfiTemporaryRamDonePpiGuid + + ## SOMETIME_PRODUCES + gEfiTemporaryRamSupportPpiGuid + + ## SOMETIMES_PRODUCES + gPeiSecPerformancePpiGuid + + ## SOMETIMES_CONSUMES + ## PRODUCES + gEfiSecPlatformInformationPpiGuid + + ## SOMETIMES_CONSUMES + ## SOMETIMES_PRODUCES + gEfiSecPlatformInformation2PpiGuid + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes = ## CONSUMES + +[Depex] + TRUE diff --git a/UefiCpuPkg/Include/Ppi/RepublishSecPpi.h b/UefiCpuPkg/Include/= Ppi/RepublishSecPpi.h new file mode 100644 index 000000000000..ea865acbb5c8 --- /dev/null +++ b/UefiCpuPkg/Include/Ppi/RepublishSecPpi.h @@ -0,0 +1,54 @@ +/** @file + This file declares Sec Platform Information PPI. + + This service is the primary handoff state into the PEI Foundation. + The Security (SEC) component creates the early, transitory memory + environment and also encapsulates knowledge of at least the + location of the Boot Firmware Volume (BFV). + + Copyright (c) 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Revision Reference: + This PPI is introduced in PI Version 1.0. + +**/ + +#ifndef __REPUBLISH_SEC_PPI_H__ +#define __REPUBLISH_SEC_PPI_H__ + +#include + +#define REPUBLISH_SEC_PPI_PPI_GUID \ + { \ + 0x27a71b1e, 0x73ee, 0x43d6, { 0xac, 0xe3, 0x52, 0x1a, 0x2d, 0xc5, 0xd0= , 0x92 } \ + } + +typedef struct _REPUBLISH_SEC_PPI_PPI REPUBLISH_SEC_PPI_PPI; + +/** + This interface re-installs PPIs installed in SecCore from a post-memory = PEIM. + + This is to allow a platform that may not support relocation of SecCore t= o update the PPI instance to a post-memory + copy from a PEIM that has been shadowed to permanent memory. + + @retval EFI_SUCCESS The SecCore PPIs were re-installed successfully. + @retval Others An error occurred re-installing the SecCore PPIs. + +**/ +typedef +EFI_STATUS +(EFIAPI *REPUBLISH_SEC_PPI_REPUBLISH_SEC_PPIS)( + VOID + ); + +/// +/// Republish SEC PPIs +/// +struct _REPUBLISH_SEC_PPI_PPI { + REPUBLISH_SEC_PPI_REPUBLISH_SEC_PPIS RepublishSecPpis; +}; + +extern EFI_GUID gRepublishSecPpiPpiGuid; + +#endif diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h index e8c05d713668..e20bcf86532c 100644 --- a/UefiCpuPkg/SecCore/SecMain.h +++ b/UefiCpuPkg/SecCore/SecMain.h @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include =20 diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.h b/UefiCpuPkg/SecM= igrationPei/SecMigrationPei.h new file mode 100644 index 000000000000..414672a5afe6 --- /dev/null +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.h @@ -0,0 +1,154 @@ +/** @file + Migrates SEC structures after permanent memory is installed. + + Copyright (c) 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __SEC_MIGRATION_H__ +#define __SEC_MIGRATION_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include + +/** + This interface conveys state information out of the Security (SEC) phase= into PEI. + + @param[in] PeiServices Pointer to the PEI Services Tab= le. + @param[in,out] StructureSize Pointer to the variable describ= ing size of the input buffer. + @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM= _INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformationPostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ); + +/** + Re-installs the SEC Platform Information PPIs to implementation in this = module to support post-memory. + + @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES= table published by the PEI Foundation. + @param[in] NotifyDescriptor Address of the notification descriptor data= structure. + @param[in] Ppi Address of the PPI that was installed. + + @retval EFI_SUCCESS The SEC Platform Information PPI could not = be re-installed. + @return Others An error occurred during PPI re-install. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformationPpiNotifyCallback ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ); + +/** + This interface re-installs PPIs installed in SecCore from a post-memory = PEIM. + + This is to allow a platform that may not support relocation of SecCore t= o update the PPI instance to a post-memory + copy from a PEIM that has been shadowed to permanent memory. + + @retval EFI_SUCCESS The SecCore PPIs were re-installed successfully. + @retval Others An error occurred re-installing the SecCore PPIs. + +**/ +EFI_STATUS +EFIAPI +RepublishSecPpis ( + VOID + ); + +/** + Disables the use of Temporary RAM. + + If present, this service is invoked by the PEI Foundation after + the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. + + @retval EFI_SUCCESS Use of Temporary RAM was disabled. + @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamDonePostMemory ( + VOID + ); + +/** + This service of the EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI that migrates temp= orary RAM into + permanent memory. + + @param PeiServices Pointer to the PEI Services Table. + @param TemporaryMemoryBase Source Address in temporary memory from wh= ich the SEC or PEIM will copy the + Temporary RAM contents. + @param PermanentMemoryBase Destination Address in permanent memory in= to which the SEC or PEIM will copy the + Temporary RAM contents. + @param CopySize Amount of memory to migrate from temporary= to permanent memory. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > Temporary= MemoryBase when + TemporaryMemoryBase > PermanentMemoryBase. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamSupportPostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, + IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, + IN UINTN CopySize + ); + +/** + This interface conveys performance information out of the Security (SEC)= phase into PEI. + + This service is published by the SEC phase. The SEC phase handoff has an= optional + EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed= from SEC into the + PEI Foundation. As such, if the platform supports collecting performance= data in SEC, + this information is encapsulated into the data structure abstracted by t= his service. + This information is collected for the boot-strap processor (BSP) on IA-3= 2. + + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] This The pointer to this instance of the PEI_SEC_PER= FORMANCE_PPI. + @param[out] Performance The pointer to performance data collected in SE= C phase. + + @retval EFI_SUCCESS The performance data was successfully returned. + +**/ +EFI_STATUS +EFIAPI +GetPerformancePostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN PEI_SEC_PERFORMANCE_PPI *This, + OUT FIRMWARE_SEC_PERFORMANCE *Performance + ); + +typedef struct { + UINT64 StructureSize; + EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord; +} SEC_PLATFORM_INFORMATION_CONTEXT; + +typedef struct { + EFI_HOB_GUID_TYPE Header; + UINT8 Revision; + UINT8 Reserved[3]; + FIRMWARE_SEC_PERFORMANCE FirmwareSecPerformance; + SEC_PLATFORM_INFORMATION_CONTEXT Context; +} SEC_PLATFORM_INFORMATION_CONTEXT_HOB; + +#endif diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c index 5d5e7f17dced..155be49a6011 100644 --- a/UefiCpuPkg/SecCore/SecMain.c +++ b/UefiCpuPkg/SecCore/SecMain.c @@ -370,13 +370,35 @@ SecTemporaryRamDone ( VOID ) { - BOOLEAN State; + EFI_STATUS Status; + EFI_STATUS Status2; + UINTN Index; + BOOLEAN State; + EFI_PEI_PPI_DESCRIPTOR *PeiPpiDescriptor; + REPUBLISH_SEC_PPI_PPI *RepublishSecPpiPpi; =20 // // Republish Sec Platform Information(2) PPI // RepublishSecPlatformInformationPpi (); =20 + // + // Re-install SEC PPIs using a PEIM produced service if published + // + for (Index =3D 0, Status =3D EFI_SUCCESS; Status =3D=3D EFI_SUCCESS; Ind= ex++) { + Status =3D PeiServicesLocatePpi ( + &gRepublishSecPpiPpiGuid, + Index, + &PeiPpiDescriptor, + (VOID **) &RepublishSecPpiPpi + ); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Calling RepublishSecPpi instance %d.\n", Index)= ); + Status2 =3D RepublishSecPpiPpi->RepublishSecPpis (); + ASSERT_EFI_ERROR (Status2); + } + } + // // Migrate DebugAgentContext. // @@ -385,7 +407,7 @@ SecTemporaryRamDone ( // // Disable interrupts and save current interrupt state // - State =3D SaveAndDisableInterrupts(); + State =3D SaveAndDisableInterrupts (); =20 // // Disable Temporary RAM after Stack and Heap have been migrated at this= point. diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.c b/UefiCpuPkg/SecM= igrationPei/SecMigrationPei.c new file mode 100644 index 000000000000..8fe5f78bae94 --- /dev/null +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.c @@ -0,0 +1,381 @@ +/** @file + Migrates SEC structures after permanent memory is installed. + + Copyright (c) 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "SecMigrationPei.h" + +STATIC REPUBLISH_SEC_PPI_PPI mEdkiiRepublishSecPpiPpi =3D { + RepublishSecPpis + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_SEC_PLATFORM_INFORMATION_PPI mSecPlatfo= rmInformationPostMemoryPpi =3D { + SecPlatf= ormInformationPostMemory + }; + + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_TEMPORARY_RAM_DONE_PPI mSecTemporary= RamDonePostMemoryPpi =3D { + SecTemporar= yRamDonePostMemory + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTempor= aryRamSupportPostMemoryPpi =3D { + SecTempo= raryRamSupportPostMemory + }; + +GLOBAL_REMOVE_IF_UNREFERENCED PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = =3D { + GetPerformancePost= Memory + }; + +STATIC EFI_PEI_PPI_DESCRIPTOR mEdkiiRepublishSecPpiDescriptor =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gRepublishSecPpiPpiGuid, + &mEdkiiRepublishSecPpiPpi + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mSecPlatformInformati= onPostMemoryDescriptor =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiSecPlatformInformationPpiGuid, + &mSecPlatformInformationPostMemoryPpi + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mSecTemporaryRamDoneP= ostMemoryDescriptor =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiTemporaryRamDonePpiGuid, + &mSecTemporaryRamDonePostMemoryPpi + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mSecTemporaryRamSuppo= rtPostMemoryDescriptor =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiTemporaryRamSupportPpiGuid, + &mSecTemporaryRamSupportPostMemoryPpi + }; + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_PPI_DESCRIPTOR mSecPerformancePpiDes= criptor =3D { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gPeiSecPerformancePpiGuid, + &mSecPerformancePpi + }; + +/** + Disables the use of Temporary RAM. + + If present, this service is invoked by the PEI Foundation after + the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed. + + @retval EFI_SUCCESS Use of Temporary RAM was disabled. + @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamDonePostMemory ( + VOID + ) +{ + // + // Temporary RAM Done is already done in post-memory + // install a stub function that is located in permanent memory + // + return EFI_SUCCESS; +} + +/** + This service of the EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI that migrates temp= orary RAM into + permanent memory. + + @param PeiServices Pointer to the PEI Services Table. + @param TemporaryMemoryBase Source Address in temporary memory from wh= ich the SEC or PEIM will copy the + Temporary RAM contents. + @param PermanentMemoryBase Destination Address in permanent memory in= to which the SEC or PEIM will copy the + Temporary RAM contents. + @param CopySize Amount of memory to migrate from temporary= to permanent memory. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > Temporary= MemoryBase when + TemporaryMemoryBase > PermanentMemoryBase. + +**/ +EFI_STATUS +EFIAPI +SecTemporaryRamSupportPostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, + IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, + IN UINTN CopySize + ) +{ + // + // Temporary RAM Support is already done in post-memory + // install a stub function that is located in permanent memory + // + return EFI_SUCCESS; +} + +/** + This interface conveys performance information out of the Security (SEC)= phase into PEI. + + This service is published by the SEC phase. The SEC phase handoff has an= optional + EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed= from SEC into the + PEI Foundation. As such, if the platform supports collecting performance= data in SEC, + this information is encapsulated into the data structure abstracted by t= his service. + This information is collected for the boot-strap processor (BSP) on IA-3= 2. + + @param[in] PeiServices The pointer to the PEI Services Table. + @param[in] This The pointer to this instance of the PEI_SEC_PER= FORMANCE_PPI. + @param[out] Performance The pointer to performance data collected in SE= C phase. + + @retval EFI_SUCCESS The performance data was successfully returned. + +**/ +EFI_STATUS +EFIAPI +GetPerformancePostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN PEI_SEC_PERFORMANCE_PPI *This, + OUT FIRMWARE_SEC_PERFORMANCE *Performance + ) +{ + SEC_PLATFORM_INFORMATION_CONTEXT_HOB *SecPlatformInformationContexHob; + + if (This =3D=3D NULL || Performance =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + SecPlatformInformationContexHob =3D GetFirstGuidHob (&gEfiCallerIdGuid); + if (SecPlatformInformationContexHob =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Performance->ResetEnd =3D SecPlatformInformationContexHob->FirmwareSecPe= rformance.ResetEnd; + + return EFI_SUCCESS; +} + +/** + This interface conveys state information out of the Security (SEC) phase= into PEI. + + @param[in] PeiServices Pointer to the PEI Services Tab= le. + @param[in,out] StructureSize Pointer to the variable describ= ing size of the input buffer. + @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM= _INFORMATION_RECORD. + + @retval EFI_SUCCESS The data was successfully returned. + @retval EFI_BUFFER_TOO_SMALL The buffer was too small. + +**/ +EFI_STATUS +EFIAPI +SecPlatformInformationPostMemory ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN OUT UINT64 *StructureSize, + OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord + ) +{ + SEC_PLATFORM_INFORMATION_CONTEXT_HOB *SecPlatformInformationContexHob; + + if (StructureSize =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + SecPlatformInformationContexHob =3D GetFirstGuidHob (&gEfiCallerIdGuid); + if (SecPlatformInformationContexHob =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + if (*StructureSize < SecPlatformInformationContexHob->Context.StructureS= ize) { + *StructureSize =3D SecPlatformInformationContexHob->Context.StructureS= ize; + return EFI_BUFFER_TOO_SMALL; + } + + if (PlatformInformationRecord =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + *StructureSize =3D SecPlatformInformationContexHob->Context.StructureSiz= e; + CopyMem ( + (VOID *) PlatformInformationRecord, + (VOID *) SecPlatformInformationContexHob->Context.PlatformInformationR= ecord, + (UINTN) SecPlatformInformationContexHob->Context.StructureSize + ); + + return EFI_SUCCESS; +} + +/** + This interface re-installs PPIs installed in SecCore from a post-memory = PEIM. + + This is to allow a platform that may not support relocation of SecCore t= o update the PPI instance to a post-memory + copy from a PEIM that has been shadowed to permanent memory. + + @retval EFI_SUCCESS The SecCore PPIs were re-installed successfully. + @retval Others An error occurred re-installing the SecCore PPIs. + +**/ +EFI_STATUS +EFIAPI +RepublishSecPpis ( + VOID + ) +{ + EFI_STATUS Status; + EFI_PEI_PPI_DESCRIPTOR *PeiPpiDescriptor; + VOID *PeiPpi; + SEC_PLATFORM_INFORMATION_CONTEXT_HOB *SecPlatformInformationContextHob; + EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformationPtr; + UINT64 SecStructureSize; + + SecPlatformInformationPtr =3D NULL; + SecStructureSize =3D 0; + + Status =3D PeiServicesLocatePpi ( + &gEfiTemporaryRamDonePpiGuid, + 0, + &PeiPpiDescriptor, + (VOID **) &PeiPpi + ); + if (!EFI_ERROR (Status)) { + Status =3D PeiServicesReInstallPpi ( + PeiPpiDescriptor, + &mSecTemporaryRamDonePostMemoryDescriptor + ); + ASSERT_EFI_ERROR (Status); + } + + Status =3D PeiServicesLocatePpi ( + &gEfiTemporaryRamSupportPpiGuid, + 0, + &PeiPpiDescriptor, + (VOID **) &PeiPpi + ); + if (!EFI_ERROR (Status)) { + Status =3D PeiServicesReInstallPpi ( + PeiPpiDescriptor, + &mSecTemporaryRamSupportPostMemoryDescriptor + ); + ASSERT_EFI_ERROR (Status); + } + + Status =3D PeiServicesCreateHob ( + EFI_HOB_TYPE_GUID_EXTENSION, + sizeof (SEC_PLATFORM_INFORMATION_CONTEXT_HOB), + (VOID **) &SecPlatformInformationContextHob + ); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "SecPlatformInformation Context HOB could not be = created.\n")); + return Status; + } + + SecPlatformInformationContextHob->Header.Name =3D gEfiCallerIdGuid; + SecPlatformInformationContextHob->Revision =3D 1; + + Status =3D PeiServicesLocatePpi ( + &gPeiSecPerformancePpiGuid, + 0, + &PeiPpiDescriptor, + (VOID **) &PeiPpi + ); + if (!EFI_ERROR (Status)) { + Status =3D ((PEI_SEC_PERFORMANCE_PPI *) PeiPpi)->GetPerformance ( + GetPeiServicesTablePo= inter (), + (PEI_SEC_PERFORMANCE_= PPI *) PeiPpi, + &SecPlatformInformati= onContextHob->FirmwareSecPerformance + ); + ASSERT_EFI_ERROR (Status); + if (!EFI_ERROR (Status)) { + Status =3D PeiServicesReInstallPpi ( + PeiPpiDescriptor, + &mSecPerformancePpiDescriptor + ); + ASSERT_EFI_ERROR (Status); + } + } + + Status =3D PeiServicesLocatePpi ( + &gEfiSecPlatformInformationPpiGuid, + 0, + &PeiPpiDescriptor, + (VOID **) &PeiPpi + ); + if (!EFI_ERROR (Status)) { + Status =3D ((EFI_SEC_PLATFORM_INFORMATION_PPI *) PeiPpi)->PlatformInfo= rmation ( + GetPeiServic= esTablePointer (), + &SecStructur= eSize, + SecPlatformI= nformationPtr + ); + ASSERT (Status =3D=3D EFI_BUFFER_TOO_SMALL); + if (Status !=3D EFI_BUFFER_TOO_SMALL) { + return EFI_NOT_FOUND; + } + + ZeroMem ((VOID *) &(SecPlatformInformationContextHob->Context), sizeof= (SEC_PLATFORM_INFORMATION_CONTEXT)); + SecPlatformInformationContextHob->Context.PlatformInformationRecord = =3D AllocatePool ((UINTN) SecStructureSize); + ASSERT (SecPlatformInformationContextHob->Context.PlatformInformationR= ecord !=3D NULL); + if (SecPlatformInformationContextHob->Context.PlatformInformationRecor= d =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + SecPlatformInformationContextHob->Context.StructureSize =3D SecStructu= reSize; + + Status =3D ((EFI_SEC_PLATFORM_INFORMATION_PPI *) PeiPpi)->PlatformInfo= rmation ( + GetPeiServic= esTablePointer (), + &(SecPlatfor= mInformationContextHob->Context.StructureSize), + SecPlatformI= nformationContextHob->Context.PlatformInformationRecord + ); + ASSERT_EFI_ERROR (Status); + if (!EFI_ERROR (Status)) { + Status =3D PeiServicesReInstallPpi ( + PeiPpiDescriptor, + &mSecPlatformInformationPostMemoryDescriptor + ); + ASSERT_EFI_ERROR (Status); + } + } + + return EFI_SUCCESS; +} + +/** + This function is the entry point which installs an instance of REPUBLISH= _SEC_PPI_PPI. + + It install the RepublishSecPpi depent on PcdMigrateTemporaryRamFirmwareV= olumes, install + the PPI when the PcdMigrateTemporaryRamFirmwareVolumes enabled. + + @param[in] FileHandle Pointer to image file handle. + @param[in] PeiServices Pointer to PEI Services Table + + @retval EFI_ABORTED Disable evacuate temporary memory feature by disable + PcdMigrateTemporaryRamFirmwareVolumes. + @retval EFI_SUCCESS An instance of REPUBLISH_SEC_PPI_PPI was installed = successfully. + @retval Others An error occurred installing and instance of REPUBL= ISH_SEC_PPI_PPI. + +**/ +EFI_STATUS +EFIAPI +SecMigrationPeiInitialize ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + + Status =3D EFI_ABORTED; + + if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { + Status =3D PeiServicesInstallPpi (&mEdkiiRepublishSecPpiDescriptor); + ASSERT_EFI_ERROR (Status); + } + + return Status; +} diff --git a/UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni b/UefiCpuPkg/Se= cMigrationPei/SecMigrationPei.uni new file mode 100644 index 000000000000..62c2064ba217 --- /dev/null +++ b/UefiCpuPkg/SecMigrationPei/SecMigrationPei.uni @@ -0,0 +1,13 @@ +// /** @file +// Migrates SEC structures after permanent memory is installed. +// +// Copyright (c) 2019, Intel Corporation. All rights reserved.
+// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Migrates SEC structures a= fter permanent memory is installed" + +#string STR_MODULE_DESCRIPTION #language en-US "Migrates SEC structures a= fter permanent memory is installed." + --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62828): https://edk2.groups.io/g/devel/message/62828 Mute This Topic: https://groups.io/mt/75679704/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62829+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62829+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244640; cv=none; d=zohomail.com; s=zohoarc; b=ltrBjW/3reN5SvTwolqLlZJD6SqAqnM2Vg1WwpfeTYGKWBXJ8vaMbrP1j/GFz0lBokjs8t6fWydS2HqkPStb/1Eeh8bNHh+/7X2yWkbRertm5nveDSy70UOD8m/F3Zwg14YIMdH3ZERUeI6hUqEo3fBowPYhqjTchjSD8K2xqXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244640; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=u0+nOjcwLvX9AU9kkqrsp5Sn/Bxa9A49obTdPJgaMTI=; b=mUOf6qZ3ouvpKXoVtio4yuyXHUkfCGATjHyJNMFp3j0j2Z9Z+qyiRU2gWfwlFmqPDHdTpPwThkAMJa0cnh2Beg2mVjpklfoOOworPyT9AoNfQHk0pCGcjBo2jeYUnd8JzArKUmQXQorGuQItgoKEO8CRTAcU9DmHzECgpvI7G00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62829+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244640940502.3991284681938; Mon, 20 Jul 2020 04:30:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EQVKYY1788612xlkFVZ4utaG; Mon, 20 Jul 2020 04:30:40 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:40 -0700 IronPort-SDR: qcWGCrye2BVmwJdfjXPq9x6EvbiznGVPEl62g9n7v7QEsik3iUqli+VVVHICvI2r+ImkPy14e+ jel2reauM4wA== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373188" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373188" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:39 -0700 IronPort-SDR: 7Y2l6qEJ/ipI2SG95HyE7B2WWFxlPBeQYM5ehK3IQks6pJ9GeKrG0o2NppqEfOm8mhqIYx8fD9 73cnLfHwgPiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411233" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:37 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Debkumar De , Harry Han , Catharine West , Laszlo Ersek Subject: [edk2-devel] [PATCH v6 05/10] MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:17 +0800 Message-Id: <20200720113022.675-6-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: TjjPcYrwOOw8m0qfpr4vdKuzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244640; bh=jJ8FEww8LRtq2t0pVh0UdF7ePUpMEC6PR/CmoZvc3Cg=; h=Cc:Date:From:Reply-To:Subject:To; b=EXsGKUyvFHRM0amDxvDCEhVMEXSqVjl8iiQ0F7wx6vvE9OrYMlK2qbf1vbideMuCOe8 M780mH4ZsewNM9ADE3SWe2enk+g7ScuurPLrEeEe1CzPNXV2Qy91i9sm87wxWWH0KNiIi ituCgfIUpq3LF+nNDS7tR57MRuhNkkOpUlg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 When we allocate pool to save the rebased PEIMs, the address will change randomly, therefore the hash will change and result PCR0 change as well. To avoid this, we save the raw PEIMs and use it to calculate hash. The MigratedFvInfo HOB will never produce when PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD control the total feature. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Debkumar De Cc: Harry Han Cc: Catharine West Signed-off-by: Guomin Jiang Acked-by: Laszlo Ersek Reviewed-by: Jian J Wang --- MdeModulePkg/MdeModulePkg.dec | 3 ++ MdeModulePkg/Core/Pei/PeiMain.inf | 1 + MdeModulePkg/Core/Pei/PeiMain.h | 1 + MdeModulePkg/Include/Guid/MigratedFvInfo.h | 22 +++++++++++++++ MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 28 +++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 MdeModulePkg/Include/Guid/MigratedFvInfo.h diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index e88f22756d7f..e0ad9373e62f 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -389,6 +389,9 @@ [Guids] ## GUID indicates the capsule is to store Capsule On Disk file names. gEdkiiCapsuleOnDiskNameGuid =3D { 0x98c80a4f, 0xe16b, 0x4d11, { 0x93, 0x= 9a, 0xab, 0xe5, 0x61, 0x26, 0x3, 0x30 } } =20 + ## Include/Guid/MigratedFvInfo.h + gEdkiiMigratedFvInfoGuid =3D { 0xc1ab12f7, 0x74aa, 0x408d, { 0xa2, 0xf4,= 0xc6, 0xce, 0xfd, 0x17, 0x98, 0x71 } } + [Ppis] ## Include/Ppi/AtaController.h gPeiAtaControllerPpiGuid =3D { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,= 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }} diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiM= ain.inf index 5b36d516b3fa..0cf357371a16 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -77,6 +77,7 @@ [Guids] ## CONSUMES ## GUID # Used to compare with FV's file system GUID = and get the FV's file system format gEfiFirmwareFileSystem3Guid gStatusCodeCallbackGuid + gEdkiiMigratedFvInfoGuid ## SOMETIMES_PRODUCES = ## HOB =20 [Ppis] gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # Pe= iReportStatusService is not ready if this PPI doesn't exist diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMai= n.h index 6d95a5d32c78..c27e8fc33bc6 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 /// /// It is an FFS type extension used for PeiFindFileEx. It indicates curre= nt diff --git a/MdeModulePkg/Include/Guid/MigratedFvInfo.h b/MdeModulePkg/Incl= ude/Guid/MigratedFvInfo.h new file mode 100644 index 000000000000..061c17ed0e48 --- /dev/null +++ b/MdeModulePkg/Include/Guid/MigratedFvInfo.h @@ -0,0 +1,22 @@ +/** @file + Migrated FV information + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ +#define __EDKII_MIGRATED_FV_INFO_GUID_H__ + +typedef struct { + UINT32 FvOrgBase; // original FV address + UINT32 FvNewBase; // new FV address + UINT32 FvDataBase; // original FV data + UINT32 FvLength; // Fv Length +} EDKII_MIGRATED_FV_INFO; + +extern EFI_GUID gEdkiiMigratedFvInfoGuid; + +#endif // #ifndef __EDKII_MIGRATED_FV_INFO_GUID_H__ + diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index 6cf32fdeeb14..210b5b22f727 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -1223,10 +1223,12 @@ EvacuateTempRam ( EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FIRMWARE_VOLUME_HEADER *ChildFvHeader; EFI_FIRMWARE_VOLUME_HEADER *MigratedFvHeader; + EFI_FIRMWARE_VOLUME_HEADER *RawDataFvHeader; EFI_FIRMWARE_VOLUME_HEADER *MigratedChildFvHeader; =20 PEI_CORE_FV_HANDLE PeiCoreFvHandle; EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi; + EDKII_MIGRATED_FV_INFO MigratedFvInfo; =20 ASSERT (Private->PeiMemoryInstalled); =20 @@ -1263,6 +1265,9 @@ EvacuateTempRam ( (((EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader + (FvHeader->FvLength - 1= )) < Private->FreePhysicalMemoryTop) ) ) { + // + // Allocate page to save the rebased PEIMs, the PEIMs will get dispa= tched later. + // Status =3D PeiServicesAllocatePages ( EfiBootServicesCode, EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength), @@ -1270,6 +1275,17 @@ EvacuateTempRam ( ); ASSERT_EFI_ERROR (Status); =20 + // + // Allocate pool to save the raw PEIMs, it used to keep consistent c= ontext across + // multiple boot and PCR0 will keep same no matter if the address of= allocated page is changed. + // + Status =3D PeiServicesAllocatePages ( + EfiBootServicesCode, + EFI_SIZE_TO_PAGES ((UINTN) FvHeader->FvLength), + (EFI_PHYSICAL_ADDRESS *) &RawDataFvHeader + ); + ASSERT_EFI_ERROR (Status); + DEBUG (( DEBUG_VERBOSE, " Migrating FV[%d] from 0x%08X to 0x%08X\n", @@ -1278,7 +1294,19 @@ EvacuateTempRam ( (UINTN) MigratedFvHeader )); =20 + // + // Copy the context to the rebased pages and raw pages, and create h= ob to save the + // information. The MigratedFvInfo HOB will never be produced when + // PcdMigrateTemporaryRamFirmwareVolumes is FALSE, because the PCD c= ontrol the + // feature. + // CopyMem (MigratedFvHeader, FvHeader, (UINTN) FvHeader->FvLength); + CopyMem (RawDataFvHeader, MigratedFvHeader, (UINTN) FvHeader->FvLeng= th); + MigratedFvInfo.FvOrgBase =3D (UINT32) (UINTN) FvHeader; + MigratedFvInfo.FvNewBase =3D (UINT32) (UINTN) MigratedFvHeader; + MigratedFvInfo.FvDataBase =3D (UINT32) (UINTN) RawDataFvHeader; + MigratedFvInfo.FvLength =3D (UINT32) (UINTN) FvHeader->FvLength; + BuildGuidDataHob (&gEdkiiMigratedFvInfoGuid, &MigratedFvInfo, sizeof= (MigratedFvInfo)); =20 // // Migrate any children for this FV now --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62829): https://edk2.groups.io/g/devel/message/62829 Mute This Topic: https://groups.io/mt/75679705/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62830+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62830+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244643; cv=none; d=zohomail.com; s=zohoarc; b=AwxhAVQUvxhHf/vKjCiA/JAgjunZd+Y+wB0rvNsqiW+1P+u6MyCA6LOllC8isNGHdULOgxqzvjN62DHU70mEDwwgWCe6K6P0hZNFnTsnMkn4JOt7RXrQ07gx36inl2N1KgIFxz97j9bPYcEVer2wIJLa5qBan6jYQwMWo16P3ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244643; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=s28tC7+wL2/ti5aalWAx1RxtBCjlswWibC10AMq0l48=; b=Fy4gcUHa/H72SPifaaj3fEcmYIcsXLcv2eGvufyJH1Plr9U/H/qc65TPVOM8E9ccPs7M4ImWpWlvJp7Cx1AnSuW4+Kns+KiblGZj1+OaaKXtAxZDei4M+xCUSjhupDDBBXCL+ib87+AdObBYTAJBO5ccOijqRcVAcieWQRyuGwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62830+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244643008752.3898734899102; Mon, 20 Jul 2020 04:30:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 97eDYY1788612x8QcInW9fmn; Mon, 20 Jul 2020 04:30:42 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:42 -0700 IronPort-SDR: HuXzsRmuZsjvW87pcE2B0yjPNXnhmnNY9u+Ho4h9/wVW+xfhxjV4wl1+XYeES0P3kL1XVku06b lQZ3j5yZEi8Q== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373196" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373196" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:41 -0700 IronPort-SDR: tCEiPRPFqctsDETNVkWwNyjhZO+r/PfE871Xs+IGSlvmuth6GZbcPtmd4vuYOvh5F5NIg6lr7V xyuls5Y5cysw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411254" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:39 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v6 06/10] SecurityPkg/Tcg2Pei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:18 +0800 Message-Id: <20200720113022.675-7-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: 4oAp6Vx8h6MbGfJTdcyPTqJwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244642; bh=KqNNQIKc0qMABOv5dB5kt9I52ODPUm80RdVLTThpy/o=; h=Cc:Date:From:Reply-To:Subject:To; b=jMzCKKFOiJo2jVDpIYEX2xUiPRXuMREQAudFYnycN+6mLjZJD/gt43MFivuTY6uJJNF Qa7RW5rkrMeTp9fPk0pSfY90t8TdwyBnP4zAzH4MpmdKDJo/Dlcam8L936Rhvk7rEW/lw vwbB3oiMh9nJaEjtmFqe0mFF6GphN/ZEFVg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 When we allocate pool to save rebased the PEIMs, the address will change randomly, therefore the hash will change and result PCR0 change as well. To avoid this, we save the raw PEIMs and use it to calculate hash. The Tcg2Pei calculate the hash and it use the Migrated FV Info. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Guomin Jiang Reviewed-by: Jian J Wang Reviewed-by: Zhang, Qi1 --- SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 1 + SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 31 ++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf b/SecurityPkg/Tcg/Tcg2Pei/= Tcg2Pei.inf index 3d361e8859e7..367df21eedaf 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf @@ -63,6 +63,7 @@ [Guids] gTcgEvent2EntryHobGuid ## = PRODUCES ## HOB gEfiTpmDeviceInstanceNoneGuid ## = SOMETIMES_PRODUCES ## GUID # TPM device identifier gEfiTpmDeviceInstanceTpm12Guid ## = SOMETIMES_PRODUCES ## GUID # TPM device identifier + gEdkiiMigratedFvInfoGuid ## = SOMETIMES_CONSUMES ## HOB =20 [Ppis] gEfiPeiFirmwareVolumeInfoPpiGuid ## = SOMETIMES_CONSUMES ## NOTIFY diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tc= g2Pei.c index 19b8e4b318c5..18569f89b430 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c @@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -536,6 +537,10 @@ MeasureFvImage ( EDKII_PEI_FIRMWARE_VOLUME_INFO_PREHASHED_FV_PPI *PrehashedFvPpi; HASH_INFO *PreHashInfo; UINT32 HashAlgoMask; + EFI_PHYSICAL_ADDRESS FvOrgBase; + EFI_PHYSICAL_ADDRESS FvDataBase; + EFI_PEI_HOB_POINTERS Hob; + EDKII_MIGRATED_FV_INFO *MigratedFvInfo; =20 // // Check Excluded FV list @@ -621,6 +626,26 @@ MeasureFvImage ( Instance++; } while (!EFI_ERROR(Status)); =20 + // + // Search the matched migration FV info + // + FvOrgBase =3D FvBase; + FvDataBase =3D FvBase; + Hob.Raw =3D GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid); + while (Hob.Raw !=3D NULL) { + MigratedFvInfo =3D GET_GUID_HOB_DATA (Hob); + if ((MigratedFvInfo->FvNewBase =3D=3D (UINT32) FvBase) && (MigratedFvI= nfo->FvLength =3D=3D (UINT32) FvLength)) { + // + // Found the migrated FV info + // + FvOrgBase =3D (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgB= ase; + FvDataBase =3D (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvData= Base; + break; + } + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw); + } + // // Init the log event for FV measurement // @@ -631,14 +656,14 @@ MeasureFvImage ( if (FvName !=3D NULL) { AsciiSPrint ((CHAR8 *)FvBlob2.BlobDescription, sizeof(FvBlob2.BlobDe= scription), "Fv(%g)", FvName); } - FvBlob2.BlobBase =3D FvBase; + FvBlob2.BlobBase =3D FvOrgBase; FvBlob2.BlobLength =3D FvLength; TcgEventHdr.PCRIndex =3D 0; TcgEventHdr.EventType =3D EV_EFI_PLATFORM_FIRMWARE_BLOB2; TcgEventHdr.EventSize =3D sizeof (FvBlob2); EventData =3D &FvBlob2; } else { - FvBlob.BlobBase =3D FvBase; + FvBlob.BlobBase =3D FvOrgBase; FvBlob.BlobLength =3D FvLength; TcgEventHdr.PCRIndex =3D 0; TcgEventHdr.EventType =3D EV_EFI_PLATFORM_FIRMWARE_BLOB; @@ -673,7 +698,7 @@ MeasureFvImage ( // Status =3D HashLogExtendEvent ( 0, - (UINT8*) (UINTN) FvBase, // HashData + (UINT8*) (UINTN) FvDataBase, // HashData (UINTN) FvLength, // HashDataLen &TcgEventHdr, // EventHdr EventData // EventData --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62830): https://edk2.groups.io/g/devel/message/62830 Mute This Topic: https://groups.io/mt/75679706/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62831+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62831+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244644; cv=none; d=zohomail.com; s=zohoarc; b=YAv9b0LcgQSOxmvcBEAKsPX6n9WnnfHd8DGf4uoKVL7jzD4bAbluCdleJ6uiC40O0JFPDv+x+rwE31FdfsuslGJ9ZzyY8BkIzpxbDC76OoceM/q7MJygI6PJ7GKnrqPHy5+uk2Hj9Au0Mev/AkSVFkqdyZqEaKwWS8hqBnP7UWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244644; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cE9oYcIP2Y3tPBWJ0V+Q8a6993H5GgAEcbRZYiqxn0w=; b=jLXjNXANmDXbdvOf5pDrovnCVpwIKzq1m8xyVcS+7qE/IMVlS8KHZTKB+31Rpdpwv0nCWpJjsierGlOsNFF1YkQCz8svoP+DPfqCA1IzgoC20QrBrILrv5X5sfSUnjF1jf8AtN5B8DEQFM46+HKZEQkfPMOWGy+h7Wbc3LJ8dNU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62831+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 159524464449649.2760610474171; Mon, 20 Jul 2020 04:30:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WJFTYY1788612xuhkRStORk1; Mon, 20 Jul 2020 04:30:44 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:43 -0700 IronPort-SDR: lnOekYMqDolMxE9UBlCnMnpq3ru8Tht0k/TEJCGkO6L7bF1MiJ/DIcxbZLJQcO/xkkksbLKduy EMSmW9nMTfeg== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373201" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373201" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:43 -0700 IronPort-SDR: Hs7ABX3jlEuTowJwY7p9KjVht7WvPAmw36DR3INbREpNfNyf5uhLIAiKDQALECSvkov9jK5U+v zeBo7Fqx70Mw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411267" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:41 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v6 07/10] UefiCpuPkg/CpuMpPei: Enable paging and set NP flag to avoid TOCTOU (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:19 +0800 Message-Id: <20200720113022.675-8-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: sYSnhskpMmw4y2K6ejvtTw44x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244644; bh=P1s70SY+sPB+BhT6c3r+d3NHEOEd8luCGoWqp0M1GX0=; h=Cc:Date:From:Reply-To:Subject:To; b=W7htwj+Q2isTCnfDYJRZq6wbc8dVTRDYnWtuKLZI46aeRe91riYo3VikONnsvzmFMM0 ciggTs2bMSJ89xr+l9bnZBm6+bDhkSQV7v1jU/dv7q8peEj13+2ksIvCa0USR8RtHRknY pgomutdfGKD+l7sMaX9+sO0r2Fbn9fM/iY0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 To avoid the TOCTOU, enable paging and set Not Present flag so when access any code in the flash range, it will trigger #PF exception. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Guomin Jiang Acked-by: Laszlo Ersek Reviewed-by: Jian J Wang --- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 +++ UefiCpuPkg/CpuMpPei/CpuPaging.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPe= i.inf index f4d11b861f77..7e511325d8b8 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -46,6 +46,9 @@ [LibraryClasses] BaseMemoryLib CpuLib =20 +[Guids] + gEdkiiMigratedFvInfoGuid ## = SOMETIMES_CONSUMES ## HOB + [Ppis] gEfiPeiMpServicesPpiGuid ## PRODUCES gEfiSecPlatformInformationPpiGuid ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPagin= g.c index 3bf0574b34c6..8ab7dfcce3a0 100644 --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c @@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include "CpuMpPei.h" =20 @@ -602,9 +603,11 @@ MemoryDiscoveredPpiNotifyCallback ( IN VOID *Ppi ) { - EFI_STATUS Status; - BOOLEAN InitStackGuard; - BOOLEAN InterruptState; + EFI_STATUS Status; + BOOLEAN InitStackGuard; + BOOLEAN InterruptState; + EDKII_MIGRATED_FV_INFO *MigratedFvInfo; + EFI_PEI_HOB_POINTERS Hob; =20 if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { InterruptState =3D SaveAndDisableInterrupts (); @@ -619,9 +622,14 @@ MemoryDiscoveredPpiNotifyCallback ( // the task switch (for the sake of stack switch). // InitStackGuard =3D FALSE; - if (IsIa32PaeSupported () && PcdGetBool (PcdCpuStackGuard)) { + Hob.Raw =3D NULL; + if (IsIa32PaeSupported ()) { + Hob.Raw =3D GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid); + InitStackGuard =3D PcdGetBool (PcdCpuStackGuard); + } + + if (InitStackGuard || Hob.Raw !=3D NULL) { EnablePaging (); - InitStackGuard =3D TRUE; } =20 Status =3D InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices= ); @@ -631,6 +639,20 @@ MemoryDiscoveredPpiNotifyCallback ( SetupStackGuardPage (); } =20 + while (Hob.Raw !=3D NULL) { + MigratedFvInfo =3D GET_GUID_HOB_DATA (Hob); + + // + // Enable #PF exception, so if the code access SPI after disable NEM, = it will generate + // the exception to avoid potential vulnerability. + // + ConvertMemoryPageAttributes (MigratedFvInfo->FvOrgBase, MigratedFvInfo= ->FvLength, 0); + + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw); + } + CpuFlushTlb (); + return Status; } =20 --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62831): https://edk2.groups.io/g/devel/message/62831 Mute This Topic: https://groups.io/mt/75679707/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62832+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62832+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244646; cv=none; d=zohomail.com; s=zohoarc; b=XDZ8UTXKVQy6JfoCjaRUwN4ZKoyXRyVzTOYcy2fDV6Le9/5a5KxkYoVy81G4lHy3HFRI2+Q4PI0suPzX0NerVnS07xc7O+GjheZR0A/FqwVI5ViHA0Z9ItDupmjXXLksPJT4XsvZUQ4Qfw1tXqARYZcR01oxVQcfpECvFGDJPFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244646; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=D4ck5Fx3n6IsxXGjB7w0VguAN2+JVQvQM9tvcF9mHEI=; b=T50nXqc/Smdl/Mi4LHTl2jhfFfi461KHXxvU8qHJsLQdrtBLyF5a0vjwqaX9oC5/EyHiZkxHUpWU+nX986IZzQy9QYvwu70p9tv8XxW8+82LaRYIaU8kXWQ3gVV9h3DBDQH3uaMCH2pUqLkVYYF+7jaJbq+/NZaTuiQmscvp8Gc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62832+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244646509879.1511202932662; Mon, 20 Jul 2020 04:30:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RiEHYY1788612xgg0oij8mu2; Mon, 20 Jul 2020 04:30:46 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:45 -0700 IronPort-SDR: zQlleJYkCkeQ3hRWZlZ2N4T+pRGTUdyj6bT0cGVBXwOqm1zCWG+thSLIbS47GQS1KXz1cckXOm JdL6YV6qJEfg== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373212" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373212" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:45 -0700 IronPort-SDR: Z+VsCJAPqyBv1MPe3jUvU+JBbuhtQbT4IPxcUkEIGPPQBgF5qKNplPUGALP+49yqfGjYLqLKsH GsT/WOgmlEtA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411284" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:43 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v6 08/10] UefiCpuPkg: Correct some typos. Date: Mon, 20 Jul 2020 19:30:20 +0800 Message-Id: <20200720113022.675-9-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: f3oG3RafdHcNHAJZRzHRGbO3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244646; bh=Pwu58UDJDA7ikKG3RVVCKCSFmdAf+4rHnt0hKXWH1gY=; h=Cc:Date:From:Reply-To:Subject:To; b=CfmGcuEonrgxjCRI4SFFGTwbfnLqcchA60snJYu4zj2jgE9XmrRXf3lxKj0S94h6/zs oLh6lvb5KOn1wqpbDZUbZTOW8vy9+YO1dYi+uKgRtzA5t0aCBHlhsb8emoVx1natmas/b X6QoUMM3Y5t5sg9fm53G/E/UUF/c4GHKLqY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Correct some typos. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Guomin Jiang Reviewed-by: Laszlo Ersek --- UefiCpuPkg/CpuMpPei/CpuMpPei.h | 2 +- .../Library/CpuExceptionHandlerLib/CpuExceptionCommon.h | 4 ++-- UefiCpuPkg/CpuMpPei/CpuPaging.c | 4 ++-- .../CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c | 4 ++-- .../Library/CpuExceptionHandlerLib/SecPeiCpuException.c | 2 +- .../Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index 309478cbe14c..6a481a84dcc7 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -424,7 +424,7 @@ InitializeCpuMpWorker ( ); =20 /** - Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to= TRUE. + Enable/setup stack guard for each processor if PcdCpuStackGuard is set t= o TRUE. =20 Doing this in the memory-discovered callback is to make sure the Stack G= uard feature to cover as most PEI code as possible. diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h index 805dd9cbb4ff..0544d6dba631 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/CpuExceptionCommon.h @@ -90,8 +90,8 @@ AsmGetTemplateAddressMap ( **/ VOID ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler + OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler ); =20 /** diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPagin= g.c index 8ab7dfcce3a0..50ad4277af79 100644 --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c @@ -153,7 +153,7 @@ GetPhysicalAddressWidth ( Get the type of top level page table. =20 @retval Page512G PML4 paging. - @retval Page1G PAE paing. + @retval Page1G PAE paging. =20 **/ PAGE_ATTRIBUTE @@ -583,7 +583,7 @@ SetupStackGuardPage ( } =20 /** - Enabl/setup stack guard for each processor if PcdCpuStackGuard is set to= TRUE. + Enable/setup stack guard for each processor if PcdCpuStackGuard is set t= o TRUE. =20 Doing this in the memory-discovered callback is to make sure the Stack G= uard feature to cover as most PEI code as possible. diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHa= ndler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandl= er.c index 1aafb7dac139..903449e0daa9 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ArchExceptionHandler.c @@ -18,8 +18,8 @@ **/ VOID ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler + OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler ) { IdtEntry->Bits.OffsetLow =3D (UINT16)(UINTN)InterruptHandler; diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c index 20148db74cf8..d4ae153c5742 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -87,7 +87,7 @@ InitializeCpuExceptionHandlers ( IdtEntryCount =3D (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESC= RIPTOR); if (IdtEntryCount > CPU_EXCEPTION_NUM) { // - // CPU exeption library only setup CPU_EXCEPTION_NUM exception handler= at most + // CPU exception library only setup CPU_EXCEPTION_NUM exception handle= r at most // IdtEntryCount =3D CPU_EXCEPTION_NUM; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHan= dler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler= .c index 894c1cfb7533..d3da16e4dfa2 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -17,8 +17,8 @@ **/ VOID ArchUpdateIdtEntry ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler + OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler ) { IdtEntry->Bits.OffsetLow =3D (UINT16)(UINTN)InterruptHandler; --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62832): https://edk2.groups.io/g/devel/message/62832 Mute This Topic: https://groups.io/mt/75679708/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62833+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62833+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244648; cv=none; d=zohomail.com; s=zohoarc; b=Y9jjB5weccWcztDZnTmZoed8pl/idTwRh+UWjF3E9v4ysfgtSYM9Ec438JTUnqTZEvNDL5QiYxfFE8FW5OUfYfRxWzFa9UKlR3GZLtuQr0DGRx/x0dHfl5BCt3eDzKMr0VXmZ5yfweCpq7tFniz5fmBwXTd/335lMcKEkgmJM0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244648; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tTyO5XuCBEL8Gt3QAUPiYKZ+oCIQF+wXev0d5gsvQnY=; b=Pe1gAqDNMlp7xaGD5JIursJWFQ4fcYFNhWPeRHEAFzpMZYzK1HEhPmun+5SCMmzGKogvwfR7F0h/J7BGOpSX0ZMCO5G8fy055/5gTq0xN3iKl1BXQzIwFoKLzLByxwBMbkonmF82cNQILz/VpjZroccbFAVo/GHyCnaNPhxwBm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62833+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244648635582.2999633155914; Mon, 20 Jul 2020 04:30:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id i0fiYY1788612xUSPWsWnS2v; Mon, 20 Jul 2020 04:30:48 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:47 -0700 IronPort-SDR: U55i4HIHLlWJz9imWS6T7onRve0J6GK+wCxs8MIRqjtukHXbKOvxd80V2hIIAy77qSNNoiBvH2 NjQvR/YeYgCw== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373225" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373225" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:47 -0700 IronPort-SDR: WdWQNTbjrnk4Esdw53muGkeAoGrWY2SPN6YZL6mNQwBTqNSs+TZ6Bvbsq8Bejfihifh/AHn7SP D+N7E+ue17Fg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411304" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:45 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v6 09/10] SecurityPkg/TcgPei: Use Migrated FV Info Hob for calculating hash (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:21 +0800 Message-Id: <20200720113022.675-10-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: rbze0fjJZUzqd42unbqM7Q26x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244648; bh=+gyIQcvpyvU/luUm0A3yKD32E/03JoQERZBVdYmdYVA=; h=Cc:Date:From:Reply-To:Subject:To; b=WPlJxcxpjO90a7J1HQrOuDuMemOknqdnvbRrcNB7MlanygCpcXBJ//IBUKbrPXpcuKp Qo6rdtPYTBgM1lqXMSL35Q884nrZIRx589J6t5Eoo5nFQggv0e8/xBRqnm3hrMf+yunDB WOYiv5NhzfbA/2qsdmiDkuAB8t1g7aLdHqg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 When we allocate pool to save rebased the PEIMs, the address will change randomly, therefore the hash will change and result PCR0 change as well. To avoid this, we save the raw PEIMs and use it to calculate hash. The TcgPei calculate the hash and it use the Migrated FV Info. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Guomin Jiang Reviewed-by: Jian J Wang Reviewed-by: Zhang, Qi1 --- SecurityPkg/Tcg/TcgPei/TcgPei.inf | 1 + SecurityPkg/Tcg/TcgPei/TcgPei.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/Tcg= Pei.inf index c0bff6e85e9d..6d1951f8ed65 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf @@ -58,6 +58,7 @@ [Guids] gTpmErrorHobGuid ## S= OMETIMES_PRODUCES ## HOB gMeasuredFvHobGuid ## P= RODUCES ## HOB gEfiTpmDeviceInstanceTpm12Guid ## P= RODUCES ## GUID # TPM device identifier + gEdkiiMigratedFvInfoGuid ## S= OMETIMES_CONSUMES ## HOB =20 [Ppis] gPeiLockPhysicalPresencePpiGuid ## S= OMETIMES_CONSUMES ## NOTIFY diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPe= i.c index a9a808c9ecf3..9701bfe8715b 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c @@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -378,6 +379,10 @@ MeasureFvImage ( EFI_STATUS Status; EFI_PLATFORM_FIRMWARE_BLOB FvBlob; TCG_PCR_EVENT_HDR TcgEventHdr; + EFI_PHYSICAL_ADDRESS FvOrgBase; + EFI_PHYSICAL_ADDRESS FvDataBase; + EFI_PEI_HOB_POINTERS Hob; + EDKII_MIGRATED_FV_INFO *MigratedFvInfo; =20 // // Check if it is in Excluded FV list @@ -401,10 +406,30 @@ MeasureFvImage ( } } =20 + // + // Search the matched migration FV info + // + FvOrgBase =3D FvBase; + FvDataBase =3D FvBase; + Hob.Raw =3D GetFirstGuidHob (&gEdkiiMigratedFvInfoGuid); + while (Hob.Raw !=3D NULL) { + MigratedFvInfo =3D GET_GUID_HOB_DATA (Hob); + if ((MigratedFvInfo->FvNewBase =3D=3D (UINT32) FvBase) && (MigratedFvI= nfo->FvLength =3D=3D (UINT32) FvLength)) { + // + // Found the migrated FV info + // + FvOrgBase =3D (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvOrgB= ase; + FvDataBase =3D (EFI_PHYSICAL_ADDRESS) (UINTN) MigratedFvInfo->FvData= Base; + break; + } + Hob.Raw =3D GET_NEXT_HOB (Hob); + Hob.Raw =3D GetNextGuidHob (&gEdkiiMigratedFvInfoGuid, Hob.Raw); + } + // // Measure and record the FV to the TPM // - FvBlob.BlobBase =3D FvBase; + FvBlob.BlobBase =3D FvOrgBase; FvBlob.BlobLength =3D FvLength; =20 DEBUG ((DEBUG_INFO, "The FV which is measured by TcgPei starts at: 0x%x\= n", FvBlob.BlobBase)); @@ -416,7 +441,7 @@ MeasureFvImage ( =20 Status =3D HashLogExtendEvent ( (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(), - (UINT8*) (UINTN) FvBlob.BlobBase, + (UINT8*) (UINTN) FvDataBase, (UINTN) FvBlob.BlobLength, &TcgEventHdr, (UINT8*) &FvBlob --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62833): https://edk2.groups.io/g/devel/message/62833 Mute This Topic: https://groups.io/mt/75679710/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 4 17:02:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62834+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62834+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595244651; cv=none; d=zohomail.com; s=zohoarc; b=IL9+r9YwBbqUZ6yZe0p9oH7SbyGlkIwnYpcFfGUqTbTJeYlhT+28qLNN244fIoliruVUckuuvG2lDksbKJ3gt/P6wscBrepGErirFD3+Otwxv5jVOseChxc8IHrMtYQisEWIOIlWb0ybW4mVKQk70zgjr4mkSnBntct6G6or3Kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595244651; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=me2zvWxziKYirriHfUjC/tQ71P3tDZNgmxYxa5eXx+s=; b=MSaU9Z27/x0UVvRWd0f8UyGlYUMuV0waHz215nlSEpCTwl91JDsZ88ay/Xm3ax9q+WlYgLkxU+H1pJTqQsp8OiRHLUB0R3ej6RGg2mE0L/Tc9B8wDXHQHpAawulRDkMdLeb+QWotguSsbiddBXenlW5RWLT0e7aVuW1yuDiP40Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62834+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595244651801199.604423905747; Mon, 20 Jul 2020 04:30:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qk0UYY1788612xJuC6K4tzUd; Mon, 20 Jul 2020 04:30:51 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.35600.1595244629521419095 for ; Mon, 20 Jul 2020 04:30:51 -0700 IronPort-SDR: IigbWWavEelamxY02kQCzuyAAuEfvhBF1PMT7FxF5nLbYhBOgdFHf3VH9Aufldq/rSRhHFishK bQSd+fTHtm5g== X-IronPort-AV: E=McAfee;i="6000,8403,9687"; a="137373239" X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="137373239" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 04:30:50 -0700 IronPort-SDR: qWwJO7eMMbVpSDegjb7nBduPm3MfKiYeWKM+tABplStRHLrtNc2hJKAeJVxgARb+Y0qeLSTKrW avOgHI//p5TQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,374,1589266800"; d="scan'208";a="271411329" X-Received: from guominji-mobl.ccr.corp.intel.com ([10.238.13.140]) by fmsmga008.fm.intel.com with ESMTP; 20 Jul 2020 04:30:47 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Debkumar De , Harry Han , Catharine West Subject: [edk2-devel] [PATCH v6 10/10] MdeModulePkg/Core: Avoid redundant shadow when enable the Migrated PCD (CVE-2019-11098) Date: Mon, 20 Jul 2020 19:30:22 +0800 Message-Id: <20200720113022.675-11-guomin.jiang@intel.com> In-Reply-To: <20200720113022.675-1-guomin.jiang@intel.com> References: <20200720113022.675-1-guomin.jiang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,guomin.jiang@intel.com X-Gm-Message-State: csSyu1d17AoqjmPvRDr85sXUx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595244651; bh=DNYpPL9ksj/cl4Jssb5uxNGrcnIyodj08Sz1R6vf4wU=; h=Cc:Date:From:Reply-To:Subject:To; b=jnQV9jqGa6uJtlzfVPM6MlmOQn9gRlqESoTUFRf2uaDW7j9NzH0g6QXCVaoSTaDm/wi hN4wfnPmr1yaktnWZofeFd/GqXUHFqmchnr91lhN3izHmEU6ojkq9slL8pHkPczMofiFM fUDXQk7bxVSu3O5DSEikXQuV0VyC/OSqSAc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1614 When PcdMigrateTemporaryRamFirmwareVolumes is TRUE, it will shadow the PEIMs, when it is disabled, PEIMs marked REGISTER_FOR_SHADOW will be shadowed as well and it is controled by PcdShadowPeimOnBoot and PcdShadowPeimOnS3Boot. To cover the shadow behavior, the change will always shadow PEIMs when enable PcdMigrateTemporaryRamFirmwareVolumes. When PcdMigrateTemporaryRamFirmwareVolumes is true, if enable PcdShadowPeiOnBoot, it will shadow some PEIMs twice and occupy more memory and waste more boot time. it is unnecessary, so the only valid choice is to enable PcdMigrateTemporaryRamFirmwareVolumes and disable PcdShadowPeimOnBoot. Signed-off-by: Guomin Jiang Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Debkumar De Cc: Harry Han Cc: Catharine West --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 11 +++++++++-- MdeModulePkg/Core/Pei/Image/Image.c | 14 ++++++++++---- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 18 +++++++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/C= ore/Pei/Dispatcher/Dispatcher.c index 210b5b22f727..74cd5387c158 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -1408,7 +1408,11 @@ PeiDispatcher ( PeimFileHandle =3D NULL; EntryPoint =3D 0; =20 - if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformatio= nTable->BootMode !=3D BOOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boo= t))) { + if ((Private->PeiMemoryInstalled) && + (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) + || (Private->HobList.HandoffInformationTable->BootMode !=3D BOOT_ON= _S3_RESUME) + || PcdGetBool (PcdShadowPeimOnS3Boot)) + ) { // // Once real memory is available, shadow the RegisterForShadow modules= . And meanwhile // update the modules' status from PEIM_STATE_REGISTER_FOR_SHADOW to P= EIM_STATE_DONE. @@ -1607,7 +1611,10 @@ PeiDispatcher ( PeiCheckAndSwitchStack (SecCoreData, Private); =20 if ((Private->PeiMemoryInstalled) && (Private->Fv[FvCount].Pei= mState[PeimCount] =3D=3D PEIM_STATE_REGISTER_FOR_SHADOW) && \ - (Private->HobList.HandoffInformationTable->BootMode !=3D B= OOT_ON_S3_RESUME || PcdGetBool (PcdShadowPeimOnS3Boot))) { + (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) + || (Private->HobList.HandoffInformationTable->BootMode != =3D BOOT_ON_S3_RESUME) + || PcdGetBool (PcdShadowPeimOnS3Boot)) + ) { // // If memory is available we shadow images by default for pe= rformance reasons. // We call the entry point a 2nd time so the module knows it= 's shadowed. diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/Image.c index 0caeb63e26b4..85d1a84e4b67 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -328,8 +328,11 @@ LoadAndRelocatePeCoffImage ( // // When Image has no reloc section, it can't be relocated into memory. // - if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) &&= ((!IsPeiModule) || - (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShad= ow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) { + if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) + && ((!IsPeiModule) || PcdGetBool (PcdMigrateTemporaryRamFirmwareVolu= mes) + || (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegister= ForShadow)) + || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot))) + ) { DEBUG ((EFI_D_INFO|EFI_D_LOAD, "The image at 0x%08x without reloc sect= ion can't be loaded into memory\n", (UINTN) Pe32Data)); } =20 @@ -343,8 +346,11 @@ LoadAndRelocatePeCoffImage ( // On normal boot, PcdShadowPeimOnBoot decides whether load PEIM or PeiC= ore into memory. // On S3 boot, PcdShadowPeimOnS3Boot decides whether load PEIM or PeiCor= e into memory. // - if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled)= && ((!IsPeiModule) || - (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShad= ow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) { + if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) + && ((!IsPeiModule) || PcdGetBool (PcdMigrateTemporaryRamFirmwareVolu= mes) + || (!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegister= ForShadow)) + || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot))) + ) { // // Allocate more buffer to avoid buffer overflow. // diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pe= i/PeiMain/PeiMain.c index 48605eeada86..ce8649f954a8 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -322,7 +322,8 @@ PeiCore ( // PEI Core and PEIMs to get high performance. // OldCoreData->ShadowedPeiCore =3D (PEICORE_FUNCTION_POINTER) (UINTN) = PeiCore; - if ((HandoffInformationTable->BootMode =3D=3D BOOT_ON_S3_RESUME && P= cdGetBool (PcdShadowPeimOnS3Boot)) + if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) + || (HandoffInformationTable->BootMode =3D=3D BOOT_ON_S3_RESUME &= & PcdGetBool (PcdShadowPeimOnS3Boot)) || (HandoffInformationTable->BootMode !=3D BOOT_ON_S3_RESUME && = PcdGetBool (PcdShadowPeimOnBoot))) { OldCoreData->ShadowedPeiCore =3D ShadowPeiCore (OldCoreData); } @@ -422,10 +423,17 @@ PeiCore ( } } else { if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) { - if (PrivateData.HobList.HandoffInformationTable->BootMode =3D=3D BOO= T_ON_S3_RESUME) { - TempRamEvacuation =3D PcdGetBool (PcdShadowPeimOnS3Boot); - } else { - TempRamEvacuation =3D PcdGetBool (PcdShadowPeimOnBoot); + TempRamEvacuation =3D TRUE; + + // + // When PcdMigrateTemporaryRamFirmwareVolumes is TRUE, it make sense= only + // when PcdShadowPeimOnBoot is FALSE. in this situation, all PEIMs w= ill be copied + // and shadowed, and doesn't need shadow PEIMs again, it will occupy= more + // memory and waste more time if you enable it. + // + if (PcdGetBool (PcdShadowPeimOnBoot)) { + DEBUG ((DEBUG_ERROR, "!!!IMPORTANT NOTICE!!!\nWhen you see the mes= sage, it mean that you enable the PcdMigrateTemporaryRamFirmwareVolumes and= PcdShadowPeimOnBoot at the same time\nIt make no sense because it will occ= upy more memory and waste more time.\nYou must disable PcdShadowPeimOnBoot = when you enable PcdMigrateTemporaryRamFirmwareVolumes for performance reaso= n.\n\n")); + ASSERT ((PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) =3D=3D= TRUE) && (PcdGetBool (PcdShadowPeimOnBoot) =3D=3D FALSE)); } } =20 --=20 2.25.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#62834): https://edk2.groups.io/g/devel/message/62834 Mute This Topic: https://groups.io/mt/75679712/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-