From: Dionna Glaze Date: Thu, 26 Jan 2023 21:17:39 +0000 (+0000) Subject: OvmfPkg: Implement AcceptAllUnacceptedMemory in AmdSevDxe X-Git-Tag: edk2-stable202302~86 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=466d8f65e3c7f748d52e7a0046a1f7c1febe5691 OvmfPkg: Implement AcceptAllUnacceptedMemory in AmdSevDxe This protocol implementation disables the accept-all-memory behavior of the BeforeExitBootServices event this driver adds. Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Ard Biesheuvel Cc: "Min M. Xu" Cc: Andrew Fish Cc: "Michael D. Kinney" Signed-off-by: Dionna Glaze Reviewed-by: Ard Biesheuvel --- diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 37d1a3ff55..6391d1f775 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -21,6 +21,7 @@ #include #include #include +#include #include STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION mSnpBootDxeTable = { @@ -143,6 +144,21 @@ ResolveUnacceptedMemory ( ASSERT_EFI_ERROR (Status); } +STATIC +EFI_STATUS +EFIAPI +AllowUnacceptedMemory ( + IN OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL *This + ) +{ + mAcceptAllMemoryAtEBS = FALSE; + return EFI_SUCCESS; +} + +STATIC +OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL + mMemoryAcceptanceProtocol = { AllowUnacceptedMemory }; + STATIC EDKII_MEMORY_ACCEPT_PROTOCOL mMemoryAcceptProtocol = { AmdSevMemoryAccept }; @@ -268,11 +284,13 @@ AmdSevDxeEntryPoint ( // Memory acceptance began being required in SEV-SNP, so install the // memory accept protocol implementation for a SEV-SNP active guest. // - Status = gBS->InstallProtocolInterface ( + Status = gBS->InstallMultipleProtocolInterfaces ( &mAmdSevDxeHandle, &gEdkiiMemoryAcceptProtocolGuid, - EFI_NATIVE_INTERFACE, - &mMemoryAcceptProtocol + &mMemoryAcceptProtocol, + &gOvmfSevMemoryAcceptanceProtocolGuid, + &mMemoryAcceptanceProtocol, + NULL ); ASSERT_EFI_ERROR (Status); diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf index 5b443d45bc..e7c7d526c9 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.inf +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.inf @@ -49,6 +49,7 @@ [Protocols] gEdkiiMemoryAcceptProtocolGuid + gOvmfSevMemoryAcceptanceProtocolGuid [Guids] gConfidentialComputingSevSnpBlobGuid