Received: by 10.223.185.116 with SMTP id b49csp1100437wrg; Fri, 23 Feb 2018 11:57:49 -0800 (PST) X-Google-Smtp-Source: AH8x22712fIsZYJ/oh2Du4nI5snvash8bjbMHSoHM+0lnezWrt2NjJY7pktQArQEIfDi/jdow5mk X-Received: by 10.98.103.69 with SMTP id b66mr2861843pfc.114.1519415869763; Fri, 23 Feb 2018 11:57:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519415869; cv=none; d=google.com; s=arc-20160816; b=ZRxbZZ8D91vbm5tP7JtzU0SBCVO6yfuZpdrnREbUxiBcqdNZxJXoq9ILxT55eyTuAp 56VoLpHkIIjd3VBMZn1Qsin55q/s+FDMEVlm1p05n/6RV1WQDF/Y2cPuVDmWpYacznB6 24dMearEInSA0eUXAIz3AE8y+8IGhR2azIJDuO/liK+92hiH0wVEuwdO7bkF2kvzzKwJ RCYXcRe21zAydDmRVIgqUHl0ytAIhtpwlVm+Fq74nuDkFbOwRV0g9+zUFKsZGzlDWBAt Jl+0c2TrbcybYFEdyeq5Ota9rJwkMXqMgmg8GY0eYnfrfTLBvfBk56LVnCWVv8fCBrsA UvOA== 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=R66NDvw82rI3rkNS1j3VwJzt3fOKgZV8PCxFUeJVoao=; b=l+6Tl56NPsop+PtmsEZ4wpwqeAayaSfjBu3d8zG+gR4B2FVmyxSpnRWbz0ithgWExY NYaC4ANDo8yQx9sAY2/SathPERnkQ/k4QEvTt+TJP6vxuKfec9xb+1ztwdloW7RMXSsH wGPThyIMZGvIlVbCIXN9lAC5ZVW/B+l+dUlEwzA+CxAmzm/0E2ksOMo847r3dgxJyfUF ZTgCedB5Z9d6GXbd+oR9kgkZXpIB9nh520sK8EWvxQiTdWb66ht+/jzAw5AsCrcmUH11 ihpN7EnotXPtpZnXFiIRV4tNbLRCXVdZHzCkg4ZLTQ+Wky1Rzml+WPgYpeGiseF6wkTJ 5nnA== 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 w2si1863387pgm.215.2018.02.23.11.57.35; Fri, 23 Feb 2018 11:57:49 -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 S933793AbeBWTzu (ORCPT + 99 others); Fri, 23 Feb 2018 14:55:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43156 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933052AbeBWSo6 (ORCPT ); Fri, 23 Feb 2018 13:44:58 -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 2A1FA122E; Fri, 23 Feb 2018 18:44:51 +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.9 061/145] powerpc/perf: Fix oops when grouping different pmu events Date: Fri, 23 Feb 2018 19:26:07 +0100 Message-Id: <20180223170732.680009918@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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;