public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* Fwd: arch/ && tracehook_report_syscall_xxx()
       [not found]   ` <20090427183218.GA31596@lst.de>
@ 2009-04-29 19:08     ` Oleg Nesterov
  2009-04-29 19:08       ` Oleg Nesterov
                         ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Oleg Nesterov @ 2009-04-29 19:08 UTC (permalink / raw)
  To: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson@
  Cc: Roland McGrath, linux-kernel, linux-arch

On 04/27, Christoph Hellwig wrote:
>
> I've poked a few arch maintainers in the past to separate the enter/exit
> path and usually got the desired changes :)

I'd like to try your method!

So. Dear maintainers of

	alpha
	arm
	avr32
	blackfin
	cris
	h8300
	m32r
	m68k
	m68knommu
	mips
	parisc
	um
	xtensa

. Could you please convert your syscall trace code to use
tracehook_report_syscall_entry/tracehook_report_syscall_exit ?


For example, let's look at more or less typical arch/alpha/kernel/ptrace.c,

	asmlinkage void
	syscall_trace(void)
	{
		if (!test_thread_flag(TIF_SYSCALL_TRACE))
			return;
		if (!(current->ptrace & PT_PTRACED))
			return;
		/* The 0x80 provides a way for the tracing parent to distinguish
		   between a syscall stop and SIGTRAP delivery */
		ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
					 ? 0x80 : 0));

		/*
		 * This isn't the same as continuing with a signal, but it will do
		 * for normal use.  strace only continues with a signal if the
		 * stopping signal is not SIGTRAP.  -brl
		 */
		if (current->exit_code) {
			send_sig(current->exit_code, current, 1);
			current->exit_code = 0;
		}
	}

it would be really nice to turn it into something like

	asmlinkage void
	syscall_trace(int entryexit)
	{
		if (!test_thread_flag(TIF_SYSCALL_TRACE))
			return;

		if (entryexit)
			tracehook_report_syscall_entry(task_pt_regs(current));
		else
			tracehook_report_syscall_exit(task_pt_regs(current), stepping);
	}

Also, tracehook_report_syscall_entry() might want to abort this system
call (please see the comment above this helper), it would be great to
take the returned value into account.


arch/* play with ptrace internals which should be changed soon, not good.

Thanks!

Oleg.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Fwd: arch/ && tracehook_report_syscall_xxx()
  2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
@ 2009-04-29 19:08       ` Oleg Nesterov
  2009-04-29 19:17       ` Roland McGrath
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Oleg Nesterov @ 2009-04-29 19:08 UTC (permalink / raw)
  To: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson, kyle, linux, ralf, rth,
	starvik, takata, ysato, zippel
  Cc: Roland McGrath, linux-kernel, linux-arch

On 04/27, Christoph Hellwig wrote:
>
> I've poked a few arch maintainers in the past to separate the enter/exit
> path and usually got the desired changes :)

I'd like to try your method!

So. Dear maintainers of

	alpha
	arm
	avr32
	blackfin
	cris
	h8300
	m32r
	m68k
	m68knommu
	mips
	parisc
	um
	xtensa

. Could you please convert your syscall trace code to use
tracehook_report_syscall_entry/tracehook_report_syscall_exit ?


For example, let's look at more or less typical arch/alpha/kernel/ptrace.c,

	asmlinkage void
	syscall_trace(void)
	{
		if (!test_thread_flag(TIF_SYSCALL_TRACE))
			return;
		if (!(current->ptrace & PT_PTRACED))
			return;
		/* The 0x80 provides a way for the tracing parent to distinguish
		   between a syscall stop and SIGTRAP delivery */
		ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
					 ? 0x80 : 0));

		/*
		 * This isn't the same as continuing with a signal, but it will do
		 * for normal use.  strace only continues with a signal if the
		 * stopping signal is not SIGTRAP.  -brl
		 */
		if (current->exit_code) {
			send_sig(current->exit_code, current, 1);
			current->exit_code = 0;
		}
	}

it would be really nice to turn it into something like

	asmlinkage void
	syscall_trace(int entryexit)
	{
		if (!test_thread_flag(TIF_SYSCALL_TRACE))
			return;

		if (entryexit)
			tracehook_report_syscall_entry(task_pt_regs(current));
		else
			tracehook_report_syscall_exit(task_pt_regs(current), stepping);
	}

Also, tracehook_report_syscall_entry() might want to abort this system
call (please see the comment above this helper), it would be great to
take the returned value into account.


arch/* play with ptrace internals which should be changed soon, not good.

Thanks!

Oleg.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: arch/ && tracehook_report_syscall_xxx()
  2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
  2009-04-29 19:08       ` Oleg Nesterov
@ 2009-04-29 19:17       ` Roland McGrath
  2009-04-29 19:30       ` Ingo Molnar
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Roland McGrath @ 2009-04-29 19:17 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson, kyle, linux, ralf, rth,
	starvik, takata, ysato, zippel, linux-kernel, linux-arch

Christoph has already poked everyone, I believe.

> it would be really nice to turn it into something like
> 
> 	asmlinkage void
> 	syscall_trace(int entryexit)

We recommend replacing this with separate entry/exit paths from the
assembly code, if you are changing arch code anyway.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: arch/ && tracehook_report_syscall_xxx()
  2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
  2009-04-29 19:08       ` Oleg Nesterov
  2009-04-29 19:17       ` Roland McGrath
