]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Implement AcceptAllUnacceptedMemory in AmdSevDxe
authorDionna Glaze <dionnaglaze@google.com>
Thu, 26 Jan 2023 21:17:39 +0000 (21:17 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 26 Jan 2023 23:00:51 +0000 (23:00 +0000)
This protocol implementation disables the accept-all-memory behavior
of the BeforeExitBootServices event this driver adds.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: "Min M. Xu" <min.m.xu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: "Michael D. Kinney" <michael.d.kinney@intel.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/AmdSevDxe/AmdSevDxe.c
OvmfPkg/AmdSevDxe/AmdSevDxe.inf

index 37d1a3ff55c6bbb1aae521ca112931d014f953ea..6391d1f775d571966275a9f082b17a4f53b09e32 100644 (file)
@@ -21,6 +21,7 @@
 #include <Guid/ConfidentialComputingSevSnpBlob.h>\r
 #include <Library/PcdLib.h>\r
 #include <Pi/PrePiDxeCis.h>\r
+#include <Protocol/SevMemoryAcceptance.h>\r
 #include <Protocol/MemoryAccept.h>\r
 \r
 STATIC CONFIDENTIAL_COMPUTING_SNP_BLOB_LOCATION  mSnpBootDxeTable = {\r
@@ -143,6 +144,21 @@ ResolveUnacceptedMemory (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+AllowUnacceptedMemory (\r
+  IN  OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL  *This\r
+  )\r
+{\r
+  mAcceptAllMemoryAtEBS = FALSE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+STATIC\r
+OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL\r
+  mMemoryAcceptanceProtocol = { AllowUnacceptedMemory };\r
+\r
 STATIC EDKII_MEMORY_ACCEPT_PROTOCOL  mMemoryAcceptProtocol = {\r
   AmdSevMemoryAccept\r
 };\r
@@ -268,11 +284,13 @@ AmdSevDxeEntryPoint (
     // Memory acceptance began being required in SEV-SNP, so install the\r
     // memory accept protocol implementation for a SEV-SNP active guest.\r
     //\r
-    Status = gBS->InstallProtocolInterface (\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
                     &mAmdSevDxeHandle,\r
                     &gEdkiiMemoryAcceptProtocolGuid,\r
-                    EFI_NATIVE_INTERFACE,\r
-                    &mMemoryAcceptProtocol\r
+                    &mMemoryAcceptProtocol,\r
+                    &gOvmfSevMemoryAcceptanceProtocolGuid,\r
+                    &mMemoryAcceptanceProtocol,\r
+                    NULL\r
                     );\r
     ASSERT_EFI_ERROR (Status);\r
 \r
index 5b443d45bcefbf7ff29199836b0f1f203e829946..e7c7d526c95f96698ad7568730ed4f031fb74494 100644 (file)
@@ -49,6 +49,7 @@
 \r
 [Protocols]\r
   gEdkiiMemoryAcceptProtocolGuid\r
+  gOvmfSevMemoryAcceptanceProtocolGuid\r
 \r
 [Guids]\r
   gConfidentialComputingSevSnpBlobGuid\r