This protocol implementation disables the accept-all-memory behavior of the BeforeExitBootServices event this driver adds.
Cc: Gerd Hoffmann <kra...@redhat.com> Cc: James Bottomley <j...@linux.ibm.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Tom Lendacky <thomas.lenda...@amd.com> Cc: Ard Biesheuvel <a...@kernel.org> Cc: "Min M. Xu" <min.m...@intel.com> Cc: Andrew Fish <af...@apple.com> Cc: "Michael D. Kinney" <michael.d.kin...@intel.com> Signed-off-by: Dionna Glaze <dionnagl...@google.com> --- OvmfPkg/CocoDxe/CocoDxe.c | 28 ++++++++++++++++++++ OvmfPkg/CocoDxe/CocoDxe.inf | 1 + 2 files changed, 29 insertions(+) diff --git a/OvmfPkg/CocoDxe/CocoDxe.c b/OvmfPkg/CocoDxe/CocoDxe.c index 98874e6cfc..14fbcf60d7 100644 --- a/OvmfPkg/CocoDxe/CocoDxe.c +++ b/OvmfPkg/CocoDxe/CocoDxe.c @@ -17,11 +17,14 @@ #include <Library/MemEncryptSevLib.h> #include <Library/MemEncryptTdxLib.h> #include <Protocol/MemoryAccept.h> +#include <Protocol/MemoryAcceptance.h> STATIC BOOLEAN mAcceptAllMemoryAtEBS = TRUE; STATIC EFI_EVENT mAcceptAllMemoryEvent = NULL; +STATIC EFI_HANDLE mCocoDxeHandle = NULL; + STATIC EFI_STATUS AcceptAllMemory ( @@ -110,6 +113,21 @@ ResolveUnacceptedMemory ( ASSERT_EFI_ERROR (Status); } +STATIC +EFI_STATUS +EFIAPI +AllowUnacceptedMemory ( + IN BZ3987_MEMORY_ACCEPTANCE_PROTOCOL *This + ) +{ + mAcceptAllMemoryAtEBS = FALSE; + return EFI_SUCCESS; +} + +STATIC +BZ3987_MEMORY_ACCEPTANCE_PROTOCOL + mMemoryAcceptanceProtocol = { AllowUnacceptedMemory }; + EFI_STATUS EFIAPI CocoDxeEntryPoint ( @@ -142,5 +160,15 @@ CocoDxeEntryPoint ( DEBUG ((DEBUG_ERROR, "AllowUnacceptedMemory event creation for EventBeforeExitBootServices failed.\n")); } + Status = gBS->InstallProtocolInterface ( + &mCocoDxeHandle, + &gBz3987MemoryAcceptanceProtocolGuid, + EFI_NATIVE_INTERFACE, + &mMemoryAcceptanceProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Install Bz3987MemoryAcceptanceProtocol failed.\n")); + } + return EFI_SUCCESS; } diff --git a/OvmfPkg/CocoDxe/CocoDxe.inf b/OvmfPkg/CocoDxe/CocoDxe.inf index 8d4452e94d..05c2651a89 100644 --- a/OvmfPkg/CocoDxe/CocoDxe.inf +++ b/OvmfPkg/CocoDxe/CocoDxe.inf @@ -42,4 +42,5 @@ gEfiEventBeforeExitBootServicesGuid [Protocols] + gBz3987MemoryAcceptanceProtocolGuid gEdkiiMemoryAcceptProtocolGuid -- 2.38.0.135.g90850a2211-goog -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#95530): https://edk2.groups.io/g/devel/message/95530 Mute This Topic: https://groups.io/mt/94544537/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-