From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web09.9294.1632987354978990704 for ; Thu, 30 Sep 2021 00:35:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=SAMAFskx; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="288782894" X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="288782894" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 00:35:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,335,1624345200"; d="scan'208";a="476908618" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 30 Sep 2021 00:35:37 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx605.amr.corp.intel.com (10.18.126.85) 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:35:37 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) 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:35:37 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.168) by edgegateway.intel.com (192.55.55.68) 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:35:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELQ6OjT8ao/TLZB8VcrXA2zOlwvFbVAEqMQjduirxICqS8uukv3tVeLSY15qp1hnh8SMrFRVa0HFfN+E9ItJqb053v140lv7wJgY4zckcmOmhaBx78Se26HhE67ysuP53rmhik1tdqthuS/ituAcUp4Sz6w8e/Fg9Kto/19haPAv4VTXuvDhfbr40Iv3Fv54H0vd7WT0JbfB2OLCeTuFnT9+qQcFtBf/pCoAFQx5aQSRMCfIspU56Ua8elQMrczkbKbvHhMFIf/Ptw5VfZlHDrkSzmyP7GzbDVF32F23baaPs1IBj8G2iqWh9PAorhZ6L2UTpedFtE+z0Q+mXrSkaQ== 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=LKA3HQ4zO1w0n/UB1zKh1EBRjOwfuqXwgujlqQxAjso=; b=VjtF+CB6+L1zVZB5P+ESTFN0dJ9chJWaGLNKHOU6DtBS8j1oyQUxT/36Kjs+bqfiZt8GQTSTAzNr7wx2jdo7pHOMAUBPvJiNakijAABWUe1yFqK470fAheKXM6lj7+6lU+PHHyysIOSeuTwAjtXpNLKC6UHK7SAQMY6zLQZ3PlOk/zMTgcm87w4wR4TzX2NYme4Nl2fZ//eOppCCP7EsvdxsoSu/xhfK+soi9SEUaQVmVNKamkdAIbUDpxTgylVYhbrtHd9sC7l+nfRPTSuTo15loGEFFU5b6a94NR4DYmATMlzMTWEUSKM3LHhNvPM5tkAx7SdkXr/yQgMYj79jmw== 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=LKA3HQ4zO1w0n/UB1zKh1EBRjOwfuqXwgujlqQxAjso=; b=SAMAFskxt9U31XA7+oHja1QpBw2jCYF2YZydAeZVts3Pxv/K78uaSpRS7dwGOLuHzAyX5MtJ3a2PEwotfIG59vaFADUJysG1PAqn2Uly5aBSeVglzjmu6c5RQI9IgB+rdQathx5UQJBv1hbYLwawQ+KBADwj/MZbUxVXshgPKos= Received: from CY4PR1101MB2072.namprd11.prod.outlook.com (2603:10b6:910:1d::15) by CY4PR11MB1574.namprd11.prod.outlook.com (2603:10b6:910:f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.13; Thu, 30 Sep 2021 07:35:36 +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:35:36 +0000 From: "Ni, Ray" To: "Dong, Eric" , "Lou, Yun" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul1" Subject: Re: [PATCH v1] UefiCpuPkg: Cpu feature data stored in memory may be migrated Thread-Topic: [PATCH v1] UefiCpuPkg: Cpu feature data stored in memory may be migrated Thread-Index: AQHXtSijzaJ+TgzKrUe0/NfPOrOw/au7FFeAgAEcPZA= Date: Thu, 30 Sep 2021 07:35:36 +0000 Message-ID: References: <20210929115329.1220-1-yun.lou@intel.com> In-Reply-To: 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: 03535e4b-4520-41d8-d77a-08d983e4e4c0 x-ms-traffictypediagnostic: CY4PR11MB1574: 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: CILoosm6jfYwZGBVy64Zk/0mWESU1vwQhpEKi1iS7ekho6O9arAHFA2wx0H2kUW+NeeK3HhfIQaBABw+KAgG7oU48iaFzSI8EbeWJHDY9ZWqL3tc7jGzSF3hqaSr4kigmd2AE07/a7L1QgUiEaN3yOfRI4Ls/4/oKN6wGt+1A/as/x4VWDYLipZl/NccDjzffFxC9d//kG9VWCIbK2ccitFWYSmaHA4r5sS+qSLtvz2RLhYbXA7rSPMHHE/FFvOTurLwKblsRYL8cx250HSJn4UQHR7dQ4iSFHhyJSFxpXYjzUxA3Cbv7KFOjN4fN6AoUBj30qU3lt5+/Vwjq/qFtib4dvx6lVvtrhisKTTFbD9tFfE992g7mL4zhsAqvMKv6tUqCjN9ER8G0tNEGo5rFJvsiIm8r7GpRn3IzEi2ak2v0HLwKCWdj98YVFCP5EPtdHKnBHhucASSewAG1pPMhHQPwkjfCXi/LM2xNws76zibVEgQf0f5yg/+/Iq+7nPRAYLxsa9NFfo4Jd8JxBWUm8rHiQREOyxpZ86wfqY+s4D1vVxb28J1+Fwda+uhog0iqTArcgDeuZnoDg5ysLvjbg3WiW0wG5LrqYxcrEJauz8iPn/BKD8aePgthXMG5zvFj0676wFB9JEozXNLElL+BM2fJdjtkERCe5Z9zDV2BTUT1FWzDKtYEsFNIPhB6ErXXjh0yq5K9PNPjdcAFS1kfgv0eyAl9NqxBrtvLmBW+w0qhplIsp/r3ATZXIQutv46mvuhjyFhC1NmwSZcH90dRba7dKFZUnFM2yK/8En3wsc= 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)(84040400005)(4326008)(8936002)(66556008)(66446008)(64756008)(8676002)(86362001)(38100700002)(186003)(52536014)(122000001)(38070700005)(71200400001)(83380400001)(66946007)(33656002)(76116006)(66476007)(5660300002)(53546011)(7696005)(54906003)(26005)(110136005)(6506007)(966005)(55016002)(2906002)(316002)(107886003)(508600001)(9686003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Ep2vWgdC2srr25g7l+L9kKnfT0gMkQ3fGMV6gJAwVLYj3b11LTmCStib/ppq?= =?us-ascii?Q?mpaD3ep7B0auGXrN1ymlozhnF21JUPGBCt6Kk9XI62SSUZR4OSfegeBtWOCS?= =?us-ascii?Q?jQ74tQ2RBiwIb41cD2i/EetZdl5skSA5KlugtaoySHbF2TKFbWCEhalIEvNS?= =?us-ascii?Q?rHcGTZh8LwIKkpBZRPGFhRSI5rMpQbHBANiOsY/7pbRwZtf/5VEpVdBUqojD?= =?us-ascii?Q?gAVj64G9l6Bb26rZNYY+77b+rAKDv4WUL+a89UwC2mI8sZuRmZ5D+ag1PwSx?= =?us-ascii?Q?8F3u8CWxeKOVwxlFN9FgQZlJ+tTflxY7KsIxRl+58xKtR6gZEtiRbABaI0Y6?= =?us-ascii?Q?xLUUY+7RSU8kUHG+wsreREwGKuXZS2lHuwWxfnDJuLdBkxY4xP1pIE3n7YnV?= =?us-ascii?Q?933xtmMUszwnm68H4rioXcaPVGT9mTldFLo7wliWX4Qaom6dedPHADkkfqDn?= =?us-ascii?Q?WF8HV5aRpSB6rgefTiLVq2JpIXECB1lxmud7f+absF2J5iRzXivLzBrlYf4v?= =?us-ascii?Q?HdDM3F84UfxtM9wfhf8temuCv6j/HRvUASfUluQMgFaRzQWtFJJk2IFVuRY7?= =?us-ascii?Q?QfKbyr+J6rxD6KwWV8LKqG++bXHtSApDqrMD9BolDJIPaR7t4cMu7wO/Sl21?= =?us-ascii?Q?+4ecO7G6nrH2pVKrIQBons8ZLyhEO0iE+xWx4GWMN4ox23XTi+p0JnDadctA?= =?us-ascii?Q?kav0oPFrsLnnyZLsG0UjSjwl07Yj5Pn8RYveOKjjwfydnDB2Nt3/+Hf3D2lv?= =?us-ascii?Q?X/ntLfZpnsz1HhMKwpkefu0yGFGIgt4ZtdofvDoQ/l2P1ZPMfDcJ1fwQkgTG?= =?us-ascii?Q?NRO+6Xmf9YlxS35HaNn92OzhPIGS1UkXBmTEHAEg3EeJN2uwTiiZ2+7cVkzl?= =?us-ascii?Q?sHWDC8+RFfhnvyvV5UuuSIEl5plBP70rqcL69iEvmfw8pVKhgxucEuzdoSAu?= =?us-ascii?Q?mHWkaZG/mV5ZgusIlVlSk9ATIPt8aVp5DXu0TBn0LaTsJcseTsap2Wd39FYq?= =?us-ascii?Q?5XiiAhI7NjwbVmIGX3S+vC7GW/iU1SV87ie/rqNZ5f3ah4PBjYaiXLSvib8T?= =?us-ascii?Q?dIZnatCagfE1yCeHiBDRJLXUcQHEfKePPRmq18AxmG2YIqzcnAiJa/lZ358f?= =?us-ascii?Q?sMYinl9AfMn8ysCKos1xaj/4bQbXjFm2g/X2xJBJ1g46M8SA4hF11rTkPyVL?= =?us-ascii?Q?y15Q83AOhuDBv45++fAQANlYdlyO+OZiXzU86Pw30+MiWqVqzRqhFtvnSCr5?= =?us-ascii?Q?6l0BqzMkNhoSNNgkN/qC3rnBVtIggU2M81U7B0IBzz6QvMV2UM6JnDnt/t9y?= =?us-ascii?Q?ZEJhZs3aD+xr4GSSL3S7AxRV?= 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: 03535e4b-4520-41d8-d77a-08d983e4e4c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Sep 2021 07:35:36.1781 (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: Qgn12ouxgD6uNium48XzsN3GZjXMrUmvGi6KwuBQSqM73Shy8p3+KxDpm9iA5ashqP2hTMpc7o4Pt7Ps5XYRHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1574 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 Eric, it's related to how pool/page memory is allocated in PEI. The PEI pool is allocated in HOB. HOB data is migrated by DXE core to a new= location. The migration guarantees the HOB data is kept but doesn't fix up= the ACPI_CPU_DATA pointer that points to the HOB data. The PEI page is allocated between Phit->FreeMemoryTop and Phit->MemoryTop. = The location is not changed in DXE. Thanks, Ray > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, September 29, 2021 10:36 PM > To: Lou, Yun ; devel@edk2.groups.io > Cc: Ni, Ray ; Laszlo Ersek ; Kumar, = Rahul1 > Subject: RE: [PATCH v1] UefiCpuPkg: Cpu feature data stored in memory may= be migrated >=20 > Hi, >=20 > Can you help to explain more why PeiAllocatePages does not have the probl= em while PeiAllocatePool has? >=20 > Thanks, > Eric >=20 > -----Original Message----- > From: Lou, Yun > Sent: Wednesday, September 29, 2021 7:53 PM > To: devel@edk2.groups.io > Cc: Lou, Yun ; Ni, Ray ; Dong, Eric = ; Laszlo Ersek > ; Kumar, Rahul1 > Subject: [PATCH v1] 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 | 6 ++= +--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitial= ize.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 >=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 > AcpiCpuData->CpuFeatureInitData.ApLocation =3D (EFI_PHYSICAL_ADDRESS)(= UINTN)Location; >=20 >=20 >=20 > @@ -205,11 +205,11 @@ 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 > 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 > CpuStatus->ThreadCountPerCore =3D (EFI_PHYSICAL_ADDRESS)(UINTN)ThreadC= ountPerCore; >=20 >=20 >=20 > -- > 2.28.0.windows.1