From nobody Sun May 19 06:50:53 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+81279+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+81279+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632916417; cv=none; d=zohomail.com; s=zohoarc; b=fBCCyUyeyUszWlEMJckqr1JEASpfGK5dKcCyJiyKrUfJppNKHNqaxojGEnvxslLSwhKAlMLi/NdHYDzmt5pQVsyBSi/SYpkywHbagtLO/4p9t/jSM3HLxYsFcngXyOI2lu9BhX5fDKdA+0MZlzYceFDHovvHxUDwPH3OJec3lcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632916417; 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=+sCK0r/kv4i4W9cPgpNP8tG0RtTgJ6cgQUui0sf6w9Q=; b=CrqAhYN0u/AQnxo2Q7blrSkDw1P4ymvm72h9zmMoGRC/ZGevGHWyz8DftqGdTCYVJ3f9EJKqBhFhhqyHlspb7Wa3oXm/FGi4MeAFUjqLGKJzhB3HzJMpF1kfyQwOZH9dVtznRmgCn46V7GKqYR2VkFPKMlVagqJbn7bmpaEEbEs= 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+81279+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 1632916417737100.35051843880115; Wed, 29 Sep 2021 04:53:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zcnJYY1788612xkko7PNZK8y; Wed, 29 Sep 2021 04:53:37 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.7673.1632916416556250312 for ; Wed, 29 Sep 2021 04:53:36 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10121"; a="224992434" X-IronPort-AV: E=Sophos;i="5.85,332,1624345200"; d="scan'208";a="224992434" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 04:53:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,332,1624345200"; d="scan'208";a="519776124" X-Received: from shwdeopenlab102.ccr.corp.intel.com ([10.239.183.74]) by fmsmga008.fm.intel.com with ESMTP; 29 Sep 2021 04:53:33 -0700 From: "Jason Lou" To: devel@edk2.groups.io Cc: Jason , Ray Ni , Eric Dong , Laszlo Ersek , Rahul Kumar Subject: [edk2-devel] [PATCH v1] UefiCpuPkg: Cpu feature data stored in memory may be migrated Date: Wed, 29 Sep 2021 19:53:29 +0800 Message-Id: <20210929115329.1220-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: 0Xpbfhn0SNRAVZubOnqVO6Pnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632916417; bh=gsIwhdmwY0zVcqPnUU9jV3dGJKmTjIbbbA95Ln1mWRs=; h=Cc:Date:From:Reply-To:Subject:To; b=mVfYl0wM3Z0ICS58QcrhxDPoWrQB7JoeS+VXwIbEmOzjv8Dd3DicLBdcDW6MHnac7fM D97f6/sNuZ2IjI/cOPcDLL5z75Kc1edqY+pR7fyzM6GZfHq+CfR21GQDJsE5oz0R+GJdj CuxqIdpA2DnPKr1TR2g8W6aLQkZkWE+7ns8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632916419928100003 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 | 6 +++-= -- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 6e2ab79518..e9eba64914 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -153,7 +153,7 @@ 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); AcpiCpuData->CpuFeatureInitData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(UI= NTN)Location; =20 @@ -205,11 +205,11 @@ 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); 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); CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadCou= ntPerCore; =20 --=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 (#81279): https://edk2.groups.io/g/devel/message/81279 Mute This Topic: https://groups.io/mt/85946317/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-