@ 2009-04-29 19:30       ` Ingo Molnar
  2009-04-29 19:44       ` Christoph Hellwig
  2009-04-29 19:53       ` Kyle McMartin
  4 siblings, 0 replies; 6+ messages in thread
From: Ingo Molnar @ 2009-04-29 19:30 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson, kyle, linux, ralf, rth,
	starvik, takata, ysato, zippel, Roland McGrath, linux-kernel,
	linux-arch


* Oleg Nesterov <oleg@redhat.com> wrote:

> On 04/27, Christoph Hellwig wrote:
> >
> > I've poked a few arch maintainers in the past to separate the enter/exit
> > path and usually got the desired changes :)
> 
> I'd like to try your method!
> 
> So. Dear maintainers of
> 
> 	alpha
> 	arm
> 	avr32
> 	blackfin
> 	cris
> 	h8300
> 	m32r
> 	m68k
> 	m68knommu
> 	mips
> 	parisc
> 	um
> 	xtensa
> 
> . Could you please convert your syscall trace code to use
> tracehook_report_syscall_entry/tracehook_report_syscall_exit ?
> 
> 
> For example, let's look at more or less typical arch/alpha/kernel/ptrace.c,
> 
> 	asmlinkage void
> 	syscall_trace(void)
> 	{
> 		if (!test_thread_flag(TIF_SYSCALL_TRACE))
> 			return;
> 		if (!(current->ptrace & PT_PTRACED))
> 			return;
> 		/* The 0x80 provides a way for the tracing parent to distinguish
> 		   between a syscall stop and SIGTRAP delivery */
> 		ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
> 					 ? 0x80 : 0));
> 
> 		/*
> 		 * This isn't the same as continuing with a signal, but it will do
> 		 * for normal use.  strace only continues with a signal if the
> 		 * stopping signal is not SIGTRAP.  -brl
> 		 */
> 		if (current->exit_code) {
> 			send_sig(current->exit_code, current, 1);
> 			current->exit_code = 0;
> 		}
> 	}
> 
> it would be really nice to turn it into something like
> 
> 	asmlinkage void
> 	syscall_trace(int entryexit)
> 	{
> 		if (!test_thread_flag(TIF_SYSCALL_TRACE))
> 			return;
> 
> 		if (entryexit)
> 			tracehook_report_syscall_entry(task_pt_regs(current));
> 		else
> 			tracehook_report_syscall_exit(task_pt_regs(current), stepping);
> 	}
> 
> Also, tracehook_report_syscall_entry() might want to abort this system
> call (please see the comment above this helper), it would be great to
> take the returned value into account.
> 
> arch/* play with ptrace internals which should be changed soon, not good.

And there's upstream examples in:

 arch/ia64/kernel/ptrace.c
 arch/powerpc/kernel/ptrace.c
 arch/s390/kernel/ptrace.c
 arch/sh/kernel/ptrace_32.c
 arch/sh/kernel/ptrace_64.c
 arch/sparc/kernel/ptrace_32.c
 arch/sparc/kernel/ptrace_64.c
 arch/x86/kernel/ptrace.c

as well, for tracehook usage. Chances are that your architecture's 
syscall entry/exit ptrace hooks look quite similar to one of the 
architectures above!

	Ingo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: arch/ && tracehook_report_syscall_xxx()
  2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
                         ` (2 preceding siblings ...)
  2009-04-29 19:30       ` Ingo Molnar
@ 2009-04-29 19:44       ` Christoph Hellwig
  2009-04-29 19:53       ` Kyle McMartin
  4 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2009-04-29 19:44 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson, kyle, linux, ralf, rth,
	starvik, takata, ysato, zippel, Roland McGrath, linux-kernel,
	linux-arch

On Wed, Apr 29, 2009 at 09:08:52PM +0200, Oleg Nesterov wrote:
> . Could you please convert your syscall trace code to use
> tracehook_report_syscall_entry/tracehook_report_syscall_exit ?

This is part of Roland's step by step cookbook for new-style ptrace,
so we should have most done.  Is there anything that makes this more
urgent than the others steps for you?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fwd: arch/ && tracehook_report_syscall_xxx()
  2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
                         ` (3 preceding siblings ...)
  2009-04-29 19:44       ` Christoph Hellwig
@ 2009-04-29 19:53       ` Kyle McMartin
  4 siblings, 0 replies; 6+ messages in thread
From: Kyle McMartin @ 2009-04-29 19:53 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Christoph Hellwig, chris, cooloney, deller, geert, gerg,
	hskinnemoen, jdike, jesper.nilsson, kyle, linux, ralf, rth,
	starvik, takata, ysato, zippel, Roland McGrath, linux-kernel,
	linux-arch

On Wed, Apr 29, 2009 at 09:08:52PM +0200, Oleg Nesterov wrote:
> So. Dear maintainers of
> 
> 	parisc
> 
> . Could you please convert your syscall trace code to use
> tracehook_report_syscall_entry/tracehook_report_syscall_exit ?
> 

I've got this mostly completed and working on parisc (at least, gdb
and strace continue working, so I'm happy with that result... :)

I'll probably push it for .30 since it seems harmless.

--Kyle

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-29 19:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20090427180455.GA32509@redhat.com>
     [not found] ` <20090427182919.B923DFC3BF@magilla.sf.frob.com>
     [not found]   ` <20090427183218.GA31596@lst.de>
2009-04-29 19:08     ` Fwd: arch/ && tracehook_report_syscall_xxx() Oleg Nesterov
2009-04-29 19:08       ` Oleg Nesterov
2009-04-29 19:17       ` Roland McGrath
2009-04-29 19:30       ` Ingo Molnar
2009-04-29 19:44       ` Christoph Hellwig
2009-04-29 19:53       ` Kyle McMartin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox