audk/UefiCpuPkg/PiSmmCpuDxeSmm
Laszlo Ersek bb767506b2 UefiCpuPkg/PiSmmCpuDxeSmm: handle dynamic PcdCpuMaxLogicalProcessorNumber
"UefiCpuPkg/UefiCpuPkg.dec" already allows platforms to make
PcdCpuMaxLogicalProcessorNumber dynamic, however PiSmmCpuDxeSmm does not
take this into account everywhere. As soon as a platform turns the PCD
into a dynamic one, at least S3 fails. When the PCD is dynamic, all
PcdGet() calls translate into PCD DXE protocol calls, which are only
permitted at boot time, not at runtime or during S3 resume.

We already have a variable called mMaxNumberOfCpus; it is initialized in
the entry point function like this:

> //
> // If support CPU hot plug, we need to allocate resources for possibly
> // hot-added processors
> //
> if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
>   mMaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
> } else {
>   mMaxNumberOfCpus = mNumberOfCpus;
> }

There's another use of the PCD a bit higher up, also in the entry point
function:

> //
> // Use MP Services Protocol to retrieve the number of processors and
> // number of enabled processors
> //
> Status = MpServices->GetNumberOfProcessors (MpServices, &mNumberOfCpus,
>                        &NumberOfEnabledProcessors);
> ASSERT_EFI_ERROR (Status);
> ASSERT (mNumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));

Preserve these calls in the entry point function, and replace all other
uses of PcdCpuMaxLogicalProcessorNumber -- there are only reads -- with
mMaxNumberOfCpus.

For PcdCpuHotPlugSupport==TRUE, this is an unobservable change.

For PcdCpuHotPlugSupport==FALSE, we even save SMRAM, because we no longer
allocate resources needlessly for CPUs that can never appear in the
system.

PcdCpuMaxLogicalProcessorNumber is also retrieved in
"UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c",  but only in
the library instance constructor, which runs even before the entry point
function is called.

Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=116
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2016-11-28 12:19:40 +01:00
..
Ia32 UefiCpuPkg/PiSmmCpu: Correct exception message. 2016-11-24 10:51:16 +08:00
X64 UefiCpuPkg/PiSmmCpu: Correct exception message. 2016-11-24 10:51:16 +08:00
CpuS3.c UefiCpuPkg/PiSmmCpuDxeSmm: Add volatile to mNumberToFinish 2016-11-17 17:37:50 -08:00
CpuService.c UefiCpuPkg/LocalApicLib: Rename GetProcessorLocation() 2016-11-02 09:16:21 +08:00
CpuService.h UefiCpuPkg: Add PiSmmCpuDxeSmm module no IA32/X64 files 2015-10-19 19:12:53 +00:00
MpService.c UefiCpuPkg/PiSmmCpuDxeSmm: dynamic PcdCpuSmmApSyncTimeout, PcdCpuSmmSyncMode 2016-11-22 09:02:54 +01:00
PiSmmCpuDxeSmm.c UefiCpuPkg/PiSmmCpuDxeSmm: handle dynamic PcdCpuMaxLogicalProcessorNumber 2016-11-28 12:19:40 +01:00
PiSmmCpuDxeSmm.h UefiCpuPkg/PiSmmCpuDxeSmm: TransferApToSafeState() use UINTN params 2016-11-17 17:37:50 -08:00
PiSmmCpuDxeSmm.inf UefiCpuPkg/PiSmmCpuDxeSmm: Add paging protection. 2016-11-17 16:30:07 +08:00
PiSmmCpuDxeSmm.uni UefiCpuPkg: Convert all .uni files to utf-8 2015-12-15 04:59:14 +00:00
PiSmmCpuDxeSmmExtra.uni UefiCpuPkg: Convert all .uni files to utf-8 2015-12-15 04:59:14 +00:00
SmmCpuMemoryManagement.c UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX. 2016-11-18 10:53:59 +08:00
SmmProfile.c UefiCpuPkg/PiSmmCpuDxeSmm: handle dynamic PcdCpuMaxLogicalProcessorNumber 2016-11-28 12:19:40 +01:00
SmmProfile.h UefiCpuPkg/PiSmmCpu: Correct exception message. 2016-11-24 10:51:16 +08:00
SmmProfileInternal.h UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile: Remove unnecessary BTS MSRs 2016-05-16 10:40:18 -07:00
SmramSaveState.c UefiCpuPkg: Add PiSmmCpuDxeSmm module no IA32/X64 files 2015-10-19 19:12:53 +00:00
SyncTimer.c UefiCpuPkg: Add PiSmmCpuDxeSmm module no IA32/X64 files 2015-10-19 19:12:53 +00:00