From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.5839.1651201379396253939 for ; Thu, 28 Apr 2022 20:03:00 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=gTAbeAKG; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651201379; x=1682737379; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6+7gtnnjezYX1mLm6V6G/svegvkx0WFvMwl7Zm51VFw=; b=gTAbeAKGq+uf3xhCT9ZdwUCsTT5aPXoZ8kkjnU3Kkfs4/MVfhYZf//W+ wY74BKTwIN+nQGCjxLm3tW1pzX1AtUSrO8TRUcJe4Qs55ksnlmLEzVehr TlSHtX9hgmz0kT/FvgzktxAU7opikegeDuvOFJ2rwjuwDmxO+u+jMrQ63 2S0c9zHd4w980GShnLuPOk4yBm/JlC4gabJ+GVra+MVif7z+sgamiY0Bd aEskzNraAP72zSmDnnFQaYiV6EZb0ugMP3bHsw++pIJkEv6+2+PnjF+/i hygSCqzc1olHKNYIndZ38mrJmsUuzF9zrWuHBfegzEEb2mJ4nZHCQsuhJ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="352939442" X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="352939442" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2022 20:02:58 -0700 X-IronPort-AV: E=Sophos;i="5.91,297,1647327600"; d="scan'208";a="581815272" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.170.245]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2022 20:02:55 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Eric Dong , Ray Ni Subject: [PATCH 1/1] UefiCpuPkg: Save PcdConfidentialComputingGuestAttr in mCcGuestAttr Date: Fri, 29 Apr 2022 11:02:43 +0800 Message-Id: <1bef66daa55f86bba85b78aec1aaec077d97d0a8.1651201263.git.min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni Signed-off-by: Min Xu --- 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 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