powerpc/hw_brk: Fix setting of length for exact mode breakpoints
Subsystems (2)
PATCH 1/2 powerpc/hw_brk: Fix setting of length for exact mode breakpoints
The smallest match region for both the DABR and DAWR is 8 bytes, so the kernel needs to filter matches when users want to look at regions smaller than this.
Currently we set the length of PPC_BREAKPOINT_MODE_EXACT breakpoints to 8. This is wrong as in exact mode we should only match on 1 address, hence the length should be 1.
This ensures that the kernel will filter out any exact mode hardware breakpoint matches on any addresses other than the requested one.
--- arch/powerpc/kernel/ptrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/ptrace.c +3 -1
@@ -1449,7 +1449,9 @@ static long ppc_set_hwdebug(struct task_struct *child,*/ if (bp_info->addr_mode ==PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE ) { len = bp_info->addr2 - bp_info->addr; - }else if (bp_info->addr_mode !=PPC_BREAKPOINT_MODE_EXACT ) { + }else if (bp_info->addr_mode ==PPC_BREAKPOINT_MODE_EXACT ) + len =1 ; +else {ptrace_put_breakpoints (child);return -EINVAL ; }
Signature · 1 line
1.7.10.4
PATCH 2/2 powerpc/hw_brk: Fix clearing of extraneous IRQ
In 9422de3 "powerpc: Hardware breakpoints rewrite to handle non DABR breakpoint registers" we changed the way we mark extraneous irqs with this:
- info->extraneous_interrupt = !((bp->attr.bp_addr <= dar) &&
- (dar - bp->attr.bp_addr < bp->attr.bp_len));
+ if (!((bp->attr.bp_addr <= dar) &&
+ (dar - bp->attr.bp_addr < bp->attr.bp_len)))
+ info->type |= HW_BRK_TYPE_EXTRANEOUS_IRQ;
Unfortunately this is bogus as it never clears extraneous IRQ if it's already set.
This correctly clears extraneous IRQ before possibly setting it.
--- arch/powerpc/kernel/hw_breakpoint.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/kernel/hw_breakpoint.c +1 -0
@@ -250,6 +250,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args)* we still need to single-step the instruction, but we don't * generate an event. */ + info->type &= ~HW_BRK_TYPE_EXTRANEOUS_IRQ ;if (!((bp->attr.bp_addr <= dar) && (dar - bp->attr.bp_addr < bp->attr.bp_len))) info->type |=HW_BRK_TYPE_EXTRANEOUS_IRQ ;
Signature · 1 line
1.7.10.4
Quoted 4 lines · Michael Neuling
The smallest match region for both the DABR and DAWR is 8 bytes, so the kernel needs to filter matches when users want to look at regions smaller than this.
Quoted 8 lines
Currently we set the length of
PPC_BREAKPOINT_MODE_EXACTbreakpoints to 8. This is wrong as in exact mode we should only match on 1 address, hence the length should be 1.This ensures that the kernel will filter out any exact mode hardware breakpoint matches on any addresses other than the requested one.
Signed-off-by Michael Neuling <[email protected]>
Re: [PATCH 2/2] powerpc/hw_brk: Fix clearing of extraneous IRQ
In reply to Michael NeulingQuoted 9 lines · Michael Neuling
In 9422de3 "powerpc: Hardware breakpoints rewrite to handle non DABR breakpoint registers" we changed the way we mark extraneous irqs with this:
(quoted diff) +3
-2- info->extraneous_interrupt = !((bp->attr.bp_addr <= dar) && - (dar - bp->attr.bp_addr < bp->attr.bp_len)); + if (!((bp->attr.bp_addr <= dar) && + (dar - bp->attr.bp_addr < bp->attr.bp_len))) + info->type |= HW_BRK_TYPE_EXTRANEOUS_IRQ;
Quoted 6 lines
Unfortunately this is bogus as it never clears extraneous IRQ if it's already set.
This correctly clears extraneous IRQ before possibly setting it.
Signed-off-by Michael Neuling <[email protected]>