Re: [PATCH 00/23] tracehook

David Miller
2008-07-18T09:20:44Z

From: Roland McGrath <roland@redhat.com>
Date: Thu, 17 Jul 2008 00:25:41 -0700 (PDT)

> I have done some arch work and will submit this to the arch maintainers
> after the generic tracehook series settles in. For now, that work is
> available in my GIT repositories, and in patch and mbox-of-patches form
> at http://people.redhat.com/roland/utrace/2.6-current/

Thanks for doing this work.

I took a quick look at the sparc64 tracehook support and only spotted
one issue.

You'll need special handling for 32-bit compat tasks when copying the
arguments in. You can't just use the full 64-bit values because they
get 32-bit zero extended by the 32-bit syscall entry code, and this
doesn't propagate into the pt_regs copies.

See arch/sparc64/kernel/syscalls.S:linux_sparc_syscall32

So at a minimum, when _TIF_32BIT is set, you'll need to "u32" cast
the regs->u_regs[] values before assigning them into the unsigned long
array slots.

Actually, it's more complicated than that. We have to sign extend
arguments in some cases, and this is performed by a class of stubs
in arch/sparc64/kernel/sys32.S which then revector to the real
system call handler.

I don't know how you want to handle those cases. Should the tracehook
user know that it's a 32-bit task, what system call it is, and therefore
do the appropriate sign extensions? That doesn't sound right.

So likely we have to properly sign extend those things here in the
asm/syscall.h handlers.

If you look at arch/sparc64/kernel/sys32.S it uses macros and then a
list of cases that could be slightly modified such that they could be
used to build argument sign extension tables. Simply change the
explicit register name arguments to pure numbers (ie. %o0 becomes
plain 0) and adjust the assembler macros accordingly.

Then, in a C file somewhere, you set these macro defines differently
then feed the list of instantiations through them and build the table.

The other arch's with compat support will have this same exact issue.