Skip to content

Commit 9492587

Browse files
hkamezawatorvalds
authored andcommitted
kcore: register text area in generic way
Some 64bit arch has special segment for mapping kernel text. It should be entried to /proc/kcore in addtion to direct-linear-map, vmalloc area. This patch unifies KCORE_TEXT entry scattered under x86 and ia64. I'm not familiar with other archs (mips has its own even after this patch) but range of [_stext ..._end) is a valid area of text and it's not in direct-map area, defining CONFIG_ARCH_PROC_KCORE_TEXT is only a necessary thing to do. Note: I left mips as it is now. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.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>
1 parent a0614da commit 9492587

5 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎arch/ia64/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ config HAVE_ARCH_NODEDATA_EXTENSION
500500
def_bool y
501501
depends on NUMA
502502

503+
config ARCH_PROC_KCORE_TEXT
504+
def_bool y
505+
depends on PROC_KCORE
506+
503507
config IA32_SUPPORT
504508
bool "Support for Linux/x86 binaries"
505509
help

‎arch/ia64/mm/init.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ mem_init (void)
617617
long reserved_pages, codesize, datasize, initsize;
618618
pg_data_t *pgdat;
619619
int i;
620-
static struct kcore_list kcore_mem, kcore_kernel;
620+
static struct kcore_list kcore_mem;
621621

622622
BUG_ON(PTRS_PER_PGD * sizeof(pgd_t) != PAGE_SIZE);
623623
BUG_ON(PTRS_PER_PMD * sizeof(pmd_t) != PAGE_SIZE);
@@ -640,7 +640,6 @@ mem_init (void)
640640
high_memory = __va(max_low_pfn * PAGE_SIZE);
641641

642642
kclist_add(&kcore_mem, __va(0), max_low_pfn * PAGE_SIZE, KCORE_RAM);
643-
kclist_add(&kcore_kernel, _stext, _end - _stext, KCORE_TEXT);
644643

645644
for_each_online_pgdat(pgdat)
646645
if (pgdat->bdata->node_bootmem_map)

‎arch/x86/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,10 @@ config ARCH_DISCONTIGMEM_DEFAULT
12041204
def_bool y
12051205
depends on NUMA && X86_32
12061206

1207+
config ARCH_PROC_KCORE_TEXT
1208+
def_bool y
1209+
depends on X86_64 && PROC_KCORE
1210+
12071211
config ARCH_SPARSEMEM_DEFAULT
12081212
def_bool y
12091213
depends on X86_64

‎arch/x86/mm/init_64.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
647647

648648
#endif /* CONFIG_MEMORY_HOTPLUG */
649649

650-
static struct kcore_list kcore_mem, kcore_kernel,
651-
kcore_modules, kcore_vsyscall;
650+
static struct kcore_list kcore_mem, kcore_modules, kcore_vsyscall;
652651

653652
void __init mem_init(void)
654653
{
@@ -678,7 +677,6 @@ void __init mem_init(void)
678677

679678
/* Register memory areas for /proc/kcore */
680679
kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
681-
kclist_add(&kcore_kernel, &_stext, _end - _stext, KCORE_TEXT);
682680
kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN,
683681
KCORE_OTHER);
684682
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,

‎fs/proc/kcore.c‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <asm/uaccess.h>
2222
#include <asm/io.h>
2323
#include <linux/list.h>
24+
#include <asm/sections.h>
2425

2526
#define CORE_STR "CORE"
2627

@@ -374,10 +375,26 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
374375

375376
static struct kcore_list kcore_vmalloc;
376377

378+
#ifdef CONFIG_ARCH_PROC_KCORE_TEXT
379+
static struct kcore_list kcore_text;
380+
/*
381+
* If defined, special segment is used for mapping kernel text instead of
382+
* direct-map area. We need to create special TEXT section.
383+
*/
384+
static void __init proc_kcore_text_init(void)
385+
{
386+
kclist_add(&kcore_text, _stext, _end - _stext, KCORE_TEXT);
387+
}
388+
#else
389+
static void __init proc_kcore_text_init(void)
390+
{
391+
}
392+
#endif
393+
377394
static int __init proc_kcore_init(void)
378395
{
379396
proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);
380-
397+
proc_kcore_text_init();
381398
kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
382399
VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
383400
return 0;

0 commit comments

Comments
 (0)