From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Two or more type TXT spf records found.) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 1BE762110E887 for ; Sun, 2 Sep 2018 20:15:57 -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 orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2018 20:15:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,323,1531810800"; d="scan'208";a="259323779" Received: from shwdeopenpsi777.ccr.corp.intel.com ([10.239.158.27]) by fmsmga005.fm.intel.com with ESMTP; 02 Sep 2018 20:15:55 -0700 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Eric Dong , Laszlo Ersek , Ruiyu Ni , Jiewen Yao , Star Zeng , "Ware, Ryan R" Date: Mon, 3 Sep 2018 11:15:49 +0800 Message-Id: <20180903031550.4440-4-jian.j.wang@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20180903031550.4440-1-jian.j.wang@intel.com> References: <20180903031550.4440-1-jian.j.wang@intel.com> Subject: [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: Mon, 03 Sep 2018 03:15:57 -0000 The conflict issues are introduced by Stack Guard feature enabled for PEI. 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. 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(-) 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; - AsmWriteCr0 (VolatileRegisters->Cr0); AsmWriteCr3 (VolatileRegisters->Cr3); AsmWriteCr4 (VolatileRegisters->Cr4); + AsmWriteCr0 (VolatileRegisters->Cr0); if (IsRestoreDr) { AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32); @@ -1558,7 +1558,7 @@ MpInitLibInitialize ( ApLoopMode = GetApLoopMode (&MonitorFilterSize); // - // Save BSP's Control registers for APs + // Save BSP's Control registers for APs. // SaveVolatileRegisters (&VolatileRegisters); @@ -1656,6 +1656,10 @@ MpInitLibInitialize ( // CopyMem ((VOID *)ApIdtBase, (VOID *)VolatileRegisters.Idtr.Base, VolatileRegisters.Idtr.Limit + 1); VolatileRegisters.Idtr.Base = ApIdtBase; + // + // Don't pass BSP's TR to APs to avoid AP init failure. + // + VolatileRegisters.Tr = 0; CopyMem (&CpuMpData->CpuData[0].VolatileRegisters, &VolatileRegisters, sizeof (VolatileRegisters)); // // Set BSP basic information -- 2.16.2.windows.1