From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel-bounces@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4062F21A00AE6; Tue, 4 Sep 2018 22:30:36 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2018 22:30:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,332,1531810800"; d="scan'208";a="259940003" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 04 Sep 2018 22:29:55 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 4 Sep 2018 22:29:54 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 4 Sep 2018 22:29:54 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.226]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0319.002; Wed, 5 Sep 2018 13:29:52 +0800 From: "Dong, Eric" To: edk2-devel , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Yao, Jiewen" , Laszlo Ersek , "Zeng, Star" Thread-Topic: [edk2] [PATCH 3/4] UefiCpuPkg/MpInitLib: fix register restore issue in AP wakeup Thread-Index: AQHUQzR2ZYeXmDMCpU28XrOdGyGEIaThLHSg Date: Wed, 5 Sep 2018 05:29:51 +0000 Message-ID: References: <20180903031550.4440-1-jian.j.wang@intel.com> <20180903031550.4440-4-jian.j.wang@intel.com> In-Reply-To: <20180903031550.4440-4-jian.j.wang@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 Subject: Re: [PATCH 3/4] UefiCpuPkg/MpInitLib: fix register restore issue in AP wakeup X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 05:30:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] > Sent: Monday, September 3, 2018 11:16 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Dong, Eric ; Yao= , > Jiewen ; Laszlo Ersek ; Zeng, > Star > Subject: [edk2] [PATCH 3/4] UefiCpuPkg/MpInitLib: fix register restore is= sue > in AP wakeup >=20 > The conflict issues are introduced by Stack Guard feature enabled for PEI= . >=20 > The first is CR0 which should be restored after CR3 and CR4. > Another is TR which should not be passed from BSP to AP during init phase= . >=20 > Cc: Eric Dong > Cc: Laszlo Ersek > Cc: Ruiyu Ni > Cc: Jiewen Yao > Cc: Star Zeng > Cc: "Ware, Ryan R" > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c > b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 377876643f..709fbc1575 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -217,9 +217,9 @@ RestoreVolatileRegisters ( > CPUID_VERSION_INFO_EDX VersionInfoEdx; > IA32_TSS_DESCRIPTOR *Tss; >=20 > - AsmWriteCr0 (VolatileRegisters->Cr0); > AsmWriteCr3 (VolatileRegisters->Cr3); > AsmWriteCr4 (VolatileRegisters->Cr4); > + AsmWriteCr0 (VolatileRegisters->Cr0); >=20 > if (IsRestoreDr) { > AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, > &VersionInfoEdx.Uint32); @@ -1558,7 +1558,7 @@ MpInitLibInitialize ( > ApLoopMode =3D GetApLoopMode (&MonitorFilterSize); >=20 > // > - // Save BSP's Control registers for APs > + // Save BSP's Control registers for APs. > // > SaveVolatileRegisters (&VolatileRegisters); >=20 > @@ -1656,6 +1656,10 @@ MpInitLibInitialize ( > // > CopyMem ((VOID *)ApIdtBase, (VOID *)VolatileRegisters.Idtr.Base, > VolatileRegisters.Idtr.Limit + 1); > VolatileRegisters.Idtr.Base =3D ApIdtBase; > + // > + // 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)); > // > // Set BSP basic information > -- > 2.16.2.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel