Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 May 2014 15:49:27 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r265325 - in user/dchagin/lemul/sys: amd64/linux amd64/linux32 compat/linux i386/linux
Message-ID:  <201405041549.s44FnRn0049087@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May  4 15:49:26 2014
New Revision: 265325
URL: http://svnweb.freebsd.org/changeset/base/265325

Log:
  We can have both 64 & 32 bit Linuxulator running,
  so any eventhandler can be called twice for us. To prevent this
  we will check that proc is handled by corresponding module.

Modified:
  user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c
  user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c
  user/dchagin/lemul/sys/compat/linux/linux_emul.c
  user/dchagin/lemul/sys/i386/linux/linux_sysvec.c

Modified: user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c	Sun May  4 15:47:58 2014	(r265324)
+++ user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c	Sun May  4 15:49:26 2014	(r265325)
@@ -961,9 +961,9 @@ linux64_elf_modevent(module_t mod, int t
 			LIST_INIT(&futex_list);
 			mtx_init(&futex_mtx, "ftllk64", NULL, MTX_DEF);
 			linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
-			    linux_proc_exit, NULL, 1000);
+			    linux_proc_exit, (void *) (long) elf_linux_sysvec.sv_flags, 1000);
 			linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
-			    linux_proc_exec, NULL, 1000);
+			    linux_proc_exec, (void *) (long)elf_linux_sysvec.sv_flags, 1000);
 			linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
 			    linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
 			linux_osd_jail_register();

Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c	Sun May  4 15:47:58 2014	(r265324)
+++ user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c	Sun May  4 15:49:26 2014	(r265325)
@@ -1171,9 +1171,9 @@ linux_elf_modevent(module_t mod, int typ
 			LIST_INIT(&futex_list);
 			mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
 			linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
-			    linux_proc_exit, NULL, 1000);
+			    linux_proc_exit, (void *) (long) elf_linux_sysvec.sv_flags, 1000);
 			linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
-			    linux_proc_exec, NULL, 1000);
+			    linux_proc_exec, (void *) (long)elf_linux_sysvec.sv_flags, 1000);
 			linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
 			    linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
 			linux_osd_jail_register();

Modified: user/dchagin/lemul/sys/compat/linux/linux_emul.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linux/linux_emul.c	Sun May  4 15:47:58 2014	(r265324)
+++ user/dchagin/lemul/sys/compat/linux/linux_emul.c	Sun May  4 15:49:26 2014	(r265325)
@@ -220,9 +220,10 @@ linux_common_execve(struct thread *td, s
 }
 
 void 
-linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
+linux_proc_exec(void *arg, struct proc *p, struct image_params *imgp)
 {
 	struct thread *td = curthread;
+	int sv_flags;
 
 	/*
 	 * In a case of execing to linux binary we create linux
@@ -230,6 +231,16 @@ linux_proc_exec(void *arg __unused, stru
 	 */
 	if (__predict_false((imgp->sysent->sv_flags & SV_ABI_MASK) ==
 	    SV_ABI_LINUX)) {
+
+		/*
+		 * We can have both 64 & 32 bit Linuxulator running,
+		 * so eventhandler is called twice for us. To prevent this
+		 * we will check that proc is handled by corresponding module.
+		 */
+		sv_flags = (int) arg;
+		if ((sv_flags & SV_IS_MASK) != SV_PROC_IS(p))
+			return;
+
 		LIN_SDT_PROBE2(emul, proc_exec, entry, p, imgp);
 		if (SV_PROC_ABI(p) == SV_ABI_LINUX)
 			linux_proc_init(td, NULL, 0);
@@ -363,13 +374,23 @@ linux_set_tid_address(struct thread *td,
 }
 
 void
-linux_proc_exit(void *arg __unused, struct proc *p)
+linux_proc_exit(void *arg, struct proc *p)
 {
 	struct linux_pemuldata *pem;
+	int sv_flags;
 
 	if (__predict_true(SV_PROC_ABI(p) != SV_ABI_LINUX))
 		return;
 
+	/*
+	 * We can have both 64 & 32 bit Linuxulator running,
+	 * so eventhandler is called twice for us. To prevent this
+	 * we will check that proc is handled by corresponding module.
+	 */
+	sv_flags = (int) arg;
+	if ((sv_flags & SV_IS_MASK) != SV_PROC_IS(p))
+		return;
+
 	pem = pem_find(p);
 	KASSERT(pem != NULL, ("proc_exit: proc emuldata not found.\n"));
 	p->p_emuldata = NULL;

Modified: user/dchagin/lemul/sys/i386/linux/linux_sysvec.c
==============================================================================
--- user/dchagin/lemul/sys/i386/linux/linux_sysvec.c	Sun May  4 15:47:58 2014	(r265324)
+++ user/dchagin/lemul/sys/i386/linux/linux_sysvec.c	Sun May  4 15:49:26 2014	(r265325)
@@ -1150,9 +1150,9 @@ linux_elf_modevent(module_t mod, int typ
 			LIST_INIT(&futex_list);
 			mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
 			linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
-			    linux_proc_exit, NULL, 1000);
+			    linux_proc_exit, (void *) elf_linux_sysvec.sv_flags, 1000);
 			linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
-			    linux_proc_exec, NULL, 1000);
+			    linux_proc_exec, (void *) elf_linux_sysvec.sv_flags, 1000);
 			linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
 			    linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
 			linux_get_machine(&linux_kplatform);



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