powerpc/ptrace: Fix enforcement of DAWR constraints [Linux 3.16.61]

This Linux kernel change "powerpc/ptrace: Fix enforcement of DAWR constraints" is included in the Linux 3.16.61 release. This change is authored by Michael Neuling <mikey [at] neuling.org> on Thu May 17 15:37:14 2018 +1000. The commit for this change in Linux stable tree is 5a31ed1 (patch) which is from upstream commit cd6ef7e. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream cd6ef7e.

powerpc/ptrace: Fix enforcement of DAWR constraints

commit cd6ef7eebf171bfcba7dc2df719c2a4958775040 upstream.

Back when we first introduced the DAWR, in commit 4ae7ebe9522a
("powerpc: Change hardware breakpoint to allow longer ranges"), we
screwed up the constraint making it a 1024 byte boundary rather than a
512. This makes the check overly permissive. Fortunately GDB is the
only real user and it always did they right thing, so we never

This fixes the constraint to 512 bytes.

Fixes: 4ae7ebe9522a ("powerpc: Change hardware breakpoint to allow longer ranges")
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/powerpc/kernel/hw_breakpoint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 839b7cd..3bcecf0 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -174,8 +174,8 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
    if (cpu_has_feature(CPU_FTR_DAWR)) {
        length_max = 512 ; /* 64 doublewords */
        /* DAWR region can't cross 512 boundary */
-       if ((bp->attr.bp_addr >> 10) != 
-           ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 10))
+       if ((bp->attr.bp_addr >> 9) !=
+           ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 9))
            return -EINVAL;
    if (info->len >

Leave a Reply

Your email address will not be published. Required fields are marked *