From: Michael Neuling <mikey@neuling.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Neuling <mikey@neuling.org>, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 5/5] powerpc: Dynamically calculate the dabrx based on kernel/user/hypervisor
Date: Thu, 6 Sep 2012 15:17:51 +1000 [thread overview]
Message-ID: <1346908671-7464-5-git-send-email-mikey@neuling.org> (raw)
In-Reply-To: <1346908671-7464-1-git-send-email-mikey@neuling.org>
Currently we mark the DABRX to interrupt on all matches
(hypervisor/kernel/user and then filter in software. We can be a lot
smarter now that we can set the DABRX dynamically.
This sets the DABRX based on the flags passed by the user.
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
arch/powerpc/include/asm/hw_breakpoint.h | 1 +
arch/powerpc/kernel/hw_breakpoint.c | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index c6f48eb..4234245 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -28,6 +28,7 @@
struct arch_hw_breakpoint {
unsigned long address;
+ unsigned long dabrx;
int type;
u8 len; /* length of the target data symbol */
bool extraneous_interrupt;
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 6891d79..a89cae4 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -73,7 +73,7 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
* If so, DABR will be populated in single_step_dabr_instruction().
*/
if (current->thread.last_hit_ubp != bp)
- set_dabr(info->address | info->type | DABR_TRANSLATION, DABRX_ALL);
+ set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx);
return 0;
}
@@ -170,6 +170,13 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
info->address = bp->attr.bp_addr;
info->len = bp->attr.bp_len;
+ info->dabrx = DABRX_ALL;
+ if (bp->attr.exclude_user)
+ info->dabrx &= ~DABRX_USER;
+ if (bp->attr.exclude_kernel)
+ info->dabrx &= ~DABRX_KERNEL;
+ if (bp->attr.exclude_hv)
+ info->dabrx &= ~DABRX_HYP;
/*
* Since breakpoint length can be a maximum of HW_BREAKPOINT_LEN(8)
@@ -197,7 +204,7 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs)
info = counter_arch_bp(tsk->thread.last_hit_ubp);
regs->msr &= ~MSR_SE;
- set_dabr(info->address | info->type | DABR_TRANSLATION, DABRX_ALL);
+ set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx);
tsk->thread.last_hit_ubp = NULL;
}
@@ -281,7 +288,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)
if (!info->extraneous_interrupt)
perf_bp_event(bp, regs);
- set_dabr(info->address | info->type | DABR_TRANSLATION, DABRX_ALL);
+ set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx);
out:
rcu_read_unlock();
return rc;
@@ -313,7 +320,7 @@ int __kprobes single_step_dabr_instruction(struct die_args *args)
if (!info->extraneous_interrupt)
perf_bp_event(bp, regs);
- set_dabr(info->address | info->type | DABR_TRANSLATION, DABRX_ALL);
+ set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx);
current->thread.last_hit_ubp = NULL;
/*
--
1.7.9.5
next prev parent reply other threads:[~2012-09-06 5:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 5:17 [PATCH 1/5] powerpc: Pack arch_hw_breakpoint to avoid holes in struct Michael Neuling
2012-09-06 5:17 ` [PATCH 2/5] powerpc: Use consistent name info for arch_hw_breakpoint Michael Neuling
2012-09-06 5:17 ` [PATCH 3/5] powerpc: Use the XDABR hcall Michael Neuling
2012-09-06 5:17 ` [PATCH 4/5] powerpc: Rework set_dabr so it can take a DABRX value as well Michael Neuling
2012-09-06 5:35 ` Geert Uytterhoeven
2012-09-07 3:37 ` Michael Neuling
2012-09-07 5:26 ` Geert Uytterhoeven
2012-09-07 5:43 ` Michael Neuling
2012-09-10 12:27 ` Geert Uytterhoeven
2012-09-07 7:24 ` [PATCH v2 0/3] powerpc: HW filtering of breakpoint for user/kernel/hypervisor events Michael Neuling
2012-09-07 7:24 ` [PATCH 1/3] powerpc: Rework set_dabr so it can take a DABRX value as well Michael Neuling
2012-09-07 7:24 ` [PATCH 2/3] powerpc: Dynamically calculate the dabrx based on kernel/user/hypervisor Michael Neuling
2012-09-07 7:24 ` [PATCH 3/3] powerpc: cleanup old DABRX #defines Michael Neuling
2012-09-06 5:17 ` Michael Neuling [this message]
2012-09-06 5:31 ` [PATCH 5/5] powerpc: Dynamically calculate the dabrx based on kernel/user/hypervisor 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=1346908671-7464-5-git-send-email-mikey@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.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 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).