From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.8724.1579177402435580366 for ; Thu, 16 Jan 2020 04:23:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: ray.ni@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 04:23:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,326,1574150400"; d="scan'208,217";a="220350765" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2020 04:23:21 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jan 2020 04:23:21 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jan 2020 04:23:20 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.197]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.55]) with mapi id 14.03.0439.000; Thu, 16 Jan 2020 20:23:18 +0800 From: "Ni, Ray" To: "Dong, Eric" , "devel@edk2.groups.io" CC: Laszlo Ersek Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption. Thread-Topic: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption. Thread-Index: AQHVy2oDst6phhspP028HfdBKFPOcqfrV/mg//98mQCAAmPzkA== Date: Thu, 16 Jan 2020 12:23:18 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C3F6C02@SHSMSX104.ccr.corp.intel.com> References: <20200115060642.1707-1-eric.dong@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C3F5870@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_734D49CCEBEEF84792F5B80ED585239D5C3F6C02SHSMSX104ccrcor_" --_000_734D49CCEBEEF84792F5B80ED585239D5C3F6C02SHSMSX104ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I recommend to switch BSP in PEI and see whether system is good in DXE. From: Dong, Eric Sent: Wednesday, January 15, 2020 3:53 PM To: Ni, Ray ; devel@edk2.groups.io Cc: Laszlo Ersek Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP = index =3D=3D 0 Assumption. Ray, I applied this change to an internal desktop machine and did below tests: 1. boot it to shell 2. reboot the system to shell. Thanks, Eric From: Ni, Ray Sent: Wednesday, January 15, 2020 3:43 PM To: devel@edk2.groups.io; Dong, Eric > Cc: Laszlo Ersek > Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP = index =3D=3D 0 Assumption. Eric, What unit test was done for this patch? > -----Original Message----- > From: devel@edk2.groups.io > On Behalf Of Dong, Eric > Sent: Wednesday, January 15, 2020 2:07 PM > To: devel@edk2.groups.io > Cc: Ni, Ray >; Laszlo Ersek > > Subject: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP in= dex =3D=3D 0 Assumption. > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2392 > > > Current code implementation assumes BSP index is 0 at the begin. > This code change removes this assumption. It get BSP index from > the saved data structure if it existed. > > Cc: Ray Ni > > Cc: Laszlo Ersek > > Signed-off-by: Eric Dong = > > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index 6ec9b172b8..922c87b766 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -636,7 +636,7 @@ ApWakeupFunction ( > // to initialize AP in InitConfig path. > > // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegiste= rs points to a different IDT shared by all APs. > > // > > - RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters= , FALSE); > > + RestoreVolatileRegisters (&CpuMpData->CpuData[CpuMpData->BspNumber= ].VolatileRegisters, FALSE); > > InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfSta= ck); > > ApStartupSignalBuffer =3D CpuMpData->CpuData[ProcessorNumber].Star= tupApSignal; > > > > @@ -1615,6 +1615,7 @@ MpInitLibInitialize ( > UINTN ApResetVectorSize; > > UINTN BackupBufferAddr; > > UINTN ApIdtBase; > > + UINT64 BspTopOfStack; > > > > OldCpuMpData =3D GetCpuMpDataFromGuidedHob (); > > if (OldCpuMpData =3D=3D NULL) { > > @@ -1677,7 +1678,7 @@ MpInitLibInitialize ( > CpuMpData->BackupBufferSize =3D ApResetVectorSize; > > CpuMpData->WakeupBuffer =3D (UINTN) -1; > > CpuMpData->CpuCount =3D 1; > > - CpuMpData->BspNumber =3D 0; > > + CpuMpData->BspNumber =3D OldCpuMpData !=3D NULL ? OldCpuMpData-= >BspNumber : 0; > > CpuMpData->WaitEvent =3D NULL; > > CpuMpData->SwitchBspFlag =3D FALSE; > > CpuMpData->CpuData =3D (CPU_AP_DATA *) (CpuMpData + 1); > > @@ -1704,11 +1705,12 @@ MpInitLibInitialize ( > // Don't pass BSP's TR to APs to avoid AP init failure. > > // > > VolatileRegisters.Tr =3D 0; > > - CopyMem (&CpuMpData->CpuData[0].VolatileRegisters, &VolatileRegisters,= sizeof (VolatileRegisters)); > > + CopyMem (&CpuMpData->CpuData[CpuMpData->BspNumber].VolatileRegisters, = &VolatileRegisters, sizeof > (VolatileRegisters)); > > // > > // Set BSP basic information > > // > > - InitializeApData (CpuMpData, 0, 0, CpuMpData->Buffer + ApStackSize); > > + BspTopOfStack =3D CpuMpData->Buffer + (CpuMpData->BspNumber + 1) * Cpu= MpData->CpuApStackSize; > > + InitializeApData (CpuMpData, CpuMpData->BspNumber, 0, BspTopOfStack); > > // > > // Save assembly code information > > // > > -- > 2.23.0.windows.1 > > > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#53263): https://edk2.groups.io/g/devel/message/53263 > Mute This Topic: https://groups.io/mt/69712223/1712937 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D --_000_734D49CCEBEEF84792F5B80ED585239D5C3F6C02SHSMSX104ccrcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I recommend to switch BSP in PEI and see whether sy= stem is good in DXE.

 

From: Dong, Eric <eric.dong@intel= .com>
Sent: Wednesday, January 15, 2020 3:53 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io
Cc: Laszlo Ersek <lersek@redhat.com>
Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remo= ve BSP index =3D=3D 0 Assumption.

 

