From nobody Wed May 8 00:08:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94135+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94135+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1663879880; cv=none; d=zohomail.com; s=zohoarc; b=N+aWIIleK96ZpEKny0UCpI4YG5uZi+mw60WakqdzhdOtjVjabu586blWUAxppELefZM7wikMcAM1KPIsJPNisgPK/tZCqw0M5OdRUdwRZdiEy0aZHA4BRhbnAQmP9S+Mo253T19c+T9Nh9VW0dX4vvg8YW0pMNduLeqB0XYY56w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663879880; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ka0Gtju5u5aKHTQBfhRimvsLgGvaNhPUM5WMVQ1emNI=; b=FHPTUUgiCT0mgutE0WAMFh9inoNO3HOAIkBHQlC7/yv4aDkoHlgXd/e1hMKwS+kT5cHBUzyG4nHjJjmYQWwfH8EdkcF8goKffbAbcqcTQBk9J5m4rC1RzuZHZm9cO6rQj/MW9TmH8fKsuxhTjVtLxXzb/w9eTszHkGzzJ300VPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94135+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663879880757370.3730343855457; Thu, 22 Sep 2022 13:51:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dGkeYY1788612xpPtbElVzLQ; Thu, 22 Sep 2022 13:51:20 -0700 X-Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by mx.groups.io with SMTP id smtpd.web12.408.1663879879839377455 for ; Thu, 22 Sep 2022 13:51:19 -0700 X-Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-34d3fbc7cfcso69956227b3.7 for ; Thu, 22 Sep 2022 13:51:19 -0700 (PDT) X-Gm-Message-State: o78L8rCYmu5S13rzFFFdUizVx1787277AA= X-Google-Smtp-Source: AMsMyM4cxRzxOZ+7CvkEZA+Eea3H3vUK3HdhrDij69/sBVVxoxb3EExNtBOk784JooFl6z1Ms3ipPV8WmGAKatD8tw== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a81:ac04:0:b0:340:e323:f318 with SMTP id k4-20020a81ac04000000b00340e323f318mr5128521ywh.165.1663879878971; Thu, 22 Sep 2022 13:51:18 -0700 (PDT) Date: Thu, 22 Sep 2022 20:50:50 +0000 In-Reply-To: <20220922205052.1198237-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20220922205052.1198237-1-dionnaglaze@google.com> Message-ID: <20220922205052.1198237-2-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH 1/3] OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Sophia Wolf Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663879880; bh=38atfK0S0MbHJXwAJnpsCavbT2yoDgYTUbRZ24F1urg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=jM1F/2zUmy/fauw1ccTWIjsrR50h+8rlIStvz7EcYfaRh/UjzZkjaqSTeWSGVTlNyFh AvOtSC2YDBpt5xHQ5Ir/q1E5CqPANvK8D1ihYAWwXHIG2yrh8rmX3V9NVdfNiU4Yj30d6 iRs4mEUd6rsC7EKfCV/lQ54udg2fkoTI35o= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663879881958100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sophia Wolf When a guest OS does not support unaccepted memory, the unaccepted memory must be accepted before returning a memory map to the caller. EfiMemoryAcceptProtocol is defined in MdePkg and is implementated / Installed in AmdSevDxe for AMD SEV-SNP memory acceptance. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Sophia Wolf --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 27 ++++++++++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 3 ++ OvmfPkg/Include/Library/MemEncryptSevLib.h | 14 ++++++++ .../Ia32/MemEncryptSevLib.c | 17 +++++++++ .../X64/DxeSnpSystemRamValidate.c | 35 +++++++++++++++++++ .../X64/PeiSnpSystemRamValidate.c | 17 +++++++++ .../X64/SecSnpSystemRamValidate.c | 18 ++++++++++ 7 files changed, 131 insertions(+) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 662d3c4ccb..74b82a5814 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -20,6 +20,7 @@ #include #include #include +#include =20 STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBootDxeTable =3D { SIGNATURE_32 ('A', 'M', 'D', 'E'), @@ -31,6 +32,25 @@ STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBoo= tDxeTable =3D { FixedPcdGet32 (PcdOvmfCpuidSize), }; =20 +EFI_HANDLE mAmdSevDxeHandle =3D NULL; + +EFI_STATUS +EFIAPI +AmdSevMemoryAccept ( + IN EFI_MEMORY_ACCEPT_PROTOCOL *This, + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINTN Size +) +{ + MemEncryptSnpAcceptPages (StartAddress, Size / SIZE_4KB); + + return EFI_SUCCESS; +} + +EFI_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol =3D { + AmdSevMemoryAccept +}; + EFI_STATUS EFIAPI AmdSevDxeEntryPoint ( @@ -147,6 +167,13 @@ AmdSevDxeEntryPoint ( } } =20 + Status =3D gBS->InstallProtocolInterface (&mAmdSevDxeHandle, + &gEfiMemoryAcceptProtocolGuid, EFI_NATIVE_INTERFACE, + &mMemoryAcceptProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install EfiMemoryAcceptProtocol failed.\n")); + } + // // If its SEV-SNP active guest then install the CONFIDENTIAL_COMPUTING_S= EV_SNP_BLOB. // It contains the location for both the Secrets and CPUID page. diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.= inf index 9acf860cf2..5ddddabc32 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -47,6 +47,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize =20 +[Protocols] + gEfiMemoryAcceptProtocolGuid + [Guids] gConfidentialComputingSevSnpBlobGuid =20 diff --git a/OvmfPkg/Include/Library/MemEncryptSevLib.h b/OvmfPkg/Include/L= ibrary/MemEncryptSevLib.h index 4fa9c0d700..05ec10471d 100644 --- a/OvmfPkg/Include/Library/MemEncryptSevLib.h +++ b/OvmfPkg/Include/Library/MemEncryptSevLib.h @@ -228,4 +228,18 @@ MemEncryptSevSnpPreValidateSystemRam ( IN UINTN NumPages ); =20 +/** + Accept pages system RAM when SEV-SNP is enabled in the guest VM. + + @param[in] BaseAddress Base address + @param[in] NumPages Number of pages starting from the ba= se address + +**/ +VOID +EFIAPI +MemEncryptSnpAcceptPages ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINTN NumPages + ); + #endif // _MEM_ENCRYPT_SEV_LIB_H_ diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c b= /OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c index f92299fc77..f0747d792e 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c @@ -153,3 +153,20 @@ MemEncryptSevSnpPreValidateSystemRam ( { ASSERT (FALSE); } + +/** + Accept pages system RAM when SEV-SNP is enabled in the guest VM. + + @param[in] BaseAddress Base address + @param[in] NumPages Number of pages starting from the ba= se address + +**/ +VOID +EFIAPI +MemEncryptSnpAcceptPages ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINTN NumPages + ) +{ + ASSERT (FALSE); +} diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValida= te.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c index d3a95e4913..7693e0ca66 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c @@ -14,6 +14,7 @@ #include =20 #include "SnpPageStateChange.h" +#include "VirtualMemory.h" =20 /** Pre-validate the system RAM when SEV-SNP is enabled in the guest VM. @@ -38,3 +39,37 @@ MemEncryptSevSnpPreValidateSystemRam ( // ASSERT (FALSE); } + +/** + Accept pages system RAM when SEV-SNP is enabled in the guest VM. + + @param[in] BaseAddress Base address + @param[in] NumPages Number of pages starting from the ba= se address + +**/ +VOID +EFIAPI +MemEncryptSnpAcceptPages ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINTN NumPages + ) +{ + EFI_STATUS Status; + + if (!MemEncryptSevSnpIsEnabled ()) { + return; + } + if (BaseAddress >=3D SIZE_4GB) { + Status =3D InternalMemEncryptSevCreateIdentityMap1G ( + 0, + BaseAddress, + EFI_PAGES_TO_SIZE (NumPages) + ); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + CpuDeadLoop (); + } + } + + InternalSetPageState (BaseAddress, NumPages, SevSnpPagePrivate, TRUE); +} diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValida= te.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c index 4970165444..1c52bfe691 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiSnpSystemRamValidate.c @@ -126,3 +126,20 @@ MemEncryptSevSnpPreValidateSystemRam ( BaseAddress =3D EndAddress; } } + +/** + Accept pages system RAM when SEV-SNP is enabled in the guest VM. + + @param[in] BaseAddress Base address + @param[in] NumPages Number of pages starting from the ba= se address + +**/ +VOID +EFIAPI +MemEncryptSnpAcceptPages ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINTN NumPages + ) +{ + ASSERT (FALSE); +} diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValida= te.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValidate.c index 7797febb8a..edfebf6ef4 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValidate.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecSnpSystemRamValidate.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include =20 #include "SnpPageStateChange.h" @@ -80,3 +81,20 @@ MemEncryptSevSnpPreValidateSystemRam ( =20 InternalSetPageState (BaseAddress, NumPages, SevSnpPagePrivate, TRUE); } + +/** + Accept pages system RAM when SEV-SNP is enabled in the guest VM. + + @param[in] BaseAddress Base address + @param[in] NumPages Number of pages starting from the ba= se address + +**/ +VOID +EFIAPI +MemEncryptSnpAcceptPages ( + IN PHYSICAL_ADDRESS BaseAddress, + IN UINTN NumPages + ) +{ + ASSERT(FALSE); +} --=20 2.37.3.998.g577e59143f-goog -=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 (#94135): https://edk2.groups.io/g/devel/message/94135 Mute This Topic: https://groups.io/mt/93857642/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 Wed May 8 00:08:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94137+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94137+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1663879888; cv=none; d=zohomail.com; s=zohoarc; b=Z7AEIhlywyaANiEle3WYJGS+jTYFqFEtAqQAohfKlbyUKYHNj0tupXK5bTxmHuiOnmeLbFEfgJALaVhcfQO/RkYhmCpwLy+oY+C+Itdi8bJZWQ3LyE5GUMgoxumdzFAok17hNCGs5QP7s9ZdN7G36Nhc1gCTznEOj9VR+LN6j0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663879888; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FX828bhC05HXCCOlfQAZilzKP7IGDoFVy+13WruCxKg=; b=U9OeIEqg610A4Wypq5mkQDzNlTmzxc43P6kSW0jVIBXFDe5NohX/yMFYuQ2fE48YOSLMS0anr5EwIKE7eJtFgNZ9/rDB0mEm9xnEL8zyoZ9lOjNqSSoSETACJjV6+cQPPg4gISPRuWe5GvfM3Z/nWjPvDfMQlXbqE+AQIBZah3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94137+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663879888407470.4945065342806; Thu, 22 Sep 2022 13:51:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IuuvYY1788612xwNipCEHdBA; Thu, 22 Sep 2022 13:51:27 -0700 X-Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by mx.groups.io with SMTP id smtpd.web08.455.1663879886163120483 for ; Thu, 22 Sep 2022 13:51:26 -0700 X-Received: by mail-pg1-f202.google.com with SMTP id r126-20020a632b84000000b004393806c06eso5888542pgr.4 for ; Thu, 22 Sep 2022 13:51:26 -0700 (PDT) X-Gm-Message-State: ZXhz5YhPJD7bNjZH6JipQ4Vbx1787277AA= X-Google-Smtp-Source: AMsMyM4LuP1qKdYT9ThJ03mXwlLrnx5srtjp34UreNoWKFHgdRUiUN9eaEBqxsPrhmhDc/ZRsrJuWZKz3tpLS0n3TA== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90b:10a:b0:200:2849:235f with SMTP id p10-20020a17090b010a00b002002849235fmr385468pjz.1.1663879884138; Thu, 22 Sep 2022 13:51:24 -0700 (PDT) Date: Thu, 22 Sep 2022 20:50:51 +0000 In-Reply-To: <20220922205052.1198237-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20220922205052.1198237-1-dionnaglaze@google.com> Message-ID: <20220922205052.1198237-3-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH 2/3] DxeMain accepts all memory at EBS if needed From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663879887; bh=DCw6/rWZSwyYrFY0KwM8C8yYk3pfWoOCFkl5DiX0kis=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=bR3dPOnNM7Oi1SpdQqCqrnIynyYrFANEVAD5F5xcVMTFOvkAOHyBZi9FfkO+oiUG+8C MvWyCS/ztqpL4Wu/8bLYyJSjsVKT8fqNMv6N2pkDh04QOinx5GfRdvozjxFB22+Ds+xoc eqVfi0/gT33F9cEwrAgf7aFxuA05340GmI0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663879889805100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With the addition of the EfiUnacceptedMemory memory type, it is possible the EFI-enlightened guests do not themselves support the new memory type. This commit adds a dynamic Pcd that can be set to enable unaccepted memory support before ExitBootServices is called. The expected usage is to set the new Pcd with a protocol that is usable by bootloaders and directly-booted OSes when they can determine that the OS does indeed support unaccepted memory. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.h | 10 +++ MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 14 +++- MdeModulePkg/Core/Dxe/Mem/Page.c | 87 +++++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 6 ++ MdeModulePkg/MdeModulePkg.uni | 6 ++ OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 2 + OvmfPkg/CloudHv/CloudHvX64.dsc | 2 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 + OvmfPkg/OvmfPkgIa32X64.dsc | 2 + OvmfPkg/OvmfPkgX64.dsc | 2 + OvmfPkg/OvmfXen.dsc | 2 + 13 files changed, 137 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index 815a6b4bd8..ac943c87a3 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2698,6 +2698,16 @@ CoreInitializeMemoryProtection ( VOID ); =20 +/** + Accept and convert unaccepted memory to conventional memory if unaccept= ed + memory is not enabled and there is an implementation of MemoryAcceptPro= tocol + installed. + **/ +EFI_STATUS +CoreResolveUnacceptedMemory ( + VOID + ); + /** Install MemoryAttributesTable on memory allocation. =20 diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index e4bca89577..deb8bb2ba8 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -153,6 +153,7 @@ gEfiHiiPackageListProtocolGuid ## SOMETIMES_PRODUCES gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES + gEfiMemoryAcceptProtocolGuid ## SOMETIMES_CONSUMES =20 # Arch Protocols gEfiBdsArchProtocolGuid ## CONSUMES @@ -186,6 +187,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory = ## CONSUMES =20 # [Hob] # RESOURCE_DESCRIPTOR ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 5733f0c8ec..8d1de32fe7 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -768,13 +768,25 @@ CoreExitBootServices ( // gTimer->SetTimerPeriod (gTimer, 0); =20 + // + // Accept all memory if unaccepted memory isn't enabled. + // + Status =3D CoreResolveUnacceptedMemory(); + if (EFI_ERROR (Status)) { + // + // Notify other drivers that ExitBootServices failed + // + CoreNotifySignalList (&gEventExitBootServicesFailedGuid); + return Status; + } + // // Terminate memory services if the MapKey matches // Status =3D CoreTerminateMemoryMap (MapKey); if (EFI_ERROR (Status)) { // - // Notify other drivers that ExitBootServices fail + // Notify other drivers that ExitBootServices failed // CoreNotifySignalList (&gEventExitBootServicesFailedGuid); return Status; diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index ffe79dcca9..cbebe62a28 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "DxeMain.h" #include "Imem.h" #include "HeapGuard.h" +#include +#include =20 // // Entry for tracking the memory regions for each memory type to coalesce = similar memory types @@ -2118,6 +2120,91 @@ CoreFreePoolPages ( CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory); } =20 +EFI_EVENT gExitBootServiceEvent =3D NULL; + +STATIC +EFI_STATUS +AcceptAllUnacceptedMemory ( + IN EFI_MEMORY_ACCEPT_PROTOCOL *AcceptMemory + ) +{ + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDescMap; + UINTN NumEntries; + UINTN Index; + EFI_STATUS Status; + + /* + * Get a copy of the memory space map to iterate over while + * changing the map. + */ + Status =3D CoreGetMemorySpaceMap (&NumEntries, &AllDescMap); + if (EFI_ERROR (Status)) { + return Status; + } + for (Index =3D 0; Index < NumEntries; Index++) { + CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; + + Desc =3D &AllDescMap[Index]; + if (Desc->GcdMemoryType !=3D EfiGcdMemoryTypeUnaccepted) { + continue; + } + + Status =3D AcceptMemory->AcceptMemory ( + AcceptMemory, + Desc->BaseAddress, + Desc->Length + ); + if (EFI_ERROR(Status)) { + goto done; + } + + Status =3D CoreRemoveMemorySpace(Desc->BaseAddress, Desc->Length); + if (EFI_ERROR(Status)) { + goto done; + } + + Status =3D CoreAddMemorySpace ( + EfiGcdMemoryTypeSystemMemory, + Desc->BaseAddress, + Desc->Length, + EFI_MEMORY_CPU_CRYPTO | EFI_MEMORY_XP | EFI_MEMORY_RO | EFI_MEMORY_RP + ); + if (EFI_ERROR(Status)) { + goto done; + } + } + +done: + FreePool (AllDescMap); + return Status; +} + +EFI_STATUS +CoreResolveUnacceptedMemory ( + VOID + ) +{ + EFI_MEMORY_ACCEPT_PROTOCOL *AcceptMemory; + EFI_STATUS Status; + + // No need to accept anything. Unaccepted memory is enabled. + if (PcdGetBool(PcdEnableUnacceptedMemory)) { + return EFI_SUCCESS; + } + + Status =3D gBS->LocateProtocol (&gEfiMemoryAcceptProtocolGuid, NULL, + (VOID **)&AcceptMemory); + if (Status =3D=3D EFI_NOT_FOUND) { + return EFI_SUCCESS; + } + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "Error locating MemoryAcceptProtocol: %d\n", Stat= us)); + return Status; + } + + return AcceptAllUnacceptedMemory(AcceptMemory); +} + /** Make sure the memory map is following all the construction rules, it is the last time to check memory map error before exit boot services. diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 58e6ab0048..dd07b3725a 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -2102,6 +2102,12 @@ # @Prompt The shared bit mask when Intel Tdx is enabled. gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0|UINT64|0x10000025 =20 + ## Indicates if the memory map may include unaccepted memory after ExitB= ootServices().

