diff options
author | Ceping Sun <cepingx.sun@intel.com> | 2024-08-29 07:34:47 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-09-13 18:10:08 +0000 |
commit | ec18fa81d311663e24e9b9ad61b90b38862a1ea8 (patch) | |
tree | f3da97d66e9887a835ff959aa949ebd15693f3c5 | |
parent | 262ab6259f30203306d8a94de530d08998dab121 (diff) | |
download | edk2-ec18fa81d311663e24e9b9ad61b90b38862a1ea8.tar.gz edk2-ec18fa81d311663e24e9b9ad61b90b38862a1ea8.tar.bz2 edk2-ec18fa81d311663e24e9b9ad61b90b38862a1ea8.zip |
OvmfPkg: Use TdInfo instead of fw_cfg to get cpu count in TDVF
Currently TDVF gets cpu count information via fw_cfg, but
this information can also be retrieved by calling of TdCall.TdInfo.
And TdCall is responded by tdx-module which is trust.
So, from the security perspective we shall use TdCall.Tdinfo instead
of fw_cfg.
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
-rw-r--r-- | OvmfPkg/Library/PlatformInitLib/Platform.c | 15 | ||||
-rw-r--r-- | OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf | 2 | ||||
-rw-r--r-- | OvmfPkg/OvmfPkgIa32.dsc | 1 |
3 files changed, 16 insertions, 2 deletions
diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/PlatformInitLib/Platform.c index c2e0430d22..10fc17355f 100644 --- a/OvmfPkg/Library/PlatformInitLib/Platform.c +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c @@ -33,6 +33,7 @@ #include <Guid/SystemNvDataGuid.h>
#include <Guid/VariableFormat.h>
#include <OvmfPlatforms.h>
+#include <Library/TdxLib.h>
#include <Library/PlatformInitLib.h>
@@ -563,6 +564,20 @@ PlatformMaxCpuCountInitialization ( UINT16 BootCpuCount = 0;
UINT32 MaxCpuCount;
+ if (TdIsEnabled ()) {
+ BootCpuCount = (UINT16)TdVCpuNum ();
+ MaxCpuCount = TdMaxVCpuNum ();
+
+ if (BootCpuCount > MaxCpuCount) {
+ DEBUG ((DEBUG_ERROR, "%a: Failed with BootCpuCount (%d) more than MaxCpuCount(%u) \n", __func__, BootCpuCount, MaxCpuCount));
+ ASSERT (FALSE);
+ }
+
+ PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber = MaxCpuCount;
+ PlatformInfoHob->PcdCpuBootLogicalProcessorNumber = BootCpuCount;
+ return;
+ }
+
//
// Try to fetch the boot CPU count.
//
diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf index e9c07467bb..3e63ef4423 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -53,8 +53,6 @@ PcdLib
PciLib
PeiHardwareInfoLib
-
-[LibraryClasses.X64]
TdxLib
[Guids]
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 5e2086eb33..34f7b9958b 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -251,6 +251,7 @@ AmdSvsmLib|UefiCpuPkg/Library/AmdSvsmLibNull/AmdSvsmLibNull.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
+ TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
TdxMailboxLib|OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
[LibraryClasses.common.SEC]
|