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>
This commit is contained in:
Ceping Sun 2024-08-29 07:34:47 +08:00 committed by mergify[bot]
parent 262ab6259f
commit ec18fa81d3
3 changed files with 16 additions and 2 deletions

View File

@ -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.
//

View File

@ -53,8 +53,6 @@
PcdLib
PciLib
PeiHardwareInfoLib
[LibraryClasses.X64]
TdxLib
[Guids]

View File

@ -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]