Skip to content

Commit

Permalink
powerpc: Dynamically calculate the dabrx based on kernel/user/hypervisor
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Michael Neuling authored and Benjamin Herrenschmidt committed Sep 9, 2012
1 parent 4474ef0 commit cd14457
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/hw_breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 11 additions & 4 deletions arch/powerpc/kernel/hw_breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static int pseries_set_xdabr(unsigned long dabr, unsigned long dabrx)
if (dabrx == 0 && dabr == 0)
dabrx = DABRX_USER;
/* PAPR says we can only set kernel and user bits */
dabrx &= H_DABRX_KERNEL | H_DABRX_USER;
dabrx &= DABRX_KERNEL | DABRX_USER;

return plpar_hcall_norets(H_SET_XDABR, dabr, dabrx);
}
Expand Down

0 comments on commit cd14457

Please sign in to comment.