Commit 81ac3ad9061dd9cd490ee92f0c5316a14d77ce18
Committed by
Linus Torvalds
1 parent
26562c59fa
Exists in
master
and in
20 other branches
kcore: register module area in generic way
Some archs define MODULED_VADDR/MODULES_END which is not in VMALLOC area. This is handled only in x86-64. This patch make it more generic. And we can use vread/vwrite to access the area. Fix it. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Jiri Slaby <jirislaby@gmail.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 4 changed files with 28 additions and 5 deletions Side-by-side Diff
arch/x86/mm/init_64.c
... | ... | @@ -647,7 +647,7 @@ |
647 | 647 | |
648 | 648 | #endif /* CONFIG_MEMORY_HOTPLUG */ |
649 | 649 | |
650 | -static struct kcore_list kcore_modules, kcore_vsyscall; | |
650 | +static struct kcore_list kcore_vsyscall; | |
651 | 651 | |
652 | 652 | void __init mem_init(void) |
653 | 653 | { |
... | ... | @@ -676,8 +676,6 @@ |
676 | 676 | initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; |
677 | 677 | |
678 | 678 | /* Register memory areas for /proc/kcore */ |
679 | - kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN, | |
680 | - KCORE_OTHER); | |
681 | 679 | kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, |
682 | 680 | VSYSCALL_END - VSYSCALL_START, KCORE_OTHER); |
683 | 681 |
fs/proc/kcore.c
... | ... | @@ -490,7 +490,7 @@ |
490 | 490 | if (m == NULL) { |
491 | 491 | if (clear_user(buffer, tsz)) |
492 | 492 | return -EFAULT; |
493 | - } else if (is_vmalloc_addr((void *)start)) { | |
493 | + } else if (is_vmalloc_or_module_addr((void *)start)) { | |
494 | 494 | char * elf_buf; |
495 | 495 | |
496 | 496 | elf_buf = kzalloc(tsz, GFP_KERNEL); |
... | ... | @@ -586,6 +586,22 @@ |
586 | 586 | } |
587 | 587 | #endif |
588 | 588 | |
589 | +#if defined(CONFIG_MODULES) && defined(MODULES_VADDR) | |
590 | +/* | |
591 | + * MODULES_VADDR has no intersection with VMALLOC_ADDR. | |
592 | + */ | |
593 | +struct kcore_list kcore_modules; | |
594 | +static void __init add_modules_range(void) | |
595 | +{ | |
596 | + kclist_add(&kcore_modules, (void *)MODULES_VADDR, | |
597 | + MODULES_END - MODULES_VADDR, KCORE_VMALLOC); | |
598 | +} | |
599 | +#else | |
600 | +static void __init add_modules_range(void) | |
601 | +{ | |
602 | +} | |
603 | +#endif | |
604 | + | |
589 | 605 | static int __init proc_kcore_init(void) |
590 | 606 | { |
591 | 607 | proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, |
... | ... | @@ -595,6 +611,7 @@ |
595 | 611 | /* Store vmalloc area */ |
596 | 612 | kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, |
597 | 613 | VMALLOC_END - VMALLOC_START, KCORE_VMALLOC); |
614 | + add_modules_range(); | |
598 | 615 | /* Store direct-map area from physical memory map */ |
599 | 616 | kcore_update_ram(); |
600 | 617 | hotplug_memory_notifier(kcore_callback, 0); |
include/linux/mm.h
... | ... | @@ -285,6 +285,14 @@ |
285 | 285 | return 0; |
286 | 286 | #endif |
287 | 287 | } |
288 | +#ifdef CONFIG_MMU | |
289 | +extern int is_vmalloc_or_module_addr(const void *x); | |
290 | +#else | |
291 | +static int is_vmalloc_or_module_addr(const void *x) | |
292 | +{ | |
293 | + return 0; | |
294 | +} | |
295 | +#endif | |
288 | 296 | |
289 | 297 | static inline struct page *compound_head(struct page *page) |
290 | 298 | { |
mm/vmalloc.c