Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to
linux/pgtable.h so that they can be used outside of vmalloc and ioremap.
Cc: <stable@vger.kernel.org>
Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
---
include/linux/pgtable.h | 16 ++++++++++++++++
include/linux/vmalloc.h | 16 ----------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 4c035637eeb7..ba699df6ef69 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned
}
#endif
+/*
+ * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values
+ * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings()
+ * needs to be called.
+ */
+#ifndef ARCH_PAGE_TABLE_SYNC_MASK
+#define ARCH_PAGE_TABLE_SYNC_MASK 0
+#endif
+
+/*
+ * There is no default implementation for arch_sync_kernel_mappings(). It is
+ * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK
+ * is 0.
+ */
+void arch_sync_kernel_mappings(unsigned long start, unsigned long end);
+
#endif /* CONFIG_MMU */
/*
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index fdc9aeb74a44..2759dac6be44 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -219,22 +219,6 @@ extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
int vmap_pages_range(unsigned long addr, unsigned long end, pgprot_t prot,
struct page **pages, unsigned int page_shift);
-/*
- * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values
- * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings()
- * needs to be called.
- */
-#ifndef ARCH_PAGE_TABLE_SYNC_MASK
-#define ARCH_PAGE_TABLE_SYNC_MASK 0
-#endif
-
-/*
- * There is no default implementation for arch_sync_kernel_mappings(). It is
- * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK
- * is 0.
- */
-void arch_sync_kernel_mappings(unsigned long start, unsigned long end);
-
/*
* Lowlevel-APIs (not for driver use!)
*/
--
2.43.0
On Mon, Aug 11, 2025 at 02:34:18PM +0900, Harry Yoo wrote: > Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to > linux/pgtable.h so that they can be used outside of vmalloc and ioremap. > > Cc: <stable@vger.kernel.org> > Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges") > Signed-off-by: Harry Yoo <harry.yoo@oracle.com> LGTM, obviously assuming you address Mike's comments about... comments :) So: Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > --- > include/linux/pgtable.h | 16 ++++++++++++++++ > include/linux/vmalloc.h | 16 ---------------- > 2 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 4c035637eeb7..ba699df6ef69 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > } > #endif > > +/* > + * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > + * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > + * needs to be called. > + */ > +#ifndef ARCH_PAGE_TABLE_SYNC_MASK > +#define ARCH_PAGE_TABLE_SYNC_MASK 0 > +#endif > + > +/* > + * There is no default implementation for arch_sync_kernel_mappings(). It is > + * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > + * is 0. > + */ > +void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > + > #endif /* CONFIG_MMU */ > > /* > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > index fdc9aeb74a44..2759dac6be44 100644 > --- a/include/linux/vmalloc.h > +++ b/include/linux/vmalloc.h > @@ -219,22 +219,6 @@ extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, > int vmap_pages_range(unsigned long addr, unsigned long end, pgprot_t prot, > struct page **pages, unsigned int page_shift); > > -/* > - * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > - * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > - * needs to be called. > - */ > -#ifndef ARCH_PAGE_TABLE_SYNC_MASK > -#define ARCH_PAGE_TABLE_SYNC_MASK 0 > -#endif > - > -/* > - * There is no default implementation for arch_sync_kernel_mappings(). It is > - * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > - * is 0. > - */ > -void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > - > /* > * Lowlevel-APIs (not for driver use!) > */ > -- > 2.43.0 >
On Mon, Aug 11, 2025 at 02:34:18PM +0900, Harry Yoo wrote: > Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to > linux/pgtable.h so that they can be used outside of vmalloc and ioremap. > > Cc: <stable@vger.kernel.org> > Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges") > Signed-off-by: Harry Yoo <harry.yoo@oracle.com> > --- > include/linux/pgtable.h | 16 ++++++++++++++++ > include/linux/vmalloc.h | 16 ---------------- > 2 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 4c035637eeb7..ba699df6ef69 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > } > #endif > > +/* > + * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > + * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() If ARCH_PAGE_TABLE_SYNC_MASK can be used outside vmalloc(), the comment needs an update, maybe ... and let the generic code that modifies kernel page tables Other than that Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > + * needs to be called. > + */ > +#ifndef ARCH_PAGE_TABLE_SYNC_MASK > +#define ARCH_PAGE_TABLE_SYNC_MASK 0 > +#endif > + > +/* > + * There is no default implementation for arch_sync_kernel_mappings(). It is > + * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > + * is 0. > + */ > +void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > + > #endif /* CONFIG_MMU */ > > /* > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > index fdc9aeb74a44..2759dac6be44 100644 > --- a/include/linux/vmalloc.h > +++ b/include/linux/vmalloc.h > @@ -219,22 +219,6 @@ extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, > int vmap_pages_range(unsigned long addr, unsigned long end, pgprot_t prot, > struct page **pages, unsigned int page_shift); > > -/* > - * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > - * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > - * needs to be called. > - */ > -#ifndef ARCH_PAGE_TABLE_SYNC_MASK > -#define ARCH_PAGE_TABLE_SYNC_MASK 0 > -#endif > - > -/* > - * There is no default implementation for arch_sync_kernel_mappings(). It is > - * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > - * is 0. > - */ > -void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > - > /* > * Lowlevel-APIs (not for driver use!) > */ > -- > 2.43.0 > -- Sincerely yours, Mike.
On Mon, Aug 11, 2025 at 11:05:51AM +0300, Mike Rapoport wrote: > On Mon, Aug 11, 2025 at 02:34:18PM +0900, Harry Yoo wrote: > > Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to > > linux/pgtable.h so that they can be used outside of vmalloc and ioremap. > > > > Cc: <stable@vger.kernel.org> > > Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges") > > Signed-off-by: Harry Yoo <harry.yoo@oracle.com> > > --- > > include/linux/pgtable.h | 16 ++++++++++++++++ > > include/linux/vmalloc.h | 16 ---------------- > > 2 files changed, 16 insertions(+), 16 deletions(-) > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > index 4c035637eeb7..ba699df6ef69 100644 > > --- a/include/linux/pgtable.h > > +++ b/include/linux/pgtable.h > > @@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > > } > > #endif > > > > +/* > > + * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > > + * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > > If ARCH_PAGE_TABLE_SYNC_MASK can be used outside vmalloc(), the comment > needs an update, maybe > > ... and let the generic code that modifies kernel page tables > > Other than that > > Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > > > + * needs to be called. > > + */ > > +#ifndef ARCH_PAGE_TABLE_SYNC_MASK > > +#define ARCH_PAGE_TABLE_SYNC_MASK 0 > > +#endif > > + > > +/* > > + * There is no default implementation for arch_sync_kernel_mappings(). It is > > + * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > > + * is 0. > > + */ > > +void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > > + > > #endif /* CONFIG_MMU */ > > > > /* > > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > > index fdc9aeb74a44..2759dac6be44 100644 > > --- a/include/linux/vmalloc.h > > +++ b/include/linux/vmalloc.h > > @@ -219,22 +219,6 @@ extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, > > int vmap_pages_range(unsigned long addr, unsigned long end, pgprot_t prot, > > struct page **pages, unsigned int page_shift); > > > > -/* > > - * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > > - * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > > - * needs to be called. > > - */ > > -#ifndef ARCH_PAGE_TABLE_SYNC_MASK > > -#define ARCH_PAGE_TABLE_SYNC_MASK 0 > > -#endif > > - > > -/* > > - * There is no default implementation for arch_sync_kernel_mappings(). It is > > - * relied upon the compiler to optimize calls out if ARCH_PAGE_TABLE_SYNC_MASK > > - * is 0. > > - */ > > -void arch_sync_kernel_mappings(unsigned long start, unsigned long end); > > - > > /* > > * Lowlevel-APIs (not for driver use!) > > */ > > -- > > 2.43.0 > > > LGTM, Reviewed-by: "Uladzislau Rezki (Sony)" <urezki@gmail.com> -- Uladzislau Rezki
On Mon, Aug 11, 2025 at 11:05:51AM +0300, Mike Rapoport wrote: > On Mon, Aug 11, 2025 at 02:34:18PM +0900, Harry Yoo wrote: > > Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to > > linux/pgtable.h so that they can be used outside of vmalloc and ioremap. > > > > Cc: <stable@vger.kernel.org> > > Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges") > > Signed-off-by: Harry Yoo <harry.yoo@oracle.com> > > --- > > include/linux/pgtable.h | 16 ++++++++++++++++ > > include/linux/vmalloc.h | 16 ---------------- > > 2 files changed, 16 insertions(+), 16 deletions(-) > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > index 4c035637eeb7..ba699df6ef69 100644 > > --- a/include/linux/pgtable.h > > +++ b/include/linux/pgtable.h > > @@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > > } > > #endif > > > > +/* > > + * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > > + * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > > If ARCH_PAGE_TABLE_SYNC_MASK can be used outside vmalloc(), the comment > needs an update, maybe > > ... and let the generic code that modifies kernel page tables Right, and patch 2 updates the comment as it uses it outside vmalloc(): diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index ba699df6ef69..0cf5c6c3e483 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1469,8 +1469,8 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned /* * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values - * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() - * needs to be called. + * and let generic vmalloc, ioremap and page table update code know when + * arch_sync_kernel_mappings() needs to be called. */ #ifndef ARCH_PAGE_TABLE_SYNC_MASK #define ARCH_PAGE_TABLE_SYNC_MASK 0 Or if you think "page table update code" is unclear, please let me know. > Other than that > > Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Thanks a lot for all the reviews, Mike! -- Cheers, Harry / Hyeonggon
On Mon, Aug 11, 2025 at 05:36:53PM +0900, Harry Yoo wrote: > On Mon, Aug 11, 2025 at 11:05:51AM +0300, Mike Rapoport wrote: > > On Mon, Aug 11, 2025 at 02:34:18PM +0900, Harry Yoo wrote: > > > Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to > > > linux/pgtable.h so that they can be used outside of vmalloc and ioremap. > > > > > > Cc: <stable@vger.kernel.org> > > > Fixes: 8d400913c231 ("x86/vmemmap: handle unpopulated sub-pmd ranges") > > > Signed-off-by: Harry Yoo <harry.yoo@oracle.com> > > > --- > > > include/linux/pgtable.h | 16 ++++++++++++++++ > > > include/linux/vmalloc.h | 16 ---------------- > > > 2 files changed, 16 insertions(+), 16 deletions(-) > > > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > > index 4c035637eeb7..ba699df6ef69 100644 > > > --- a/include/linux/pgtable.h > > > +++ b/include/linux/pgtable.h > > > @@ -1467,6 +1467,22 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > > > } > > > #endif > > > > > > +/* > > > + * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > > > + * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > > > > If ARCH_PAGE_TABLE_SYNC_MASK can be used outside vmalloc(), the comment > > needs an update, maybe > > > > ... and let the generic code that modifies kernel page tables > > Right, and patch 2 updates the comment as it uses it outside vmalloc(): > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index ba699df6ef69..0cf5c6c3e483 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1469,8 +1469,8 @@ static inline void modify_prot_commit_ptes(struct vm_area_struct *vma, unsigned > > /* > * Architectures can set this mask to a combination of PGTBL_P?D_MODIFIED values > - * and let generic vmalloc and ioremap code know when arch_sync_kernel_mappings() > - * needs to be called. > + * and let generic vmalloc, ioremap and page table update code know when > + * arch_sync_kernel_mappings() needs to be called. > */ > #ifndef ARCH_PAGE_TABLE_SYNC_MASK > #define ARCH_PAGE_TABLE_SYNC_MASK 0 > > Or if you think "page table update code" is unclear, please let me know. It's fine :) > > Other than that > > > > Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > > Thanks a lot for all the reviews, Mike! > > -- > Cheers, > Harry / Hyeonggon -- Sincerely yours, Mike.
© 2016 - 2025 Red Hat, Inc.