public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: edk2-devel-groups-io <devel@edk2.groups.io>, Min Xu <min.m.xu@intel.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>,
	Abner Chang <abner.chang@hpe.com>,
	 Daniel Schaefer <daniel.schaefer@hpe.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [edk2-devel] [PATCH V2 3/8] EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib
Date: Wed, 3 Aug 2022 08:22:57 +0200	[thread overview]
Message-ID: <CAMj1kXHFsqQpDoZF5DiMbcMDUFviZO_TBTjKHftouGU2txJA9g@mail.gmail.com> (raw)
In-Reply-To: <ff5f7539fa150abab634bc245e3c2a5518d0d4e5.1656210686.git.min.m.xu@intel.com>

On Sun, 26 Jun 2022 at 05:06, Min Xu <min.m.xu@intel.com> wrote:
>
> From: Min M Xu <min.m.xu@intel.com>
>
> AllocateRuntimePages is used to allocate one or more 4KB pages of
> type EfiRuntimeServicesData.
>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Abner Chang <abner.chang@hpe.com>
> Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Min Xu <min.m.xu@intel.com>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  EmbeddedPkg/Include/Library/PrePiLib.h        | 19 ++++++
>  .../MemoryAllocationLib.c                     | 64 ++++++++++++++-----
>  2 files changed, 67 insertions(+), 16 deletions(-)
>
> diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h b/EmbeddedPkg/Include/Library/PrePiLib.h
> index 7b2cea296f1c..3741b08c4478 100644
> --- a/EmbeddedPkg/Include/Library/PrePiLib.h
> +++ b/EmbeddedPkg/Include/Library/PrePiLib.h
> @@ -665,6 +665,25 @@ AllocatePages (
>    IN UINTN  Pages
>    );
>
> +/**
> +  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
> +
> +  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimePages (
> +  IN UINTN  Pages
> +  );
> +
>  /**
>    Allocates a buffer of type EfiBootServicesData.
>
> diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 78f8da5e9527..9d7b34ad28fa 100644
> --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> @@ -14,23 +14,11 @@
>  #include <Library/PrePiLib.h>
>  #include <Library/DebugLib.h>
>
> -/**
> -  Allocates one or more 4KB pages of type EfiBootServicesData.
> -
> -  Allocates the number of 4KB pages of MemoryType and returns a pointer to the
> -  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> -  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> -  returned.
> -
> -  @param  Pages                 The number of 4 KB pages to allocate.
> -
> -  @return A pointer to the allocated buffer or NULL if allocation fails.
> -
> -**/
>  VOID *
>  EFIAPI
> -AllocatePages (
> -  IN UINTN  Pages
> +InternalAllocatePages (
> +  IN UINTN            Pages,
> +  IN EFI_MEMORY_TYPE  MemoryType
>    )
>  {
>    EFI_PEI_HOB_POINTERS  Hob;
> @@ -65,12 +53,56 @@ AllocatePages (
>      BuildMemoryAllocationHob (
>        Hob.HandoffInformationTable->EfiFreeMemoryTop,
>        Pages * EFI_PAGE_SIZE,
> -      EfiBootServicesData
> +      MemoryType
>        );
>      return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
>    }
>  }
>
> +/**
> +  Allocates one or more 4KB pages of type EfiBootServicesData.
> +
> +  Allocates the number of 4KB pages of MemoryType and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocatePages (
> +  IN UINTN  Pages
> +  )
> +{
> +  return InternalAllocatePages (Pages, EfiBootServicesData);
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
> +
> +  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimePages (
> +  IN UINTN  Pages
> +  )
> +{
> +  return InternalAllocatePages (Pages, EfiRuntimeServicesData);
> +}
> +
>  /**
>    Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
>
> --
> 2.29.2.windows.2
>
>
>
> 
>
>

  parent reply	other threads:[~2022-08-03  6:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-26  3:05 [PATCH V2 0/8] Enable secure-boot when lauch OVMF with -bios parameter Min Xu
2022-06-26  3:05 ` [PATCH V2 1/8] OvmfPkg: Move TdxValidateCfv from PeilessStartupLib to PlatformInitLib Min Xu
2022-06-27  7:02   ` Gerd Hoffmann
2022-06-27  8:04     ` Min Xu
2022-06-27  8:41       ` [edk2-devel] " Gerd Hoffmann
2022-06-29  5:16         ` Min Xu
2022-06-26  3:05 ` [PATCH V2 2/8] OvmfPkg: Validate Cfv integrity in Tdx guest Min Xu
2022-06-26  3:05 ` [PATCH V2 3/8] EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib Min Xu
2022-07-20  8:49   ` Min Xu
2022-08-03  2:26     ` Min Xu
2022-08-03  6:22   ` Ard Biesheuvel [this message]
2022-06-26  3:05 ` [PATCH V2 4/8] OvmfPkg/PlatformInitLib: Add functions for EmuVariableNvStore Min Xu
2022-06-27  9:10   ` Gerd Hoffmann
2022-06-29  5:16     ` [edk2-devel] " Min Xu
2022-06-26  3:05 ` [PATCH V2 5/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore Min Xu
2022-06-27  9:14   ` Gerd Hoffmann
2022-06-29  5:17     ` [edk2-devel] " Min Xu
2022-06-26  3:05 ` [PATCH V2 6/8] OvmfPkg: Reserve and init EmuVariableNvStore in Pei-less Startup Min Xu
2022-06-26  3:05 ` [PATCH V2 7/8] OvmfPkg/TdxDxe: Set PcdEmuVariableNvStoreReserved Min Xu
2022-06-26  3:05 ` [PATCH V2 8/8] OvmfPkg: Add build-flag SECURE_BOOT_FEATURE_ENABLED Min Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMj1kXHFsqQpDoZF5DiMbcMDUFviZO_TBTjKHftouGU2txJA9g@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox