[PATCH v3 01/10] efi_loader: add runtime memset helper

Abdellatif El Khlifi abdellatif.elkhlifi at arm.com
Mon Jun 29 20:21:59 CEST 2026


On Sat, Jun 27, 2026 at 03:44:12PM +0100, Harsimran Singh Tungal wrote:
> Add efi_memset_runtime() for EFI runtime paths
> 
> This keeps buffer initialization in runtime-resident code after
> ExitBootServices() and avoids relying on non-runtime helpers.
> 
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
> ---
>  include/efi_loader.h         |  3 +++
>  lib/efi_loader/efi_runtime.c | 20 ++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 3a4d502631c..9dfea1fd7de 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -1151,6 +1151,9 @@ void efi_memcpy_runtime(void *dest, const void *src, size_t n);
>  /* runtime implementation of memcmp() */
>  int efi_memcmp_runtime(const void *s1, const void *s2, size_t n);
>  
> +/* runtime implementation of memset() */
> +void *efi_memset_runtime(void *dest, int c, size_t n);
> +
>  /* commonly used helper functions */
>  u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name,
>  			     unsigned int index);
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 73d4097464c..c0182931c42 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -233,6 +233,26 @@ int __efi_runtime efi_memcmp_runtime(const void *s1, const void *s2, size_t n)
>  	return 0;
>  }
>  
> +/**
> + * efi_memset_runtime() - fill memory area
> + *
> + * At runtime memset() is not available.
> + *
> + * @dest:	destination buffer
> + * @c:		byte value used to fill destination buffer
> + * @n:		number of bytes to set
> + * Return:	pointer to destination buffer
> + */
> +__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n)
> +{
> +	u8 *d = dest;
> +
> +	for (; n; --n)
> +		*d++ = (u8)c;
> +
> +	return dest;
> +}
> +
>  /**
>   * efi_update_table_header_crc32() - Update crc32 in table header
>   *
> -- 
> 2.34.1
> 

Reviewed-by: Abdellatif El Khlifi <abdellatif.elkhlifi at arm.com>


More information about the U-Boot mailing list