Subject: Re: syscall() system call stub
To: David Laight <david@l8s.co.uk>
From: Andrew Doran <ad@netbsd.org>
List: port-amd64
Date: 11/04/2007 16:32:17
On Sun, Nov 04, 2007 at 10:31:19AM +0000, David Laight wrote:

> Yes I've had that thought as well.
> I think 2 generic functions will suffice.
> 
> Adding a SYSCALL_NOTRACE [1] flag, and saving the 'code' from the syscall
> entry trace for the exit one would solve the trace issue.
> 
> I think the code would be something like:
> 
> sys_syscall(lwp *l, register_t *args, register_t *rval)
> {
> 	p = l->l_proc;
> 	code = args[0];
> 	callp = p->p_emul->e_sysent + code;
> 	if (p->p_trace_enabled)
> 		trace_enter(l, code, code, args + 1, callp->sy_argsize);
> 	return callp->sy_call(l, args + 1, rval);
> }
> 
> Modulo some error checking and the argument types etc.

I think the beauty of it is we don't really need to have any special
handling for tracing + syscall() in the fast path. Again, I'm going to
ignore systrace for a moment but we have some options:

We could have trace_enter() be smart enought to fix up the arguments and
realise that it is syscall() then DTRT.

Or my favourite: do nothing. The only thing that is really interested in the
data is ktrace. The data is still recorded and displayed for the user, minus
decoding it would be a bit more cryptic but given the infrequency of
syscall() that might not be so bad.

Or, based on the last one, enhance the decoding in the user binaries and
have them pull the correct syscall info out.

Thanks,
Andrew