From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com []) by mx.groups.io with SMTP id smtpd.web10.3030.1587519300506659025 for ; Tue, 21 Apr 2020 18:35:01 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: eric.dong@intel.com) IronPort-SDR: X7PrRVrteLmgmbMrS6YZqiZVugKvsxO8IjTEv2Y5znNtoGcxMFslsWNuS51XMBhK1recoZuokf 5ranP0ElBsrA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2020 18:35:01 -0700 IronPort-SDR: 9JBAcNGeWZ63Dfa49Wa5bOBe7KPhyKDV2VoxuZ8OdUjXP5XD113u1SlrcEkhSfyt5CtBPIkXZt HKPXqg9su6aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,412,1580803200"; d="scan'208";a="429730940" Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by orsmga005.jf.intel.com with ESMTP; 21 Apr 2020 18:34:59 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar Subject: [PATCH 1/2] UefiCpuPkg/MpInitLib: Restore IDT context for APs. Date: Wed, 22 Apr 2020 09:34:55 +0800 Message-Id: <20200422013456.1053-2-eric.dong@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20200422013456.1053-1-eric.dong@intel.com> References: <20200422013456.1053-1-eric.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2683=0D =0D This patch used to fix a ASSERT because AP can't find the CpuMpData.=0D When AP been waked up through Init-Sipi-Sipi, the IDT should been restore to preallcated buffer to make it can get the CpuMpData through IDT base address. Not when CpuMpData->InitFlag is ApInitReconfig or ApInitConfig, AP will be wake up through Init-Sipi-Sipi. Current code already has logic to handle ApInitConfig, but miss the handler for ApInitReconfig. This patch fixes this gap. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Signed-off-by: Eric Dong --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 64a4c3546e..ac7f92fd48 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -664,8 +664,9 @@ ApWakeupFunction ( BistData =3D *(UINT32 *) ((UINTN) ApTopOfStack - sizeof (UINTN));=0D //=0D // CpuMpData->CpuData[0].VolatileRegisters is initialized based on B= SP environment,=0D - // 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 + // to initialize AP in InitConfig/ApInitReconfig path.=0D + // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegisters= points to a=0D + // different IDT shared by all APs.=0D //=0D RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, = FALSE);=0D InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack= );=0D @@ -673,6 +674,16 @@ ApWakeupFunction ( =0D InterlockedDecrement ((UINT32 *) &CpuMpData->MpCpuExchangeInfo->NumA= psExecuting);=0D } else {=0D + if ((CpuMpData->InitFlag =3D=3D ApInitReconfig) && (CpuMpData->ApLoo= pMode !=3D ApInHltLoop)) {=0D + //=0D + // CpuMpData->CpuData[0].VolatileRegisters is initialized based on= BSP environment,=0D + // to initialize AP in InitConfig/ApInitReconfig path.=0D + // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegiste= rs points to a=0D + // different IDT shared by all APs.=0D + //=0D + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters= , FALSE);=0D + }=0D +=0D //=0D // Execute AP function if AP is ready=0D //=0D --=20 2.23.0.windows.1