From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.1661.1579249639919439544 for ; Fri, 17 Jan 2020 00:27:20 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: ray.ni@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2020 00:24:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,329,1574150400"; d="scan'208";a="274296039" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by FMSMGA003.fm.intel.com with ESMTP; 17 Jan 2020 00:24:41 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Jan 2020 00:24:41 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 17 Jan 2020 00:24:41 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.197]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.89]) with mapi id 14.03.0439.000; Fri, 17 Jan 2020 16:24:39 +0800 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Wu, Hao A" CC: "Dong, Eric" , Laszlo Ersek , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible uninitialized 'InitFlag' field Thread-Topic: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible uninitialized 'InitFlag' field Thread-Index: AQHVzQNK4ol9pYqllEGlR2uXf9ikzKfuhJsw Date: Fri, 17 Jan 2020 08:24:38 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C3F82C9@SHSMSX104.ccr.corp.intel.com> References: <20200117065638.9176-1-hao.a.wu@intel.com> In-Reply-To: <20200117065638.9176-1-hao.a.wu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, Hao > A > Sent: Friday, January 17, 2020 2:57 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Dong, Eric ; Ni= , > Ray ; Laszlo Ersek ; Kinney, Michae= l > D > Subject: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible > uninitialized 'InitFlag' field >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2474 >=20 > Previous commit d786a17232: > UefiCpuPkg/MpInitLib: Reduce the size when loading microcode patches >=20 > 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: >=20 > CpuMpData->InitFlag =3D ApInitReconfig; > ... > CpuMpData->InitFlag =3D ApInitDone; >=20 > 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 inval= id > value for the type of 'InitFlag' (AP_INIT_STATE). >=20 > It may potentially cause the WakeUpAP() function to run some unnecessary > codes when the APs have been successfully waken up before: >=20 > if (CpuMpData->WakeUpByInitSipiSipi || > CpuMpData->InitFlag !=3D ApInitDone) { > ResetVectorRequired =3D TRUE; > AllocateResetVector (CpuMpData); > FillExchangeInfoData (CpuMpData); > SaveLocalApicTimerSetting (CpuMpData); > } >=20 > This commit will address the above-mentioned issue. >=20 > Test done: > * OS boot on a real platform with multi processors >=20 > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Michael D Kinney > Signed-off-by: Hao A Wu > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c > b/UefiCpuPkg/Library/MpInitLib/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); > } > -- > 2.12.0.windows.1 >=20 >=20 >=20