diff options
-rw-r--r-- | arch/xtensa/include/asm/hw_breakpoint.h | 6 | ||||
-rw-r--r-- | arch/xtensa/kernel/hw_breakpoint.c | 33 |
2 files changed, 17 insertions, 22 deletions
diff --git a/arch/xtensa/include/asm/hw_breakpoint.h b/arch/xtensa/include/asm/hw_breakpoint.h index 2525bf6816a6..f347c2132e6b 100644 --- a/arch/xtensa/include/asm/hw_breakpoint.h +++ b/arch/xtensa/include/asm/hw_breakpoint.h | |||
@@ -30,13 +30,17 @@ struct arch_hw_breakpoint { | |||
30 | u16 type; | 30 | u16 type; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | struct perf_event_attr; | ||
33 | struct perf_event; | 34 | struct perf_event; |
34 | struct pt_regs; | 35 | struct pt_regs; |
35 | struct task_struct; | 36 | struct task_struct; |
36 | 37 | ||
37 | int hw_breakpoint_slots(int type); | 38 | int hw_breakpoint_slots(int type); |
38 | int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw); | 39 | int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw); |
39 | int arch_validate_hwbkpt_settings(struct perf_event *bp); | 40 | int hw_breakpoint_arch_parse(struct perf_event *bp, |
41 | const struct perf_event_attr *attr, | ||
42 | struct arch_hw_breakpoint *hw); | ||
43 | #define hw_breakpoint_arch_parse hw_breakpoint_arch_parse | ||
40 | int hw_breakpoint_exceptions_notify(struct notifier_block *unused, | 44 | int hw_breakpoint_exceptions_notify(struct notifier_block *unused, |
41 | unsigned long val, void *data); | 45 | unsigned long val, void *data); |
42 | 46 | ||
diff --git a/arch/xtensa/kernel/hw_breakpoint.c b/arch/xtensa/kernel/hw_breakpoint.c index 6e34c3848885..c2e387c19cda 100644 --- a/arch/xtensa/kernel/hw_breakpoint.c +++ b/arch/xtensa/kernel/hw_breakpoint.c | |||
@@ -47,50 +47,41 @@ int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw) | |||
47 | /* | 47 | /* |
48 | * Construct an arch_hw_breakpoint from a perf_event. | 48 | * Construct an arch_hw_breakpoint from a perf_event. |
49 | */ | 49 | */ |
50 | static int arch_build_bp_info(struct perf_event *bp) | 50 | int hw_breakpoint_arch_parse(struct perf_event *bp, |
51 | const struct perf_event_attr *attr, | ||
52 | struct arch_hw_breakpoint *hw) | ||
51 | { | 53 | { |
52 | struct arch_hw_breakpoint *info = counter_arch_bp(bp); | ||
53 | |||
54 | /* Type */ | 54 | /* Type */ |
55 | switch (bp->attr.bp_type) { | 55 | switch (attr->bp_type) { |
56 | case HW_BREAKPOINT_X: | 56 | case HW_BREAKPOINT_X: |
57 | info->type = XTENSA_BREAKPOINT_EXECUTE; | 57 | hw->type = XTENSA_BREAKPOINT_EXECUTE; |
58 | break; | 58 | break; |
59 | case HW_BREAKPOINT_R: | 59 | case HW_BREAKPOINT_R: |
60 | info->type = XTENSA_BREAKPOINT_LOAD; | 60 | hw->type = XTENSA_BREAKPOINT_LOAD; |
61 | break; | 61 | break; |
62 | case HW_BREAKPOINT_W: | 62 | case HW_BREAKPOINT_W: |
63 | info->type = XTENSA_BREAKPOINT_STORE; | 63 | hw->type = XTENSA_BREAKPOINT_STORE; |
64 | break; | 64 | break; |
65 | case HW_BREAKPOINT_RW: | 65 | case HW_BREAKPOINT_RW: |
66 | info->type = XTENSA_BREAKPOINT_LOAD | XTENSA_BREAKPOINT_STORE; | 66 | hw->type = XTENSA_BREAKPOINT_LOAD | XTENSA_BREAKPOINT_STORE; |
67 | break; | 67 | break; |
68 | default: | 68 | default: |
69 | return -EINVAL; | 69 | return -EINVAL; |
70 | } | 70 | } |
71 | 71 | ||
72 | /* Len */ | 72 | /* Len */ |
73 | info->len = bp->attr.bp_len; | 73 | hw->len = attr->bp_len; |
74 | if (info->len < 1 || info->len > 64 || !is_power_of_2(info->len)) | 74 | if (hw->len < 1 || hw->len > 64 || !is_power_of_2(hw->len)) |
75 | return -EINVAL; | 75 | return -EINVAL; |
76 | 76 | ||
77 | /* Address */ | 77 | /* Address */ |
78 | info->address = bp->attr.bp_addr; | 78 | hw->address = attr->bp_addr; |
79 | if (info->address & (info->len - 1)) | 79 | if (hw->address & (hw->len - 1)) |
80 | return -EINVAL; | 80 | return -EINVAL; |
81 | 81 | ||
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | 84 | ||
85 | int arch_validate_hwbkpt_settings(struct perf_event *bp) | ||
86 | { | ||
87 | int ret; | ||
88 | |||
89 | /* Build the arch_hw_breakpoint. */ | ||
90 | ret = arch_build_bp_info(bp); | ||
91 | return ret; | ||
92 | } | ||
93 | |||
94 | int hw_breakpoint_exceptions_notify(struct notifier_block *unused, | 85 | int hw_breakpoint_exceptions_notify(struct notifier_block *unused, |
95 | unsigned long val, void *data) | 86 | unsigned long val, void *data) |
96 | { | 87 | { |