]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/RegisterCpuFeaturesLib: Replace AcquireSpinLock.
authorEric Dong <eric.dong@intel.com>
Thu, 20 Dec 2018 01:15:51 +0000 (09:15 +0800)
committerEric Dong <eric.dong@intel.com>
Tue, 15 Jan 2019 05:27:37 +0000 (13:27 +0800)
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>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c

index 269af052b160fb9317aa8a5bdc3bcb8b6ae6487b..bae92b89a655cd817d81b98045547cddce7e8e82 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Features Initialize functions.\r
 \r
-  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -841,7 +841,12 @@ ProgramProcessorRegister (
     RegisterTableEntry = &RegisterTableEntryHead[Index];\r
 \r
     DEBUG_CODE_BEGIN ();\r
-      AcquireSpinLock (&CpuFlags->ConsoleLogLock);\r
+      //\r
+      // Wait for the AP to release the MSR spin lock.\r
+      //\r
+      while (!AcquireSpinLockOrFail (&CpuFlags->ConsoleLogLock)) {\r
+        CpuPause ();\r
+      }\r
       ThreadIndex = ApLocation->Package * CpuStatus->MaxCoreCount * CpuStatus->MaxThreadCount +\r
               ApLocation->Core * CpuStatus->MaxThreadCount +\r
               ApLocation->Thread;\r