From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com []) by mx.groups.io with SMTP id smtpd.web11.2717.1587545162325592913 for ; Wed, 22 Apr 2020 01:46:03 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: eric.dong@intel.com) IronPort-SDR: 2mfXcyFHilyzZs2X5Cx/uWcRphM8IUeQ+NJeyh5uUtZSYQgAHBNQWWvmr5fCHSKcrhWxOHQrnV iOJSGUGQrwSA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2020 01:46:03 -0700 IronPort-SDR: HTtBqLp40IRTUtO7SKg7fl4eKfJww9UKp5NXt7Cx8BdF305sI1LPOLqVyKCzq5zotaO/+J5gPt JbzihPwxnsTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,413,1580803200"; d="scan'208";a="334553932" Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by orsmga001.jf.intel.com with ESMTP; 22 Apr 2020 01:46:01 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar Subject: [PATCH v2 1/2] UefiCpuPkg/MpInitLib: Restore IDT context for APs. Date: Wed, 22 Apr 2020 16:45:57 +0800 Message-Id: <20200422084558.623-2-eric.dong@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20200422084558.623-1-eric.dong@intel.com> References: <20200422084558.623-1-eric.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2683 This patch fixes an assertion because AP can't find the CpuMpData. When AP is waken up through Init-Sipi-Sipi, AP's IDT should be restored to pre-allocated buffer so AP can get the CpuMpData through the IDT base address. Current code already has logic to handle this when CpuMpData-> InitFlag is ApInitConfig but misses the logic when CpuMpData->InitFlag is ApInitReconfig. This patch fixes this gap. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Signed-off-by: Eric Dong ---=0D V2:=0D Enhance code to remove CpuMpData->ApLoopMode =3D=3D ApInHltLoop check.=0D UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 64a4c3546e..2e87aa1f06 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -692,6 +692,16 @@ ApWakeupFunction ( //=0D RestoreVolatileRegisters (&CpuMpData->CpuData[ProcessorNumber].Vol= atileRegisters, TRUE);=0D } else {=0D + if (CpuMpData->InitFlag =3D=3D ApInitReconfig) {=0D + //=0D + // Initialize AP volatile registers in ApInitReconfig path.=0D + // ApInitReconfig happens when:=0D + // 1. AP is re-enabled after it's disabled, in either PEI or DXE= phase.=0D + // 2. AP is initialized in DXE phase.=0D + //=0D + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegiste= rs, FALSE);=0D + }=0D +=0D //=0D // The CPU driver might not flush TLB for APs on spot after updati= ng=0D // page attributes. AP in mwait loop mode needs to take care of it= when=0D --=20 2.23.0.windows.1