Ray,

 

I applied this change to an internal = desktop machine and did below tests:

  1. boot it to shell
  2. reboot the system to shell.

 

Thanks,

Eric

From: Ni, Ray
Sent: Wednesday, January 15, 2020 3:43 PM
To: devel@edk2.groups.io= ; Dong, Eric <eric.dong@intel.com= >
Cc: Laszlo Ersek <lersek@red= hat.com>
Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/Library/MpInitLib: Remo= ve BSP index =3D=3D 0 Assumption.

 

Eric,
What unit test was done&nbs= p;for this patch?

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of = ;Dong, Eric
> Sent: Wednesday, January&n= bsp;15, 2020 2:07 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo E= rsek <lersek@redhat.com>= ;
> Subject: [edk2-devel] [PAT= CH] UefiCpuPkg/Library/MpInitLib: Remove BSP index = ;=3D=3D 0 Assumption.

> REF: https://bugzilla.tianocore.org/show= _bug.cgi?id=3D2392


> Current code implementatio= n assumes BSP index is 0 at the beg= in.
> This code change remo= ves this assumption. It get BSP index fr= om
> the saved data struct= ure if it existed.

> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <= lersek@redhat.com>
> Signed-off-by: Eric Dong&n= bsp;<eric.dong@intel.com><= /span>
> ---
>  UefiCpuPkg/Library/MpInitLib/M= pLib.c | 10 ++++++----
>  1 file changed, = ;6 insertions(+), 4 deletions(-)

> diff --git a/UefiCpuPkg/Li= brary/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c<= br> > index 6ec9b172b8..922c87b766&nb= sp;100644
> --- a/UefiCpuPkg/Library/MpInit= Lib/MpLib.c
> +++ b/UefiCpuPkg/Li= brary/MpInitLib/MpLib.c
> @@ -636,7 +636,7 = @@ ApWakeupFunction (
>       =  //   to initialize AP in InitConfi= g path.

>       =  // NOTE: IDTR.BASE stored in CpuMpData->C= puData[0].VolatileRegisters points to a different = IDT shared by all APs.

>       =  //

> -      = ;RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegis= ters, FALSE);

> +     &= nbsp;RestoreVolatileRegisters (&CpuMpData->CpuData[CpuMpData-&g= t;BspNumber].VolatileRegisters, FALSE);

>       =  InitializeApData (CpuMpData, ProcessorNumber, BistData= , ApTopOfStack);

>       =  ApStartupSignalBuffer =3D CpuMpData->CpuData[ProcessorNu= mber].StartupApSignal;



> @@ -1615,6 +1615,7&nbs= p;@@ MpInitLibInitialize (
>    UINTN  &= nbsp;           &nbs= p;     ApResetVectorSize;

>    UINTN  &= nbsp;           &nbs= p;     BackupBufferAddr;

>    UINTN  &= nbsp;           &nbs= p;     ApIdtBase;

> +  UINT64  &= nbsp;           &nbs= p;    BspTopOfStack;



>    OldCpuMpData = =3D GetCpuMpDataFromGuidedHob ();

>    if (OldCpuMpD= ata =3D=3D NULL) {

> @@ -1677,7 +1678,7&nbs= p;@@ MpInitLibInitialize (
>    CpuMpData->Back= upBufferSize =3D ApResetVectorSize;

>    CpuMpData->Wake= upBuffer     =3D (UINTN) -1;

>    CpuMpData->CpuC= ount         =3D 1;

> -  CpuMpData->BspNumber=         =3D 0;

> +  CpuMpData->BspNu= mber        =3D OldCpuMpData&n= bsp;!=3D NULL ? OldCpuMpData->BspNumber : 0;

>    CpuMpData->Wait= Event        =3D NULL;<= br>
>    CpuMpData->Swit= chBspFlag    =3D FALSE;

>    CpuMpData->CpuD= ata          =3D (CP= U_AP_DATA *) (CpuMpData + 1);

> @@ -1704,11 +1705,12&n= bsp;@@ MpInitLibInitialize (
>    // Don't = ;pass BSP's TR to APs to avoid AP i= nit failure.

>    //

>    VolatileRegisters.= Tr =3D 0;

> -  CopyMem (&CpuM= pData->CpuData[0].VolatileRegisters, &VolatileRegisters, s= izeof (VolatileRegisters));

> +  CopyMem (&= CpuMpData->CpuData[CpuMpData->BspNumber].VolatileRegisters, &= ;VolatileRegisters, sizeof
> (VolatileRegisters));

>    //

>    // Set B= SP basic information

>    //

> -  InitializeApData (= CpuMpData, 0, 0, CpuMpData->Buffer + ApStac= kSize);

> +  BspTopOfStack = =3D CpuMpData->Buffer + (CpuMpData->BspNumber = ;+ 1) * CpuMpData->CpuApStackSize;

> +  InitializeApData&nb= sp;(CpuMpData, CpuMpData->BspNumber, 0, BspTopOfStack);

>    //

>    // Save = assembly code information

>    //

> --
> 2.23.0.windows.1


> -=3D-=3D-=3D-=3D-=3D-=3D
> Groups.io Links: You = receive all messages sent to this group.

> View/Reply Online (#53263)= : https://edk= 2.groups.io/g/devel/message/53263
> Mute This Topic: https://groups.io/mt/69712223= /1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub&nbs= p; [ray.ni@intel.com]
> -=3D-=3D-=3D-=3D-=3D-=3D=

--_000_734D49CCEBEEF84792F5B80ED585239D5C3F6C02SHSMSX104ccrcor_--