소스 검색

OvmfPkg: Call gEdkiiMemoryAcceptProtocolGuid to accept pages

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>
Min M Xu 1 년 전
부모
커밋
720c25ab41
2개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 0
      OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
  2. 9 3
      OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c

+ 3 - 0
OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf

@@ -42,3 +42,6 @@
 
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr
+
+[Protocols]
+  gEdkiiMemoryAcceptProtocolGuid

+ 9 - 3
OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c

@@ -27,6 +27,8 @@
 #include "VirtualMemory.h"
 #include <IndustryStandard/Tdx.h>
 #include <Library/TdxLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/MemoryAccept.h>
 #include <ConfidentialComputingGuestAttr.h>
 
 typedef enum {
@@ -517,8 +519,9 @@ SetOrClearSharedBit (
   IN           UINT64              Length
   )
 {
-  UINT64  AddressEncMask;
-  UINT64  Status;
+  UINT64                        AddressEncMask;
+  UINT64                        Status;
+  EDKII_MEMORY_ACCEPT_PROTOCOL  *MemoryAcceptProtocol;
 
   AddressEncMask = GetMemEncryptionAddressMask ();
 
@@ -539,7 +542,10 @@ SetOrClearSharedBit (
   // If changing shared to private, must accept-page again
   //
   if (Mode == ClearSharedBit) {
-    TdAcceptPages (PhysicalAddress, Length / EFI_PAGE_SIZE, EFI_PAGE_SIZE);
+    Status = gBS->LocateProtocol (&gEdkiiMemoryAcceptProtocolGuid, NULL, (VOID **)&MemoryAcceptProtocol);
+    ASSERT (!EFI_ERROR (Status));
+    Status = MemoryAcceptProtocol->AcceptMemory (MemoryAcceptProtocol, PhysicalAddress, Length);
+    ASSERT (!EFI_ERROR (Status));
   }
 
   DEBUG ((