From nobody Thu May 2 18:51:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53344+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53344+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579244205; cv=none; d=zohomail.com; s=zohoarc; b=Dxw9ap62yHi0WNtIqf4STkXBdXqTQZK/6NZe6zhMachIoAicVTqZhLkSFATqIeHxixqC3BXk5MnY7IH6sPG1Qr/TLFLmr6+T1xIcYkLegiyjkbxBzxIV3k3L30xp9KPcQIcyZChnJStPIpjHNAn1H8ZZNqqU3c23PB7JUfCHWHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579244205; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=wJBBxdJJ0+R5GWiain5luTH49/nDV8ULfX9Xo+YUxEc=; b=hf/uFC0//GV3sGJ5yLgOxJ99VW1LtYUv0KnpGNzAtdyqTkpRc2Ios8V9bo2bR+brUAmB/KBjfMZxFmlI4dBaUq6nTXHjqjEM2K6UklVVXU+mEkdFc9uvpuLHJm01G9WhbGsOIFu1+Jyrwrm4QIgmaSgfkBOMajU73Fhfk77cbCc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53344+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579244205811937.3946360400357; Thu, 16 Jan 2020 22:56:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id k7kQYY1788612xP4dlJnbFNW; Thu, 16 Jan 2020 22:56:44 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.996.1579244203527997062 for ; Thu, 16 Jan 2020 22:56:43 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 22:56:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,329,1574150400"; d="scan'208";a="373569726" X-Received: from unknown (HELO SHWDEOPENPSI014.ccr.corp.intel.com) ([10.239.9.8]) by orsmga004.jf.intel.com with ESMTP; 16 Jan 2020 22:56:40 -0800 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Ray Ni , Laszlo Ersek , Michael D Kinney Subject: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible uninitialized 'InitFlag' field Date: Fri, 17 Jan 2020 14:56:38 +0800 Message-Id: <20200117065638.9176-1-hao.a.wu@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,hao.a.wu@intel.com X-Gm-Message-State: 4smm58rvhqvG051UDJ1dGHCcx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579244204; bh=Ul6MZDmADP8Tq09cWrxNq6s/e2qwTaq4DtSW9TAj1tk=; h=Cc:Date:From:Reply-To:Subject:To; b=j3BnyL1UxmA+BL1bgc5LJT0Ynni+uassCiS6IXJnMyWKER9yuF3bbz8UMbAN2V02XSx RXS3G4yceQPJtAImNj9lJJfk4HRk3eg1TPrOXitXMt8mmHlT0jgRuOGYtsYfKfJuHziDN jmPSUL5B+q+khgIPDhJ3mtw/WTvKUc9uThk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2474 Previous commit d786a17232: UefiCpuPkg/MpInitLib: Reduce the size when loading microcode patches Removed the below assignments for the 'InitFlag' field of CPU_MP_DATA structure in function MpInitLibInitialize() when APs are waken up to do some initialize sync: CpuMpData->InitFlag =3D ApInitReconfig; ... CpuMpData->InitFlag =3D ApInitDone; Under some cases (e.g. when variable OldCpuMpData is not NULL, which means function CollectProcessorCount() will not be called), this will left the 'InitFlag' field being uninitialized with a value of 0, which is a invalid value for the type of 'InitFlag' (AP_INIT_STATE). It may potentially cause the WakeUpAP() function to run some unnecessary codes when the APs have been successfully waken up before: if (CpuMpData->WakeUpByInitSipiSipi || CpuMpData->InitFlag !=3D ApInitDone) { ResetVectorRequired =3D TRUE; AllocateResetVector (CpuMpData); FillExchangeInfoData (CpuMpData); SaveLocalApicTimerSetting (CpuMpData); } This commit will address the above-mentioned issue. Test done: * OS boot on a real platform with multi processors Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Michael D Kinney Signed-off-by: Hao A Wu Reviewed-by: Ray Ni --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 6ec9b172b8..17e19395f2 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1775,11 +1775,12 @@ MpInitLibInitialize ( // Wakeup APs to do some AP initialize sync (Microcode & MTRR) // if (CpuMpData->CpuCount > 1) { + CpuMpData->InitFlag =3D ApInitReconfig; WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { CpuPause (); } - + CpuMpData->InitFlag =3D ApInitDone; for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); } --=20 2.12.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53344): https://edk2.groups.io/g/devel/message/53344 Mute This Topic: https://groups.io/mt/69838817/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-