From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.3193.1579068418674265486 for ; Tue, 14 Jan 2020 22:06:58 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 22:06:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="256626350" Received: from unknown (HELO ydong10-desktop.ccr.corp.intel.com) ([10.239.158.133]) by fmsmga002.fm.intel.com with ESMTP; 14 Jan 2020 22:06:57 -0800 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek Subject: [PATCH] UefiCpuPkg/Library/MpInitLib: Remove BSP index == 0 Assumption. Date: Wed, 15 Jan 2020 14:06:42 +0800 Message-Id: <20200115060642.1707-1-eric.dong@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2392=0D 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/MpIn= itLib/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.=0D // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegisters= points to a different IDT shared by all APs.=0D //=0D - RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, = FALSE);=0D + RestoreVolatileRegisters (&CpuMpData->CpuData[CpuMpData->BspNumber].= VolatileRegisters, FALSE);=0D InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack= );=0D ApStartupSignalBuffer =3D CpuMpData->CpuData[ProcessorNumber].Startu= pApSignal;=0D =0D @@ -1615,6 +1615,7 @@ MpInitLibInitialize ( UINTN ApResetVectorSize;=0D UINTN BackupBufferAddr;=0D UINTN ApIdtBase;=0D + UINT64 BspTopOfStack;=0D =0D OldCpuMpData =3D GetCpuMpDataFromGuidedHob ();=0D if (OldCpuMpData =3D=3D NULL) {=0D @@ -1677,7 +1678,7 @@ MpInitLibInitialize ( CpuMpData->BackupBufferSize =3D ApResetVectorSize;=0D CpuMpData->WakeupBuffer =3D (UINTN) -1;=0D CpuMpData->CpuCount =3D 1;=0D - CpuMpData->BspNumber =3D 0;=0D + CpuMpData->BspNumber =3D OldCpuMpData !=3D NULL ? OldCpuMpData->B= spNumber : 0;=0D CpuMpData->WaitEvent =3D NULL;=0D CpuMpData->SwitchBspFlag =3D FALSE;=0D CpuMpData->CpuData =3D (CPU_AP_DATA *) (CpuMpData + 1);=0D @@ -1704,11 +1705,12 @@ MpInitLibInitialize ( // Don't pass BSP's TR to APs to avoid AP init failure.=0D //=0D VolatileRegisters.Tr =3D 0;=0D - CopyMem (&CpuMpData->CpuData[0].VolatileRegisters, &VolatileRegisters, s= izeof (VolatileRegisters));=0D + CopyMem (&CpuMpData->CpuData[CpuMpData->BspNumber].VolatileRegisters, &V= olatileRegisters, sizeof (VolatileRegisters));=0D //=0D // Set BSP basic information=0D //=0D - InitializeApData (CpuMpData, 0, 0, CpuMpData->Buffer + ApStackSize);=0D + BspTopOfStack =3D CpuMpData->Buffer + (CpuMpData->BspNumber + 1) * CpuMp= Data->CpuApStackSize;=0D + InitializeApData (CpuMpData, CpuMpData->BspNumber, 0, BspTopOfStack);=0D //=0D // Save assembly code information=0D //=0D --=20 2.23.0.windows.1