[PATCH 01/12] efi_loader: add runtime memset helper
Simon Glass
sjg at chromium.org
Tue Apr 28 20:08:59 CEST 2026
Hi Harsimran,
On 2026-04-24T17:31:50, Harsimran Singh Tungal
<harsimransingh.tungal at arm.com> wrote:
> efi_loader: add runtime memset helper
>
> 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.
>
> Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
>
> include/efi_loader.h | 3 +++
> lib/efi_loader/efi_runtime.c | 21 +++++++++++++++++++++
> 2 files changed, 24 insertions(+)
> diff --git 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 */
> +__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n);
> +
Two inconsistencies with the neighbouring declarations: the comment
should say memset() to match memcpy() / memcmp() above, and the
section attribute does not belong in the prototype, as
efi_memcpy_runtime() and efi_memcmp_runtime() carry __efi_runtime only
on the definition. Please drop it from the header.
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> @@ -233,6 +233,27 @@ int __efi_runtime efi_memcmp_runtime(const void *s1, const void *s2, size_t n)
> +/**
> + * efi_memset_runtime() - fill a memory region with a byte value
> + *
> + * At runtime memset() is not available.
> + *
> + * @dest: pointer to the block of memory to fill.
> + * @c: value to be set. The value is passed as an int, but the
> + * function fills the block of memory using the u8 conversion of this value.
> + * @n: number of bytes to be set to the value.
> + * Return: dest is returned
> + */
> +__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n)
Please match the kernel-doc style of the two helpers above: tabs after
the ':' in the parameter list, no trailing periods, one-line @c
description. The @c line is also over 80 columns. Flip the attribute
to 'void * __efi_runtime efi_memset_runtime(...)' to match
efi_memcpy_runtime() / efi_memcmp_runtime() in this same file.
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> @@ -233,6 +233,27 @@ int __efi_runtime efi_memcmp_runtime(const void *s1, const void *s2, size_t n)
> +__efi_runtime void *efi_memset_runtime(void *dest, int c, size_t n)
> +{
> + u8 *d = dest;
> +
> + for (; n; --n)
> + *d++ = c;
> +
> + return dest;
> +}
Just to check, was there a reason not to mask 'c' to a byte (i.e.
'*d++ = (u8)c') as the doc comment promises? An explicit cast matches
the comment and silences future -Wconversion noise.
Regards,
Simon
More information about the U-Boot
mailing list