From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web08.9042.1632986504693129394 for ; Thu, 30 Sep 2021 00:21:45 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ISTzQ1eH; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="223234560" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="223234560" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 00:21:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="479756733" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga007.fm.intel.com with ESMTP; 30 Sep 2021 00:21:43 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 30 Sep 2021 00:21:42 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 30 Sep 2021 00:21:42 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.47) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 30 Sep 2021 00:21:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQvhZ9g1PlntAIKbiMOvzASUsU6dmJxc+sM6t9nbQIfJcyM8H1xZXdiPBtjNURom+upphwlw1WL/rX1PyQKem14ke3Z+2gPLFyBOFmCezOzyvNQwPnTDLOo4bifx2C+3cSu6WRTE9RzcUBPeGN8DA/TkficYKEnG3qaUh1vItAyqtm23wKAn/lrgh5iDzZIwCvnHxH5fEN9sV3nDydAJQUil7O8vDRwaUUIASU3pIDIigMF9HmrQSrCZmCFRfMCG99jDWXOm1JtS4Tdq2YFmu+/oI6OVoOI1gdWmfGTiPu7Gkk8Kzd0r41AxUCH5yGCzVYbMhRkZJoowCyRYtd245Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=66MwMnjWh4hMFMdKRs2CBhBMORktkLhW8NUvUqHC3Ho=; b=Id1ps6RIkynlZ20X1fkpS6XEci7LF6FB/5FmyrCbKu13MC7mlM/w2ODMYKzD9gIwGBnz4VsPI1cH/Q6TcuN+3F+KxqXTya0w3J4f5jvWlxTokP5OIly26XhCvlgR8PgrsYxMYMn+tMn+F8Q0ynU/8wXFuiz24F+TJn5Qes2LI9qfV/LYETvkTNfQxnuGBUYNCjqwiaelZGi7RVb+EFX5irXJ1RQwlK+yhXDF0uXTg7lPKMteMnP0E9QoM1K5NDkqfygcpY6dpWGbsTvX4KFbXzrSOq6+jus9ozBAnzDRZ+tcG2H/Y+DkgoF3aBrY+HNy5csMGlELs9n3rf+8MpjFBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=66MwMnjWh4hMFMdKRs2CBhBMORktkLhW8NUvUqHC3Ho=; b=ISTzQ1eHcfaHXuNeWNQ/IgP5j7XiMgNxQW9nDndqXHZ9g4uO/G1SwFeLNMess0SJGunJNaoD8rhZoTGl2PSz+Dw7+AaAItRamoUf1zBxBgDfuyYn8JjA8IY4LAB+vXUdO11EyA8C+Dyxwh2AeIi1pxZeK3YTLhbQf89D8tCsxDI= Received: from CY4PR1101MB2072.namprd11.prod.outlook.com (2603:10b6:910:1d::15) by CY4PR11MB1448.namprd11.prod.outlook.com (2603:10b6:910:b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 07:21:39 +0000 Received: from CY4PR1101MB2072.namprd11.prod.outlook.com ([fe80::7dc5:34b5:bbff:832f]) by CY4PR1101MB2072.namprd11.prod.outlook.com ([fe80::7dc5:34b5:bbff:832f%8]) with mapi id 15.20.4566.015; Thu, 30 Sep 2021 07:21:39 +0000 From: "Ni, Ray" To: "Lou, Yun" , "devel@edk2.groups.io" CC: "Dong, Eric" , Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH v2] UefiCpuPkg: Cpu feature data stored in memory may be migrated Thread-Topic: [PATCH v2] UefiCpuPkg: Cpu feature data stored in memory may be migrated Thread-Index: AQHXtcQgpMZVirZ1YE6lNzUC0lz4Equ8LAqw Date: Thu, 30 Sep 2021 07:21:39 +0000 Message-ID: References: <20210930062624.1425-1-yun.lou@intel.com> In-Reply-To: <20210930062624.1425-1-yun.lou@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0829699e-338d-4c4c-1efe-08d983e2f222 x-ms-traffictypediagnostic: CY4PR11MB1448: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9gB3pKds86A9t9Hc2+qRJqiP/hjf8BddBop4iHs36IKr/ddaEkZ18QT5rpJ8babZp+HFyH0lM5OMAnlp2dAuN9kceq7l1S2jNmSmaZCwu/eFN8tZLQrwcBBsZxzcUpxDxyTzCX3VILupFiZ8lhmnpjpZqC/+C2C0CUWzyFwf6/bI6+0BQTU07bjF+i/SkHramvDvZQbXMI8aYZAPv2sLBxKbM0QzOCaP0f4wT5mSMie3aQMjTGuS0Tu8R1f6rP42w17jxqdbNRRJ5bLPHudFk/RZ0LybJyoceVCePLOsAp1wzQ9pxKEHVNHk+rY30vovBsMP0WpH7xokTrt2nXOZKm14glBiBm2OVSgPoMMuKPnCZav/zXV07MYVjUPylj00cLtlAjhq1N7eOnanoUK0SRDGaaCEG8Z7e5k+fu/8vuY9sN/Z7x/aMU6et5D1WfTdqYTMpJGMqQwikE2TqfIfwEM3VVb+NyM4eWZTjDBWHr7b89Q/7j96M9IqBDdjBSr8QJNJ0B8jJnAtasoUWIOJhjO+KKFX+egP7eJGY46nYTByf4KE798xhAwFruhGjAkFwp+ckXPzjdV/q7TT/IJUSSHdCQ79FKL1vycXr82IYXZ6Z6eOJWciDQRa6zLypmxHzF/15MH7hMd+xJEKVueVKTw/9uJtrwsRo1Zlk6HqTZjhjzmLiVbsOMQ7OeonodebCTao2ikAxejJyVdR9dJlLaLB57am3bjr9bRC2WZychSqCnDguoKwCE56l9WqfRqb0ZZuM8SaAxsB+tqta2wQTsnJ7SJrDElOnFgzJu6VviA= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR1101MB2072.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(66556008)(64756008)(66446008)(26005)(52536014)(66476007)(86362001)(83380400001)(76116006)(2906002)(4326008)(8936002)(53546011)(186003)(6506007)(7696005)(71200400001)(66946007)(9686003)(55016002)(5660300002)(8676002)(38100700002)(110136005)(508600001)(966005)(38070700005)(122000001)(54906003)(107886003)(316002)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NL3pYirVrLKBmh9lB7UOuaxwHyZS1qSO5TGJut9FJ+jAiWKdDRBx53Oh2WcO?= =?us-ascii?Q?RV5rNHL0i4IWi9W/L+0ykQUUjlQweXPXl8T8U1f5AqllVJG6gEHP/0zzzy4I?= =?us-ascii?Q?XfVJfKNuSrvTlv+TwdsaXrQKaxdK/uv7tv904w8TElrb0eip54nppBixs3WV?= =?us-ascii?Q?LRykTi9/ull/7ebfilwnjK5l2Bs9OVyfckJUM0PBi9kBpuGhLJSwq6Jt0APw?= =?us-ascii?Q?sGEk4wrqK7bGzhl1MJBKVPp/GE+nClWju1ddZMO11MqcqWfTFvZlBBpXwaBx?= =?us-ascii?Q?lrTCKG9TbnwJ3iVvMlAMtgCg15NdbmM1CInmL+fOdLDIRGqdcjT5bHzOmEk8?= =?us-ascii?Q?s3cZClDjbCbAAOrdigq6YC+VNjnDnEQwU0jol7N93Nf/xTJeDGe3qjY+g1uD?= =?us-ascii?Q?kznya4Hwy06oqXdGK+o0wTf1oiUh5W7by0AH52yPgpYyfw95jdxFlbkSpBXT?= =?us-ascii?Q?V04AEvCc5Rhr1eYwWoaWEjexr6WNpgEzuQA1acU0TQnJevXUvpa18tpXD1TS?= =?us-ascii?Q?Umeuosz+nCb60jyv8pVwpmvdQFho4BjFBi6WZdehwsh0U/eXlbozvKLVohXc?= =?us-ascii?Q?8PNEHtpSProf8qA06h0F6c8DyOzWI/dxBuZV2pVf9JtyPffesxrf/jQeBqyo?= =?us-ascii?Q?ttQxCAZ7E9FubZj/7toCIYBo7Ubg2o49WYXopVWTJRQgLyATxQQwj98IIKab?= =?us-ascii?Q?UOsOL0FbzNfho/Z+qnlCRYe0OWKrD8RQvYyJQCqYmz5oVjgcXI6D/tZzR8QI?= =?us-ascii?Q?1szA150TkjTtYNsHDcZZGC5nISB2hytDXYgcVo29bxdo+gxxT7rn7uE4CV/R?= =?us-ascii?Q?Ou5vMIttKQxstg5S3DJ9qPTaiRHZNs236wC1WHBuUI06131NkTonOey2r3a8?= =?us-ascii?Q?YRDYnEsQM4S5i+rEC5uO5No3MGyu6eu/GmP9heibwjksWLRHYGefddiXNzp+?= =?us-ascii?Q?W34n6JUwn2+KH5nGZPs8Tl1RxBXsJv2z5UwXEDN178oVRgPFkA4is6E5vnel?= =?us-ascii?Q?hbLmHf+aVIjo6zbOT71uE6K2AxgYAGyC8msOHkcsb+8aSpb022Pw6jQEXpHq?= =?us-ascii?Q?AiaqbGGLJ6qTDOQvYYLjOpe0NdawqwSX7PnVE5uN+ihliXEkAf6OzeQ0nnYi?= =?us-ascii?Q?W2ozvBcawI6a6LLX+2PCeZ8tk6gh4p2NkcH3funVWe5p9RB4+2ryH7fxhfkb?= =?us-ascii?Q?llTPPu/TMBSgk1D2h9EI8LX3+rQPZ5Z3OO3A508dUQZ71o8sLWU45ixWNnON?= =?us-ascii?Q?rDRsRFcmHqzbgYTlNPSt3zh4TuRdMSoab06Uo1ibQBypURQce3nd4lFmvvEb?= =?us-ascii?Q?tpB5lI1UF8gbfX70YChg6Tzh?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR1101MB2072.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0829699e-338d-4c4c-1efe-08d983e2f222 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Sep 2021 07:21:39.6806 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Bs2mvPLSeCzn/I54rfGQ0lYFROihhguu+/o2y/xsQhKtJFsD+udIc0U0qr+Rjq/TTD+Bu809BI6k4bx+vWjgIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1448 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Lou, Yun > Sent: Thursday, September 30, 2021 2:26 PM > To: devel@edk2.groups.io > Cc: Lou, Yun ; Ni, Ray ; Dong, Eric = ; Laszlo Ersek > ; Kumar, Rahul1 > Subject: [PATCH v2] UefiCpuPkg: Cpu feature data stored in memory may be = migrated >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3634 >=20 > 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. >=20 > Signed-off-by: Jason Lou > Cc: Ray Ni > Cc: Eric Dong > Cc: Laszlo Ersek > Cc: Rahul Kumar > --- > UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 9 ++= ++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitial= ize.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 >=20 >=20 > CpuStatus =3D &AcpiCpuData->CpuFeatureInitData.CpuStatus; >=20 > - Location =3D AllocateZeroPool (sizeof (EFI_CPU_PHYSICAL_LOCATION) * Nu= mberOfCpus); >=20 > + Location =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (EFI_CPU_PHYSICA= L_LOCATION) * NumberOfCpus)); >=20 > ASSERT (Location !=3D NULL); >=20 > + ZeroMem (Location, sizeof (EFI_CPU_PHYSICAL_LOCATION) * NumberOfCpus); >=20 > AcpiCpuData->CpuFeatureInitData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(= UINTN)Location; >=20 >=20 >=20 > for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorN= umber++) { >=20 > @@ -205,12 +206,14 @@ CpuInitDataInitialize ( > // >=20 > // Collect valid core count in each package because not all cores are = valid. >=20 > // >=20 > - ThreadCountPerPackage =3D AllocateZeroPool (sizeof (UINT32) * CpuStatu= s->PackageCount); >=20 > + ThreadCountPerPackage =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UI= NT32) * CpuStatus->PackageCount)); >=20 > ASSERT (ThreadCountPerPackage !=3D NULL); >=20 > + ZeroMem (ThreadCountPerPackage, sizeof (UINT32) * CpuStatus->PackageCo= unt); >=20 > CpuStatus->ThreadCountPerPackage =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Thre= adCountPerPackage; >=20 >=20 >=20 > - ThreadCountPerCore =3D AllocateZeroPool (sizeof (UINT8) * CpuStatus->P= ackageCount * CpuStatus->MaxCoreCount); >=20 > + ThreadCountPerCore =3D AllocatePages (EFI_SIZE_TO_PAGES (sizeof (UINT8= ) * CpuStatus->PackageCount * CpuStatus- > >MaxCoreCount)); >=20 > ASSERT (ThreadCountPerCore !=3D NULL); >=20 > + ZeroMem (ThreadCountPerCore, sizeof (UINT8) * CpuStatus->PackageCount = * CpuStatus->MaxCoreCount); >=20 > CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadC= ountPerCore; >=20 >=20 >=20 > for (ProcessorNumber =3D 0; ProcessorNumber < NumberOfCpus; ProcessorN= umber++) { >=20 > -- > 2.28.0.windows.1