Skip to content

Commit 5aa04b3

Browse files
Ravi Bangoriampe
authored andcommitted
powerpc/perf: Fix oops when grouping different pmu events
When user tries to group imc (In-Memory Collections) event with normal event, (sometime) kernel crashes with following log: Faulting instruction address: 0x00000000 [link register ] c00000000010ce88 power_check_constraints+0x128/0x980 ... c00000000010e238 power_pmu_event_init+0x268/0x6f0 c0000000002dc60c perf_try_init_event+0xdc/0x1a0 c0000000002dce88 perf_event_alloc+0x7b8/0xac0 c0000000002e92e0 SyS_perf_event_open+0x530/0xda0 c00000000000b004 system_call+0x38/0xe0 'event_base' field of 'struct hw_perf_event' is used as flags for normal hw events and used as memory address for imc events. While grouping these two types of events, collect_events() tries to interpret imc 'event_base' as a flag, which causes a corruption resulting in a crash. Consider only those events which belongs to 'perf_hw_context' in collect_events(). Signed-off-by: Ravi Bangoria <[email protected]> Reviewed-By: Madhavan Srinivasan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent ae64f9b commit 5aa04b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/powerpc/perf/core-book3s.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,15 +1415,15 @@ static int collect_events(struct perf_event *group, int max_count,
14151415
int n = 0;
14161416
struct perf_event *event;
14171417

1418-
if (!is_software_event(group)) {
1418+
if (group->pmu->task_ctx_nr == perf_hw_context) {
14191419
if (n >= max_count)
14201420
return -1;
14211421
ctrs[n] = group;
14221422
flags[n] = group->hw.event_base;
14231423
events[n++] = group->hw.config;
14241424
}
14251425
list_for_each_entry(event, &group->sibling_list, group_entry) {
1426-
if (!is_software_event(event) &&
1426+
if (event->pmu->task_ctx_nr == perf_hw_context &&
14271427
event->state != PERF_EVENT_STATE_OFF) {
14281428
if (n >= max_count)
14291429
return -1;

0 commit comments

Comments
 (0)