From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.4024.1579074762010755227 for ; Tue, 14 Jan 2020 23:52:42 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 23:52:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208,217";a="242783477" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 14 Jan 2020 23:52:40 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 23:52:40 -0800 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 23:52:40 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.202]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.139]) with mapi id 14.03.0439.000; Wed, 15 Jan 2020 15:52:38 +0800 From: "Dong, Eric" To: "Ni, Ray" , "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: AQHVy2oDLdFoPubsKUKVYFRF2SHXbqfrV/mggAACHCA= Date: Wed, 15 Jan 2020 07:52:38 +0000 Message-ID: References: <20200115060642.1707-1-eric.dong@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C3F5870@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C3F5870@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_ED077930C258884BBCB450DB737E662259FA537Dshsmsx102ccrcor_" --_000_ED077930C258884BBCB450DB737E662259FA537Dshsmsx102ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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_ED077930C258884BBCB450DB737E662259FA537Dshsmsx102ccrcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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@redhat.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_ED077930C258884BBCB450DB737E662259FA537Dshsmsx102ccrcor_--