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.web08.991.1613177916962313763 for ; Fri, 12 Feb 2021 16:58:37 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=SZKt1NpO; 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 A218520B57A0; Fri, 12 Feb 2021 16:58:36 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A218520B57A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1613177916; bh=nPcUXTRO3d9ad6BX85oSKKIJglmdThFnroeME2Z8y9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZKt1NpOLarmfPozTm86JfAYfxvlYZG+aaQF1NzbJH0I2WG3Lm6gaAaNnNjO82KOK mVdrecmNcH3nTcFYkBV3OceSpRds8ilg9YzUh/fV/hVDDcvjZKy9E0ChUlez4ywaX5 NlYXcAGrCCJrQ8KClyYHPhm45DlZhQKy+Ft8OShM= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v2 3/4] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber Date: Fri, 12 Feb 2021 16:58:05 -0800 Message-Id: <20210213005806.2927-4-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210213005806.2927-1-mikuback@linux.microsoft.com> References: <20210213005806.2927-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 --- UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.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/SmmCpuFeaturesLib.c b/U= efiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index e74f87f3f266..a494988898b8 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.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..6a4eff755d92 --- /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. + + @retval 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..1a72ba4e2e13 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. + + @retval The value of PcdCpuMaxLogicalProcessorNumber. + +**/ +UINT32 +GetCpuMaxLogicalProcessorNumber ( + VOID + ); + #endif diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b= /UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index a6d8467d26aa..b32dbeab9383 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -20,6 +20,7 @@ [Sources] CpuFeaturesLib.h SmmCpuFeaturesLib.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 89cd252ef44e..f72ef0a88088 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -22,6 +22,7 @@ [Sources] SmmCpuFeaturesLib.c SmmStm.c SmmStm.h + TraditionalMmCpuFeaturesLib.c =20 [Sources.Ia32] Ia32/SmmStmSupport.c --=20 2.28.0.windows.1