linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] efi/libstub: describe memory functions
@ 2020-02-17 21:13 Heinrich Schuchardt
  2020-02-17 21:25 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-02-17 21:13 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: linux-efi, linux-kernel, Heinrich Schuchardt

Provide descriptions of:

* efi_get_memory_map()
* efi_low_alloc_above()
* efi_free()

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/firmware/efi/libstub/mem.c | 31 ++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
index c25fd9174b74..be24c062115f 100644
--- a/drivers/firmware/efi/libstub/mem.c
+++ b/drivers/firmware/efi/libstub/mem.c
@@ -16,6 +16,15 @@ static inline bool mmap_has_headroom(unsigned long buff_size,
 	return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS;
 }

+/**
+ * efi_get_memory_map() - get memory map
+ * @map		on return pointer to memory map
+ *
+ * Retrieve the UEFI memory map. The allocated memory leaves room for
+ * up to EFI_MMAP_NR_SLACK_SLOTS additional memory map entries.
+ *
+ * Return:	status code
+ */
 efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
 {
 	efi_memory_desc_t *m = NULL;
@@ -109,8 +118,20 @@ efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr,
 	}
 	return EFI_SUCCESS;
 }
-/*
- * Allocate at the lowest possible address that is not below 'min'.
+/**
+ * efi_low_alloc_above() - allocate pages at or above given address
+ * @size:	size of the memory area to allocate
+ * @align:	minimum alignment of the allocated memory area. It should
+ *		a power of two.
+ * @addr:	on exit the address of the allocated memory
+ * @min:	minimum address to used for the memory allocation
+ *
+ * Allocate at the lowest possible address that is not below 'min' as
+ * EFI_LOADER_DATA. The allocated pages are aligned according to 'align' but at
+ * least EFI_ALLOC_ALIGN. The first allocated page will not below the address
+ * given by 'min'.
+ *
+ * Return:	status code
  */
 efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
 				 unsigned long *addr, unsigned long min)
@@ -187,6 +208,12 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
 	return status;
 }

+/**
+ * efi_free() - free memory pages
+ * @size	size of the memory area to free in bytes
+ * @addr	start of the memory area to free (must be EFI_PAGE_SIZE
+ *		aligned)
+ */
 void efi_free(unsigned long size, unsigned long addr)
 {
 	unsigned long nr_pages;
--
2.25.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] efi/libstub: describe memory functions
  2020-02-17 21:13 [PATCH 1/1] efi/libstub: describe memory functions Heinrich Schuchardt
@ 2020-02-17 21:25 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2020-02-17 21:25 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: linux-efi, Linux Kernel Mailing List

On Mon, 17 Feb 2020 at 22:14, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Provide descriptions of:
>
> * efi_get_memory_map()
> * efi_low_alloc_above()
> * efi_free()
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Thanks Heinrich. One comment below.

> ---
>  drivers/firmware/efi/libstub/mem.c | 31 ++++++++++++++++++++++++++++--
>  1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c
> index c25fd9174b74..be24c062115f 100644
> --- a/drivers/firmware/efi/libstub/mem.c
> +++ b/drivers/firmware/efi/libstub/mem.c
> @@ -16,6 +16,15 @@ static inline bool mmap_has_headroom(unsigned long buff_size,
>         return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS;
>  }
>
> +/**
> + * efi_get_memory_map() - get memory map
> + * @map                on return pointer to memory map
> + *
> + * Retrieve the UEFI memory map. The allocated memory leaves room for
> + * up to EFI_MMAP_NR_SLACK_SLOTS additional memory map entries.
> + *
> + * Return:     status code
> + */
>  efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
>  {
>         efi_memory_desc_t *m = NULL;
> @@ -109,8 +118,20 @@ efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr,
>         }
>         return EFI_SUCCESS;
>  }
> -/*
> - * Allocate at the lowest possible address that is not below 'min'.
> +/**
> + * efi_low_alloc_above() - allocate pages at or above given address
> + * @size:      size of the memory area to allocate
> + * @align:     minimum alignment of the allocated memory area. It should
> + *             a power of two.
> + * @addr:      on exit the address of the allocated memory
> + * @min:       minimum address to used for the memory allocation
> + *
> + * Allocate at the lowest possible address that is not below 'min' as
> + * EFI_LOADER_DATA. The allocated pages are aligned according to 'align' but at
> + * least EFI_ALLOC_ALIGN. The first allocated page will not below the address
> + * given by 'min'.
> + *
> + * Return:     status code
>   */
>  efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
>                                  unsigned long *addr, unsigned long min)
> @@ -187,6 +208,12 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
>         return status;
>  }
>
> +/**
> + * efi_free() - free memory pages
> + * @size       size of the memory area to free in bytes
> + * @addr       start of the memory area to free (must be EFI_PAGE_SIZE
> + *             aligned)
> + */

It may be good to mention here that the allocation is rounded up to
EFI_ALLOC_ALIGN again, so it should only be used for allocation that
were made using efi_allocate_pages() or efi_low_alloc_above().


>  void efi_free(unsigned long size, unsigned long addr)
>  {
>         unsigned long nr_pages;
> --
> 2.25.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-17 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 21:13 [PATCH 1/1] efi/libstub: describe memory functions Heinrich Schuchardt
2020-02-17 21:25 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).