audk/UefiCpuPkg/Library/MpInitLib
Ray Ni c6be6dab9c UefiCpuPkg/MpInitLib: Don't increase CpuCount in ApWakeupFunction
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3179

When BSP first time wakes all APs, each AP atomically increases
CpuMpData->CpuCount and CpuMpData->FinishedCount.

Each AP atomically increases CpuMpData->NumApsExecuting
in early assembly code and decreases it before it enters to HLT or
MWAIT state.

Putting them together, the 3 variables are changed in the following order:
1. NumApsExecuting++ // in assembly
2. CpuCpunt++
4. FinishedCount++
3. NumApsExecuting-- // in C

BSP waits for a certain timeout and then polls NumApsExecuting
until it drops to zero. It assumes all APs are waken up concurrently
and NumApsExecuting only drops to zero when all APs have checked in.

Then it additionally waits for FinishedCount == CpuCount - 1. (FinishedCount doesn't include BSP while CpuCount includes BSP.)

There is no need to additionally wait for
FinishedCount == CpuCount - 1 because when NumApsExecuting == 0,
the number of increament of FinishedCount and CpuCount should equal.

This patch simplifies the code to remove "CpuCount++" in
ApWakeupFunction() and
assigns FinishedCount + 1 to CpuCount after WakeUpAP().

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2021-01-29 03:09:35 +00:00
..
Ia32 UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use 2020-08-17 02:46:39 +00:00
X64 UefiCpuPkg/MpInitLib: Fix a hang in above 4GB case 2021-01-12 06:35:30 +00:00
DxeMpInitLib.inf UefiCpuPkg: Allow AP booting under SEV-ES 2020-08-17 02:46:39 +00:00
DxeMpInitLib.uni UefiCpuPkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:28 -07:00
DxeMpLib.c UefiCpuPkg, OvmfPkg: Disable interrupts when using the GHCB 2020-11-10 19:07:55 +00:00
Microcode.c UefiCpuPkg: Remove FIT based microcode shadow logic from MpInitLib. 2020-02-14 04:31:18 +00:00
MpLib.c UefiCpuPkg/MpInitLib: Don't increase CpuCount in ApWakeupFunction 2021-01-29 03:09:35 +00:00
MpLib.h UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use 2020-08-17 02:46:39 +00:00
PeiMpInitLib.inf UefiCpuPkg: Allow AP booting under SEV-ES 2020-08-17 02:46:39 +00:00
PeiMpInitLib.uni UefiCpuPkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:28 -07:00
PeiMpLib.c UefiCpuPkg: Allow AP booting under SEV-ES 2020-08-17 02:46:39 +00:00