From 4907ed9e39ebe8ecd8a17b4586d3568849c5d440 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Tue, 6 Apr 2021 08:39:51 +0800 Subject: [PATCH] OvmfPkg: Delete PcdTdxSharedPageMask PcdTdxSharedPageMask indicates the GPA Width which is defined in OvmfPkg. But this PCD is used in MdePkg. We can call TdSharedPageMask() to do the same job as PcdTdxSharedPageMask. --- .../BaseMemEncryptTdxLib.inf | 3 --- .../BaseMemEncryptTdxLib/MemoryEncryption.c | 21 +------------------ OvmfPkg/OvmfPkg.dec | 2 -- OvmfPkg/OvmfPkgX64.dsc | 3 --- OvmfPkg/TdxDxe/TdxDxe.c | 11 ---------- OvmfPkg/TdxDxe/TdxDxe.inf | 2 -- 6 files changed, 1 insertion(+), 41 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf index c1332fac9901f..41438394da0da 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf @@ -44,6 +44,3 @@ TdxLib TdxProbeLib -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdTdxSharedPageMask - gUefiOvmfPkgTokenSpaceGuid.PcdTdxDisableSharedMask diff --git a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c index 202f491b73b53..b71e1c6843c9a 100644 --- a/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c +++ b/OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c @@ -27,8 +27,6 @@ typedef enum { ClearSharedBit } TDX_PAGETABLE_MODE; -STATIC BOOLEAN mAddressEncMaskChecked = FALSE; -STATIC UINT64 mAddressEncMask; STATIC PAGE_TABLE_POOL *mPageTablePool = NULL; /** @@ -63,21 +61,7 @@ GetMemEncryptionAddressMask ( VOID ) { - if (mAddressEncMaskChecked) { - return mAddressEncMask; - } - - mAddressEncMask = PcdGet64(PcdTdxSharedPageMask); - - mAddressEncMaskChecked = TRUE; - DEBUG (( - DEBUG_INFO, - "%a:%a: AddressEncMask=0x%Lx\n", - gEfiCallerBaseName, - __FUNCTION__, - mAddressEncMask)); - - return mAddressEncMask; + return TdSharedPageMask(); } /** @@ -532,9 +516,6 @@ SetOrClearSharedBit( } Status = TdVmCall(TDVMCALL_MAPGPA, PhysicalAddress, Length, 0, 0, NULL); - if (PcdGetBool(PcdTdxDisableSharedMask) != TRUE) { - ASSERT(Status == 0); - } // // If changing shared to private, must accept-page again diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index f54a739a5833b..41491e21c5ea8 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -339,7 +339,6 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfImageSizeInKb|0|UINT32|0x58 gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageChunkSize|0x2000|UINT64|0x59 - gUefiOvmfPkgTokenSpaceGuid.PcdTdxDisableSharedMask|FALSE|BOOLEAN|0x5a gUefiOvmfPkgTokenSpaceGuid.PcdTdxSetNxForStack|FALSE|BOOLEAN|0x5b gUefiOvmfPkgTokenSpaceGuid.PcdTdxPteMemoryEncryptionAddressOrMask|0|UINT64|0x5c @@ -379,7 +378,6 @@ # This PCD is only accessed if PcdSmmSmramRequire is TRUE (see below). gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE|BOOLEAN|0x34 - gUefiOvmfPkgTokenSpaceGuid.PcdTdxSharedPageMask|0x0|UINT64|0x101 gUefiOvmfPkgTokenSpaceGuid.PcdTdRelocatedMailboxBase|0|UINT64|0x102 ## This PCD records LAML field in TDX EVENTLOG ACPI table. diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 5c187b6576640..d5d78e7cde6bb 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -603,9 +603,6 @@ # !if $(TDX_IGNORE_VE_HLT) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdIgnoreVeHalt|TRUE -!endif -!if $(TDX_DISABLE_SHARED_MASK) == TRUE - gUefiOvmfPkgTokenSpaceGuid.PcdTdxDisableSharedMask|TRUE !endif # 32M gUefiOvmfPkgTokenSpaceGuid.PcdTdxAcceptPageChunkSize|0x2000000 diff --git a/OvmfPkg/TdxDxe/TdxDxe.c b/OvmfPkg/TdxDxe/TdxDxe.c index 8052b07731dd5..cec3aea7670be 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.c +++ b/OvmfPkg/TdxDxe/TdxDxe.c @@ -123,7 +123,6 @@ TdxDxeEntryPoint ( EFI_HOB_PLATFORM_INFO *PlatformInfo = NULL; EFI_HOB_GUID_TYPE *GuidHob; UINT32 CpuMaxLogicalProcessorNumber; - EFI_HOB_CPU * CpuHob; TD_RETURN_DATA TdReturnData; GuidHob = GetFirstGuidHob(&gUefiOvmfPkgTdxPlatformGuid); @@ -185,15 +184,5 @@ TdxDxeEntryPoint ( ASSERT_RETURN_ERROR(PcdStatus); } - if (PcdGetBool(PcdTdxDisableSharedMask) == TRUE) { - PcdStatus = PcdSet64S (PcdTdxSharedPageMask, 0); - ASSERT_RETURN_ERROR(PcdStatus); - } else { - CpuHob = GetFirstHob (EFI_HOB_TYPE_CPU); - ASSERT (CpuHob != NULL); - PcdStatus = PcdSet64S (PcdTdxSharedPageMask, (1ULL << (CpuHob->SizeOfMemorySpace - 1))); - ASSERT_RETURN_ERROR(PcdStatus); - } - return EFI_SUCCESS; } diff --git a/OvmfPkg/TdxDxe/TdxDxe.inf b/OvmfPkg/TdxDxe/TdxDxe.inf index c24b360a31465..c8f78cdf4f15c 100644 --- a/OvmfPkg/TdxDxe/TdxDxe.inf +++ b/OvmfPkg/TdxDxe/TdxDxe.inf @@ -51,7 +51,5 @@ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber - gUefiOvmfPkgTokenSpaceGuid.PcdTdxSharedPageMask gUefiOvmfPkgTokenSpaceGuid.PcdUseTdxEmulation - gUefiOvmfPkgTokenSpaceGuid.PcdTdxDisableSharedMask gUefiOvmfPkgTokenSpaceGuid.PcdTdRelocatedMailboxBase