From nobody Fri May 17 11:05:26 2024 Delivered-To: importer@patchew.org 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+112312+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 170230972713845.248597625183606; Mon, 11 Dec 2023 07:48:47 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=KhdONycsEl5aBRTawNp544t+CK9R8Gl4Ncz9Ri6wPgU=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1702309726; v=1; b=YaaIVh+OpraRP/cGIsGnqfoAW57PRe+NSC8HebvrS6AxXlnn5euF2LANVKbc/2hyqzW1v0NU LarVTFUi8hMO3Bj3/tw3yMiAXHmbrOqdxCVswcURHAL2TvXybNs5lVgo3JFjB/iXxsDqkhbXHUi FEN0FckInYi7CTqVYmFjjVDE= X-Received: by 127.0.0.2 with SMTP id 91XIYY1788612xfGreKWlZgR; Mon, 11 Dec 2023 07:48:46 -0800 X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.107.96.69]) by mx.groups.io with SMTP id smtpd.web10.11737.1702309725990102665 for ; Mon, 11 Dec 2023 07:48:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOknDbnwgbViqmCY0SKb4GrdguEb7evPES09Zj88dR9nsd4AX0/QDbG2oBpoa5mTxzh7BWqdEASInyMGyiW1hcJmVk4sznGikzTmBySByr7XkV7i2xOO/4gObnEpsRCgA7fwXTF70SNt1MCukGrMExrxQvcKOnMkPOOMdt5xNS+aUy6jPUEUwsjhVOZP35b1Py/+T6vw1fnKLduwK4dolra3yawUVXxMTiQ/x0cEN+2Zgx+m/qpKw1SjTrvlMyknHX3Tet+mgGStiJGprNaoz5BwwFVhBLLbts+E8wOVLK1vtdxXr9j8b54FCCSTSqtYQJ/4IlBsys2R02Fmi9BD0A== 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=yvD7w1Wc0mfkUT40gSyC3Fs+ebu8c793C4eHa1LTuxc=; b=Vcn6DrJccSZ+xPY36/Pr6Cb9z+ewv4pr1X3N+a6zUnCjovf0fUYfpHD2S66Wgvx1vXo0R749i6KrgTGovwnKCQZCw9xUnFUaV4aFSSaw+m+CbdfigFJyVCLhXOKO3WpiNLRNMlZcmuH1NwaoRNuZegNlSoQQ3um5RDWj0C6QghNlOiloONTNXTisIzY9V30UBTxDMhsrQ9h57wpuihAjNuGlfAavlUeaYEKswz/pOKB2jDQQtVijR8qXPToY2WFHA/89wgaW0UGluptmHVOtQ3nUc1Z/eOJiFbdDCOkvffmkxUa2hvfAGgmPWQL27Is3LEPVq9hcrm3zc66EedL9ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from CH2PR11CA0011.namprd11.prod.outlook.com (2603:10b6:610:54::21) by SN7PR12MB6766.namprd12.prod.outlook.com (2603:10b6:806:26a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 15:48:43 +0000 X-Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:610:54:cafe::56) by CH2PR11CA0011.outlook.office365.com (2603:10b6:610:54::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Mon, 11 Dec 2023 15:48:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; 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+112312+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 15:48:42 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 11 Dec 2023 07:48:24 -0800 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 11 Dec 2023 07:48:23 -0800 X-Received: from 9365154cdc6c.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 11 Dec 2023 07:48:23 -0800 From: "Jeff Brasen via groups.io" To: CC: , , , Jeff Brasen Subject: [edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add ReallocatePool Date: Mon, 11 Dec 2023 07:48:21 -0800 Message-ID: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EB:EE_|SN7PR12MB6766:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ca42992-8c74-480f-d25a-08dbfa60a6bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: X14eo5brDGAUCW0nY7MNuBMq0EaGooEQOQAjdKb6oJWmviNd/Ej7DDgsV7c/yd+IWBhhTHE1Fy3dzsQbtGyNXCCRuZMERinYCaaR6Sc2PkLMuBa0hJNrhDIbgWhripNes5al8pyPwfub9i9mZkZyHDLHZ/YWOpSAtAjsSSyWZjzwUXDW4I9eY9TFKEOXktJ8ejcSWI60KwUff57co+GKqgCLufuTinPjzik1d1jX6PaSMqwh6KwM0e4FrRtFABbh4o70qsBGYhsbxDjV98mEafAiYOIPkeanl2bB69a8lH6iI/9ly4Sg7DevQJ3PjsO48q6v+hsbaAvO+qL2/WBX0T2jI5+WWBj0utoWd7MH20Ei7q50+6wA2o0D7wJgac6mrkesdVeBelp4hKpxgq57AtUpdDjPv5b4j3G7YbumdgyJTf6cCLX+Z6Au8N1vohRxT0UqmxuA0pafB4B/RQ/UZ4MEjxRcoMmDSMtUeY/JxbnGKYqIDK5moBU8VyMMIseWQPA2+KuBOXIguTO5zs1kt1RGUTPKR0/fIo7Md8tWb8lVlAsFfStfo3ikVnJbOT1hkFMq4ZhgQOXZbOyHeHeO4vCySvvvIyV2Xmdd4eLl6AaELCmoTiDgPBUzqayblB0fHS70cn4lgm/BwchTnCxxNqzS7iZWs62DcWfwhIqPOqlP4GW216tIOaEmmLYdbduYW+EvvDN7XsDhwzaqGXwtco9Itjt9ZZ5Bg3fhvwvmDrbKIBTLbubaJl9E91l8o5x1 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 15:48:42.2913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ca42992-8c74-480f-d25a-08dbfa60a6bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6766 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,jbrasen@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: CdWkIbHb0fQf6CtPyYQImbFsx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1702309729050100003 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Abner Chang Reviewed-by: Ard Biesheuvel --- .../MemoryAllocationLib.c | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationL= ib.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 OldS= ize and + NewSize bytes are copied from OldBuffer to the newly allocated buffer, a= nd + OldBuffer is freed. A pointer to the newly allocated buffer is returned. + If NewSize is 0, then a valid buffer of 0 size is returned. If there i= s 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 New= Size 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. This= 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->EfiMemoryBot= tom)); + ASSERT (((EFI_PHYSICAL_ADDRESS)(OldBuffer + OldSize) <=3D HandOffHob->= EfiFreeMemoryBottom)); + } + + DEBUG_CODE_END (); + + // If new buffer would be smaller just return old buffer as FreePool isn= '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; +} --=20 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 (#112312): https://edk2.groups.io/g/devel/message/112312 Mute This Topic: https://groups.io/mt/103110962/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-