From nobody Thu May 2 12:08:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+57773+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57773+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1587519302; cv=none; d=zohomail.com; s=zohoarc; b=PtLnoVKzHV8wLThG8McG3Zm59hYQCiBk9EwVdd8TIeDy/VJPdVKl3Atr8Ui04QUdDUg/qk0MT5n6m61JL3O8UC91Z4Cgq6Svktd3NYXVEZ4/d8X0mEs7ioGqTYMQ3OH7stBABUSjRuuJsocCTmZOdNzBOCJdCHKGUSTu1DmQa0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587519302; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=YA4DPs+ORacXYLPGvTv7w5zt/L8J9OH8T4etX67+Ga8=; b=MMhDJ8ikPop7LuUI943Rqn0H9EwAMmhJSrDbxmhYWm241OL6LYz/OFyqaerESJQFNLvPrkHHPWeGfd0UZeya7AMTS0JZtrXti/rEFmttAukghownOhjP5WPsntd4e+G72y6FTwbsBvVWmIu787WlNg87bw1MKyFOLBiFwphVsJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57773+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1587519302492122.87992369366225; Tue, 21 Apr 2020 18:35:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0YLfYY1788612x5uciGQVxkp; Tue, 21 Apr 2020 18:35:02 -0700 X-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 IronPort-SDR: X7PrRVrteLmgmbMrS6YZqiZVugKvsxO8IjTEv2Y5znNtoGcxMFslsWNuS51XMBhK1recoZuokf 5ranP0ElBsrA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-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" X-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: [edk2-devel] [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> In-Reply-To: <20200422013456.1053-1-eric.dong@intel.com> References: <20200422013456.1053-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com X-Gm-Message-State: xPn6DDQqxzxtT68r3dZg9XB2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1587519302; bh=rAK7o+V07bbUUP6v1LQRMORWIFPFzPQLu69zJmv4Nqc=; h=Cc:Date:From:Reply-To:Subject:To; b=YSVCknw6lX+6mDjxilGNP7WOscQRS/QY7w6t69nLtkKt2LZR4xKufcymVHsK18f0izB kQsDIBn94ALQnUH5MMLeaXq4kSMFiL6wNMW4yI8f/8TlNiNk4/3CtbEjNzR6ybwr+UkOK 3y7IpzPk41rufmt9ji2NkZ4HhsLRMnhZthU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2683 This patch used to fix a ASSERT because AP can't find the CpuMpData. 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)); // // CpuMpData->CpuData[0].VolatileRegisters is initialized based on B= SP environment, - // to initialize AP in InitConfig path. - // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegisters= points to a different IDT shared by all APs. + // to initialize AP in InitConfig/ApInitReconfig path. + // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegisters= points to a + // different IDT shared by all APs. // RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, = FALSE); InitializeApData (CpuMpData, ProcessorNumber, BistData, ApTopOfStack= ); @@ -673,6 +674,16 @@ ApWakeupFunction ( =20 InterlockedDecrement ((UINT32 *) &CpuMpData->MpCpuExchangeInfo->NumA= psExecuting); } else { + if ((CpuMpData->InitFlag =3D=3D ApInitReconfig) && (CpuMpData->ApLoo= pMode !=3D ApInHltLoop)) { + // + // CpuMpData->CpuData[0].VolatileRegisters is initialized based on= BSP environment, + // to initialize AP in InitConfig/ApInitReconfig path. + // NOTE: IDTR.BASE stored in CpuMpData->CpuData[0].VolatileRegiste= rs points to a + // different IDT shared by all APs. + // + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters= , FALSE); + } + // // Execute AP function if AP is ready // --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#57773): https://edk2.groups.io/g/devel/message/57773 Mute This Topic: https://groups.io/mt/73187416/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 12:08:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+57774+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57774+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1587519303; cv=none; d=zohomail.com; s=zohoarc; b=J40XaXICu0Ck58+spliZta6NAhrmm7A7VGO7wDYa2ZsPlQB4n1AVK9+1ouaRpDHYbo3bx4QpFIExIt15GSeAp+RXfZTr/aSBrM04zwt8dv9nFmu8k2ZevIda5BKaAGfVBBrkQFTM9hOaqLnzsmQUr6OltoKJdY3grotVcxIJYsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587519303; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=U5quh6e2DougalXki/THkPoVwBpziBjD787l3LeHm24=; b=d8iRmylyuW9OwpXu4K02BGl4S/tFlnDIRDGIF01EZOpeWP41KUaGJPTxCZ+j5TbDih8iAnLbEQJ/0Lq59jchI8ZfDnxKdiim7euB7zhjGnc6mTiEGyqYcuxTG+XVbj4KdvJcXZ8KZvCuHIqy8bSfQeggZEtK1AxZTfwMc8ccmHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+57774+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1587519303880220.39357204568444; Tue, 21 Apr 2020 18:35:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Hj5gYY1788612xtgehLn6d1M; Tue, 21 Apr 2020 18:35:03 -0700 X-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:03 -0700 IronPort-SDR: nfnyK2ZTkgxuwQH3wIZ4VnHYV6L5rtDbfY/10CldLeTU3SGsrbypVecvhJxuNvwVhxFHhXuqiL qe/JajfU4Gqw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-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:02 -0700 IronPort-SDR: RjDd0MhRwLMOkRUhkp5MFaQwvDefjTaWntPpFRNStcuWR7dWqXQ/Vn+HcOUCxN0DJBzWKyXEVr yL7DrKDFNxQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,412,1580803200"; d="scan'208";a="429730969" X-Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by orsmga005.jf.intel.com with ESMTP; 21 Apr 2020 18:35:01 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Avoid ApInitReconfig in PEI. Date: Wed, 22 Apr 2020 09:34:56 +0800 Message-Id: <20200422013456.1053-3-eric.dong@intel.com> In-Reply-To: <20200422013456.1053-1-eric.dong@intel.com> References: <20200422013456.1053-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com X-Gm-Message-State: Z6ptT2zAE9NdRL5dlbMPMGqlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1587519303; bh=ga1L818JaerXl9KoTmQjXlTZExQR+ypI098y1S/D768=; h=Cc:Date:From:Reply-To:Subject:To; b=NHpRz1qBVsDlRZQ/de4IF7dACgJF+4qlVK2kdTc2x5vUEn5Z2WwILGzDeTqi58hTBi6 0gfRDTGRJsVaDMDjF1lwOkUF20BEKU2SjtXodT5vw9dYmueoJdi4BKvaCXE7K/4hnoW0I hqEmAuXrKYsBmf4ZzBrW5I2bfMQA84sGOwM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2683 In PEI phase, AP already been waked up through ApInitConfig, so it can directly wake up it through change wakup buffer instead of use ApInitReconfig flag. It can save some time. Change code to only use ApInitReconfig flag in DXE phase which must need to update the wake up buffer. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Signed-off-by: Eric Dong Reviewed-by: Ray Ni with a bit comments update: --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index ac7f92fd48..644971b68f 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1819,7 +1819,14 @@ MpInitLibInitialize ( // Wakeup APs to do some AP initialize sync (Microcode & MTRR) // if (CpuMpData->CpuCount > 1) { - CpuMpData->InitFlag =3D ApInitReconfig; + if (OldCpuMpData !=3D NULL) { + // + // Only needs to use this flag for DXE phase to update the wake up + // buffer. Current been used wake up buffer is allocated in PEI phase + // and no long valid at this time. + // + CpuMpData->InitFlag =3D ApInitReconfig; + } WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); // // Wait for all APs finished initialization @@ -1827,7 +1834,9 @@ MpInitLibInitialize ( while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { CpuPause (); } - CpuMpData->InitFlag =3D ApInitDone; + if (OldCpuMpData !=3D NULL) { + CpuMpData->InitFlag =3D ApInitDone; + } for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); } --=20 2.23.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#57774): https://edk2.groups.io/g/devel/message/57774 Mute This Topic: https://groups.io/mt/73187417/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-