Subject: Re: port-sparc64/23473: kdump dumps core on sparc64/compat_svr4
To: David Laight <david@l8s.co.uk>
From: Andrey Petrov <petrov@netbsd.org>
List: netbsd-bugs
Date: 11/22/2003 16:51:26
On Sat, Nov 22, 2003 at 07:55:09PM +0000, David Laight wrote:
> kdump has been fixed so that it wong get so confused when the traced
> arguments are incorrect.
> 
> However is still won't work for 32bit binaries on 64bit kernels.
> The syscall entry code carefully converts the args from int64[] to
> int32[] but the tracing code uses a count based on nargs * sizeof (int32)
> so the wrong amount of information is traced.
> 
> I'd actually suggest removing the code that converts the argument list
> and changing kdump to handle 32bit argument arrays from 32bit processes
> on 64bit kernels.  kdump already keeps track of the emulation for each pid.
> 

If my reading is correct it is indeed excessive conversion and ktrsyscall
uses an actual argument length from sysent table. I can't verify that
momentarily (need to set up quite a bit to do that). 

In case someone willing to do that here is a patch.

Thanks David,

	Andrey

Index: trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/trap.c,v
retrieving revision 1.101
diff -u -p -r1.101 trap.c
--- trap.c      9 Nov 2003 16:41:53 -0000       1.101
+++ trap.c      23 Nov 2003 00:48:14 -0000
@@ -2107,19 +2103,8 @@ syscall(tf, code, pc)
                        *argp++ = *ap++;
 
 #ifdef KTRACE
-               if (KTRPOINT(p, KTR_SYSCALL)) {
-#if defined(__arch64__)
-                       register_t temp[8];
-                       
-                       /* Need to xlate 32-bit->64-bit */
-                       i = callp->sy_narg;
-                       for (j = 0; j < i; j++) 
-                               temp[j] = args.i[j];
-                       ktrsyscall(p, code, code, NULL, (register_t *)temp);
-#else
-                       ktrsyscall(p, code, code, NULL, (register_t *)&args.i);
-#endif
-               }
+               if (KTRPOINT(p, KTR_SYSCALL))
+                       ktrsyscall(p, code, code, NULL, (register_t *)&args);
 #endif /* KTRACE */
                if (error) {
                        goto bad;