[PATCH 01/12] efi_loader: add runtime memset helper

Harsimran Singh Tungal harsimransingh.tungal at arm.com
Mon May 4 22:03:14 CEST 2026


On 2026-04-28 12:08 -0600, Simon Glass wrote:
> 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.
>

Thanks for your feedback.
I will fix this in patchset v2.

Regards
Harsimran Singh Tungal

> > 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.
>

Sure, I will fix this in patchset v2.

Regards
Harsimran Singh Tungal

> > 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.
>

Thanks for noticing this.
No, there was no specific reason to not to mask 'c' to a byte.
I will do the suggested change in patchset v2.

Regards
Harsimran Singh Tungal

> Regards,
> Simon
> 




More information about the U-Boot mailing list