Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbcD0Jhd (ORCPT ); Wed, 27 Apr 2016 05:37:33 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:42538 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbcD0Jh0 (ORCPT ); Wed, 27 Apr 2016 05:37:26 -0400 From: Adam Borowski To: Ingo Molnar , linux-kernel@vger.kernel.org, Stephane Eranian , Peter Zijlstra , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, Borislav Petkov Cc: Adam Borowski Date: Wed, 27 Apr 2016 11:35:31 +0200 Message-Id: <1461749731-30979-1-git-send-email-kilobyte@angband.pl> X-Mailer: git-send-email 2.8.1 In-Reply-To: <20160427093251.GA13534@angband.pl> References: <20160427093251.GA13534@angband.pl> X-SA-Exim-Connect-IP: 2001:6a0:118::6 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH] perf/x86/amd: Set the size of event map array to PERF_COUNT_HW_MAX. X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1046 Lines: 30 The entry for PERF_COUNT_HW_REF_CPU_CYCLES is not used on AMD, but is referenced by filter_events() which expects undefined events to have a value of 0. 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 --- arch/x86/events/amd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index 86a9bec..bd3e842 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -115,7 +115,7 @@ static __initconst const u64 amd_hw_cache_event_ids /* * AMD Performance Monitor K7 and later. */ -static const u64 amd_perfmon_event_map[] = +static const u64 amd_perfmon_event_map[PERF_COUNT_HW_MAX] = { [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, -- 2.8.1