linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/8] ARM: hw_breakpoint: don't advertise reserved breakpoints
Date: Tue, 30 Nov 2010 10:01:00 +0000	[thread overview]
Message-ID: <20101130100100.GA4398@pulham.picochip.com> (raw)
In-Reply-To: <1291052088-17243-6-git-send-email-will.deacon@arm.com>

On Mon, Nov 29, 2010 at 05:34:45PM +0000, Will Deacon wrote:
> To permit handling of watchpoint exceptions without signalling a
> debugger, it is necessary to reserve breakpoint registers for in-kernel
> use only.
> 
> This patch ensures that we record and subtract the number of reserved
> breakpoints from the number of usable breakpoint registers that we
> advertise to userspace via the ptrace API.
> 
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/kernel/hw_breakpoint.c |  205 ++++++++++++++++++++++-----------------
>  1 files changed, 116 insertions(+), 89 deletions(-)
> 
> diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
> index 61eeb41..b8acfbc 100644
> --- a/arch/arm/kernel/hw_breakpoint.c
> +++ b/arch/arm/kernel/hw_breakpoint.c
> @@ -44,6 +44,7 @@ static DEFINE_PER_CPU(struct perf_event *, wp_on_reg[ARM_MAX_WRP]);
>  
[...]
> +/* Determine number of BRP register available. */
> +static int get_num_brp_resources(void)
> +{
> +	u32 didr;
> +	ARM_DBG_READ(c0, 0, didr);
> +	return ((didr >> 24) & 0xf) + 1;
> +}
> +
> +/* Does this core support mismatch breakpoints? */
> +static int core_has_mismatch_brps(void)
> +{
> +	return (get_debug_arch() >= ARM_DEBUG_ARCH_V7_ECP14 &&
> +		get_num_brp_resources() > 1);
> +}
> +
> +/* Determine number of usable WRPs available. */
> +static int get_num_wrps(void)
> +{
> +	/*
> +	 * FIXME: When a watchpoint fires, the only way to work out which
> +	 * watchpoint it was is by disassembling the faulting instruction
> +	 * and working out the address of the memory access.
> +	 *
> +	 * Furthermore, we can only do this if the watchpoint was precise
> +	 * since imprecise watchpoints prevent us from calculating register
> +	 * based addresses.
> +	 *
> +	 * For the time being, we only report 1 watchpoint register so we
> +	 * always know which watchpoint fired. In the future we can either
> +	 * add a disassembler and address generation emulator, or we can
> +	 * insert a check to see if the DFAR is set on watchpoint exception
> +	 * entry [the ARM ARM states that the DFAR is UNKNOWN, but
> +	 * experience shows that it is set on some implementations].
> +	 */
> +
> +#if 0
> +	int wrps;
> +	u32 didr;
> +	ARM_DBG_READ(c0, 0, didr);
> +	wrps = ((didr >> 28) & 0xf) + 1;
> +#endif
> +	int wrps = 1;
> +
> +	if (core_has_mismatch_brps() && wrps >= get_num_brp_resources())
> +		wrps = get_num_brp_resources() - 1;
> +
> +	return wrps;
> +}
Hi Will,

Minor nitpick, is the comment above still valid? It looks like this could 
return something other than 1. Is this to handle the case when there aren't 
any watchpoint registers?

Jamie

  reply	other threads:[~2010-11-30 10:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-29 17:34 [PATCH 0/8] ARM: hw_breakpoint: fixes and improvements (v2) Will Deacon
2010-11-29 17:34 ` [PATCH 1/8] ARM: hw_breakpoint: ensure OS lock is clear before writing to debug registers Will Deacon
2010-11-29 17:34 ` [PATCH 2/8] ARM: hw_breakpoint: reset control registers in hotplug path Will Deacon
2010-11-29 17:34 ` [PATCH 3/8] ARM: hw_breakpoint: correct and simplify alignment fixup code Will Deacon
2010-11-29 17:34 ` [PATCH 4/8] ARM: hw_breakpoint: disable preemption during debug exception handling Will Deacon
2010-11-29 17:34 ` [PATCH 5/8] ARM: hw_breakpoint: don't advertise reserved breakpoints Will Deacon
2010-11-30 10:01   ` Jamie Iles [this message]
2010-11-30 10:12     ` Will Deacon
2010-11-30 11:02       ` Jamie Iles
2010-11-30 13:50         ` Will Deacon
2010-11-29 17:34 ` [PATCH 6/8] ARM: hw_breakpoint: do not allocate new breakpoints with rcu_read_lock held Will Deacon
2010-11-29 17:34 ` [PATCH 7/8] ARM: ptrace: fix style issue with hw_breakpoint interface Will Deacon
2010-11-29 17:34 ` [PATCH 8/8] ARM: hw_breakpoint: fix warnings generated by sparse Will Deacon

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=20101130100100.GA4398@pulham.picochip.com \
    --to=jamie@jamieiles.com \
    --cc=linux-arm-kernel@lists.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;
as well as URLs for NNTP newsgroup(s).