mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
b2d76fdd42
commit
a00b71b009
|
@ -13,14 +13,10 @@
|
||||||
#include <Library/UefiCpuLib.h>
|
#include <Library/UefiCpuLib.h>
|
||||||
#include <Library/SynchronizationLib.h>
|
#include <Library/SynchronizationLib.h>
|
||||||
#include <Uefi/UefiBaseType.h>
|
#include <Uefi/UefiBaseType.h>
|
||||||
#include <Library/TdxLib.h>
|
|
||||||
#include <IndustryStandard/IntelTdx.h>
|
#include <IndustryStandard/IntelTdx.h>
|
||||||
#include <IndustryStandard/Tdx.h>
|
#include <IndustryStandard/Tdx.h>
|
||||||
#include <Library/TdxMailboxLib.h>
|
#include <Library/TdxMailboxLib.h>
|
||||||
|
|
||||||
volatile VOID *mMailBox = NULL;
|
|
||||||
UINT32 mNumOfCpus = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function will be called by BSP to get the CPU number.
|
This function will be called by BSP to get the CPU number.
|
||||||
|
|
||||||
|
@ -32,11 +28,17 @@ GetCpusNum (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mNumOfCpus == 0) {
|
UINT64 Status;
|
||||||
mNumOfCpus = TdVCpuNum ();
|
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
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mMailBox == NULL) {
|
return (VOID *)(UINTN)PcdGet32 (PcdOvmfSecGhcbBackupBase);
|
||||||
mMailBox = (VOID *)(UINTN)PcdGet32 (PcdOvmfSecGhcbBackupBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMailBox;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue