From owner-dev-commits-src-all@freebsd.org Wed Aug 4 18:24:31 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A8136653514; Wed, 4 Aug 2021 18:24:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gg0Wg3KRGz4hmq; Wed, 4 Aug 2021 18:24:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5B9123823; Wed, 4 Aug 2021 18:24:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 174IOVqd001467; Wed, 4 Aug 2021 18:24:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 174IOVtA001466; Wed, 4 Aug 2021 18:24:31 GMT (envelope-from git) Date: Wed, 4 Aug 2021 18:24:31 GMT Message-Id: <202108041824.174IOVtA001466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 4f35e8cba232 - main - hwpmc: disable uncore class on Sandy Bridge and newer MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f35e8cba232d9256ab1399b8adfb761988e5eff Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2021 18:24:31 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4f35e8cba232d9256ab1399b8adfb761988e5eff commit 4f35e8cba232d9256ab1399b8adfb761988e5eff Author: Mitchell Horne AuthorDate: 2021-08-04 17:31:36 +0000 Commit: Mitchell Horne CommitDate: 2021-08-04 18:23:22 +0000 hwpmc: disable uncore class on Sandy Bridge and newer It was written for Nehalem and Westmere, with minor but incomplete updates for Sandy Bridge in 78d763a29b15. The uncore architecture changed significantly with this generation, bringing new layouts and locations for some MSRs. Misprogramming these MSRs in ucp_start_pmc() may panic the system, and this is trivially reproducible via pmcstat(8) on at least Broadwell and Haswell. Disable the class on these CPUs until it can be updated more completely and leave a TODO comment detailing some of the work required. Note that the nclasses value for Broadwell was already incorrect and doesn't need changing. The result is that any uncore events listed by pmcstat -L will no longer be allocatable, but this is already the case for newer generations of Intel CPUs. PR: 253687 Reported by: Zhenlei Huang Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31389 --- sys/dev/hwpmc/hwpmc_intel.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c index aec037b64938..02b8fd9431d1 100644 --- a/sys/dev/hwpmc/hwpmc_intel.c +++ b/sys/dev/hwpmc/hwpmc_intel.c @@ -149,7 +149,7 @@ pmc_intel_initialize(void) break; case 0x2A: /* Per Intel document 253669-039US 05/2011. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE; - nclasses = 5; + nclasses = 3; break; case 0x2D: /* Per Intel document 253669-044US 08/2012. */ cputype = PMC_CPU_INTEL_SANDYBRIDGE_XEON; @@ -195,7 +195,7 @@ pmc_intel_initialize(void) case 0x3C: /* Per Intel document 325462-045US 01/2013. */ case 0x45: /* Per Intel document 325462-045US 09/2014. */ cputype = PMC_CPU_INTEL_HASWELL; - nclasses = 5; + nclasses = 3; break; case 0x37: case 0x4A: @@ -275,10 +275,27 @@ pmc_intel_initialize(void) * Intel Corei7 and Westmere processors. */ case PMC_CPU_INTEL_COREI7: - case PMC_CPU_INTEL_HASWELL: - case PMC_CPU_INTEL_SANDYBRIDGE: case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet + /* + * TODO: re-enable uncore class on these processors. + * + * The uncore unit was reworked beginning with Sandy Bridge, including + * the MSRs required to program it. In particular, we need to: + * - Parse the MSR_UNC_CBO_CONFIG MSR for number of C-box units in the + * system + * - Support reading and writing to ARB and C-box units, depending on + * the requested event + * - Create some kind of mapping between C-box <--> CPU + * + * Also TODO: support other later changes to these interfaces, to + * enable the uncore class on generations newer than Broadwell. + * Skylake+ appears to use newer addresses for the uncore MSRs. + */ + case PMC_CPU_INTEL_HASWELL: case PMC_CPU_INTEL_BROADWELL: + case PMC_CPU_INTEL_SANDYBRIDGE: +#endif error = pmc_uncore_initialize(pmc_mdep, ncpus); break; default: @@ -329,11 +346,13 @@ pmc_intel_finalize(struct pmc_mdep *md) * Uncore. */ switch (md->pmd_cputype) { - case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_COREI7: + case PMC_CPU_INTEL_WESTMERE: +#ifdef notyet case PMC_CPU_INTEL_HASWELL: + case PMC_CPU_INTEL_BROADWELL: case PMC_CPU_INTEL_SANDYBRIDGE: - case PMC_CPU_INTEL_WESTMERE: +#endif pmc_uncore_finalize(md); break; default: