From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web12.8786.1631784440741836209 for ; Thu, 16 Sep 2021 02:27:20 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: yun.lou@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="202023650" X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="202023650" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 02:27:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,298,1624345200"; d="scan'208";a="545455037" Received: from shwdeopenlab102.ccr.corp.intel.com ([10.239.183.74]) by FMSMGA003.fm.intel.com with ESMTP; 16 Sep 2021 02:27:15 -0700 From: "Jason Lou" To: devel@edk2.groups.io Cc: Jason , Ray Ni , Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [PATCH v2 1/2] UefiCpuPkg: Refactor initialization of CPU features during S3 resume Date: Thu, 16 Sep 2021 17:27:11 +0800 Message-Id: <20210916092712.4340-1-yun.lou@intel.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3621 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3631 Refactor initialization of CPU features during S3 resume. In addition, the macro ACPI_CPU_DATA_STRUCTURE_UPDATE is used to fix incompatibility issue caused by ACPI_CPU_DATA structure update. It will be removed after all the platform code uses new ACPI_CPU_DATA structure. Signed-off-by: Jason Lou Cc: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar --- OvmfPkg/CpuS3DataDxe/CpuS3Data.c | 7 +- UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 7 +- UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 12 +- UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c | 18 += -- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 160 += ++++++++++--------- UefiCpuPkg/Include/AcpiCpuData.h | 91 += +++++----- 6 files changed, 167 insertions(+), 128 deletions(-) diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c b/OvmfPkg/CpuS3DataDxe/CpuS3D= ata.c index 5ffe1f3cd7..de20d87567 100644 --- a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c +++ b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c @@ -9,7 +9,7 @@ number of CPUs reported by the MP Services Protocol, so thi= s module does not support hot plug CPUs. This module can be copied into a CPU specific pack= age=0D and customized if these additional features are required.=0D =0D -Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2013 - 2021, Intel Corporation. All rights reserved.
=0D Copyright (c) 2015 - 2020, Red Hat, Inc.=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -252,10 +252,7 @@ CpuS3DataInitialize ( AcpiCpuDataEx->IdtrProfile.Base =3D (UINTN)Idt;=0D =0D if (OldAcpiCpuData !=3D NULL) {=0D - AcpiCpuData->RegisterTable =3D OldAcpiCpuData->RegisterTable= ;=0D - AcpiCpuData->PreSmmInitRegisterTable =3D OldAcpiCpuData->PreSmmInitReg= isterTable;=0D - AcpiCpuData->ApLocation =3D OldAcpiCpuData->ApLocation;=0D - CopyMem (&AcpiCpuData->CpuStatus, &OldAcpiCpuData->CpuStatus, sizeof (= CPU_STATUS_INFORMATION));=0D + CopyMem (&AcpiCpuData->CpuFeatureInitData, &OldAcpiCpuData->CpuFeature= InitData, sizeof (CPU_FEATURE_INIT_DATA));=0D }=0D =0D //=0D diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/= CpuS3Data.c index 078af36cfb..61ec7c44b2 100644 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c @@ -9,7 +9,7 @@ number of CPUs reported by the MP Services Protocol, so thi= s module does not support hot plug CPUs. This module can be copied into a CPU specific pack= age=0D and customized if these additional features are required.=0D =0D -Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2013 - 2021, Intel Corporation. All rights reserved.
=0D Copyright (c) 2015, Red Hat, Inc.=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -247,10 +247,7 @@ CpuS3DataInitialize ( AcpiCpuDataEx->IdtrProfile.Base =3D (UINTN)Idt;=0D =0D if (OldAcpiCpuData !=3D NULL) {=0D - AcpiCpuData->RegisterTable =3D OldAcpiCpuData->RegisterTable= ;=0D - AcpiCpuData->PreSmmInitRegisterTable =3D OldAcpiCpuData->PreSmmInitReg= isterTable;=0D - AcpiCpuData->ApLocation =3D OldAcpiCpuData->ApLocation;=0D - CopyMem (&AcpiCpuData->CpuStatus, &OldAcpiCpuData->CpuStatus, sizeof (= CPU_STATUS_INFORMATION));=0D + CopyMem (&AcpiCpuData->CpuFeatureInitData, &OldAcpiCpuData->CpuFeature= InitData, sizeof (CPU_FEATURE_INIT_DATA));=0D }=0D =0D //=0D diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 57511c4efa..6e2ab79518 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -1,7 +1,7 @@ /** @file=0D CPU Features Initialize functions.=0D =0D - Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -152,10 +152,10 @@ CpuInitDataInitialize ( ASSERT (AcpiCpuData !=3D NULL);=0D CpuFeaturesData->AcpiCpuData=3D AcpiCpuData;=0D =0D - CpuStatus =3D &AcpiCpuData->CpuStatus;=0D + CpuStatus =3D &AcpiCpuData->CpuFeatureInitData.CpuStatus;=0D Location =3D AllocateZeroPool (sizeof (EFI_CPU_PHYSICAL_LOCATION) * Numb= erOfCpus);=0D ASSERT (Location !=3D NULL);=0D - AcpiCpuData->ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Location;=0D + AcpiCpuData->CpuFeatureInitData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UI= NTN)Location;=0D =0D for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorNum= ber++) {=0D InitOrder =3D &CpuFeaturesData->InitOrder[ProcessorNumber];=0D @@ -1131,7 +1131,7 @@ SetProcessorRegister ( CpuFeaturesData =3D (CPU_FEATURES_DATA *) Buffer;=0D AcpiCpuData =3D CpuFeaturesData->AcpiCpuData;=0D =0D - RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->RegisterTab= le;=0D + RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->CpuFeatureI= nitData.RegisterTable;=0D =0D InitApicId =3D GetInitialApicId ();=0D RegisterTable =3D NULL;=0D @@ -1147,8 +1147,8 @@ SetProcessorRegister ( =0D ProgramProcessorRegister (=0D RegisterTable,=0D - (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)AcpiCpuData->ApLocation + ProcInde= x,=0D - &AcpiCpuData->CpuStatus,=0D + (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)AcpiCpuData->CpuFeatureInitData.Ap= Location + ProcIndex,=0D + &AcpiCpuData->CpuFeatureInitData.CpuStatus,=0D &CpuFeaturesData->CpuFlags=0D );=0D }=0D diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesL= ib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c index 60daa5cc87..e6ef9c602d 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c @@ -952,8 +952,8 @@ GetAcpiCpuData ( AcpiCpuData->NumberOfCpus =3D (UINT32)NumberOfCpus;=0D }=0D =0D - if (AcpiCpuData->RegisterTable =3D=3D 0 ||=0D - AcpiCpuData->PreSmmInitRegisterTable =3D=3D 0) {=0D + if (AcpiCpuData->CpuFeatureInitData.RegisterTable =3D=3D 0 ||=0D + AcpiCpuData->CpuFeatureInitData.PreSmmInitRegisterTable =3D=3D 0) {= =0D //=0D // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable= for all CPUs=0D //=0D @@ -976,11 +976,11 @@ GetAcpiCpuData ( RegisterTable[NumberOfCpus + Index].AllocatedSize =3D 0;=0D RegisterTable[NumberOfCpus + Index].RegisterTableEntry =3D 0;=0D }=0D - if (AcpiCpuData->RegisterTable =3D=3D 0) {=0D - AcpiCpuData->RegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Register= Table;=0D + if (AcpiCpuData->CpuFeatureInitData.RegisterTable =3D=3D 0) {=0D + AcpiCpuData->CpuFeatureInitData.RegisterTable =3D (EFI_PHYSICAL_ADDR= ESS)(UINTN)RegisterTable;=0D }=0D - if (AcpiCpuData->PreSmmInitRegisterTable =3D=3D 0) {=0D - AcpiCpuData->PreSmmInitRegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINT= N)(RegisterTable + NumberOfCpus);=0D + if (AcpiCpuData->CpuFeatureInitData.PreSmmInitRegisterTable =3D=3D 0) = {=0D + AcpiCpuData->CpuFeatureInitData.PreSmmInitRegisterTable =3D (EFI_PHY= SICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);=0D }=0D }=0D =0D @@ -1063,9 +1063,9 @@ CpuRegisterTableWriteWorker ( CpuFeaturesData =3D GetCpuFeaturesData ();=0D if (CpuFeaturesData->RegisterTable =3D=3D NULL) {=0D AcpiCpuData =3D GetAcpiCpuData ();=0D - ASSERT ((AcpiCpuData !=3D NULL) && (AcpiCpuData->RegisterTable !=3D 0)= );=0D - CpuFeaturesData->RegisterTable =3D (CPU_REGISTER_TABLE *) (UINTN) Acpi= CpuData->RegisterTable;=0D - CpuFeaturesData->PreSmmRegisterTable =3D (CPU_REGISTER_TABLE *) (UINTN= ) AcpiCpuData->PreSmmInitRegisterTable;=0D + ASSERT ((AcpiCpuData !=3D NULL) && (AcpiCpuData->CpuFeatureInitData.Re= gisterTable !=3D 0));=0D + CpuFeaturesData->RegisterTable =3D (CPU_REGISTER_TABLE *) (UINTN) Acpi= CpuData->CpuFeatureInitData.RegisterTable;=0D + CpuFeaturesData->PreSmmRegisterTable =3D (CPU_REGISTER_TABLE *) (UINTN= ) AcpiCpuData->CpuFeatureInitData.PreSmmInitRegisterTable;=0D }=0D =0D if (PreSmmFlag) {=0D diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index ab7f39aa2b..2873cba083 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -476,16 +476,19 @@ SetRegister ( IN BOOLEAN PreSmmRegisterTable=0D )=0D {=0D + CPU_FEATURE_INIT_DATA *FeatureInitData;=0D CPU_REGISTER_TABLE *RegisterTable;=0D CPU_REGISTER_TABLE *RegisterTables;=0D UINT32 InitApicId;=0D UINTN ProcIndex;=0D UINTN Index;=0D =0D + FeatureInitData =3D &mAcpiCpuData.CpuFeatureInitData;=0D +=0D if (PreSmmRegisterTable) {=0D - RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.PreSmmIni= tRegisterTable;=0D + RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)FeatureInitData->PreSm= mInitRegisterTable;=0D } else {=0D - RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.RegisterT= able;=0D + RegisterTables =3D (CPU_REGISTER_TABLE *)(UINTN)FeatureInitData->Regis= terTable;=0D }=0D if (RegisterTables =3D=3D NULL) {=0D return;=0D @@ -503,18 +506,18 @@ SetRegister ( }=0D ASSERT (RegisterTable !=3D NULL);=0D =0D - if (mAcpiCpuData.ApLocation !=3D 0) {=0D + if (FeatureInitData->ApLocation !=3D 0) {=0D ProgramProcessorRegister (=0D RegisterTable,=0D - (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)mAcpiCpuData.ApLocation + ProcIn= dex,=0D - &mAcpiCpuData.CpuStatus,=0D + (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)FeatureInitData->ApLocation + Pr= ocIndex,=0D + &FeatureInitData->CpuStatus,=0D &mCpuFlags=0D );=0D } else {=0D ProgramProcessorRegister (=0D RegisterTable,=0D NULL,=0D - &mAcpiCpuData.CpuStatus,=0D + &FeatureInitData->CpuStatus,=0D &mCpuFlags=0D );=0D }=0D @@ -1010,6 +1013,71 @@ IsRegisterTableEmpty ( return TRUE;=0D }=0D =0D +/**=0D + Copy the data used to initialize processor register into SMRAM.=0D +=0D + @param[in,out] CpuFeatureInitDataDst Pointer to the destination CPU_F= EATURE_INIT_DATA structure.=0D + @param[in] CpuFeatureInitDataSrc Pointer to the source CPU_FEATUR= E_INIT_DATA structure.=0D +=0D +**/=0D +VOID=0D +CopyCpuFeatureInitDatatoSmram (=0D + IN OUT CPU_FEATURE_INIT_DATA *CpuFeatureInitDataDst,=0D + IN CPU_FEATURE_INIT_DATA *CpuFeatureInitDataSrc=0D + )=0D +{=0D + CPU_STATUS_INFORMATION *CpuStatus;=0D +=0D + if (!IsRegisterTableEmpty ((CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDa= taSrc->PreSmmInitRegisterTable, mAcpiCpuData.NumberOfCpus)) {=0D + CpuFeatureInitDataDst->PreSmmInitRegisterTable =3D (EFI_PHYSICAL_ADDRE= SS)(UINTN)AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TA= BLE));=0D + ASSERT (CpuFeatureInitDataDst->PreSmmInitRegisterTable !=3D 0);=0D +=0D + CopyRegisterTable (=0D + (CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDataDst->PreSmmInitRegist= erTable,=0D + (CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDataSrc->PreSmmInitRegist= erTable,=0D + mAcpiCpuData.NumberOfCpus=0D + );=0D + }=0D +=0D + if (!IsRegisterTableEmpty ((CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDa= taSrc->RegisterTable, mAcpiCpuData.NumberOfCpus)) {=0D + CpuFeatureInitDataDst->RegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE));=0D + ASSERT (CpuFeatureInitDataDst->RegisterTable !=3D 0);=0D +=0D + CopyRegisterTable (=0D + (CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDataDst->RegisterTable,=0D + (CPU_REGISTER_TABLE *)(UINTN)CpuFeatureInitDataSrc->RegisterTable,=0D + mAcpiCpuData.NumberOfCpus=0D + );=0D + }=0D +=0D + CpuStatus =3D &CpuFeatureInitDataDst->CpuStatus;=0D + CopyMem (CpuStatus, &CpuFeatureInitDataSrc->CpuStatus, sizeof (CPU_STATU= S_INFORMATION));=0D +=0D + if (CpuFeatureInitDataSrc->CpuStatus.ThreadCountPerPackage !=3D 0) {=0D + CpuStatus->ThreadCountPerPackage =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Allo= cateCopyPool (=0D + sizeof (UINT32) * CpuStatus->P= ackageCount,=0D + (UINT32 *)(UINTN)CpuFeatureIni= tDataSrc->CpuStatus.ThreadCountPerPackage=0D + );=0D + ASSERT (CpuStatus->ThreadCountPerPackage !=3D 0);=0D + }=0D +=0D + if (CpuFeatureInitDataSrc->CpuStatus.ThreadCountPerCore !=3D 0) {=0D + CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Allocat= eCopyPool (=0D + sizeof (UINT8) * (CpuStatus->P= ackageCount * CpuStatus->MaxCoreCount),=0D + (UINT32 *)(UINTN)CpuFeatureIni= tDataSrc->CpuStatus.ThreadCountPerCore=0D + );=0D + ASSERT (CpuStatus->ThreadCountPerCore !=3D 0);=0D + }=0D +=0D + if (CpuFeatureInitDataSrc->ApLocation !=3D 0) {=0D + CpuFeatureInitDataDst->ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UINTN)All= ocateCopyPool (=0D + mAcpiCpuData.NumberOfCpus * sizeof (EFI_CP= U_PHYSICAL_LOCATION),=0D + (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)CpuFea= tureInitDataSrc->ApLocation=0D + );=0D + ASSERT (CpuFeatureInitDataDst->ApLocation !=3D 0);=0D + }=0D +}=0D +=0D /**=0D Get ACPI CPU data.=0D =0D @@ -1064,39 +1132,13 @@ GetAcpiCpuData ( =0D CopyMem ((VOID *)(UINTN)mAcpiCpuData.IdtrProfile, (VOID *)(UINTN)AcpiCpu= Data->IdtrProfile, sizeof (IA32_DESCRIPTOR));=0D =0D - if (!IsRegisterTableEmpty ((CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->Pre= SmmInitRegisterTable, mAcpiCpuData.NumberOfCpus)) {=0D - mAcpiCpuData.PreSmmInitRegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= AllocatePool (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE));=0D - ASSERT (mAcpiCpuData.PreSmmInitRegisterTable !=3D 0);=0D -=0D - CopyRegisterTable (=0D - (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.PreSmmInitRegisterTable,=0D - (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->PreSmmInitRegisterTable,=0D - mAcpiCpuData.NumberOfCpus=0D - );=0D - } else {=0D - mAcpiCpuData.PreSmmInitRegisterTable =3D 0;=0D - }=0D -=0D - if (!IsRegisterTableEmpty ((CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->Reg= isterTable, mAcpiCpuData.NumberOfCpus)) {=0D - mAcpiCpuData.RegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePo= ol (mAcpiCpuData.NumberOfCpus * sizeof (CPU_REGISTER_TABLE));=0D - ASSERT (mAcpiCpuData.RegisterTable !=3D 0);=0D -=0D - CopyRegisterTable (=0D - (CPU_REGISTER_TABLE *)(UINTN)mAcpiCpuData.RegisterTable,=0D - (CPU_REGISTER_TABLE *)(UINTN)AcpiCpuData->RegisterTable,=0D - mAcpiCpuData.NumberOfCpus=0D - );=0D - } else {=0D - mAcpiCpuData.RegisterTable =3D 0;=0D - }=0D -=0D //=0D // Copy AP's GDT, IDT and Machine Check handler into SMRAM.=0D //=0D Gdtr =3D (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.GdtrProfile;=0D Idtr =3D (IA32_DESCRIPTOR *)(UINTN)mAcpiCpuData.IdtrProfile;=0D =0D - GdtForAp =3D AllocatePool ((Gdtr->Limit + 1) + (Idtr->Limit + 1) + mAcp= iCpuData.ApMachineCheckHandlerSize);=0D + GdtForAp =3D AllocatePool ((Gdtr->Limit + 1) + (Idtr->Limit + 1) + mAcpi= CpuData.ApMachineCheckHandlerSize);=0D ASSERT (GdtForAp !=3D NULL);=0D IdtForAp =3D (VOID *) ((UINTN)GdtForAp + (Gdtr->Limit + 1));=0D MachineCheckHandlerForAp =3D (VOID *) ((UINTN)IdtForAp + (Idtr->Limit + = 1));=0D @@ -1109,41 +1151,23 @@ GetAcpiCpuData ( Idtr->Base =3D (UINTN)IdtForAp;=0D mAcpiCpuData.ApMachineCheckHandlerBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= MachineCheckHandlerForAp;=0D =0D - CpuStatus =3D &mAcpiCpuData.CpuStatus;=0D - CopyMem (CpuStatus, &AcpiCpuData->CpuStatus, sizeof (CPU_STATUS_INFORMAT= ION));=0D - if (AcpiCpuData->CpuStatus.ThreadCountPerPackage !=3D 0) {=0D - CpuStatus->ThreadCountPerPackage =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Allo= cateCopyPool (=0D - sizeof (UINT32) * CpuStatus->P= ackageCount,=0D - (UINT32 *)(UINTN)AcpiCpuData->= CpuStatus.ThreadCountPerPackage=0D - );=0D - ASSERT (CpuStatus->ThreadCountPerPackage !=3D 0);=0D - }=0D - if (AcpiCpuData->CpuStatus.ThreadCountPerCore !=3D 0) {=0D - CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Allocat= eCopyPool (=0D - sizeof (UINT8) * (CpuStatus->P= ackageCount * CpuStatus->MaxCoreCount),=0D - (UINT32 *)(UINTN)AcpiCpuData->= CpuStatus.ThreadCountPerCore=0D - );=0D - ASSERT (CpuStatus->ThreadCountPerCore !=3D 0);=0D - }=0D - if (AcpiCpuData->ApLocation !=3D 0) {=0D - mAcpiCpuData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateCopyP= ool (=0D - mAcpiCpuData.NumberOfCpus * sizeof (EFI_CP= U_PHYSICAL_LOCATION),=0D - (EFI_CPU_PHYSICAL_LOCATION *)(UINTN)AcpiCp= uData->ApLocation=0D - );=0D - ASSERT (mAcpiCpuData.ApLocation !=3D 0);=0D - }=0D - if (CpuStatus->PackageCount !=3D 0) {=0D - mCpuFlags.CoreSemaphoreCount =3D AllocateZeroPool (=0D - sizeof (UINT32) * CpuStatus->PackageC= ount *=0D - CpuStatus->MaxCoreCount * CpuStatus->= MaxThreadCount=0D - );=0D - ASSERT (mCpuFlags.CoreSemaphoreCount !=3D NULL);=0D - mCpuFlags.PackageSemaphoreCount =3D AllocateZeroPool (=0D - sizeof (UINT32) * CpuStatus->Packa= geCount *=0D - CpuStatus->MaxCoreCount * CpuStatu= s->MaxThreadCount=0D - );=0D - ASSERT (mCpuFlags.PackageSemaphoreCount !=3D NULL);=0D - }=0D + ZeroMem (&mAcpiCpuData.CpuFeatureInitData, sizeof (CPU_FEATURE_INIT_DATA= ));=0D + CopyCpuFeatureInitDatatoSmram (&mAcpiCpuData.CpuFeatureInitData, &AcpiCp= uData->CpuFeatureInitData);=0D +=0D + CpuStatus =3D &mAcpiCpuData.CpuFeatureInitData.CpuStatus;=0D +=0D + mCpuFlags.CoreSemaphoreCount =3D AllocateZeroPool (=0D + sizeof (UINT32) * CpuStatus->PackageCou= nt *=0D + CpuStatus->MaxCoreCount * CpuStatus->Ma= xThreadCount=0D + );=0D + ASSERT (mCpuFlags.CoreSemaphoreCount !=3D NULL);=0D +=0D + mCpuFlags.PackageSemaphoreCount =3D AllocateZeroPool (=0D + sizeof (UINT32) * CpuStatus->Package= Count *=0D + CpuStatus->MaxCoreCount * CpuStatus-= >MaxThreadCount=0D + );=0D + ASSERT (mCpuFlags.PackageSemaphoreCount !=3D NULL);=0D +=0D InitializeSpinLock((SPIN_LOCK*) &mCpuFlags.MemoryMappedLock);=0D }=0D =0D diff --git a/UefiCpuPkg/Include/AcpiCpuData.h b/UefiCpuPkg/Include/AcpiCpuD= ata.h index 62a01b2c6b..2fa8801d1f 100644 --- a/UefiCpuPkg/Include/AcpiCpuData.h +++ b/UefiCpuPkg/Include/AcpiCpuData.h @@ -1,7 +1,7 @@ /** @file=0D Definitions for CPU S3 data.=0D =0D -Copyright (c) 2013 - 2020, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2013 - 2021, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -9,6 +9,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _ACPI_CPU_DATA_H_=0D #define _ACPI_CPU_DATA_H_=0D =0D +//=0D +// This macro definition is used to fix incompatibility issue caused by=0D +// ACPI_CPU_DATA structure update. It will be removed after all the platfo= rm=0D +// code uses new ACPI_CPU_DATA structure.=0D +//=0D +#ifndef ACPI_CPU_DATA_STRUCTURE_UPDATE=0D +#define ACPI_CPU_DATA_STRUCTURE_UPDATE=0D +#endif=0D +=0D //=0D // Register types in register table=0D //=0D @@ -118,6 +127,49 @@ typedef struct { EFI_PHYSICAL_ADDRESS RegisterTableEntry;=0D } CPU_REGISTER_TABLE;=0D =0D +//=0D +// Data structure that is used for CPU feature initialization during ACPI = S3=0D +// resume.=0D +//=0D +typedef struct {=0D + //=0D + // Physical address of an array of CPU_REGISTER_TABLE structures, with=0D + // NumberOfCpus entries. If a register table is not required, then the= =0D + // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to= 0.=0D + // If TableLength is > 0, then elements of RegisterTableEntry are used t= o=0D + // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me,=0D + // before SMBASE relocation is performed.=0D + // If a register table is not required for any one of the CPUs, then=0D + // PreSmmInitRegisterTable may be set to 0.=0D + //=0D + EFI_PHYSICAL_ADDRESS PreSmmInitRegisterTable;=0D + //=0D + // Physical address of an array of CPU_REGISTER_TABLE structures, with=0D + // NumberOfCpus entries. If a register table is not required, then the= =0D + // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to= 0.=0D + // If TableLength is > 0, then elements of RegisterTableEntry are used t= o=0D + // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me,=0D + // after SMBASE relocation is performed.=0D + // If a register table is not required for any one of the CPUs, then=0D + // RegisterTable may be set to 0.=0D + //=0D + EFI_PHYSICAL_ADDRESS RegisterTable;=0D + //=0D + // CPU information which is required when set the register table.=0D + //=0D + CPU_STATUS_INFORMATION CpuStatus;=0D + //=0D + // Location info for each AP.=0D + // It points to an array which saves all APs location info.=0D + // The array count is the AP count in this CPU.=0D + //=0D + // If the platform does not support MSR setting at S3 resume, and=0D + // therefore it doesn't need the dependency semaphores, it should set=0D + // this field to 0.=0D + //=0D + EFI_PHYSICAL_ADDRESS ApLocation;=0D +} CPU_FEATURE_INIT_DATA;=0D +=0D //=0D // Data structure that is required for ACPI S3 resume. The PCD=0D // PcdCpuS3DataAddress must be set to the physical address where this stru= cture=0D @@ -172,28 +224,6 @@ typedef struct { //=0D EFI_PHYSICAL_ADDRESS MtrrTable;=0D //=0D - // Physical address of an array of CPU_REGISTER_TABLE structures, with=0D - // NumberOfCpus entries. If a register table is not required, then the= =0D - // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to= 0.=0D - // If TableLength is > 0, then elements of RegisterTableEntry are used t= o=0D - // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me,=0D - // before SMBASE relocation is performed.=0D - // If a register table is not required for any one of the CPUs, then=0D - // PreSmmInitRegisterTable may be set to 0.=0D - //=0D - EFI_PHYSICAL_ADDRESS PreSmmInitRegisterTable;=0D - //=0D - // Physical address of an array of CPU_REGISTER_TABLE structures, with=0D - // NumberOfCpus entries. If a register table is not required, then the= =0D - // TableLength and AllocatedSize fields of CPU_REGISTER_TABLE are set to= 0.=0D - // If TableLength is > 0, then elements of RegisterTableEntry are used t= o=0D - // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me,=0D - // after SMBASE relocation is performed.=0D - // If a register table is not required for any one of the CPUs, then=0D - // RegisterTable may be set to 0.=0D - //=0D - EFI_PHYSICAL_ADDRESS RegisterTable;=0D - //=0D // Physical address of a buffer that contains the machine check handler = that=0D // is used during an ACPI S3 Resume. In order for this machine check=0D // handler to be active on an AP during an ACPI S3 resume, the machine c= heck=0D @@ -208,19 +238,10 @@ typedef struct { //=0D UINT32 ApMachineCheckHandlerSize;=0D //=0D - // CPU information which is required when set the register table.=0D - //=0D - CPU_STATUS_INFORMATION CpuStatus;=0D - //=0D - // Location info for each AP.=0D - // It points to an array which saves all APs location info.=0D - // The array count is the AP count in this CPU.=0D - //=0D - // If the platform does not support MSR setting at S3 resume, and=0D - // therefore it doesn't need the dependency semaphores, it should set=0D - // this field to 0.=0D + // Data structure that is used for CPU feature initialization during ACP= I S3=0D + // resume.=0D //=0D - EFI_PHYSICAL_ADDRESS ApLocation;=0D + CPU_FEATURE_INIT_DATA CpuFeatureInitData;=0D } ACPI_CPU_DATA;=0D =0D #endif=0D --=20 2.28.0.windows.1