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 3A3B87803CD for ; Mon, 18 Dec 2023 02:23:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=w8z4bCzSi45nkWP7lxv1W0OWX4utwdFQkAc6UZKw8qU=; 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:msip_labels: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=1702866200; v=1; b=iWFJryWWhiA6gBLHS5+vSkDpSGZasaCXvLBOM5YU9tmV9sbGJshW9pfsSZ0McKuHVqIcH3tQ KU+6pj5W5vrXwTf5ANtC2sxtohFhywkp5SwbEhXZUNtOWmXBmyGCWySyTqRhvZiogoS2iMAEtGN kOV7TTqiPR4B4T7QJeiVNPEw= X-Received: by 127.0.0.2 with SMTP id L4ErYY7687511xfCldeqLymf; Sun, 17 Dec 2023 18:23:20 -0800 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.45]) by mx.groups.io with SMTP id smtpd.web11.33957.1702866200142765299 for ; Sun, 17 Dec 2023 18:23:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rt+R8+DuCJz2fTSs2UmH4Ocu+k3XHYn48twNnMksZ+VgIxS+fj8xQkYIVDT5IYS2PuSaVldHZmPMkjL3BWOs71W71Lxn5MM/OhppYf0WbRDQBFKdWqSZ7jrnpbWUeW6uP5XLXVkYsRRzdMHsLRny0b9ZLPHmIjpXi6+fXxrOMnoX16v4P3AxgiKLc0tyLRazjB+VMkmzg3mTqxAWcX61tfWqcmvtP5+udQKEkJsAPId//C5sV5FRAG6YJfEzTiYpILe3A2t4ZI/gZSacModjOvz0cxoAO1IcF2rEN0y58t8plckRTGvg6as6KhYPMhwE/Hqe4MhN2w9HAo66svhzcA== 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=ktkgk7hOHZU82c5Ej5o5o+ewoosFM76DiHk0jtY54WE=; b=C1bBJR4S530lec1sMcmMZVym6kiSonTpa0aimY1WjCVv+4mciwDcAiInixT3s5xPZsGcNExLsPjk5TgPwR2A2nEyIQk6b8OBQ+XRaradw/AbtnKaGhK3u39EBraf3mLlwXgKpSA10KB/OSClzfiXVcBIo+kb8I52JOUVm2gGdNgPjT5bYT45iuVhpYPEdfjxZJbRcvwY9CkHiq67yF7k1tT10hAHhl02yNdYHxM25j4G5meLsJoNy56xKvpzLSKma4ZHn21CH0OxBRbpgCvki5jjDHoPJbAyWpCe0CRbTlcKOq/hsNf7UP7AHLmtBJHR/BknpYwO14G86Ic71ZhAww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DM4PR12MB6494.namprd12.prod.outlook.com (2603:10b6:8:ba::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.37; Mon, 18 Dec 2023 02:23:17 +0000 X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::91d9:e679:32a3:dd05]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::91d9:e679:32a3:dd05%5]) with mapi id 15.20.7091.034; Mon, 18 Dec 2023 02:23:17 +0000 From: "Chang, Abner via groups.io" To: Jeff Brasen , "devel@edk2.groups.io" CC: "ardb+tianocore@kernel.org" , "quic_llindhol@quicinc.com" Subject: Re: [edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool Thread-Topic: [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool Thread-Index: AQHaLEmH8OQl+7v+J0e+kwCPNHv6C7CuWZ/g Date: Mon, 18 Dec 2023 02:23:16 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=8ccd0142-4806-4c43-b933-ae281cceb24f;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-12-18T02:22:50Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|DM4PR12MB6494:EE_ x-ms-office365-filtering-correlation-id: 7130ab71-9aba-4061-2657-08dbff704b30 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: py0uhCVsrK2oSMvWiUxgcMofNyGrQFoH2Cku86O9gh9Z7QMwTFlbwln95Qq/dL8jmJqmgPRWrTJZXoWrQ2JLS7zrgGlTiYOu5joLgElCGWAbS4/+rc5RSUP6L1RIGMryN9WPPm9j4yFR6DX2nL1780lmqm0vk4exK9A8H/wVEc7xYZFDjCkbgf5ppOT3rcJwkLya+tZcDtRYXf+wf6tELxRZfP4VwIY9KREQa2f2RZOn6Kr+MaZuGygDU1GxGDE/nRe7pCrQxp/Rhn8t+bILTYEFUimJNNj294MWZTj9tr6PBjwp4zTGiXOMrahY/vv43alDHm3oFZ2D2Pu+9GaMKm41wK6whCnADEgxmSzVU58ARFcvMB31iJFuTmca32sQJ2ejei2lzvuqpZDkTfslSeVYt+3/5pz+aSVKwFTE1T1gE7wYEvzkJo1/Io5dCsgxA/engjIhpIepFgVLbiGgyHXaw0ztJppGwlxRpnkil453FkNX8jI9n313v1UDzLBLhmaXM3lHtIyRoDvlcLjrYy2GMCBy9J7wWPzVBL8Vp4uDrv4pLKBykUunIQPhcah1FHT5Xbcr83H1Dax4y9cl/+f21z/FrMVTb/Kb4HTiQOm9gQFtvJq/OyKpq/4gmcKouFvyMp0FLVcWhOXWB7MxmPCu1pJ5q8XhNahd2oZfkiE= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Enr+5UKkNeF5oVIjo6+zSML094ViSbHk2eAQobd3AcyFJ6ij/ztPouWeeswT?= =?us-ascii?Q?laIpIpuBF6plhzjiONhpAUgrrfcSjwQuWiKaLmGX4Cz5yTEl6K38VxNbjVNv?= =?us-ascii?Q?4S188pTMCyiVRVHh5FOESUdNEtFiFcHZ1RBwimBylpIUUD8bsDXLNRdfHN2K?= =?us-ascii?Q?oWYOq8P2nvLVWgZj55AC6TFgYbwf2hS9He/LJTkq4xEI/b5wMeseyrcQZZwD?= =?us-ascii?Q?gdnTrUwXlL3nHoUde3WYkXSPuMie6Q6DsxGsOoXXdzDsdsTiGxoce3AvgY2u?= =?us-ascii?Q?igq5RB0JEkw1829IR/BZbrw9629rxtFKw7fIjToLpKUUe73akcUdYEj6g5AX?= =?us-ascii?Q?ZhMyb7q5SGDL0fXgegvYvvVG/OIPJlO08XSSK+N9pf6Yv75PHrVejfJ0S2tx?= =?us-ascii?Q?IX4haTwd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TymH9SG?= =?us-ascii?Q?3bxtpNLgTzaywqmmFAd0dOjk9PUVk6zC0l3oJA3aueQSaRERg+pPr5Txnvn3?= =?us-ascii?Q?lb1JpCbwNG/o4oJSCMGHoiCzlhyuZqhpoNPir1mKvJxdn6B3uokDQc30dDL+?= =?us-ascii?Q?BwkhFDhFtX+YfoCDs847QWdkWwcaDCgNXr6HhS2T3RN8mxO9SRxcvzj3uWB7?= =?us-ascii?Q?tz3wWT5L+Lqu1abtK46hCO1zZ9CS0oEMLp81BLOVUo29V3S3WeqhelPsvi/G?= =?us-ascii?Q?riSuAJ62RzqFMK0/KKs=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7130ab71-9aba-4061-2657-08dbff704b30 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2023 02:23:16.5581 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: A15b7wHdwGOXR49O9fxKY7aDi5KULWWe2t4yYqk660a/XZwUd0bRKDiqp6MWZQ8td6Zp+HNklDapfyfUhQ5aoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6494 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: yVPFr8tuJn3UfHsyJpEJ9YUwx7686176AA= 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=iWFJryWW; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=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 [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Jeff Brasen > Sent: Monday, December 11, 2023 11:48 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; ardb+tianocore@kernel.org; > quic_llindhol@quicinc.com; Jeff Brasen > Subject: [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add > ReallocatePool > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > Add implementation of ReallocatePool which is defined in the > MemoryAllocationLib header file to allow components to not > need special handling for PrePi module types. > > Signed-off-by: Jeff Brasen > --- > .../MemoryAllocationLib.c | 57 +++++++++++++++++++ > 1 file changed, 57 insertions(+) > > diff --git > a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > index 08a0add340..39fbe243dd 100644 > --- > a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > +++ > b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > @@ -269,3 +269,60 @@ FreePool ( > { > // Not implemented yet > } > + > +/** > + Reallocates a buffer of type EfiBootServicesData. > + > + Allocates and zeros the number bytes specified by NewSize from memory = of > type > + EfiBootServicesData. If OldBuffer is not NULL, then the smaller of Ol= dSize > and > + NewSize bytes are copied from OldBuffer to the newly allocated buffer,= and > + OldBuffer is freed. A pointer to the newly allocated buffer is return= ed. > + If NewSize is 0, then a valid buffer of 0 size is returned. If there= is not > + enough memory remaining to satisfy the request, then NULL is returned. > + > + If the allocation of the new buffer is successful and the smaller of N= ewSize > and OldSize > + is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). > + > + @param OldSize The size, in bytes, of OldBuffer. > + @param NewSize The size, in bytes, of the buffer to reallocate= . > + @param OldBuffer The buffer to copy to the allocated buffer. Th= is is an > optional > + parameter that may be NULL. > + > + @return A pointer to the allocated buffer or NULL if allocation fails. > + > +**/ > +VOID * > +EFIAPI > +ReallocatePool ( > + IN UINTN OldSize, > + IN UINTN NewSize, > + IN VOID *OldBuffer OPTIONAL > + ) > +{ > + VOID *NewBuffer; > + > + // Validate the OldBuffer is HobAllocated. > + DEBUG_CODE_BEGIN (); > + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; > + > + if (OldBuffer !=3D NULL) { > + HandOffHob =3D GetHobList (); > + ASSERT (((EFI_PHYSICAL_ADDRESS)OldBuffer >=3D HandOffHob- > >EfiMemoryBottom)); > + ASSERT (((EFI_PHYSICAL_ADDRESS)(OldBuffer + OldSize) <=3D HandOffHob= - > >EfiFreeMemoryBottom)); > + } > + > + DEBUG_CODE_END (); > + > + // If new buffer would be smaller just return old buffer as FreePool i= sn't > supported. > + if ((OldBuffer !=3D NULL) && (OldSize >=3D NewSize)) { > + return OldBuffer; > + } > + > + NewBuffer =3D AllocateZeroPool (NewSize); > + if ((NewBuffer !=3D NULL) && (OldBuffer !=3D NULL)) { > + CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize)); > + FreePool (OldBuffer); > + } > + > + return NewBuffer; > +} > -- > 2.34.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 (#112613): https://edk2.groups.io/g/devel/message/112613 Mute This Topic: https://groups.io/mt/103110962/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-