From owner-svn-src-stable@freebsd.org Tue Jul 28 02:53:46 2020 Return-Path: Delivered-To: svn-src-stable@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 4F60D37911A; Tue, 28 Jul 2020 02:53:46 +0000 (UTC) (envelope-from freqlabs@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BG1TQ1V6Nz3Sfn; Tue, 28 Jul 2020 02:53:46 +0000 (UTC) (envelope-from freqlabs@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 169CB27DFE; Tue, 28 Jul 2020 02:53:46 +0000 (UTC) (envelope-from freqlabs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06S2rjtF040047; Tue, 28 Jul 2020 02:53:45 GMT (envelope-from freqlabs@FreeBSD.org) Received: (from freqlabs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06S2rjrq040043; Tue, 28 Jul 2020 02:53:45 GMT (envelope-from freqlabs@FreeBSD.org) Message-Id: <202007280253.06S2rjrq040043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: freqlabs set sender to freqlabs@FreeBSD.org using -f From: Ryan Moeller Date: Tue, 28 Jul 2020 02:53:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r363629 - in stable/12/sys: dev/coretemp dev/hwpmc x86/include X-SVN-Group: stable-12 X-SVN-Commit-Author: freqlabs X-SVN-Commit-Paths: in stable/12/sys: dev/coretemp dev/hwpmc x86/include X-SVN-Commit-Revision: 363629 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jul 2020 02:53:46 -0000 Author: freqlabs Date: Tue Jul 28 02:53:44 2020 New Revision: 363629 URL: https://svnweb.freebsd.org/changeset/base/363629 Log: MFC r363206: hwpmc: Always set pmc_cpuid to something pmc_cpuid was uninitialized for most AMD processor families. We can still populate this string for unimplemented families. Also added a CPUID_TO_STEPPING macro and converted existing code to use it. Reviewed by: mav Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25673 Modified: stable/12/sys/dev/coretemp/coretemp.c stable/12/sys/dev/hwpmc/hwpmc_amd.c stable/12/sys/dev/hwpmc/hwpmc_intel.c stable/12/sys/x86/include/specialreg.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/coretemp/coretemp.c ============================================================================== --- stable/12/sys/dev/coretemp/coretemp.c Tue Jul 28 01:05:40 2020 (r363628) +++ stable/12/sys/dev/coretemp/coretemp.c Tue Jul 28 02:53:44 2020 (r363629) @@ -165,7 +165,7 @@ coretemp_attach(device_t dev) sc->sc_dev = dev; pdev = device_get_parent(dev); cpu_model = CPUID_TO_MODEL(cpu_id); - cpu_stepping = cpu_id & CPUID_STEPPING; + cpu_stepping = CPUID_TO_STEPPING(cpu_id); /* * Some CPUs, namely the PIII, don't have thermal sensors, but Modified: stable/12/sys/dev/hwpmc/hwpmc_amd.c ============================================================================== --- stable/12/sys/dev/hwpmc/hwpmc_amd.c Tue Jul 28 01:05:40 2020 (r363628) +++ stable/12/sys/dev/hwpmc/hwpmc_amd.c Tue Jul 28 02:53:44 2020 (r363629) @@ -1073,7 +1073,7 @@ pmc_amd_initialize(void) enum pmc_cputype cputype; struct pmc_mdep *pmc_mdep; enum pmc_class class; - int model, stepping; + int family, model, stepping; char *name; /* @@ -1085,14 +1085,16 @@ pmc_amd_initialize(void) */ name = NULL; - model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); - stepping = cpu_id & 0xF; - if (CPUID_TO_FAMILY(cpu_id) == 0x17) - snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X-%X", - CPUID_TO_FAMILY(cpu_id), model, stepping); - if (CPUID_TO_FAMILY(cpu_id) == 0x18) + family = CPUID_TO_FAMILY(cpu_id); + model = CPUID_TO_MODEL(cpu_id); + stepping = CPUID_TO_STEPPING(cpu_id); + + if (family == 0x18) snprintf(pmc_cpuid, sizeof(pmc_cpuid), "HygonGenuine-%d-%02X-%X", - CPUID_TO_FAMILY(cpu_id), model, stepping); + family, model, stepping); + else + snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X-%X", + family, model, stepping); switch (cpu_id & 0xF00) { #if defined(__i386__) Modified: stable/12/sys/dev/hwpmc/hwpmc_intel.c ============================================================================== --- stable/12/sys/dev/hwpmc/hwpmc_intel.c Tue Jul 28 01:05:40 2020 (r363628) +++ stable/12/sys/dev/hwpmc/hwpmc_intel.c Tue Jul 28 02:53:44 2020 (r363629) @@ -80,7 +80,7 @@ pmc_intel_initialize(void) { struct pmc_mdep *pmc_mdep; enum pmc_cputype cputype; - int error, model, nclasses, ncpus, stepping, verov; + int error, family, model, nclasses, ncpus, stepping, verov; KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL, ("[intel,%d] Initializing non-intel processor", __LINE__)); @@ -91,11 +91,13 @@ pmc_intel_initialize(void) nclasses = 2; error = 0; verov = 0; - model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); - stepping = cpu_id & 0xF; + family = CPUID_TO_FAMILY(cpu_id); + model = CPUID_TO_MODEL(cpu_id); + stepping = CPUID_TO_STEPPING(cpu_id); snprintf(pmc_cpuid, sizeof(pmc_cpuid), "GenuineIntel-%d-%02X-%X", - (cpu_id & 0xF00) >> 8, model, stepping); + family, model, stepping); + switch (cpu_id & 0xF00) { case 0x600: /* Pentium Pro, Celeron, Pentium II & III */ switch (model) { Modified: stable/12/sys/x86/include/specialreg.h ============================================================================== --- stable/12/sys/x86/include/specialreg.h Tue Jul 28 01:05:40 2020 (r363628) +++ stable/12/sys/x86/include/specialreg.h Tue Jul 28 02:53:44 2020 (r363629) @@ -293,6 +293,7 @@ ((((id) & CPUID_FAMILY) >> 8) + \ (((id) & CPUID_EXT_FAMILY) >> 20)) #endif +#define CPUID_TO_STEPPING(id) ((id) & CPUID_STEPPING) /* * CPUID instruction 1 ebx info