perf/arch/arm: Implement hw_breakpoint_arch_parse()
Migrate to the new API in order to remove arch_validate_hwbkpt_settings() that clumsily mixes up architecture validation and commit. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joel Fernandes <joel.opensrc@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rich Felker <dalias@libc.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will.deacon@arm.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: http://lkml.kernel.org/r/1529981939-8231-6-git-send-email-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
5d5176baed
commit
9d52718cd3
@ -111,6 +111,7 @@ static inline void decode_ctrl_reg(u32 reg,
|
|||||||
asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
|
asm volatile("mcr p14, 0, %0, " #N "," #M ", " #OP2 : : "r" (VAL));\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
struct perf_event_attr;
|
||||||
struct notifier_block;
|
struct notifier_block;
|
||||||
struct perf_event;
|
struct perf_event;
|
||||||
struct pmu;
|
struct pmu;
|
||||||
@ -118,7 +119,10 @@ struct pmu;
|
|||||||
extern int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
|
extern int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
|
||||||
int *gen_len, int *gen_type);
|
int *gen_len, int *gen_type);
|
||||||
extern int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw);
|
extern int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw);
|
||||||
extern int arch_validate_hwbkpt_settings(struct perf_event *bp);
|
extern int hw_breakpoint_arch_parse(struct perf_event *bp,
|
||||||
|
const struct perf_event_attr *attr,
|
||||||
|
struct arch_hw_breakpoint *hw);
|
||||||
|
#define hw_breakpoint_arch_parse hw_breakpoint_arch_parse
|
||||||
extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
|
extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
|
||||||
unsigned long val, void *data);
|
unsigned long val, void *data);
|
||||||
|
|
||||||
|
@ -517,42 +517,42 @@ int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
|
|||||||
/*
|
/*
|
||||||
* Construct an arch_hw_breakpoint from a perf_event.
|
* Construct an arch_hw_breakpoint from a perf_event.
|
||||||
*/
|
*/
|
||||||
static int arch_build_bp_info(struct perf_event *bp)
|
static int arch_build_bp_info(struct perf_event *bp,
|
||||||
|
const struct perf_event_attr *attr,
|
||||||
|
struct arch_hw_breakpoint *hw)
|
||||||
{
|
{
|
||||||
struct arch_hw_breakpoint *info = counter_arch_bp(bp);
|
|
||||||
|
|
||||||
/* Type */
|
/* Type */
|
||||||
switch (bp->attr.bp_type) {
|
switch (attr->bp_type) {
|
||||||
case HW_BREAKPOINT_X:
|
case HW_BREAKPOINT_X:
|
||||||
info->ctrl.type = ARM_BREAKPOINT_EXECUTE;
|
hw->ctrl.type = ARM_BREAKPOINT_EXECUTE;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_R:
|
case HW_BREAKPOINT_R:
|
||||||
info->ctrl.type = ARM_BREAKPOINT_LOAD;
|
hw->ctrl.type = ARM_BREAKPOINT_LOAD;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_W:
|
case HW_BREAKPOINT_W:
|
||||||
info->ctrl.type = ARM_BREAKPOINT_STORE;
|
hw->ctrl.type = ARM_BREAKPOINT_STORE;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_RW:
|
case HW_BREAKPOINT_RW:
|
||||||
info->ctrl.type = ARM_BREAKPOINT_LOAD | ARM_BREAKPOINT_STORE;
|
hw->ctrl.type = ARM_BREAKPOINT_LOAD | ARM_BREAKPOINT_STORE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Len */
|
/* Len */
|
||||||
switch (bp->attr.bp_len) {
|
switch (attr->bp_len) {
|
||||||
case HW_BREAKPOINT_LEN_1:
|
case HW_BREAKPOINT_LEN_1:
|
||||||
info->ctrl.len = ARM_BREAKPOINT_LEN_1;
|
hw->ctrl.len = ARM_BREAKPOINT_LEN_1;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_LEN_2:
|
case HW_BREAKPOINT_LEN_2:
|
||||||
info->ctrl.len = ARM_BREAKPOINT_LEN_2;
|
hw->ctrl.len = ARM_BREAKPOINT_LEN_2;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_LEN_4:
|
case HW_BREAKPOINT_LEN_4:
|
||||||
info->ctrl.len = ARM_BREAKPOINT_LEN_4;
|
hw->ctrl.len = ARM_BREAKPOINT_LEN_4;
|
||||||
break;
|
break;
|
||||||
case HW_BREAKPOINT_LEN_8:
|
case HW_BREAKPOINT_LEN_8:
|
||||||
info->ctrl.len = ARM_BREAKPOINT_LEN_8;
|
hw->ctrl.len = ARM_BREAKPOINT_LEN_8;
|
||||||
if ((info->ctrl.type != ARM_BREAKPOINT_EXECUTE)
|
if ((hw->ctrl.type != ARM_BREAKPOINT_EXECUTE)
|
||||||
&& max_watchpoint_len >= 8)
|
&& max_watchpoint_len >= 8)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -565,24 +565,24 @@ static int arch_build_bp_info(struct perf_event *bp)
|
|||||||
* by the hardware and must be aligned to the appropriate number of
|
* by the hardware and must be aligned to the appropriate number of
|
||||||
* bytes.
|
* bytes.
|
||||||
*/
|
*/
|
||||||
if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE &&
|
if (hw->ctrl.type == ARM_BREAKPOINT_EXECUTE &&
|
||||||
info->ctrl.len != ARM_BREAKPOINT_LEN_2 &&
|
hw->ctrl.len != ARM_BREAKPOINT_LEN_2 &&
|
||||||
info->ctrl.len != ARM_BREAKPOINT_LEN_4)
|
hw->ctrl.len != ARM_BREAKPOINT_LEN_4)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Address */
|
/* Address */
|
||||||
info->address = bp->attr.bp_addr;
|
hw->address = attr->bp_addr;
|
||||||
|
|
||||||
/* Privilege */
|
/* Privilege */
|
||||||
info->ctrl.privilege = ARM_BREAKPOINT_USER;
|
hw->ctrl.privilege = ARM_BREAKPOINT_USER;
|
||||||
if (arch_check_bp_in_kernelspace(info))
|
if (arch_check_bp_in_kernelspace(hw))
|
||||||
info->ctrl.privilege |= ARM_BREAKPOINT_PRIV;
|
hw->ctrl.privilege |= ARM_BREAKPOINT_PRIV;
|
||||||
|
|
||||||
/* Enabled? */
|
/* Enabled? */
|
||||||
info->ctrl.enabled = !bp->attr.disabled;
|
hw->ctrl.enabled = !attr->disabled;
|
||||||
|
|
||||||
/* Mismatch */
|
/* Mismatch */
|
||||||
info->ctrl.mismatch = 0;
|
hw->ctrl.mismatch = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -590,9 +590,10 @@ static int arch_build_bp_info(struct perf_event *bp)
|
|||||||
/*
|
/*
|
||||||
* Validate the arch-specific HW Breakpoint register settings.
|
* Validate the arch-specific HW Breakpoint register settings.
|
||||||
*/
|
*/
|
||||||
int arch_validate_hwbkpt_settings(struct perf_event *bp)
|
int hw_breakpoint_arch_parse(struct perf_event *bp,
|
||||||
|
const struct perf_event_attr *attr,
|
||||||
|
struct arch_hw_breakpoint *hw)
|
||||||
{
|
{
|
||||||
struct arch_hw_breakpoint *info = counter_arch_bp(bp);
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
u32 offset, alignment_mask = 0x3;
|
u32 offset, alignment_mask = 0x3;
|
||||||
|
|
||||||
@ -601,14 +602,14 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/* Build the arch_hw_breakpoint. */
|
/* Build the arch_hw_breakpoint. */
|
||||||
ret = arch_build_bp_info(bp);
|
ret = arch_build_bp_info(bp, attr, hw);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Check address alignment. */
|
/* Check address alignment. */
|
||||||
if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
|
if (hw->ctrl.len == ARM_BREAKPOINT_LEN_8)
|
||||||
alignment_mask = 0x7;
|
alignment_mask = 0x7;
|
||||||
offset = info->address & alignment_mask;
|
offset = hw->address & alignment_mask;
|
||||||
switch (offset) {
|
switch (offset) {
|
||||||
case 0:
|
case 0:
|
||||||
/* Aligned */
|
/* Aligned */
|
||||||
@ -616,19 +617,19 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
|
|||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
/* Allow halfword watchpoints and breakpoints. */
|
/* Allow halfword watchpoints and breakpoints. */
|
||||||
if (info->ctrl.len == ARM_BREAKPOINT_LEN_2)
|
if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2)
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Allow single byte watchpoint. */
|
/* Allow single byte watchpoint. */
|
||||||
if (info->ctrl.len == ARM_BREAKPOINT_LEN_1)
|
if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->address &= ~alignment_mask;
|
hw->address &= ~alignment_mask;
|
||||||
info->ctrl.len <<= offset;
|
hw->ctrl.len <<= offset;
|
||||||
|
|
||||||
if (is_default_overflow_handler(bp)) {
|
if (is_default_overflow_handler(bp)) {
|
||||||
/*
|
/*
|
||||||
@ -639,7 +640,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* We don't allow mismatch breakpoints in kernel space. */
|
/* We don't allow mismatch breakpoints in kernel space. */
|
||||||
if (arch_check_bp_in_kernelspace(info))
|
if (arch_check_bp_in_kernelspace(hw))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -654,8 +655,8 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
|
|||||||
* reports them.
|
* reports them.
|
||||||
*/
|
*/
|
||||||
if (!debug_exception_updates_fsr() &&
|
if (!debug_exception_updates_fsr() &&
|
||||||
(info->ctrl.type == ARM_BREAKPOINT_LOAD ||
|
(hw->ctrl.type == ARM_BREAKPOINT_LOAD ||
|
||||||
info->ctrl.type == ARM_BREAKPOINT_STORE))
|
hw->ctrl.type == ARM_BREAKPOINT_STORE))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user