Re: [PATCH v3 7/8] execmem: add support for cache of large ROX pages

Mike Rapoport
2024-09-15T13:51:46Z

Hi Ard,

On Fri, Sep 13, 2024 at 05:00:42PM +0200, Ard Biesheuvel wrote:
> Hi Mike,
>
> On Mon, 9 Sept 2024 at 08:51, Mike Rapoport <rppt@kernel.org> wrote:

...

> > +static void execmem_fill_trapping_insns(void *ptr, size_t size, bool writable)
> > +{
> > + if (execmem_info->fill_trapping_insns)
> > + execmem_info->fill_trapping_insns(ptr, size, writable);
> > + else
> > + memset(ptr, 0, size);
>
> Does this really have to be a function pointer with a runtime check?
>
> This could just be a __weak definition, with the arch providing an
> override if the memset() is not appropriate.

I prefer to keep this a method in execmem_info rather that have a __weak
definition that architectures can override.

This is not on the hot path, so I don't think a runtime check here would
matter. Still, I can fill in a default with memset at init time.

--
Sincerely yours,
Mike.