From: Matthew Dillon Date: Mon, 20 Oct 2003 04:47:35 +0000 (+0000) Subject: Additional checkpoint suppor for vmspace info. In particular, the data size X-Git-Tag: v2.0.1~12795 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/5a5c6af60503a0877cc9f775ad9269b2681a36d0 Additional checkpoint suppor for vmspace info. In particular, the data size is used by sbrk and must be restored for programs to work properly. --- diff --git a/sys/Makefile b/sys/Makefile index 4928bd8185..23d37ee1de 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/Makefile,v 1.20.2.1 2000/07/10 08:22:34 obrien Exp $ -# $DragonFly: src/sys/Makefile,v 1.6 2003/08/16 02:51:54 dillon Exp $ +# $DragonFly: src/sys/Makefile,v 1.7 2003/10/20 04:47:30 dillon Exp $ # This is the old aout only boot loader. .if exists(${.CURDIR}/${MACHINE_ARCH}/boot) && ${OBJFORMAT} == "aout" @@ -15,7 +15,7 @@ SUBDIR= boot # KLD modules build for both a.out and ELF # note: emulation must come before dev (for arch_svr4 softlink) .if defined(MODULES_WITH_WORLD) -SUBDIR+=bus crypto emulation dev kern net netgraph netproto vfs +SUBDIR+=bus checkpt crypto emulation dev kern net netgraph netproto vfs .endif HTAGSFLAGS+= -at `awk -F= '/^RELEASE *=/{release=$2}; END {print "FreeBSD", release, "kernel"}' < conf/newvers.sh` diff --git a/sys/Makefile.modules b/sys/Makefile.modules index e60fa931e0..7a5ad2f967 100644 --- a/sys/Makefile.modules +++ b/sys/Makefile.modules @@ -1,8 +1,8 @@ # Makefile.modules - build the modules (executed from the modules: target # in Makefile). # -# $DragonFly: src/sys/Makefile.modules,v 1.1 2003/08/16 22:00:16 dillon Exp $ -SUBDIR=bus crypto emulation dev kern net netgraph netproto vfs +# $DragonFly: src/sys/Makefile.modules,v 1.2 2003/10/20 04:47:30 dillon Exp $ +SUBDIR=bus checkpt crypto emulation dev kern net netgraph netproto vfs .include diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index ca26137579..c4164d3a96 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/kern/imgact_elf.c,v 1.73.2.13 2002/12/28 19:49:41 dillon Exp $ - * $DragonFly: src/sys/kern/imgact_elf.c,v 1.10 2003/10/19 19:24:18 dillon Exp $ + * $DragonFly: src/sys/kern/imgact_elf.c,v 1.11 2003/10/20 04:47:32 dillon Exp $ */ #include @@ -868,18 +868,15 @@ generic_elf_coredump(struct proc *p, struct file *fp, off_t limit) /* Write the contents of all of the writable segments. */ if (error == 0) { Elf_Phdr *php; - off_t offset; int i; php = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr)) + 1; - offset = hdrsize; for (i = 0; i < seginfo.count; i++) { int nbytes; - error = fp_pwrite(fp, (caddr_t)php->p_vaddr, php->p_filesz, - offset, &nbytes); + error = fp_write(fp, (caddr_t)php->p_vaddr, php->p_filesz, + &nbytes); if (error != 0) break; - offset += php->p_filesz; php++; } } @@ -1089,7 +1086,7 @@ elf_corehdr(struct proc *p, struct file *fp, struct ucred *cred, int numsegs, free(tempdata, M_TEMP); /* Write it to the core file. */ - return fp_pwrite(fp, hdr, hdrsize, (off_t)0, &nbytes); + return fp_write(fp, hdr, hdrsize, &nbytes); } static void @@ -1269,21 +1266,31 @@ elf_putfiles(struct proc *p, void *dst, int *off) static void elf_puttextvp(struct proc *p, void *dst, int *off) { - int count = 0; - struct fp_closure fpc; int *vn_count; - if (!dst) { - each_segment(p, cb_fpcount_segment, &count, 0); - *off += sizeof(struct vn_hdr)*count + sizeof(int); - return; + struct fp_closure fpc; + struct ckpt_vminfo *vminfo; + + vminfo = (struct ckpt_vminfo *)((char *)dst + *off); + if (dst != NULL) { + vminfo->cvm_dsize = p->p_vmspace->vm_dsize; + vminfo->cvm_tsize = p->p_vmspace->vm_tsize; + vminfo->cvm_daddr = p->p_vmspace->vm_daddr; + vminfo->cvm_taddr = p->p_vmspace->vm_taddr; } + *off += sizeof(*vminfo); + vn_count = (int *)((char *)dst + *off); *off += sizeof(int); + fpc.vnh = (struct vn_hdr *)((char *)dst + *off); fpc.count = 0; - each_segment(p, cb_put_fp, &fpc, 0); - *vn_count = fpc.count; - *off += fpc.count*sizeof(struct vn_hdr); + if (dst != NULL) { + each_segment(p, cb_put_fp, &fpc, 0); + *vn_count = fpc.count; + } else { + each_segment(p, cb_fpcount_segment, &fpc.count, 0); + } + *off += fpc.count * sizeof(struct vn_hdr); } diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 9b36dd768e..2d6ae3aafe 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ - $DragonFly: src/sys/kern/syscalls.master,v 1.3 2003/10/08 01:30:32 daver Exp $ + $DragonFly: src/sys/kern/syscalls.master,v 1.4 2003/10/20 04:47:32 dillon Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 ; $FreeBSD: src/sys/kern/syscalls.master,v 1.72.2.10 2002/07/12 08:22:46 alfred Exp $ @@ -326,7 +326,7 @@ ; ; The following are reserved for loadable syscalls ; -210 NODEF NOHIDE lkmnosys lkmnosys nosys_args int +210 NODEF NOHIDE lkmnosys lkmnosys nosys_args int ; CHECKPOINT MODULE 211 NODEF NOHIDE lkmnosys lkmnosys nosys_args int 212 NODEF NOHIDE lkmnosys lkmnosys nosys_args int 213 NODEF NOHIDE lkmnosys lkmnosys nosys_args int diff --git a/sys/sys/ckpt.h b/sys/sys/ckpt.h index b9ed7ea7d4..8297a6b566 100644 --- a/sys/sys/ckpt.h +++ b/sys/sys/ckpt.h @@ -1,5 +1,28 @@ -/* - * $DragonFly: src/sys/sys/ckpt.h,v 1.2 2003/10/19 23:23:29 dillon Exp $ +/*- + * Copyright (c) 2003 Kip Macy All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $DragonFly: src/sys/sys/ckpt.h,v 1.3 2003/10/20 04:47:35 dillon Exp $ */ #ifndef _SYS_CKPT_H_ #define _SYS_CKPT_H_ @@ -10,6 +33,14 @@ struct ckpt_filehdr { int cfh_reserved[8]; }; +struct ckpt_vminfo { + segsz_t cvm_dsize; + segsz_t cvm_tsize; + segsz_t cvm_reserved1[4]; + caddr_t cvm_daddr; + caddr_t cvm_taddr; + caddr_t cvm_reserved2[4]; +}; struct ckpt_fileinfo { int cfi_index; @@ -42,12 +73,12 @@ printf("entering %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__) printf("exiting %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__) #define TRACE_ERR \ printf("failure encountered in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__) -#define PRINTF printf +#define PRINTF(args) printf args #else #define TRACE_ENTER #define TRACE_EXIT #define TRACE_ERR -#define PRINTF() +#define PRINTF(args) #endif #endif