All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Adam Borowski <kilobyte@angband.pl>
Cc: linux-kernel@vger.kernel.org,
	Stephane Eranian <eranian@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Borislav Petkov <bp@suse.de>
Subject: Re: [PATCH] perf/x86/amd: Explicitly define PERF_COUNT_HW_REF_CPU_CYCLES as undefined.
Date: Wed, 27 Apr 2016 10:03:45 +0200	[thread overview]
Message-ID: <20160427080345.GB16991@gmail.com> (raw)
In-Reply-To: <1461719993-12461-1-git-send-email-kilobyte@angband.pl>


* Adam Borowski <kilobyte@angband.pl> wrote:

> filter_events() relies on the value of 0 to remove events that are not
> applicable, like this one.
> 
> UBSAN: Undefined behaviour in arch/x86/events/amd/core.c:132:30
> index 9 is out of range for type 'u64 [9]'
> UBSAN: Undefined behaviour in arch/x86/events/amd/core.c:132:9
> load of address ffffffff81c021c8 with insufficient space
> for an object of type 'const u64'
> 
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
>  arch/x86/events/amd/core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
> index 86a9bec..5fa1b8e 100644
> --- a/arch/x86/events/amd/core.c
> +++ b/arch/x86/events/amd/core.c
> @@ -125,6 +125,7 @@ static const u64 amd_perfmon_event_map[] =
>    [PERF_COUNT_HW_BRANCH_MISSES]			= 0x00c3,
>    [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND]	= 0x00d0, /* "Decoder empty" event */
>    [PERF_COUNT_HW_STALLED_CYCLES_BACKEND]	= 0x00d1, /* "Dispatch stalls" event */
> +  [PERF_COUNT_HW_REF_CPU_CYCLES]		=      0,
>  };

Hm, I think it would be cleaner and more robust to change this (and all other 
similar, if any) arrays to [PERF_COUNT_HW_MAX] instead.

Thanks,

	Ingo

  reply	other threads:[~2016-04-27  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27  1:19 [PATCH] perf/x86/amd: Explicitly define PERF_COUNT_HW_REF_CPU_CYCLES as undefined Adam Borowski
2016-04-27  8:03 ` Ingo Molnar [this message]
2016-04-27  9:32   ` Adam Borowski
2016-04-27  9:35     ` [PATCH] perf/x86/amd: Set the size of event map array to PERF_COUNT_HW_MAX Adam Borowski
2016-04-28  8:24       ` [tip:perf/urgent] " tip-bot for Adam Borowski

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=20160427080345.GB16991@gmail.com \
    --to=mingo@kernel.org \
    --cc=bp@suse.de \
    --cc=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.