From 2883703e00a4a50e97f2ee18676d8cef1687f032 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 2 Mar 2009 18:43:50 +0000 Subject: [PATCH] Use the p_sysent->sv_flags flag SV_ILP32 to detect 32bit process executing on 64bit kernel. This eliminates the direct comparisions of p_sysent with &ia32_freebsd_sysvec, that were left intact after r185169. --- sys/amd64/amd64/vm_machdep.c | 11 +++-------- sys/fs/procfs/procfs_dbregs.c | 6 +++--- sys/fs/procfs/procfs_fpregs.c | 6 +++--- sys/fs/procfs/procfs_regs.c | 6 +++--- sys/kern/sys_process.c | 9 ++++----- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 0cc9b039a22..1e87bdc6fbf 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -80,12 +81,6 @@ __FBSDID("$FreeBSD$"); #include -#ifdef COMPAT_IA32 - -extern struct sysentvec ia32_freebsd_sysvec; - -#endif - static void cpu_reset_real(void); #ifdef SMP static void cpu_reset_proxy(void); @@ -331,7 +326,7 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, cpu_thread_clean(td); #ifdef COMPAT_IA32 - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { + if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { /* * Set the trap frame to point at the beginning of the uts * function. @@ -377,7 +372,7 @@ cpu_set_user_tls(struct thread *td, void *tls_base) return (EINVAL); #ifdef COMPAT_IA32 - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { + if (td->td_proc->p_sysent->sv_flags & SV_ILP32) { if (td == curthread) { critical_enter(); td->td_pcb->pcb_gsbase = (register_t)tls_base; diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c index 722e4cf5be9..efa4e14d668 100644 --- a/sys/fs/procfs/procfs_dbregs.c +++ b/sys/fs/procfs/procfs_dbregs.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -63,7 +64,6 @@ #include #include -extern struct sysentvec ia32_freebsd_sysvec; /* * PROC(write, dbregs, td2, &r) becomes * proc_write_dbregs(td2, &r) or @@ -107,8 +107,8 @@ procfs_doprocdbregs(PFS_FILL_ARGS) td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_IA32 - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { - if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) { + if (SV_CURPROC_FLAG(SV_ILP32)) { + if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { PROC_UNLOCK(p); return (EINVAL); } diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c index 25412d83e7e..43af53e3ce5 100644 --- a/sys/fs/procfs/procfs_fpregs.c +++ b/sys/fs/procfs/procfs_fpregs.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,6 @@ #include #include -extern struct sysentvec ia32_freebsd_sysvec; /* * PROC(write, fpregs, td2, &r) becomes * proc_write_fpregs(td2, &r) or @@ -102,8 +102,8 @@ procfs_doprocfpregs(PFS_FILL_ARGS) /* XXXKSE: */ td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_IA32 - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { - if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) { + if (SV_CURPROC_FLAG(SV_ILP32)) { + if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { PROC_UNLOCK(p); return (EINVAL); } diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c index 481c0534716..82922fbe897 100644 --- a/sys/fs/procfs/procfs_regs.c +++ b/sys/fs/procfs/procfs_regs.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,6 @@ #include #include -extern struct sysentvec ia32_freebsd_sysvec; /* * PROC(write, regs, td2, &r) becomes * proc_write_regs(td2, &r) or @@ -102,8 +102,8 @@ procfs_doprocregs(PFS_FILL_ARGS) /* XXXKSE: */ td2 = FIRST_THREAD_IN_PROC(p); #ifdef COMPAT_IA32 - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { - if (td2->td_proc->p_sysent != &ia32_freebsd_sysvec) { + if (SV_CURPROC_FLAG(SV_ILP32)) { + if ((td2->td_proc->p_sysent->sv_flags & SV_ILP32) == 0) { PROC_UNLOCK(p); return (EINVAL); } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index ceae8de8e90..0ed7ce43d03 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -64,8 +65,6 @@ __FBSDID("$FreeBSD$"); #include #include -extern struct sysentvec ia32_freebsd_sysvec; - struct ptrace_io_desc32 { int piod_op; u_int32_t piod_offs; @@ -394,7 +393,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) #ifdef COMPAT_IA32 int wrap32 = 0; - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) + if (SV_CURPROC_FLAG(SV_ILP32)) wrap32 = 1; #endif AUDIT_ARG(pid, uap->pid); @@ -581,8 +580,8 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) * Test if we're a 32 bit client and what the target is. * Set the wrap controls accordingly. */ - if (td->td_proc->p_sysent == &ia32_freebsd_sysvec) { - if (td2->td_proc->p_sysent == &ia32_freebsd_sysvec) + if (SV_CURPROC_FLAG(SV_ILP32)) { + if (td2->td_proc->p_sysent->sv_flags & SV_ILP32) safe = 1; wrap32 = 1; }