On Sun, May 25, 2008 at 10:43:23AM -0700, Matt Kraai wrote: > tag 479902 patch > thanks > > The attached patch allows cryopid to build on my i386 system. It > handles the removal of asm/page.h, the move of linux/user.h to > sys/user.h, and the renamings of user_i387_regs to user_fpregs_regs > and some registers. Your patch fixes i386, but amd64 fails, because it needs to be fixed, too. The attached patch fixes the build on amd64, but the binaries created by the freeze command do not work. Do they work for you, using your patch, on i386?
It may be possible that my patch is missing something, because I am not really experienced in this code. I'm currently working on a QA upload for this package. > > -- > Matt > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_r_i387.c > cryopid-0.5.9.1/src/arch-i386/cp_r_i387.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_r_i387.c 2008-05-25 > 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_r_i387.c 2008-05-25 10:21:38.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <sys/ptrace.h> > #include <string.h> > #include <errno.h> > @@ -8,8 +8,8 @@ > > void read_chunk_i387_data(void *fptr, int action) > { > - struct user_i387_struct u; > - read_bit(fptr, &u, sizeof(struct user_i387_struct)); > + struct user_fpregs_struct u; > + read_bit(fptr, &u, sizeof(struct user_fpregs_struct)); > > if (action & ACTION_PRINT) > fprintf(stderr, "i387 state (not currently restored)"); > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_r_regs.c > cryopid-0.5.9.1/src/arch-i386/cp_r_regs.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_r_regs.c 2008-05-25 > 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_r_regs.c 2008-05-25 10:17:00.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <linux/unistd.h> > #include <asm/ldt.h> > #include <sys/mman.h> > @@ -28,8 +28,8 @@ > *(long*)r->esp = r->eflags; > > /* set up gs */ > - if (!emulate_tls && r->gs != 0) { > - *cp++=0x66;*cp++=0xb8; *(short*)(cp) = r->gs; cp+=2; /* mov foo, %eax > */ > + if (!emulate_tls && r->xgs != 0) { > + *cp++=0x66;*cp++=0xb8; *(short*)(cp) = r->xgs; cp+=2; /* mov foo, %eax > */ > *cp++=0x8e;*cp++=0xe8; /* mov %eax, %gs */ > } > > @@ -90,8 +90,8 @@ > /* jump back to where we were. */ > *cp++=0xea; > *(unsigned long*)(cp) = r->eip; cp+= 4; > - asm("mov %%cs,%w0": "=q"(r->cs)); /* ensure we use the right CS for the > current kernel */ > - *(unsigned short*)(cp) = r->cs; cp+= 2; /* jmp cs:foo */ > + asm("mov %%cs,%w0": "=q"(r->xcs)); /* ensure we use the right CS for the > current kernel */ > + *(unsigned short*)(cp) = r->xcs; cp+= 2; /* jmp cs:foo */ > syscall_check( > (int)mprotect((void*)TRAMPOLINE_ADDR, PAGE_SIZE, PROT_READ|PROT_EXEC), > 0, "mmap"); > @@ -111,7 +111,7 @@ > fprintf(stderr, "\tesi: 0x%08lx edi: 0x%08lx ebp: 0x%08lx esp: > 0x%08lx\n", > user.regs.esi, user.regs.edi, user.regs.ebp, user.regs.esp); > fprintf(stderr, "\t ds: 0x%08x es: 0x%08x fs: 0x%08x gs: 0x%08x\n", > - user.regs.ds, user.regs.es, user.regs.fs, user.regs.gs); > + user.regs.xds, user.regs.xes, user.regs.xfs, user.regs.xgs); > fprintf(stderr, "\teip: 0x%08lx eflags: 0x%08lx", > user.regs.eip, user.regs.eflags); > } > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_r_tls.c > cryopid-0.5.9.1/src/arch-i386/cp_r_tls.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_r_tls.c 2008-05-25 10:08:50.000000000 > -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_r_tls.c 2008-05-25 10:18:15.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <linux/unistd.h> > #include <signal.h> > #include <asm/ldt.h> > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_w_i387.c > cryopid-0.5.9.1/src/arch-i386/cp_w_i387.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_w_i387.c 2008-05-25 > 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_w_i387.c 2008-05-25 10:32:38.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <sys/ptrace.h> > #include <string.h> > #include <errno.h> > @@ -8,15 +8,15 @@ > > void write_chunk_i387_data(void *fptr, struct cp_i387_data *data) > { > - write_bit(fptr, data->i387_data, sizeof(struct user_i387_struct)); > + write_bit(fptr, data->i387_data, sizeof(struct user_fpregs_struct)); > } > > void fetch_chunks_i387_data(pid_t pid, int flags, struct list *l) > { > struct cp_chunk *chunk; > - struct user_i387_struct *i387_data; > + struct user_fpregs_struct *i387_data; > > - i387_data = xmalloc(sizeof(struct user_i387_struct)); > + i387_data = xmalloc(sizeof(struct user_fpregs_struct)); > if (ptrace(PTRACE_GETFPREGS, pid, 0, i387_data) == -1) { > bail("ptrace(PTRACE_PEEKDATA): %s", strerror(errno)); > } > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_w_regs.c > cryopid-0.5.9.1/src/arch-i386/cp_w_regs.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_w_regs.c 2008-05-25 > 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_w_regs.c 2008-05-25 10:27:35.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <linux/unistd.h> > #include <asm/ldt.h> > #include <sys/mman.h> > diff -ru cryopid-0.5.9.1~/src/arch-i386/cp_w_tls.c > cryopid-0.5.9.1/src/arch-i386/cp_w_tls.c > --- cryopid-0.5.9.1~/src/arch-i386/cp_w_tls.c 2008-05-25 10:08:50.000000000 > -0700 > +++ cryopid-0.5.9.1/src/arch-i386/cp_w_tls.c 2008-05-25 10:28:51.000000000 > -0700 > @@ -1,4 +1,4 @@ > -#include <linux/user.h> > +#include <sys/user.h> > #include <linux/unistd.h> > #include <signal.h> > #include <asm/ldt.h> > diff -ru cryopid-0.5.9.1~/src/arch-i386/elfwriter.c > cryopid-0.5.9.1/src/arch-i386/elfwriter.c > --- cryopid-0.5.9.1~/src/arch-i386/elfwriter.c 2008-05-25 > 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/arch-i386/elfwriter.c 2008-05-25 10:26:16.000000000 > -0700 > @@ -1,5 +1,5 @@ > #include <elf.h> > -#include <asm/page.h> > +#include <sys/user.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > diff -ru cryopid-0.5.9.1~/src/arch-i386/process.c > cryopid-0.5.9.1/src/arch-i386/process.c > --- cryopid-0.5.9.1~/src/arch-i386/process.c 2008-05-25 10:08:50.000000000 > -0700 > +++ cryopid-0.5.9.1/src/arch-i386/process.c 2008-05-25 10:23:40.000000000 > -0700 > @@ -10,8 +10,7 @@ > #include <assert.h> > #include <netinet/tcp.h> > #include <linux/net.h> > -#include <asm/page.h> > -#include <asm/user.h> > +#include <sys/user.h> > > #include "linux/tcpcp.h" > > diff -ru cryopid-0.5.9.1~/src/arch-i386/stub.h > cryopid-0.5.9.1/src/arch-i386/stub.h > --- cryopid-0.5.9.1~/src/arch-i386/stub.h 2008-05-25 10:08:50.000000000 > -0700 > +++ cryopid-0.5.9.1/src/arch-i386/stub.h 2008-05-25 10:36:11.000000000 > -0700 > @@ -2,7 +2,7 @@ > #define _STUB_H_ > > #include <sys/mman.h> > -#include <asm/page.h> > +#include <sys/user.h> > #include "cryopid.h" > > static inline void jump_to_trampoline() > diff -ru cryopid-0.5.9.1~/src/common.c cryopid-0.5.9.1/src/common.c > --- cryopid-0.5.9.1~/src/common.c 2008-05-25 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/common.c 2008-05-25 10:38:36.000000000 -0700 > @@ -6,7 +6,7 @@ > #include <string.h> > #include <unistd.h> > #include <sys/mman.h> > -#include <asm/page.h> > +#include <sys/user.h> > > #include "cryopid.h" > > diff -ru cryopid-0.5.9.1~/src/cp_w_vma.c cryopid-0.5.9.1/src/cp_w_vma.c > --- cryopid-0.5.9.1~/src/cp_w_vma.c 2008-05-25 10:08:50.000000000 -0700 > +++ cryopid-0.5.9.1/src/cp_w_vma.c 2008-05-25 10:34:23.000000000 -0700 > @@ -5,7 +5,7 @@ > #include <fcntl.h> > #include <stdio.h> > #include <unistd.h> > -#include <asm/page.h> > +#include <sys/user.h> > > #include "cpimage.h" > #include "process.h"
* Fix Build failure with GCC 4.3 on i386 (and on AMD64) Index: cryopid-0.5.9.1/src/arch-i386/cp_r_i387.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_r_i387.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_r_i387.c 2008-06-10 18:48:59.399985682 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <sys/ptrace.h> #include <string.h> #include <errno.h> @@ -8,8 +8,8 @@ void read_chunk_i387_data(void *fptr, int action) { - struct user_i387_struct u; - read_bit(fptr, &u, sizeof(struct user_i387_struct)); + struct user_fpregs_struct u; + read_bit(fptr, &u, sizeof(struct user_fpregs_struct)); if (action & ACTION_PRINT) fprintf(stderr, "i387 state (not currently restored)"); Index: cryopid-0.5.9.1/src/arch-i386/cp_r_regs.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_r_regs.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_r_regs.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <asm/ldt.h> #include <sys/mman.h> @@ -28,8 +28,8 @@ *(long*)r->esp = r->eflags; /* set up gs */ - if (!emulate_tls && r->gs != 0) { - *cp++=0x66;*cp++=0xb8; *(short*)(cp) = r->gs; cp+=2; /* mov foo, %eax */ + if (!emulate_tls && r->xgs != 0) { + *cp++=0x66;*cp++=0xb8; *(short*)(cp) = r->xgs; cp+=2; /* mov foo, %eax */ *cp++=0x8e;*cp++=0xe8; /* mov %eax, %gs */ } @@ -90,8 +90,8 @@ /* jump back to where we were. */ *cp++=0xea; *(unsigned long*)(cp) = r->eip; cp+= 4; - asm("mov %%cs,%w0": "=q"(r->cs)); /* ensure we use the right CS for the current kernel */ - *(unsigned short*)(cp) = r->cs; cp+= 2; /* jmp cs:foo */ + asm("mov %%cs,%w0": "=q"(r->xcs)); /* ensure we use the right CS for the current kernel */ + *(unsigned short*)(cp) = r->xcs; cp+= 2; /* jmp cs:foo */ syscall_check( (int)mprotect((void*)TRAMPOLINE_ADDR, PAGE_SIZE, PROT_READ|PROT_EXEC), 0, "mmap"); @@ -111,7 +111,7 @@ fprintf(stderr, "\tesi: 0x%08lx edi: 0x%08lx ebp: 0x%08lx esp: 0x%08lx\n", user.regs.esi, user.regs.edi, user.regs.ebp, user.regs.esp); fprintf(stderr, "\t ds: 0x%08x es: 0x%08x fs: 0x%08x gs: 0x%08x\n", - user.regs.ds, user.regs.es, user.regs.fs, user.regs.gs); + user.regs.xds, user.regs.xes, user.regs.xfs, user.regs.xgs); fprintf(stderr, "\teip: 0x%08lx eflags: 0x%08lx", user.regs.eip, user.regs.eflags); } Index: cryopid-0.5.9.1/src/arch-i386/cp_r_tls.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_r_tls.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_r_tls.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <signal.h> #include <asm/ldt.h> Index: cryopid-0.5.9.1/src/arch-i386/cp_w_i387.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_w_i387.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_w_i387.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <sys/ptrace.h> #include <string.h> #include <errno.h> @@ -8,15 +8,15 @@ void write_chunk_i387_data(void *fptr, struct cp_i387_data *data) { - write_bit(fptr, data->i387_data, sizeof(struct user_i387_struct)); + write_bit(fptr, data->i387_data, sizeof(struct user_fpregs_struct)); } void fetch_chunks_i387_data(pid_t pid, int flags, struct list *l) { struct cp_chunk *chunk; - struct user_i387_struct *i387_data; + struct user_fpregs_struct *i387_data; - i387_data = xmalloc(sizeof(struct user_i387_struct)); + i387_data = xmalloc(sizeof(struct user_fpregs_struct)); if (ptrace(PTRACE_GETFPREGS, pid, 0, i387_data) == -1) { bail("ptrace(PTRACE_PEEKDATA): %s", strerror(errno)); } Index: cryopid-0.5.9.1/src/arch-i386/cp_w_regs.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_w_regs.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_w_regs.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <asm/ldt.h> #include <sys/mman.h> Index: cryopid-0.5.9.1/src/arch-i386/cp_w_tls.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/cp_w_tls.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/cp_w_tls.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <signal.h> #include <asm/ldt.h> Index: cryopid-0.5.9.1/src/arch-i386/elfwriter.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/elfwriter.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/elfwriter.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,5 +1,5 @@ #include <elf.h> -#include <asm/page.h> +#include <sys/user.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> Index: cryopid-0.5.9.1/src/arch-i386/process.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/process.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/process.c 2008-06-10 18:48:59.403972431 +0200 @@ -10,8 +10,7 @@ #include <assert.h> #include <netinet/tcp.h> #include <linux/net.h> -#include <asm/page.h> -#include <asm/user.h> +#include <sys/user.h> #include "linux/tcpcp.h" Index: cryopid-0.5.9.1/src/arch-i386/stub.h =================================================================== --- cryopid-0.5.9.1.orig/src/arch-i386/stub.h 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-i386/stub.h 2008-06-10 18:48:59.403972431 +0200 @@ -2,7 +2,7 @@ #define _STUB_H_ #include <sys/mman.h> -#include <asm/page.h> +#include <sys/user.h> #include "cryopid.h" static inline void jump_to_trampoline() Index: cryopid-0.5.9.1/src/arch-x86_64/stub.h =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/stub.h 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-x86_64/stub.h 2008-06-10 18:48:59.403972431 +0200 @@ -2,7 +2,7 @@ #define _STUB_H_ #include <sys/mman.h> -#include <asm/page.h> +#include <sys/user.h> #include "cryopid.h" static inline void jump_to_trampoline() Index: cryopid-0.5.9.1/src/common.c =================================================================== --- cryopid-0.5.9.1.orig/src/common.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/common.c 2008-06-10 18:48:59.403972431 +0200 @@ -6,7 +6,7 @@ #include <string.h> #include <unistd.h> #include <sys/mman.h> -#include <asm/page.h> +#include <sys/user.h> #include "cryopid.h" Index: cryopid-0.5.9.1/src/cp_w_vma.c =================================================================== --- cryopid-0.5.9.1.orig/src/cp_w_vma.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/cp_w_vma.c 2008-06-10 18:48:59.403972431 +0200 @@ -5,7 +5,7 @@ #include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <asm/page.h> +#include <sys/user.h> #include "cpimage.h" #include "process.h" Index: cryopid-0.5.9.1/src/arch-x86_64/stub.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/stub.c 2008-06-10 18:48:59.379989914 +0200 +++ cryopid-0.5.9.1/src/arch-x86_64/stub.c 2008-06-10 18:48:59.403972431 +0200 @@ -9,7 +9,7 @@ #include <sys/mman.h> #include <sys/prctl.h> #include <asm/prctl.h> -#include <asm/page.h> +#include <sys/user.h> #include <errno.h> #include "cryopid.h" Index: cryopid-0.5.9.1/src/arch-x86_64/cp_r_regs.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/cp_r_regs.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-x86_64/cp_r_regs.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <asm/ldt.h> #include <asm/prctl.h> Index: cryopid-0.5.9.1/src/arch-x86_64/process.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/process.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-x86_64/process.c 2008-06-10 18:48:59.403972431 +0200 @@ -9,8 +9,7 @@ #include <assert.h> #include <netinet/tcp.h> #include <linux/net.h> -#include <linux/user.h> -#include <asm/page.h> +#include <sys/user.h> #include "cryopid.h" #include "cpimage.h" Index: cryopid-0.5.9.1/src/arch-x86_64/elfwriter.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/elfwriter.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-x86_64/elfwriter.c 2008-06-10 18:48:59.403972431 +0200 @@ -3,7 +3,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> -#include <asm/page.h> +#include <sys/user.h> #include <string.h> #include <unistd.h> #include "process.h" Index: cryopid-0.5.9.1/src/arch-x86_64/cp_w_regs.c =================================================================== --- cryopid-0.5.9.1.orig/src/arch-x86_64/cp_w_regs.c 2006-12-07 19:03:34.000000000 +0100 +++ cryopid-0.5.9.1/src/arch-x86_64/cp_w_regs.c 2008-06-10 18:48:59.403972431 +0200 @@ -1,4 +1,4 @@ -#include <linux/user.h> +#include <sys/user.h> #include <linux/unistd.h> #include <asm/ldt.h> #include <asm/prctl.h>
signature.asc
Description: Digital signature