From nobody Sun May 19 02:38:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+81314+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81314+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632983199; cv=none; d=zohomail.com; s=zohoarc; b=Hg4IU8IdNze7T4o6H/THdkqSj7sa8JHJKQ0rJUUbNZKPRW6GeG+acRcqJ4UuUBr5CgINn/3eBLz1jSNfeAuT2IaQWsi0qIx4WYc5hxGg0MyhLSQ/DW6eodq5FLtRcplywyn281EdnRtFHnjY2qjEu4GoNyAmEVbF7yMS1mKnsjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632983199; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=nIO0HckKaFh7pERweEHcH33iJcBKDYh06nRmKwMrf5Q=; b=KcNkeBWlbAqBi81hLrx0AL7x835y2y/dpzT8iQwWImKHF21RJ+mXYgRli0gYVyeeySfhhuFxGFHv+mwr/7Zz0CX4K8oQIfrY0gpgFO5NzKEMU7dacGdg/LR8S2l7JjzCWKp0OXLYbR29VJ7MtiiCMzniEgL2G7ugLmNYuK34i14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81314+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1632983199886858.9746747266112; Wed, 29 Sep 2021 23:26:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rOFGYY1788612x1R57AGiZsO; Wed, 29 Sep 2021 23:26:39 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.8858.1632983198807559275 for ; Wed, 29 Sep 2021 23:26:38 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="204596615" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="204596615" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 23:26:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="520225581" X-Received: from shwdeopenlab102.ccr.corp.intel.com ([10.239.183.74]) by fmsmga008.fm.intel.com with ESMTP; 29 Sep 2021 23:26:31 -0700 From: "Jason Lou" To: devel@edk2.groups.io Cc: Jason , Ray Ni , Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v2] UefiCpuPkg: Cpu feature data stored in memory may be migrated Date: Thu, 30 Sep 2021 14:26:24 +0800 Message-Id: <20210930062624.1425-1-yun.lou@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,yun.lou@intel.com X-Gm-Message-State: IPI4z2qqeRYpQBdL7BGaddFpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632983199; bh=yauxtuEOHbVVoU9KDYRGS8teyPY/QW8/XJnR58z7w0g=; h=Cc:Date:From:Reply-To:Subject:To; b=BJIJ1YLgnwkAx3a0qhKkhGlLr56IKYeY27kNLR67B7pKvSOSmBeCQs1VV35UURF8/GU W5Ye+EGCPMX3tlZJVXZwOPi6KHHMP9hpV9EiT4XG7YAql0aCrqBJHGkQTHbwjApp+HM5y GM1KcdbWBSOBFsHQidxPbi3B9cxLIKuMPU0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632983201852100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3634 The memory allocated through "PeiAllocatePool" is located in HOB, and in DXE phase, the HOB will be migrated to a different location. After the migration, the data stored in the HOB stays the same, but the address of pointer to the memory(such as the pointers in ACPI_CPU_DATA structure) changes, which may cause "PiSmmCpuDxeSmm" driver can't find the memory(the pointers in ACPI_CPU_DATA structure) that allocated in "PeiRegisterCpuFeaturesLib", so use "PeiAllocatePages" to allocate memory instead. Signed-off-by: Jason Lou Cc: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar Reviewed-by: Ray Ni --- UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 9 ++++= ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 6e2ab79518..a6534436a7 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -153,8 +153,9 @@ CpuInitDataInitialize ( CpuFeaturesData->AcpiCpuData=3D AcpiCpuData; =20 CpuStatus =3D &AcpiCpuData->CpuFeatureInitData.CpuStatus; - Location =3D AllocateZeroPool (sizeof (EFI_CPU_PHYSICAL_LOCATION) * Numb= erOfCpus); + Location =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (EFI_CPU_PHYSICAL_= LOCATION) * NumberOfCpus)); ASSERT (Location !=3D NULL); + ZeroMem (Location, sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus); AcpiCpuData->CpuFeatureInitData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UI= NTN)Location; =20 for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorNum= ber++) { @@ -205,12 +206,14 @@ CpuInitDataInitialize ( // // Collect valid core count in each package because not all cores are va= lid. // - ThreadCountPerPackage =3D AllocateZeroPool (sizeof (UINT32) * CpuStatus-= >PackageCount); + ThreadCountPerPackage =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UINT= 32) * CpuStatus->PackageCount)); ASSERT (ThreadCountPerPackage !=3D NULL); + ZeroMem (ThreadCountPerPackage, sizeof (UINT32) * CpuStatus->PackageCoun= t); CpuStatus->ThreadCountPerPackage =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Thread= CountPerPackage; =20 - ThreadCountPerCore =3D AllocateZeroPool (sizeof (UINT8) * CpuStatus->Pac= kageCount * CpuStatus->MaxCoreCount); + ThreadCountPerCore =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UINT8) = * CpuStatus->PackageCount * CpuStatus->MaxCoreCount)); ASSERT (ThreadCountPerCore !=3D NULL); + ZeroMem (ThreadCountPerCore, sizeof (UINT8) * CpuStatus->PackageCount * = CpuStatus->MaxCoreCount); CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCou= ntPerCore; =20 for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorNum= ber++) { --=20 2.28.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 (#81314): https://edk2.groups.io/g/devel/message/81314 Mute This Topic: https://groups.io/mt/85967849/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-