Received: by 10.223.185.116 with SMTP id b49csp1139124wrg; Fri, 23 Feb 2018 12:37:40 -0800 (PST) X-Google-Smtp-Source: AH8x226G8VIaH49EYMl4aJAz3bEEP2Diuq4dJhuwX4cA6ybHqbus9h7P8tI0jIQrP8TvajxfkJit X-Received: by 2002:a17:902:7006:: with SMTP id y6-v6mr2814419plk.37.1519418260797; Fri, 23 Feb 2018 12:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418260; cv=none; d=google.com; s=arc-20160816; b=Uo1hlpEtwLGTM7nTUWcHWVFonv7hQIliLwH0zVlAbkxZUA5Co5XHYHMvoE/NtMqTTM m0KmqlXb6502VvtDw+0uZJjbpeA9o1ZGEITvsXbKnDBmFrmBgIWuQGgbundwbrFzLuFM PbvEJX4lQ0rzLCpwG52HboSq4NEAp9+K2PeZLgTfbGm+9rIaaVvqTcqYbGqY/0i0jtU/ ov/mFO3sSM542OMEjnYYSiOe6cAwor/EwLqq0vJbQD45nnM446fzHbxrA40ltyXm1PIx sZpGvLaBnNvHCHZLUhfygr6gXWE2sFrn9PJdWbzGJp/NVPOiIcVw5RI/Q0PCYNNQ6rNT MsRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aZUoiu8gD5qNhUJu/StKGiukfbeMoKv0YIHq/X5+GYg=; b=BvGUO7K8jZLfLsF/tNEDNi/5oLdjSasQ/llEh2S03NaS3T2m25HBi8rpXCzSbgGUlQ TYuo8gnJtLNF5Wq6iVy0lhGB2YvPzbffeYYcJ1makrsVzrO1HEqgpWxSu/ZsJA1PyG2+ 7yCmmwKWr/Dud5yjKz0Eei8yI3uW8y/ZK41WjhBMs7+GOo+3Of1SOCYL1zs+eah76sKY xUXRzIFTFfnlpyi/Oy1HVrJneg3dv2+y7K5H9JQlfs1chJbgofNsOt9nwS6nMk2uTr/l Bisa7eFofvZNq6xinjmuKC99BKVcwijbzi9ZJPEo3/q7/xkQvJPX0al9qzcWxewuZUcU 3cSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m27si2337755pfg.64.2018.02.23.12.37.26; Fri, 23 Feb 2018 12:37:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753588AbeBWSei (ORCPT + 99 others); Fri, 23 Feb 2018 13:34:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36960 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753567AbeBWSeb (ORCPT ); Fri, 23 Feb 2018 13:34:31 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EA2BA121B; Fri, 23 Feb 2018 18:34:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Bangoria , Madhavan Srinivasan , Michael Ellerman , Sasha Levin Subject: [PATCH 4.4 043/193] powerpc/perf: Fix oops when grouping different pmu events Date: Fri, 23 Feb 2018 19:24:36 +0100 Message-Id: <20180223170332.800079565@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ravi Bangoria [ Upstream commit 5aa04b3eb6fca63d2e9827be656dcadc26d54e11 ] 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 Reviewed-By: Madhavan Srinivasan Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/perf/core-book3s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -1381,7 +1381,7 @@ static int collect_events(struct perf_ev int n = 0; struct perf_event *event; - if (!is_software_event(group)) { + if (group->pmu->task_ctx_nr == perf_hw_context) { if (n >= max_count) return -1; ctrs[n] = group; @@ -1389,7 +1389,7 @@ static int collect_events(struct perf_ev events[n++] = group->hw.config; } list_for_each_entry(event, &group->sibling_list, group_entry) { - if (!is_software_event(event) && + if (event->pmu->task_ctx_nr == perf_hw_context && event->state != PERF_EVENT_STATE_OFF) { if (n >= max_count) return -1;