All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	fweisbec@redhat.com
Subject: Re: [PATCH] Enable hardware breakpoint upon re-registering
Date: Wed, 07 Nov 2012 07:53:26 +1100	[thread overview]
Message-ID: <24260.1352235206@neuling.org> (raw)
In-Reply-To: <20121105081527.29141.11384.stgit@aravinda>

Aravinda Prasad <aravinda@linux.vnet.ibm.com> wrote:

> On powerpc, ptrace will disable hardware breakpoint request once the
> breakpoint is hit. It is the responsibility of the caller to set it
> again. However, when the caller sets the hardware breakpoint again
> using ptrace(PTRACE_SET_DEBUGREG, child_pid, 0, addr), the hardware
> breakpoint is not enabled.
> 
> While gdb's approach is to unregister and re-register the hardware
> breakpoint every time the breakpoint is hit - which is working fine,
> this could affect other programs trying to re-register hardware
> breakpoint without unregistering.
> 
> This patch enables hardware breakpoint if the caller is re-registering.
> 
> Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>

Passes my tests here and I don't think it'll break existing gdb.  So FWIW

Acked-by: Michael Neuling <mikey@neuling.org>

Thanks!

> ---
>  arch/powerpc/kernel/ptrace.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 79d8e56..09371d0 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -952,6 +952,10 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
>  		arch_bp_generic_fields(data &
>  					(DABR_DATA_WRITE | DABR_DATA_READ),
>  							&attr.bp_type);
> +
> +		/* Enable breakpoint */
> +		attr.disabled = false;
> +
>  		ret =  modify_user_hw_breakpoint(bp, &attr);
>  		if (ret) {
>  			ptrace_put_breakpoints(task);
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 

WARNING: multiple messages have this Message-ID (diff)
From: Michael Neuling <mikey@neuling.org>
To: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org,
	fweisbec@redhat.com, benh@kernel.crashing.org
Subject: Re: [PATCH] Enable hardware breakpoint upon re-registering
Date: Wed, 07 Nov 2012 07:53:26 +1100	[thread overview]
Message-ID: <24260.1352235206@neuling.org> (raw)
In-Reply-To: <20121105081527.29141.11384.stgit@aravinda>

Aravinda Prasad <aravinda@linux.vnet.ibm.com> wrote:

> On powerpc, ptrace will disable hardware breakpoint request once the
> breakpoint is hit. It is the responsibility of the caller to set it
> again. However, when the caller sets the hardware breakpoint again
> using ptrace(PTRACE_SET_DEBUGREG, child_pid, 0, addr), the hardware
> breakpoint is not enabled.
> 
> While gdb's approach is to unregister and re-register the hardware
> breakpoint every time the breakpoint is hit - which is working fine,
> this could affect other programs trying to re-register hardware
> breakpoint without unregistering.
> 
> This patch enables hardware breakpoint if the caller is re-registering.
> 
> Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com>

Passes my tests here and I don't think it'll break existing gdb.  So FWIW

Acked-by: Michael Neuling <mikey@neuling.org>

Thanks!

> ---
>  arch/powerpc/kernel/ptrace.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 79d8e56..09371d0 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -952,6 +952,10 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
>  		arch_bp_generic_fields(data &
>  					(DABR_DATA_WRITE | DABR_DATA_READ),
>  							&attr.bp_type);
> +
> +		/* Enable breakpoint */
> +		attr.disabled = false;
> +
>  		ret =  modify_user_hw_breakpoint(bp, &attr);
>  		if (ret) {
>  			ptrace_put_breakpoints(task);
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 

  reply	other threads:[~2012-11-06 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  8:15 [PATCH] Enable hardware breakpoint upon re-registering Aravinda Prasad
2012-11-06 20:53 ` Michael Neuling [this message]
2012-11-06 20:53   ` Michael Neuling

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=24260.1352235206@neuling.org \
    --to=mikey@neuling.org \
    --cc=aravinda@linux.vnet.ibm.com \
    --cc=fweisbec@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.