public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Min Xu" <min.m.xu@intel.com>
To: devel@edk2.groups.io
Cc: Min Xu <min.m.xu@intel.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Erdem Aktas <erdemaktas@google.com>,
	James Bottomley <jejb@linux.ibm.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: [PATCH 1/1] UefiCpuPkg: Save PcdConfidentialComputingGuestAttr in mCcGuestAttr
Date: Fri, 29 Apr 2022 11:02:43 +0800	[thread overview]
Message-ID: <1bef66daa55f86bba85b78aec1aaec077d97d0a8.1651201263.git.min.m.xu@intel.com> (raw)
In-Reply-To: <cover.1651201263.git.min.m.xu@intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3918

There is an issue reported when booting multiple vCPU guests (regular
and SEV). This issues consist of EfiAcquireLock() / EfiReleaseLock()
ASSERTS and TPL level ASSERTS that occur during ExitBootServices when
the APs are being parked by RelocateApLoop(). The root cause is that
PCD accesses use locking which is not SMP safe.

To fix this issue PCD usage can be reduced to getting the
PcdConfidentialComputingGuestAttr value at init (MpInitLibInitialize)
and caching it in a STATIC variable (mCcGuestAttr).

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 91c7afaeb2ad..fb9247f58427 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -16,6 +16,7 @@
 #include <ConfidentialComputingGuestAttr.h>
 
 EFI_GUID  mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;
+UINT64    mCcGuestAttr         = 0;
 
 /**
   The function will check if BSP Execute Disable is enabled.
@@ -1805,7 +1806,9 @@ MpInitLibInitialize (
   UINTN                    BackupBufferAddr;
   UINTN                    ApIdtBase;
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  mCcGuestAttr = PcdGet64 (PcdConfidentialComputingGuestAttr);
+
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return EFI_SUCCESS;
   }
 
@@ -2079,7 +2082,7 @@ MpInitLibGetProcessorInfo (
   CPU_INFO_IN_HOB  *CpuInfoInHob;
   UINTN            OriginalProcessorNumber;
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return TdxMpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, HealthData);
   }
 
@@ -2177,7 +2180,7 @@ SwitchBSPWorker (
   BOOLEAN                      OldInterruptState;
   BOOLEAN                      OldTimerInterruptState;
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return EFI_UNSUPPORTED;
   }
 
@@ -2321,7 +2324,7 @@ EnableDisableApWorker (
   CPU_MP_DATA  *CpuMpData;
   UINTN        CallerNumber;
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return EFI_UNSUPPORTED;
   }
 
@@ -2385,7 +2388,7 @@ MpInitLibWhoAmI (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     *ProcessorNumber = 0;
     return EFI_SUCCESS;
   }
@@ -2432,7 +2435,7 @@ MpInitLibGetNumberOfProcessors (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return TdxMpInitLibGetNumberOfProcessors (NumberOfProcessors, NumberOfEnabledProcessors);
   }
 
@@ -2534,7 +2537,7 @@ StartupAllCPUsWorker (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     //
     // For Td guest ExcludeBsp must be FALSE. Otherwise it will return in above checks.
     //
@@ -2692,7 +2695,7 @@ StartupThisAPWorker (
   //
   // In Td guest, startup of AP is not supported in current stage.
   //
-  if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
+  if (CC_GUEST_IS_TDX (mCcGuestAttr)) {
     return EFI_UNSUPPORTED;
   }
 
-- 
2.29.2.windows.2


       reply	other threads:[~2022-04-29  3:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1651201263.git.min.m.xu@intel.com>
2022-04-29  3:02 ` Min Xu [this message]
2022-04-29  3:06   ` [PATCH 1/1] UefiCpuPkg: Save PcdConfidentialComputingGuestAttr in mCcGuestAttr Ni, Ray
2022-05-02  7:03     ` Min Xu
2022-05-05  1:41       ` [edk2-devel] " Ni, Ray
2022-05-05 14:30         ` Min Xu

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=1bef66daa55f86bba85b78aec1aaec077d97d0a8.1651201263.git.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