[edk2-devel] [PATCH 03/10] EmbeddedPkg/MemoryAllocationLib: Add null stub for AllocateCopyPool

Ard Biesheuvel ardb at kernel.org
Tue Dec 14 13:59:09 UTC 2021


On Tue, 14 Dec 2021 at 14:42, Min Xu <min.m.xu at intel.com> wrote:
>
> RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429
>
> This function is a null stub to make the build success.
>
> Cc: Michael D Kinney <michael.d.kinney at intel.com>
> Cc: Brijesh Singh <brijesh.singh at amd.com>
> Cc: Erdem Aktas <erdemaktas at google.com>
> Cc: James Bottomley <jejb at linux.ibm.com>
> Cc: Jiewen Yao <jiewen.yao at intel.com>
> Cc: Tom Lendacky <thomas.lendacky at amd.com>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: Leif Lindholm <leif at nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
> Cc: Abner Chang <abner.chang at hpe.com>
> Cc: Daniel Schaefer <daniel.schaefer at hpe.com>
> Signed-off-by: Min Xu <min.m.xu at intel.com>
> ---
>  .../MemoryAllocationLib.c                     | 28 +++++++++++++++++++
>  1 file changed, 28 insertions(+)
>

Why is it justified to implement a broken version of this routine?
This is not a NULL library class that only exists for build test
purposes, it is actually used in production builds.

If the TDVF code needs the symbol but does not actually call it,
perhaps there is another place where this should get fixed?


> diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 78f8da5e9527..ddc27150c680 100644
> --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> @@ -220,6 +220,34 @@ AllocateZeroPool (
>    return Buffer;
>  }
>
> +/**
> +  Copies a buffer to an allocated buffer of type EfiBootServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
> +  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
> +  allocated buffer.  If AllocationSize 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 Buffer is NULL, then ASSERT().
> +  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +  @param  Buffer                The buffer to copy to the allocated buffer.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateCopyPool (
> +  IN UINTN       AllocationSize,
> +  IN CONST VOID  *Buffer
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
>  /**
>    Frees a buffer that was previously allocated with one of the pool allocation functions in the
>    Memory Allocation Library.
> --
> 2.29.2.windows.2
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84816): https://edk2.groups.io/g/devel/message/84816
Mute This Topic: https://groups.io/mt/87720795/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list