@@ -3035,7 +3035,8 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
if (WARN_ON(addr >= end))
return -EINVAL;
- arch_update_kernel_mappings_begin(start, end);
+ if (mm == &init_mm)
+ arch_update_kernel_mappings_begin(start, end);
pgd = pgd_offset(mm, addr);
do {
@@ -3057,7 +3058,8 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
break;
} while (pgd++, addr = next, addr != end);
- arch_update_kernel_mappings_end(start, end, mask);
+ if (mm == &init_mm)
+ arch_update_kernel_mappings_end(start, end, mask);
return err;
}
arch_update_kernel_mappings_[begin|end]() is called from __apply_to_page_range(), which operates both on kernel and user mappings. Previously arch_update_kernel_mappings_[begin|end]() was called unconditionally for both user and kernel mappings. The existing arch implementations of arch_sync_kernel_mappings() (which is called by the default implementation of arch_update_kernel_mappings_end()) filter on kernel address ranges so this change is still correct for those users. But given "kernel_mappings" is in the function name, we really shouldn't be calling it for user mappings. This change will also make the upcoming arm64 implementation simpler. Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> --- mm/memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)