From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 283E9740054 for ; Wed, 6 Dec 2023 10:14:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zTGwrhDhdkYzU/lub65uQjTqjhWxuZGZuAwX9vDo9vk=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1701857684; v=1; b=WUznkxKeN7pgjVGVMGvgH/I4jAPBCnPzb/pi1MZpmJ3ufBzl/Kgc6yDsbg38Nb6DFsXAIl+j fKx0A2yxnksYr/TIXUJZoiBclJO7S9WPsb4rIy2vLsN85FQW3UvqBX33lrOEIS/hMxU0puAeuYT AtP/8iiYNmqQdutGeGlvjlnI= X-Received: by 127.0.0.2 with SMTP id nf0QYY7687511xgM8uGmCH8T; Wed, 06 Dec 2023 02:14:44 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mx.groups.io with SMTP id smtpd.web10.28527.1701857684102041376 for ; Wed, 06 Dec 2023 02:14:44 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="1105856" X-IronPort-AV: E=Sophos;i="6.04,254,1695711600"; d="scan'208";a="1105856" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 02:14:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,254,1695711600"; d="scan'208";a="19279066" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 06 Dec 2023 02:14:44 -0800 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 6 Dec 2023 02:14:43 -0800 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 6 Dec 2023 02:14:43 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 6 Dec 2023 02:14:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a/TYBBbUBrTV+PPNUTwPzW1j5t/sI4tabTiSyAQdAtIfO76aW58n6rqcodQ9xsLpEpdd/k7c/6Ip4szSJ7k+xXegO6YWxepgaV6nRzyLambn+ibJ+JOA0gGeLsGnU7Yt3xWQpB96xygQNmRqAPG4WREsvmraW3razsEfM50xlQqz877J/2sUMn3yH6IqepTjNXxCSTPw5iNsPF6xvvL7Czqdkyw9AnLHxXgA3Mk7syAwYL2vanHzybcpmwv9cPMBn1BRbFJia5w2SCcXsXvVnAq8+CKedD73jDlaY+fwIQwbBGZ27WzaJkoOIzaIKJAZTuJpeCAaJ5P20Jar4tMSuw== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H0ScRB7K1Qpr/vhWofmwLYi+nR0SCz/TFRy6yiPFj90=; b=nu4nbK/+CrBqANU6bJaOp8ziTDoYhbodNSpw21GERxf3AuOf6nK0WlD2QkTt2V/qs1SAE2McVKN+sg51G1P113oSqO470lurHEkI6nAbyxoFrA3zctmLlyagtA8JwhVTQa4dPPvMKYjNVGijgPw1hViM2LUfnRKJQE4rBmI6sPB7Pxl5rcOOoZxTcBzBAULXHgo/TtjQqjqunrKvHRC5smKQuEjzhA0E6endpQq/vvnDk05ZNRo91bZcqsnTIePq3Xn9WJf6W4tyMaF5BbwrHxV2rxLx67p/4ASxHaDzWEC8cAXiOnJQ5SqquoP7gvABnP3QuwL3r0l6ZKKDp70O/w== 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 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by DS0PR11MB7766.namprd11.prod.outlook.com (2603:10b6:8:138::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 10:14:35 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::b614:1f5e:8b0c:9858]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::b614:1f5e:8b0c:9858%4]) with mapi id 15.20.7046.034; Wed, 6 Dec 2023 10:14:34 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [edk2-devel] [PATCH 6/6] UefiCpuPkg: Avoid assuming only one smmbasehob Thread-Topic: [PATCH 6/6] UefiCpuPkg: Avoid assuming only one smmbasehob Thread-Index: AQHaJz7WWrojerSTqUuFdFtB2LzLs7CcCEsQ Date: Wed, 6 Dec 2023 10:14:34 +0000 Message-ID: References: <20231205054900.926-1-dun.tan@intel.com> <20231205054900.926-7-dun.tan@intel.com> In-Reply-To: <20231205054900.926-7-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|DS0PR11MB7766:EE_ x-ms-office365-filtering-correlation-id: f6898add-fe36-4346-0569-08dbf6442565 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: DJiru+yT2AHlvcHqA65cdo3rc83Vfh2EqnuJrC1nrRN8oCM/0wTpjYgES4z06tFUEqjXTqxwzZNYC2Dh1FEHE91y6Bc1bNJXbn613Dq7r94U+BwK1T1U8XFwqeMUM9O104lgHOsmEANKLlS54KPWsvXetq+QVFjqcvd0DKSkaobl3/IbWxY6e/tPjeXFwvwwKdkGfbnB8oGvtufWsBCxv5q+aUaE888ygojzGqajl/Sw17vf4d5oLeoaDVugd0uR6/D2VU41GVHOV2utK85Mse9YCmIu/oob2cUJkyszlnQ5gOQHxiioj+8HfwnlYyEVyy2SsRSjXtPBYhzIMIr6jfECQMlKXNsFgpMD7fX9dKMBOcejw/J3+H2gAd/QQp8vxS23PTWuBPxQ3r3jBZy0FmdBqv3ITje5WBk8uJPyyRB4exVsPcGH/bqL9ml23i+B0+v3+lLZ8SxCZHhJ8UxuSrCbDrEqFzLw7ldgxAqs+aqfkJhAtIh3cfZcICQ/cks02HYOuetmEXMuOi/uYmZM8y+XjhvRTnXPZG1ho8BmRYk1b09/LWX15V4cVYaXa0vhn2CmuvxA/5Mts+oCPcW+7xR99m8F1Oc+xTm2AIojEVys+kpwGUismRgD0Nm9+Z8K x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rfOY6ecCQRynN8QupV9/nXmp4AeE4ghRT6yZJdzYRL1tfsUL8SYuHgXXMPWu?= =?us-ascii?Q?pMdMgqssyWg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sHa?= =?us-ascii?Q?eNndrp1DSojZEnckHRpmf50eoPqgRiKwt7E2Dx2F8CDXrdji0mYGDX5fFa5a?= =?us-ascii?Q?oxJ9GOTnsl0J+lxY+2aKLtMDeAf7tHICImog3jl5MD84W1o/Dhq6NxnPhxlX?= =?us-ascii?Q?faRrZG0C7Padc3uXNJEb6YpIO14MXr1GcvcGG+TT7URiUBNNdxhhR42a6KJ3?= =?us-ascii?Q?hPLsLlm4+9pbrr9psa43TmORZnAQekaWL85sQLZW0HsThNqSJbTzuQLjxWsP?= =?us-ascii?Q?QHqLkG/hAiqsHwpLWyhE2kJuAGQcA60vkng0/kYz3iZ7jKF6pPrPYQNVnktj?= =?us-ascii?Q?ygDIRDCHGrulvtNGf4FhXMBHfCXcC0R1WAs7wxfav4r6MrNww+z/5CcXcN1m?= =?us-ascii?Q?a/x0QOK44JOPk0boe9nLPYsGjoSHzS+V5bQifMEYyCZCogxtVODC5JGI//Vf?= =?us-ascii?Q?0iU17n1sIoX1j7qtFjKoIOqs5LGmOxdMWcup/YrKEPABRZuYyArdHU96CTfw?= =?us-ascii?Q?MmTQ7Gor3E3H+zKeXdQxpYO+loB+R1ACukhfm9v0pZdtCqrd01GOhGBNktAs?= =?us-ascii?Q?iQIOdHM7p+frne65m6Huuu2qBuLcflIhyFoHzLVgWdgR1QOMfwek77rytLtw?= =?us-ascii?Q?i2DvhF/SdiYyj7HHIuU=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6898add-fe36-4346-0569-08dbf6442565 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Dec 2023 10:14:34.8494 (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: IZxHuWmCoeS1uyd2HTQ9OtbNp5GYwEHJjOEPAhpuXGD+Lxh9bS2tjr24WCMqmDFUGi0EuliQPXxHbGqSSwlrTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7766 X-OriginatorOrg: intel.com Precedence: Bulk 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,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: vxbiCOYwMzFPHixlFBMND5Y0x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=WUznkxKe; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") > +EFI_STATUS > +GetSmBaseFromSmmBaseHob ( > + IN EFI_HOB_GUID_TYPE *FirstSmmBaseGuidHob, > + IN UINTN MaxNumberOfCpus, > + OUT UINTN **SmBaseBufferPointer > + ) 1. It's a bit strange that caller should locate the first GuidHob. Can you update the existing code as follows: mCpuHotPlugData.SmBase =3D GetSmBase(mMaxNumberOfCpus); if (mCpuHotPlugData.SmBase !=3D NULL) { mSmmRelocated =3D TRUE; } > +{ > + UINTN HobCount; > + EFI_HOB_GUID_TYPE *GuidHob; > + SMM_BASE_HOB_DATA *SmmBaseHobData; > + UINTN NumberOfProcessors; > + SMM_BASE_HOB_DATA **SmBaseHobPointerBuffer; > + UINTN *SmBaseBuffer; > + UINTN Index; > + UINTN SortBuffer; > + UINTN ProcessorIndex; > + UINT64 PrevProcessorIndex; > + > + SmmBaseHobData =3D NULL; > + Index =3D 0; > + ProcessorIndex =3D 0; > + PrevProcessorIndex =3D 0; > + HobCount =3D 0; > + NumberOfProcessors =3D 0; > + GuidHob =3D FirstSmmBaseGuidHob; > + > + while (GuidHob !=3D NULL) { > + HobCount++; > + SmmBaseHobData =3D GET_GUID_HOB_DATA (GuidHob); > + NumberOfProcessors +=3D SmmBaseHobData->NumberOfProcessors; > + GuidHob =3D GetNextGuidHob (&gSmmBaseHobGuid, > GET_NEXT_HOB (GuidHob)); 2. We could break the while-loop when NumberOfProcessors equals to the valu= e we retrieved from MpInfo2Hob. Right? This can speed up the code when there are lots of HOBs after the last SmmBa= seHob instance. > + } > + > + ASSERT (NumberOfProcessors =3D=3D MaxNumberOfCpus); 3. ASSERT may fail when HotPlug is TRUE? > + > + SmBaseHobPointerBuffer =3D AllocatePool (sizeof (SMM_BASE_HOB_DATA *) > * HobCount); 4. SmBaseHobPointerBuffer -> SmBaseHobs > + for (Index =3D 0; Index < HobCount; Index++) { > + // > + // Make sure no overlap and no gap in the CPU range covered by each > HOB > + // > + ASSERT (SmBaseHobPointerBuffer[Index]->ProcessorIndex =3D=3D > PrevProcessorIndex); 5. similarly, can you move "PrevProcessorIndex" assignment to just above "f= or"? > + > + // > + // Cache each SmBase in order. > + // > + if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { > + CopyMem ( > + SmBaseBuffer + PrevProcessorIndex, > + &SmBaseHobPointerBuffer[Index]->SmBase, > + sizeof (UINT64) * > SmBaseHobPointerBuffer[Index]->NumberOfProcessors > + ); > + } else { > + for (ProcessorIndex =3D 0; ProcessorIndex < > SmBaseHobPointerBuffer[Index]->NumberOfProcessors; ProcessorIndex++) { > + SmBaseBuffer[PrevProcessorIndex + ProcessorIndex] =3D > (UINTN)SmBaseHobPointerBuffer[Index]->SmBase[ProcessorIndex]; > + } > + } 6. I don't like the "if-else" above. Can you just change SmBaseBuffer to UI= NT64 *? Or, you always use for-loop to copy SmBase value for each cpu. > + > + PrevProcessorIndex +=3D > SmBaseHobPointerBuffer[Index]->NumberOfProcessors; > + } > + > + FreePool (SmBaseHobPointerBuffer); > + > + *SmBaseBufferPointer =3D SmBaseBuffer; 7. Similarly, how about return SmBaseBuffer? -=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 (#112119): https://edk2.groups.io/g/devel/message/112119 Mute This Topic: https://groups.io/mt/102987142/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-