From 832c4c7ad6109847b2e7fdcca6bf539106523c61 Mon Sep 17 00:00:00 2001 From: Damian Nikodem Date: Wed, 11 Sep 2019 16:23:01 +0800 Subject: [PATCH] UefiCpuPkg: Fix potential spinLock issue in SmmStartupThisAp 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 Reviewed-by: Eric Dong Reviewed-by: Ray Ni Cc: Benjamin You Cc: Laszlo Ersek Cc: Krzysztof Rusocki --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index d8d2b6f444..0685637c2b 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1235,14 +1235,9 @@ InternalSmmStartupThisAp ( return EFI_INVALID_PARAMETER; } - if (Token == NULL) { - AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); - } else { - if (!AcquireSpinLockOrFail (mSmmMpSyncData->CpuData[CpuIndex].Busy)) { - DEBUG((DEBUG_ERROR, "Can't acquire mSmmMpSyncData->CpuData[%d].Busy\n", CpuIndex)); - return EFI_NOT_READY; - } + AcquireSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy); + if (Token != NULL) { *Token = (MM_COMPLETION) CreateToken (); }