From 2df12b22ee779d3f10995325e7cbd0d4be5705a0 Mon Sep 17 00:00:00 2001 From: guenther Date: Tue, 5 May 2015 02:13:46 +0000 Subject: [PATCH] emul_native is only used for kernel threads which can't dump core, so delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump, and various #includes that are superfluous. This leaves compat_linux processes without a coredump callback. If that ability is desired, someone should update it to use coredump_elf32() and verify the results... ok kettenis@ --- sys/arch/alpha/alpha/vm_machdep.c | 50 +------- sys/arch/alpha/include/pcb.h | 12 +- sys/arch/amd64/amd64/hibernate_machdep.c | 3 +- sys/arch/amd64/amd64/vm_machdep.c | 53 +------- sys/arch/amd64/include/pcb.h | 10 +- sys/arch/arm/arm/vm_machdep.c | 52 +------- sys/arch/arm/include/pcb.h | 9 +- sys/arch/armish/armish/armish_machdep.c | 3 +- sys/arch/hppa/hppa/vm_machdep.c | 44 +------ sys/arch/hppa/include/pcb.h | 8 +- sys/arch/hppa64/hppa64/vm_machdep.c | 44 +------ sys/arch/hppa64/include/pcb.h | 8 +- sys/arch/i386/i386/vm_machdep.c | 53 +------- sys/arch/i386/include/pcb.h | 10 +- .../loongson/loongson/hibernate_machdep.c | 3 +- sys/arch/loongson/loongson/machdep.c | 3 +- sys/arch/m88k/include/pcb.h | 12 +- sys/arch/m88k/m88k/vm_machdep.c | 46 +------ sys/arch/mips64/include/pcb.h | 10 +- sys/arch/mips64/mips64/vm_machdep.c | 52 +------- sys/arch/powerpc/include/pcb.h | 6 +- sys/arch/powerpc/powerpc/vm_machdep.c | 40 +----- sys/arch/sh/include/pcb.h | 5 +- sys/arch/sh/sh/sh_machdep.c | 4 +- sys/arch/sh/sh/vm_machdep.c | 60 +-------- sys/arch/sparc/include/pcb.h | 14 +-- sys/arch/sparc/sparc/vm_machdep.c | 49 +------- sys/arch/sparc64/include/pcb.h | 14 +-- sys/arch/sparc64/sparc64/vm_machdep.c | 50 +------- sys/arch/vax/include/pcb.h | 7 +- sys/arch/vax/vax/vm_machdep.c | 53 +------- sys/arch/zaurus/zaurus/zaurus_machdep.c | 3 +- sys/compat/linux/linux_exec.c | 5 +- sys/ddb/db_structinfo.c | 3 +- sys/kern/init_main.c | 7 +- sys/kern/kern_sig.c | 44 +------ sys/sys/core.h | 8 +- sys/sys/signalvar.h | 7 +- sys/uvm/uvm_extern.h | 5 +- sys/uvm/uvm_unix.c | 119 +----------------- 40 files changed, 52 insertions(+), 936 deletions(-) diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index ef712b325b6..26385a93044 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.42 2014/11/16 12:30:52 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.43 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.55 2000/03/29 03:49:48 simonb Exp $ */ /* @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -46,53 +45,6 @@ #include -/* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - int error; - struct md_coredump cpustate; - struct coreseg cseg; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_ALPHA, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(cpustate); - - cpustate.md_tf = *p->p_md.md_tf; - cpustate.md_tf.tf_regs[FRAME_SP] = alpha_pal_rdusp(); /* XXX */ - if (p->p_md.md_flags & MDP_FPUSED) { - if (p->p_addr->u_pcb.pcb_fpcpu != NULL) - fpusave_proc(p, 1); - cpustate.md_fpstate = p->p_addr->u_pcb.pcb_fp; - } else - bzero(&cpustate.md_fpstate, sizeof(cpustate.md_fpstate)); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_ALPHA, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cpustate, sizeof(cpustate), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - - if (!error) - chdr->c_nseg++; - - return error; -} - /* * cpu_exit is called as the last action during exit. */ diff --git a/sys/arch/alpha/include/pcb.h b/sys/arch/alpha/include/pcb.h index 6b5528852f2..97fa2d77b09 100644 --- a/sys/arch/alpha/include/pcb.h +++ b/sys/arch/alpha/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.10 2014/03/29 18:09:28 guenther Exp $ */ +/* $OpenBSD: pcb.h,v 1.11 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.5 1996/11/13 22:21:00 cgd Exp $ */ /* @@ -57,16 +57,6 @@ struct pcb { struct cpu_info *volatile pcb_fpcpu; /* CPU with our FP state[SW] */ }; -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. For the Alpha, that's a trap frame and the floating - * point registers. - */ -struct md_coredump { - struct trapframe md_tf; - struct fpreg md_fpstate; -}; - #ifdef _KERNEL void savectx(struct pcb *); #endif diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c index 4921343b70d..37b57d8ec8c 100644 --- a/sys/arch/amd64/amd64/hibernate_machdep.c +++ b/sys/arch/amd64/amd64/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.36 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.37 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 2012 Mike Larkin @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/sys/arch/amd64/amd64/vm_machdep.c b/sys/arch/amd64/amd64/vm_machdep.c index eb609a4a987..52d0c5037f1 100644 --- a/sys/arch/amd64/amd64/vm_machdep.c +++ b/sys/arch/amd64/amd64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.30 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.31 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.1 2003/04/26 18:39:33 fvdl Exp $ */ /*- @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -152,56 +151,6 @@ cpu_exit(struct proc *p) sched_exit(p); } -/* - * Dump the machine specific segment at the start of a core dump. - */ -struct md_core { - struct reg intreg; - struct fpreg freg; -}; - -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - struct md_core md_core; - struct coreseg cseg; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - /* Save integer registers. */ - error = process_read_regs(p, &md_core.intreg); - if (error) - return error; - - /* Save floating point registers. */ - error = process_read_fpregs(p, &md_core.freg); - if (error) - return error; - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - /* * Set a red zone in the kernel stack after the u. area. */ diff --git a/sys/arch/amd64/include/pcb.h b/sys/arch/amd64/include/pcb.h index 5bf1ab856f0..85efc564252 100644 --- a/sys/arch/amd64/include/pcb.h +++ b/sys/arch/amd64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.12 2011/07/10 18:12:03 deraadt Exp $ */ +/* $OpenBSD: pcb.h,v 1.13 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $ */ /*- @@ -89,12 +89,4 @@ struct pcb { int pcb_cr0; /* saved image of CR0 */ }; -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. For the i386, there is nothing to add. - */ -struct md_coredump { - long md_pad[8]; -}; - #endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/arm/arm/vm_machdep.c b/sys/arch/arm/arm/vm_machdep.c index 54b6cb22ff3..5e127281422 100644 --- a/sys/arch/arm/arm/vm_machdep.c +++ b/sys/arch/arm/arm/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.14 2014/11/16 12:30:56 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.15 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.31 2004/01/04 11:33:29 jdolecek Exp $ */ /* @@ -52,7 +52,6 @@ #include #include #include -#include #include #include @@ -176,55 +175,6 @@ cpu_exit(struct proc *p) sched_exit(p); } -/* - * Dump the machine specific segment at the start of a core dump. - */ - -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - int error; - struct { - struct reg regs; - struct fpreg fpregs; - } cpustate; - struct coreseg cseg; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(cpustate); - - /* Save integer registers. */ - error = process_read_regs(p, &cpustate.regs); - if (error) - return error; - /* Save floating point registers. */ - error = process_read_fpregs(p, &cpustate.fpregs); - if (error) - return error; - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cpustate, sizeof(cpustate), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - - return error; -} - /* * Map a user I/O request into kernel virtual address space. * Note: the pages are already locked by uvm_vslock(), so we diff --git a/sys/arch/arm/include/pcb.h b/sys/arch/arm/include/pcb.h index 2ee7a801c93..8e0b06a3baf 100644 --- a/sys/arch/arm/include/pcb.h +++ b/sys/arch/arm/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.5 2013/09/12 11:43:51 patrick Exp $ */ +/* $OpenBSD: pcb.h,v 1.6 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.10 2003/10/13 21:46:39 scw Exp $ */ /* @@ -86,11 +86,4 @@ struct pcb { struct fpe_sp_state pcb_fpstate; /* Floating Point state */ }; -/* - * No additional data for core dumps. - */ -struct md_coredump { - int md_empty; -}; - #endif /* _ARM_PCB_H_ */ diff --git a/sys/arch/armish/armish/armish_machdep.c b/sys/arch/armish/armish/armish_machdep.c index ece2c284508..9038d44f3b8 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.36 2015/01/18 10:17:42 jsg Exp $ */ +/* $OpenBSD: armish_machdep.c,v 1.37 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -89,7 +89,6 @@ #include #include #include -#include #include diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index fca81111753..11bceafc94c 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.80 2014/12/16 18:30:03 tedu Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.81 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 1999-2004 Michael Shalayeff @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -49,47 +48,6 @@ extern struct pool hppa_fppl; -/* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *core) -{ - struct md_coredump md_core; - struct coreseg cseg; - off_t off; - int error; - - CORE_SETMAGIC(*core, COREMAGIC, MID_HPPA, 0); - core->c_hdrsize = ALIGN(sizeof(*core)); - core->c_seghdrsize = ALIGN(sizeof(cseg)); - core->c_cpusize = sizeof(md_core); - - process_read_regs(p, &md_core.md_reg); - process_read_fpregs(p, &md_core.md_fpreg); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_HPPA, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = core->c_cpusize; - -#define write(vp, addr, n) \ - vn_rdwr(UIO_WRITE, (vp), (caddr_t)(addr), (n), off, \ - UIO_SYSSPACE, IO_UNIT, cred, NULL, p) - - off = core->c_hdrsize; - if ((error = write(vp, &cseg, core->c_seghdrsize))) - return error; - off += core->c_seghdrsize; - if ((error = write(vp, &md_core, sizeof md_core))) - return error; - -#undef write - core->c_nseg++; - - return error; -} - void cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize, void (*func)(void *), void *arg) diff --git a/sys/arch/hppa/include/pcb.h b/sys/arch/hppa/include/pcb.h index b24f037eac8..1c1a929285c 100644 --- a/sys/arch/hppa/include/pcb.h +++ b/sys/arch/hppa/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.15 2011/11/10 22:48:13 deraadt Exp $ */ +/* $OpenBSD: pcb.h,v 1.16 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 1999-2004 Michael Shalayeff @@ -40,10 +40,4 @@ struct pcb { pa_space_t pcb_space; /* copy pmap_space, for asm's sake */ }; -struct md_coredump { - struct reg md_reg; - struct fpreg md_fpreg; -}; - - #endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/hppa64/hppa64/vm_machdep.c b/sys/arch/hppa64/hppa64/vm_machdep.c index f582b9167d0..fa9abd7fdf0 100644 --- a/sys/arch/hppa64/hppa64/vm_machdep.c +++ b/sys/arch/hppa64/hppa64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.21 2014/11/16 12:30:57 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.22 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -39,47 +38,6 @@ extern struct pool hppa_fppl; -/* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *core) -{ - struct md_coredump md_core; - struct coreseg cseg; - off_t off; - int error; - - CORE_SETMAGIC(*core, COREMAGIC, MID_HPPA20, 0); - core->c_hdrsize = ALIGN(sizeof(*core)); - core->c_seghdrsize = ALIGN(sizeof(cseg)); - core->c_cpusize = sizeof(md_core); - - process_read_regs(p, &md_core.md_reg); - process_read_fpregs(p, &md_core.md_fpreg); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_HPPA20, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = core->c_cpusize; - -#define write(vp, addr, n) \ - vn_rdwr(UIO_WRITE, (vp), (caddr_t)(addr), (n), off, \ - UIO_SYSSPACE, IO_UNIT, cred, NULL, p) - - off = core->c_hdrsize; - if ((error = write(vp, &cseg, core->c_seghdrsize))) - return error; - off += core->c_seghdrsize; - if ((error = write(vp, &md_core, sizeof md_core))) - return error; - -#undef write - core->c_nseg++; - - return error; -} - void cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize, void (*func)(void *), void *arg) diff --git a/sys/arch/hppa64/include/pcb.h b/sys/arch/hppa64/include/pcb.h index 8ed995f81f9..2a8cee8eb8b 100644 --- a/sys/arch/hppa64/include/pcb.h +++ b/sys/arch/hppa64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.4 2011/11/10 23:15:11 deraadt Exp $ */ +/* $OpenBSD: pcb.h,v 1.5 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -31,10 +31,4 @@ struct pcb { pa_space_t pcb_space; /* copy pmap_space, for asm's sake */ }; -struct md_coredump { - struct reg md_reg; - struct fpreg md_fpreg; -}; - - #endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index 5dd07849c52..c5357f94a5c 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.62 2015/03/31 04:35:50 guenther Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.63 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.61 1996/05/03 19:42:35 christos Exp $ */ /*- @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -139,56 +138,6 @@ cpu_exit(struct proc *p) sched_exit(p); } -/* - * Dump the machine specific segment at the start of a core dump. - */ -struct md_core { - struct reg intreg; - struct fpreg freg; -}; - -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - struct md_core md_core; - struct coreseg cseg; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_I386, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - /* Save integer registers. */ - error = process_read_regs(p, &md_core.intreg); - if (error) - return error; - - /* Save floating point registers. */ - error = process_read_fpregs(p, &md_core.freg); - if (error) - return error; - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_I386, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - /* * Convert kernel VA to physical address */ diff --git a/sys/arch/i386/include/pcb.h b/sys/arch/i386/include/pcb.h index 0693d7becf3..8fd23c94a81 100644 --- a/sys/arch/i386/include/pcb.h +++ b/sys/arch/i386/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.17 2013/05/08 15:36:30 tedu Exp $ */ +/* $OpenBSD: pcb.h,v 1.18 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.21 1996/01/08 13:51:42 mycroft Exp $ */ /*- @@ -84,12 +84,4 @@ struct pcb { #define TSEG_FS 0 #define TSEG_GS 1 -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. For the i386, there is nothing to add. - */ -struct md_coredump { - long md_pad[8]; -}; - #endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/loongson/loongson/hibernate_machdep.c b/sys/arch/loongson/loongson/hibernate_machdep.c index c7c9fc77002..d0d565d759f 100644 --- a/sys/arch/loongson/loongson/hibernate_machdep.c +++ b/sys/arch/loongson/loongson/hibernate_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate_machdep.c,v 1.7 2014/07/20 19:47:53 deraadt Exp $ */ +/* $OpenBSD: hibernate_machdep.c,v 1.8 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 2013 Paul Irofti. @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c index c1b99e72467..eaef59d6460 100644 --- a/sys/arch/loongson/loongson/machdep.c +++ b/sys/arch/loongson/loongson/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.61 2014/12/10 15:29:53 mikeb Exp $ */ +/* $OpenBSD: machdep.c,v 1.62 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 2009, 2010, 2014 Miodrag Vallat. @@ -62,7 +62,6 @@ #ifdef SYSVSEM #include #endif -#include #include diff --git a/sys/arch/m88k/include/pcb.h b/sys/arch/m88k/include/pcb.h index 849e5113710..20504a9db61 100644 --- a/sys/arch/m88k/include/pcb.h +++ b/sys/arch/m88k/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.6 2013/07/17 19:19:29 miod Exp $ */ +/* $OpenBSD: pcb.h,v 1.7 2015/05/05 02:13:46 guenther Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Mach Operating System @@ -86,14 +86,4 @@ struct pcb #define USER_REGS(p) \ (((struct reg *)(&((p)->p_addr->u_pcb.user_state)))) -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. Note that the trapframe here is a copy of the one - * from the top of the kernel stack (included here so that the kernel - * stack itself need not be dumped). - */ -struct md_coredump { - struct trapframe md_tf; -}; - #endif /* _M88K_PCB_H_ */ diff --git a/sys/arch/m88k/m88k/vm_machdep.c b/sys/arch/m88k/m88k/vm_machdep.c index 08a27322e43..d4cb331f49b 100644 --- a/sys/arch/m88k/m88k/vm_machdep.c +++ b/sys/arch/m88k/m88k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.23 2014/11/16 12:30:58 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.24 2015/05/05 02:13:47 guenther Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -131,49 +130,6 @@ cpu_exit(struct proc *p) sched_exit(p); } -/* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - struct reg reg; - struct coreseg cseg; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(reg); - - /* Save registers. */ - error = process_read_regs(p, ®); - if (error) - return error; - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)®, sizeof(reg), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - /* * Map an IO request into kernel virtual address space via phys_map. */ diff --git a/sys/arch/mips64/include/pcb.h b/sys/arch/mips64/include/pcb.h index 701ca2ae375..08c32512ecd 100644 --- a/sys/arch/mips64/include/pcb.h +++ b/sys/arch/mips64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.6 2014/03/22 00:01:04 miod Exp $ */ +/* $OpenBSD: pcb.h,v 1.7 2015/05/05 02:13:47 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -57,12 +57,4 @@ struct pcb { vaddr_t pcb_wiredpc; /* last tracked pc value within above */ }; -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. For the MIPS, there is nothing to add. - */ -struct md_coredump { - long md_pad[8]; -}; - #endif /* !_MIPS64_PCB_H_ */ diff --git a/sys/arch/mips64/mips64/vm_machdep.c b/sys/arch/mips64/mips64/vm_machdep.c index 900785dc59f..fbc0ca5b491 100644 --- a/sys/arch/mips64/mips64/vm_machdep.c +++ b/sys/arch/mips64/mips64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.31 2014/12/16 18:30:03 tedu Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.32 2015/05/05 02:13:47 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1992, 1993 @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -162,55 +161,6 @@ cpu_exit(p) sched_exit(p); } -/* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - struct cpu_info *ci = curcpu(); - int error; - /*register struct user *up = p->p_addr;*/ - struct coreseg cseg; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MIPS, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof (p -> p_addr -> u_pcb.pcb_regs); - - /* - * Copy floating point state from the FP chip if this process - * has state stored there. - */ - if (p == ci->ci_fpuproc) - save_fpu(); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MIPS, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, - (caddr_t)(&(p -> p_addr -> u_pcb.pcb_regs)), - (off_t)chdr -> c_cpusize, - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), - UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - - if (!error) - chdr->c_nseg++; - - return error; -} - extern vm_map_t phys_map; /* diff --git a/sys/arch/powerpc/include/pcb.h b/sys/arch/powerpc/include/pcb.h index edacac9d43f..c7b1a3823eb 100644 --- a/sys/arch/powerpc/include/pcb.h +++ b/sys/arch/powerpc/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.13 2011/08/22 18:18:35 deraadt Exp $ */ +/* $OpenBSD: pcb.h,v 1.14 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.1 1996/09/30 16:34:29 ws Exp $ */ /*- @@ -61,10 +61,6 @@ struct pcb { struct cpu_info *pcb_veccpu; }; -struct md_coredump { - struct reg regs; -}; - #ifdef _KERNEL extern struct proc *fpuproc; int setfault(faultbuf *env) __returns_twice; diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c index 475fe57504c..43e18f7401e 100644 --- a/sys/arch/powerpc/powerpc/vm_machdep.c +++ b/sys/arch/powerpc/powerpc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.47 2014/11/16 12:30:58 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.48 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */ /* @@ -32,7 +32,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include #include #include @@ -158,43 +157,6 @@ cpu_exit(struct proc *p) sched_exit(p); } -/* - * Write the machine-dependent part of a core dump. - */ -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - struct coreseg cseg; - struct md_coredump md_core; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_POWERPC, 0); - chdr->c_hdrsize = ALIGN(sizeof *chdr); - chdr->c_seghdrsize = ALIGN(sizeof cseg); - chdr->c_cpusize = sizeof md_core; - - process_read_regs(p, &(md_core.regs)); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_POWERPC, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof md_core, - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - /* * Map an IO request into kernel virtual address space. */ diff --git a/sys/arch/sh/include/pcb.h b/sys/arch/sh/include/pcb.h index e6d41940891..9b3262d4e97 100644 --- a/sys/arch/sh/include/pcb.h +++ b/sys/arch/sh/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.3 2008/06/26 05:42:12 ray Exp $ */ +/* $OpenBSD: pcb.h,v 1.4 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.7 2002/05/09 12:28:08 uch Exp $ */ /*- @@ -42,9 +42,6 @@ struct pcb { struct fpreg pcb_fp; /* fp context for resume */ }; -struct md_coredump { -}; - extern struct pcb *curpcb; #endif /* !_SH_PCB_H_ */ diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c index d8eccbfccae..7d32f59db92 100644 --- a/sys/arch/sh/sh/sh_machdep.c +++ b/sys/arch/sh/sh/sh_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sh_machdep.c,v 1.38 2015/01/20 19:43:21 kettenis Exp $ */ +/* $OpenBSD: sh_machdep.c,v 1.39 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */ /* @@ -95,8 +95,6 @@ #include #include #include -#include -#include #include #include diff --git a/sys/arch/sh/sh/vm_machdep.c b/sys/arch/sh/sh/vm_machdep.c index b48aeba66d2..77b50487b5b 100644 --- a/sys/arch/sh/sh/vm_machdep.c +++ b/sys/arch/sh/sh/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.12 2014/11/16 12:30:58 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.13 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.53 2006/08/31 16:49:21 matt Exp $ */ /* @@ -103,7 +103,6 @@ #include #include #include -#include #include #include #include @@ -245,63 +244,6 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize, #endif } -/* - * Dump the machine specific segment at the start of a core dump. - */ -struct md_core { - struct reg intreg; - struct fpreg fpreg; -}; - -int -cpu_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - struct md_core md_core; - struct coreseg cseg; - int error; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - /* Save integer registers. */ - error = process_read_regs(p, &md_core.intreg); - if (error) - return error; - -#ifdef SH4 - if (CPU_IS_SH4) { - error = process_read_fpregs(p, &md_core.fpreg); - if (error) - return error; - } -#endif -#ifdef SH3 - if (CPU_IS_SH3) - bzero(&md_core.fpreg, sizeof(md_core.fpreg)); -#endif - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return error; - - chdr->c_nseg++; - return 0; -} - /* * Map an IO request into kernel virtual address space. * All requests are (re)mapped into kernel VA space via the phys_map diff --git a/sys/arch/sparc/include/pcb.h b/sys/arch/sparc/include/pcb.h index 6942c653e93..fc98d187d97 100644 --- a/sys/arch/sparc/include/pcb.h +++ b/sys/arch/sparc/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.6 2011/03/23 16:54:37 pirofti Exp $ */ +/* $OpenBSD: pcb.h,v 1.7 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.4 1995/03/28 18:19:56 jtc Exp $ */ /* @@ -107,18 +107,6 @@ struct pcb { struct rwindow pcb_rw[PCB_MAXWIN]; /* saved windows */ }; -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. Note that the trapframe here is a copy of the one - * from the top of the kernel stack (included here so that the kernel - * stack itself need not be dumped). - */ -struct md_coredump { - struct trapframe md_tf; - struct fpstate md_fpstate; - u_int32_t md_wcookie; -}; - #ifdef _KERNEL extern struct pcb *cpcb; #endif /* _KERNEL */ diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c index d0d611dce3c..e70d8c01878 100644 --- a/sys/arch/sparc/sparc/vm_machdep.c +++ b/sys/arch/sparc/sparc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.59 2015/03/30 20:30:22 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.60 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */ /* @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -285,49 +284,3 @@ cpu_exit(p) pmap_deactivate(p); sched_exit(p); } - -/* - * cpu_coredump is called to write a core dump header. - * (should this be defined elsewhere? machdep.c?) - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - int error; - struct md_coredump md_core; - struct coreseg cseg; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_SPARC, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - md_core.md_tf = *p->p_md.md_tf; - md_core.md_wcookie = p->p_addr->u_pcb.pcb_wcookie; - if (p->p_md.md_fpstate) { - if (p == cpuinfo.fpproc) - savefpstate(p->p_md.md_fpstate); - md_core.md_fpstate = *p->p_md.md_fpstate; - } else - bzero((caddr_t)&md_core.md_fpstate, sizeof(struct fpstate)); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_SPARC, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (!error) - chdr->c_nseg++; - - return error; -} diff --git a/sys/arch/sparc64/include/pcb.h b/sys/arch/sparc64/include/pcb.h index dc72ecad17a..108f669031c 100644 --- a/sys/arch/sparc64/include/pcb.h +++ b/sys/arch/sparc64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.9 2011/03/23 16:54:37 pirofti Exp $ */ +/* $OpenBSD: pcb.h,v 1.10 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.7 2000/12/29 17:12:05 eeh Exp $ */ /* @@ -143,18 +143,6 @@ struct pcb { u_int64_t pcb_rwsp[PCB_MAXWIN]; }; -/* - * The pcb is augmented with machine-dependent additional data for - * core dumps. Note that the trapframe here is a copy of the one - * from the top of the kernel stack (included here so that the kernel - * stack itself need not be dumped). - */ -struct md_coredump { - struct trapframe64 md_tf; - struct fpstate64 md_fpstate; - u_int64_t md_wcookie; -}; - #ifndef _KERNEL /* Let gdb compile. We need fancier macros to make these make sense. */ #define pcb_psr pcb_pstate diff --git a/sys/arch/sparc64/sparc64/vm_machdep.c b/sys/arch/sparc64/sparc64/vm_machdep.c index 61494dd2856..e8484e52a43 100644 --- a/sys/arch/sparc64/sparc64/vm_machdep.c +++ b/sys/arch/sparc64/sparc64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.32 2014/11/16 12:30:59 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.33 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.38 2001/06/30 00:02:20 eeh Exp $ */ /* @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -369,50 +368,3 @@ cpu_exit(struct proc *p) pmap_deactivate(p); sched_exit(p); } - -/* - * cpu_coredump is called to write a core dump header. - * (should this be defined elsewhere? machdep.c?) - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - int error; - struct md_coredump md_core; - struct coreseg cseg; - - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = ALIGN(sizeof(*chdr)); - chdr->c_seghdrsize = ALIGN(sizeof(cseg)); - chdr->c_cpusize = sizeof(md_core); - - md_core.md_tf = *p->p_md.md_tf; - md_core.md_wcookie = p->p_addr->u_pcb.pcb_wcookie; - if (p->p_md.md_fpstate) { - fpusave_proc(p, 1); - md_core.md_fpstate = *p->p_md.md_fpstate; - } else - bzero((caddr_t)&md_core.md_fpstate, - sizeof(md_core.md_fpstate)); - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - if (!error) - chdr->c_nseg++; - - return error; -} - diff --git a/sys/arch/vax/include/pcb.h b/sys/arch/vax/include/pcb.h index b8732d54d10..bbc96b002b7 100644 --- a/sys/arch/vax/include/pcb.h +++ b/sys/arch/vax/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.8 2013/11/24 22:08:23 miod Exp $ */ +/* $OpenBSD: pcb.h,v 1.9 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: pcb.h,v 1.10 1996/02/02 18:08:26 mycroft Exp $ */ /* @@ -69,10 +69,5 @@ struct pcb { #define AST_MASK 0x07000000 #define AST_PCB 0x04000000 -/* machine-specific core dump; save regs */ -struct md_coredump { - struct reg md_reg; -}; - #endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c index 7ab91cfa425..a47c00ae0c3 100644 --- a/sys/arch/vax/vax/vm_machdep.c +++ b/sys/arch/vax/vax/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.42 2014/11/16 12:30:59 deraadt Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.43 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.67 2000/06/29 07:14:34 mrg Exp $ */ /* @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -178,56 +177,6 @@ sys_sysarch(p, v, retval) return (ENOSYS); }; -/* - * Dump the machine specific header information at the start of a core dump. - * First put all regs in PCB for debugging purposes. This is not an good - * way to do this, but good for my purposes so far. - */ -int -cpu_coredump(p, vp, cred, chdr) - struct proc *p; - struct vnode *vp; - struct ucred *cred; - struct core *chdr; -{ - struct trapframe *tf; - struct md_coredump state; - struct reg *regs = &state.md_reg; - struct coreseg cseg; - int error; - - tf = p->p_addr->u_pcb.framep; - CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0); - chdr->c_hdrsize = sizeof(struct core); - chdr->c_seghdrsize = sizeof(struct coreseg); - chdr->c_cpusize = sizeof(struct md_coredump); - - bcopy(&tf->r0, ®s->r0, 12 * sizeof(int)); - regs->ap = tf->ap; - regs->fp = tf->fp; - regs->sp = tf->sp; - regs->pc = tf->pc; - regs->psl = tf->psl; - - CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU); - cseg.c_addr = 0; - cseg.c_size = chdr->c_cpusize; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize, - (off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - if (error) - return error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&state, sizeof(state), - (off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE, - IO_UNIT, cred, NULL, p); - - if (!error) - chdr->c_nseg++; - - return error; -} - /* * Map in a bunch of pages read/writeable for the kernel. */ diff --git a/sys/arch/zaurus/zaurus/zaurus_machdep.c b/sys/arch/zaurus/zaurus/zaurus_machdep.c index edc2c6e0325..55578bee94f 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.56 2015/01/18 10:17:42 jsg Exp $ */ +/* $OpenBSD: zaurus_machdep.c,v 1.57 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -121,7 +121,6 @@ #include #include #include -#include #include diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index d8b592f917d..4982f3bb1fe 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.42 2014/07/12 18:50:00 tedu Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.43 2015/05/05 02:13:47 guenther Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /*- @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -96,7 +95,7 @@ struct emul emul_linux_elf = { elf32_copyargs, setregs, exec_elf32_fixup, - coredump_trad, + NULL, /* coredump */ linux_sigcode, linux_esigcode, 0, diff --git a/sys/ddb/db_structinfo.c b/sys/ddb/db_structinfo.c index 7e6309eb764..06b4949f591 100644 --- a/sys/ddb/db_structinfo.c +++ b/sys/ddb/db_structinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_structinfo.c,v 1.12 2015/01/27 10:12:45 dlg Exp $ */ +/* $OpenBSD: db_structinfo.c,v 1.13 2015/05/05 02:13:46 guenther Exp $ */ /* public domain */ /* * This file is intended to be compiled with debug information, @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 3888890d6b3..6c71f382e93 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.238 2015/05/01 11:18:21 miod Exp $ */ +/* $OpenBSD: init_main.c,v 1.239 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -39,7 +39,6 @@ */ #include -#include #include #include #include @@ -169,8 +168,8 @@ struct emul emul_native = { 0, copyargs, setregs, - NULL, - coredump_trad, + NULL, /* fixup */ + NULL, /* coredump */ sigcode, esigcode, EMUL_ENABLED | EMUL_NATIVE, diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index fe9e4c58cae..501d4011689 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.179 2015/03/14 03:38:50 jsg Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.180 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1457,6 +1457,9 @@ coredump(struct proc *p) char name[MAXPATHLEN]; const char *dir = "/var/crash"; + if (pr->ps_emul->e_coredump == NULL) + return (EINVAL); + pr->ps_flags |= PS_COREDUMP; /* @@ -1559,45 +1562,6 @@ out: #endif } -int -coredump_trad(struct proc *p, void *cookie) -{ -#ifdef SMALL_KERNEL - return EPERM; -#else - struct coredump_iostate *io = cookie; - struct vmspace *vm = io->io_proc->p_vmspace; - struct vnode *vp = io->io_vp; - struct ucred *cred = io->io_cred; - struct core core; - int error; - - core.c_midmag = 0; - strlcpy(core.c_name, p->p_comm, sizeof(core.c_name)); - core.c_nseg = 0; - core.c_signo = p->p_sisig; - core.c_ucode = p->p_sitrapno; - core.c_cpusize = 0; - core.c_tsize = (u_long)ptoa(vm->vm_tsize); - core.c_dsize = (u_long)ptoa(vm->vm_dsize); - core.c_ssize = (u_long)round_page(ptoa(vm->vm_ssize)); - error = cpu_coredump(p, vp, cred, &core); - if (error) - return (error); - /* - * uvm_coredump() spits out all appropriate segments. - * All that's left to do is to write the core header. - */ - error = uvm_coredump(p, vp, cred, &core); - if (error) - return (error); - error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&core, - (int)core.c_hdrsize, (off_t)0, - UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - return (error); -#endif -} - #ifndef SMALL_KERNEL int coredump_write(void *cookie, enum uio_seg segflg, const void *data, size_t len) diff --git a/sys/sys/core.h b/sys/sys/core.h index 464fa5843df..2ffb893c69f 100644 --- a/sys/sys/core.h +++ b/sys/sys/core.h @@ -1,4 +1,4 @@ -/* $OpenBSD: core.h,v 1.5 2013/01/15 01:34:27 deraadt Exp $ */ +/* $OpenBSD: core.h,v 1.6 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: core.h,v 1.4 1994/10/29 08:20:14 cgd Exp $ */ /* @@ -56,7 +56,9 @@ #define CORE_DATA 2 #define CORE_STACK 4 +#ifndef _KERNEL /* + * XXX OBSOLETE, NO LONGER USED * A core file consists of a header followed by a number of segments. * Each segment is preceded by a `coreseg' structure giving the * segment's type, the virtual address where the bits resided in @@ -87,9 +89,7 @@ struct coreseg { u_long c_size; /* Size of this segment */ }; -#ifdef _KERNEL -int coredump_trad(struct proc *, void *); - +#else int coredump_write(void *, enum uio_seg, const void *, size_t); void coredump_unmap(void *, vaddr_t, vaddr_t); #endif diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index ede4326b1bd..a38788bbd98 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signalvar.h,v 1.27 2014/03/22 06:05:45 guenther Exp $ */ +/* $OpenBSD: signalvar.h,v 1.28 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ /* @@ -176,10 +176,5 @@ void sigactsfree(struct process *); */ void sendsig(sig_t action, int sig, int returnmask, u_long code, int type, union sigval val); -struct core; -struct vnode; -struct ucred; -int cpu_coredump(struct proc *, struct vnode *, struct ucred *, - struct core *); #endif /* _KERNEL */ #endif /* !_SYS_SIGNALVAR_H_ */ diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index ddee989106b..68b97337042 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.131 2015/02/07 08:21:24 miod Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.132 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -167,7 +167,6 @@ typedef int vm_prot_t; #ifdef _KERNEL struct buf; -struct core; struct mount; struct pglist; struct vmspace; @@ -462,8 +461,6 @@ int uvm_pglistalloc(psize_t, paddr_t, paddr_t, void uvm_pglistfree(struct pglist *); void uvm_pmr_use_inc(paddr_t, paddr_t); void uvm_swap_init(void); -int uvm_coredump(struct proc *, struct vnode *, - struct ucred *, struct core *); int uvm_coredump_walkmap(struct proc *, void *, int (*)(struct proc *, void *, struct uvm_coredump_state *), void *); diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c index 69fb33546db..366a14e986e 100644 --- a/sys/uvm/uvm_unix.c +++ b/sys/uvm/uvm_unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_unix.c,v 1.55 2015/02/09 09:39:09 miod Exp $ */ +/* $OpenBSD: uvm_unix.c,v 1.56 2015/05/05 02:13:46 guenther Exp $ */ /* $NetBSD: uvm_unix.c,v 1.18 2000/09/13 15:00:25 thorpej Exp $ */ /* @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -137,119 +136,9 @@ uvm_grow(struct proc *p, vaddr_t sp) #ifndef SMALL_KERNEL /* - * uvm_coredump: dump core! + * Walk the VA space for a process, invoking 'func' on each present range + * that should be included in a coredump. */ - -int -uvm_coredump(struct proc *p, struct vnode *vp, struct ucred *cred, - struct core *chdr) -{ - struct vmspace *vm = p->p_vmspace; - vm_map_t map = &vm->vm_map; - vm_map_entry_t entry, safe; - vaddr_t start, end, top; - struct coreseg cseg; - off_t offset, coffset; - int csize, chunk, flag, error = 0; - - offset = chdr->c_hdrsize + chdr->c_seghdrsize + chdr->c_cpusize; - - RB_FOREACH_SAFE(entry, uvm_map_addr, &map->addr, safe) { - /* should never happen for a user process */ - if (UVM_ET_ISSUBMAP(entry)) { - panic("uvm_coredump: user process with submap?"); - } - - if (!(entry->protection & PROT_WRITE) && - entry->start != p->p_p->ps_sigcode) - continue; - - /* Don't dump mmaped devices. */ - if (entry->object.uvm_obj != NULL && - UVM_OBJ_IS_DEVICE(entry->object.uvm_obj)) - continue; - - start = entry->start; - end = entry->end; - - if (start >= VM_MAXUSER_ADDRESS) - continue; - - if (end > VM_MAXUSER_ADDRESS) - end = VM_MAXUSER_ADDRESS; - -#ifdef MACHINE_STACK_GROWS_UP - if ((vaddr_t)vm->vm_maxsaddr <= start && - start < ((vaddr_t)vm->vm_maxsaddr + MAXSSIZ)) { - top = round_page((vaddr_t)vm->vm_maxsaddr + - ptoa(vm->vm_ssize)); - if (end > top) - end = top; - - if (start >= end) - continue; -#else - if (start >= (vaddr_t)vm->vm_maxsaddr) { - top = trunc_page((vaddr_t)vm->vm_minsaddr - - ptoa(vm->vm_ssize)); - if (start < top) - start = top; - - if (start >= end) - continue; -#endif - flag = CORE_STACK; - } else - flag = CORE_DATA; - - /* Set up a new core file segment. */ - CORE_SETMAGIC(cseg, CORESEGMAGIC, CORE_GETMID(*chdr), flag); - cseg.c_addr = start; - cseg.c_size = end - start; - - error = vn_rdwr(UIO_WRITE, vp, - (caddr_t)&cseg, chdr->c_seghdrsize, - offset, UIO_SYSSPACE, IO_UNIT, cred, NULL, p); - /* - * We might get an EFAULT on objects mapped beyond - * EOF. Ignore the error. - */ - if (error && error != EFAULT) - break; - - offset += chdr->c_seghdrsize; - - coffset = 0; - csize = (int)cseg.c_size; - do { - if (p->p_siglist & sigmask(SIGKILL)) - return (EINTR); - - /* Rest of the loop sleeps with lock held, so... */ - yield(); - - chunk = MIN(csize, MAXPHYS); - error = vn_rdwr(UIO_WRITE, vp, - (caddr_t)(u_long)cseg.c_addr + coffset, - chunk, offset + coffset, UIO_USERSPACE, - IO_UNIT, cred, NULL, p); - if (error) - return (error); - - coffset += chunk; - csize -= chunk; - } while (csize > 0); - offset += cseg.c_size; - - /* Discard the memory */ - uvm_unmap(map, cseg.c_addr, cseg.c_addr + cseg.c_size); - - chdr->c_nseg++; - } - - return (error); -} - int uvm_coredump_walkmap(struct proc *p, void *iocookie, int (*func)(struct proc *, void *, struct uvm_coredump_state *), @@ -269,7 +158,7 @@ uvm_coredump_walkmap(struct proc *p, void *iocookie, /* should never happen for a user process */ if (UVM_ET_ISSUBMAP(entry)) { - panic("uvm_coredump: user process with submap?"); + panic("%s: user process with submap?", __func__); } if (!(entry->protection & PROT_WRITE) && -- 2.20.1