From: "K.Prasad" <prasad@linux.vnet.ibm.com>
To: David Gibson <dwg@au1.ibm.com>
Cc: Michael Neuling <mikey@neuling.org>,
Benjamin Herrenschmidt <benh@au1.ibm.com>,
linuxppc-dev@ozlabs.org, paulus@samba.org,
Alan Stern <stern@rowland.harvard.edu>,
Roland McGrath <roland@redhat.com>
Subject: Re: [Patch 2/6] Introduce PPC64 specific Hardware Breakpoint interfaces
Date: Mon, 15 Jun 2009 12:48:28 +0530 [thread overview]
Message-ID: <20090615071828.GA7608@in.ibm.com> (raw)
In-Reply-To: <20090615064045.GB26817@yookeroo.seuss>
On Mon, Jun 15, 2009 at 04:40:45PM +1000, David Gibson wrote:
> On Wed, Jun 10, 2009 at 12:13:49PM +0530, K.Prasad wrote:
> > On Fri, Jun 05, 2009 at 03:11:58PM +1000, David Gibson wrote:
> > > On Wed, Jun 03, 2009 at 10:05:11PM +0530, K.Prasad wrote:
> >
> > > > + else {
> > > > + /*
> > > > + * This exception is triggered not because of a memory access on
> > > > + * the monitored variable but in the double-word address range
> > > > + * in which it is contained. We will consume this exception,
> > > > + * considering it as 'noise'.
> > > > + */
> > > > + rc = NOTIFY_STOP;
> > > > + goto out;
> > > > + }
> > > > + is_one_shot = (bp->triggered == ptrace_triggered) ? 1 : 0;
> > >
> > > Ouch, explicitly special-casing ptrace_triggered is pretty nasty.
> > > Since the bp_info is already arch specific, maybe it should include a
> > > flag to indicate whether the breakpoint is one-shot or not.
> > >
> >
> > The reason to check for ptrace_triggered is to contain the one-shot
> > behaviour only to ptrace (thus retaining the semantics) and not to extend
> > them to all user-space requests through
> > register_user_hw_breakpoint().
>
> Right, but couldn't you implement that withing ptrace_triggered
> itself, without a special test here, by having it cancel the
> breakpoint.
>
A special check (either using the callback routine as above, or using a
special flag) will be required in hw_breakpoint_handler() to enable
early return (without single-stepping). I'm not sure if I got your
suggestion right, and let me know if you think so.
> > A one-shot behaviour for all user-space requests would create more work
> > for the user-space programs (such as re-registration) and will leave open
> > a small window of opportunity for debug register grabbing by kernel-space
> > requests.
> >
> > So, in effect a request through register_user_hw_breakpoint() interface
> > will behave as under:
> > - Single-step over the causative instruction that triggered the
> > breakpoint exception handler.
> > - Deliver the SIGTRAP signal to user-space after executing the causative
> > instruction.
> >
> > This behaviour is in consonance with that of kernel-space requests and
> > those on x86 processors, and helps define a consistent behaviour across
> > architectures for user-space.
> >
> > Let me know what you think on the same.
>
> I certainly see the value in consistent semantics across archs.
> However, I can also see uses for the powerpc trap-before-execute
> behaviour. That's why I'm suggesting it might be worth having an
> arch-specific flag.
>
> [snip]
So, you suggest that the 'one-shot' behaviour should be driven by
user-request and not just confined to ptrace? (The default behaviour for
all breakpoints-minus-ptrace will remain 'continuous' though).
It can be implemented through an additional flag in 'struct
arch_hw_breakpoint'. I can send a new version 7 of the patchset with this
change (with the hope that the version 6 of the patchset looks fine in
its present form!). Meanwhile, we'd like to know what uses you see in
addition to the present one if the one-shot behaviour is made
user-defined. Are those uses beyond what can be achieved through the
present ptrace interface?
> > > > +int __kprobes single_step_dabr_instruction(struct die_args *args)
> > > > +{
> > > > + struct pt_regs *regs = args->regs;
> > > > + int cpu = get_cpu();
> > > > + int ret = NOTIFY_DONE;
> > > > + siginfo_t info;
> > > > + unsigned long this_dabr_data = per_cpu(dabr_data, cpu);
> > > > +
> > > > + /*
> > > > + * Check if we are single-stepping as a result of a
> > > > + * previous HW Breakpoint exception
> > > > + */
> > > > + if (this_dabr_data == 0)
> > > > + goto out;
> > > > +
> > > > + regs->msr &= ~MSR_SE;
> > > > + /* Deliver signal to user-space */
> > > > + if (this_dabr_data < TASK_SIZE) {
> > > > + info.si_signo = SIGTRAP;
> > > > + info.si_errno = 0;
> > > > + info.si_code = TRAP_HWBKPT;
> > > > + info.si_addr = (void __user *)(per_cpu(dabr_data, cpu));
> > > > + force_sig_info(SIGTRAP, &info, current);
> > >
> > > Uh.. I recall mentioning in my previous review that in order to match
> > > previous behaviour we need to deliver the userspace signal *before*
> > > stepping over the breakpointed instruction, rather than after (which
> > > I guess is why breakpoints are one-shot in the old scheme).
> >
> > This code would implement the behaviour as stated in the comment for
> > user-space requests above.
>
> And you're relying on the old trap-sending code in do_dabr for ptrace
> requests?
>
Yes.
> --
> David Gibson | I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
> | _way_ _around_!
> http://www.ozlabs.org/~dgibson
Thanks,
K.Prasad
next prev parent reply other threads:[~2009-06-15 7:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090603162741.197115376@prasadkr_t60p.in.ibm.com>
2009-06-03 16:34 ` [Patch 1/6] Prepare the PowerPC platform for HW Breakpoint infrastructure K.Prasad
2009-06-03 16:35 ` [Patch 2/6] Introduce PPC64 specific Hardware Breakpoint interfaces K.Prasad
2009-06-05 5:11 ` David Gibson
2009-06-10 6:43 ` K.Prasad
2009-06-15 6:40 ` David Gibson
2009-06-15 7:18 ` K.Prasad [this message]
2009-06-17 4:45 ` David Gibson
2009-06-03 16:35 ` [Patch 3/6] Modify ptrace code to use " K.Prasad
2009-06-05 5:13 ` David Gibson
2009-06-10 6:50 ` K.Prasad
2009-06-15 6:52 ` David Gibson
2009-06-03 16:35 ` [Patch 4/6] Modify process and processor handling code to recognise hardware debug registers K.Prasad
2009-06-03 16:35 ` [Patch 5/6] Modify Data storage exception code to recognise DABR match first K.Prasad
2009-06-03 16:35 ` [Patch 6/6] Adapt kexec and samples code to recognise PPC64 hardware breakpoint usage K.Prasad
[not found] <20090726235854.574539012@prasadkr_t60p.in.ibm.com>
2009-07-27 0:13 ` [Patch 2/6] Introduce PPC64 specific Hardware Breakpoint interfaces K.Prasad
2009-07-31 6:16 ` David Gibson
2009-08-03 20:59 ` K.Prasad
2009-08-05 2:55 ` David Gibson
[not found] <20090610090316.898961359@prasadkr_t60p.in.ibm.com>
2009-06-10 9:08 ` K.Prasad
2009-06-17 4:32 ` David Gibson
2009-06-18 18:20 ` K.Prasad
2009-06-19 5:04 ` David Gibson
2009-07-03 8:11 ` K.Prasad
[not found] <20090525004730.944465878@prasadkr_t60p.in.ibm.com>
2009-05-25 1:15 ` K.Prasad
2009-05-29 4:18 ` David Gibson
2009-05-29 13:54 ` K.Prasad
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=20090615071828.GA7608@in.ibm.com \
--to=prasad@linux.vnet.ibm.com \
--cc=benh@au1.ibm.com \
--cc=dwg@au1.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=paulus@samba.org \
--cc=roland@redhat.com \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).