From patchwork Wed Jul 31 13:37:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11067919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCCCC112C for ; Wed, 31 Jul 2019 13:38:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB8D82896F for ; Wed, 31 Jul 2019 13:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF9AD2894C; Wed, 31 Jul 2019 13:38:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C69B72022B for ; Wed, 31 Jul 2019 13:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hQFzD2nhdWBk5uvQlD7ChwXAvEqqfmtQ3N81Nma5jBE=; b=bFDs+BtpGMSps5 QaieJOgyD89veSP9DQD/n0f4i22A4fBfL6qOQ0dVd4i90ZI81OpTsfWOwvH9enfX4fPhlIByIv9Md LjbnC3ksECCmmryRFrx1nd92+NMJOy2/DPmiV9g6xU3kzbLYHoh4GCSGhzCERH0y5tFXjgSU5WQq4 k1/f2XjLoyd/W8ftmlwLXiU5o7subW7bimUTS7HFkdFE0jz/pnrR/nc6bZK2LNjxxQLQo3e6TDw9Y K42Jpiax8aBjnRfSWTApLddlvmx/cXTsAvAi8Ajy8I1BtxM5ccDNkzHndhvKBuAZwLAZgUQdJB5sR tnSRbx0pre/0i1v3LL/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsonz-00073D-0u; Wed, 31 Jul 2019 13:38:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsonr-0006vs-9k for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 13:38:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 496CA1570; Wed, 31 Jul 2019 06:38:02 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 982363F694; Wed, 31 Jul 2019 06:38:01 -0700 (PDT) From: Robin Murphy To: will@kernel.org, mark.rutland@arm.com Subject: [PATCH 2/2] perf/smmuv3: Validate groups for global filtering Date: Wed, 31 Jul 2019 14:37:42 +0100 Message-Id: <1921604dc4cd820363ccf728ade6508e0987e082.1564580090.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.21.0.dirty In-Reply-To: <7108cdcc6fdce8dd1cfd869849bd78d05bac870f.1564580090.git.robin.murphy@arm.com> References: <7108cdcc6fdce8dd1cfd869849bd78d05bac870f.1564580090.git.robin.murphy@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_063803_382437_02AD1750 X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, shameerali.kolothum.thodi@huawei.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With global filtering, it becomes possible for users to construct self-contradictory groups with conflicting filters. Make sure we cover that when initially validating events. Signed-off-by: Robin Murphy --- drivers/perf/arm_smmuv3_pmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index dd40df2ac895..e1e41d2fea94 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -324,6 +324,8 @@ static int smmu_pmu_event_init(struct perf_event *event) struct device *dev = smmu_pmu->dev; struct perf_event *sibling; int group_num_events = 1; + bool has_filter; + u32 filter_span, filter_sid; u16 event_id; if (event->attr.type != event->pmu->type) @@ -354,6 +356,10 @@ static int smmu_pmu_event_init(struct perf_event *event) return -EINVAL; } + has_filter = get_filter_enable(event); + filter_span = get_filter_span(event); + filter_sid = get_filter_stream_id(event); + for_each_sibling_event(sibling, event->group_leader) { if (sibling->pmu != event->pmu && !is_software_event(sibling)) { @@ -363,6 +369,16 @@ static int smmu_pmu_event_init(struct perf_event *event) if (++group_num_events >= smmu_pmu->num_counters) return -EINVAL; + + if (smmu_pmu->global_filter) { + if (has_filter != (bool)get_filter_enable(sibling)) + return -EINVAL; + + if (has_filter && + (filter_span != get_filter_span(sibling) || + filter_sid != get_filter_stream_id (sibling))) + return -EINVAL; + } } hwc->idx = -1;