UefiCpuPkg: Implements SmmCpuSyncLib library instance

Implements SmmCpuSyncLib Library instance. The instance refers the
existing SMM CPU driver (PiSmmCpuDxeSmm) sync implementation
and behavior:
1.Abstract Counter and Run semaphores into SmmCpuSyncCtx.
2.Abstract CPU arrival count operation to
SmmCpuSyncGetArrivedCpuCount(), SmmCpuSyncCheckInCpu(),
SmmCpuSyncCheckOutCpu(), SmmCpuSyncLockDoor().
Implementation is aligned with existing SMM CPU driver.
3. Abstract SMM CPU Sync flow to:
BSP: SmmCpuSyncReleaseOneAp  -->  AP: SmmCpuSyncWaitForBsp
BSP: SmmCpuSyncWaitForAPs    <--  AP: SmmCpuSyncReleaseBsp
Semaphores release & wait during sync flow is same as existing SMM
CPU driver.
4.Same operation to Counter and Run semaphores by leverage the atomic
compare exchange.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Jiaxin Wu
2023-11-30 11:12:54 +08:00
committed by mergify[bot]
parent 6f6a43cc8e
commit 69eb9ad4a1
3 changed files with 688 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
## @file
# SMM CPU Synchronization lib.
#
# This is SMM CPU Synchronization lib used for SMM CPU sync operations.
#
# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SmmCpuSyncLib
FILE_GUID = 1ca1bc1a-16a4-46ef-956a-ca500fd3381f
MODULE_TYPE = DXE_SMM_DRIVER
LIBRARY_CLASS = SmmCpuSyncLib|DXE_SMM_DRIVER
[Sources]
SmmCpuSyncLib.c
[Packages]
MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
DebugLib
MemoryAllocationLib
SafeIntLib
SynchronizationLib
[Pcd]
[Protocols]