svn commit: r205517 - in projects/ppc64/sys: kern powerpc/powerpc sys

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Mar 23 15:14:46 UTC 2010


Author: nwhitehorn
Date: Tue Mar 23 15:14:45 2010
New Revision: 205517
URL: http://svn.freebsd.org/changeset/base/205517

Log:
  Use an alternative solution to the nargvstr width issue. Use suword32 to
  copy it to userspace, and use the stack arguments instead of ps_strings
  in exec_setregs() like all other platforms. This avoids changing the size
  of struct ps_strings, and so should create a minimum of breakage after
  merge.

Modified:
  projects/ppc64/sys/kern/kern_exec.c
  projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
  projects/ppc64/sys/sys/exec.h

Modified: projects/ppc64/sys/kern/kern_exec.c
==============================================================================
--- projects/ppc64/sys/kern/kern_exec.c	Tue Mar 23 14:31:31 2010	(r205516)
+++ projects/ppc64/sys/kern/kern_exec.c	Tue Mar 23 15:14:45 2010	(r205517)
@@ -1260,7 +1260,7 @@ exec_copyout_strings(imgp)
 	 * Fill in "ps_strings" struct for ps, w, etc.
 	 */
 	suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp);
-	suword(&arginfo->ps_nargvstr, argc);
+	suword32(&arginfo->ps_nargvstr, argc);
 
 	/*
 	 * Fill in argument portion of vector table.
@@ -1276,7 +1276,7 @@ exec_copyout_strings(imgp)
 	suword(vectp++, 0);
 
 	suword(&arginfo->ps_envstr, (long)(intptr_t)vectp);
-	suword(&arginfo->ps_nenvstr, envc);
+	suword32(&arginfo->ps_nenvstr, envc);
 
 	/*
 	 * Fill in environment portion of vector table.

Modified: projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/exec_machdep.c	Tue Mar 23 14:31:31 2010	(r205516)
+++ projects/ppc64/sys/powerpc/powerpc/exec_machdep.c	Tue Mar 23 15:14:45 2010	(r205517)
@@ -492,7 +492,7 @@ void
 exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
 {
 	struct trapframe	*tf;
-	struct ps_strings	arginfo;
+	register_t		argc;
 	#ifdef __powerpc64__
 	register_t		entry_desc[3];
 	#endif
@@ -506,12 +506,6 @@ exec_setregs(struct thread *td, struct i
 	#endif
 
 	/*
-	 * XXX Machine-independent code has already copied arguments and
-	 * XXX environment to userland.  Get them back here.
-	 */
-	(void)copyin((char *)PS_STRINGS, &arginfo, sizeof(arginfo));
-
-	/*
 	 * Set up arguments for _start():
 	 *	_start(argc, argv, envp, obj, cleanup, ps_strings);
 	 *
@@ -525,20 +519,24 @@ exec_setregs(struct thread *td, struct i
 	 * XXX We have to set both regs and retval here due to different
 	 * XXX calling convention in trap.c and init_main.c.
 	 */
+
+	/* Collect argc from the user stack */
+	argc = fuword((void *)stack);
+
         /*
          * XXX PG: these get overwritten in the syscall return code.
          * execve() should return EJUSTRETURN, like it does on NetBSD.
          * Emulate by setting the syscall return value cells. The
          * registers still have to be set for init's fork trampoline.
          */
-        td->td_retval[0] = arginfo.ps_nargvstr;
-        td->td_retval[1] = (register_t)arginfo.ps_argvstr;
-	tf->fixreg[3] = arginfo.ps_nargvstr;
-	tf->fixreg[4] = (register_t)arginfo.ps_argvstr;
-	tf->fixreg[5] = (register_t)arginfo.ps_envstr;
-	tf->fixreg[6] = 0;			/* auxillary vector */
-	tf->fixreg[7] = 0;			/* termination vector */
-	tf->fixreg[8] = (register_t)PS_STRINGS;	/* NetBSD extension */
+        td->td_retval[0] = argc;
+        td->td_retval[1] = stack + sizeof(register_t);
+	tf->fixreg[3] = argc;
+	tf->fixreg[4] = stack + sizeof(register_t);
+	tf->fixreg[5] = stack + (2 + argc)*sizeof(register_t);
+	tf->fixreg[6] = 0;				/* auxillary vector */
+	tf->fixreg[7] = 0;				/* termination vector */
+	tf->fixreg[8] = (register_t)imgp->ps_strings;	/* NetBSD extension */
 
 	#ifdef __powerpc64__
 	/*

Modified: projects/ppc64/sys/sys/exec.h
==============================================================================
--- projects/ppc64/sys/sys/exec.h	Tue Mar 23 14:31:31 2010	(r205516)
+++ projects/ppc64/sys/sys/exec.h	Tue Mar 23 15:14:45 2010	(r205517)
@@ -48,9 +48,9 @@
  */
 struct ps_strings {
 	char	**ps_argvstr;	/* first of 0 or more argument strings */
-	unsigned long ps_nargvstr; /* the number of argument strings */
+	unsigned int ps_nargvstr; /* the number of argument strings */
 	char	**ps_envstr;	/* first of 0 or more environment strings */
-	unsigned long ps_nenvstr; /* the number of environment strings */
+	unsigned int ps_nenvstr; /* the number of environment strings */
 };
 
 /*


More information about the svn-src-projects mailing list