linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: panand@redhat.com (Pratyush Anand)
To: linux-arm-kernel@lists.infradead.org
Subject: Support for unaligned watchpoints in arm/arm64
Date: Tue, 7 Jun 2016 12:25:20 +0530	[thread overview]
Message-ID: <20160607065520.GD13643@dhcppc6> (raw)
In-Reply-To: <20160531123827.GF24936@arm.com>

On 31/05/2016:01:38:27 PM, Will Deacon wrote:
> On Thu, May 26, 2016 at 05:04:46PM +0100, Pavel Labath wrote:
> > Hello all,
> 
> Hi Pavel,
> 
> > I've been wondering if there are any plans about adding support for
> > unaligned watchpoints to the kernel. It seems quite a shame that
> > applications are not able not use them, even though the hardware
> > should support that feature.
> 
> I'm actually coming round to the idea of ditching the perf hw_breakpoint
> mechanism entirely and simply writing a ptrace back-end that can expose
> the hardware features directly to userspace. The two issues with this
> are:
> 
>   (1) It's a fair amount of work

So, by the time this new interface would come, probably we can consider a fixup
like following to resolve this issue at hand. Probably, things should work by
just allowing hw_breakpoint.c to pass checks for unaligned offset when it is a
WATCHPOINT, no?

diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index 26a6bf77d272..c803347c1413 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -384,7 +384,12 @@ int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
                *gen_len = HW_BREAKPOINT_LEN_8;
@@ -384,7 +384,12 @@ int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
                *gen_len = HW_BREAKPOINT_LEN_8;
                break;
        default:
-               return -EINVAL;
+               if (ctrl.type == ARM_BREAKPOINT_EXECUTE
+                               || ctrl.len & (ctrl.len + 1)
+                               || ctrl.len < ARM_BREAKPOINT_LEN_1
+                               || ctrl.len > ARM_BREAKPOINT_LEN_8)
+                       return -EINVAL;
+               *gen_len = ffs(ctrl.len + 1) - 1;
        }

        return 0;
@@ -430,7 +435,11 @@ static int arch_build_bp_info(struct perf_event *bp)
                info->ctrl.len = ARM_BREAKPOINT_LEN_8;
                break;
        default:
-               return -EINVAL;
+               if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE
+                               || bp->attr.bp_len < HW_BREAKPOINT_LEN_1
+                               || bp->attr.bp_len > HW_BREAKPOINT_LEN_8)
+                       return -EINVAL;
+               info->ctrl.len = (1 << bp->attr.bp_len) - 1;
        }

        /*

@Pavel, does above patch helps to resolve the issue.

~Pratyush

>   (2) We might already have users of the perf interface (including compat)
> 
> I'm really not happy with the way hw_breakpoint worked out :(
> 
> Will
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2016-06-07  6:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 16:04 Support for unaligned watchpoints in arm/arm64 Pavel Labath
2016-05-31 12:38 ` Will Deacon
2016-06-07  6:55   ` Pratyush Anand [this message]
2016-06-07 15:17     ` Pratyush Anand
2016-06-08  0:15       ` Pavel Labath
2016-06-08  8:13         ` Pratyush Anand

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=20160607065520.GD13643@dhcppc6 \
    --to=panand@redhat.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).