History

mm/memory.c: add apply_to_existing_page_range() helper

apply_to_page_range() takes an address range, and if any parts of it are not covered by the existing page table hierarchy, it allocates memory to fill them in. In some use cases, this is not what we want - we want to be able to operate exclusively on PTEs that are already in the tables. Add apply_to_existing_page_range() for this. Adjust the walker functions for apply_to_page_range to take 'create', which switches them between the old and new modes. This will be used in KASAN vmalloc. [akpm@linux-foundation.org: reduce code duplication] [akpm@linux-foundation.org: s/apply_to_existing_pages/apply_to_existing_page_range/] [akpm@linux-foundation.org: initialize __apply_to_page_range::err] Link: http://lkml.kernel.org/r/20191205140407.1874-1-dja@axtens.net Signed-off-by: Daniel Axtens <dja@axtens.net> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Daniel Axtens <dja@axtens.net> Cc: Qian Cai <cai@lca.pw> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Daniel Axtens committed 6 years ago

Commit be1db471 parent d98c9e82 files · +97 −42Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/mm.h+3−0
@@ -2621,6 +2621,9 @@ static inline int vm_fault_to_errno(vm_fault_t vm_fault, int foll_flags) · 2620 unmodified lines
2621typedef int (*pte_fn_t)(pte_t *pte, unsigned long addr, void *data);2621typedef int (*pte_fn_t)(pte_t *pte, unsigned long addr, void *data);
2622extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,2622extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
2623 unsigned long size, pte_fn_t fn, void *data);2623 unsigned long size, pte_fn_t fn, void *data);
2624extern int apply_to_existing_page_range(struct mm_struct *mm,
2625 unsigned long address, unsigned long size,
2626 pte_fn_t fn, void *data);
2624 2627
2625#ifdef CONFIG_PAGE_POISONING2628#ifdef CONFIG_PAGE_POISONING
2626extern bool page_poisoning_enabled(void);2629extern bool page_poisoning_enabled(void);