From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: star.zeng@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 10 Jul 2019 04:42:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2019 04:42:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,474,1557212400"; d="scan'208";a="166050223" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.38]) by fmsmga008.fm.intel.com with ESMTP; 10 Jul 2019 04:42:36 -0700 From: "Zeng, Star" To: devel@edk2.groups.io Cc: Star Zeng , Laszlo Ersek , Eric Dong , Ray Ni , Chandana Kumar , Kevin Li Subject: [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Fix an ASSERTION issue Date: Wed, 10 Jul 2019 19:42:36 +0800 Message-Id: <20190710114236.14800-1-star.zeng@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1968 We met assertion like below, it happens when there is only one processor. ASSERT_EFI_ERROR (Status = Not started) ASSERT [CpuFeaturesDxe] X:\XXX\XXX\RegisterCpuFeaturesLib\ DxeRegisterCpuFeaturesLib.c(149): !EFI_ERROR (Status) The code should not call StartupAllAPs when there is only one processor. Cc: Laszlo Ersek Cc: Eric Dong Cc: Ray Ni Cc: Chandana Kumar Cc: Kevin Li Signed-off-by: Star Zeng --- .../CpuFeaturesInitialize.c | 10 +++-- .../DxeRegisterCpuFeaturesLib.c | 43 +++++++++++-------- .../PeiRegisterCpuFeaturesLib.c | 11 +++-- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index aff7ad600cad..1746f4f07f7b 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -1071,10 +1071,12 @@ CpuFeaturesDetect ( CpuInitDataInitialize (); - // - // Wakeup all APs for data collection. - // - StartupAPsWorker (CollectProcessorData, NULL); + if (CpuFeaturesData->NumberOfCpus > 1) { + // + // Wakeup all APs for data collection. + // + StartupAPsWorker (CollectProcessorData, NULL); + } // // Collect data on BSP diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c index 9c78a2d993c4..ffd99046a6cd 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c @@ -229,31 +229,36 @@ CpuFeaturesInitialize ( OldBspNumber = GetProcessorIndex (CpuFeaturesData); CpuFeaturesData->BspNumber = OldBspNumber; - Status = gBS->CreateEvent ( - EVT_NOTIFY_WAIT, - TPL_CALLBACK, - EfiEventEmptyFunction, - NULL, - &MpEvent - ); - ASSERT_EFI_ERROR (Status); + if (CpuFeaturesData->NumberOfCpus > 1) { + Status = gBS->CreateEvent ( + EVT_NOTIFY_WAIT, + TPL_CALLBACK, + EfiEventEmptyFunction, + NULL, + &MpEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Wakeup all APs for programming. + // + StartupAPsWorker (SetProcessorRegister, MpEvent); + } - // - // Wakeup all APs for programming. - // - StartupAPsWorker (SetProcessorRegister, MpEvent); // // Programming BSP // SetProcessorRegister (CpuFeaturesData); - // - // Wait all processors to finish the task. - // - do { - Status = gBS->CheckEvent (MpEvent); - } while (Status == EFI_NOT_READY); - ASSERT_EFI_ERROR (Status); + if (CpuFeaturesData->NumberOfCpus > 1) { + // + // Wait all processors to finish the task. + // + do { + Status = gBS->CheckEvent (MpEvent); + } while (Status == EFI_NOT_READY); + ASSERT_EFI_ERROR (Status); + } // // Switch to new BSP if required diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c index 2b1553f9b84b..8ad5a40e5a44 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c @@ -273,10 +273,13 @@ CpuFeaturesInitialize ( // DXE type instance. // - // - // Wakeup all APs for programming. - // - StartupAPsWorker (SetProcessorRegister, NULL); + if (CpuFeaturesData->NumberOfCpus > 1) { + // + // Wakeup all APs for programming. + // + StartupAPsWorker (SetProcessorRegister, NULL); + } + // // Programming BSP // -- 2.21.0.windows.1