diff options
author | Min M Xu <min.m.xu@intel.com> | 2022-12-20 16:42:35 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-12-21 07:06:17 +0000 |
commit | a00b71b009a60947fec8ace0ac56ab2ece887d97 (patch) | |
tree | d0bed948c8f5f13f591838547fb267a770c73b59 /OvmfPkg/Library/TdxMailboxLib | |
parent | b2d76fdd421b5081c2e03ae46079ccf8ecc045fe (diff) | |
download | edk2-a00b71b009a60947fec8ace0ac56ab2ece887d97.tar.gz edk2-a00b71b009a60947fec8ace0ac56ab2ece887d97.tar.bz2 edk2-a00b71b009a60947fec8ace0ac56ab2ece887d97.zip |
OvmfPkg/TdxMailboxLib: Delete global variables
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4172
TdxMailboxLib once was designed to be used in DXE phase. But now it is
going to be used in SEC/PEI phase (in the following patches). Global
variables are not allowed. The library is refactored after those global
variables are deleted.
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg/Library/TdxMailboxLib')
-rw-r--r-- | OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c b/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c index 74cb55611f..c580a28856 100644 --- a/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c +++ b/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c @@ -13,14 +13,10 @@ #include <Library/UefiCpuLib.h>
#include <Library/SynchronizationLib.h>
#include <Uefi/UefiBaseType.h>
-#include <Library/TdxLib.h>
#include <IndustryStandard/IntelTdx.h>
#include <IndustryStandard/Tdx.h>
#include <Library/TdxMailboxLib.h>
-volatile VOID *mMailBox = NULL;
-UINT32 mNumOfCpus = 0;
-
/**
This function will be called by BSP to get the CPU number.
@@ -32,11 +28,17 @@ GetCpusNum ( VOID
)
{
- if (mNumOfCpus == 0) {
- mNumOfCpus = TdVCpuNum ();
+ UINT64 Status;
+ TD_RETURN_DATA TdReturnData;
+
+ Status = TdCall (TDCALL_TDINFO, 0, 0, 0, &TdReturnData);
+ if (Status == TDX_EXIT_REASON_SUCCESS) {
+ return TdReturnData.TdInfo.NumVcpus;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Failed call TDCALL_TDINFO. %llx\n", Status));
}
- return mNumOfCpus;
+ return 0;
}
/**
@@ -48,11 +50,7 @@ GetTdxMailBox ( VOID
)
{
- if (mMailBox == NULL) {
- mMailBox = (VOID *)(UINTN)PcdGet32 (PcdOvmfSecGhcbBackupBase);
- }
-
- return mMailBox;
+ return (VOID *)(UINTN)PcdGet32 (PcdOvmfSecGhcbBackupBase);
}
/**
|