]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages
authorMin M Xu <min.m.xu@intel.com>
Tue, 1 Nov 2022 05:13:49 +0000 (13:13 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 1 Nov 2022 10:08:10 +0000 (10:08 +0000)
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3937

After EdkiiMemoryAcceptProtocol is implemented in TdxDxe driver, we can
call it to accept pages in DXE phase.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c

index a8abfec12fa397f9cdccf74c1a8fdc6ea77fa1f1..11768825f8cadea803fcfcae23fca97248549495 100644 (file)
@@ -42,3 +42,6 @@
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr\r
+\r
+[Protocols]\r
+  gEdkiiMemoryAcceptProtocolGuid\r
index 9d11c6e4df728093a617778b9a156bb81d74f865..503f626d75c64275e0bdfb2f21572ca25cdb03da 100644 (file)
@@ -27,6 +27,8 @@
 #include "VirtualMemory.h"\r
 #include <IndustryStandard/Tdx.h>\r
 #include <Library/TdxLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Protocol/MemoryAccept.h>\r
 #include <ConfidentialComputingGuestAttr.h>\r
 \r
 typedef enum {\r
@@ -517,8 +519,9 @@ SetOrClearSharedBit (
   IN           UINT64              Length\r
   )\r
 {\r
-  UINT64  AddressEncMask;\r
-  UINT64  Status;\r
+  UINT64                        AddressEncMask;\r
+  UINT64                        Status;\r
+  EDKII_MEMORY_ACCEPT_PROTOCOL  *MemoryAcceptProtocol;\r
 \r
   AddressEncMask = GetMemEncryptionAddressMask ();\r
 \r
@@ -539,7 +542,10 @@ SetOrClearSharedBit (
   // If changing shared to private, must accept-page again\r
   //\r
   if (Mode == ClearSharedBit) {\r
-    TdAcceptPages (PhysicalAddress, Length / EFI_PAGE_SIZE, EFI_PAGE_SIZE);\r
+    Status = gBS->LocateProtocol (&gEdkiiMemoryAcceptProtocolGuid, NULL, (VOID **)&MemoryAcceptProtocol);\r
+    ASSERT (!EFI_ERROR (Status));\r
+    Status = MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, PhysicalAddress, Length);\r
+    ASSERT (!EFI_ERROR (Status));\r
   }\r
 \r
   DEBUG ((\r