Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Nov 2008 12:36:15 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185169 - in head/sys: amd64/amd64 amd64/linux32 arm/arm compat/ia32 compat/svr4 i386/i386 i386/ibcs2 i386/linux ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sys
Message-ID:  <200811221236.mAMCaFbb017749@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Nov 22 12:36:15 2008
New Revision: 185169
URL: http://svn.freebsd.org/changeset/base/185169

Log:
  Add sv_flags field to struct sysentvec with intention to provide description
  of the ABI of the currently executing image. Change some places to test
  the flags instead of explicit comparing with address of known sysentvec
  structures to determine ABI features.
  
  Discussed with:	dchagin, imp, jhb, peter

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/elf_machdep.c
  head/sys/compat/ia32/ia32_sysvec.c
  head/sys/compat/svr4/svr4_sysvec.c
  head/sys/i386/i386/elf_machdep.c
  head/sys/i386/ibcs2/ibcs2_sysvec.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/ia64/ia64/elf_machdep.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/kern_thr.c
  head/sys/kern/uipc_socket.c
  head/sys/mips/mips/elf_machdep.c
  head/sys/powerpc/powerpc/elf_machdep.c
  head/sys/sparc64/sparc64/elf_machdep.c
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- head/sys/amd64/amd64/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/amd64/amd64/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -72,7 +72,8 @@ struct sysentvec elf64_freebsd_sysvec = 
 	.sv_copyout_strings	= exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64
 };
 
 static Elf64_Brandinfo freebsd_brand_info = {

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/amd64/linux32/linux32_sysvec.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -1026,6 +1026,7 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_setregs	= exec_linux_setregs,
 	.sv_fixlimit	= linux32_fixlimit,
 	.sv_maxssiz	= &linux32_maxssiz,
+	.sv_flags	= SV_ABI_LINUX | SV_ILP32 | SV_IA32
 };
 
 static Elf32_Brandinfo linux_brand = {

Modified: head/sys/arm/arm/elf_machdep.c
==============================================================================
--- head/sys/arm/arm/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/arm/arm/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -72,7 +72,8 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: head/sys/compat/ia32/ia32_sysvec.c
==============================================================================
--- head/sys/compat/ia32/ia32_sysvec.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/compat/ia32/ia32_sysvec.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -135,7 +135,8 @@ struct sysentvec ia32_freebsd_sysvec = {
 	.sv_copyout_strings	= ia32_copyout_strings,
 	.sv_setregs	= ia32_setregs,
 	.sv_fixlimit	= ia32_fixlimit,
-	.sv_maxssiz	= &ia32_maxssiz
+	.sv_maxssiz	= &ia32_maxssiz,
+	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32
 };
 
 

Modified: head/sys/compat/svr4/svr4_sysvec.c
==============================================================================
--- head/sys/compat/svr4/svr4_sysvec.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/compat/svr4/svr4_sysvec.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -190,7 +190,8 @@ struct sysentvec svr4_sysvec = {
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz     = NULL
+	.sv_maxssiz     = NULL,
+	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32
 };
 
 const char      svr4_emul_path[] = "/compat/svr4";

Modified: head/sys/i386/i386/elf_machdep.c
==============================================================================
--- head/sys/i386/i386/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/i386/i386/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -72,7 +72,8 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_copyout_strings	= exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_IA32 | SV_ILP32
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: head/sys/i386/ibcs2/ibcs2_sysvec.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_sysvec.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/i386/ibcs2/ibcs2_sysvec.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -85,7 +85,8 @@ struct sysentvec ibcs2_svr3_sysvec = {
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_UNDEF | SV_IA32 | SV_ILP32
 };
 
 static int

Modified: head/sys/i386/linux/linux_sysvec.c
==============================================================================
--- head/sys/i386/linux/linux_sysvec.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/i386/linux/linux_sysvec.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -837,7 +837,8 @@ struct sysentvec linux_sysvec = {
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_linux_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_LINUX | SV_AOUT | SV_IA32 | SV_ILP32
 };
 
 struct sysentvec elf_linux_sysvec = {
@@ -867,7 +868,8 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_linux_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_LINUX | SV_IA32 | SV_ILP32
 };
 
 static Elf32_Brandinfo linux_brand = {

Modified: head/sys/ia64/ia64/elf_machdep.c
==============================================================================
--- head/sys/ia64/ia64/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/ia64/ia64/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -80,7 +80,8 @@ struct sysentvec elf64_freebsd_sysvec = 
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64
 };
 
 static Elf64_Brandinfo freebsd_brand_info = {

Modified: head/sys/kern/imgact_aout.c
==============================================================================
--- head/sys/kern/imgact_aout.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/kern/imgact_aout.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -82,7 +82,13 @@ struct sysentvec aout_sysvec = {
 	.sv_copyout_strings	= exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_AOUT |
+#if defined(__i386__)
+	SV_IA32 | SV_ILP32
+#else
+#error Choose SV_XXX flags for the platform
+#endif
 };
 
 static int

Modified: head/sys/kern/kern_thr.c
==============================================================================
--- head/sys/kern/kern_thr.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/kern/kern_thr.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -57,14 +57,12 @@ __FBSDID("$FreeBSD$");
 
 #ifdef COMPAT_IA32
 
-extern struct sysentvec ia32_freebsd_sysvec;
-
 static inline int
 suword_lwpid(void *addr, lwpid_t lwpid)
 {
 	int error;
 
-	if (curproc->p_sysent != &ia32_freebsd_sysvec)
+	if (SV_CURPROC_FLAG(SV_LP64))
 		error = suword(addr, lwpid);
 	else
 		error = suword32(addr, lwpid);

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/kern/uipc_socket.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -136,9 +136,8 @@ __FBSDID("$FreeBSD$");
 
 #ifdef COMPAT_IA32
 #include <sys/mount.h>
+#include <sys/sysent.h>
 #include <compat/freebsd32/freebsd32.h>
-
-extern struct sysentvec ia32_freebsd_sysvec;
 #endif
 
 static int	soreceive_rcvoob(struct socket *so, struct uio *uio,
@@ -2280,7 +2279,7 @@ sosetopt(struct socket *so, struct socko
 		case SO_SNDTIMEO:
 		case SO_RCVTIMEO:
 #ifdef COMPAT_IA32
-			if (curthread->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+			if (SV_CURPROC_FLAG(SV_ILP32)) {
 				struct timeval32 tv32;
 
 				error = sooptcopyin(sopt, &tv32, sizeof tv32,
@@ -2461,7 +2460,7 @@ integer:
 			tv.tv_sec = optval / hz;
 			tv.tv_usec = (optval % hz) * tick;
 #ifdef COMPAT_IA32
-			if (curthread->td_proc->p_sysent == &ia32_freebsd_sysvec) {
+			if (SV_CURPROC_FLAG(SV_ILP32)) {
 				struct timeval32 tv32;
 
 				CP(tv, tv32, tv_sec);

Modified: head/sys/mips/mips/elf_machdep.c
==============================================================================
--- head/sys/mips/mips/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/mips/mips/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -74,7 +74,8 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: head/sys/powerpc/powerpc/elf_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/powerpc/powerpc/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -75,7 +75,8 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32
 };
 
 static Elf32_Brandinfo freebsd_brand_info = {

Modified: head/sys/sparc64/sparc64/elf_machdep.c
==============================================================================
--- head/sys/sparc64/sparc64/elf_machdep.c	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/sparc64/sparc64/elf_machdep.c	Sat Nov 22 12:36:15 2008	(r185169)
@@ -87,7 +87,8 @@ static struct sysentvec elf64_freebsd_sy
 	.sv_copyout_strings = exec_copyout_strings,
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
-	.sv_maxssiz	= NULL
+	.sv_maxssiz	= NULL,
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64
 };
 
 static Elf64_Brandinfo freebsd_brand_info = {

Modified: head/sys/sys/sysent.h
==============================================================================
--- head/sys/sys/sysent.h	Sat Nov 22 12:34:49 2008	(r185168)
+++ head/sys/sys/sysent.h	Sat Nov 22 12:36:15 2008	(r185169)
@@ -100,8 +100,22 @@ struct sysentvec {
 	void		(*sv_setregs)(struct thread *, u_long, u_long, u_long);
 	void		(*sv_fixlimit)(struct rlimit *, int);
 	u_long		*sv_maxssiz;
+	u_int		sv_flags;
 };
 
+#define	SV_ILP32	0x000100
+#define	SV_LP64		0x000200
+#define	SV_IA32		0x004000
+#define	SV_AOUT		0x008000
+
+#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)
+/* same as ELFOSABI_XXX, to prevent header pollution */
+#define	SV_ABI_LINUX	3
+#define	SV_ABI_FREEBSD 	9
+#define	SV_ABI_UNDEF	255
+
 #ifdef _KERNEL
 extern struct sysentvec aout_sysvec;
 extern struct sysentvec elf_freebsd_sysvec;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811221236.mAMCaFbb017749>