[PATCH v2] random: vDSO: Avoid call to memset() when zeroing reserved in __cvdso_getrandom_data()

Nathan Chancellor nathan at kernel.org
Fri Sep 25 15:19:21 PDT 2026


On Fri, Sep 25, 2026 at 03:00:46PM -0700, Nick Desaulniers wrote:
> > > > +static inline void *memset_inline(void *dst, int value, size_t size)
> > > > +{
> > > > +       char *d = dst;
> > > > +
> > > > +       while (size--)
> > > > +               *d++ = value;
> > > > +
> > > > +       return d;
> > > > +}
> > >
> > > Does this work?
> > > https://godbolt.org/z/Tx6EaGMfb
> >
> > Hmmm...possibly.
> > https://godbolt.org/z/ec9rzd9Yf
> > I don't get it...
> 
> Just keep it under 2 pages, it will be fine:
> https://godbolt.org/z/qqoMqfxev

Yeah, it might be worth a comment that this is only safe for small
values of size so it should not be blindly copied elsewhere (although I
guess if it is, the outlined version exists in the majority of other
places).

-- 
Cheers,
Nathan



More information about the linux-riscv mailing list