Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6903976rdb; Tue, 2 Jan 2024 19:10:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKSp6nVyHh1T0OZPCHIokqB8SGPzkJ7EO8zFgascOXB3L4qDypHP3IgBDEw/D3RTgLtykC X-Received: by 2002:a17:902:6807:b0:1d4:4b09:6b69 with SMTP id h7-20020a170902680700b001d44b096b69mr14656497plk.137.1704251443015; Tue, 02 Jan 2024 19:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704251443; cv=none; d=google.com; s=arc-20160816; b=qA0XXTLDw/DDrl6ZlfvEXSpGPiWUP9eAKKVMHZTdRcp9nIq2FOiTxqv4Kfw4iWoRLi pMBlRfQ0MPdwfPeEN9HEW9wILaaPSu3a9jriq4yfTbANCrRR1z6FxrswUCCo3hiNisMX FMaS+ZISulH8v5Gy0bIpT1T2yWp6patzn9gYlZHzmKiyGGC2dgGfGUk0mi1rYwb/oe5E jR9ghHXv9c++0eibePXEFyKK5Z9THd5cWaMk6KVP0MkRSkod7hWm9soyq+7xZUCGzR6p rolcmfvyR0RuFioUMUz5G25+Zx629Oqcn7pQW6tA1Maq6gR3bO5UaOsl3U3qr4x3tPaW w92w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iHl0PqGfnstcGQ/mqAQ/a2TEN85mgw2O/ElQI70b8MI=; fh=YsfTl7qN5yLiZ/GhYjuBdDgWBv8FNcMbD5266uBeHkY=; b=qrQqaTcM0aPvxtXzqBrggG1MfAX3TJkXHpVj09v7zimYkD78cT0nCxlBPt7IoFdT+2 kFovFCYOT1klDNRlTblc70qhHGLFQreWe0rOfvdHWgJKyGhJYUtnZRfNuRUHd6eSb3aw mFAHzovs/UO5SVbZRq59YreSrnA5g4QTTAjkuU535KD8j+uhC03JtBdUGwXvnUbXf+6c 8f59td9cTY39vGVT+4SBmIUUdKXyxlF+ledyr9xoxroMuw38u3BXnFzg/ywCo8K6aIsq qdtw37uTN91BM34umTjQeR8jRNFIEVWASn/G5mXEYNnptBxrRV3PWn1SrZbTvyUkEdF5 uHmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EF1M32V1; spf=pass (google.com: domain of linux-kernel+bounces-15117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v19-20020a17090abb9300b0028bd757ba37si477122pjr.6.2024.01.02.19.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 19:10:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EF1M32V1; spf=pass (google.com: domain of linux-kernel+bounces-15117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2EC68B21987 for ; Wed, 3 Jan 2024 03:10:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F368182B6; Wed, 3 Jan 2024 03:09:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EF1M32V1" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53F3018050; Wed, 3 Jan 2024 03:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704251378; x=1735787378; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kfSCHGv/CfTNu74cuaUBe9OREwyoA2RBsBWS61xedrk=; b=EF1M32V11YXtj4z32ZUgMykRigj3I3rCzWbJPfOhoOXjOo3vSpJWTXQO g/UNX/fuaOwBOGLdNeaXI8CEePum9Bv5snsDEYT3pBmTitFu221rljvCl j01m1ikEgrZbVimS+4wPFEQYdCqFsHt0TH5P1UHEItBU/lyme3NiQcfNT Guf/+dNKdm2k5Qzsq92pcXuqMo/2He0hZX8SsP2ARKVoCLyfpnIC7gfRm hb3HtI+lfkwbZOpXiWWTaREzROa1M9iy3ks7Xuin+hdBNd/T2UhFitANu qUzMc1Gl5NJ3Y8jAeOcAMm2fbY4nndRc9/shuSwidT2gY71iMeXPPmeQq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="10343125" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="10343125" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 19:09:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="729665921" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="729665921" Received: from dmi-pnp-i7.sh.intel.com ([10.239.159.155]) by orsmga003.jf.intel.com with ESMTP; 02 Jan 2024 19:09:33 -0800 From: Dapeng Mi To: Sean Christopherson , Paolo Bonzini , Jim Mattson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang , Zhang Xiong , Mingwei Zhang , Like Xu , Jinrong Liang , Dapeng Mi , Dapeng Mi Subject: [kvm-unit-tests Patch v3 02/11] x86: pmu: Enlarge cnt[] length to 64 in check_counters_many() Date: Wed, 3 Jan 2024 11:14:00 +0800 Message-Id: <20240103031409.2504051-3-dapeng1.mi@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240103031409.2504051-1-dapeng1.mi@linux.intel.com> References: <20240103031409.2504051-1-dapeng1.mi@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Considering there are already 8 GP counters and 4 fixed counters on latest Intel processors, like Sapphire Rapids. The original cnt[] array length 10 is definitely not enough to cover all supported PMU counters on these new processors even through currently KVM only supports 3 fixed counters at most. This would cause out of bound memory access and may trigger false alarm on PMU counter validation It's probably more and more GP and fixed counters are introduced in the future and then directly extends the cnt[] array length to 64 once and for all. Signed-off-by: Dapeng Mi --- x86/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/pmu.c b/x86/pmu.c index 0def28695c70..a13b8a8398c6 100644 --- a/x86/pmu.c +++ b/x86/pmu.c @@ -254,7 +254,7 @@ static void check_fixed_counters(void) static void check_counters_many(void) { - pmu_counter_t cnt[10]; + pmu_counter_t cnt[64]; int i, n; for (i = 0, n = 0; n < pmu.nr_gp_counters; i++) { -- 2.34.1