Skip to contentSkip to conversation

Support /proc/kcore for MIPS

PATCH In review Daniel Jacobowitz 4 participants 5 messages Jan 21, 2005 – Feb 7, 2006 MIPS

lore
Share & tools
lore
#0 lore raw

I wanted to do live debugging on an ornery task_struct this morning, so I hooked up /proc/kcore for MIPS. I'm pretty sure that the CKSEG0 bits are wrong, but I did need to cover that region - because the SB-1 kernel links at 0xffffffff80100000 or so, disassembly and printing static variables don't work unless the debugger can read that region.

arch/mips/mm/init.c +16 -0
Index: linux/arch/mips/mm/init.c
===================================================================
@@ -24,6 +24,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
+#include <linux/proc_fs.h>
 
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
@@ -197,6 +198,11 @@
 	return 0;
 }
 
+static struct kcore_list kcore_mem, kcore_vmalloc;
+#ifdef CONFIG_MIPS64
+static struct kcore_list kcore_kseg0;
+#endif
+
 void __init mem_init(void)
 {
 	unsigned long codesize, reservedpages, datasize, initsize;
@@ -247,6 +253,16 @@
 	datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
 	initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
 
+#ifdef CONFIG_MIPS64
+	if ((unsigned long) &_text > (unsigned long) CKSEG0)
+		/* The -4 is a hack so that user tools don't have to handle
+		   the overflow.  */
+		kclist_add(&kcore_kseg0, (void *) CKSEG0, 0x80000000 - 4);
+#endif
+	kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
+	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
+		   VMALLOC_END-VMALLOC_START);
+
 	printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
 	       "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
 	       (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
Signature · 1 line
Daniel Jacobowitz
#1 lore raw

Ping. I've now tested this patch in both 32-bit and 64-bit kernels.

Quoted 54 lines · Daniel Jacobowitz

I wanted to do live debugging on an ornery task_struct this morning, so I hooked up /proc/kcore for MIPS. I'm pretty sure that the CKSEG0 bits are wrong, but I did need to cover that region - because the SB-1 kernel links at 0xffffffff80100000 or so, disassembly and printing static variables don't work unless the debugger can read that region.

Index: linux/arch/mips/mm/init.c
===================================================================

arch/mips/mm/init.c +16 -0
@@ -24,6 +24,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
+#include <linux/proc_fs.h>
 
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
@@ -197,6 +198,11 @@
 	return 0;
 }
 
+static struct kcore_list kcore_mem, kcore_vmalloc;
+#ifdef CONFIG_MIPS64
+static struct kcore_list kcore_kseg0;
+#endif
+
 void __init mem_init(void)
 {
 	unsigned long codesize, reservedpages, datasize, initsize;
@@ -247,6 +253,16 @@
 	datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
 	initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
 
+#ifdef CONFIG_MIPS64
+	if ((unsigned long) &_text > (unsigned long) CKSEG0)
+		/* The -4 is a hack so that user tools don't have to handle
+		   the overflow.  */
+		kclist_add(&kcore_kseg0, (void *) CKSEG0, 0x80000000 - 4);
+#endif
+	kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
+	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
+		   VMALLOC_END-VMALLOC_START);
+
 	printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
 	       "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
 	       (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
Signature · 2 lines
-- 
Daniel Jacobowitz
Signature · 2 lines
Daniel Jacobowitz
CodeSourcery, LLC
#2 lore raw
Quoted 1 line · Daniel Jacobowitz

Ping. I've now tested this patch in both 32-bit and 64-bit kernels.

Ralf, can this be applied or are there objections?

Quoted 50 lines · Daniel Jacobowitz
Quoted 49 lines

I wanted to do live debugging on an ornery task_struct this morning, so I hooked up /proc/kcore for MIPS. I'm pretty sure that the CKSEG0 bits are wrong, but I did need to cover that region - because the SB-1 kernel links at 0xffffffff80100000 or so, disassembly and printing static variables don't work unless the debugger can read that region.

Index: linux/arch/mips/mm/init.c
===================================================================

arch/mips/mm/init.c +16 -0
@@ -24,6 +24,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
+#include <linux/proc_fs.h>
 
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
@@ -197,6 +198,11 @@
 	return 0;
 }
 
+static struct kcore_list kcore_mem, kcore_vmalloc;
+#ifdef CONFIG_MIPS64
+static struct kcore_list kcore_kseg0;
+#endif
+
 void __init mem_init(void)
 {
 	unsigned long codesize, reservedpages, datasize, initsize;
@@ -247,6 +253,16 @@
 	datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
 	initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
 
+#ifdef CONFIG_MIPS64
+	if ((unsigned long) &_text > (unsigned long) CKSEG0)
+		/* The -4 is a hack so that user tools don't have to handle
+		   the overflow.  */
+		kclist_add(&kcore_kseg0, (void *) CKSEG0, 0x80000000 - 4);
+#endif
+	kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
+	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
+		   VMALLOC_END-VMALLOC_START);
+
 	printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
 	       "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
 	       (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
Signature · 2 lines
Martin Michlmayr
http://www.cyrius.com/
#3 lore raw

PATCH 1/1 use CONFIG_64BIT for /proc/kcore fix

CONFIG_MIPS64 was replaced by CONFIG_64BIT a while ago.

arch/mips/mm/init.c +2 -2
index 4188df8..0ff9a34 100644
@@ -202,7 +202,7 @@ static inline int page_is_ram(unsigned l
 }
 
 static struct kcore_list kcore_mem, kcore_vmalloc;
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 static struct kcore_list kcore_kseg0;
 #endif
 
@@ -255,7 +255,7 @@ void __init mem_init(void)
 	datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
 	initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
 
-#ifdef CONFIG_MIPS64
+#ifdef CONFIG_64BIT
 	if ((unsigned long) &_text > (unsigned long) CKSEG0)
 		/* The -4 is a hack so that user tools don't have to handle
 		   the overflow.  */
#4 lore raw

Re: [PATCH] use CONFIG_64BIT for /proc/kcore fix

Quoted 1 line · Atsushi Nemoto

CONFIG_MIPS64 was replaced by CONFIG_64BIT a while ago.

Applied also.

Ralf