summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2011-01-26 20:03:58 +0000
committerdchagin <dchagin@FreeBSD.org>2011-01-26 20:03:58 +0000
commit1e124ec538abd89755a07370b3e298c5d4e275bc (patch)
tree11e55f54986e1fd2a80fd707f1d646272a4b9266
parent0044f4e6eb992ee895bfd4d01fcd358a52ef2622 (diff)
downloadFreeBSD-src-1e124ec538abd89755a07370b3e298c5d4e275bc.zip
FreeBSD-src-1e124ec538abd89755a07370b3e298c5d4e275bc.tar.gz
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
-rw-r--r--sys/amd64/amd64/vm_machdep.c4
-rw-r--r--sys/amd64/linux32/linux32_machdep.c2
-rw-r--r--sys/compat/linprocfs/linprocfs.c2
-rw-r--r--sys/fs/procfs/procfs_dbregs.c2
-rw-r--r--sys/fs/procfs/procfs_fpregs.c2
-rw-r--r--sys/fs/procfs/procfs_map.c4
-rw-r--r--sys/fs/procfs/procfs_regs.c2
-rw-r--r--sys/i386/linux/linux_machdep.c4
-rw-r--r--sys/kern/kern_jail.c4
-rw-r--r--sys/kern/sys_process.c2
-rw-r--r--sys/powerpc/aim/trap.c6
-rw-r--r--sys/powerpc/powerpc/exec_machdep.c12
-rw-r--r--sys/sys/sysent.h6
13 files changed, 27 insertions, 25 deletions
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index 8e8d0c1..972484a 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -445,7 +445,7 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
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 *tls_base)
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);
}
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 8d4050e..c5bb16a 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -131,7 +131,7 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
* 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);
}
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 8626e66..2aae07d 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -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);
diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c
index 68945ef..de5dc76 100644
--- a/sys/fs/procfs/procfs_dbregs.c
+++ b/sys/fs/procfs/procfs_dbregs.c
@@ -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);
}
diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c
index 541efed..c89c8e7 100644
--- a/sys/fs/procfs/procfs_fpregs.c
+++ b/sys/fs/procfs/procfs_fpregs.c
@@ -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);
}
diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c
index 5b322eb..4396aca 100644
--- a/sys/fs/procfs/procfs_map.c
+++ b/sys/fs/procfs/procfs_map.c
@@ -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;
}
diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c
index 605d1c6..3f78478 100644
--- a/sys/fs/procfs/procfs_regs.c
+++ b/sys/fs/procfs/procfs_regs.c
@@ -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);
}
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index d26504f..6400875 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -146,8 +146,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
* 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);
}
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 093165b..335cd31 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -745,7 +745,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
}
#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 uio *optuio, int flags)
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));
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index ee374c6..a7f280a 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -727,7 +727,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
* 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;
}
diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c
index 930810f..60c0f3b 100644
--- a/sys/powerpc/aim/trap.c
+++ b/sys/powerpc/aim/trap.c
@@ -389,7 +389,7 @@ cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
* 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, struct syscall_args *sa)
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, struct syscall_args *sa)
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--)
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 9d38d70..651befd 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -156,7 +156,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
#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, sigset_t *mask)
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, sigset_t *mask)
* 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, int error)
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, void (*entry)(void *), void *arg,
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;
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index 55cac2b..d96a6ba 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -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
OpenPOWER on IntegriCloud