From nobody Fri Oct 24 20:35:25 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1495614022536943.6436124221877; Wed, 24 May 2017 01:20:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 92FEC219FFEF8; Wed, 24 May 2017 01:20:17 -0700 (PDT) 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 980DB219FFEF1 for ; Wed, 24 May 2017 01:20:16 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 24 May 2017 01:20:16 -0700 Received: from jfan12-desk.ccr.corp.intel.com ([10.239.158.57]) by FMSMGA003.fm.intel.com with ESMTP; 24 May 2017 01:20:15 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,385,1491289200"; d="scan'208";a="860728096" From: Jeff Fan To: edk2-devel@lists.01.org Date: Wed, 24 May 2017 16:18:41 +0800 Message-Id: <20170524081841.10496-3-jeff.fan@intel.com> X-Mailer: git-send-email 2.9.3.windows.2 In-Reply-To: <20170524081841.10496-1-jeff.fan@intel.com> References: <20170524081841.10496-1-jeff.fan@intel.com> Subject: [edk2] [PATCH v2 2/2] UefiCpuPkg/MpInitLib: Check APIC mode change around AP function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Eric Dong MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If APIC ID values are changed during AP functions execution, we need to upd= ate new APIC ID values in local data structure accordingly. But if APIC mode change happened during AP function execution, we do not su= pport APIC ID value changed. Cc: Michael D Kinney Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 735e099..c6f8191 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -547,6 +547,7 @@ ApWakeupFunction ( volatile UINT32 *ApStartupSignalBuffer; CPU_INFO_IN_HOB *CpuInfoInHob; UINT64 ApTopOfStack; + UINTN CurrentApicMode; =20 // // AP finished assembly code and begin to execute C code @@ -560,6 +561,7 @@ ApWakeupFunction ( ProgramVirtualWireMode (); SyncLocalApicTimerSetting (CpuMpData); =20 + CurrentApicMode =3D GetApicMode (); while (TRUE) { if (CpuMpData->InitFlag =3D=3D ApInitConfig) { // @@ -627,11 +629,23 @@ ApWakeupFunction ( ApStartupSignalBuffer =3D CpuMpData->CpuData[ProcessorNumber].= StartupApSignal; CpuInfoInHob[ProcessorNumber].ApTopOfStack =3D CpuInfoInHob[Cp= uMpData->NewBspNumber].ApTopOfStack; } else { - // - // Re-get the CPU APICID and Initial APICID - // - CpuInfoInHob[ProcessorNumber].ApicId =3D GetApicId (); - CpuInfoInHob[ProcessorNumber].InitialApicId =3D GetInitialApic= Id (); + if (CpuInfoInHob[ProcessorNumber].ApicId !=3D GetApicId () || + CpuInfoInHob[ProcessorNumber].InitialApicId !=3D GetInitia= lApicId ()) { + if (CurrentApicMode !=3D GetApicMode ()) { + // + // If APIC mode change happened during AP function executi= on, + // we do not support APIC ID value changed. + // + ASSERT (FALSE); + CpuDeadLoop (); + } else { + // + // Re-get the CPU APICID and Initial APICID if they are ch= anged + // + CpuInfoInHob[ProcessorNumber].ApicId =3D GetApicId = (); + CpuInfoInHob[ProcessorNumber].InitialApicId =3D GetInitial= ApicId (); + } + } } } SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateFinished= ); --=20 2.9.3.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel