From: "Min Xu" <min.m.xu@intel.com>
To: devel@edk2.groups.io
Cc: Min M Xu <min.m.xu@intel.com>,
Erdem Aktas <erdemaktas@google.com>,
Gerd Hoffmann <kraxel@redhat.com>,
James Bottomley <jejb@linux.ibm.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: [PATCH V2 1/6] OvmfPkg/TdxMailboxLib: Delete global variables
Date: Tue, 20 Dec 2022 16:42:35 +0800 [thread overview]
Message-ID: <20221220084240.1922-2-min.m.xu@intel.com> (raw)
In-Reply-To: <20221220084240.1922-1-min.m.xu@intel.com>
From: Min M Xu <min.m.xu@intel.com>
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>
---
OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c b/OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c
index 74cb55611fe3..c580a2885603 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);
}
/**
--
2.29.2.windows.2
next prev parent reply other threads:[~2022-12-20 8:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 8:42 [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF Min Xu
2022-12-20 8:42 ` Min Xu [this message]
2022-12-20 8:42 ` [PATCH V2 2/6] OvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib Min Xu
2022-12-20 8:42 ` [PATCH V2 3/6] OvmfPkg: Add TdxMailboxLibNull in some platform dsc Min Xu
2022-12-20 8:42 ` [PATCH V2 4/6] OvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm Min Xu
2022-12-20 8:42 ` [PATCH V2 5/6] OvmfPkg: Enable APs to accept memory for TDVF Min Xu
2022-12-20 8:42 ` [PATCH V2 6/6] OvmfPkg/PlatformInitLib: Implement multi-core " Min Xu
2022-12-21 8:07 ` [PATCH V2 0/6] Enable Multi-core based lazy-accept " Yao, Jiewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221220084240.1922-2-min.m.xu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox