Re: [PATCH v2] docs/mm: describe set_memory() and set_direct_map() APIs
From: Mike Rapoport
Date: Tue Sep 22 2026 - 05:45:23 EST
On Mon, Sep 21, 2026 at 03:03:32PM +0200, Kevin Brodsky wrote:
> On 19/09/2026 12:43, Mike Rapoport (Microsoft) wrote:
> > [...]
> >
> > +Modifying the kernel page tables
> > +================================
> > +
> > +Except for the vmalloc area, the kernel page tables are mostly static. Still,
> > +there are cases when the permissions of existing kernel mappings have to be
> > +updated, for instance when a module is loaded and its text becomes read-only
> > +and executable, or when a page is temporarily removed from the direct map to
> > +reduce its exposure.
> > +
> > +There are two families of functions for this, both declared in
> > +`include/linux/set_memory.h`:
> > +
> > +* `set_memory_*()` change permissions of an arbitrary kernel mapping. They
> > + take a kernel virtual address and the number of pages.
> > +
> > +* `set_direct_map_*()` change permissions of the direct mapping of the page
> > + frame represented by a `struct page`. They take a `struct page` pointer and
>
> The new phrasing is a mouthful but at least should be accurate :) It
> should probably say "range of page frames" or something like that though.
It gets even more mouthful, but you are right, "range" should be there.
Andrew, can you please fold this in:
diff --git a/Documentation/mm/kernel-page-tables.rst b/Documentation/mm/kernel-page-tables.rst
index b3148df07fc8b..c16de34b4f79d 100644
--- a/Documentation/mm/kernel-page-tables.rst
+++ b/Documentation/mm/kernel-page-tables.rst
@@ -103,9 +103,9 @@ There are two families of functions for this, both declared in
* `set_memory_*()` change permissions of an arbitrary kernel mapping. They
take a kernel virtual address and the number of pages.
-* `set_direct_map_*()` change permissions of the direct mapping of the page
- frame represented by a `struct page`. They take a `struct page` pointer and
- the number of pages.
+* `set_direct_map_*()` change permissions of the direct mapping for the range
+ of page frames starting at the page represented by a `struct page`. They take
+ a `struct page` pointer and the number of pages.
Architectures that implement `set_memory()` select `CONFIG_ARCH_HAS_SET_MEMORY`
> Looks good otherwise!
>
> Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
>
--
Sincerely yours,
Mike.