[edk2-devel] [PATCH v3 4/5] UefiCpuPkg/SmmCpuFeaturesLib: Abstract PcdCpuMaxLogicalProcessorNumber

Laszlo Ersek lersek at redhat.com
Fri Feb 19 20:43:26 UTC 2021


On 02/17/21 22:32, mikuback at linux.microsoft.com wrote:
> From: Michael Kubacki <michael.kubacki at microsoft.com>
> 
> 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 <eric.dong at intel.com>
> Cc: Ray Ni <ray.ni at intel.com>
> Cc: Laszlo Ersek <lersek at redhat.com>
> Cc: Rahul Kumar <rahul1.kumar at intel.com>
> Signed-off-by: Michael Kubacki <michael.kubacki at microsoft.com>
> Reviewed-by: Laszlo Ersek <lersek at redhat.com>
> ---
>  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(-)

Looks good, thanks.
Laszlo

> 
> 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 = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
> +  mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLogicalProcessorNumber ());
>    ASSERT (mSmrrEnabled != NULL);
>  }
>  
> diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/TraditionalMmCpuFeaturesLib.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.<BR>
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Base.h>
> +#include <Library/PcdLib.h>
> +#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);
> +}
> diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCpuPkg/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
>    );
>  
> +/**
> +  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 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
>  
>  [Packages]
>    MdePkg/MdePkg.dec
> diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf 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
>  
>  [Sources.Ia32]
>    Ia32/SmmStmSupport.c
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71857): https://edk2.groups.io/g/devel/message/71857
Mute This Topic: https://groups.io/mt/80715271/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list