diff options
author | Min M Xu <min.m.xu@intel.com> | 2022-11-01 13:13:49 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-11-01 10:08:10 +0000 |
commit | 720c25ab41400f9a3dfd0742da5a6d237991df5b (patch) | |
tree | 5d50615a45869d32a2e8a2d7c22ed0f80eec2c9b | |
parent | 7dcc2f387071e808be560f6ad0acbd1a7f0f6001 (diff) | |
download | edk2-720c25ab41400f9a3dfd0742da5a6d237991df5b.zip edk2-720c25ab41400f9a3dfd0742da5a6d237991df5b.tar.gz edk2-720c25ab41400f9a3dfd0742da5a6d237991df5b.tar.bz2 |
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>
-rw-r--r-- | OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf | 3 | ||||
-rw-r--r-- | OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index a8abfec..1176882 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -42,3 +42,6 @@ [Pcd]
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr
+
+[Protocols]
+ gEdkiiMemoryAcceptProtocolGuid
diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index 9d11c6e..503f626 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/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 ((
|