Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jul 2008 13:43:55 +0200
From:      Marcin Cieslak <saper@system.pl>
To:        freebsd-emulation@freebsd.org
Subject:   linux emulation: Preliminary support for more auxvec's
Message-ID:  <g57h1u$5od$1@ger.gmane.org>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigB9C2465D4B5F6674128C91F7
Content-Type: multipart/mixed; boundary="------------050802080807070906070205"

This is a multi-part message in MIME format.
--------------050802080807070906070205
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: quoted-printable

Hello,

Attached please find a simple diff to implement additional loader=20
information (for background please see:=20
http://lists.freebsd.org/pipermail/freebsd-emulation/2006-September/00259=
1.html)

This patch creates linux_get_machine() making linux_new_uname=20
platform-independent.

AT_PLATFORM is not yet implemented, since I need to allocate a string=20
for it on the user stack. I *could* use something on the SPARE_USRSPACE, =

but I think we got rid of all such tricks long time ago.

A bit better solution might be to change linux_copyout_strings to=20
allocate more space for the AT_PLATFORM (but how do I then pass the=20
pointer to the elf_linux_fixup?)

This would also mean to bring the linux_copyout_strings to i386.

What's the best way to do this?

--Marcin

--------------050802080807070906070205
Content-Type: text/x-diff;
 name="auxvec.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
 filename="auxvec.diff"

Index: compat/linux/linux_misc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.214.2.1
diff -u -r1.214.2.1 linux_misc.c
--- compat/linux/linux_misc.c	29 Feb 2008 14:58:08 -0000	1.214.2.1
+++ compat/linux/linux_misc.c	11 Jul 2008 09:59:10 -0000
@@ -732,34 +732,8 @@
 			*p =3D '\0';
 			break;
 		}
-#ifdef __i386__
-	{
-		const char *class;
-
-		switch (cpu_class) {
-		case CPUCLASS_686:
-			class =3D "i686";
-			break;
-		case CPUCLASS_586:
-			class =3D "i586";
-			break;
-		case CPUCLASS_486:
-			class =3D "i486";
-			break;
-		default:
-			class =3D "i386";
-		}
-		strlcpy(utsname.machine, class, LINUX_MAX_UTSNAME);
-	}
-#elif defined(__amd64__)	/* XXX: Linux can change 'personality'. */
-#ifdef COMPAT_LINUX32
-	strlcpy(utsname.machine, "i686", LINUX_MAX_UTSNAME);
-#else
-	strlcpy(utsname.machine, "x86_64", LINUX_MAX_UTSNAME);
-#endif /* COMPAT_LINUX32 */
-#else /* something other than i386 or amd64 - assume we and Linux agree =
*/
-	strlcpy(utsname.machine, machine, LINUX_MAX_UTSNAME);
-#endif /* __i386__ */
+
+	linux_get_machine(&utsname);
 	strlcpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME);
=20
 	return (copyout(&utsname, args->buf, sizeof(utsname)));
Index: i386/include/elf.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/i386/include/elf.h,v
retrieving revision 1.17
diff -u -r1.17 elf.h
--- i386/include/elf.h	4 Oct 2006 21:37:09 -0000	1.17
+++ i386/include/elf.h	11 Jul 2008 11:20:03 -0000
@@ -104,8 +104,12 @@
 #define	AT_EUID		12	/* Effective uid. */
 #define	AT_GID		13	/* Real gid. */
 #define	AT_EGID		14	/* Effective gid. */
+#define	AT_PLATFORM	15	/* CPU identification string. */
+#define	AT_HWCAP	16	/* CPU capabilities (arch dependent). */
+#define	AT_CLKTCK	17	/* Frequency at which times() increments */
+#define	AT_SECURE	23	/* Secure mode */
=20
-#define	AT_COUNT	15	/* Count of defined aux entry types. */
+#define	AT_COUNT	18	/* Count of defined aux entry types. */
=20
 /*
  * Relocation types.
Index: i386/linux/linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/i386/linux/linux.h,v
retrieving revision 1.78
diff -u -r1.78 linux.h
--- i386/linux/linux.h	18 Sep 2007 19:50:33 -0000	1.78
+++ i386/linux/linux.h	11 Jul 2008 09:52:51 -0000
@@ -309,6 +309,7 @@
=20
 int linux_to_bsd_sigaltstack(int lsa);
 int bsd_to_linux_sigaltstack(int bsa);
+void linux_get_machine(struct l_new_utsname *utsname);
=20
 typedef void	(*l_handler_t)(l_int);
 typedef l_ulong	l_osigset_t;
Index: i386/linux/linux_machdep.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/i386/linux/linux_machdep.c,v
retrieving revision 1.78.2.2
diff -u -r1.78.2.2 linux_machdep.c
--- i386/linux/linux_machdep.c	14 Feb 2008 18:37:39 -0000	1.78.2.2
+++ i386/linux/linux_machdep.c	11 Jul 2008 09:57:02 -0000
@@ -971,6 +971,27 @@
 	return (error);
 }
=20
+void
+linux_get_machine(struct l_new_utsname *utsname)
+{
+	const char *class;
+
+	switch (cpu_class) {
+	case CPUCLASS_686:
+		class =3D "i686";
+		break;
+	case CPUCLASS_586:
+		class =3D "i586";
+		break;
+	case CPUCLASS_486:
+		class =3D "i486";
+		break;
+	default:
+		class =3D "i386";
+	}
+	strlcpy(utsname->machine, class, LINUX_MAX_UTSNAME);
+}
+
 /*
  * Linux has two extra args, restart and oldmask.  We dont use these,
  * but it seems that "restart" is actually a context pointer that
Index: i386/linux/linux_sysvec.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/i386/linux/linux_sysvec.c,v
retrieving revision 1.150.2.1
diff -u -r1.150.2.1 linux_sysvec.c
--- i386/linux/linux_sysvec.c	27 Mar 2008 13:46:27 -0000	1.150.2.1
+++ i386/linux/linux_sysvec.c	11 Jul 2008 10:38:55 -0000
@@ -260,6 +260,9 @@
 	AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
 	AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
 	AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
+	AUXARGS_ENTRY(pos, AT_HWCAP, cpu_feature);
+	AUXARGS_ENTRY(pos, AT_CLKTCK, hz);
+	AUXARGS_ENTRY(pos, AT_SECURE, 0);
 	AUXARGS_ENTRY(pos, AT_NULL, 0);
=20
 	free(imgp->auxargs, M_TEMP);
Index: amd64/include/elf.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/amd64/include/elf.h,v
retrieving revision 1.19
diff -u -r1.19 elf.h
--- amd64/include/elf.h	4 Oct 2006 21:37:09 -0000	1.19
+++ amd64/include/elf.h	11 Jul 2008 08:53:56 -0000
@@ -101,8 +101,12 @@
 #define	AT_EUID		12	/* Effective uid. */
 #define	AT_GID		13	/* Real gid. */
 #define	AT_EGID		14	/* Effective gid. */
