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 #include #include -#include #include #include #include -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); } /**