From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <anton@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/7] uprobes: Introduce uprobe_copy_insn()
Date: Sat, 6 Oct 2012 15:15:28 +0530 [thread overview]
Message-ID: <20121006094528.GC9145@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120930194217.GA11340@redhat.com>
* Oleg Nesterov <oleg@redhat.com> [2012-09-30 21:42:17]:
> Preparation. Extract the copy_insn/arch_uprobe_analyze_insn code
> from install_breakpoint() into the new helper, uprobe_copy_insn().
>
> And move uprobe->flags defines from uprobes.h to uprobes.c, nobody
> else can use them anyway.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> include/linux/uprobes.h | 10 --------
> kernel/events/uprobes.c | 60 ++++++++++++++++++++++++++++++++---------------
> 2 files changed, 41 insertions(+), 29 deletions(-)
>
> diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
> index 18d839d..2459457 100644
> --- a/include/linux/uprobes.h
> +++ b/include/linux/uprobes.h
> @@ -35,16 +35,6 @@ struct inode;
> # include <asm/uprobes.h>
> #endif
>
> -/* flags that denote/change uprobes behaviour */
> -
> -/* Have a copy of original instruction */
> -#define UPROBE_COPY_INSN 0x1
> -
> -/* Dont run handlers when first register/ last unregister in progress*/
> -#define UPROBE_RUN_HANDLER 0x2
> -/* Can skip singlestep */
> -#define UPROBE_SKIP_SSTEP 0x4
> -
> struct uprobe_consumer {
> int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs);
> /*
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index a81080f..5c0c1b0 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -78,6 +78,13 @@ static struct mutex uprobes_mmap_mutex[UPROBES_HASH_SZ];
> */
> static atomic_t uprobe_events = ATOMIC_INIT(0);
>
> +/* Have a copy of original instruction */
> +#define UPROBE_COPY_INSN 0x1
> +/* Dont run handlers when first register/ last unregister in progress*/
> +#define UPROBE_RUN_HANDLER 0x2
> +/* Can skip singlestep */
> +#define UPROBE_SKIP_SSTEP 0x4
> +
> struct uprobe {
> struct rb_node rb_node; /* node in the rb tree */
> atomic_t ref;
> @@ -563,6 +570,37 @@ static int copy_insn(struct uprobe *uprobe, struct file *filp)
> return __copy_insn(mapping, filp, uprobe->arch.insn, bytes, uprobe->offset);
> }
>
> +static int uprobe_copy_insn(struct uprobe *uprobe, struct file *file,
> + struct mm_struct *mm, unsigned long vaddr)
> +{
> + int ret = 0;
> +
> + if (uprobe->flags & UPROBE_COPY_INSN)
> + return ret;
> +
> + ret = copy_insn(uprobe, file);
> + if (ret)
> + goto out;
> +
> + ret = -ENOTSUPP;
> + if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn))
> + goto out;
> +
> + ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr);
> + if (ret)
> + goto out;
> +
> + /* write_opcode() assumes we don't cross page boundary */
> + BUG_ON((uprobe->offset & ~PAGE_MASK) +
> + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
> +
> + smp_wmb(); /* pairs with rmb() in find_active_uprobe() */
> + uprobe->flags |= UPROBE_COPY_INSN;
> + ret = 0;
> + out:
> + return ret;
> +}
> +
2 nits:
why do we need to reset ret before out label? I think its redudant.
arch_uprobe_analyze_insn() should have set it to 0 already. No?
blank line above out:
Currently only extern functions start with uprobe_ but we already have
copy_insn, and __copy_insn, So can think of any names for
uprobe_copy_insn. Not sure test_and_copy_insn() is a good alternative.
--
thanks and regards
Srikar
next prev parent reply other threads:[~2012-10-06 9:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-30 19:41 [PATCH 0/7] uprobes: register/unregister bugfixes Oleg Nesterov
2012-09-30 19:41 ` [PATCH 1/7] uprobes/x86: Only rep+nop can be emulated correctly Oleg Nesterov
2012-10-06 7:20 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 2/7] uprobes: Don't return success if alloc_uprobe() fails Oleg Nesterov
2012-10-06 7:25 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 3/7] uprobes: Do not delete uprobe if uprobe_unregister() fails Oleg Nesterov
2012-10-06 8:48 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 4/7] uprobes: Fix handle_swbp() vs unregister() + register() race Oleg Nesterov
2012-10-02 18:42 ` Oleg Nesterov
2012-10-06 9:33 ` Srikar Dronamraju
2012-10-06 17:25 ` Oleg Nesterov
2012-10-06 17:37 ` Srikar Dronamraju
2012-10-06 18:53 ` Oleg Nesterov
2012-10-07 7:12 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 5/7] uprobes: Introduce uprobe_copy_insn() Oleg Nesterov
2012-10-06 9:45 ` Srikar Dronamraju [this message]
2012-10-06 17:10 ` Oleg Nesterov
2012-10-06 17:38 ` Srikar Dronamraju
2012-10-06 18:59 ` Oleg Nesterov
2012-10-07 7:14 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 6/7] uprobes: Fix uprobe_copy_insn() race with itself Oleg Nesterov
2012-10-06 9:52 ` Srikar Dronamraju
2012-09-30 19:42 ` [PATCH 7/7] uprobes: Fix the racy uprobe->flags manipulation Oleg Nesterov
2012-10-04 8:57 ` Anton Arapov
2012-10-06 9:54 ` Srikar Dronamraju
2012-09-30 19:44 ` [PATCH 0/7] uprobes: register/unregister bugfixes Oleg Nesterov
2012-10-01 12:55 ` Srikar Dronamraju
2012-10-01 14:03 ` Oleg Nesterov
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=20121006094528.GC9145@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=ananth@in.ibm.com \
--cc=anton@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.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