public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Meelis Roos <mroos@linux.ee>, LKML <linux-kernel@vger.kernel.org>,
	x86@kernel.org, Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:116:29
Date: Wed, 4 Dec 2019 16:44:24 +0100	[thread overview]
Message-ID: <20191204154424.GA2810@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191204152444.GA15573@krava>

On Wed, Dec 04, 2019 at 04:24:44PM +0100, Jiri Olsa wrote:

> > diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> > index 9a89d98c55bd..f17417644665 100644
> > --- a/arch/x86/events/core.c
> > +++ b/arch/x86/events/core.c
> > @@ -1642,9 +1643,12 @@ static struct attribute_group x86_pmu_format_group __ro_after_init = {
> >  
> >  ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page)
> >  {
> > -	struct perf_pmu_events_attr *pmu_attr = \
> > +	struct perf_pmu_events_attr *pmu_attr =
> 
> ugh, did this do something weird? ;-)

No, but it's weird to explicitly concat the line outside of a macro, so
if 'fixed' it.

> >  		container_of(attr, struct perf_pmu_events_attr, attr);
> > -	u64 config = x86_pmu.event_map(pmu_attr->id);
> > +	u64 config = 0;
> > +
> > +	if (pmu_attr->id < x86_pmu.max_events)
> > +		x86_pmu.event_map(pmu_attr->id);
> 
> hum, should this be assigned to config?
> 
> 		config = x86_pmu.event_map(pmu_attr->id);

D'oh... Yes.

> >  
> >  	/* string trumps id */
> >  	if (pmu_attr->event_str)

  reply	other threads:[~2019-12-04 15:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 17:55 UBSAN: Undefined behaviour in arch/x86/events/intel/p6.c:116:29 Meelis Roos
2019-12-02 17:06 ` Peter Zijlstra
2019-12-03 13:39   ` Meelis Roos
2019-12-04 12:15     ` Jiri Olsa
2019-12-04 15:06       ` Peter Zijlstra
2019-12-04 15:24         ` Jiri Olsa
2019-12-04 15:44           ` Peter Zijlstra [this message]
2019-12-04 19:47         ` Meelis Roos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191204154424.GA2810@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mroos@linux.ee \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox