public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
To: prasanna@in.ibm.com
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org, ak@muc.de,
	akpm@osdl.org, suparna@in.ibm.com
Subject: Re: [1/3] kprobes-func-args-268-rc3.patch
Date: Thu, 05 Aug 2004 13:09:46 +0200	[thread overview]
Message-ID: <m3acx9yh6t.fsf@averell.firstfloor.org> (raw)
In-Reply-To: <2pMJz-13N-9@gated-at.bofh.it> (Prasanna S. Panchamukhi's message of "Thu, 05 Aug 2004 11:30:09 +0200")

Prasanna S Panchamukhi <prasanna@in.ibm.com> writes:
> traps again to restore processor state and switch back to the
> probed function. Linus noted correctly at KS that we need to be 
> careful as gcc assumes that the callee owns arguments. For the
> time being we try to avoid tailcalls in the probe function; in 
> the long run we should probably also save and restore enough 
> stack bytes to cover argument space.
>
> Sample Usage:
> 	static int jip_queue_xmit(struct sk_buff *skb, int ipfragok)
> 	{
> 		... whatever ...
> 		jprobe_return();
> 		/*No tailcalls please */
> 		return 0;
> 	}

I think you misunderstood Linus' suggestion.  The problem with
modifying arguments on the stack frame is always there because the C
ABI allows it. One suggested solution was to use a second function
call that passes the arguments again to get a private copy. But the
compiler's tail call optimization could sabotate that when you a
are not careful.

That's all quite hackish and compiler dependent. I would suggest an 
assembly wrapper that copies the arguments when !CONFIG_REGPARM.
Just assume the function doesn't have more than a fixed number
of arguments, that should be good enough.

This way you avoid any subtle compiler dependencies.
With CONFIG_REGPARM it's enough to just save/restore pt_regs,
which kprobes will do anyways.
>  
>  static struct kprobe *current_kprobe;
>  static unsigned long kprobe_status, kprobe_old_eflags, kprobe_saved_eflags;
> +static struct pt_regs kprobe_saved_regs;
> +static long *kprobe_saved_esp;
> +extern void show_registers(struct pt_regs *regs);

Shouldn't that be in some header? 

  
> +
> +int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
> +{
> +	u8 *addr = (u8 *)(regs->eip-1);
> +
> +	if ((addr > (u8 *)jprobe_return) && (addr < (u8 *)jprobe_return_end)) {

It would be probably safer to use RELOC_HIDE on the function pointer here,
just to be safe against future gcc optimizations

The rest looks ok.

-Andi


       reply	other threads:[~2004-08-05 11:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2pMJz-13N-9@gated-at.bofh.it>
2004-08-05 11:09 ` Andi Kleen [this message]
2004-08-05 12:24   ` [1/3] kprobes-func-args-268-rc3.patch Suparna Bhattacharya
2004-08-05 12:54     ` Andi Kleen
2004-08-05 13:33       ` Suparna Bhattacharya
2004-08-05 13:51         ` Andi Kleen
2004-08-05 15:05           ` Suparna Bhattacharya
2004-08-05  9:24 Prasanna S Panchamukhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3acx9yh6t.fsf@averell.firstfloor.org \
    --to=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prasanna@in.ibm.com \
    --cc=suparna@in.ibm.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox