From owner-svn-src-all@FreeBSD.ORG Wed Jan 26 20:03:58 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA5F81065670; Wed, 26 Jan 2011 20:03:58 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 975C68FC12; Wed, 26 Jan 2011 20:03:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0QK3w6D088024; Wed, 26 Jan 2011 20:03:58 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0QK3wmY088010; Wed, 26 Jan 2011 20:03:58 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201101262003.p0QK3wmY088010@svn.freebsd.org> From: Dmitry Chagin Date: Wed, 26 Jan 2011 20:03:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217896 - in head/sys: amd64/amd64 amd64/linux32 compat/linprocfs fs/procfs i386/linux kern powerpc/aim powerpc/powerpc sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2011 20:03:58 -0000 Author: dchagin Date: Wed Jan 26 20:03:58 2011 New Revision: 217896 URL: http://svn.freebsd.org/changeset/base/217896 Log: Add macro to test the sv_flags of any process. Change some places to test the flags instead of explicit comparing with address of known sysentvec structures. MFC after: 1 month Modified: head/sys/amd64/amd64/vm_machdep.c head/sys/amd64/linux32/linux32_machdep.c head/sys/compat/linprocfs/linprocfs.c head/sys/fs/procfs/procfs_dbregs.c head/sys/fs/procfs/procfs_fpregs.c head/sys/fs/procfs/procfs_map.c head/sys/fs/procfs/procfs_regs.c head/sys/i386/linux/linux_machdep.c head/sys/kern/kern_jail.c head/sys/kern/sys_process.c head/sys/powerpc/aim/trap.c head/sys/powerpc/powerpc/exec_machdep.c head/sys/sys/sysent.h Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/amd64/amd64/vm_machdep.c Wed Jan 26 20:03:58 2011 (r217896) @@ -445,7 +445,7 @@ cpu_set_upcall_kse(struct thread *td, vo cpu_thread_clean(td); #ifdef COMPAT_FREEBSD32 - if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { /* * Set the trap frame to point at the beginning of the uts * function. @@ -498,7 +498,7 @@ cpu_set_user_tls(struct thread *td, void pcb = td->td_pcb; #ifdef COMPAT_FREEBSD32 - if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { pcb->pcb_gsbase = (register_t)tls_base; return (0); } Modified: head/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- head/sys/amd64/linux32/linux32_machdep.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/amd64/linux32/linux32_machdep.c Wed Jan 26 20:03:58 2011 (r217896) @@ -131,7 +131,7 @@ linux_execve(struct thread *td, struct l * linux_proc_init, this leads to a panic on KASSERT * because such process has p->p_emuldata == NULL. */ - if (td->td_proc->p_sysent == &elf_linux_sysvec) + if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) error = linux_proc_init(td, 0, 0); return (error); } Modified: head/sys/compat/linprocfs/linprocfs.c ============================================================================== --- head/sys/compat/linprocfs/linprocfs.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/compat/linprocfs/linprocfs.c Wed Jan 26 20:03:58 2011 (r217896) @@ -928,7 +928,7 @@ do { \ #ifdef COMPAT_FREEBSD32 env_vector32 = NULL; - if ((p->p_sysent->sv_flags & SV_ILP32) != 0) { + if (SV_PROC_FLAG(p, SV_ILP32) != 0) { env_vector32 = malloc(sizeof(*env_vector32) * MAX_ARGV_STR, M_TEMP, M_WAITOK); elm_len = sizeof(int32_t); Modified: head/sys/fs/procfs/procfs_dbregs.c ============================================================================== --- head/sys/fs/procfs/procfs_dbregs.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/fs/procfs/procfs_dbregs.c Wed Jan 26 20:03:58 2011 (r217896) @@ -107,7 +107,7 @@ procfs_doprocdbregs(PFS_FILL_ARGS) td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { - if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { + if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) { PROC_UNLOCK(p); return (EINVAL); } Modified: head/sys/fs/procfs/procfs_fpregs.c ============================================================================== --- head/sys/fs/procfs/procfs_fpregs.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/fs/procfs/procfs_fpregs.c Wed Jan 26 20:03:58 2011 (r217896) @@ -106,7 +106,7 @@ procfs_doprocfpregs(PFS_FILL_ARGS) td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { - if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { + if (SV_PROC_FLAG(td2->td_proc, SV_ILP32) == 0) { PROC_UNLOCK(p); return (EINVAL); } Modified: head/sys/fs/procfs/procfs_map.c ============================================================================== --- head/sys/fs/procfs/procfs_map.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/fs/procfs/procfs_map.c Wed Jan 26 20:03:58 2011 (r217896) @@ -100,8 +100,8 @@ procfs_doprocmap(PFS_FILL_ARGS) return (EOPNOTSUPP); #ifdef COMPAT_FREEBSD32 - if (curproc->p_sysent->sv_flags & SV_ILP32) { - if (!(p->p_sysent->sv_flags & SV_ILP32)) + if (SV_CURPROC_FLAG(SV_ILP32)) { + if (!(SV_PROC_FLAG(p, SV_ILP32))) return (EOPNOTSUPP); wrap32 = 1; } Modified: head/sys/fs/procfs/procfs_regs.c ============================================================================== --- head/sys/fs/procfs/procfs_regs.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/fs/procfs/procfs_regs.c Wed Jan 26 20:03:58 2011 (r217896) @@ -106,7 +106,7 @@ procfs_doprocregs(PFS_FILL_ARGS) td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32)) { - if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { + if ((SV_PROC_FLAG(td2->td_proc, SV_ILP32)) == 0) { PROC_UNLOCK(p); return (EINVAL); } Modified: head/sys/i386/linux/linux_machdep.c ============================================================================== --- head/sys/i386/linux/linux_machdep.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/i386/linux/linux_machdep.c Wed Jan 26 20:03:58 2011 (r217896) @@ -146,8 +146,8 @@ linux_execve(struct thread *td, struct l * linux_proc_init, this leads to a panic on KASSERT * because such process has p->p_emuldata == NULL */ - if (td->td_proc->p_sysent == &elf_linux_sysvec) - error = linux_proc_init(td, 0, 0); + if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX) + error = linux_proc_init(td, 0, 0); return (error); } Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/kern/kern_jail.c Wed Jan 26 20:03:58 2011 (r217896) @@ -745,7 +745,7 @@ kern_jail_set(struct thread *td, struct } #ifdef COMPAT_FREEBSD32 - if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { uint32_t hid32; error = vfs_copyopt(opts, "host.hostid", &hid32, sizeof(hid32)); @@ -1972,7 +1972,7 @@ kern_jail_get(struct thread *td, struct if (error != 0 && error != ENOENT) goto done_deref; #ifdef COMPAT_FREEBSD32 - if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { uint32_t hid32 = pr->pr_hostid; error = vfs_setopt(opts, "host.hostid", &hid32, sizeof(hid32)); Modified: head/sys/kern/sys_process.c ============================================================================== --- head/sys/kern/sys_process.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/kern/sys_process.c Wed Jan 26 20:03:58 2011 (r217896) @@ -727,7 +727,7 @@ kern_ptrace(struct thread *td, int req, * Set the wrap controls accordingly. */ if (SV_CURPROC_FLAG(SV_ILP32)) { - if (td2->td_proc->p_sysent->sv_flags & SV_ILP32) + if (SV_PROC_FLAG(td2->td_proc, SV_ILP32)) safe = 1; wrap32 = 1; } Modified: head/sys/powerpc/aim/trap.c ============================================================================== --- head/sys/powerpc/aim/trap.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/powerpc/aim/trap.c Wed Jan 26 20:03:58 2011 (r217896) @@ -389,7 +389,7 @@ cpu_fetch_syscall_args(struct thread *td * so as to maintain quad alignment * for the rest of the args. */ - if (p->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(p, SV_ILP32)) { params += sizeof(register_t); sa->code = *(register_t *) params; params += sizeof(register_t); @@ -410,7 +410,7 @@ cpu_fetch_syscall_args(struct thread *td sa->narg = sa->callp->sy_narg; - if (p->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(p, SV_ILP32)) { argsz = sizeof(uint32_t); for (i = 0; i < n; i++) @@ -430,7 +430,7 @@ cpu_fetch_syscall_args(struct thread *td error = 0; #ifdef __powerpc64__ - if (p->p_sysent->sv_flags & SV_ILP32 && sa->narg > n) { + if (SV_PROC_FLAG(p, SV_ILP32) && sa->narg > n) { /* Expand the size of arguments copied from the stack */ for (i = sa->narg; i >= n; i--) Modified: head/sys/powerpc/powerpc/exec_machdep.c ============================================================================== --- head/sys/powerpc/powerpc/exec_machdep.c Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/powerpc/powerpc/exec_machdep.c Wed Jan 26 20:03:58 2011 (r217896) @@ -156,7 +156,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, #endif #ifdef COMPAT_FREEBSD32 - if (p->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(p, SV_ILP32)) { siginfo_to_siginfo32(&ksi->ksi_info, &siginfo32); sig = siginfo32.si_signo; code = siginfo32.si_code; @@ -251,7 +251,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, tf->fixreg[FIRSTARG] = sig; #ifdef COMPAT_FREEBSD32 tf->fixreg[FIRSTARG+2] = (register_t)usfp + - ((p->p_sysent->sv_flags & SV_ILP32) ? + ((SV_PROC_FLAG(p, SV_ILP32)) ? offsetof(struct sigframe32, sf_uc) : offsetof(struct sigframe, sf_uc)); #else @@ -263,7 +263,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, * Signal handler installed with SA_SIGINFO. */ #ifdef COMPAT_FREEBSD32 - if (p->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(p, SV_ILP32)) { sf32.sf_si = siginfo32; tf->fixreg[FIRSTARG+1] = (register_t)usfp + offsetof(struct sigframe32, sf_si); @@ -871,7 +871,7 @@ cpu_set_syscall_retval(struct thread *td tf = td->td_frame; if (tf->fixreg[0] == SYS___syscall && - (p->p_sysent->sv_flags & SV_ILP32)) { + (SV_PROC_FLAG(p, SV_ILP32))) { int code = tf->fixreg[FIRSTARG + 1]; if (p->p_sysent->sv_mask) code &= p->p_sysent->sv_mask; @@ -944,7 +944,7 @@ int cpu_set_user_tls(struct thread *td, void *tls_base) { - if (td->td_proc->p_sysent->sv_flags & SV_LP64) + if (SV_PROC_FLAG(td->td_proc, SV_LP64)) td->td_frame->fixreg[13] = (register_t)tls_base + 0x7010; else td->td_frame->fixreg[2] = (register_t)tls_base + 0x7008; @@ -1011,7 +1011,7 @@ cpu_set_upcall_kse(struct thread *td, vo tf->fixreg[1] = (register_t)sp; tf->fixreg[3] = (register_t)arg; - if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { tf->srr0 = (register_t)entry; #ifdef AIM tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT; Modified: head/sys/sys/sysent.h ============================================================================== --- head/sys/sys/sysent.h Wed Jan 26 19:55:54 2011 (r217895) +++ head/sys/sys/sysent.h Wed Jan 26 20:03:58 2011 (r217896) @@ -129,8 +129,10 @@ struct sysentvec { #define SV_SHP 0x010000 #define SV_ABI_MASK 0xff -#define SV_CURPROC_FLAG(x) (curproc->p_sysent->sv_flags & (x)) -#define SV_CURPROC_ABI() (curproc->p_sysent->sv_flags & SV_ABI_MASK) +#define SV_PROC_FLAG(p, x) ((p)->p_sysent->sv_flags & (x)) +#define SV_PROC_ABI(p) ((p)->p_sysent->sv_flags & SV_ABI_MASK) +#define SV_CURPROC_FLAG(x) SV_PROC_FLAG(curproc, x) +#define SV_CURPROC_ABI() SV_PROC_ABI(curproc) /* same as ELFOSABI_XXX, to prevent header pollution */ #define SV_ABI_LINUX 3 #define SV_ABI_FREEBSD 9