From e542e05d4fc2e4aeae752db5d429e2f4650cd5ee Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Wed, 17 Feb 2021 13:32:26 -0800 Subject: [PATCH] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3218 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 Message-Id: <20210217213227.1277-5-mikuback@linux.microsoft.com> Reviewed-by: Eric Dong --- .../SmmCpuFeaturesLib/CpuFeaturesLib.h | 14 ++++++++++ .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 + .../SmmCpuFeaturesLibCommon.c | 2 +- .../SmmCpuFeaturesLibStm.inf | 1 + .../TraditionalMmCpuFeaturesLib.c | 28 +++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h index c18521fd9c..8a1c2adc5c 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h @@ -31,4 +31,18 @@ FinishSmmCpuFeaturesInitializeProcessor ( VOID ); +/** + Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber. + + This access is abstracted from the PCD services to enforce that the PCD 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 ddd00eeceb..35292dac31 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -21,6 +21,7 @@ SmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c + TraditionalMmCpuFeaturesLib.c [Packages] MdePkg/MdePkg.dec diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c index 7a919c5ee7..50379f3aea 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 = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); + mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLogicalProcessorNumber ()); ASSERT (mSmrrEnabled != NULL); } diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf index 78f8e4b42c..022351f593 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -22,6 +22,7 @@ SmmCpuFeaturesLibCommon.c SmmStm.c SmmStm.h + TraditionalMmCpuFeaturesLib.c [Sources.Ia32] Ia32/SmmStmSupport.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.c new file mode 100644 index 0000000000..b7a5c1926e --- /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 PcdCpuMaxLogicalProcessorNumber. + + This access is abstracted from the PCD services to enforce that the PCD be + FixedAtBuild in the Standalone MM build of this driver. + + @return The value of PcdCpuMaxLogicalProcessorNumber. + +**/ +UINT32 +GetCpuMaxLogicalProcessorNumber ( + VOID + ) +{ + return PcdGet32 (PcdCpuMaxLogicalProcessorNumber); +}