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.
This commit is contained in:
Konstantin Belousov 2009-03-02 18:43:50 +00:00
parent e2c10e7d4a
commit 2883703e00
5 changed files with 16 additions and 22 deletions

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sf_buf.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
#include <sys/vmmeter.h>
@ -80,12 +81,6 @@ __FBSDID("$FreeBSD$");
#include <amd64/isa/isa.h>
#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;

View File

@ -51,6 +51,7 @@
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/sysent.h>
#include <sys/uio.h>
#include <machine/reg.h>
@ -63,7 +64,6 @@
#include <machine/fpu.h>
#include <compat/ia32/ia32_reg.h>
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);
}

View File

@ -45,6 +45,7 @@
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/sysent.h>
#include <sys/uio.h>
#include <machine/reg.h>
@ -57,7 +58,6 @@
#include <machine/fpu.h>
#include <compat/ia32/ia32_reg.h>
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);
}

View File

@ -45,6 +45,7 @@
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/sysent.h>
#include <sys/uio.h>
#include <machine/reg.h>
@ -57,7 +58,6 @@
#include <machine/fpu.h>
#include <compat/ia32/ia32_reg.h>
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);
}

View File

@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/proc.h>
#include <sys/vnode.h>
@ -64,8 +65,6 @@ __FBSDID("$FreeBSD$");
#include <machine/fpu.h>
#include <compat/ia32/ia32_reg.h>
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;
}