[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160427080345.GB16991@gmail.com>
Date: Wed, 27 Apr 2016 10:03:45 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Adam Borowski <kilobyte@...band.pl>
Cc: linux-kernel@...r.kernel.org,
Stephane Eranian <eranian@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Borislav Petkov <bp@...e.de>
Subject: Re: [PATCH] perf/x86/amd: Explicitly define
PERF_COUNT_HW_REF_CPU_CYCLES as undefined.
* Adam Borowski <kilobyte@...band.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@...band.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
Powered by blists - more mailing lists