Date: Wed, 7 Apr 2010 02:24:42 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r206336 - in stable/8: . sys/amd64/amd64 sys/amd64/conf sys/amd64/include sys/amd64/linux32 sys/compat/freebsd32 sys/compat/ia32 sys/conf sys/fs/procfs sys/ia64/conf sys/ia64/ia64 sys/i... Message-ID: <201004070224.o372OgHA058011@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: nwhitehorn Date: Wed Apr 7 02:24:41 2010 New Revision: 206336 URL: http://svn.freebsd.org/changeset/base/206336 Log: MFC r205014,205015: Provide groundwork for 32-bit binary compatibility on non-x86 platforms, for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. This MFC is required for MFCs of later changes to the freebsd32 compatibility from HEAD. Requested by: kib Modified: stable/8/UPDATING stable/8/sys/amd64/amd64/db_trace.c stable/8/sys/amd64/amd64/exception.S stable/8/sys/amd64/amd64/vm_machdep.c stable/8/sys/amd64/conf/GENERIC stable/8/sys/amd64/conf/NOTES stable/8/sys/amd64/conf/XENHVM stable/8/sys/amd64/include/elf.h stable/8/sys/amd64/include/reg.h stable/8/sys/amd64/linux32/linux32_sysvec.c stable/8/sys/compat/freebsd32/freebsd32.h stable/8/sys/compat/freebsd32/freebsd32_misc.c stable/8/sys/compat/freebsd32/freebsd32_util.h stable/8/sys/compat/freebsd32/syscalls.master stable/8/sys/compat/ia32/ia32_reg.h stable/8/sys/compat/ia32/ia32_sysvec.c stable/8/sys/conf/files.amd64 stable/8/sys/conf/files.ia64 stable/8/sys/conf/options.amd64 stable/8/sys/conf/options.ia64 stable/8/sys/fs/procfs/procfs_dbregs.c stable/8/sys/fs/procfs/procfs_fpregs.c stable/8/sys/fs/procfs/procfs_ioctl.c stable/8/sys/fs/procfs/procfs_map.c stable/8/sys/fs/procfs/procfs_regs.c stable/8/sys/ia64/conf/GENERIC stable/8/sys/ia64/conf/NOTES stable/8/sys/ia64/ia64/exception.S stable/8/sys/ia64/ia64/genassym.c stable/8/sys/ia64/ia64/machdep.c stable/8/sys/ia64/include/elf.h stable/8/sys/ia64/include/reg.h stable/8/sys/kern/imgact_elf.c stable/8/sys/kern/kern_jail.c stable/8/sys/kern/kern_module.c stable/8/sys/kern/kern_thr.c stable/8/sys/kern/kern_umtx.c stable/8/sys/kern/sys_generic.c stable/8/sys/kern/sys_process.c stable/8/sys/kern/uipc_socket.c stable/8/sys/kern/vfs_aio.c stable/8/sys/modules/linux/Makefile stable/8/sys/modules/procfs/Makefile stable/8/sys/sys/ptrace.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/UPDATING ============================================================================== --- stable/8/UPDATING Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/UPDATING Wed Apr 7 02:24:41 2010 (r206336) @@ -15,6 +15,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. debugging tools present in HEAD were left in place because sun4v support still needs work to become production ready. +20100406: + The kernel option COMPAT_IA32 has been replaced with COMPAT_FREEBSD32 + to allow 32-bit compatibility on non-x86 platforms. All kernel + configurations on amd64 and ia64 platforms using these options must + be modified accordingly. + 20100125: Introduce the kernel thread "deadlock resolver" (which can be enabled via the DEADLKRES option, see NOTES for more details) and the Modified: stable/8/sys/amd64/amd64/db_trace.c ============================================================================== --- stable/8/sys/amd64/amd64/db_trace.c Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/amd64/db_trace.c Wed Apr 7 02:24:41 2010 (r206336) @@ -319,7 +319,7 @@ db_nextframe(struct amd64_frame **fp, db frame_type = INTERRUPT; else if (strcmp(name, "Xfast_syscall") == 0) frame_type = SYSCALL; -#ifdef COMPAT_IA32 +#ifdef COMPAT_FREEBSD32 else if (strcmp(name, "Xint0x80_syscall") == 0) frame_type = SYSCALL; #endif Modified: stable/8/sys/amd64/amd64/exception.S ============================================================================== --- stable/8/sys/amd64/amd64/exception.S Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/amd64/exception.S Wed Apr 7 02:24:41 2010 (r206336) @@ -572,7 +572,7 @@ ENTRY(fork_trampoline) * included. */ -#ifdef COMPAT_IA32 +#ifdef COMPAT_FREEBSD32 .data .p2align 4 .text Modified: stable/8/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/vm_machdep.c Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/amd64/vm_machdep.c Wed Apr 7 02:24:41 2010 (r206336) @@ -439,7 +439,7 @@ cpu_set_upcall_kse(struct thread *td, vo */ cpu_thread_clean(td); -#ifdef COMPAT_IA32 +#ifdef COMPAT_FREEBSD32 if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { /* * Set the trap frame to point at the beginning of the uts @@ -490,7 +490,7 @@ cpu_set_user_tls(struct thread *td, void if ((u_int64_t)tls_base >= VM_MAXUSER_ADDRESS) return (EINVAL); -#ifdef COMPAT_IA32 +#ifdef COMPAT_FREEBSD32 if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { td->td_pcb->pcb_gsbase = (register_t)tls_base; return (0); Modified: stable/8/sys/amd64/conf/GENERIC ============================================================================== --- stable/8/sys/amd64/conf/GENERIC Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/conf/GENERIC Wed Apr 7 02:24:41 2010 (r206336) @@ -54,7 +54,7 @@ options PSEUDOFS # Pseudo-filesystem f options GEOM_PART_GPT # GUID Partition Tables. options GEOM_LABEL # Provides labelization options COMPAT_43TTY # BSD 4.3 TTY compat (sgtty) -options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD32 # Compatible with i386 binaries options COMPAT_FREEBSD4 # Compatible with FreeBSD4 options COMPAT_FREEBSD5 # Compatible with FreeBSD5 options COMPAT_FREEBSD6 # Compatible with FreeBSD6 Modified: stable/8/sys/amd64/conf/NOTES ============================================================================== --- stable/8/sys/amd64/conf/NOTES Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/conf/NOTES Wed Apr 7 02:24:41 2010 (r206336) @@ -445,7 +445,7 @@ options PMAP_SHPGPERPROC=201 #XXX these 32 bit binaries is added. # Enable 32-bit runtime support for FreeBSD/i386 binaries. -options COMPAT_IA32 +options COMPAT_FREEBSD32 # Enable iBCS2 runtime support for SCO and ISC binaries #XXX#options IBCS2 @@ -456,7 +456,7 @@ options COMPAT_IA32 # Enable Linux ABI emulation #XXX#options COMPAT_LINUX -# Enable 32-bit Linux ABI emulation (requires COMPAT_43 and COMPAT_IA32) +# Enable 32-bit Linux ABI emulation (requires COMPAT_43 and COMPAT_FREEBSD32) options COMPAT_LINUX32 # Enable the linux-like proc filesystem support (requires COMPAT_LINUX32 Modified: stable/8/sys/amd64/conf/XENHVM ============================================================================== --- stable/8/sys/amd64/conf/XENHVM Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/conf/XENHVM Wed Apr 7 02:24:41 2010 (r206336) @@ -55,7 +55,7 @@ options PSEUDOFS # Pseudo-filesystem f options GEOM_PART_GPT # GUID Partition Tables. options GEOM_LABEL # Provides labelization options COMPAT_43TTY # BSD 4.3 TTY compat (sgtty) -options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD32 # Compatible with i386 binaries options COMPAT_FREEBSD4 # Compatible with FreeBSD4 options COMPAT_FREEBSD5 # Compatible with FreeBSD5 options COMPAT_FREEBSD6 # Compatible with FreeBSD6 Modified: stable/8/sys/amd64/include/elf.h ============================================================================== --- stable/8/sys/amd64/include/elf.h Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/include/elf.h Wed Apr 7 02:24:41 2010 (r206336) @@ -42,6 +42,7 @@ #include <sys/elf_generic.h> #define ELF_ARCH EM_X86_64 +#define ELF_ARCH32 EM_386 #define ELF_MACHINE_OK(x) ((x) == EM_X86_64) Modified: stable/8/sys/amd64/include/reg.h ============================================================================== --- stable/8/sys/amd64/include/reg.h Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/include/reg.h Wed Apr 7 02:24:41 2010 (r206336) @@ -37,6 +37,10 @@ #ifndef _MACHINE_REG_H_ #define _MACHINE_REG_H_ +#if defined(_KERNEL) && !defined(_STANDALONE) +#include "opt_compat.h" +#endif + /* * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS. */ @@ -116,6 +120,11 @@ struct dbreg { #define DBREG_DRX(d,x) ((d)->dr[(x)]) /* reference dr0 - dr15 by register number */ +#ifdef COMPAT_FREEBSD32 +#include <machine/fpu.h> +#include <compat/ia32/ia32_reg.h> +#endif + #ifdef _KERNEL /* * XXX these interfaces are MI, so they should be declared in a MI place. Modified: stable/8/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- stable/8/sys/amd64/linux32/linux32_sysvec.c Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/amd64/linux32/linux32_sysvec.c Wed Apr 7 02:24:41 2010 (r206336) @@ -34,8 +34,8 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" -#ifndef COMPAT_IA32 -#error "Unable to compile Linux-emulator due to missing COMPAT_IA32 option!" +#ifndef COMPAT_FREEBSD32 +#error "Unable to compile Linux-emulator due to missing COMPAT_FREEBSD32 option!" #endif #define __ELF_WORD_SIZE 32 Modified: stable/8/sys/compat/freebsd32/freebsd32.h ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32.h Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/freebsd32/freebsd32.h Wed Apr 7 02:24:41 2010 (r206336) @@ -29,6 +29,9 @@ #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ #define _COMPAT_FREEBSD32_FREEBSD32_H_ +#include <sys/procfs.h> +#include <sys/socket.h> + #define PTRIN(v) (void *)(uintptr_t) (v) #define PTROUT(v) (u_int32_t)(uintptr_t) (v) @@ -197,4 +200,25 @@ struct i386_ldt_args32 { uint32_t num; }; +/* + * Alternative layouts for <sys/procfs.h> + */ +struct prstatus32 { + int pr_version; + u_int pr_statussz; + u_int pr_gregsetsz; + u_int pr_fpregsetsz; + int pr_osreldate; + int pr_cursig; + pid_t pr_pid; + struct reg32 pr_reg; +}; + +struct prpsinfo32 { + int pr_version; + u_int pr_psinfosz; + char pr_fname[PRFNAMESZ+1]; + char pr_psargs[PRARGSZ+1]; +}; + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ Modified: stable/8/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_misc.c Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/freebsd32/freebsd32_misc.c Wed Apr 7 02:24:41 2010 (r206336) @@ -31,6 +31,8 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" +#define __ELF_WORD_SIZE 32 + #include <sys/param.h> #include <sys/bus.h> #include <sys/clock.h> @@ -44,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/malloc.h> #include <sys/file.h> /* Must come after sys/malloc.h */ +#include <sys/imgact.h> #include <sys/mbuf.h> #include <sys/mman.h> #include <sys/module.h> @@ -91,6 +94,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_extern.h> #include <machine/cpu.h> +#include <machine/elf.h> #include <security/audit/audit.h> @@ -115,6 +119,16 @@ CTASSERT(sizeof(struct sigaction32) == 2 static int freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count); static int freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count); +#if BYTE_ORDER == BIG_ENDIAN +#define PAIR32TO64(type, name) ((name ## 2) | ((type)(name ## 1) << 32)) +#define RETVAL_HI 0 +#define RETVAL_LO 1 +#else +#define PAIR32TO64(type, name) ((name ## 1) | ((type)(name ## 2) << 32)) +#define RETVAL_HI 1 +#define RETVAL_LO 0 +#endif + int freebsd32_wait4(struct thread *td, struct freebsd32_wait4_args *uap) { @@ -426,8 +440,7 @@ freebsd32_mmap(struct thread *td, struct int prot = uap->prot; int flags = uap->flags; int fd = uap->fd; - off_t pos = (uap->poslo - | ((off_t)uap->poshi << 32)); + off_t pos = PAIR32TO64(off_t,uap->pos); #ifdef __ia64__ vm_size_t pageoff; int error; @@ -523,8 +536,8 @@ freebsd6_freebsd32_mmap(struct thread *t ap.prot = uap->prot; ap.flags = uap->flags; ap.fd = uap->fd; - ap.poslo = uap->poslo; - ap.poshi = uap->poshi; + ap.pos1 = uap->pos1; + ap.pos2 = uap->pos2; return (freebsd32_mmap(td, &ap)); } @@ -586,7 +599,6 @@ freebsd32_select(struct thread *td, stru } else tvp = NULL; /* - * XXX big-endian needs to convert the fd_sets too. * XXX Do pointers need PTRIN()? */ return (kern_select(td, uap->nd, uap->in, uap->ou, uap->ex, tvp, @@ -620,7 +632,6 @@ freebsd32_pselect(struct thread *td, str } else uset = NULL; /* - * XXX big-endian needs to convert the fd_sets too. * XXX Do pointers need PTRIN()? */ error = kern_pselect(td, uap->nd, uap->in, uap->ou, uap->ex, tvp, @@ -843,7 +854,7 @@ freebsd32_preadv(struct thread *td, stru error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio); if (error) return (error); - error = kern_preadv(td, uap->fd, auio, uap->offset); + error = kern_preadv(td, uap->fd, auio, PAIR32TO64(off_t,uap->offset)); free(auio, M_IOV); return (error); } @@ -857,7 +868,7 @@ freebsd32_pwritev(struct thread *td, str error = freebsd32_copyinuio(uap->iovp, uap->iovcnt, &auio); if (error) return (error); - error = kern_pwritev(td, uap->fd, auio, uap->offset); + error = kern_pwritev(td, uap->fd, auio, PAIR32TO64(off_t,uap->offset)); free(auio, M_IOV); return (error); } @@ -1982,7 +1993,7 @@ freebsd32_pread(struct thread *td, struc ap.fd = uap->fd; ap.buf = uap->buf; ap.nbyte = uap->nbyte; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); return (pread(td, &ap)); } @@ -1994,7 +2005,7 @@ freebsd32_pwrite(struct thread *td, stru ap.fd = uap->fd; ap.buf = uap->buf; ap.nbyte = uap->nbyte; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); return (pwrite(td, &ap)); } @@ -2006,13 +2017,13 @@ freebsd32_lseek(struct thread *td, struc off_t pos; ap.fd = uap->fd; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); ap.whence = uap->whence; error = lseek(td, &ap); /* Expand the quad return into two parts for eax and edx */ pos = *(off_t *)(td->td_retval); - td->td_retval[0] = pos & 0xffffffff; /* %eax */ - td->td_retval[1] = pos >> 32; /* %edx */ + td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ + td->td_retval[RETVAL_HI] = pos >> 32; /* %edx */ return error; } @@ -2022,7 +2033,7 @@ freebsd32_truncate(struct thread *td, st struct truncate_args ap; ap.path = uap->path; - ap.length = (uap->lengthlo | ((off_t)uap->lengthhi << 32)); + ap.length = PAIR32TO64(off_t,uap->length); return (truncate(td, &ap)); } @@ -2032,7 +2043,7 @@ freebsd32_ftruncate(struct thread *td, s struct ftruncate_args ap; ap.fd = uap->fd; - ap.length = (uap->lengthlo | ((off_t)uap->lengthhi << 32)); + ap.length = PAIR32TO64(off_t,uap->length); return (ftruncate(td, &ap)); } @@ -2064,7 +2075,7 @@ freebsd6_freebsd32_pread(struct thread * ap.fd = uap->fd; ap.buf = uap->buf; ap.nbyte = uap->nbyte; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); return (pread(td, &ap)); } @@ -2076,7 +2087,7 @@ freebsd6_freebsd32_pwrite(struct thread ap.fd = uap->fd; ap.buf = uap->buf; ap.nbyte = uap->nbyte; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); return (pwrite(td, &ap)); } @@ -2088,13 +2099,13 @@ freebsd6_freebsd32_lseek(struct thread * off_t pos; ap.fd = uap->fd; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); ap.whence = uap->whence; error = lseek(td, &ap); /* Expand the quad return into two parts for eax and edx */ pos = *(off_t *)(td->td_retval); - td->td_retval[0] = pos & 0xffffffff; /* %eax */ - td->td_retval[1] = pos >> 32; /* %edx */ + td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */ + td->td_retval[RETVAL_HI] = pos >> 32; /* %edx */ return error; } @@ -2104,7 +2115,7 @@ freebsd6_freebsd32_truncate(struct threa struct truncate_args ap; ap.path = uap->path; - ap.length = (uap->lengthlo | ((off_t)uap->lengthhi << 32)); + ap.length = PAIR32TO64(off_t,uap->length); return (truncate(td, &ap)); } @@ -2114,7 +2125,7 @@ freebsd6_freebsd32_ftruncate(struct thre struct ftruncate_args ap; ap.fd = uap->fd; - ap.length = (uap->lengthlo | ((off_t)uap->lengthhi << 32)); + ap.length = PAIR32TO64(off_t,uap->length); return (ftruncate(td, &ap)); } #endif /* COMPAT_FREEBSD6 */ @@ -2141,7 +2152,7 @@ freebsd32_do_sendfile(struct thread *td, ap.fd = uap->fd; ap.s = uap->s; - ap.offset = (uap->offsetlo | ((off_t)uap->offsethi << 32)); + ap.offset = PAIR32TO64(off_t,uap->offset); ap.nbytes = uap->nbytes; ap.hdtr = (struct sf_hdtr *)uap->hdtr; /* XXX not used */ ap.sbytes = uap->sbytes; @@ -2879,7 +2890,7 @@ freebsd32_cpuset_setid(struct thread *td struct cpuset_setid_args ap; ap.which = uap->which; - ap.id = (uap->idlo | ((id_t)uap->idhi << 32)); + ap.id = PAIR32TO64(id_t,uap->id); ap.setid = uap->setid; return (cpuset_setid(td, &ap)); @@ -2893,7 +2904,7 @@ freebsd32_cpuset_getid(struct thread *td ap.level = uap->level; ap.which = uap->which; - ap.id = (uap->idlo | ((id_t)uap->idhi << 32)); + ap.id = PAIR32TO64(id_t,uap->id); ap.setid = uap->setid; return (cpuset_getid(td, &ap)); @@ -2907,7 +2918,7 @@ freebsd32_cpuset_getaffinity(struct thre ap.level = uap->level; ap.which = uap->which; - ap.id = (uap->idlo | ((id_t)uap->idhi << 32)); + ap.id = PAIR32TO64(id_t,uap->id); ap.cpusetsize = uap->cpusetsize; ap.mask = uap->mask; @@ -2922,7 +2933,7 @@ freebsd32_cpuset_setaffinity(struct thre ap.level = uap->level; ap.which = uap->which; - ap.id = (uap->idlo | ((id_t)uap->idhi << 32)); + ap.id = PAIR32TO64(id_t,uap->id); ap.cpusetsize = uap->cpusetsize; ap.mask = uap->mask; @@ -3072,3 +3083,123 @@ syscall32_module_handler(struct module * return (error); } } + +register_t * +freebsd32_copyout_strings(struct image_params *imgp) +{ + int argc, envc; + u_int32_t *vectp; + char *stringp, *destp; + u_int32_t *stack_base; + struct freebsd32_ps_strings *arginfo; + size_t execpath_len; + int szsigcode; + + /* + * Calculate string base and vector table pointers. + * Also deal with signal trampoline code for this exec type. + */ + if (imgp->execpath != NULL && imgp->auxargs != NULL) + execpath_len = strlen(imgp->execpath) + 1; + else + execpath_len = 0; + arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS; + szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); + destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - + roundup(execpath_len, sizeof(char *)) - + roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); + + /* + * install sigcode + */ + if (szsigcode) + copyout(imgp->proc->p_sysent->sv_sigcode, + ((caddr_t)arginfo - szsigcode), szsigcode); + + /* + * Copy the image path for the rtld. + */ + if (execpath_len != 0) { + imgp->execpathp = (uintptr_t)arginfo - szsigcode - execpath_len; + copyout(imgp->execpath, (void *)imgp->execpathp, + execpath_len); + } + + /* + * If we have a valid auxargs ptr, prepare some room + * on the stack. + */ + if (imgp->auxargs) { + /* + * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for + * lower compatibility. + */ + imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size + : (AT_COUNT * 2); + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets,and imgp->auxarg_size is room + * for argument of Runtime loader. + */ + vectp = (u_int32_t *) (destp - (imgp->args->argc + + imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) * + sizeof(u_int32_t)); + } else + /* + * The '+ 2' is for the null pointers at the end of each of + * the arg and env vector sets + */ + vectp = (u_int32_t *) + (destp - (imgp->args->argc + imgp->args->envc + 2) * sizeof(u_int32_t)); + + /* + * vectp also becomes our initial stack base + */ + stack_base = vectp; + + stringp = imgp->args->begin_argv; + argc = imgp->args->argc; + envc = imgp->args->envc; + /* + * Copy out strings - arguments and environment. + */ + copyout(stringp, destp, ARG_MAX - imgp->args->stringspace); + + /* + * Fill in "ps_strings" struct for ps, w, etc. + */ + suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp); + suword32(&arginfo->ps_nargvstr, argc); + + /* + * Fill in argument portion of vector table. + */ + for (; argc > 0; --argc) { + suword32(vectp++, (u_int32_t)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* a null vector table pointer separates the argp's from the envp's */ + suword32(vectp++, 0); + + suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp); + suword32(&arginfo->ps_nenvstr, envc); + + /* + * Fill in environment portion of vector table. + */ + for (; envc > 0; --envc) { + suword32(vectp++, (u_int32_t)(intptr_t)destp); + while (*stringp++ != 0) + destp++; + destp++; + } + + /* end of vector table is a null pointer */ + suword32(vectp, 0); + + return ((register_t *)stack_base); +} + Modified: stable/8/sys/compat/freebsd32/freebsd32_util.h ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_util.h Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/freebsd32/freebsd32_util.h Wed Apr 7 02:24:41 2010 (r206336) @@ -83,4 +83,6 @@ int syscall32_register(int *offset, s int syscall32_deregister(int *offset, struct sysent *old_sysent); int syscall32_module_handler(struct module *mod, int what, void *arg); +register_t *freebsd32_copyout_strings(struct image_params *imgp); + #endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */ Modified: stable/8/sys/compat/freebsd32/syscalls.master ============================================================================== --- stable/8/sys/compat/freebsd32/syscalls.master Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/freebsd32/syscalls.master Wed Apr 7 02:24:41 2010 (r206336) @@ -53,6 +53,10 @@ #include <compat/freebsd32/freebsd32.h> #include <compat/freebsd32/freebsd32_proto.h> +#if !defined(PAD64_REQUIRED) && defined(__powerpc__) +#define PAD64_REQUIRED +#endif + ; Reserved/unimplemented system calls in the range 0-150 inclusive ; are reserved for use in future Berkeley releases. ; Additional system calls implemented in vendor and other @@ -195,7 +199,6 @@ 93 AUE_SELECT STD { int freebsd32_select(int nd, fd_set *in, \ fd_set *ou, fd_set *ex, \ struct timeval32 *tv); } -; XXX need to override for big-endian - little-endian should work fine. 94 AUE_NULL UNIMPL setdopt 95 AUE_FSYNC NOPROTO { int fsync(int fd); } 96 AUE_SETPRIORITY NOPROTO { int setpriority(int which, int who, \ @@ -316,12 +319,10 @@ 172 AUE_NULL UNIMPL nosys 173 AUE_PREAD COMPAT6 { ssize_t freebsd32_pread(int fd, void *buf, \ size_t nbyte, int pad, \ - u_int32_t offsetlo, u_int32_t offsethi); } -; XXX note - bigendian is different + u_int32_t offset1, u_int32_t offset2); } 174 AUE_PWRITE COMPAT6 { ssize_t freebsd32_pwrite(int fd, \ const void *buf, size_t nbyte, int pad, \ - u_int32_t offsetlo, u_int32_t offsethi); } -; XXX note - bigendian is different + u_int32_t offset1, u_int32_t offset2); } 175 AUE_NULL UNIMPL nosys 176 AUE_NTP_ADJTIME NOPROTO { int ntp_adjtime(struct timex *tp); } 177 AUE_NULL UNIMPL sfork (BSD/OS 2.x) @@ -356,21 +357,17 @@ char *buf, u_int count, int32_t *basep); } 197 AUE_MMAP COMPAT6 { caddr_t freebsd32_mmap(caddr_t addr, \ size_t len, int prot, int flags, int fd, \ - int pad, u_int32_t poslo, \ - u_int32_t poshi); } + int pad, u_int32_t pos1, u_int32_t pos2); } 198 AUE_NULL NOPROTO { int nosys(void); } __syscall \ __syscall_args int -; XXX note - bigendian is different 199 AUE_LSEEK COMPAT6 { off_t freebsd32_lseek(int fd, int pad, \ - u_int32_t offsetlo, u_int32_t offsethi, \ + u_int32_t offset1, u_int32_t offset2, \ int whence); } -; XXX note - bigendian is different 200 AUE_TRUNCATE COMPAT6 { int freebsd32_truncate(char *path, \ - int pad, u_int32_t lengthlo, \ - u_int32_t lengthhi); } -; XXX note - bigendian is different + int pad, u_int32_t length1, \ + u_int32_t length2); } 201 AUE_FTRUNCATE COMPAT6 { int freebsd32_ftruncate(int fd, int pad, \ - u_int32_t lengthlo, u_int32_t lengthhi); } + u_int32_t length1, u_int32_t length2); } 202 AUE_SYSCTL STD { int freebsd32_sysctl(int *name, \ u_int namelen, void *old, \ u_int32_t *oldlenp, void *new, \ @@ -403,7 +400,7 @@ ; ; The following were introduced with NetBSD/4.4Lite-2 -; They are initialized by thier respective modules/sysinits +; They are initialized by their respective modules/sysinits ; XXX PROBLEM!! 220 AUE_SEMCTL COMPAT7 { int freebsd32_semctl(int semid, int semnum, \ int cmd, union semun32 *arg); } @@ -504,12 +501,12 @@ ; 289 and 290 from NetBSD (OpenBSD: 267 and 268) 289 AUE_PREADV STD { ssize_t freebsd32_preadv(int fd, \ struct iovec32 *iovp, \ - u_int iovcnt, off_t offset); } -; XXX note - bigendian is different + u_int iovcnt, \ + u_int32_t offset1, u_int32_t offset2); } 290 AUE_PWRITEV STD { ssize_t freebsd32_pwritev(int fd, \ struct iovec32 *iovp, \ - u_int iovcnt, off_t offset); } -; XXX note - bigendian is different + u_int iovcnt, \ + u_int32_t offset1, u_int32_t offset2); } 291 AUE_NULL UNIMPL nosys 292 AUE_NULL UNIMPL nosys 293 AUE_NULL UNIMPL nosys @@ -582,9 +579,8 @@ 334 AUE_NULL NOPROTO { int sched_rr_get_interval (pid_t pid, \ struct timespec *interval); } 335 AUE_NULL NOPROTO { int utrace(const void *addr, size_t len); } -; XXX note - bigendian is different 336 AUE_SENDFILE COMPAT4 { int freebsd32_sendfile(int fd, int s, \ - u_int32_t offsetlo, u_int32_t offsethi, \ + u_int32_t offset1, u_int32_t offset2, \ size_t nbytes, struct sf_hdtr32 *hdtr, \ off_t *sbytes, int flags); } 337 AUE_NULL NOPROTO { int kldsym(int fileid, int cmd, \ @@ -687,7 +683,7 @@ 392 AUE_NULL NOPROTO { int uuidgen(struct uuid *store, \ int count); } 393 AUE_SENDFILE STD { int freebsd32_sendfile(int fd, int s, \ - u_int32_t offsetlo, u_int32_t offsethi, \ + u_int32_t offset1, u_int32_t offset2, \ size_t nbytes, struct sf_hdtr32 *hdtr, \ off_t *sbytes, int flags); } 394 AUE_NULL UNIMPL mac_syscall @@ -821,42 +817,74 @@ 474 AUE_NULL NOPROTO { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ struct sockaddr * from, __socklen_t *fromlenaddr, \ struct sctp_sndrcvinfo *sinfo, int *msg_flags); } +#ifdef PAD64_REQUIRED 475 AUE_PREAD STD { ssize_t freebsd32_pread(int fd, \ void *buf,size_t nbyte, \ - u_int32_t offsetlo, u_int32_t offsethi); } + int pad, \ + u_int32_t offset1, u_int32_t offset2); } 476 AUE_PWRITE STD { ssize_t freebsd32_pwrite(int fd, \ const void *buf, size_t nbyte, \ - u_int32_t offsetlo, u_int32_t offsethi); } + int pad, \ + u_int32_t offset1, u_int32_t offset2); } 477 AUE_MMAP STD { caddr_t freebsd32_mmap(caddr_t addr, \ size_t len, int prot, int flags, int fd, \ - u_int32_t poslo, u_int32_t poshi); } + int pad, \ + u_int32_t pos1, u_int32_t pos2); } 478 AUE_LSEEK STD { off_t freebsd32_lseek(int fd, \ - u_int32_t offsetlo, u_int32_t offsethi, \ + int pad, \ + u_int32_t offset1, u_int32_t offset2, \ int whence); } 479 AUE_TRUNCATE STD { int freebsd32_truncate(char *path, \ - u_int32_t lengthlo, u_int32_t lengthhi); } + int pad, \ + u_int32_t length1, u_int32_t length2); } 480 AUE_FTRUNCATE STD { int freebsd32_ftruncate(int fd, \ - u_int32_t lengthlo, u_int32_t lengthhi); } + int pad, \ + u_int32_t length1, u_int32_t length2); } +#else +475 AUE_PREAD STD { ssize_t freebsd32_pread(int fd, \ + void *buf,size_t nbyte, \ + u_int32_t offset1, u_int32_t offset2); } +476 AUE_PWRITE STD { ssize_t freebsd32_pwrite(int fd, \ + const void *buf, size_t nbyte, \ + u_int32_t offset1, u_int32_t offset2); } +477 AUE_MMAP STD { caddr_t freebsd32_mmap(caddr_t addr, \ + size_t len, int prot, int flags, int fd, \ + u_int32_t pos1, u_int32_t pos2); } +478 AUE_LSEEK STD { off_t freebsd32_lseek(int fd, \ + u_int32_t offset1, u_int32_t offset2, \ + int whence); } +479 AUE_TRUNCATE STD { int freebsd32_truncate(char *path, \ + u_int32_t length1, u_int32_t length2); } +480 AUE_FTRUNCATE STD { int freebsd32_ftruncate(int fd, \ + u_int32_t length1, u_int32_t length2); } +#endif 481 AUE_KILL NOPROTO { int thr_kill2(pid_t pid, long id, int sig); } 482 AUE_SHMOPEN NOPROTO { int shm_open(const char *path, int flags, \ mode_t mode); } 483 AUE_SHMUNLINK NOPROTO { int shm_unlink(const char *path); } 484 AUE_NULL NOPROTO { int cpuset(cpusetid_t *setid); } +#ifdef PAD64_REQUIRED +485 AUE_NULL STD { int freebsd32_cpuset_setid(cpuwhich_t which, \ + int pad, \ + u_int32_t id1, u_int32_t id2, \ + cpusetid_t setid); } +#else 485 AUE_NULL STD { int freebsd32_cpuset_setid(cpuwhich_t which, \ - uint32_t idlo, uint32_t idhi, \ + u_int32_t id1, u_int32_t id2, \ cpusetid_t setid); } +#endif 486 AUE_NULL STD { int freebsd32_cpuset_getid(cpulevel_t level, \ cpuwhich_t which, \ - uint32_t idlo, uint32_t idhi, \ + u_int32_t id1, u_int32_t id2, \ cpusetid_t *setid); } 487 AUE_NULL STD { int freebsd32_cpuset_getaffinity( \ cpulevel_t level, cpuwhich_t which, \ - uint32_t idlo, uint32_t idhi, \ + u_int32_t id1, u_int32_t id2, \ size_t cpusetsize, \ cpuset_t *mask); } 488 AUE_NULL STD { int freebsd32_cpuset_setaffinity( \ cpulevel_t level, cpuwhich_t which, \ - uint32_t idlo, uint32_t idhi, \ + u_int32_t id1, u_int32_t id2, \ size_t cpusetsize, \ const cpuset_t *mask); } 489 AUE_FACCESSAT NOPROTO { int faccessat(int fd, char *path, int mode, \ Modified: stable/8/sys/compat/ia32/ia32_reg.h ============================================================================== --- stable/8/sys/compat/ia32/ia32_reg.h Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/ia32/ia32_reg.h Wed Apr 7 02:24:41 2010 (r206336) @@ -105,29 +105,6 @@ struct save87 { u_char sv_pad[64]; /* padding; used by emulators */ }; - -/* - * Alternative layouts for <sys/procfs.h> - * Used in core dumps, the reason for this file existing. - */ -struct prstatus32 { - int pr_version; - u_int pr_statussz; - u_int pr_gregsetsz; - u_int pr_fpregsetsz; - int pr_osreldate; - int pr_cursig; - pid_t pr_pid; - struct reg32 pr_reg; -}; - -struct prpsinfo32 { - int pr_version; - u_int pr_psinfosz; - char pr_fname[PRFNAMESZ+1]; - char pr_psargs[PRARGSZ+1]; -}; - /* * Wrappers and converters. */ Modified: stable/8/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/8/sys/compat/ia32/ia32_sysvec.c Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/compat/ia32/ia32_sysvec.c Wed Apr 7 02:24:41 2010 (r206336) @@ -93,7 +93,6 @@ CTASSERT(sizeof(struct ia32_ucontext4) = CTASSERT(sizeof(struct ia32_sigframe4) == 408); #endif -static register_t *ia32_copyout_strings(struct image_params *imgp); static void ia32_fixlimit(struct rlimit *rl, int which); SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); @@ -132,7 +131,7 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_usrstack = FREEBSD32_USRSTACK, .sv_psstrings = FREEBSD32_PS_STRINGS, .sv_stackprot = VM_PROT_ALL, - .sv_copyout_strings = ia32_copyout_strings, + .sv_copyout_strings = freebsd32_copyout_strings, .sv_setregs = ia32_setregs, .sv_fixlimit = ia32_fixlimit, .sv_maxssiz = &ia32_maxssiz, @@ -194,127 +193,6 @@ elf32_dump_thread(struct thread *td __un { } - -/* XXX may be freebsd32 MI */ -static register_t * -ia32_copyout_strings(struct image_params *imgp) -{ - int argc, envc; - u_int32_t *vectp; - char *stringp, *destp; - u_int32_t *stack_base; - struct freebsd32_ps_strings *arginfo; - size_t execpath_len; - int szsigcode; - - /* - * Calculate string base and vector table pointers. - * Also deal with signal trampoline code for this exec type. - */ - if (imgp->execpath != NULL && imgp->auxargs != NULL) - execpath_len = strlen(imgp->execpath) + 1; - else - execpath_len = 0; - arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS; - szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); - destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - - roundup(execpath_len, sizeof(char *)) - - roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); - - /* - * install sigcode - */ - if (szsigcode) - copyout(imgp->proc->p_sysent->sv_sigcode, - ((caddr_t)arginfo - szsigcode), szsigcode); - - /* - * Copy the image path for the rtld. - */ - if (execpath_len != 0) { - imgp->execpathp = (uintptr_t)arginfo - szsigcode - execpath_len; - copyout(imgp->execpath, (void *)imgp->execpathp, - execpath_len); - } - - /* - * If we have a valid auxargs ptr, prepare some room - * on the stack. - */ - if (imgp->auxargs) { - /* - * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for - * lower compatibility. - */ - imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size - : (AT_COUNT * 2); - /* - * The '+ 2' is for the null pointers at the end of each of - * the arg and env vector sets,and imgp->auxarg_size is room - * for argument of Runtime loader. - */ - vectp = (u_int32_t *) (destp - (imgp->args->argc + - imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) * - sizeof(u_int32_t)); - } else - /* - * The '+ 2' is for the null pointers at the end of each of - * the arg and env vector sets - */ - vectp = (u_int32_t *) - (destp - (imgp->args->argc + imgp->args->envc + 2) * sizeof(u_int32_t)); - - /* - * vectp also becomes our initial stack base - */ - stack_base = vectp; - - stringp = imgp->args->begin_argv; - argc = imgp->args->argc; - envc = imgp->args->envc; - /* - * Copy out strings - arguments and environment. - */ - copyout(stringp, destp, ARG_MAX - imgp->args->stringspace); - - /* - * Fill in "ps_strings" struct for ps, w, etc. - */ - suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp); - suword32(&arginfo->ps_nargvstr, argc); - - /* - * Fill in argument portion of vector table. - */ - for (; argc > 0; --argc) { - suword32(vectp++, (u_int32_t)(intptr_t)destp); - while (*stringp++ != 0) - destp++; - destp++; - } - - /* a null vector table pointer separates the argp's from the envp's */ - suword32(vectp++, 0); - - suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp); - suword32(&arginfo->ps_nenvstr, envc); - - /* - * Fill in environment portion of vector table. - */ - for (; envc > 0; --envc) { - suword32(vectp++, (u_int32_t)(intptr_t)destp); - while (*stringp++ != 0) - destp++; - destp++; - } - - /* end of vector table is a null pointer */ - suword32(vectp, 0); - - return ((register_t *)stack_base); -} - static void ia32_fixlimit(struct rlimit *rl, int which) { Modified: stable/8/sys/conf/files.amd64 ============================================================================== --- stable/8/sys/conf/files.amd64 Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/conf/files.amd64 Wed Apr 7 02:24:41 2010 (r206336) @@ -236,20 +236,20 @@ kern/link_elf_obj.c standard # # IA32 binary support # -#amd64/ia32/ia32_exception.S optional compat_ia32 -amd64/ia32/ia32_reg.c optional compat_ia32 -amd64/ia32/ia32_signal.c optional compat_ia32 -amd64/ia32/ia32_sigtramp.S optional compat_ia32 -amd64/ia32/ia32_syscall.c optional compat_ia32 -amd64/ia32/ia32_misc.c optional compat_ia32 -compat/freebsd32/freebsd32_ioctl.c optional compat_ia32 -compat/freebsd32/freebsd32_misc.c optional compat_ia32 -compat/freebsd32/freebsd32_syscalls.c optional compat_ia32 -compat/freebsd32/freebsd32_sysent.c optional compat_ia32 -compat/ia32/ia32_sysvec.c optional compat_ia32 +#amd64/ia32/ia32_exception.S optional compat_freebsd32 +amd64/ia32/ia32_reg.c optional compat_freebsd32 +amd64/ia32/ia32_signal.c optional compat_freebsd32 +amd64/ia32/ia32_sigtramp.S optional compat_freebsd32 +amd64/ia32/ia32_syscall.c optional compat_freebsd32 +amd64/ia32/ia32_misc.c optional compat_freebsd32 +compat/freebsd32/freebsd32_ioctl.c optional compat_freebsd32 +compat/freebsd32/freebsd32_misc.c optional compat_freebsd32 +compat/freebsd32/freebsd32_syscalls.c optional compat_freebsd32 +compat/freebsd32/freebsd32_sysent.c optional compat_freebsd32 +compat/ia32/ia32_sysvec.c optional compat_freebsd32 compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs -kern/imgact_elf32.c optional compat_ia32 +kern/imgact_elf32.c optional compat_freebsd32 # # Linux/i386 binary support # Modified: stable/8/sys/conf/files.ia64 ============================================================================== --- stable/8/sys/conf/files.ia64 Wed Apr 7 01:53:00 2010 (r206335) +++ stable/8/sys/conf/files.ia64 Wed Apr 7 02:24:41 2010 (r206336) @@ -28,11 +28,11 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -compat/freebsd32/freebsd32_ioctl.c optional compat_ia32 -compat/freebsd32/freebsd32_misc.c optional compat_ia32 -compat/freebsd32/freebsd32_syscalls.c optional compat_ia32 -compat/freebsd32/freebsd32_sysent.c optional compat_ia32 -compat/ia32/ia32_sysvec.c optional compat_ia32 +compat/freebsd32/freebsd32_ioctl.c optional compat_freebsd32 +compat/freebsd32/freebsd32_misc.c optional compat_freebsd32 +compat/freebsd32/freebsd32_syscalls.c optional compat_freebsd32 +compat/freebsd32/freebsd32_sysent.c optional compat_freebsd32 +compat/ia32/ia32_sysvec.c optional compat_freebsd32 contrib/ia64/libuwx/src/uwx_bstream.c standard contrib/ia64/libuwx/src/uwx_context.c standard contrib/ia64/libuwx/src/uwx_env.c standard @@ -69,10 +69,10 @@ ia64/acpica/madt.c optional acpi ia64/disasm/disasm_decode.c standard ia64/disasm/disasm_extract.c standard ia64/disasm/disasm_format.c standard -ia64/ia32/ia32_misc.c optional compat_ia32 *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004070224.o372OgHA058011>