public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Wu, Hao A" <hao.a.wu@intel.com>
Cc: "Dong, Eric" <eric.dong@intel.com>,
	Laszlo Ersek <lersek@redhat.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible uninitialized 'InitFlag' field
Date: Fri, 17 Jan 2020 08:24:38 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C3F82C9@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20200117065638.9176-1-hao.a.wu@intel.com>

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <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 <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni,
> Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kinney, Michael
> D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible
> uninitialized 'InitFlag' field
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2474
> 
> 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  = ApInitReconfig;
> ...
> CpuMpData->InitFlag = 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   != ApInitDone) {
>     ResetVectorRequired = 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 <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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 = ApInitReconfig;
>      WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE);
>      while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {
>        CpuPause ();
>      }
> -
> +    CpuMpData->InitFlag = ApInitDone;
>      for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
>        SetApState (&CpuMpData->CpuData[Index], CpuStateIdle);
>      }
> --
> 2.12.0.windows.1
> 
> 
> 


  reply	other threads:[~2020-01-17  8:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17  6:56 [PATCH v1] UefiCpuPkg/MpInitLib: Fix possible uninitialized 'InitFlag' field Wu, Hao A
2020-01-17  8:24 ` Ni, Ray [this message]
2020-01-17  8:41 ` Laszlo Ersek
2020-01-17  8:46   ` [edk2-devel] " Wu, Hao A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5C3F82C9@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox