Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp453929ybi; Fri, 26 Jul 2019 12:37:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCPArWOt4g2fOOiq/7V+ig3+AlJuuh58u2T3FENOELncksmzY6v3j4FOGKfyKzQwwOluEE X-Received: by 2002:a17:90a:1b48:: with SMTP id q66mr95556656pjq.83.1564169839443; Fri, 26 Jul 2019 12:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564169839; cv=none; d=google.com; s=arc-20160816; b=aH8hySR/H02cDqvQFd55ylzP3vqnIBWJWGmpUvSVDiZMGBzDuG9D8dA/Ov+S7tdiYY pTz0lFF39r8qNOKI5NskLLkLvs1TrCKVKFw6z6R4gO7OoonNGgb5Qk36aAjamhY+s63+ KnAz1kdcD/E5BYSc2Js0Vi1RuIeKqyi0UMmhUgMI9JsBWnmPjyVBYW0ubLz9mlk3MqgK nnOEY+CHeOs312sJBt/+zb3tAlXAcdSRPymk4uxBw/Ww9KjpwLPS5M1te6RZaYNdAqhK NI0pDYTtQ+j2xjnmSzH0JxwXe+gvdNmbDEQBIE5ZSI1pumyXTg99iqmSp1xZ8534jZQt I38A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HMGvWmarQ5ttqqb3NAwXxLGaGIvNysnhSM9UIw1mXQw=; b=VGV+CX5rExS4K2HS75v8OwwUG22aVCYt9csVIutkZJkKphf0X8c6r7wOS0G3OtmN8K ymj1Zqc/sClXZG+n25XANGsZVyf6NtCKqnXEYbmTGyx4b84/x5FDry2QYL3rZz8drKUI lpowk84KCgCK/MGzDj6CU1jBLBBh+m0IEUR1HGJV7wyM4QRs2lGCoKZH8GjWS1Y6nyOq 2hhMspP7NXhC6Kh5RcM86q9Q3fkQtFm5e6MICUVxFvEroqDwUxE09HlKnYS59JiT9ill 71ySU9z2PkJLyBNcC4b/QVGyrufLArOOhPOB0nV0WsVOT0F4T2eUVEFRDKF+yiEqk2eT 7DAA== 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 v19si18536801pff.229.2019.07.26.12.37.04; Fri, 26 Jul 2019 12:37:19 -0700 (PDT) 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 S1728088AbfGZR7W (ORCPT + 99 others); Fri, 26 Jul 2019 13:59:22 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:38194 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbfGZR7W (ORCPT ); Fri, 26 Jul 2019 13:59:22 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id D02E28023F; Fri, 26 Jul 2019 19:59:07 +0200 (CEST) Date: Fri, 26 Jul 2019 19:59:17 +0200 From: Pavel Machek To: pavel@ucw.cz Cc: linux-kernel@vger.kernel.org, Kan Liang , "Peter Zijlstra (Intel)" , Linus Torvalds , Thomas Gleixner , acme@kernel.org, eranian@google.com, Ingo Molnar , Sasha Levin Subject: Re: [PATCH 4.19 078/271] perf/x86/intel/uncore: Handle invalid event coding for free-running counter Message-ID: <20190726175917.GC5945@xo-6d-61-c0.localdomain> References: <20190724191655.268628197@linuxfoundation.org> <20190724191701.880558315@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190724191701.880558315@linuxfoundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2019-07-24 21:19:07, Greg Kroah-Hartman wrote: > [ Upstream commit 543ac280b3576c0009e8c0fcd4d6bfc9978d7bd0 ] > > Counting with invalid event coding for free-running counter may cause > OOPs, e.g. uncore_iio_free_running_0/event=1/. > > Current code only validate the event with free-running event format, > event=0xff,umask=0xXY. Non-free-running event format never be checked > for the PMU with free-running counters. > > Add generic hw_config() to check and reject the invalid event coding > for free-running PMU. So this is interesting. "static inline", but it is never really inlined because the only use is for taking pointer. Best regards, Pavel > +++ b/arch/x86/events/intel/uncore.h > @@ -402,6 +402,16 @@ static inline bool is_freerunning_event(struct perf_event *event) > (((cfg >> 8) & 0xff) >= UNCORE_FREERUNNING_UMASK_START); > } > > +/* Check and reject invalid config */ > +static inline int uncore_freerunning_hw_config(struct intel_uncore_box *box, > + struct perf_event *event) > +{ > + if (is_freerunning_event(event)) > + return 0; > + > + return -EINVAL; > +} > + > static inline void uncore_disable_box(struct intel_uncore_box *box) > { > if (box->pmu->type->ops->disable_box) > diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c > index b10e04387f38..8e4e8e423839 100644 > --- a/arch/x86/events/intel/uncore_snbep.c > +++ b/arch/x86/events/intel/uncore_snbep.c > @@ -3585,6 +3585,7 @@ static struct uncore_event_desc skx_uncore_iio_freerunning_events[] = { > > static struct intel_uncore_ops skx_uncore_iio_freerunning_ops = { > .read_counter = uncore_msr_read_counter, > + .hw_config = uncore_freerunning_hw_config, > }; > > static struct attribute *skx_uncore_iio_freerunning_formats_attr[] = { > -- > 2.20.1 > > -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html