]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Fix potential spinLock issue in SmmStartupThisAp
authorDamian Nikodem <damian.nikodem@intel.com>
Wed, 11 Sep 2019 08:23:01 +0000 (16:23 +0800)
committerEric Dong <eric.dong@intel.com>
Fri, 20 Sep 2019 06:37:42 +0000 (14:37 +0800)
Due to needs a tackling the deficiency of the AP API, it's necessary to
ensure that in non-blocking mode previous AP executed command is
finished before starting new one.

To remedy above:
  1) execute AcquireSpinLock instead AcquireSpinLockOrFail - this will
     ensure time "window" to eliminate potential race condition between
     BSP and AP spinLock release in non-blocking mode.
     This also will eliminate possibility to start executing new AP
     function before last is finished.
  2) remove returns EFI_STATUS - EFI_NOT_READY - in new scenario returned
     status is not necessary to caller.

Signed-off-by: Damian Nikodem <damian.nikodem@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

index d8d2b6f44461220c7597d681b0cdbd03bef644ee..0685637c2b51bf3e883e6adfa9aa6291058bd374 100644 (file)
@@ -1235,14 +1235,9 @@ InternalSmmStartupThisAp (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Token == NULL) {\r
-    AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy);\r
-  } else {\r
-    if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy)) {\r
-      DEBUG((DEBUG_ERROR, "Can't acquire mSmmMpSyncData->CpuData[%d].Busy\n", CpuIndex));\r
-      return EFI_NOT_READY;\r
-    }\r
+  AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy);\r
 \r
+  if (Token != NULL) {\r
     *Token = (MM_COMPLETION) CreateToken ();\r
   }\r
 \r