Module Name: src Committed By: msaitoh Date: Wed Jun 15 16:28:01 UTC 2022
Modified Files: src/usr.sbin/cpuctl/arch: i386.c Log Message: Modify output of CPUID Fn0000000a. old: cpu0: Perfmon-eax 0x8300805<VERSION=0x5,GPCounter=0x8,GPBitwidth=0x30> cpu0: Perfmon-eax 0x8300805<Vectorlen=0x8> cpu0: Perfmon-edx 0x8604<FixedFunc=0x4,FFBitwidth=0x30,ANYTHREADDEPR> new: cpu0: Perfmon: Ver. 5 cpu0: Perfmon: General: bitwidth 48, 8 counters cpu0: Perfmon: General: avail 0xff<CORECYCL,INST,REFCYCL,LLCREF,LLCMISS,BRINST> cpu0: Perfmon: General: avail 0xff<BRMISPR,TOPDOWNSLOT> cpu0: Perfmon: Fixed: bitwidth 48, 4 counters cpu0: Perfmon: Fixed: avail 0xf<INST,CLK_CORETHREAD,CLK_REF_TSC,TOPDOWNSLOT> To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/cpuctl/arch/i386.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/cpuctl/arch/i386.c diff -u src/usr.sbin/cpuctl/arch/i386.c:1.127 src/usr.sbin/cpuctl/arch/i386.c:1.128 --- src/usr.sbin/cpuctl/arch/i386.c:1.127 Sat Jan 29 08:20:45 2022 +++ src/usr.sbin/cpuctl/arch/i386.c Wed Jun 15 16:28:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: i386.c,v 1.127 2022/01/29 08:20:45 msaitoh Exp $ */ +/* $NetBSD: i386.c,v 1.128 2022/06/15 16:28:01 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: i386.c,v 1.127 2022/01/29 08:20:45 msaitoh Exp $"); +__RCSID("$NetBSD: i386.c,v 1.128 2022/06/15 16:28:01 msaitoh Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -2249,13 +2249,48 @@ identifycpu(int fd, const char *cpuname) } } else if (cpu_vendor == CPUVENDOR_INTEL) { if (ci->ci_max_cpuid >= 0x0a) { + unsigned int pmcver, ncounter, veclen; + x86_cpuid(0x0a, descs); - print_bits(cpuname, "Perfmon-eax", - CPUID_PERF_FLAGS0, descs[0]); - print_bits(cpuname, "Perfmon-ebx", + pmcver = __SHIFTOUT(descs[0], CPUID_PERF_VERSION); + ncounter = __SHIFTOUT(descs[0], CPUID_PERF_NGPPC); + veclen = __SHIFTOUT(descs[0], CPUID_PERF_BVECLEN); + aprint_verbose("%s: Perfmon: Ver. %u", + cpuname, pmcver); + if (((pmcver >= 3) && (pmcver <= 4)) || + ((pmcver >= 5) && + (descs[3] & CPUID_PERF_ANYTHREADDEPR) == 0)) + aprint_verbose(" <ANYTHREAD>\n"); + else + aprint_verbose("\n"); + + aprint_verbose("%s: Perfmon: General: " + "bitwidth %u, %u counters\n", cpuname, + (uint32_t)__SHIFTOUT(descs[0], CPUID_PERF_NBWGPPC), + ncounter); + /* Invert logic for the output */ + descs[1] ^= __BITS(veclen - 1, 0); + /* + * Mask unrelated bits. An hypervisor reduces the + * vector and set bit(s) out of the vector. + */ + descs[1] &= __BITS(veclen - 1, 0); + print_bits(cpuname, "Perfmon: General: avail", CPUID_PERF_FLAGS1, descs[1]); - print_bits(cpuname, "Perfmon-edx", - CPUID_PERF_FLAGS3, descs[3]); + + if (pmcver >= 2) { + ncounter = __SHIFTOUT(descs[3], + CPUID_PERF_NFFPC); + aprint_verbose("%s: Perfmon: Fixed: " + "bitwidth %u, %u counters\n", cpuname, + (uint32_t)__SHIFTOUT(descs[3], + CPUID_PERF_NBWFFPC), + ncounter); + if (pmcver <= 4) + descs[2] = __BITS(ncounter - 1, 0); + print_bits(cpuname, "Perfmon: Fixed: avail", + CPUID_PERF_FLAGS2, descs[2]); + } } if (ci->ci_max_cpuid >= 0x1a) { x86_cpuid(0x1a, descs);