+ # TRUE - The memory map may include unaccepted memory after ExitBootS= ervices().
+ # FALSE - The memory map may not include unaccepted memory after ExitB= ootServices().
+ # @Prompt Support unaccepted memory type. + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE|BOOLEAN|0= x10000026 + [PcdsPatchableInModule] ## Specify memory size with page number for PEI code when # Loading Module at Fixed Address feature is enabled. diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 33ce9f6198..fde57da123 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -1338,3 +1338,9 @@ #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdPcieResizableBarSupport_HELP= #language en-US "Indicates if the PCIe Resizable BAR Capability Supported.=

\n" = "TRUE - PCIe Resizable BAR Capability is supported.
\= n" = "FALSE - PCIe Resizable BAR Capability is not supported.<= BR>" + +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableUnacceptedMemory_PROMP= T #language en-US "Support unaccepted memory type" +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableUnacceptedMemory_HELP = #language en-US "Indicates if the memory map may include unaccepted memory " + = "after ExitBootServices().

\n" + = "TRUE - The memory map may include unaccepted memory after= ExitBootServices().
\n" + = "FALSE - The memory map may not include unaccepted memory a= fter ExitBootServices().
\n" diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 90e8a213ef..23086748c5 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -526,6 +526,7 @@ =20 # Set ConfidentialComputing defaults gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE =20 !include OvmfPkg/OvmfTpmPcds.dsc.inc =20 diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index 475b88b21a..004be8b019 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -559,6 +559,8 @@ # Set Tdx shared bit mask gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 =20 # MdeModulePkg resolution sets up the system display resolution diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index 10b16104ac..41f43a2631 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -618,6 +618,8 @@ # Set Tdx shared bit mask gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + # Set SEV-ES defaults gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index c0c1a15b09..55b6a2a845 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -514,6 +514,8 @@ # Set Tdx shared bit mask gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + # Set SEV-ES defaults gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index af566b953f..aebe1c3192 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -655,6 +655,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + # Set SEV-ES defaults gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index f39d9cd117..6e4418388e 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -679,6 +679,8 @@ # Set Tdx shared bit mask gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + # Set SEV-ES defaults gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize|0 diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 58a7c97cdd..0f57e22a2b 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -505,6 +505,8 @@ # Set Tdx shared bit mask gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask|0x0 =20 + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory|FALSE + gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x00 =20 ##########################################################################= ###### --=20 2.37.3.998.g577e59143f-goog -=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 (#94137): https://edk2.groups.io/g/devel/message/94137 Mute This Topic: https://groups.io/mt/93857645/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 Wed May 8 00:08:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+94141+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94141+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1663879890; cv=none; d=zohomail.com; s=zohoarc; b=G6V0yc9h7UZq84IRFyTq/U6kXQboHNsxd/f3T44qWRLj3kvOgpFt5vjcE4v0E6lni1qjtecDKrtQ9I7nN7Ux6rG6wIzHOxVJ8/QcYQA9UeZO6A5+8xdV9LJllpTTclCyvidsB1rfNTZgncaw4hJW/gG7cZl6eN8Tz6TopV18iKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663879890; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=EhcO9ihfjNjggodLgMKYKMbimSkHrCDr2Wm1gRVJe1Q=; b=MrXn/9u8tdBf3d+C/bBh65BPSmwf80UhaHRKSJTeCJEUvC030HvPG+r0eolTspO0xNO8A2nZ55/5CrkcGIrEbz8Nk+IK7cMrHu76wXXsQlEedar9uiV6tP4uru6x2LnDh7c/C1kT+PoP4S4nHg8PPiTZjjJKAUspWxSOzn9fAKU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+94141+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1663879890463785.0478234581999; Thu, 22 Sep 2022 13:51:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vxS8YY1788612xpv0d7i4H3b; Thu, 22 Sep 2022 13:51:30 -0700 X-Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by mx.groups.io with SMTP id smtpd.web11.420.1663879889241583864 for ; Thu, 22 Sep 2022 13:51:29 -0700 X-Received: by mail-pg1-f202.google.com with SMTP id l72-20020a63914b000000b00434ac6f8214so5905774pge.13 for ; Thu, 22 Sep 2022 13:51:29 -0700 (PDT) X-Gm-Message-State: vmuwGqYEYyQhz8dJXKY8nBnEx1787277AA= X-Google-Smtp-Source: AMsMyM4Ox3voKgC/UzztzBS4wYKeJ41hb74fYHk15QID5Mxf/KntSd5OfXrd8TshrL7j5EoPkZl4CyX1o1uvaCsACg== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a05:6a00:2192:b0:54e:6aed:c6fb with SMTP id h18-20020a056a00219200b0054e6aedc6fbmr5528026pfi.10.1663879888616; Thu, 22 Sep 2022 13:51:28 -0700 (PDT) Date: Thu, 22 Sep 2022 20:50:52 +0000 In-Reply-To: <20220922205052.1198237-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20220922205052.1198237-1-dionnaglaze@google.com> Message-ID: <20220922205052.1198237-4-dionnaglaze@google.com> Subject: [edk2-devel] [PATCH 3/3] MdeModulePkg: add EnableUnacceptedMemoryProtocol From: "Dionna Glaze via groups.io" To: devel@edk2.groups.io Cc: Dionna Glaze , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky , Ard Biesheuvel Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dionnaglaze@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1663879890; bh=/QH7XiGS9MWLXP9uBbqUUs620gs1jvmmKA0bFERLmpw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=P8CmbHD7POYibvwDK+4OkZuUPs9uwnf7WmRA3G3XyVT6v9owfqCvPYb1UUR0WZytnyO e0BS1P1zXqOHUiY1N0bbRh8V56KMii8oKKN1OJzUhZV72zkKSWczfwv4EXudXq8P0FSH5 h8OsNB4sdeWSJeNdjzdnqbNS+jm91X/W160= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1663879891729100021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a simple protocol that enables the use of the unaccepted memory type. Must be called before ExitBootServices to be effective. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Signed-off-by: Dionna Glaze --- MdeModulePkg/Core/Dxe/DxeMain.h | 22 ++++++++++++++++ MdeModulePkg/Core/Dxe/DxeMain.inf | 3 ++- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 5 ++++ MdeModulePkg/Core/Dxe/Mem/Page.c | 35 +++++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 +++ 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMai= n.h index ac943c87a3..5f0114b04f 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2708,6 +2708,28 @@ CoreResolveUnacceptedMemory ( VOID ); =20 + +typedef struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL + ENABLE_UNACCEPTED_MEMORY_PROTOCOL; + +typedef EFI_STATUS (EFIAPI *ENABLE_UNACCEPTED_MEMORY)( + IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL * + ); + +struct _ENABLE_UNACCEPTED_MEMORY_PROTOCOL { + ENABLE_UNACCEPTED_MEMORY Enable; +}; + +extern EFI_GUID gEnableUnacceptedMemoryProtocolGuid; + +/** + Implement the protocol for enabling unaccepted memory. + **/ +VOID +InstallEnableUnacceptedMemoryProtocol ( + VOID + ); + /** Install MemoryAttributesTable on memory allocation. =20 diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeM= ain.inf index deb8bb2ba8..39dcac98bb 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -122,6 +122,7 @@ gEfiMemoryAttributesTableGuid ## SOMETIMES_PRODUCES ##= SystemTable gEfiEndOfDxeEventGroupGuid ## SOMETIMES_CONSUMES ##= Event gEfiHobMemoryAllocStackGuid ## SOMETIMES_CONSUMES ##= SystemTable + gEnableUnacceptedMemoryProtocolGuid ## PRODUCES ##= GUID # Install protocol =20 [Ppis] gEfiVectorHandoffInfoPpiGuid ## UNDEFINED # HOB @@ -187,7 +188,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard = ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFwVolDxeMaxEncapsulationDepth = ## CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory = ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableUnacceptedMemory = ## CONSUMES ## SOMETIMES_PRODUCES =20 # [Hob] # RESOURCE_DESCRIPTOR ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dx= e/DxeMain/DxeMain.c index 8d1de32fe7..bc1a8ab6b2 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -354,6 +354,11 @@ DxeMain ( Status =3D CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid= , &gMemoryTypeInformation); ASSERT_EFI_ERROR (Status); =20 + // + // Install unaccepted memory configuration protocol + // + InstallEnableUnacceptedMemoryProtocol(); + // // If Loading modules At fixed address feature is enabled, install Load = moduels at fixed address // Configuration Table so that user could easily to retrieve the top add= ress to load Dxe and PEI diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index cbebe62a28..10e152d80d 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -96,6 +96,14 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiM= axMemoryType + 1] =3D { // GLOBAL_REMOVE_IF_UNREFERENCED BOOLEAN gLoadFixedAddressCodeMemoryReady = =3D FALSE; =20 +EFI_STATUS EFIAPI CoreEnableUnacceptedMemory(IN ENABLE_UNACCEPTED_MEMORY_P= ROTOCOL *); + +struct { + ENABLE_UNACCEPTED_MEMORY enable; +} mEnableUnacceptedMemoryProtocol =3D { + CoreEnableUnacceptedMemory, +}; + /** Enter critical section by gaining lock on gMemoryLock. =20 @@ -2205,6 +2213,33 @@ CoreResolveUnacceptedMemory ( return AcceptAllUnacceptedMemory(AcceptMemory); } =20 +EFI_STATUS +EFIAPI +CoreEnableUnacceptedMemory ( + IN ENABLE_UNACCEPTED_MEMORY_PROTOCOL *This + ) +{ + return PcdSetBoolS(PcdEnableUnacceptedMemory, TRUE); +} + +VOID +InstallEnableUnacceptedMemoryProtocol ( + VOID + ) +{ + EFI_HANDLE Handle; + EFI_STATUS Status; + + Handle =3D NULL; + Status =3D CoreInstallMultipleProtocolInterfaces ( + &Handle, + &gEnableUnacceptedMemoryProtocolGuid, + &mEnableUnacceptedMemoryProtocol, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + /** Make sure the memory map is following all the construction rules, it is the last time to check memory map error before exit boot services. diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index dd07b3725a..ce72c06a93 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -244,6 +244,9 @@ gEdkiiPerformanceMeasurementProtocolGuid =3D { 0xc85d06be, 0x5f75, = 0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } } gEdkiiSmmPerformanceMeasurementProtocolGuid =3D { 0xd56b6d73, 0x1a7b, = 0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } } =20 + ## Bootloader protocol Guid for enabling unaccepted memory support. + gEnableUnacceptedMemoryProtocolGuid =3D { 0xc5a010fe, 0x38a7, 0x4531, { = 0x8a, 0x4a, 0x05, 0x00, 0xd2, 0xfd, 0x16, 0x49 } } + ## Guid is defined for CRC32 encapsulation scheme. # Include/Guid/Crc32GuidedSectionExtraction.h gEfiCrc32GuidedSectionExtractionGuid =3D { 0xFC1BCDB0, 0x7D31, 0x49aa, {= 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } } --=20 2.37.3.998.g577e59143f-goog -=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 (#94141): https://edk2.groups.io/g/devel/message/94141 Mute This Topic: https://groups.io/mt/93857649/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-