Re: [PATCH v9 03/10] set_memory.h: Introduce can_set_direct_map_range()
From: Vincent Donnefort
Date: Mon Sep 07 2026 - 05:59:57 EST
On Sun, Sep 06, 2026 at 10:39:02PM +0300, Mike Rapoport wrote:
> On Wed, Sep 02, 2026 at 11:47:05AM +0100, Vincent Donnefort wrote:
> > While can_set_direct_map() tells whether the direct map can be modified
> > globally, can_set_direct_map_range() checks if a specific range can be
> > modified. e.g. if mapped at PTE-level.
>
> set_direct_map are going to have number of pages parameter soon:
>
> https://lore.kernel.org/all/20260903-execmem-set-vm-perms-v0-2-v3-1-949b64a9f755@xxxxxxxxxx
>
> so this check can be a part of arm64::set_direct_map
ack.
>
> I wouldn't expose can_set_direct_map_range() as a public API and rely on
> the callers to "Do The Right Thing".
ack.
Thanks for having a look at the series.
--
Vincent
>
> > Signed-off-by: Vincent Donnefort <vdonnefort@xxxxxxxxxx>
> >
> > diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h
> > index 3030d9245f5a..88175c3fa751 100644
> > --- a/include/linux/set_memory.h
> > +++ b/include/linux/set_memory.h
> > @@ -44,6 +44,12 @@ static inline bool kernel_page_present(struct page *page)
> > {
> > return true;
> > }
> > +
> > +static inline bool can_set_direct_map_range(struct page *page,
> > + unsigned long nr_pages)
> > +{
> > + return false;
> > +}
> > #else /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
> > /*
> > * Some architectures, e.g. ARM64 can disable direct map modifications at
> > @@ -56,6 +62,14 @@ static inline bool can_set_direct_map(void)
> > }
> > #define can_set_direct_map can_set_direct_map
> > #endif
> > +
> > +#ifndef can_set_direct_map_range
> > +static inline bool can_set_direct_map_range(struct page *page, unsigned long nr_pages)
> > +{
> > + return can_set_direct_map();
> > +}
> > +#define can_set_direct_map_range can_set_direct_map_range
> > +#endif
> > #endif /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
> >
> > #ifdef CONFIG_X86_64
> > --
> > 2.55.0.970.g62bdec98f9-goog
> >
>
> --
> Sincerely yours,
> Mike.