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 <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Eric Dong 2018-12-20 09:15:51 +08:00
parent 306a58365a
commit eb98fe2ae1
1 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
CPU Features Initialize functions. CPU Features Initialize functions.
Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -841,7 +841,12 @@ ProgramProcessorRegister (
RegisterTableEntry = &RegisterTableEntryHead[Index]; RegisterTableEntry = &RegisterTableEntryHead[Index];
DEBUG_CODE_BEGIN (); 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 + ThreadIndex = ApLocation->Package * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount +
ApLocation->Core * CpuStatus->MaxThreadCount + ApLocation->Core * CpuStatus->MaxThreadCount +
ApLocation->Thread; ApLocation->Thread;