From owner-svn-ports-all@FreeBSD.ORG Tue Apr 15 17:01:18 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A340DDCB; Tue, 15 Apr 2014 17:01:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 843481320; Tue, 15 Apr 2014 17:01:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3FH1I7s034337; Tue, 15 Apr 2014 17:01:18 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3FH1InP034335; Tue, 15 Apr 2014 17:01:18 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201404151701.s3FH1InP034335@svn.freebsd.org> From: Warner Losh Date: Tue, 15 Apr 2014 17:01:18 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r351350 - in head/sysutils/intel-pcm: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2014 17:01:18 -0000 Author: imp Date: Tue Apr 15 17:01:17 2014 New Revision: 351350 URL: http://svnweb.freebsd.org/changeset/ports/351350 QAT: https://qat.redports.org/buildarchive/r351350/ Log: Add a seat-belt safety check to make sure that cpuctl is loaded before using it. Otherwise, we can divide by zero with a semaphore held and it takes extraordinary measures to reset the semaphore... Submitted by: Jim Harris Added: head/sysutils/intel-pcm/files/patch-cpuctl_check (contents, props changed) Modified: head/sysutils/intel-pcm/Makefile Modified: head/sysutils/intel-pcm/Makefile ============================================================================== --- head/sysutils/intel-pcm/Makefile Tue Apr 15 17:00:35 2014 (r351349) +++ head/sysutils/intel-pcm/Makefile Tue Apr 15 17:01:17 2014 (r351350) @@ -3,7 +3,7 @@ PORTNAME= intel-pcm PORTVERSION= 2.6 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils MASTER_SITES= LOCAL/imp DISTNAME= intelperformancecountermonitorv${PORTVERSION} Added: head/sysutils/intel-pcm/files/patch-cpuctl_check ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/intel-pcm/files/patch-cpuctl_check Tue Apr 15 17:01:17 2014 (r351350) @@ -0,0 +1,60 @@ +commit f87e1f30a39055cdb3b10964a805a9b5e41e6a77 +Author: Jim Harris +Date: Mon Apr 14 22:59:44 2014 -0700 + + FreeBSD: ensure cpuctl(4) driver is loaded. + + Also do a couple of sanity checks on some of the apic cpuid parsing. + This just ensures we get a sensible error messages rather than an + FPE if some logic bug is found in the apic parsing code. + +diff --git cpucounters.cpp cpucounters.cpp +index df8a802..0a9fc26 100644 +--- cpucounters.cpp ++++ cpucounters.cpp +@@ -63,6 +63,8 @@ int convertUnknownToInt(size_t size, char* value); + #endif + + #if defined (__FreeBSD__) ++#include ++#include + #include + #include + #include +@@ -735,11 +737,23 @@ PCM::PCM() : + std::cerr << "Unable to get kern.smp.cpus from sysctl." << std::endl; + return; + } ++ ++ if (modfind("cpuctl") == -1) ++ { ++ std::cout << "cpuctl(4) not loaded." << std::endl; ++ return; ++ } + + do_cpuid(1, cpuid_args.data); + + apic_ids_per_package = (cpuid_args.data[1] & 0x00FF0000) >> 16; + ++ if (apic_ids_per_package == 0) ++ { ++ std::cout << "apic_ids_per_package == 0" << std::endl; ++ return; ++ } ++ + cpuid_count(0xb, 0x0, cpuid_args.data); + + if ((cpuid_args.data[2] & 0xFF00) == 0x100) +@@ -747,6 +761,12 @@ PCM::PCM() : + else + apic_ids_per_core = 1; + ++ if (apic_ids_per_core == 0) ++ { ++ std::cout << "apic_ids_per_core == 0" << std::endl; ++ return; ++ } ++ + for (int i = 0; i < num_cores; i++) + { + char cpuctl_name[64];