From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web09.599.1613597605493580068 for ; Wed, 17 Feb 2021 13:33:25 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=nkxuWNLa; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [131.107.174.202]) by linux.microsoft.com (Postfix) with ESMTPSA id 3F92320B6C40; Wed, 17 Feb 2021 13:33:25 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3F92320B6C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613597605; bh=vnhK3Mr3/61xz+SJJCIxwy+90CEq2DY9ylJkBL19V30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkxuWNLaYv9m4gYKrXoD+SV3kGpmmDlRKaEDl4kux1lyKtVOx+L/nBUEA33DC5sk6 dJFgYFI7hQUkGsPBvlpXf0yk+mcb5ySCKtUwmFuBA3pIDvWWAxtzaizOl6/z/GVZEe cFaqnRcBc9mb2cJSk5rM/8YTM4r5Y0jccDCjvmRE= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber Date: Wed, 17 Feb 2021 13:32:26 -0800 Message-Id: <20210217213227.1277-5-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210217213227.1277-1-mikuback@linux.microsoft.com> References: <20210217213227.1277-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3218 Adds a new function called GetCpuMaxLogicalProcessorNumber() to return the number of maximum CPU logical processors (currently gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber). This allows the the mechanism used to retrieve the CPU maximum logical processor number to be abstracted from the logic that needs the value. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Signed-off-by: Michael Kubacki Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c | 2 = +- UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c | 28 = ++++++++++++++++++++ UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h | 14 = ++++++++++ UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 = + UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf | 1 = + 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon= .c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c index 7a919c5ee70f..50379f3aea19 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c @@ -157,7 +157,7 @@ CpuFeaturesLibInitialization ( // // Allocate array for state of SMRR enable on all CPUs // - mSmrrEnabled =3D (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 = (PcdCpuMaxLogicalProcessorNumber)); + mSmrrEnabled =3D (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMax= LogicalProcessorNumber ()); ASSERT (mSmrrEnabled !=3D NULL); } =20 diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeature= sLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib= .c new file mode 100644 index 000000000000..b7a5c1926e4d --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c @@ -0,0 +1,28 @@ +/** @file + Traditional MM CPU specific programming. + + Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include "CpuFeaturesLib.h" + +/** + Gets the maximum number of logical processors from the PCD PcdCpuMaxLo= gicalProcessorNumber. + + This access is abstracted from the PCD services to enforce that the PC= D be + FixedAtBuild in the Standalone MM build of this driver. + + @return The value of PcdCpuMaxLogicalProcessorNumber. + +**/ +UINT32 +GetCpuMaxLogicalProcessorNumber ( + VOID + ) +{ + return PcdGet32 (PcdCpuMaxLogicalProcessorNumber); +} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/Uefi= CpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h index f9a758e82558..2b6bfa899a48 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h @@ -31,4 +31,18 @@ FinishSmmCpuFeaturesInitializeProcessor ( VOID ); =20 +/** + Gets the maximum number of logical processors from the PCD PcdCpuMaxLo= gicalProcessorNumber. + + This access is abstracted from the PCD services to enforce that the PC= D be + FixedAtBuild in the Standalone MM build of this driver. + + @return The value of PcdCpuMaxLogicalProcessorNumber. + +**/ +UINT32 +GetCpuMaxLogicalProcessorNumber ( + VOID + ); + #endif diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b= /UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index ddd00eeceb84..35292dac31ba 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -21,6 +21,7 @@ [Sources] SmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c + TraditionalMmCpuFeaturesLib.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.in= f b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf index 78f8e4b42c44..022351f59320 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -22,6 +22,7 @@ [Sources] SmmCpuFeaturesLibCommon.c SmmStm.c SmmStm.h + TraditionalMmCpuFeaturesLib.c =20 [Sources.Ia32] Ia32/SmmStmSupport.c --=20 2.28.0.windows.1