Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9492587c authored by KAMEZAWA Hiroyuki's avatar KAMEZAWA Hiroyuki Committed by Linus Torvalds
Browse files

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: default avatarKAMEZAWA 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a0614da8
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -500,6 +500,10 @@ config HAVE_ARCH_NODEDATA_EXTENSION
	def_bool y
	def_bool y
	depends on NUMA
	depends on NUMA


config ARCH_PROC_KCORE_TEXT
	def_bool y
	depends on PROC_KCORE

config IA32_SUPPORT
config IA32_SUPPORT
	bool "Support for Linux/x86 binaries"
	bool "Support for Linux/x86 binaries"
	help
	help
+1 −2
Original line number Original line Diff line number Diff line
@@ -617,7 +617,7 @@ mem_init (void)
	long reserved_pages, codesize, datasize, initsize;
	long reserved_pages, codesize, datasize, initsize;
	pg_data_t *pgdat;
	pg_data_t *pgdat;
	int i;
	int i;
	static struct kcore_list kcore_mem, kcore_kernel;
	static struct kcore_list kcore_mem;


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


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


	for_each_online_pgdat(pgdat)
	for_each_online_pgdat(pgdat)
		if (pgdat->bdata->node_bootmem_map)
		if (pgdat->bdata->node_bootmem_map)
+4 −0
Original line number Original line Diff line number Diff line
@@ -1204,6 +1204,10 @@ config ARCH_DISCONTIGMEM_DEFAULT
	def_bool y
	def_bool y
	depends on NUMA && X86_32
	depends on NUMA && X86_32


config ARCH_PROC_KCORE_TEXT
	def_bool y
	depends on X86_64 && PROC_KCORE

config ARCH_SPARSEMEM_DEFAULT
config ARCH_SPARSEMEM_DEFAULT
	def_bool y
	def_bool y
	depends on X86_64
	depends on X86_64
+1 −3
Original line number Original line Diff line number Diff line
@@ -647,8 +647,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);


#endif /* CONFIG_MEMORY_HOTPLUG */
#endif /* CONFIG_MEMORY_HOTPLUG */


static struct kcore_list kcore_mem, kcore_kernel,
static struct kcore_list kcore_mem, kcore_modules, kcore_vsyscall;
			 kcore_modules, kcore_vsyscall;


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


	/* Register memory areas for /proc/kcore */
	/* Register memory areas for /proc/kcore */
	kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
	kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT, KCORE_RAM);
	kclist_add(&kcore_kernel, &_stext, _end - _stext, KCORE_TEXT);
	kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN,
	kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN,
			KCORE_OTHER);
			KCORE_OTHER);
	kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
	kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
+18 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/io.h>
#include <linux/list.h>
#include <linux/list.h>
#include <asm/sections.h>


#define CORE_STR "CORE"
#define CORE_STR "CORE"


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


static struct kcore_list kcore_vmalloc;
static struct kcore_list kcore_vmalloc;


#ifdef CONFIG_ARCH_PROC_KCORE_TEXT
static struct kcore_list kcore_text;
/*
 * If defined, special segment is used for mapping kernel text instead of
 * direct-map area. We need to create special TEXT section.
 */
static void __init proc_kcore_text_init(void)
{
	kclist_add(&kcore_text, _stext, _end - _stext, KCORE_TEXT);
}
#else
static void __init proc_kcore_text_init(void)
{
}
#endif

static int __init proc_kcore_init(void)
static int __init proc_kcore_init(void)
{
{
	proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);
	proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);

	proc_kcore_text_init();
	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
		VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
		VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
	return 0;
	return 0;