All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] arm64: hw_breakpoint: Add get_hwbkt_alignment_mask
@ 2016-09-23 15:18 Pavel Labath
  2016-09-23 15:19 ` [PATCH 2/3] arm64: hw_breakpoint: Handle inexact watchpoint addresses Pavel Labath
  2016-09-23 15:19 ` [PATCH 3/3] selftests: arm64: add test for inexact watchpoint address handling Pavel Labath
  0 siblings, 2 replies; 15+ messages in thread
From: Pavel Labath @ 2016-09-23 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

This commit adds a utility function for computing the alignment mask of a
hardware breakpoint and fixes arch_validate_hwbkpt_settings to use that
instead.

Signed-off-by: Pavel Labath <labath@google.com>
---
 arch/arm64/kernel/hw_breakpoint.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
index 26a6bf7..14562ae 100644
--- a/arch/arm64/kernel/hw_breakpoint.c
+++ b/arch/arm64/kernel/hw_breakpoint.c
@@ -473,6 +473,16 @@ static int arch_build_bp_info(struct perf_event *bp)
 	return 0;
 }
 
+static unsigned int get_hwbkpt_alignment_mask(struct perf_event *bp)
+{
+	const struct arch_hw_breakpoint *info = counter_arch_bp(bp);
+
+	if (is_compat_bp(bp))
+		return info->ctrl.len == ARM_BREAKPOINT_LEN_8 ? 0x7 : 0x3;
+	else
+		return info->ctrl.type == ARM_BREAKPOINT_EXECUTE ? 0x3 : 0x7;
+}
+
 /*
  * Validate the arch-specific HW Breakpoint register settings.
  */
@@ -496,11 +506,8 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
 	 * AArch32 tasks expect some simple alignment fixups, so emulate
 	 * that here.
 	 */
+	alignment_mask = get_hwbkpt_alignment_mask(bp);
 	if (is_compat_bp(bp)) {
-		if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
-			alignment_mask = 0x7;
-		else
-			alignment_mask = 0x3;
 		offset = info->address & alignment_mask;
 		switch (offset) {
 		case 0:
@@ -521,10 +528,6 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
 		info->address &= ~alignment_mask;
 		info->ctrl.len <<= offset;
 	} else {
-		if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE)
-			alignment_mask = 0x3;
-		else
-			alignment_mask = 0x7;
 		if (info->address & alignment_mask)
 			return -EINVAL;
 	}
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-10-20  5:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 15:18 [PATCH 1/3] arm64: hw_breakpoint: Add get_hwbkt_alignment_mask Pavel Labath
2016-09-23 15:19 ` [PATCH 2/3] arm64: hw_breakpoint: Handle inexact watchpoint addresses Pavel Labath
2016-09-26 14:06   ` Will Deacon
2016-10-07 16:38   ` Pratyush Anand
2016-10-07 17:24     ` Pavel Labath
2016-10-08  5:10       ` Pratyush Anand
2016-10-12 13:50         ` Pavel Labath
2016-10-13  9:58           ` Pratyush Anand
2016-10-13 17:03             ` Pavel Labath
2016-10-14  3:15               ` Pratyush Anand
2016-10-19 12:07                 ` Will Deacon
2016-10-19 13:30                   ` Pavel Labath
2016-10-20  5:53                   ` Pratyush Anand
2016-10-10 17:08       ` Pratyush Anand
2016-09-23 15:19 ` [PATCH 3/3] selftests: arm64: add test for inexact watchpoint address handling Pavel Labath

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.