From: Eric Dong Date: Thu, 20 Dec 2018 01:15:51 +0000 (+0800) Subject: UefiCpuPkg/RegisterCpuFeaturesLib: Replace AcquireSpinLock. X-Git-Tag: edk2-stable201903~358 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=eb98fe2ae18d46a0f1c5bc35e79e3d429fadc9f5 UefiCpuPkg/RegisterCpuFeaturesLib: Replace AcquireSpinLock. In AcquireSpinLock function, it may call GetPerformanceCounter which final calls PeiService table. This code may also been used by AP but AP should not calls PeiService. This patch update code to avoid use AcquireSpinLock function. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1411 Cc: Ruiyu Ni Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong Reviewed-by: Ray Ni --- diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 269af052b1..bae92b89a6 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -1,7 +1,7 @@ /** @file CPU Features Initialize functions. - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -841,7 +841,12 @@ ProgramProcessorRegister ( RegisterTableEntry = &RegisterTableEntryHead[Index]; DEBUG_CODE_BEGIN (); - AcquireSpinLock (&CpuFlags->ConsoleLogLock); + // + // Wait for the AP to release the MSR spin lock. + // + while (!AcquireSpinLockOrFail (&CpuFlags->ConsoleLogLock)) { + CpuPause (); + } ThreadIndex = ApLocation->Package * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount + ApLocation->Core * CpuStatus->MaxThreadCount + ApLocation->Thread;