+#define	AT_PLATFORM	15	/* CPU identification string. */
+#define	AT_HWCAP	16	/* CPU capabilities (arch dependent). */
+#define	AT_CLKTCK	17	/* Frequency at which times() increments */
+#define	AT_SECURE	23	/* Secure mode */
=20
-#define	AT_COUNT	15	/* Count of defined aux entry types. */
+#define	AT_COUNT	18	/* Count of defined aux entry types. */
=20
 /*
  * Relocation types.
Index: amd64/linux32/linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/amd64/linux32/linux.h,v
retrieving revision 1.16
diff -u -r1.16 linux.h
--- amd64/linux32/linux.h	18 Sep 2007 19:50:32 -0000	1.16
+++ amd64/linux32/linux.h	11 Jul 2008 09:47:58 -0000
@@ -334,6 +334,7 @@
=20
 int linux_to_bsd_sigaltstack(int lsa);
 int bsd_to_linux_sigaltstack(int bsa);
+void linux_get_machine(struct l_new_utsname *utsname);
=20
 typedef l_uintptr_t l_handler_t;
 typedef l_ulong	l_osigset_t;
Index: amd64/linux32/linux32_machdep.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/amd64/linux32/linux32_machdep.c,v
retrieving revision 1.45.2.1
diff -u -r1.45.2.1 linux32_machdep.c
--- amd64/linux32/linux32_machdep.c	14 Feb 2008 18:37:38 -0000	1.45.2.1
+++ amd64/linux32/linux32_machdep.c	11 Jul 2008 09:51:41 -0000
@@ -103,6 +103,13 @@
 	return (lsa);
 }
=20
+void
+linux_get_machine(struct l_new_utsname *utsname)
+{
+	/* XXX Linux can change 'personality'. */
+	strlcpy(utsname->machine, "i686", LINUX_MAX_UTSNAME);
+}
+
 /*
  * Custom version of exec_copyin_args() so that we can translate
  * the pointers.
Index: amd64/linux32/linux32_sysvec.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/home/ncvs/src/sys/amd64/linux32/linux32_sysvec.c,v
retrieving revision 1.31.2.1
diff -u -r1.31.2.1 linux32_sysvec.c
--- amd64/linux32/linux32_sysvec.c	27 Mar 2008 13:46:26 -0000	1.31.2.1
+++ amd64/linux32/linux32_sysvec.c	11 Jul 2008 09:12:56 -0000
@@ -269,6 +269,9 @@
 	AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
 	AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
 	AUXARGS_ENTRY_32(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
+	AUXARGS_ENTRY_32(pos, AT_HWCAP, cpu_feature);
+	AUXARGS_ENTRY_32(pos, AT_CLKTCK, hz);
+	AUXARGS_ENTRY_32(pos, AT_SECURE, 0);
 	AUXARGS_ENTRY_32(pos, AT_NULL, 0);
=20
 	free(imgp->auxargs, M_TEMP);

--------------050802080807070906070205--

--------------enigB9C2465D4B5F6674128C91F7
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQCVAwUBSHdHfj2W2v2wY27ZAQP8/QP/YQgMk155gipKki2BsVqqa1OmIvcE2ra4
0FdRg43tWVxm2VDgrJF1nXu6QcfGOO5jZtABjFYqn11aGbii2TPp77d84B3n8+gf
XYLfJgG7mqd4+gFWsFZQuPWrT7jRyIKY5mwd70ZRW4P6YB5ooTEDddPzwnxLgTpA
sRBiTNxLoxA=
=9I1v
-----END PGP SIGNATURE-----

--------------enigB9C2465D4B5F6674128C91F7--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?g57h1u$5od$1>