[kvm-unit-tests,v3,02/11] x86: pmu: Enlarge cnt[] length to 64 in check_counters_many()
Message ID | 20240103031409.2504051-3-dapeng1.mi@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-15117-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4806025dyb; Tue, 2 Jan 2024 19:10:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUcir1LSMSgH//nFoXGLzfs+k6LDaSR0kf7wjsdNH30SlD4rycaxZjgvaH4rCFN1EJp1Er X-Received: by 2002:a05:620a:47ed:b0:781:5f1e:4158 with SMTP id du45-20020a05620a47ed00b007815f1e4158mr9348706qkb.64.1704251443820; 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=vQweI1d1ve/y6Xi406sfvD7x9NEYPQp3cyO0nJRm0XkUqxQ/Liy74Dw+x6W8AM7lI/ +0vuIYrlrUGa2WKwezfV7nuCNMMoNIUvhFUzu5B6IuoBSLV+PEPWSfNtrae739JuZceg lZ0cJRARk2UvexMPFbhkPcXUo3n3OI0YzXrs4OpZJ5tZB+QWYsL6XvZQEnFkdPJM3SWm gJ4DXLxA+S76OgVYvAipNMy2bsWnwhZPmar0H7n3KFz8wMf2Tpz2doUFAjdt2kSIRUtm wwZItXbGE2zBhJNIVX4HZO7USIhAkujSdrkuF14FoXyP3FPE27miY7OrQ2V6waBFcbzM OS8w== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15117-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id tz13-20020a05620a690d00b007811cc47b86si30327371qkn.617.2024.01.02.19.10.43 for <ouuuleilei@gmail.com> (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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15117-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A4B91C20CFB for <ouuuleilei@gmail.com>; Wed, 3 Jan 2024 03:10:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31A0918625; Wed, 3 Jan 2024 03:09:41 +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 <dapeng1.mi@linux.intel.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Jim Mattson <jmattson@google.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhenyu Wang <zhenyuw@linux.intel.com>, Zhang Xiong <xiong.y.zhang@intel.com>, Mingwei Zhang <mizhang@google.com>, Like Xu <like.xu.linux@gmail.com>, Jinrong Liang <cloudliang@tencent.com>, Dapeng Mi <dapeng1.mi@intel.com>, Dapeng Mi <dapeng1.mi@linux.intel.com> 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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787037161913547847 X-GMAIL-MSGID: 1787037161913547847 |
Series |
pmu test bugs fix and improvements
|
|
Commit Message
Mi, Dapeng
Jan. 3, 2024, 3:14 a.m. UTC
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 <dapeng1.mi@linux.intel.com>
---
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++) {