From owner-svn-src-all@freebsd.org Fri Oct 7 19:28:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3541C05425; Fri, 7 Oct 2016 19:28:46 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A48C6FE5; Fri, 7 Oct 2016 19:28:46 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u97JSjis078656; Fri, 7 Oct 2016 19:28:45 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u97JSjb9078653; Fri, 7 Oct 2016 19:28:45 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201610071928.u97JSjb9078653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Fri, 7 Oct 2016 19:28:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306824 - stable/10/sys/dev/hwpmc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2016 19:28:47 -0000 Author: julian Date: Fri Oct 7 19:28:45 2016 New Revision: 306824 URL: https://svnweb.freebsd.org/changeset/base/306824 Log: MFH: r259647 o Remove assertions on ipa_version as sometimes the version detection using cpuid can be quirky (this is the case of VMWare without the vPMC support) but fail to probe hwpmc. o Apply the fix for XEON family of processors as established by 315338-020 document (bug AJ85). Sponsored by: EMC / Isilon storage division Reviewed by: fabient MFC courtesy of panzura. Modified: stable/10/sys/dev/hwpmc/hwpmc_core.c stable/10/sys/dev/hwpmc/hwpmc_core.h stable/10/sys/dev/hwpmc/hwpmc_intel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- stable/10/sys/dev/hwpmc/hwpmc_core.c Fri Oct 7 19:13:29 2016 (r306823) +++ stable/10/sys/dev/hwpmc/hwpmc_core.c Fri Oct 7 19:28:45 2016 (r306824) @@ -2723,35 +2723,33 @@ core2_intr(int cpu, struct trapframe *tf } int -pmc_core_initialize(struct pmc_mdep *md, int maxcpu) +pmc_core_initialize(struct pmc_mdep *md, int maxcpu, int version_override) { int cpuid[CORE_CPUID_REQUEST_SIZE]; int ipa_version, flags, nflags; do_cpuid(CORE_CPUID_REQUEST, cpuid); - ipa_version = cpuid[CORE_CPUID_EAX] & 0xFF; + ipa_version = (version_override > 0) ? version_override : + cpuid[CORE_CPUID_EAX] & 0xFF; + core_cputype = md->pmd_cputype; PMCDBG3(MDP,INI,1,"core-init cputype=%d ncpu=%d ipa-version=%d", - md->pmd_cputype, maxcpu, ipa_version); + core_cputype, maxcpu, ipa_version); - if (ipa_version < 1 || ipa_version > 3) { + if (ipa_version < 1 || ipa_version > 3 || + (core_cputype != PMC_CPU_INTEL_CORE && ipa_version == 1)) { /* Unknown PMC architecture. */ printf("hwpc_core: unknown PMC architecture: %d\n", ipa_version); return (EPROGMISMATCH); } - core_cputype = md->pmd_cputype; - core_pmcmask = 0; /* * Initialize programmable counters. */ - KASSERT(ipa_version >= 1, - ("[core,%d] ipa_version %d too small", __LINE__, ipa_version)); - core_iap_npmc = (cpuid[CORE_CPUID_EAX] >> 8) & 0xFF; core_iap_width = (cpuid[CORE_CPUID_EAX] >> 16) & 0xFF; @@ -2766,10 +2764,6 @@ pmc_core_initialize(struct pmc_mdep *md, * Initialize fixed function counters, if present. */ if (core_cputype != PMC_CPU_INTEL_CORE) { - KASSERT(ipa_version >= 2, - ("[core,%d] ipa_version %d too small", __LINE__, - ipa_version)); - core_iaf_ri = core_iap_npmc; core_iaf_npmc = cpuid[CORE_CPUID_EDX] & 0x1F; core_iaf_width = (cpuid[CORE_CPUID_EDX] >> 5) & 0xFF; Modified: stable/10/sys/dev/hwpmc/hwpmc_core.h ============================================================================== --- stable/10/sys/dev/hwpmc/hwpmc_core.h Fri Oct 7 19:13:29 2016 (r306823) +++ stable/10/sys/dev/hwpmc/hwpmc_core.h Fri Oct 7 19:28:45 2016 (r306824) @@ -175,7 +175,8 @@ struct pmc_md_iap_pmc { * Prototypes. */ -int pmc_core_initialize(struct pmc_mdep *_md, int _maxcpu); +int pmc_core_initialize(struct pmc_mdep *_md, int _maxcpu, + int _version_override); void pmc_core_finalize(struct pmc_mdep *_md); int pmc_iaf_initialize(struct pmc_mdep *_md, int _maxcpu, int _npmc, int _width); Modified: stable/10/sys/dev/hwpmc/hwpmc_intel.c ============================================================================== --- stable/10/sys/dev/hwpmc/hwpmc_intel.c Fri Oct 7 19:13:29 2016 (r306823) +++ stable/10/sys/dev/hwpmc/hwpmc_intel.c Fri Oct 7 19:28:45 2016 (r306824) @@ -78,7 +78,7 @@ pmc_intel_initialize(void) { struct pmc_mdep *pmc_mdep; enum pmc_cputype cputype; - int error, model, nclasses, ncpus; + int error, model, nclasses, ncpus, stepping, verov; KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL, ("[intel,%d] Initializing non-intel processor", __LINE__)); @@ -88,7 +88,9 @@ pmc_intel_initialize(void) cputype = -1; nclasses = 2; error = 0; + verov = 0; model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); + stepping = cpu_id & 0xF; switch (cpu_id & 0xF00) { #if defined(__i386__) @@ -119,8 +121,14 @@ pmc_intel_initialize(void) cputype = PMC_CPU_INTEL_CORE; break; case 0xF: - cputype = PMC_CPU_INTEL_CORE2; - nclasses = 3; + /* Per Intel document 315338-020. */ + if (stepping == 0x7) { + cputype = PMC_CPU_INTEL_CORE; + verov = 1; + } else { + cputype = PMC_CPU_INTEL_CORE2; + nclasses = 3; + } break; case 0x17: cputype = PMC_CPU_INTEL_CORE2EXTREME; @@ -232,7 +240,7 @@ pmc_intel_initialize(void) case PMC_CPU_INTEL_IVYBRIDGE_XEON: case PMC_CPU_INTEL_HASWELL: case PMC_CPU_INTEL_HASWELL_XEON: - error = pmc_core_initialize(pmc_mdep, ncpus); + error = pmc_core_initialize(pmc_mdep, ncpus, verov); break; /*