RE: [Linux-ia64] RE: [PATCH] head.S fix for unusual load addrs

Luck, Tony
2003-05-19T17:57:03Z

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

Here's what the kcore change looks like if I take the suggestion
that Andi Kleen made on LKML
http://marc.theaimsgroup.com/?l=linux-kernel&m=103556903730989&w=2
to add the kernel to the vmlist. Combined with the KCORE_BASE
change (which is 98% included) we avoid the negative addresses
that required a bunch more changes in Andi's patch.

I've juggled the addresses around again, moving the kernel up to
0xA000004000000000 and VMALLOC_START back down to 0xA000000000030000
so that the entry for the kernel goes on the *end* of the vmlist,
so we don't have to uselessly step over it on every call to vmalloc().

I picked that kernel start address as it is half-way between
VMALLOC_START and VMALLOC_END for a PAGE_SIZE=4k kernel. There
are many alternatives ... choose a different one (between VMALLOC_START
and VMALLOC_END) if you come up with a good reason for a different
address.

This builds and boots on Tiger, and now I can run:

# gdb vmlinux /proc/kcore
(gdb) x/s log_buf

and see the contents of kernel memory.

-Tony

[-- Attachment #2: kcore2.diff --]
[-- Type: application/octet-stream, Size: 2672 bytes --]

diff -ru l2569-mosberger/arch/ia64/kernel/setup.c l2569-aegl/arch/ia64/kernel/setup.c
--- l2569-mosberger/arch/ia64/kernel/setup.c Fri May 16 11:46:57 2003
+++ l2569-aegl/arch/ia64/kernel/setup.c Fri May 16 17:11:18 2003
@@ -32,6 +32,7 @@
#include <linux/tty.h>
#include <linux/efi.h>
#include <linux/initrd.h>
+#include <linux/vmalloc.h>

#include <asm/ia32.h>
#include <asm/page.h>
@@ -47,7 +48,7 @@
# error "struct cpuinfo_ia64 too big!"
#endif

-extern char _end;
+extern char _stext, _end;

#ifdef CONFIG_SMP
unsigned long __per_cpu_offset[NR_CPUS];
@@ -393,6 +394,18 @@
{
extern unsigned long ia64_iobase;
unsigned long phys_iobase;
+ static struct vm_struct kern;
+ unsigned long s, e;
+
+ /* Add entry to vmlist for the kernel (round out to how much is mapped) */
+ s = (unsigned long)&_stext;
+ s &= ~(KERNEL_TR_PAGE_SIZE-1);
+ e = (unsigned long)&_end;
+ e = (e + KERNEL_TR_PAGE_SIZE-1) & ~(KERNEL_TR_PAGE_SIZE-1);
+ kern.addr = (void *)s;
+ kern.size = e - s;
+ kern.next = vmlist;
+ vmlist = &kern;

unw_init();

diff -ru l2569-mosberger/fs/proc/kcore.c l2569-aegl/fs/proc/kcore.c
--- l2569-mosberger/fs/proc/kcore.c Thu May 15 10:12:56 2003
+++ l2569-aegl/fs/proc/kcore.c Mon May 19 08:57:17 2003
@@ -99,7 +99,9 @@
}
#else /* CONFIG_KCORE_AOUT */

+#ifndef KCORE_BASE
#define KCORE_BASE PAGE_OFFSET
+#endif

#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))

diff -ru l2569-mosberger/include/asm-ia64/pgtable.h l2569-aegl/include/asm-ia64/pgtable.h
--- l2569-mosberger/include/asm-ia64/pgtable.h Fri May 16 11:46:57 2003
+++ l2569-aegl/include/asm-ia64/pgtable.h Mon May 19 09:04:30 2003
@@ -207,7 +207,8 @@
#define RGN_MAP_LIMIT ((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE) /* per region addr limit */
#define RGN_KERNEL 7

-#define VMALLOC_START 0xa000000200000000
+#define KCORE_BASE 0xa000000000000000
+#define VMALLOC_START (0xa000000000000000 + 3*PERCPU_PAGE_SIZE)
#define VMALLOC_VMADDR(x) ((unsigned long)(x))
#ifdef CONFIG_VIRTUAL_MEM_MAP
# define VMALLOC_END_INIT (0xa000000000000000 + (1UL << (4*PAGE_SHIFT - 9)))
diff -ru l2569-mosberger/include/asm-ia64/system.h l2569-aegl/include/asm-ia64/system.h
--- l2569-mosberger/include/asm-ia64/system.h Fri May 16 11:46:57 2003
+++ l2569-aegl/include/asm-ia64/system.h Mon May 19 09:05:25 2003
@@ -19,7 +19,7 @@
#include <asm/pal.h>
#include <asm/percpu.h>

-#define KERNEL_START (0xa000000100000000)
+#define KERNEL_START (0xa000004000000000)

/* 0xa000000000000000 - 0xa000000000000000+PERCPU_MAX_SIZE remain unmapped */
#define PERCPU_ADDR (0xa000000000000000 + PERCPU_PAGE_SIZE)