summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-05-19 15:49:07 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-05-19 15:49:07 +0000
commit55effb9ba5d36fabab2ee9010d12cba4ce97f7ab (patch)
tree9f72f6739eed57055aad3e02023fabf3ecd7de93 /sys/arch
parent912729879adc44cafe45c930dcbb3a9ffb07ea0e (diff)
Kernel crash dump support for arm-based platform, with minimal support in
libkvm, but all the necessary information for a complete _kvm_kvatop() is available in the crash dump.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm/arm/stubs.c47
-rw-r--r--sys/arch/arm/include/kcore.h15
-rw-r--r--sys/arch/armish/armish/armish_machdep.c36
-rw-r--r--sys/arch/armish/armish/autoconf.c5
-rw-r--r--sys/arch/cats/cats/autoconf.c4
-rw-r--r--sys/arch/cats/cats/cats_machdep.c13
-rw-r--r--sys/arch/zaurus/zaurus/autoconf.c5
-rw-r--r--sys/arch/zaurus/zaurus/zaurus_machdep.c14
8 files changed, 111 insertions, 28 deletions
diff --git a/sys/arch/arm/arm/stubs.c b/sys/arch/arm/arm/stubs.c
index 6e91e149e40..5d595a7568d 100644
--- a/sys/arch/arm/arm/stubs.c
+++ b/sys/arch/arm/arm/stubs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stubs.c,v 1.2 2004/02/01 06:10:33 drahn Exp $ */
+/* $OpenBSD: stubs.c,v 1.3 2007/05/19 15:49:05 miod Exp $ */
/* $NetBSD: stubs.c,v 1.14 2003/07/15 00:24:42 lukem Exp $ */
/*
@@ -47,11 +47,15 @@
#include <sys/proc.h>
#include <sys/conf.h>
#include <sys/msgbuf.h>
+#include <sys/exec.h>
+#include <sys/core.h>
+#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
+#include <machine/bootconfig.h>
#include <machine/cpu.h>
#include <machine/intr.h>
-#include <machine/bootconfig.h>
#include <machine/pcb.h>
+#include <arm/kcore.h>
#include <arm/machdep.h>
extern dev_t dumpdev;
@@ -62,7 +66,7 @@ extern dev_t dumpdev;
u_int32_t dumpmag = 0x8fca0101; /* magic number */
int dumpsize = 0; /* pages */
long dumplo = 0; /* blocks */
-
+cpu_kcore_hdr_t cpu_kcore_hdr;
struct pcb dumppcb;
/*
@@ -79,7 +83,7 @@ void
dumpconf()
{
const struct bdevsw *bdev;
- int nblks; /* size of dump area */
+ int block, nblks;
if (dumpdev == NODEV)
return;
@@ -99,10 +103,17 @@ dumpconf()
dumplo = ctod(1);
/* Put dump at end of partition, and make it fit. */
- if (dumpsize > dtoc(nblks - dumplo))
- dumpsize = dtoc(nblks - dumplo);
- if (dumplo < nblks - ctod(dumpsize))
- dumplo = nblks - ctod(dumpsize);
+ if (dumpsize + 1 > dtoc(nblks - dumplo))
+ dumpsize = dtoc(nblks - dumplo) - 1;
+ if (dumplo < nblks - ctod(dumpsize) - 1)
+ dumplo = nblks - ctod(dumpsize) - 1;
+
+ for (block = 0; block < bootconfig.dramblocks; block++) {
+ cpu_kcore_hdr.ram_segs[block].start =
+ bootconfig.dram[block].address;
+ cpu_kcore_hdr.ram_segs[block].size =
+ ptoa(bootconfig.dram[block].pages);
+ }
}
/* This should be moved to machdep.c */
@@ -126,6 +137,9 @@ dumpsys()
int block;
int len;
vaddr_t dumpspace;
+ kcore_seg_t *kseg_p;
+ cpu_kcore_hdr_t *chdr_p;
+ char dump_hdr[dbtob(1)]; /* assumes header fits in one block */
/* Save registers. */
savectx(&dumppcb);
@@ -160,9 +174,21 @@ dumpsys()
return;
}
- error = 0;
- len = 0;
+ /* Setup the dump header */
+ kseg_p = (kcore_seg_t *)dump_hdr;
+ chdr_p = (cpu_kcore_hdr_t *)&dump_hdr[ALIGN(sizeof(*kseg_p))];
+ bzero(dump_hdr, sizeof(dump_hdr));
+
+ CORE_SETMAGIC(*kseg_p, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
+ kseg_p->c_size = sizeof(dump_hdr) - ALIGN(sizeof(*kseg_p));
+ *chdr_p = cpu_kcore_hdr;
+ error = (*bdev->d_dump)(dumpdev, blkno++, (caddr_t)dump_hdr,
+ sizeof(dump_hdr));
+ if (error != 0)
+ goto abort;
+
+ len = 0;
for (block = 0; block < bootconfig.dramblocks && error == 0; ++block) {
addr = bootconfig.dram[block].address;
for (;addr < (bootconfig.dram[block].address
@@ -183,6 +209,7 @@ dumpsys()
}
}
+abort:
switch (error) {
case ENXIO:
printf("device bad\n");
diff --git a/sys/arch/arm/include/kcore.h b/sys/arch/arm/include/kcore.h
new file mode 100644
index 00000000000..02050490bbc
--- /dev/null
+++ b/sys/arch/arm/include/kcore.h
@@ -0,0 +1,15 @@
+/* $OpenBSD: kcore.h,v 1.1 2007/05/19 15:49:05 miod Exp $ */
+/* public domain */
+
+/* Make sure this is larger than DRAM_BLOCKS on all arm-based platforms */
+#define NPHYS_RAM_SEGS 8
+
+typedef struct cpu_kcore_hdr {
+ u_int32_t kernelbase; /* value of KERNEL_BASE */
+ u_int32_t kerneloffs; /* offset of kernel in RAM */
+ u_int32_t staticsize; /* size of contiguous mapping */
+ u_int32_t pmap_kernel_l1; /* pmap_kernel()->pm_l1 */
+ u_int32_t pmap_kernel_l2; /* pmap_kernel()->pm_l2 */
+ u_int32_t reserved[11];
+ phys_ram_seg_t ram_segs[NPHYS_RAM_SEGS];
+} cpu_kcore_hdr_t;
diff --git a/sys/arch/armish/armish/armish_machdep.c b/sys/arch/armish/armish/armish_machdep.c
index f4b388c43af..b4080e936f4 100644
--- a/sys/arch/armish/armish/armish_machdep.c
+++ b/sys/arch/armish/armish/armish_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: armish_machdep.c,v 1.9 2006/08/01 22:22:20 kettenis Exp $ */
+/* $OpenBSD: armish_machdep.c,v 1.10 2007/05/19 15:49:05 miod Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
@@ -89,6 +89,7 @@
#include <sys/msgbuf.h>
#include <sys/reboot.h>
#include <sys/termios.h>
+#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
@@ -106,6 +107,7 @@
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/frame.h>
+#include <arm/kcore.h>
#include <arm/undefined.h>
#include <arm/machdep.h>
@@ -340,6 +342,7 @@ u_int
initarm(void *arg)
{
extern vaddr_t xscale_cache_clean_addr;
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
int loop;
int loop1;
u_int l1pagetable;
@@ -448,7 +451,7 @@ initarm(void *arg)
* array.
*
* The kernel page directory must be on a 16K boundary. The page
- * tables must be on 4K bounaries. What we do is allocate the
+ * tables must be on 4K boundaries. What we do is allocate the
* page directory on the first 16K boundary that we encounter, and
* the page tables on 4K boundaries otherwise. Since we allocate
* at least 3 L2 page tables, we are guaranteed to encounter at
@@ -562,8 +565,10 @@ initarm(void *arg)
for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; loop++)
pmap_link_l2pt(l1pagetable, KERNEL_VM_BASE + loop * 0x00400000,
&kernel_pt_table[KERNEL_PT_VMDATA + loop]);
-// pmap_link_l2pt(l1pagetable, IQ80321_IOPXS_VBASE,
-// &kernel_pt_table[KERNEL_PT_IOPXS]);
+#if 0
+ pmap_link_l2pt(l1pagetable, IQ80321_IOPXS_VBASE,
+ &kernel_pt_table[KERNEL_PT_IOPXS]);
+#endif
/* update the top of the kernel VM */
pmap_curmaxkvaddr =
@@ -576,18 +581,29 @@ initarm(void *arg)
/* Now we fill in the L2 pagetable for the kernel static code/data
* and the symbol table. */
{
- extern char etext[], _end[];
+ extern char etext[];
+#ifdef VERBOSE_INIT_ARM
+ extern char _end[];
+#endif
size_t textsize = (u_int32_t) etext - KERNEL_TEXT_BASE;
size_t totalsize = esym - KERNEL_TEXT_BASE;
u_int logical;
-printf("kernelsize text %x total %x end %xesym %x\n", textsize, totalsize,
- _end, esym);
+
+#ifdef VERBOSE_INIT_ARM
+ printf("kernelsize text %x total %x end %xesym %x\n",
+ textsize, totalsize, _end, esym);
+#endif
textsize = round_page(textsize);
totalsize = round_page(totalsize);
logical = 0x00200000; /* offset of kernel in RAM */
+ /* Update dump information */
+ cpu_kcore_hdr.kernelbase = KERNEL_BASE;
+ cpu_kcore_hdr.kerneloffs = logical;
+ cpu_kcore_hdr.staticsize = totalsize;
+
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
@@ -658,8 +674,10 @@ printf("kernelsize text %x total %x end %xesym %x\n", textsize, totalsize,
free_pages =
(physical_freeend - physical_freestart) / PAGE_SIZE;
}
+#ifdef VERBOSE_INIT_ARM
printf("physical_freestart %x end %x\n", physical_freestart,
physical_freeend);
+#endif
/* be a client to all domains */
cpu_domains(0x55555555);
@@ -750,6 +768,10 @@ printf("kernelsize text %x total %x end %xesym %x\n", textsize, totalsize,
pmap_bootstrap((pd_entry_t *)kernel_l1pt.pv_va, KERNEL_VM_BASE,
KERNEL_VM_BASE + KERNEL_VM_SIZE);
+ /* Update dump information */
+ cpu_kcore_hdr.pmap_kernel_l1 = (u_int32_t)pmap_kernel()->pm_l1;
+ cpu_kcore_hdr.pmap_kernel_l2 = (u_int32_t)&(pmap_kernel()->pm_l2);
+
/* Setup the IRQ system */
#ifdef VERBOSE_INIT_ARM
printf("irq ");
diff --git a/sys/arch/armish/armish/autoconf.c b/sys/arch/armish/armish/autoconf.c
index dbe0f76c81f..7e9ca5b3d4c 100644
--- a/sys/arch/armish/armish/autoconf.c
+++ b/sys/arch/armish/armish/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.7 2007/05/15 01:56:47 deraadt Exp $ */
+/* $OpenBSD: autoconf.c,v 1.8 2007/05/19 15:49:05 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */
/*
@@ -62,6 +62,7 @@ struct device *bootdv = NULL;
extern char *boot_file;
void diskconf(void);
+void dumpconf(void);
/*
* Now that we are fully operational, we can checksum the
@@ -102,9 +103,7 @@ diskconf()
else
printf("boot device: %s\n", bootdv->dv_xname);
setroot(bootdv, 0, RB_USERREQ);
-#if 0
dumpconf();
-#endif
}
diff --git a/sys/arch/cats/cats/autoconf.c b/sys/arch/cats/cats/autoconf.c
index 4637cc0d294..61ca4d39596 100644
--- a/sys/arch/cats/cats/autoconf.c
+++ b/sys/arch/cats/cats/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.10 2007/05/04 19:30:54 deraadt Exp $ */
+/* $OpenBSD: autoconf.c,v 1.11 2007/05/19 15:49:05 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */
/*
@@ -86,9 +86,7 @@ diskconf()
printf("boot_file: '%s'\n", boot_file);
setroot(bootdv, 0, RB_USERREQ);
-#if 0
dumpconf();
-#endif
}
diff --git a/sys/arch/cats/cats/cats_machdep.c b/sys/arch/cats/cats/cats_machdep.c
index 78136bd965a..a1a000279b0 100644
--- a/sys/arch/cats/cats/cats_machdep.c
+++ b/sys/arch/cats/cats/cats_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cats_machdep.c,v 1.15 2007/04/10 16:43:34 miod Exp $ */
+/* $OpenBSD: cats_machdep.c,v 1.16 2007/05/19 15:49:06 miod Exp $ */
/* $NetBSD: cats_machdep.c,v 1.50 2003/10/04 14:28:28 chris Exp $ */
/*
@@ -67,6 +67,7 @@
#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/intr.h>
+#include <arm/kcore.h>
#include <arm/undefined.h>
#include <arm/machdep.h>
@@ -353,6 +354,7 @@ u_int
initarm(bootargs)
void *bootargs;
{
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
struct ebsaboot *bootinfo = bootargs;
int loop;
int loop1;
@@ -586,6 +588,11 @@ initarm(bootargs)
textsize = round_page(textsize);
totalsize = round_page(totalsize);
+ /* Update dump information */
+ cpu_kcore_hdr.kernelbase = KERNEL_BASE;
+ cpu_kcore_hdr.kerneloffs = 0;
+ cpu_kcore_hdr.staticsize = totalsize;
+
logical = pmap_map_chunk(l1pagetable, KERNEL_BASE,
physical_start, textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
@@ -864,6 +871,10 @@ initarm(bootargs)
pmap_bootstrap((pd_entry_t *)kernel_l1pt.pv_va, KERNEL_VM_BASE,
KERNEL_VM_BASE + KERNEL_VM_SIZE);
+ /* Update dump information */
+ cpu_kcore_hdr.pmap_kernel_l1 = (u_int32_t)pmap_kernel()->pm_l1;
+ cpu_kcore_hdr.pmap_kernel_l2 = (u_int32_t)&(pmap_kernel()->pm_l2);
+
/* Setup the IRQ system */
#ifdef VERBOSE_INIT_ARM
printf("irq ");
diff --git a/sys/arch/zaurus/zaurus/autoconf.c b/sys/arch/zaurus/zaurus/autoconf.c
index 66850a1cbd3..dc9cd7c330c 100644
--- a/sys/arch/zaurus/zaurus/autoconf.c
+++ b/sys/arch/zaurus/zaurus/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.10 2007/05/15 01:56:47 deraadt Exp $ */
+/* $OpenBSD: autoconf.c,v 1.11 2007/05/19 15:49:06 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */
/*
@@ -62,6 +62,7 @@ struct device *bootdv = NULL;
extern char *boot_file;
void diskconf(void);
+void dumpconf(void);
/*
* Now that we are fully operational, we can checksum the
@@ -98,9 +99,7 @@ diskconf()
printf("boot device: %s\n", bootdv->dv_xname);
setroot(bootdv, 0, RB_USERREQ);
-#if 0
dumpconf();
-#endif
timeout_add(&scoop_checkdisk, hz/25);
}
diff --git a/sys/arch/zaurus/zaurus/zaurus_machdep.c b/sys/arch/zaurus/zaurus/zaurus_machdep.c
index 0241f992c8c..688b31645db 100644
--- a/sys/arch/zaurus/zaurus/zaurus_machdep.c
+++ b/sys/arch/zaurus/zaurus/zaurus_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_machdep.c,v 1.26 2007/04/10 16:43:37 miod Exp $ */
+/* $OpenBSD: zaurus_machdep.c,v 1.27 2007/05/19 15:49:06 miod Exp $ */
/* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */
/*
@@ -121,6 +121,7 @@
#include <sys/msgbuf.h>
#include <sys/reboot.h>
#include <sys/termios.h>
+#include <sys/kcore.h>
#include <uvm/uvm_extern.h>
@@ -141,6 +142,7 @@
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/frame.h>
+#include <arm/kcore.h>
#include <arm/undefined.h>
#include <arm/machdep.h>
@@ -556,6 +558,7 @@ u_int
initarm(void *arg)
{
extern vaddr_t xscale_cache_clean_addr;
+ extern cpu_kcore_hdr_t cpu_kcore_hdr;
int loop;
int loop1;
u_int l1pagetable;
@@ -931,6 +934,11 @@ initarm(void *arg)
logical = 0x00200000; /* offset of kernel in RAM */
+ /* Update dump information */
+ cpu_kcore_hdr.kernelbase = KERNEL_BASE;
+ cpu_kcore_hdr.kerneloffs = logical;
+ cpu_kcore_hdr.staticsize = totalsize;
+
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
@@ -1096,6 +1104,10 @@ initarm(void *arg)
pmap_bootstrap((pd_entry_t *)kernel_l1pt.pv_va, KERNEL_VM_BASE,
KERNEL_VM_BASE + KERNEL_VM_SIZE);
+ /* Update dump information */
+ cpu_kcore_hdr.pmap_kernel_l1 = (u_int32_t)pmap_kernel()->pm_l1;
+ cpu_kcore_hdr.pmap_kernel_l2 = (u_int32_t)&(pmap_kernel()->pm_l2);
+
#ifdef __HAVE_MEMORY_DISK__
md_root_setconf(memory_disk, sizeof memory_disk);
#endif