Home | History | Annotate | Line # | Download | only in arch
i386.c revision 1.133.2.1
      1  1.133.2.1    martin /*	$NetBSD: i386.c,v 1.133.2.1 2023/01/23 12:54:14 martin Exp $	*/
      2        1.1        ad 
      3        1.1        ad /*-
      4        1.1        ad  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
      5        1.1        ad  * All rights reserved.
      6        1.1        ad  *
      7        1.1        ad  * This code is derived from software contributed to The NetBSD Foundation
      8        1.1        ad  * by Frank van der Linden,  and by Jason R. Thorpe.
      9        1.1        ad  *
     10        1.1        ad  * Redistribution and use in source and binary forms, with or without
     11        1.1        ad  * modification, are permitted provided that the following conditions
     12        1.1        ad  * are met:
     13        1.1        ad  * 1. Redistributions of source code must retain the above copyright
     14        1.1        ad  *    notice, this list of conditions and the following disclaimer.
     15        1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     17        1.1        ad  *    documentation and/or other materials provided with the distribution.
     18        1.1        ad  *
     19        1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20        1.1        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21        1.1        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22        1.1        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23        1.1        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24        1.1        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25        1.1        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26        1.1        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27        1.1        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28        1.1        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29        1.1        ad  * POSSIBILITY OF SUCH DAMAGE.
     30        1.1        ad  */
     31        1.1        ad 
     32        1.1        ad /*-
     33        1.1        ad  * Copyright (c)2008 YAMAMOTO Takashi,
     34        1.1        ad  * All rights reserved.
     35        1.1        ad  *
     36        1.1        ad  * Redistribution and use in source and binary forms, with or without
     37        1.1        ad  * modification, are permitted provided that the following conditions
     38        1.1        ad  * are met:
     39        1.1        ad  * 1. Redistributions of source code must retain the above copyright
     40        1.1        ad  *    notice, this list of conditions and the following disclaimer.
     41        1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     42        1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     43        1.1        ad  *    documentation and/or other materials provided with the distribution.
     44        1.1        ad  *
     45        1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     46        1.1        ad  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     47        1.1        ad  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     48        1.1        ad  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     49        1.1        ad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     50        1.1        ad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     51        1.1        ad  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     52        1.1        ad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     53        1.1        ad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     54        1.1        ad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     55        1.1        ad  * SUCH DAMAGE.
     56        1.1        ad  */
     57        1.1        ad 
     58        1.1        ad #include <sys/cdefs.h>
     59        1.1        ad #ifndef lint
     60  1.133.2.1    martin __RCSID("$NetBSD: i386.c,v 1.133.2.1 2023/01/23 12:54:14 martin Exp $");
     61        1.1        ad #endif /* not lint */
     62        1.1        ad 
     63        1.1        ad #include <sys/types.h>
     64        1.1        ad #include <sys/param.h>
     65        1.1        ad #include <sys/bitops.h>
     66        1.1        ad #include <sys/sysctl.h>
     67       1.33       dsl #include <sys/ioctl.h>
     68       1.32  drochner #include <sys/cpuio.h>
     69        1.1        ad 
     70       1.35       dsl #include <errno.h>
     71        1.1        ad #include <string.h>
     72        1.1        ad #include <stdio.h>
     73        1.1        ad #include <stdlib.h>
     74        1.1        ad #include <err.h>
     75        1.1        ad #include <assert.h>
     76        1.1        ad #include <math.h>
     77       1.14  christos #include <util.h>
     78        1.1        ad 
     79        1.1        ad #include <machine/specialreg.h>
     80        1.1        ad #include <machine/cpu.h>
     81        1.1        ad 
     82        1.1        ad #include <x86/cpuvar.h>
     83        1.1        ad #include <x86/cputypes.h>
     84       1.32  drochner #include <x86/cpu_ucode.h>
     85        1.1        ad 
     86        1.1        ad #include "../cpuctl.h"
     87       1.34       dsl #include "cpuctl_i386.h"
     88        1.1        ad 
     89        1.7  christos /* Size of buffer for printing humanized numbers */
     90       1.16   tsutsui #define HUMAN_BUFSIZE sizeof("999KB")
     91        1.7  christos 
     92        1.1        ad struct cpu_nocpuid_nameclass {
     93        1.1        ad 	int cpu_vendor;
     94        1.1        ad 	const char *cpu_vendorname;
     95        1.1        ad 	const char *cpu_name;
     96        1.1        ad 	int cpu_class;
     97        1.1        ad 	void (*cpu_setup)(struct cpu_info *);
     98        1.1        ad 	void (*cpu_cacheinfo)(struct cpu_info *);
     99        1.1        ad 	void (*cpu_info)(struct cpu_info *);
    100        1.1        ad };
    101        1.1        ad 
    102        1.1        ad struct cpu_cpuid_nameclass {
    103        1.1        ad 	const char *cpu_id;
    104        1.1        ad 	int cpu_vendor;
    105        1.1        ad 	const char *cpu_vendorname;
    106        1.1        ad 	struct cpu_cpuid_family {
    107        1.1        ad 		int cpu_class;
    108       1.37       dsl 		const char *cpu_models[256];
    109       1.37       dsl 		const char *cpu_model_default;
    110        1.1        ad 		void (*cpu_setup)(struct cpu_info *);
    111        1.1        ad 		void (*cpu_probe)(struct cpu_info *);
    112        1.1        ad 		void (*cpu_info)(struct cpu_info *);
    113        1.1        ad 	} cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1];
    114        1.1        ad };
    115        1.1        ad 
    116        1.7  christos static const struct x86_cache_info intel_cpuid_cache_info[] = INTEL_CACHE_INFO;
    117        1.1        ad 
    118        1.1        ad /*
    119        1.1        ad  * Map Brand ID from cpuid instruction to brand name.
    120       1.41   msaitoh  * Source: Table 3-24, Mapping of Brand Indices; and Intel 64 and IA-32
    121       1.41   msaitoh  * Processor Brand Strings, Chapter 3 in "Intel (R) 64 and IA-32
    122       1.41   msaitoh  * Architectures Software Developer's Manual, Volume 2A".
    123        1.1        ad  */
    124        1.1        ad static const char * const i386_intel_brand[] = {
    125        1.1        ad 	"",		    /* Unsupported */
    126        1.1        ad 	"Celeron",	    /* Intel (R) Celeron (TM) processor */
    127       1.85   msaitoh 	"Pentium III",	    /* Intel (R) Pentium (R) III processor */
    128        1.1        ad 	"Pentium III Xeon", /* Intel (R) Pentium (R) III Xeon (TM) processor */
    129       1.85   msaitoh 	"Pentium III",	    /* Intel (R) Pentium (R) III processor */
    130       1.41   msaitoh 	"",		    /* 0x05: Reserved */
    131       1.71   msaitoh 	"Mobile Pentium III",/* Mobile Intel (R) Pentium (R) III processor-M */
    132      1.103   msaitoh 	"Mobile Celeron",   /* Mobile Intel (R) Celeron (R) processor */
    133        1.1        ad 	"Pentium 4",	    /* Intel (R) Pentium (R) 4 processor */
    134        1.1        ad 	"Pentium 4",	    /* Intel (R) Pentium (R) 4 processor */
    135        1.1        ad 	"Celeron",	    /* Intel (R) Celeron (TM) processor */
    136        1.1        ad 	"Xeon",		    /* Intel (R) Xeon (TM) processor */
    137        1.1        ad 	"Xeon MP",	    /* Intel (R) Xeon (TM) processor MP */
    138       1.41   msaitoh 	"",		    /* 0x0d: Reserved */
    139        1.1        ad 	"Mobile Pentium 4", /* Mobile Intel (R) Pentium (R) 4 processor-M */
    140        1.1        ad 	"Mobile Celeron",   /* Mobile Intel (R) Celeron (R) processor */
    141       1.41   msaitoh 	"",		    /* 0x10: Reserved */
    142       1.41   msaitoh 	"Mobile Genuine",   /* Moblie Genuine Intel (R) processor */
    143       1.85   msaitoh 	"Celeron M",	    /* Intel (R) Celeron (R) M processor */
    144       1.41   msaitoh 	"Mobile Celeron",   /* Mobile Intel (R) Celeron (R) processor */
    145       1.85   msaitoh 	"Celeron",	    /* Intel (R) Celeron (R) processor */
    146       1.41   msaitoh 	"Mobile Genuine",   /* Moblie Genuine Intel (R) processor */
    147       1.85   msaitoh 	"Pentium M",	    /* Intel (R) Pentium (R) M processor */
    148       1.41   msaitoh 	"Mobile Celeron",   /* Mobile Intel (R) Celeron (R) processor */
    149        1.1        ad };
    150        1.1        ad 
    151        1.1        ad /*
    152        1.1        ad  * AMD processors don't have Brand IDs, so we need these names for probe.
    153        1.1        ad  */
    154        1.1        ad static const char * const amd_brand[] = {
    155        1.1        ad 	"",
    156        1.1        ad 	"Duron",	/* AMD Duron(tm) */
    157        1.1        ad 	"MP",		/* AMD Athlon(tm) MP */
    158        1.1        ad 	"XP",		/* AMD Athlon(tm) XP */
    159        1.1        ad 	"4"		/* AMD Athlon(tm) 4 */
    160        1.1        ad };
    161        1.1        ad 
    162      1.112   msaitoh int cpu_vendor;
    163        1.1        ad static char cpu_brand_string[49];
    164        1.1        ad static char amd_brand_name[48];
    165       1.26       chs static int use_pae, largepagesize;
    166        1.1        ad 
    167       1.44   msaitoh /* Setup functions */
    168       1.44   msaitoh static void	disable_tsc(struct cpu_info *);
    169       1.51   msaitoh static void	amd_family5_setup(struct cpu_info *);
    170       1.44   msaitoh static void	cyrix6x86_cpu_setup(struct cpu_info *);
    171       1.44   msaitoh static void	winchip_cpu_setup(struct cpu_info *);
    172       1.44   msaitoh /* Brand/Model name functions */
    173        1.1        ad static const char *intel_family6_name(struct cpu_info *);
    174        1.1        ad static const char *amd_amd64_name(struct cpu_info *);
    175       1.44   msaitoh /* Probe functions */
    176       1.44   msaitoh static void	amd_family6_probe(struct cpu_info *);
    177       1.44   msaitoh static void	powernow_probe(struct cpu_info *);
    178       1.44   msaitoh static void	intel_family_new_probe(struct cpu_info *);
    179       1.44   msaitoh static void	via_cpu_probe(struct cpu_info *);
    180       1.44   msaitoh /* (Cache) Info functions */
    181       1.85   msaitoh static void	intel_cpu_cacheinfo(struct cpu_info *);
    182       1.85   msaitoh static void	amd_cpu_cacheinfo(struct cpu_info *);
    183       1.44   msaitoh static void	via_cpu_cacheinfo(struct cpu_info *);
    184       1.44   msaitoh static void	tmx86_get_longrun_status(u_int *, u_int *, u_int *);
    185       1.44   msaitoh static void	transmeta_cpu_info(struct cpu_info *);
    186       1.44   msaitoh /* Common functions */
    187       1.44   msaitoh static void	cpu_probe_base_features(struct cpu_info *, const char *);
    188       1.60   msaitoh static void	cpu_probe_hv_features(struct cpu_info *, const char *);
    189       1.44   msaitoh static void	cpu_probe_features(struct cpu_info *);
    190       1.44   msaitoh static void	print_bits(const char *, const char *, const char *, uint32_t);
    191       1.44   msaitoh static void	identifycpu_cpuids(struct cpu_info *);
    192        1.1        ad static const char *print_cache_config(struct cpu_info *, int, const char *,
    193        1.1        ad     const char *);
    194        1.1        ad static const char *print_tlb_config(struct cpu_info *, int, const char *,
    195        1.1        ad     const char *);
    196       1.54   msaitoh static void	x86_print_cache_and_tlb_info(struct cpu_info *);
    197        1.1        ad 
    198        1.1        ad /*
    199        1.1        ad  * Note: these are just the ones that may not have a cpuid instruction.
    200        1.1        ad  * We deal with the rest in a different way.
    201        1.1        ad  */
    202        1.1        ad const struct cpu_nocpuid_nameclass i386_nocpuid_cpus[] = {
    203        1.1        ad 	{ CPUVENDOR_INTEL, "Intel", "386SX",	CPUCLASS_386,
    204        1.1        ad 	  NULL, NULL, NULL },			/* CPU_386SX */
    205        1.1        ad 	{ CPUVENDOR_INTEL, "Intel", "386DX",	CPUCLASS_386,
    206        1.1        ad 	  NULL, NULL, NULL },			/* CPU_386   */
    207        1.1        ad 	{ CPUVENDOR_INTEL, "Intel", "486SX",	CPUCLASS_486,
    208        1.1        ad 	  NULL, NULL, NULL },			/* CPU_486SX */
    209        1.1        ad 	{ CPUVENDOR_INTEL, "Intel", "486DX",	CPUCLASS_486,
    210        1.1        ad 	  NULL, NULL, NULL },			/* CPU_486   */
    211        1.1        ad 	{ CPUVENDOR_CYRIX, "Cyrix", "486DLC",	CPUCLASS_486,
    212        1.1        ad 	  NULL, NULL, NULL },			/* CPU_486DLC */
    213        1.1        ad 	{ CPUVENDOR_CYRIX, "Cyrix", "6x86",	CPUCLASS_486,
    214        1.1        ad 	  NULL, NULL, NULL },		/* CPU_6x86 */
    215       1.85   msaitoh 	{ CPUVENDOR_NEXGEN,"NexGen","586",	CPUCLASS_386,
    216        1.1        ad 	  NULL, NULL, NULL },			/* CPU_NX586 */
    217        1.1        ad };
    218        1.1        ad 
    219        1.1        ad const char *classnames[] = {
    220        1.1        ad 	"386",
    221        1.1        ad 	"486",
    222        1.1        ad 	"586",
    223        1.1        ad 	"686"
    224        1.1        ad };
    225        1.1        ad 
    226        1.1        ad const char *modifiers[] = {
    227        1.1        ad 	"",
    228        1.1        ad 	"OverDrive",
    229        1.1        ad 	"Dual",
    230        1.1        ad 	""
    231        1.1        ad };
    232        1.1        ad 
    233        1.1        ad const struct cpu_cpuid_nameclass i386_cpuid_cpus[] = {
    234        1.1        ad 	{
    235       1.41   msaitoh 		/*
    236       1.41   msaitoh 		 * For Intel processors, check Chapter 35Model-specific
    237       1.41   msaitoh 		 * registers (MSRS), in "Intel (R) 64 and IA-32 Architectures
    238       1.41   msaitoh 		 * Software Developer's Manual, Volume 3C".
    239       1.41   msaitoh 		 */
    240        1.1        ad 		"GenuineIntel",
    241        1.1        ad 		CPUVENDOR_INTEL,
    242        1.1        ad 		"Intel",
    243        1.1        ad 		/* Family 4 */
    244        1.1        ad 		{ {
    245        1.1        ad 			CPUCLASS_486,
    246        1.1        ad 			{
    247        1.1        ad 				"486DX", "486DX", "486SX", "486DX2", "486SL",
    248        1.1        ad 				"486SX2", 0, "486DX2 W/B Enhanced",
    249        1.1        ad 				"486DX4", 0, 0, 0, 0, 0, 0, 0,
    250        1.1        ad 			},
    251       1.37       dsl 			"486",		/* Default */
    252        1.1        ad 			NULL,
    253        1.1        ad 			NULL,
    254       1.52   msaitoh 			intel_cpu_cacheinfo,
    255        1.1        ad 		},
    256        1.1        ad 		/* Family 5 */
    257        1.1        ad 		{
    258        1.1        ad 			CPUCLASS_586,
    259        1.1        ad 			{
    260        1.1        ad 				"Pentium (P5 A-step)", "Pentium (P5)",
    261        1.1        ad 				"Pentium (P54C)", "Pentium (P24T)",
    262        1.1        ad 				"Pentium/MMX", "Pentium", 0,
    263        1.1        ad 				"Pentium (P54C)", "Pentium/MMX (Tillamook)",
    264       1.72   msaitoh 				"Quark X1000", 0, 0, 0, 0, 0, 0,
    265        1.1        ad 			},
    266       1.37       dsl 			"Pentium",	/* Default */
    267        1.1        ad 			NULL,
    268        1.1        ad 			NULL,
    269       1.52   msaitoh 			intel_cpu_cacheinfo,
    270        1.1        ad 		},
    271        1.1        ad 		/* Family 6 */
    272        1.1        ad 		{
    273        1.1        ad 			CPUCLASS_686,
    274        1.1        ad 			{
    275       1.37       dsl 				[0x00] = "Pentium Pro (A-step)",
    276       1.37       dsl 				[0x01] = "Pentium Pro",
    277       1.37       dsl 				[0x03] = "Pentium II (Klamath)",
    278       1.37       dsl 				[0x04] = "Pentium Pro",
    279       1.37       dsl 				[0x05] = "Pentium II/Celeron (Deschutes)",
    280       1.37       dsl 				[0x06] = "Celeron (Mendocino)",
    281       1.37       dsl 				[0x07] = "Pentium III (Katmai)",
    282       1.37       dsl 				[0x08] = "Pentium III (Coppermine)",
    283      1.103   msaitoh 				[0x09] = "Pentium M (Banias)",
    284       1.37       dsl 				[0x0a] = "Pentium III Xeon (Cascades)",
    285       1.37       dsl 				[0x0b] = "Pentium III (Tualatin)",
    286      1.103   msaitoh 				[0x0d] = "Pentium M (Dothan)",
    287       1.40   msaitoh 				[0x0e] = "Pentium Core Duo, Core solo",
    288       1.40   msaitoh 				[0x0f] = "Xeon 30xx, 32xx, 51xx, 53xx, 73xx, "
    289       1.40   msaitoh 					 "Core 2 Quad 6xxx, "
    290       1.40   msaitoh 					 "Core 2 Extreme 6xxx, "
    291       1.40   msaitoh 					 "Core 2 Duo 4xxx, 5xxx, 6xxx, 7xxx "
    292       1.40   msaitoh 					 "and Pentium DC",
    293       1.37       dsl 				[0x15] = "EP80579 Integrated Processor",
    294       1.37       dsl 				[0x16] = "Celeron (45nm)",
    295       1.40   msaitoh 				[0x17] = "Xeon 31xx, 33xx, 52xx, 54xx, "
    296       1.40   msaitoh 					 "Core 2 Quad 8xxx and 9xxx",
    297       1.40   msaitoh 				[0x1a] = "Core i7, Xeon 34xx, 35xx and 55xx "
    298       1.40   msaitoh 					 "(Nehalem)",
    299       1.70   msaitoh 				[0x1c] = "45nm Atom Family",
    300       1.37       dsl 				[0x1d] = "XeonMP 74xx (Nehalem)",
    301       1.37       dsl 				[0x1e] = "Core i7 and i5",
    302       1.37       dsl 				[0x1f] = "Core i7 and i5",
    303       1.37       dsl 				[0x25] = "Xeon 36xx & 56xx, i7, i5 and i3",
    304       1.37       dsl 				[0x26] = "Atom Family",
    305       1.37       dsl 				[0x27] = "Atom Family",
    306       1.40   msaitoh 				[0x2a] = "Xeon E3-12xx, 2nd gen i7, i5, "
    307       1.40   msaitoh 					 "i3 2xxx",
    308       1.37       dsl 				[0x2c] = "Xeon 36xx & 56xx, i7, i5 and i3",
    309       1.49   msaitoh 				[0x2d] = "Xeon E5 Sandy Bridge family, "
    310       1.48   msaitoh 					 "Core i7-39xx Extreme",
    311       1.37       dsl 				[0x2e] = "Xeon 75xx & 65xx",
    312       1.37       dsl 				[0x2f] = "Xeon E7 family",
    313       1.40   msaitoh 				[0x35] = "Atom Family",
    314       1.41   msaitoh 				[0x36] = "Atom S1000",
    315       1.65   msaitoh 				[0x37] = "Atom E3000, Z3[67]00",
    316       1.40   msaitoh 				[0x3a] = "Xeon E3-1200v2 and 3rd gen core, "
    317       1.48   msaitoh 					 "Ivy Bridge",
    318       1.40   msaitoh 				[0x3c] = "4th gen Core, Xeon E3-12xx v3 "
    319       1.40   msaitoh 					 "(Haswell)",
    320       1.67   msaitoh 				[0x3d] = "Core M-5xxx, 5th gen Core (Broadwell)",
    321       1.59   msaitoh 				[0x3e] = "Xeon E5/E7 v2 (Ivy Bridge-E), "
    322       1.59   msaitoh 					 "Core i7-49xx Extreme",
    323       1.67   msaitoh 				[0x3f] = "Xeon E5-4600/2600/1600 v3, Xeon E7 v3 (Haswell-E), "
    324       1.59   msaitoh 					 "Core i7-59xx Extreme",
    325       1.40   msaitoh 				[0x45] = "4th gen Core, Xeon E3-12xx v3 "
    326       1.40   msaitoh 					 "(Haswell)",
    327       1.40   msaitoh 				[0x46] = "4th gen Core, Xeon E3-12xx v3 "
    328       1.40   msaitoh 					 "(Haswell)",
    329       1.67   msaitoh 				[0x47] = "5th gen Core, Xeon E3-1200 v4 (Broadwell)",
    330       1.65   msaitoh 				[0x4a] = "Atom Z3400",
    331       1.66   msaitoh 				[0x4c] = "Atom X[57]-Z8000 (Airmont)",
    332       1.58   msaitoh 				[0x4d] = "Atom C2000",
    333       1.70   msaitoh 				[0x4e] = "6th gen Core, Xeon E3-1[25]00 v5 (Skylake)",
    334       1.73   msaitoh 				[0x4f] = "Xeon E[57] v4 (Broadwell), Core i7-69xx Extreme",
    335      1.102   msaitoh 				[0x55] = "Xeon Scalable (Skylake, Cascade Lake, Copper Lake)",
    336       1.68   msaitoh 				[0x56] = "Xeon D-1500 (Broadwell)",
    337       1.78   msaitoh 				[0x57] = "Xeon Phi [357]200 (Knights Landing)",
    338       1.65   msaitoh 				[0x5a] = "Atom E3500",
    339       1.77   msaitoh 				[0x5c] = "Atom (Goldmont)",
    340       1.66   msaitoh 				[0x5d] = "Atom X3-C3000 (Silvermont)",
    341       1.70   msaitoh 				[0x5e] = "6th gen Core, Xeon E3-1[25]00 v5 (Skylake)",
    342       1.77   msaitoh 				[0x5f] = "Atom (Goldmont, Denverton)",
    343      1.102   msaitoh 				[0x66] = "8th gen Core i3 (Cannon Lake)",
    344      1.116   msaitoh 				[0x6a] = "3rd gen Xeon Scalable (Ice Lake)",
    345      1.116   msaitoh 				[0x6c] = "3rd gen Xeon Scalable (Ice Lake)",
    346       1.77   msaitoh 				[0x7a] = "Atom (Goldmont Plus)",
    347      1.108   msaitoh 				[0x7d] = "10th gen Core (Ice Lake)",
    348      1.108   msaitoh 				[0x7e] = "10th gen Core (Ice Lake)",
    349       1.84   msaitoh 				[0x85] = "Xeon Phi 7215, 7285, 7295 (Knights Mill)",
    350       1.92   msaitoh 				[0x86] = "Atom (Tremont)",
    351      1.115   msaitoh 				[0x8c] = "11th gen Core (Tiger Lake)",
    352      1.115   msaitoh 				[0x8d] = "11th gen Core (Tiger Lake)",
    353      1.102   msaitoh 				[0x8e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
    354  1.133.2.1    martin 				[0x8f] = "4th gen Xeon Scalable (Sapphire Rapids)",
    355      1.117   msaitoh 				[0x96] = "Atom x6000E (Elkhart Lake)",
    356      1.125   msaitoh 				[0x97] = "12th gen Core (Alder Lake)",
    357      1.125   msaitoh 				[0x9a] = "12th gen Core (Alder Lake)",
    358      1.117   msaitoh 				[0x9c] = "Pentium Silver N6xxx, Celeron N45xx, Celeron N51xx (Jasper Lake)",
    359      1.102   msaitoh 				[0x9e] = "7th or 8th gen Core (Kaby Lake, Coffee Lake) or Xeon E (Coffee Lake)",
    360      1.113   msaitoh 				[0xa5] = "10th gen Core (Comet Lake)",
    361      1.113   msaitoh 				[0xa6] = "10th gen Core (Comet Lake)",
    362      1.125   msaitoh 				[0xa7] = "11th gen Core (Rocket Lake)",
    363      1.125   msaitoh 				[0xa8] = "11th gen Core (Rocket Lake)",
    364  1.133.2.1    martin 				[0xba] = "13th gen Core (Raptor Lake)",
    365  1.133.2.1    martin 				[0xb7] = "13th gen Core (Raptor Lake)",
    366  1.133.2.1    martin 				[0xbf] = "13th gen Core (Raptor Lake)",
    367        1.1        ad 			},
    368       1.37       dsl 			"Pentium Pro, II or III",	/* Default */
    369        1.1        ad 			NULL,
    370        1.1        ad 			intel_family_new_probe,
    371       1.52   msaitoh 			intel_cpu_cacheinfo,
    372        1.1        ad 		},
    373        1.1        ad 		/* Family > 6 */
    374        1.1        ad 		{
    375        1.1        ad 			CPUCLASS_686,
    376        1.1        ad 			{
    377        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    378        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    379        1.1        ad 			},
    380       1.37       dsl 			"Pentium 4",	/* Default */
    381        1.1        ad 			NULL,
    382        1.1        ad 			intel_family_new_probe,
    383       1.52   msaitoh 			intel_cpu_cacheinfo,
    384        1.1        ad 		} }
    385        1.1        ad 	},
    386        1.1        ad 	{
    387        1.1        ad 		"AuthenticAMD",
    388        1.1        ad 		CPUVENDOR_AMD,
    389        1.1        ad 		"AMD",
    390        1.1        ad 		/* Family 4 */
    391        1.1        ad 		{ {
    392        1.1        ad 			CPUCLASS_486,
    393        1.1        ad 			{
    394        1.1        ad 				0, 0, 0, "Am486DX2 W/T",
    395        1.1        ad 				0, 0, 0, "Am486DX2 W/B",
    396        1.1        ad 				"Am486DX4 W/T or Am5x86 W/T 150",
    397        1.1        ad 				"Am486DX4 W/B or Am5x86 W/B 150", 0, 0,
    398        1.1        ad 				0, 0, "Am5x86 W/T 133/160",
    399        1.1        ad 				"Am5x86 W/B 133/160",
    400        1.1        ad 			},
    401       1.37       dsl 			"Am486 or Am5x86",	/* Default */
    402        1.1        ad 			NULL,
    403        1.1        ad 			NULL,
    404       1.18  pgoyette 			NULL,
    405        1.1        ad 		},
    406        1.1        ad 		/* Family 5 */
    407        1.1        ad 		{
    408        1.1        ad 			CPUCLASS_586,
    409        1.1        ad 			{
    410        1.1        ad 				"K5", "K5", "K5", "K5", 0, 0, "K6",
    411        1.1        ad 				"K6", "K6-2", "K6-III", "Geode LX", 0, 0,
    412        1.1        ad 				"K6-2+/III+", 0, 0,
    413        1.1        ad 			},
    414       1.37       dsl 			"K5 or K6",		/* Default */
    415        1.1        ad 			amd_family5_setup,
    416        1.1        ad 			NULL,
    417        1.1        ad 			amd_cpu_cacheinfo,
    418        1.1        ad 		},
    419        1.1        ad 		/* Family 6 */
    420        1.1        ad 		{
    421        1.1        ad 			CPUCLASS_686,
    422        1.1        ad 			{
    423        1.1        ad 				0, "Athlon Model 1", "Athlon Model 2",
    424        1.1        ad 				"Duron", "Athlon Model 4 (Thunderbird)",
    425        1.1        ad 				0, "Athlon", "Duron", "Athlon", 0,
    426        1.1        ad 				"Athlon", 0, 0, 0, 0, 0,
    427        1.1        ad 			},
    428       1.37       dsl 			"K7 (Athlon)",	/* Default */
    429        1.1        ad 			NULL,
    430        1.1        ad 			amd_family6_probe,
    431        1.1        ad 			amd_cpu_cacheinfo,
    432        1.1        ad 		},
    433        1.1        ad 		/* Family > 6 */
    434        1.1        ad 		{
    435        1.1        ad 			CPUCLASS_686,
    436        1.1        ad 			{
    437        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    438        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    439        1.1        ad 			},
    440       1.37       dsl 			"Unknown K8 (Athlon)",	/* Default */
    441        1.1        ad 			NULL,
    442        1.1        ad 			amd_family6_probe,
    443        1.1        ad 			amd_cpu_cacheinfo,
    444        1.1        ad 		} }
    445        1.1        ad 	},
    446        1.1        ad 	{
    447        1.1        ad 		"CyrixInstead",
    448        1.1        ad 		CPUVENDOR_CYRIX,
    449        1.1        ad 		"Cyrix",
    450        1.1        ad 		/* Family 4 */
    451        1.1        ad 		{ {
    452        1.1        ad 			CPUCLASS_486,
    453        1.1        ad 			{
    454        1.1        ad 				0, 0, 0,
    455        1.1        ad 				"MediaGX",
    456        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    457        1.1        ad 			},
    458       1.37       dsl 			"486",		/* Default */
    459        1.1        ad 			cyrix6x86_cpu_setup, /* XXX ?? */
    460        1.1        ad 			NULL,
    461        1.1        ad 			NULL,
    462        1.1        ad 		},
    463        1.1        ad 		/* Family 5 */
    464        1.1        ad 		{
    465        1.1        ad 			CPUCLASS_586,
    466        1.1        ad 			{
    467        1.1        ad 				0, 0, "6x86", 0,
    468        1.1        ad 				"MMX-enhanced MediaGX (GXm)", /* or Geode? */
    469        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    470        1.1        ad 			},
    471       1.37       dsl 			"6x86",		/* Default */
    472        1.1        ad 			cyrix6x86_cpu_setup,
    473        1.1        ad 			NULL,
    474        1.1        ad 			NULL,
    475        1.1        ad 		},
    476        1.1        ad 		/* Family 6 */
    477        1.1        ad 		{
    478        1.1        ad 			CPUCLASS_686,
    479        1.1        ad 			{
    480        1.1        ad 				"6x86MX", 0, 0, 0, 0, 0, 0, 0,
    481        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    482        1.1        ad 			},
    483       1.37       dsl 			"6x86MX",		/* Default */
    484        1.1        ad 			cyrix6x86_cpu_setup,
    485        1.1        ad 			NULL,
    486        1.1        ad 			NULL,
    487        1.1        ad 		},
    488        1.1        ad 		/* Family > 6 */
    489        1.1        ad 		{
    490        1.1        ad 			CPUCLASS_686,
    491        1.1        ad 			{
    492        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    493        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    494        1.1        ad 			},
    495       1.37       dsl 			"Unknown 6x86MX",		/* Default */
    496        1.1        ad 			NULL,
    497        1.1        ad 			NULL,
    498       1.18  pgoyette 			NULL,
    499        1.1        ad 		} }
    500        1.1        ad 	},
    501        1.1        ad 	{	/* MediaGX is now owned by National Semiconductor */
    502        1.1        ad 		"Geode by NSC",
    503        1.1        ad 		CPUVENDOR_CYRIX, /* XXX */
    504        1.1        ad 		"National Semiconductor",
    505        1.1        ad 		/* Family 4, NSC never had any of these */
    506        1.1        ad 		{ {
    507        1.1        ad 			CPUCLASS_486,
    508        1.1        ad 			{
    509        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    510        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    511        1.1        ad 			},
    512       1.37       dsl 			"486 compatible",	/* Default */
    513        1.1        ad 			NULL,
    514        1.1        ad 			NULL,
    515       1.18  pgoyette 			NULL,
    516        1.1        ad 		},
    517        1.1        ad 		/* Family 5: Geode family, formerly MediaGX */
    518        1.1        ad 		{
    519        1.1        ad 			CPUCLASS_586,
    520        1.1        ad 			{
    521        1.1        ad 				0, 0, 0, 0,
    522        1.1        ad 				"Geode GX1",
    523        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    524        1.1        ad 			},
    525       1.37       dsl 			"Geode",		/* Default */
    526        1.1        ad 			cyrix6x86_cpu_setup,
    527        1.1        ad 			NULL,
    528        1.1        ad 			amd_cpu_cacheinfo,
    529        1.1        ad 		},
    530        1.1        ad 		/* Family 6, not yet available from NSC */
    531        1.1        ad 		{
    532        1.1        ad 			CPUCLASS_686,
    533        1.1        ad 			{
    534        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    535        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    536        1.1        ad 			},
    537       1.37       dsl 			"Pentium Pro compatible", /* Default */
    538        1.1        ad 			NULL,
    539        1.1        ad 			NULL,
    540       1.18  pgoyette 			NULL,
    541        1.1        ad 		},
    542        1.1        ad 		/* Family > 6, not yet available from NSC */
    543        1.1        ad 		{
    544        1.1        ad 			CPUCLASS_686,
    545        1.1        ad 			{
    546        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    547        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    548        1.1        ad 			},
    549       1.37       dsl 			"Pentium Pro compatible",	/* Default */
    550        1.1        ad 			NULL,
    551        1.1        ad 			NULL,
    552       1.18  pgoyette 			NULL,
    553        1.1        ad 		} }
    554        1.1        ad 	},
    555        1.1        ad 	{
    556        1.1        ad 		"CentaurHauls",
    557        1.1        ad 		CPUVENDOR_IDT,
    558        1.1        ad 		"IDT",
    559        1.1        ad 		/* Family 4, IDT never had any of these */
    560        1.1        ad 		{ {
    561        1.1        ad 			CPUCLASS_486,
    562        1.1        ad 			{
    563        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    564        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    565        1.1        ad 			},
    566       1.37       dsl 			"486 compatible",	/* Default */
    567        1.1        ad 			NULL,
    568        1.1        ad 			NULL,
    569       1.18  pgoyette 			NULL,
    570        1.1        ad 		},
    571        1.1        ad 		/* Family 5 */
    572        1.1        ad 		{
    573        1.1        ad 			CPUCLASS_586,
    574        1.1        ad 			{
    575        1.1        ad 				0, 0, 0, 0, "WinChip C6", 0, 0, 0,
    576        1.1        ad 				"WinChip 2", "WinChip 3", 0, 0, 0, 0, 0, 0,
    577        1.1        ad 			},
    578       1.37       dsl 			"WinChip",		/* Default */
    579        1.1        ad 			winchip_cpu_setup,
    580        1.1        ad 			NULL,
    581        1.1        ad 			NULL,
    582        1.1        ad 		},
    583        1.1        ad 		/* Family 6, VIA acquired IDT Centaur design subsidiary */
    584        1.1        ad 		{
    585        1.1        ad 			CPUCLASS_686,
    586        1.1        ad 			{
    587        1.1        ad 				0, 0, 0, 0, 0, 0, "C3 Samuel",
    588        1.1        ad 				"C3 Samuel 2/Ezra", "C3 Ezra-T",
    589       1.20  jmcneill 				"C3 Nehemiah", "C7 Esther", 0, 0, "C7 Esther",
    590       1.20  jmcneill 				0, "VIA Nano",
    591        1.1        ad 			},
    592       1.37       dsl 			"Unknown VIA/IDT",	/* Default */
    593        1.1        ad 			NULL,
    594        1.1        ad 			via_cpu_probe,
    595        1.1        ad 			via_cpu_cacheinfo,
    596        1.1        ad 		},
    597        1.1        ad 		/* Family > 6, not yet available from VIA */
    598        1.1        ad 		{
    599        1.1        ad 			CPUCLASS_686,
    600        1.1        ad 			{
    601        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    602        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    603        1.1        ad 			},
    604       1.37       dsl 			"Pentium Pro compatible",	/* Default */
    605        1.1        ad 			NULL,
    606        1.1        ad 			NULL,
    607       1.18  pgoyette 			NULL,
    608        1.1        ad 		} }
    609        1.1        ad 	},
    610        1.1        ad 	{
    611        1.1        ad 		"GenuineTMx86",
    612        1.1        ad 		CPUVENDOR_TRANSMETA,
    613        1.1        ad 		"Transmeta",
    614        1.1        ad 		/* Family 4, Transmeta never had any of these */
    615        1.1        ad 		{ {
    616        1.1        ad 			CPUCLASS_486,
    617        1.1        ad 			{
    618        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    619        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    620        1.1        ad 			},
    621       1.37       dsl 			"486 compatible",	/* Default */
    622        1.1        ad 			NULL,
    623        1.1        ad 			NULL,
    624       1.18  pgoyette 			NULL,
    625        1.1        ad 		},
    626        1.1        ad 		/* Family 5 */
    627        1.1        ad 		{
    628        1.1        ad 			CPUCLASS_586,
    629        1.1        ad 			{
    630        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    631        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    632        1.1        ad 			},
    633       1.37       dsl 			"Crusoe",		/* Default */
    634        1.1        ad 			NULL,
    635        1.1        ad 			NULL,
    636        1.1        ad 			transmeta_cpu_info,
    637        1.1        ad 		},
    638        1.1        ad 		/* Family 6, not yet available from Transmeta */
    639        1.1        ad 		{
    640        1.1        ad 			CPUCLASS_686,
    641        1.1        ad 			{
    642        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    643        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    644        1.1        ad 			},
    645       1.37       dsl 			"Pentium Pro compatible",	/* Default */
    646        1.1        ad 			NULL,
    647        1.1        ad 			NULL,
    648       1.18  pgoyette 			NULL,
    649        1.1        ad 		},
    650        1.1        ad 		/* Family > 6, not yet available from Transmeta */
    651        1.1        ad 		{
    652        1.1        ad 			CPUCLASS_686,
    653        1.1        ad 			{
    654        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    655        1.1        ad 				0, 0, 0, 0, 0, 0, 0, 0,
    656        1.1        ad 			},
    657       1.37       dsl 			"Pentium Pro compatible",	/* Default */
    658        1.1        ad 			NULL,
    659        1.1        ad 			NULL,
    660       1.18  pgoyette 			NULL,
    661        1.1        ad 		} }
    662        1.1        ad 	}
    663        1.1        ad };
    664        1.1        ad 
    665        1.1        ad /*
    666        1.1        ad  * disable the TSC such that we don't use the TSC in microtime(9)
    667        1.1        ad  * because some CPUs got the implementation wrong.
    668        1.1        ad  */
    669        1.1        ad static void
    670        1.1        ad disable_tsc(struct cpu_info *ci)
    671        1.1        ad {
    672       1.18  pgoyette 	if (ci->ci_feat_val[0] & CPUID_TSC) {
    673       1.18  pgoyette 		ci->ci_feat_val[0] &= ~CPUID_TSC;
    674        1.1        ad 		aprint_error("WARNING: broken TSC disabled\n");
    675        1.1        ad 	}
    676        1.1        ad }
    677        1.1        ad 
    678        1.1        ad static void
    679       1.44   msaitoh amd_family5_setup(struct cpu_info *ci)
    680       1.44   msaitoh {
    681       1.44   msaitoh 
    682       1.44   msaitoh 	switch (ci->ci_model) {
    683       1.44   msaitoh 	case 0:		/* AMD-K5 Model 0 */
    684       1.44   msaitoh 		/*
    685       1.44   msaitoh 		 * According to the AMD Processor Recognition App Note,
    686       1.44   msaitoh 		 * the AMD-K5 Model 0 uses the wrong bit to indicate
    687       1.44   msaitoh 		 * support for global PTEs, instead using bit 9 (APIC)
    688       1.44   msaitoh 		 * rather than bit 13 (i.e. "0x200" vs. 0x2000".  Oops!).
    689       1.44   msaitoh 		 */
    690       1.44   msaitoh 		if (ci->ci_feat_val[0] & CPUID_APIC)
    691       1.44   msaitoh 			ci->ci_feat_val[0] =
    692       1.44   msaitoh 			    (ci->ci_feat_val[0] & ~CPUID_APIC) | CPUID_PGE;
    693       1.44   msaitoh 		/*
    694       1.44   msaitoh 		 * XXX But pmap_pg_g is already initialized -- need to kick
    695       1.44   msaitoh 		 * XXX the pmap somehow.  How does the MP branch do this?
    696       1.44   msaitoh 		 */
    697       1.44   msaitoh 		break;
    698       1.44   msaitoh 	}
    699       1.44   msaitoh }
    700       1.44   msaitoh 
    701       1.44   msaitoh static void
    702        1.1        ad cyrix6x86_cpu_setup(struct cpu_info *ci)
    703        1.1        ad {
    704        1.1        ad 
    705      1.103   msaitoh 	/*
    706        1.1        ad 	 * Do not disable the TSC on the Geode GX, it's reported to
    707        1.1        ad 	 * work fine.
    708        1.1        ad 	 */
    709        1.1        ad 	if (ci->ci_signature != 0x552)
    710        1.1        ad 		disable_tsc(ci);
    711        1.1        ad }
    712        1.1        ad 
    713       1.44   msaitoh static void
    714        1.1        ad winchip_cpu_setup(struct cpu_info *ci)
    715        1.1        ad {
    716       1.36       dsl 	switch (ci->ci_model) {
    717        1.1        ad 	case 4:	/* WinChip C6 */
    718        1.1        ad 		disable_tsc(ci);
    719        1.1        ad 	}
    720        1.1        ad }
    721        1.1        ad 
    722        1.1        ad 
    723        1.1        ad static const char *
    724        1.1        ad intel_family6_name(struct cpu_info *ci)
    725        1.1        ad {
    726        1.1        ad 	const char *ret = NULL;
    727        1.1        ad 	u_int l2cache = ci->ci_cinfo[CAI_L2CACHE].cai_totalsize;
    728        1.1        ad 
    729       1.36       dsl 	if (ci->ci_model == 5) {
    730        1.1        ad 		switch (l2cache) {
    731        1.1        ad 		case 0:
    732        1.1        ad 		case 128 * 1024:
    733        1.1        ad 			ret = "Celeron (Covington)";
    734        1.1        ad 			break;
    735        1.1        ad 		case 256 * 1024:
    736        1.1        ad 			ret = "Mobile Pentium II (Dixon)";
    737        1.1        ad 			break;
    738        1.1        ad 		case 512 * 1024:
    739        1.1        ad 			ret = "Pentium II";
    740        1.1        ad 			break;
    741        1.1        ad 		case 1 * 1024 * 1024:
    742        1.1        ad 		case 2 * 1024 * 1024:
    743        1.1        ad 			ret = "Pentium II Xeon";
    744        1.1        ad 			break;
    745        1.1        ad 		}
    746       1.36       dsl 	} else if (ci->ci_model == 6) {
    747        1.1        ad 		switch (l2cache) {
    748        1.1        ad 		case 256 * 1024:
    749        1.1        ad 		case 512 * 1024:
    750        1.1        ad 			ret = "Mobile Pentium II";
    751        1.1        ad 			break;
    752        1.1        ad 		}
    753       1.36       dsl 	} else if (ci->ci_model == 7) {
    754        1.1        ad 		switch (l2cache) {
    755        1.1        ad 		case 512 * 1024:
    756        1.1        ad 			ret = "Pentium III";
    757        1.1        ad 			break;
    758        1.1        ad 		case 1 * 1024 * 1024:
    759        1.1        ad 		case 2 * 1024 * 1024:
    760        1.1        ad 			ret = "Pentium III Xeon";
    761        1.1        ad 			break;
    762        1.1        ad 		}
    763       1.36       dsl 	} else if (ci->ci_model >= 8) {
    764        1.1        ad 		if (ci->ci_brand_id && ci->ci_brand_id < 0x10) {
    765        1.1        ad 			switch (ci->ci_brand_id) {
    766        1.1        ad 			case 0x3:
    767        1.1        ad 				if (ci->ci_signature == 0x6B1)
    768        1.1        ad 					ret = "Celeron";
    769        1.1        ad 				break;
    770        1.1        ad 			case 0x8:
    771        1.1        ad 				if (ci->ci_signature >= 0xF13)
    772        1.1        ad 					ret = "genuine processor";
    773        1.1        ad 				break;
    774        1.1        ad 			case 0xB:
    775        1.1        ad 				if (ci->ci_signature >= 0xF13)
    776        1.1        ad 					ret = "Xeon MP";
    777        1.1        ad 				break;
    778        1.1        ad 			case 0xE:
    779        1.1        ad 				if (ci->ci_signature < 0xF13)
    780        1.1        ad 					ret = "Xeon";
    781        1.1        ad 				break;
    782        1.1        ad 			}
    783        1.1        ad 			if (ret == NULL)
    784        1.1        ad 				ret = i386_intel_brand[ci->ci_brand_id];
    785        1.1        ad 		}
    786        1.1        ad 	}
    787        1.1        ad 
    788        1.1        ad 	return ret;
    789        1.1        ad }
    790        1.1        ad 
    791        1.1        ad /*
    792        1.1        ad  * Identify AMD64 CPU names from cpuid.
    793        1.1        ad  *
    794        1.1        ad  * Based on:
    795        1.1        ad  * "Revision Guide for AMD Athlon 64 and AMD Opteron Processors"
    796        1.1        ad  * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25759.pdf
    797        1.1        ad  * "Revision Guide for AMD NPT Family 0Fh Processors"
    798        1.1        ad  * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/33610.pdf
    799        1.1        ad  * and other miscellaneous reports.
    800       1.36       dsl  *
    801       1.36       dsl  * This is all rather pointless, these are cross 'brand' since the raw
    802       1.36       dsl  * silicon is shared.
    803        1.1        ad  */
    804        1.1        ad static const char *
    805        1.1        ad amd_amd64_name(struct cpu_info *ci)
    806        1.1        ad {
    807       1.36       dsl 	static char family_str[32];
    808       1.36       dsl 
    809       1.36       dsl 	/* Only called if family >= 15 */
    810        1.1        ad 
    811       1.36       dsl 	switch (ci->ci_family) {
    812       1.36       dsl 	case 15:
    813       1.36       dsl 		switch (ci->ci_model) {
    814       1.36       dsl 		case 0x21:	/* rev JH-E1/E6 */
    815       1.36       dsl 		case 0x41:	/* rev JH-F2 */
    816       1.36       dsl 			return "Dual-Core Opteron";
    817       1.36       dsl 		case 0x23:	/* rev JH-E6 (Toledo) */
    818       1.36       dsl 			return "Dual-Core Opteron or Athlon 64 X2";
    819       1.36       dsl 		case 0x43:	/* rev JH-F2 (Windsor) */
    820       1.36       dsl 			return "Athlon 64 FX or Athlon 64 X2";
    821       1.36       dsl 		case 0x24:	/* rev SH-E5 (Lancaster?) */
    822       1.36       dsl 			return "Mobile Athlon 64 or Turion 64";
    823       1.36       dsl 		case 0x05:	/* rev SH-B0/B3/C0/CG (SledgeHammer?) */
    824       1.36       dsl 			return "Opteron or Athlon 64 FX";
    825       1.36       dsl 		case 0x15:	/* rev SH-D0 */
    826       1.36       dsl 		case 0x25:	/* rev SH-E4 */
    827       1.36       dsl 			return "Opteron";
    828       1.36       dsl 		case 0x27:	/* rev DH-E4, SH-E4 */
    829       1.36       dsl 			return "Athlon 64 or Athlon 64 FX or Opteron";
    830       1.36       dsl 		case 0x48:	/* rev BH-F2 */
    831       1.36       dsl 			return "Turion 64 X2";
    832       1.36       dsl 		case 0x04:	/* rev SH-B0/C0/CG (ClawHammer) */
    833       1.36       dsl 		case 0x07:	/* rev SH-CG (ClawHammer) */
    834       1.36       dsl 		case 0x0b:	/* rev CH-CG */
    835       1.36       dsl 		case 0x14:	/* rev SH-D0 */
    836       1.36       dsl 		case 0x17:	/* rev SH-D0 */
    837       1.36       dsl 		case 0x1b:	/* rev CH-D0 */
    838       1.36       dsl 			return "Athlon 64";
    839       1.36       dsl 		case 0x2b:	/* rev BH-E4 (Manchester) */
    840       1.36       dsl 		case 0x4b:	/* rev BH-F2 (Windsor) */
    841       1.36       dsl 			return "Athlon 64 X2";
    842       1.36       dsl 		case 0x6b:	/* rev BH-G1 (Brisbane) */
    843       1.36       dsl 			return "Athlon X2 or Athlon 64 X2";
    844       1.36       dsl 		case 0x08:	/* rev CH-CG */
    845       1.36       dsl 		case 0x0c:	/* rev DH-CG (Newcastle) */
    846       1.36       dsl 		case 0x0e:	/* rev DH-CG (Newcastle?) */
    847       1.36       dsl 		case 0x0f:	/* rev DH-CG (Newcastle/Paris) */
    848       1.36       dsl 		case 0x18:	/* rev CH-D0 */
    849       1.36       dsl 		case 0x1c:	/* rev DH-D0 (Winchester) */
    850       1.36       dsl 		case 0x1f:	/* rev DH-D0 (Winchester/Victoria) */
    851       1.36       dsl 		case 0x2c:	/* rev DH-E3/E6 */
    852       1.36       dsl 		case 0x2f:	/* rev DH-E3/E6 (Venice/Palermo) */
    853       1.36       dsl 		case 0x4f:	/* rev DH-F2 (Orleans/Manila) */
    854       1.36       dsl 		case 0x5f:	/* rev DH-F2 (Orleans/Manila) */
    855       1.36       dsl 		case 0x6f:	/* rev DH-G1 */
    856       1.36       dsl 			return "Athlon 64 or Sempron";
    857       1.36       dsl 		default:
    858        1.1        ad 			break;
    859        1.1        ad 		}
    860       1.36       dsl 		return "Unknown AMD64 CPU";
    861       1.36       dsl 
    862       1.36       dsl #if 0
    863       1.36       dsl 	case 16:
    864       1.36       dsl 		return "Family 10h";
    865       1.36       dsl 	case 17:
    866       1.36       dsl 		return "Family 11h";
    867       1.36       dsl 	case 18:
    868       1.36       dsl 		return "Family 12h";
    869       1.36       dsl 	case 19:
    870       1.36       dsl 		return "Family 14h";
    871       1.36       dsl 	case 20:
    872       1.36       dsl 		return "Family 15h";
    873       1.36       dsl #endif
    874       1.36       dsl 
    875       1.31    cegger 	default:
    876       1.25    jruoho 		break;
    877        1.1        ad 	}
    878        1.1        ad 
    879       1.36       dsl 	snprintf(family_str, sizeof family_str, "Family %xh", ci->ci_family);
    880       1.36       dsl 	return family_str;
    881        1.1        ad }
    882        1.1        ad 
    883        1.1        ad static void
    884       1.44   msaitoh intel_family_new_probe(struct cpu_info *ci)
    885        1.1        ad {
    886       1.44   msaitoh 	uint32_t descs[4];
    887        1.1        ad 
    888       1.44   msaitoh 	x86_cpuid(0x80000000, descs);
    889       1.34       dsl 
    890       1.44   msaitoh 	/*
    891       1.44   msaitoh 	 * Determine extended feature flags.
    892       1.44   msaitoh 	 */
    893       1.44   msaitoh 	if (descs[0] >= 0x80000001) {
    894       1.44   msaitoh 		x86_cpuid(0x80000001, descs);
    895       1.44   msaitoh 		ci->ci_feat_val[2] |= descs[3];
    896       1.44   msaitoh 		ci->ci_feat_val[3] |= descs[2];
    897       1.34       dsl 	}
    898       1.44   msaitoh }
    899       1.44   msaitoh 
    900       1.44   msaitoh static void
    901       1.44   msaitoh via_cpu_probe(struct cpu_info *ci)
    902       1.44   msaitoh {
    903       1.50   msaitoh 	u_int stepping = CPUID_TO_STEPPING(ci->ci_signature);
    904       1.44   msaitoh 	u_int descs[4];
    905       1.44   msaitoh 	u_int lfunc;
    906        1.1        ad 
    907       1.44   msaitoh 	/*
    908       1.44   msaitoh 	 * Determine the largest extended function value.
    909       1.44   msaitoh 	 */
    910       1.44   msaitoh 	x86_cpuid(0x80000000, descs);
    911       1.44   msaitoh 	lfunc = descs[0];
    912        1.1        ad 
    913       1.44   msaitoh 	/*
    914       1.44   msaitoh 	 * Determine the extended feature flags.
    915       1.44   msaitoh 	 */
    916       1.44   msaitoh 	if (lfunc >= 0x80000001) {
    917       1.44   msaitoh 		x86_cpuid(0x80000001, descs);
    918       1.44   msaitoh 		ci->ci_feat_val[2] |= descs[3];
    919        1.1        ad 	}
    920        1.1        ad 
    921       1.44   msaitoh 	if (ci->ci_model < 0x9 || (ci->ci_model == 0x9 && stepping < 3))
    922       1.44   msaitoh 		return;
    923       1.44   msaitoh 
    924       1.44   msaitoh 	/* Nehemiah or Esther */
    925       1.44   msaitoh 	x86_cpuid(0xc0000000, descs);
    926       1.44   msaitoh 	lfunc = descs[0];
    927       1.44   msaitoh 	if (lfunc < 0xc0000001)	/* no ACE, no RNG */
    928        1.1        ad 		return;
    929        1.1        ad 
    930       1.44   msaitoh 	x86_cpuid(0xc0000001, descs);
    931       1.44   msaitoh 	lfunc = descs[3];
    932       1.44   msaitoh 	ci->ci_feat_val[4] = lfunc;
    933       1.44   msaitoh }
    934       1.36       dsl 
    935       1.44   msaitoh static void
    936       1.44   msaitoh amd_family6_probe(struct cpu_info *ci)
    937       1.44   msaitoh {
    938       1.44   msaitoh 	uint32_t descs[4];
    939       1.44   msaitoh 	char *p;
    940       1.44   msaitoh 	size_t i;
    941       1.36       dsl 
    942       1.44   msaitoh 	x86_cpuid(0x80000000, descs);
    943       1.36       dsl 
    944       1.44   msaitoh 	/*
    945       1.44   msaitoh 	 * Determine the extended feature flags.
    946       1.44   msaitoh 	 */
    947       1.44   msaitoh 	if (descs[0] >= 0x80000001) {
    948       1.44   msaitoh 		x86_cpuid(0x80000001, descs);
    949       1.44   msaitoh 		ci->ci_feat_val[2] |= descs[3]; /* %edx */
    950       1.44   msaitoh 		ci->ci_feat_val[3] = descs[2]; /* %ecx */
    951       1.44   msaitoh 	}
    952        1.1        ad 
    953       1.44   msaitoh 	if (*cpu_brand_string == '\0')
    954        1.1        ad 		return;
    955      1.103   msaitoh 
    956       1.44   msaitoh 	for (i = 1; i < __arraycount(amd_brand); i++)
    957       1.44   msaitoh 		if ((p = strstr(cpu_brand_string, amd_brand[i])) != NULL) {
    958       1.44   msaitoh 			ci->ci_brand_id = i;
    959       1.44   msaitoh 			strlcpy(amd_brand_name, p, sizeof(amd_brand_name));
    960       1.44   msaitoh 			break;
    961       1.44   msaitoh 		}
    962       1.44   msaitoh }
    963       1.44   msaitoh 
    964       1.52   msaitoh static void
    965       1.52   msaitoh intel_cpu_cacheinfo(struct cpu_info *ci)
    966       1.52   msaitoh {
    967       1.52   msaitoh 	const struct x86_cache_info *cai;
    968       1.52   msaitoh 	u_int descs[4];
    969       1.52   msaitoh 	int iterations, i, j;
    970      1.104   msaitoh 	int type, level, ways, linesize, sets;
    971       1.52   msaitoh 	int caitype = -1;
    972       1.52   msaitoh 	uint8_t desc;
    973       1.52   msaitoh 
    974       1.52   msaitoh 	/* Return if the cpu is old pre-cpuid instruction cpu */
    975       1.52   msaitoh 	if (ci->ci_cpu_type >= 0)
    976       1.52   msaitoh 		return;
    977       1.52   msaitoh 
    978      1.111   msaitoh 	if (ci->ci_max_cpuid < 2)
    979       1.52   msaitoh 		return;
    980       1.52   msaitoh 
    981       1.52   msaitoh 	/*
    982       1.52   msaitoh 	 * Parse the cache info from `cpuid leaf 2', if we have it.
    983       1.52   msaitoh 	 * XXX This is kinda ugly, but hey, so is the architecture...
    984       1.52   msaitoh 	 */
    985       1.52   msaitoh 	x86_cpuid(2, descs);
    986       1.52   msaitoh 	iterations = descs[0] & 0xff;
    987       1.52   msaitoh 	while (iterations-- > 0) {
    988       1.52   msaitoh 		for (i = 0; i < 4; i++) {
    989       1.52   msaitoh 			if (descs[i] & 0x80000000)
    990       1.52   msaitoh 				continue;
    991       1.52   msaitoh 			for (j = 0; j < 4; j++) {
    992       1.65   msaitoh 				/*
    993       1.65   msaitoh 				 * The least significant byte in EAX
    994       1.65   msaitoh 				 * ((desc[0] >> 0) & 0xff) is always 0x01 and
    995       1.65   msaitoh 				 * it should be ignored.
    996       1.65   msaitoh 				 */
    997       1.52   msaitoh 				if (i == 0 && j == 0)
    998       1.52   msaitoh 					continue;
    999       1.52   msaitoh 				desc = (descs[i] >> (j * 8)) & 0xff;
   1000       1.52   msaitoh 				if (desc == 0)
   1001       1.52   msaitoh 					continue;
   1002      1.122   msaitoh 				cai = cpu_cacheinfo_lookup(
   1003      1.122   msaitoh 					intel_cpuid_cache_info, desc);
   1004       1.52   msaitoh 				if (cai != NULL)
   1005       1.52   msaitoh 					ci->ci_cinfo[cai->cai_index] = *cai;
   1006       1.81   msaitoh 				else if ((verbose != 0) && (desc != 0xff)
   1007       1.81   msaitoh 				    && (desc != 0xfe))
   1008       1.81   msaitoh 					aprint_error_dev(ci->ci_dev, "error:"
   1009       1.81   msaitoh 					    " Unknown cacheinfo desc %02x\n",
   1010       1.55   msaitoh 					    desc);
   1011       1.52   msaitoh 			}
   1012       1.52   msaitoh 		}
   1013       1.52   msaitoh 		x86_cpuid(2, descs);
   1014       1.52   msaitoh 	}
   1015       1.52   msaitoh 
   1016      1.111   msaitoh 	if (ci->ci_max_cpuid < 4)
   1017       1.52   msaitoh 		return;
   1018       1.52   msaitoh 
   1019       1.52   msaitoh 	/* Parse the cache info from `cpuid leaf 4', if we have it. */
   1020      1.104   msaitoh 	cpu_dcp_cacheinfo(ci, 4);
   1021       1.81   msaitoh 
   1022      1.111   msaitoh 	if (ci->ci_max_cpuid < 0x18)
   1023       1.81   msaitoh 		return;
   1024       1.81   msaitoh 	/* Parse the TLB info from `cpuid leaf 18H', if we have it. */
   1025       1.81   msaitoh 	x86_cpuid(0x18, descs);
   1026       1.81   msaitoh 	iterations = descs[0];
   1027       1.81   msaitoh 	for (i = 0; i <= iterations; i++) {
   1028       1.83   msaitoh 		uint32_t pgsize;
   1029       1.82   msaitoh 		bool full;
   1030       1.82   msaitoh 
   1031       1.81   msaitoh 		x86_cpuid2(0x18, i, descs);
   1032       1.81   msaitoh 		type = __SHIFTOUT(descs[3], CPUID_DATP_TCTYPE);
   1033       1.81   msaitoh 		if (type == CPUID_DATP_TCTYPE_N)
   1034       1.81   msaitoh 			continue;
   1035       1.81   msaitoh 		level = __SHIFTOUT(descs[3], CPUID_DATP_TCLEVEL);
   1036       1.83   msaitoh 		pgsize = __SHIFTOUT(descs[1], CPUID_DATP_PGSIZE);
   1037       1.81   msaitoh 		switch (level) {
   1038       1.81   msaitoh 		case 1:
   1039       1.83   msaitoh 			if (type == CPUID_DATP_TCTYPE_I) {
   1040       1.83   msaitoh 				switch (pgsize) {
   1041       1.83   msaitoh 				case CPUID_DATP_PGSIZE_4KB:
   1042       1.83   msaitoh 					caitype = CAI_ITLB;
   1043       1.83   msaitoh 					break;
   1044       1.83   msaitoh 				case CPUID_DATP_PGSIZE_2MB
   1045       1.83   msaitoh 				    | CPUID_DATP_PGSIZE_4MB:
   1046       1.83   msaitoh 					caitype = CAI_ITLB2;
   1047       1.83   msaitoh 					break;
   1048       1.83   msaitoh 				case CPUID_DATP_PGSIZE_1GB:
   1049       1.83   msaitoh 					caitype = CAI_L1_1GBITLB;
   1050       1.83   msaitoh 					break;
   1051       1.83   msaitoh 				default:
   1052       1.83   msaitoh 					aprint_error_dev(ci->ci_dev,
   1053       1.83   msaitoh 					    "error: unknown ITLB size (%d)\n",
   1054       1.83   msaitoh 					    pgsize);
   1055       1.83   msaitoh 					caitype = CAI_ITLB;
   1056       1.83   msaitoh 					break;
   1057       1.83   msaitoh 				}
   1058       1.83   msaitoh 			} else if (type == CPUID_DATP_TCTYPE_D) {
   1059       1.83   msaitoh 				switch (pgsize) {
   1060       1.83   msaitoh 				case CPUID_DATP_PGSIZE_4KB:
   1061       1.83   msaitoh 					caitype = CAI_DTLB;
   1062       1.83   msaitoh 					break;
   1063       1.83   msaitoh 				case CPUID_DATP_PGSIZE_2MB
   1064       1.83   msaitoh 				    | CPUID_DATP_PGSIZE_4MB:
   1065       1.83   msaitoh 					caitype = CAI_DTLB2;
   1066       1.83   msaitoh 					break;
   1067       1.83   msaitoh 				case CPUID_DATP_PGSIZE_1GB:
   1068       1.83   msaitoh 					caitype = CAI_L1_1GBDTLB;
   1069       1.83   msaitoh 					break;
   1070       1.83   msaitoh 				default:
   1071       1.83   msaitoh 					aprint_error_dev(ci->ci_dev,
   1072       1.83   msaitoh 					    "error: unknown DTLB size (%d)\n",
   1073       1.83   msaitoh 					    pgsize);
   1074       1.83   msaitoh 					caitype = CAI_DTLB;
   1075       1.83   msaitoh 					break;
   1076       1.83   msaitoh 				}
   1077      1.120   msaitoh 			} else if (type == CPUID_DATP_TCTYPE_L)
   1078      1.120   msaitoh 				caitype = CAI_L1_LD_TLB;
   1079      1.120   msaitoh 			else if (type == CPUID_DATP_TCTYPE_S)
   1080      1.120   msaitoh 				caitype = CAI_L1_ST_TLB;
   1081      1.120   msaitoh 			else
   1082       1.81   msaitoh 				caitype = -1;
   1083       1.81   msaitoh 			break;
   1084       1.81   msaitoh 		case 2:
   1085       1.81   msaitoh 			if (type == CPUID_DATP_TCTYPE_I)
   1086       1.81   msaitoh 				caitype = CAI_L2_ITLB;
   1087       1.81   msaitoh 			else if (type == CPUID_DATP_TCTYPE_D)
   1088       1.81   msaitoh 				caitype = CAI_L2_DTLB;
   1089       1.83   msaitoh 			else if (type == CPUID_DATP_TCTYPE_U) {
   1090      1.121   msaitoh 				if (pgsize == CPUID_DATP_PGSIZE_4KB)
   1091       1.83   msaitoh 					caitype = CAI_L2_STLB;
   1092      1.121   msaitoh 				else if (pgsize == (CPUID_DATP_PGSIZE_4KB
   1093      1.121   msaitoh 					| CPUID_DATP_PGSIZE_2MB))
   1094       1.83   msaitoh 					caitype = CAI_L2_STLB2;
   1095      1.121   msaitoh 				else if (pgsize == (CPUID_DATP_PGSIZE_2MB
   1096      1.121   msaitoh 					| CPUID_DATP_PGSIZE_4MB))
   1097      1.121   msaitoh 					caitype = CAI_L2_STLB3;
   1098      1.121   msaitoh 				else if ((pgsize & CPUID_DATP_PGSIZE_1GB)
   1099      1.121   msaitoh 				    != 0) {
   1100      1.121   msaitoh 					/* FIXME: 1GB max TLB */
   1101      1.121   msaitoh 					caitype = CAI_L2_STLB3;
   1102      1.121   msaitoh 					linesize = 1024 * 1024 * 1024;
   1103      1.121   msaitoh 				} else if ((pgsize & CPUID_DATP_PGSIZE_4MB)
   1104      1.121   msaitoh 				    != 0) {
   1105      1.121   msaitoh 					/* FIXME: 4MB max TLB */
   1106       1.83   msaitoh 					caitype = CAI_L2_STLB3;
   1107      1.121   msaitoh 					linesize = 4 * 1024 * 1024;
   1108      1.121   msaitoh 				} else if ((pgsize & CPUID_DATP_PGSIZE_2MB)
   1109      1.121   msaitoh 				    != 0) {
   1110      1.121   msaitoh 					/* FIXME: 2MB max TLB */
   1111      1.121   msaitoh 					caitype = CAI_L2_STLB2;
   1112      1.121   msaitoh 					linesize = 2 * 1024 * 1024;
   1113      1.121   msaitoh 				} else {
   1114      1.121   msaitoh 					aprint_error_dev(ci->ci_dev, "error: "
   1115      1.121   msaitoh 					    "unknown L2 STLB size (%d)\n",
   1116       1.83   msaitoh 					    pgsize);
   1117      1.121   msaitoh 					caitype = CAI_L2_STLB;
   1118      1.121   msaitoh 					linesize = 4 * 1024;
   1119       1.83   msaitoh 				}
   1120       1.83   msaitoh 			} else
   1121       1.81   msaitoh 				caitype = -1;
   1122       1.81   msaitoh 			break;
   1123       1.81   msaitoh 		case 3:
   1124       1.81   msaitoh 			/* XXX need work for L3 TLB */
   1125       1.81   msaitoh 			caitype = CAI_L3CACHE;
   1126       1.81   msaitoh 			break;
   1127       1.81   msaitoh 		default:
   1128       1.81   msaitoh 			caitype = -1;
   1129       1.81   msaitoh 			break;
   1130       1.81   msaitoh 		}
   1131       1.81   msaitoh 		if (caitype == -1) {
   1132       1.81   msaitoh 			aprint_error_dev(ci->ci_dev,
   1133       1.81   msaitoh 			    "error: unknown TLB level&type (%d & %d)\n",
   1134       1.81   msaitoh 			    level, type);
   1135       1.81   msaitoh 			continue;
   1136       1.81   msaitoh 		}
   1137       1.83   msaitoh 		switch (pgsize) {
   1138       1.81   msaitoh 		case CPUID_DATP_PGSIZE_4KB:
   1139       1.81   msaitoh 			linesize = 4 * 1024;
   1140       1.81   msaitoh 			break;
   1141       1.81   msaitoh 		case CPUID_DATP_PGSIZE_2MB:
   1142       1.81   msaitoh 			linesize = 2 * 1024 * 1024;
   1143       1.81   msaitoh 			break;
   1144       1.81   msaitoh 		case CPUID_DATP_PGSIZE_4MB:
   1145       1.81   msaitoh 			linesize = 4 * 1024 * 1024;
   1146       1.81   msaitoh 			break;
   1147       1.81   msaitoh 		case CPUID_DATP_PGSIZE_1GB:
   1148       1.81   msaitoh 			linesize = 1024 * 1024 * 1024;
   1149       1.81   msaitoh 			break;
   1150       1.81   msaitoh 		default:
   1151      1.121   msaitoh 			if ((pgsize & CPUID_DATP_PGSIZE_1GB) != 0)
   1152      1.121   msaitoh 				linesize = 1024 * 1024 * 1024; /* MAX 1G */
   1153      1.121   msaitoh 			else if ((pgsize & CPUID_DATP_PGSIZE_4MB) != 0)
   1154      1.121   msaitoh 				linesize = 4 * 1024 * 1024; /* MAX 4M */
   1155      1.121   msaitoh 			else if ((pgsize & CPUID_DATP_PGSIZE_2MB) != 0)
   1156      1.121   msaitoh 				linesize = 2 * 1024 * 1024; /* MAX 2M */
   1157      1.121   msaitoh 			else
   1158      1.121   msaitoh 				linesize = 4 * 1024;	/* XXX default to 4K */
   1159      1.121   msaitoh 			aprint_error_dev(ci->ci_dev, "WARNING: Currently "
   1160      1.121   msaitoh 			    "this info can't print correctly "
   1161      1.121   msaitoh 			    "(level = %d, pgsize = %d)\n",
   1162      1.121   msaitoh 			    level, pgsize);
   1163       1.81   msaitoh 			break;
   1164       1.81   msaitoh 		}
   1165       1.81   msaitoh 		ways = __SHIFTOUT(descs[1], CPUID_DATP_WAYS);
   1166       1.81   msaitoh 		sets = descs[2];
   1167       1.82   msaitoh 		full = descs[3] & CPUID_DATP_FULLASSOC;
   1168       1.82   msaitoh 		ci->ci_cinfo[caitype].cai_totalsize
   1169       1.82   msaitoh 		    = ways * sets; /* entries */
   1170       1.82   msaitoh 		ci->ci_cinfo[caitype].cai_associativity
   1171       1.82   msaitoh 		    = full ? 0xff : ways;
   1172       1.83   msaitoh 		ci->ci_cinfo[caitype].cai_linesize = linesize; /* pg size */
   1173       1.81   msaitoh 	}
   1174       1.52   msaitoh }
   1175       1.52   msaitoh 
   1176      1.104   msaitoh static const struct x86_cache_info amd_cpuid_l2l3cache_assoc_info[] =
   1177      1.104   msaitoh     AMD_L2L3CACHE_INFO;
   1178       1.44   msaitoh 
   1179       1.44   msaitoh static void
   1180       1.44   msaitoh amd_cpu_cacheinfo(struct cpu_info *ci)
   1181       1.44   msaitoh {
   1182       1.44   msaitoh 	const struct x86_cache_info *cp;
   1183       1.44   msaitoh 	struct x86_cache_info *cai;
   1184       1.44   msaitoh 	u_int descs[4];
   1185       1.44   msaitoh 	u_int lfunc;
   1186        1.1        ad 
   1187      1.104   msaitoh 	/* K5 model 0 has none of this info. */
   1188       1.44   msaitoh 	if (ci->ci_family == 5 && ci->ci_model == 0)
   1189       1.44   msaitoh 		return;
   1190        1.1        ad 
   1191      1.104   msaitoh 	/* Determine the largest extended function value. */
   1192       1.44   msaitoh 	x86_cpuid(0x80000000, descs);
   1193       1.44   msaitoh 	lfunc = descs[0];
   1194        1.1        ad 
   1195      1.104   msaitoh 	if (lfunc < 0x80000005)
   1196       1.44   msaitoh 		return;
   1197        1.1        ad 
   1198      1.104   msaitoh 	/* Determine L1 cache/TLB info. */
   1199       1.44   msaitoh 	x86_cpuid(0x80000005, descs);
   1200        1.1        ad 
   1201      1.104   msaitoh 	/* K6-III and higher have large page TLBs. */
   1202       1.44   msaitoh 	if ((ci->ci_family == 5 && ci->ci_model >= 9) || ci->ci_family >= 6) {
   1203       1.44   msaitoh 		cai = &ci->ci_cinfo[CAI_ITLB2];
   1204       1.44   msaitoh 		cai->cai_totalsize = AMD_L1_EAX_ITLB_ENTRIES(descs[0]);
   1205       1.44   msaitoh 		cai->cai_associativity = AMD_L1_EAX_ITLB_ASSOC(descs[0]);
   1206       1.44   msaitoh 		cai->cai_linesize = largepagesize;
   1207       1.44   msaitoh 
   1208       1.44   msaitoh 		cai = &ci->ci_cinfo[CAI_DTLB2];
   1209       1.44   msaitoh 		cai->cai_totalsize = AMD_L1_EAX_DTLB_ENTRIES(descs[0]);
   1210       1.44   msaitoh 		cai->cai_associativity = AMD_L1_EAX_DTLB_ASSOC(descs[0]);
   1211       1.44   msaitoh 		cai->cai_linesize = largepagesize;
   1212        1.1        ad 	}
   1213       1.38       dsl 
   1214       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_ITLB];
   1215       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_EBX_ITLB_ENTRIES(descs[1]);
   1216       1.44   msaitoh 	cai->cai_associativity = AMD_L1_EBX_ITLB_ASSOC(descs[1]);
   1217       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1218       1.38       dsl 
   1219       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_DTLB];
   1220       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_EBX_DTLB_ENTRIES(descs[1]);
   1221       1.44   msaitoh 	cai->cai_associativity = AMD_L1_EBX_DTLB_ASSOC(descs[1]);
   1222       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1223       1.38       dsl 
   1224       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_DCACHE];
   1225       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_ECX_DC_SIZE(descs[2]);
   1226       1.44   msaitoh 	cai->cai_associativity = AMD_L1_ECX_DC_ASSOC(descs[2]);
   1227       1.44   msaitoh 	cai->cai_linesize = AMD_L1_ECX_DC_LS(descs[2]);
   1228        1.1        ad 
   1229       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_ICACHE];
   1230       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_EDX_IC_SIZE(descs[3]);
   1231       1.44   msaitoh 	cai->cai_associativity = AMD_L1_EDX_IC_ASSOC(descs[3]);
   1232       1.44   msaitoh 	cai->cai_linesize = AMD_L1_EDX_IC_LS(descs[3]);
   1233        1.1        ad 
   1234      1.104   msaitoh 	if (lfunc < 0x80000006)
   1235        1.1        ad 		return;
   1236       1.44   msaitoh 
   1237      1.104   msaitoh 	/* Determine L2 cache/TLB info. */
   1238       1.44   msaitoh 	x86_cpuid(0x80000006, descs);
   1239        1.1        ad 
   1240       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_ITLB];
   1241       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_EBX_IUTLB_ENTRIES(descs[1]);
   1242       1.44   msaitoh 	cai->cai_associativity = AMD_L2_EBX_IUTLB_ASSOC(descs[1]);
   1243       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1244      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1245       1.44   msaitoh 	    cai->cai_associativity);
   1246       1.44   msaitoh 	if (cp != NULL)
   1247       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1248       1.44   msaitoh 	else
   1249       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1250        1.1        ad 
   1251       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_ITLB2];
   1252       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_EAX_IUTLB_ENTRIES(descs[0]);
   1253       1.44   msaitoh 	cai->cai_associativity = AMD_L2_EAX_IUTLB_ASSOC(descs[0]);
   1254       1.44   msaitoh 	cai->cai_linesize = largepagesize;
   1255      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1256       1.44   msaitoh 	    cai->cai_associativity);
   1257       1.44   msaitoh 	if (cp != NULL)
   1258       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1259       1.44   msaitoh 	else
   1260       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1261        1.1        ad 
   1262       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_DTLB];
   1263       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_EBX_DTLB_ENTRIES(descs[1]);
   1264       1.44   msaitoh 	cai->cai_associativity = AMD_L2_EBX_DTLB_ASSOC(descs[1]);
   1265       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1266      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1267       1.44   msaitoh 	    cai->cai_associativity);
   1268       1.44   msaitoh 	if (cp != NULL)
   1269       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1270       1.44   msaitoh 	else
   1271       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1272        1.1        ad 
   1273       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_DTLB2];
   1274       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_EAX_DTLB_ENTRIES(descs[0]);
   1275       1.44   msaitoh 	cai->cai_associativity = AMD_L2_EAX_DTLB_ASSOC(descs[0]);
   1276       1.44   msaitoh 	cai->cai_linesize = largepagesize;
   1277      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1278       1.44   msaitoh 	    cai->cai_associativity);
   1279       1.44   msaitoh 	if (cp != NULL)
   1280       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1281       1.44   msaitoh 	else
   1282       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1283        1.1        ad 
   1284       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2CACHE];
   1285       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_ECX_C_SIZE(descs[2]);
   1286       1.44   msaitoh 	cai->cai_associativity = AMD_L2_ECX_C_ASSOC(descs[2]);
   1287       1.44   msaitoh 	cai->cai_linesize = AMD_L2_ECX_C_LS(descs[2]);
   1288        1.1        ad 
   1289      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1290       1.44   msaitoh 	    cai->cai_associativity);
   1291       1.44   msaitoh 	if (cp != NULL)
   1292       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1293       1.44   msaitoh 	else
   1294       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1295        1.1        ad 
   1296      1.104   msaitoh 	/* Determine L3 cache info on AMD Family 10h and newer processors */
   1297       1.44   msaitoh 	if (ci->ci_family >= 0x10) {
   1298       1.44   msaitoh 		cai = &ci->ci_cinfo[CAI_L3CACHE];
   1299       1.44   msaitoh 		cai->cai_totalsize = AMD_L3_EDX_C_SIZE(descs[3]);
   1300       1.44   msaitoh 		cai->cai_associativity = AMD_L3_EDX_C_ASSOC(descs[3]);
   1301       1.44   msaitoh 		cai->cai_linesize = AMD_L3_EDX_C_LS(descs[3]);
   1302        1.1        ad 
   1303      1.122   msaitoh 		cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1304       1.44   msaitoh 		    cai->cai_associativity);
   1305       1.44   msaitoh 		if (cp != NULL)
   1306       1.44   msaitoh 			cai->cai_associativity = cp->cai_associativity;
   1307       1.44   msaitoh 		else
   1308       1.44   msaitoh 			cai->cai_associativity = 0;	/* XXX Unkn/Rsvd */
   1309       1.44   msaitoh 	}
   1310        1.1        ad 
   1311      1.104   msaitoh 	if (lfunc < 0x80000019)
   1312       1.44   msaitoh 		return;
   1313       1.44   msaitoh 
   1314      1.104   msaitoh 	/* Determine 1GB TLB info. */
   1315       1.44   msaitoh 	x86_cpuid(0x80000019, descs);
   1316       1.44   msaitoh 
   1317       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L1_1GBITLB];
   1318       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_1GB_EAX_IUTLB_ENTRIES(descs[0]);
   1319       1.44   msaitoh 	cai->cai_associativity = AMD_L1_1GB_EAX_IUTLB_ASSOC(descs[0]);
   1320       1.44   msaitoh 	cai->cai_linesize = (1024 * 1024 * 1024);
   1321      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1322       1.44   msaitoh 	    cai->cai_associativity);
   1323       1.44   msaitoh 	if (cp != NULL)
   1324       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1325       1.44   msaitoh 	else
   1326       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1327       1.44   msaitoh 
   1328       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L1_1GBDTLB];
   1329       1.44   msaitoh 	cai->cai_totalsize = AMD_L1_1GB_EAX_DTLB_ENTRIES(descs[0]);
   1330       1.44   msaitoh 	cai->cai_associativity = AMD_L1_1GB_EAX_DTLB_ASSOC(descs[0]);
   1331       1.44   msaitoh 	cai->cai_linesize = (1024 * 1024 * 1024);
   1332      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1333       1.44   msaitoh 	    cai->cai_associativity);
   1334       1.44   msaitoh 	if (cp != NULL)
   1335       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1336       1.44   msaitoh 	else
   1337       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1338       1.44   msaitoh 
   1339       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_1GBITLB];
   1340       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_1GB_EBX_IUTLB_ENTRIES(descs[1]);
   1341       1.44   msaitoh 	cai->cai_associativity = AMD_L2_1GB_EBX_IUTLB_ASSOC(descs[1]);
   1342       1.44   msaitoh 	cai->cai_linesize = (1024 * 1024 * 1024);
   1343      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1344       1.44   msaitoh 	    cai->cai_associativity);
   1345       1.44   msaitoh 	if (cp != NULL)
   1346       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1347       1.44   msaitoh 	else
   1348       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1349       1.44   msaitoh 
   1350       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2_1GBDTLB];
   1351       1.44   msaitoh 	cai->cai_totalsize = AMD_L2_1GB_EBX_DUTLB_ENTRIES(descs[1]);
   1352       1.44   msaitoh 	cai->cai_associativity = AMD_L2_1GB_EBX_DUTLB_ASSOC(descs[1]);
   1353       1.44   msaitoh 	cai->cai_linesize = (1024 * 1024 * 1024);
   1354      1.122   msaitoh 	cp = cpu_cacheinfo_lookup(amd_cpuid_l2l3cache_assoc_info,
   1355       1.44   msaitoh 	    cai->cai_associativity);
   1356       1.44   msaitoh 	if (cp != NULL)
   1357       1.44   msaitoh 		cai->cai_associativity = cp->cai_associativity;
   1358       1.44   msaitoh 	else
   1359       1.44   msaitoh 		cai->cai_associativity = 0;	/* XXX Unknown/reserved */
   1360      1.104   msaitoh 
   1361      1.104   msaitoh 	if (lfunc < 0x8000001d)
   1362      1.104   msaitoh 		return;
   1363      1.104   msaitoh 
   1364      1.106   msaitoh 	if (ci->ci_feat_val[3] & CPUID_TOPOEXT)
   1365      1.106   msaitoh 		cpu_dcp_cacheinfo(ci, 0x8000001d);
   1366        1.1        ad }
   1367        1.1        ad 
   1368        1.1        ad static void
   1369       1.44   msaitoh via_cpu_cacheinfo(struct cpu_info *ci)
   1370        1.1        ad {
   1371       1.44   msaitoh 	struct x86_cache_info *cai;
   1372       1.44   msaitoh 	int stepping;
   1373       1.44   msaitoh 	u_int descs[4];
   1374       1.44   msaitoh 	u_int lfunc;
   1375       1.44   msaitoh 
   1376       1.50   msaitoh 	stepping = CPUID_TO_STEPPING(ci->ci_signature);
   1377        1.1        ad 
   1378       1.44   msaitoh 	/*
   1379       1.44   msaitoh 	 * Determine the largest extended function value.
   1380       1.44   msaitoh 	 */
   1381        1.1        ad 	x86_cpuid(0x80000000, descs);
   1382       1.44   msaitoh 	lfunc = descs[0];
   1383        1.1        ad 
   1384        1.1        ad 	/*
   1385       1.44   msaitoh 	 * Determine L1 cache/TLB info.
   1386        1.1        ad 	 */
   1387       1.44   msaitoh 	if (lfunc < 0x80000005) {
   1388       1.44   msaitoh 		/* No L1 cache info available. */
   1389       1.44   msaitoh 		return;
   1390        1.1        ad 	}
   1391        1.1        ad 
   1392       1.44   msaitoh 	x86_cpuid(0x80000005, descs);
   1393       1.44   msaitoh 
   1394       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_ITLB];
   1395       1.44   msaitoh 	cai->cai_totalsize = VIA_L1_EBX_ITLB_ENTRIES(descs[1]);
   1396       1.44   msaitoh 	cai->cai_associativity = VIA_L1_EBX_ITLB_ASSOC(descs[1]);
   1397       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1398       1.44   msaitoh 
   1399       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_DTLB];
   1400       1.44   msaitoh 	cai->cai_totalsize = VIA_L1_EBX_DTLB_ENTRIES(descs[1]);
   1401       1.44   msaitoh 	cai->cai_associativity = VIA_L1_EBX_DTLB_ASSOC(descs[1]);
   1402       1.44   msaitoh 	cai->cai_linesize = (4 * 1024);
   1403       1.44   msaitoh 
   1404       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_DCACHE];
   1405       1.44   msaitoh 	cai->cai_totalsize = VIA_L1_ECX_DC_SIZE(descs[2]);
   1406       1.44   msaitoh 	cai->cai_associativity = VIA_L1_ECX_DC_ASSOC(descs[2]);
   1407       1.44   msaitoh 	cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[2]);
   1408       1.44   msaitoh 	if (ci->ci_model == 9 && stepping == 8) {
   1409       1.44   msaitoh 		/* Erratum: stepping 8 reports 4 when it should be 2 */
   1410       1.44   msaitoh 		cai->cai_associativity = 2;
   1411       1.44   msaitoh 	}
   1412       1.44   msaitoh 
   1413       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_ICACHE];
   1414       1.44   msaitoh 	cai->cai_totalsize = VIA_L1_EDX_IC_SIZE(descs[3]);
   1415       1.44   msaitoh 	cai->cai_associativity = VIA_L1_EDX_IC_ASSOC(descs[3]);
   1416       1.44   msaitoh 	cai->cai_linesize = VIA_L1_EDX_IC_LS(descs[3]);
   1417       1.44   msaitoh 	if (ci->ci_model == 9 && stepping == 8) {
   1418       1.44   msaitoh 		/* Erratum: stepping 8 reports 4 when it should be 2 */
   1419       1.44   msaitoh 		cai->cai_associativity = 2;
   1420       1.44   msaitoh 	}
   1421       1.44   msaitoh 
   1422       1.44   msaitoh 	/*
   1423       1.44   msaitoh 	 * Determine L2 cache/TLB info.
   1424       1.44   msaitoh 	 */
   1425       1.44   msaitoh 	if (lfunc < 0x80000006) {
   1426       1.44   msaitoh 		/* No L2 cache info available. */
   1427        1.1        ad 		return;
   1428       1.44   msaitoh 	}
   1429        1.1        ad 
   1430       1.44   msaitoh 	x86_cpuid(0x80000006, descs);
   1431        1.1        ad 
   1432       1.44   msaitoh 	cai = &ci->ci_cinfo[CAI_L2CACHE];
   1433       1.44   msaitoh 	if (ci->ci_model >= 9) {
   1434       1.44   msaitoh 		cai->cai_totalsize = VIA_L2N_ECX_C_SIZE(descs[2]);
   1435       1.44   msaitoh 		cai->cai_associativity = VIA_L2N_ECX_C_ASSOC(descs[2]);
   1436       1.44   msaitoh 		cai->cai_linesize = VIA_L2N_ECX_C_LS(descs[2]);
   1437       1.44   msaitoh 	} else {
   1438       1.44   msaitoh 		cai->cai_totalsize = VIA_L2_ECX_C_SIZE(descs[2]);
   1439       1.44   msaitoh 		cai->cai_associativity = VIA_L2_ECX_C_ASSOC(descs[2]);
   1440       1.44   msaitoh 		cai->cai_linesize = VIA_L2_ECX_C_LS(descs[2]);
   1441        1.1        ad 	}
   1442        1.1        ad }
   1443        1.1        ad 
   1444        1.1        ad static void
   1445        1.1        ad tmx86_get_longrun_status(u_int *frequency, u_int *voltage, u_int *percentage)
   1446        1.1        ad {
   1447        1.1        ad 	u_int descs[4];
   1448        1.1        ad 
   1449        1.1        ad 	x86_cpuid(0x80860007, descs);
   1450        1.1        ad 	*frequency = descs[0];
   1451        1.1        ad 	*voltage = descs[1];
   1452        1.1        ad 	*percentage = descs[2];
   1453        1.1        ad }
   1454        1.1        ad 
   1455        1.1        ad static void
   1456        1.1        ad transmeta_cpu_info(struct cpu_info *ci)
   1457        1.1        ad {
   1458        1.1        ad 	u_int descs[4], nreg;
   1459        1.1        ad 	u_int frequency, voltage, percentage;
   1460        1.1        ad 
   1461        1.1        ad 	x86_cpuid(0x80860000, descs);
   1462        1.1        ad 	nreg = descs[0];
   1463        1.1        ad 	if (nreg >= 0x80860001) {
   1464        1.1        ad 		x86_cpuid(0x80860001, descs);
   1465        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "Processor revision %u.%u.%u.%u\n",
   1466        1.1        ad 		    (descs[1] >> 24) & 0xff,
   1467        1.1        ad 		    (descs[1] >> 16) & 0xff,
   1468        1.1        ad 		    (descs[1] >> 8) & 0xff,
   1469        1.1        ad 		    descs[1] & 0xff);
   1470        1.1        ad 	}
   1471        1.1        ad 	if (nreg >= 0x80860002) {
   1472        1.1        ad 		x86_cpuid(0x80860002, descs);
   1473        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "Code Morphing Software Rev: %u.%u.%u-%u-%u\n",
   1474        1.1        ad 		    (descs[1] >> 24) & 0xff,
   1475        1.1        ad 		    (descs[1] >> 16) & 0xff,
   1476        1.1        ad 		    (descs[1] >> 8) & 0xff,
   1477        1.1        ad 		    descs[1] & 0xff,
   1478        1.1        ad 		    descs[2]);
   1479        1.1        ad 	}
   1480        1.1        ad 	if (nreg >= 0x80860006) {
   1481        1.1        ad 		union {
   1482        1.1        ad 			char text[65];
   1483        1.1        ad 			u_int descs[4][4];
   1484        1.1        ad 		} info;
   1485        1.1        ad 		int i;
   1486        1.1        ad 
   1487        1.1        ad 		for (i=0; i<4; i++) {
   1488        1.1        ad 			x86_cpuid(0x80860003 + i, info.descs[i]);
   1489        1.1        ad 		}
   1490        1.1        ad 		info.text[64] = '\0';
   1491        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "%s\n", info.text);
   1492        1.1        ad 	}
   1493        1.1        ad 
   1494        1.1        ad 	if (nreg >= 0x80860007) {
   1495        1.1        ad 		tmx86_get_longrun_status(&frequency,
   1496        1.1        ad 		    &voltage, &percentage);
   1497        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "LongRun <%dMHz %dmV %d%%>\n",
   1498        1.1        ad 		    frequency, voltage, percentage);
   1499        1.1        ad 	}
   1500        1.1        ad }
   1501        1.1        ad 
   1502       1.38       dsl static void
   1503       1.44   msaitoh cpu_probe_base_features(struct cpu_info *ci, const char *cpuname)
   1504       1.44   msaitoh {
   1505       1.44   msaitoh 	u_int descs[4];
   1506       1.52   msaitoh 	int i;
   1507       1.44   msaitoh 	uint32_t brand[12];
   1508       1.44   msaitoh 
   1509       1.44   msaitoh 	memset(ci, 0, sizeof(*ci));
   1510       1.44   msaitoh 	ci->ci_dev = cpuname;
   1511       1.44   msaitoh 
   1512       1.44   msaitoh 	ci->ci_cpu_type = x86_identify();
   1513       1.44   msaitoh 	if (ci->ci_cpu_type >= 0) {
   1514       1.44   msaitoh 		/* Old pre-cpuid instruction cpu */
   1515      1.111   msaitoh 		ci->ci_max_cpuid = -1;
   1516       1.44   msaitoh 		return;
   1517       1.44   msaitoh 	}
   1518       1.44   msaitoh 
   1519       1.51   msaitoh 	/*
   1520       1.51   msaitoh 	 * This CPU supports cpuid instruction, so we can call x86_cpuid()
   1521       1.51   msaitoh 	 * function.
   1522       1.51   msaitoh 	 */
   1523       1.51   msaitoh 
   1524       1.51   msaitoh 	/*
   1525       1.51   msaitoh 	 * Fn0000_0000:
   1526       1.51   msaitoh 	 * - Save cpuid max level.
   1527       1.51   msaitoh 	 * - Save vendor string.
   1528       1.51   msaitoh 	 */
   1529       1.44   msaitoh 	x86_cpuid(0, descs);
   1530      1.111   msaitoh 	ci->ci_max_cpuid = descs[0];
   1531       1.51   msaitoh 	/* Save vendor string */
   1532       1.44   msaitoh 	ci->ci_vendor[0] = descs[1];
   1533       1.44   msaitoh 	ci->ci_vendor[2] = descs[2];
   1534       1.44   msaitoh 	ci->ci_vendor[1] = descs[3];
   1535       1.44   msaitoh 	ci->ci_vendor[3] = 0;
   1536       1.54   msaitoh 
   1537       1.51   msaitoh 	/*
   1538       1.52   msaitoh 	 * Fn8000_0000:
   1539       1.52   msaitoh 	 * - Get cpuid extended function's max level.
   1540       1.52   msaitoh 	 */
   1541       1.52   msaitoh 	x86_cpuid(0x80000000, descs);
   1542       1.62   msaitoh 	if (descs[0] >= 0x80000000)
   1543      1.111   msaitoh 		ci->ci_max_ext_cpuid = descs[0];
   1544       1.62   msaitoh 	else {
   1545       1.52   msaitoh 		/* Set lower value than 0x80000000 */
   1546      1.111   msaitoh 		ci->ci_max_ext_cpuid = 0;
   1547       1.52   msaitoh 	}
   1548       1.52   msaitoh 
   1549       1.52   msaitoh 	/*
   1550       1.51   msaitoh 	 * Fn8000_000[2-4]:
   1551       1.51   msaitoh 	 * - Save brand string.
   1552       1.51   msaitoh 	 */
   1553      1.111   msaitoh 	if (ci->ci_max_ext_cpuid >= 0x80000004) {
   1554       1.44   msaitoh 		x86_cpuid(0x80000002, brand);
   1555       1.44   msaitoh 		x86_cpuid(0x80000003, brand + 4);
   1556       1.44   msaitoh 		x86_cpuid(0x80000004, brand + 8);
   1557       1.44   msaitoh 		for (i = 0; i < 48; i++)
   1558       1.44   msaitoh 			if (((char *) brand)[i] != ' ')
   1559       1.44   msaitoh 				break;
   1560       1.44   msaitoh 		memcpy(cpu_brand_string, ((char *) brand) + i, 48 - i);
   1561       1.44   msaitoh 	}
   1562       1.44   msaitoh 
   1563      1.111   msaitoh 	if (ci->ci_max_cpuid < 1)
   1564       1.44   msaitoh 		return;
   1565       1.44   msaitoh 
   1566       1.51   msaitoh 	/*
   1567       1.51   msaitoh 	 * Fn0000_0001:
   1568       1.51   msaitoh 	 * - Get CPU family, model and stepping (from eax).
   1569       1.51   msaitoh 	 * - Initial local APIC ID and brand ID (from ebx)
   1570       1.52   msaitoh 	 * - CPUID2 (from ecx)
   1571       1.52   msaitoh 	 * - CPUID (from edx)
   1572       1.51   msaitoh 	 */
   1573       1.44   msaitoh 	x86_cpuid(1, descs);
   1574       1.44   msaitoh 	ci->ci_signature = descs[0];
   1575       1.44   msaitoh 
   1576       1.44   msaitoh 	/* Extract full family/model values */
   1577       1.50   msaitoh 	ci->ci_family = CPUID_TO_FAMILY(ci->ci_signature);
   1578       1.50   msaitoh 	ci->ci_model = CPUID_TO_MODEL(ci->ci_signature);
   1579       1.44   msaitoh 
   1580       1.44   msaitoh 	/* Brand is low order 8 bits of ebx */
   1581       1.75   msaitoh 	ci->ci_brand_id = __SHIFTOUT(descs[1], CPUID_BRAND_INDEX);
   1582       1.51   msaitoh 	/* Initial local APIC ID */
   1583       1.75   msaitoh 	ci->ci_initapicid = __SHIFTOUT(descs[1], CPUID_LOCAL_APIC_ID);
   1584       1.44   msaitoh 
   1585       1.44   msaitoh 	ci->ci_feat_val[1] = descs[2];
   1586       1.44   msaitoh 	ci->ci_feat_val[0] = descs[3];
   1587       1.44   msaitoh 
   1588      1.111   msaitoh 	if (ci->ci_max_cpuid < 3)
   1589       1.44   msaitoh 		return;
   1590       1.44   msaitoh 
   1591       1.44   msaitoh 	/*
   1592       1.44   msaitoh 	 * If the processor serial number misfeature is present and supported,
   1593       1.44   msaitoh 	 * extract it here.
   1594       1.44   msaitoh 	 */
   1595      1.114      maxv 	if ((ci->ci_feat_val[0] & CPUID_PSN) != 0) {
   1596       1.44   msaitoh 		ci->ci_cpu_serial[0] = ci->ci_signature;
   1597       1.44   msaitoh 		x86_cpuid(3, descs);
   1598       1.44   msaitoh 		ci->ci_cpu_serial[2] = descs[2];
   1599       1.44   msaitoh 		ci->ci_cpu_serial[1] = descs[3];
   1600       1.44   msaitoh 	}
   1601       1.44   msaitoh 
   1602      1.111   msaitoh 	if (ci->ci_max_cpuid < 0x7)
   1603       1.71   msaitoh 		return;
   1604       1.71   msaitoh 
   1605       1.71   msaitoh 	x86_cpuid(7, descs);
   1606       1.71   msaitoh 	ci->ci_feat_val[5] = descs[1];
   1607       1.71   msaitoh 	ci->ci_feat_val[6] = descs[2];
   1608       1.86   msaitoh 	ci->ci_feat_val[7] = descs[3];
   1609       1.71   msaitoh 
   1610      1.111   msaitoh 	if (ci->ci_max_cpuid < 0xd)
   1611       1.44   msaitoh 		return;
   1612       1.44   msaitoh 
   1613       1.44   msaitoh 	/* Get support XCR0 bits */
   1614       1.44   msaitoh 	x86_cpuid2(0xd, 0, descs);
   1615       1.86   msaitoh 	ci->ci_feat_val[8] = descs[0];	/* Actually 64 bits */
   1616       1.44   msaitoh 	ci->ci_cur_xsave = descs[1];
   1617       1.44   msaitoh 	ci->ci_max_xsave = descs[2];
   1618       1.44   msaitoh 
   1619       1.44   msaitoh 	/* Additional flags (eg xsaveopt support) */
   1620       1.44   msaitoh 	x86_cpuid2(0xd, 1, descs);
   1621       1.86   msaitoh 	ci->ci_feat_val[9] = descs[0];	 /* Actually 64 bits */
   1622       1.44   msaitoh }
   1623       1.44   msaitoh 
   1624       1.44   msaitoh static void
   1625       1.60   msaitoh cpu_probe_hv_features(struct cpu_info *ci, const char *cpuname)
   1626       1.60   msaitoh {
   1627       1.60   msaitoh 	uint32_t descs[4];
   1628       1.60   msaitoh 	char hv_sig[13];
   1629       1.60   msaitoh 	char *p;
   1630       1.60   msaitoh 	const char *hv_name;
   1631       1.60   msaitoh 	int i;
   1632       1.60   msaitoh 
   1633       1.60   msaitoh 	/*
   1634       1.60   msaitoh 	 * [RFC] CPUID usage for interaction between Hypervisors and Linux.
   1635       1.60   msaitoh 	 * http://lkml.org/lkml/2008/10/1/246
   1636       1.60   msaitoh 	 *
   1637       1.60   msaitoh 	 * KB1009458: Mechanisms to determine if software is running in
   1638       1.60   msaitoh 	 * a VMware virtual machine
   1639       1.60   msaitoh 	 * http://kb.vmware.com/kb/1009458
   1640       1.60   msaitoh 	 */
   1641       1.60   msaitoh 	if ((ci->ci_feat_val[1] & CPUID2_RAZ) != 0) {
   1642       1.60   msaitoh 		x86_cpuid(0x40000000, descs);
   1643       1.60   msaitoh 		for (i = 1, p = hv_sig; i < 4; i++, p += sizeof(descs) / 4)
   1644       1.60   msaitoh 			memcpy(p, &descs[i], sizeof(descs[i]));
   1645       1.60   msaitoh 		*p = '\0';
   1646       1.60   msaitoh 		/*
   1647       1.60   msaitoh 		 * HV vendor	ID string
   1648       1.60   msaitoh 		 * ------------+--------------
   1649       1.95   msaitoh 		 * HAXM		"HAXMHAXMHAXM"
   1650       1.60   msaitoh 		 * KVM		"KVMKVMKVM"
   1651       1.60   msaitoh 		 * Microsoft	"Microsoft Hv"
   1652       1.94   msaitoh 		 * QEMU(TCG)	"TCGTCGTCGTCG"
   1653       1.60   msaitoh 		 * VMware	"VMwareVMware"
   1654       1.60   msaitoh 		 * Xen		"XenVMMXenVMM"
   1655       1.91      maxv 		 * NetBSD	"___ NVMM ___"
   1656       1.60   msaitoh 		 */
   1657       1.95   msaitoh 		if (strncmp(hv_sig, "HAXMHAXMHAXM", 12) == 0)
   1658       1.95   msaitoh 			hv_name = "HAXM";
   1659       1.95   msaitoh 		else if (strncmp(hv_sig, "KVMKVMKVM", 9) == 0)
   1660       1.60   msaitoh 			hv_name = "KVM";
   1661       1.60   msaitoh 		else if (strncmp(hv_sig, "Microsoft Hv", 12) == 0)
   1662       1.61     skrll 			hv_name = "Hyper-V";
   1663       1.93   msaitoh 		else if (strncmp(hv_sig, "TCGTCGTCGTCG", 12) == 0)
   1664       1.94   msaitoh 			hv_name = "QEMU(TCG)";
   1665       1.60   msaitoh 		else if (strncmp(hv_sig, "VMwareVMware", 12) == 0)
   1666       1.60   msaitoh 			hv_name = "VMware";
   1667       1.60   msaitoh 		else if (strncmp(hv_sig, "XenVMMXenVMM", 12) == 0)
   1668       1.60   msaitoh 			hv_name = "Xen";
   1669       1.91      maxv 		else if (strncmp(hv_sig, "___ NVMM ___", 12) == 0)
   1670       1.91      maxv 			hv_name = "NVMM";
   1671       1.60   msaitoh 		else
   1672       1.60   msaitoh 			hv_name = "unknown";
   1673       1.60   msaitoh 
   1674       1.60   msaitoh 		printf("%s: Running on hypervisor: %s\n", cpuname, hv_name);
   1675       1.60   msaitoh 	}
   1676       1.60   msaitoh }
   1677       1.60   msaitoh 
   1678       1.60   msaitoh static void
   1679       1.44   msaitoh cpu_probe_features(struct cpu_info *ci)
   1680       1.44   msaitoh {
   1681       1.44   msaitoh 	const struct cpu_cpuid_nameclass *cpup = NULL;
   1682       1.44   msaitoh 	unsigned int i;
   1683       1.44   msaitoh 
   1684      1.111   msaitoh 	if (ci->ci_max_cpuid < 1)
   1685       1.44   msaitoh 		return;
   1686       1.44   msaitoh 
   1687       1.44   msaitoh 	for (i = 0; i < __arraycount(i386_cpuid_cpus); i++) {
   1688       1.44   msaitoh 		if (!strncmp((char *)ci->ci_vendor,
   1689       1.44   msaitoh 		    i386_cpuid_cpus[i].cpu_id, 12)) {
   1690       1.44   msaitoh 			cpup = &i386_cpuid_cpus[i];
   1691       1.44   msaitoh 			break;
   1692       1.44   msaitoh 		}
   1693       1.44   msaitoh 	}
   1694       1.44   msaitoh 
   1695       1.44   msaitoh 	if (cpup == NULL)
   1696       1.44   msaitoh 		return;
   1697       1.44   msaitoh 
   1698       1.44   msaitoh 	i = ci->ci_family - CPU_MINFAMILY;
   1699       1.44   msaitoh 
   1700       1.44   msaitoh 	if (i >= __arraycount(cpup->cpu_family))
   1701       1.44   msaitoh 		i = __arraycount(cpup->cpu_family) - 1;
   1702       1.44   msaitoh 
   1703       1.44   msaitoh 	if (cpup->cpu_family[i].cpu_probe == NULL)
   1704       1.44   msaitoh 		return;
   1705       1.44   msaitoh 
   1706       1.44   msaitoh 	(*cpup->cpu_family[i].cpu_probe)(ci);
   1707       1.44   msaitoh }
   1708       1.44   msaitoh 
   1709       1.44   msaitoh static void
   1710       1.38       dsl print_bits(const char *cpuname, const char *hdr, const char *fmt, uint32_t val)
   1711       1.38       dsl {
   1712       1.38       dsl 	char buf[32 * 16];
   1713       1.38       dsl 	char *bp;
   1714       1.38       dsl 
   1715       1.38       dsl #define	MAX_LINE_LEN	79	/* get from command arg or 'stty cols' ? */
   1716       1.38       dsl 
   1717       1.38       dsl 	if (val == 0 || fmt == NULL)
   1718       1.38       dsl 		return;
   1719       1.38       dsl 
   1720       1.38       dsl 	snprintb_m(buf, sizeof(buf), fmt, val,
   1721       1.38       dsl 	    MAX_LINE_LEN - strlen(cpuname) - 2 - strlen(hdr) - 1);
   1722       1.38       dsl 	bp = buf;
   1723       1.38       dsl 	while (*bp != '\0') {
   1724       1.38       dsl 		aprint_verbose("%s: %s %s\n", cpuname, hdr, bp);
   1725       1.38       dsl 		bp += strlen(bp) + 1;
   1726       1.38       dsl 	}
   1727       1.38       dsl }
   1728       1.38       dsl 
   1729       1.44   msaitoh static void
   1730       1.93   msaitoh dump_descs(uint32_t leafstart, uint32_t leafend, const char *cpuname,
   1731       1.93   msaitoh     const char *blockname)
   1732       1.93   msaitoh {
   1733       1.93   msaitoh 	uint32_t descs[4];
   1734       1.93   msaitoh 	uint32_t leaf;
   1735       1.93   msaitoh 
   1736       1.93   msaitoh 	aprint_verbose("%s: highest %s info %08x\n", cpuname, blockname,
   1737       1.93   msaitoh 	    leafend);
   1738       1.93   msaitoh 
   1739       1.93   msaitoh 	if (verbose) {
   1740       1.93   msaitoh 		for (leaf = leafstart; leaf <= leafend; leaf++) {
   1741       1.93   msaitoh 			x86_cpuid(leaf, descs);
   1742       1.93   msaitoh 			printf("%s: %08x: %08x %08x %08x %08x\n", cpuname,
   1743       1.93   msaitoh 			    leaf, descs[0], descs[1], descs[2], descs[3]);
   1744       1.93   msaitoh 		}
   1745       1.93   msaitoh 	}
   1746       1.93   msaitoh }
   1747       1.93   msaitoh 
   1748       1.93   msaitoh static void
   1749       1.88   msaitoh identifycpu_cpuids_intel_0x04(struct cpu_info *ci)
   1750        1.1        ad {
   1751       1.44   msaitoh 	u_int lp_max = 1;	/* logical processors per package */
   1752       1.44   msaitoh 	u_int smt_max;		/* smt per core */
   1753       1.44   msaitoh 	u_int core_max = 1;	/* core per package */
   1754       1.44   msaitoh 	u_int smt_bits, core_bits;
   1755       1.44   msaitoh 	uint32_t descs[4];
   1756       1.44   msaitoh 
   1757       1.44   msaitoh 	/*
   1758       1.44   msaitoh 	 * 253668.pdf 7.10.2
   1759       1.44   msaitoh 	 */
   1760       1.44   msaitoh 
   1761       1.44   msaitoh 	if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
   1762       1.44   msaitoh 		x86_cpuid(1, descs);
   1763       1.75   msaitoh 		lp_max = __SHIFTOUT(descs[1], CPUID_HTT_CORES);
   1764       1.44   msaitoh 	}
   1765       1.88   msaitoh 	x86_cpuid2(4, 0, descs);
   1766       1.88   msaitoh 	core_max = __SHIFTOUT(descs[0], CPUID_DCP_CORE_P_PKG) + 1;
   1767       1.88   msaitoh 
   1768       1.44   msaitoh 	assert(lp_max >= core_max);
   1769       1.44   msaitoh 	smt_max = lp_max / core_max;
   1770       1.44   msaitoh 	smt_bits = ilog2(smt_max - 1) + 1;
   1771       1.44   msaitoh 	core_bits = ilog2(core_max - 1) + 1;
   1772       1.88   msaitoh 
   1773       1.88   msaitoh 	if (smt_bits + core_bits)
   1774       1.44   msaitoh 		ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits);
   1775       1.88   msaitoh 
   1776       1.88   msaitoh 	if (core_bits)
   1777       1.88   msaitoh 		ci->ci_coreid = __SHIFTOUT(ci->ci_initapicid,
   1778       1.88   msaitoh 		    __BITS(smt_bits, smt_bits + core_bits - 1));
   1779       1.88   msaitoh 
   1780       1.88   msaitoh 	if (smt_bits)
   1781       1.88   msaitoh 		ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid,
   1782       1.88   msaitoh 		    __BITS((int)0, (int)(smt_bits - 1)));
   1783       1.88   msaitoh }
   1784       1.88   msaitoh 
   1785       1.88   msaitoh static void
   1786       1.88   msaitoh identifycpu_cpuids_intel_0x0b(struct cpu_info *ci)
   1787       1.88   msaitoh {
   1788       1.88   msaitoh 	const char *cpuname = ci->ci_dev;
   1789       1.88   msaitoh 	u_int smt_bits, core_bits, core_shift = 0, pkg_shift = 0;
   1790       1.88   msaitoh 	uint32_t descs[4];
   1791       1.88   msaitoh 	int i;
   1792       1.88   msaitoh 
   1793       1.88   msaitoh 	x86_cpuid(0x0b, descs);
   1794       1.88   msaitoh 	if (descs[1] == 0) {
   1795       1.88   msaitoh 		identifycpu_cpuids_intel_0x04(ci);
   1796       1.88   msaitoh 		return;
   1797       1.88   msaitoh 	}
   1798       1.88   msaitoh 
   1799       1.88   msaitoh 	for (i = 0; ; i++) {
   1800       1.88   msaitoh 		unsigned int shiftnum, lvltype;
   1801       1.88   msaitoh 		x86_cpuid2(0x0b, i, descs);
   1802       1.88   msaitoh 
   1803       1.88   msaitoh 		/* On invalid level, (EAX and) EBX return 0 */
   1804       1.88   msaitoh 		if (descs[1] == 0)
   1805       1.88   msaitoh 			break;
   1806       1.88   msaitoh 
   1807       1.88   msaitoh 		shiftnum = __SHIFTOUT(descs[0], CPUID_TOP_SHIFTNUM);
   1808       1.88   msaitoh 		lvltype = __SHIFTOUT(descs[2], CPUID_TOP_LVLTYPE);
   1809       1.88   msaitoh 		switch (lvltype) {
   1810       1.88   msaitoh 		case CPUID_TOP_LVLTYPE_SMT:
   1811       1.88   msaitoh 			core_shift = shiftnum;
   1812       1.88   msaitoh 			break;
   1813       1.88   msaitoh 		case CPUID_TOP_LVLTYPE_CORE:
   1814       1.88   msaitoh 			pkg_shift = shiftnum;
   1815       1.88   msaitoh 			break;
   1816       1.88   msaitoh 		case CPUID_TOP_LVLTYPE_INVAL:
   1817       1.88   msaitoh 			aprint_verbose("%s: Invalid level type\n", cpuname);
   1818       1.88   msaitoh 			break;
   1819       1.88   msaitoh 		default:
   1820       1.88   msaitoh 			aprint_verbose("%s: Unknown level type(%d) \n",
   1821       1.88   msaitoh 			    cpuname, lvltype);
   1822       1.88   msaitoh 			break;
   1823       1.88   msaitoh 		}
   1824       1.44   msaitoh 	}
   1825       1.88   msaitoh 
   1826       1.88   msaitoh 	assert(pkg_shift >= core_shift);
   1827       1.88   msaitoh 	smt_bits = core_shift;
   1828       1.88   msaitoh 	core_bits = pkg_shift - core_shift;
   1829       1.88   msaitoh 
   1830       1.88   msaitoh 	ci->ci_packageid = ci->ci_initapicid >> pkg_shift;
   1831       1.88   msaitoh 
   1832       1.88   msaitoh 	if (core_bits)
   1833       1.88   msaitoh 		ci->ci_coreid = __SHIFTOUT(ci->ci_initapicid,
   1834       1.88   msaitoh 		    __BITS(core_shift, pkg_shift - 1));
   1835       1.88   msaitoh 
   1836       1.88   msaitoh 	if (smt_bits)
   1837       1.88   msaitoh 		ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid,
   1838       1.88   msaitoh 		    __BITS((int)0, core_shift - 1));
   1839       1.88   msaitoh }
   1840       1.88   msaitoh 
   1841       1.88   msaitoh static void
   1842       1.88   msaitoh identifycpu_cpuids_intel(struct cpu_info *ci)
   1843       1.88   msaitoh {
   1844       1.88   msaitoh 	const char *cpuname = ci->ci_dev;
   1845       1.88   msaitoh 
   1846      1.111   msaitoh 	if (ci->ci_max_cpuid >= 0x0b)
   1847       1.88   msaitoh 		identifycpu_cpuids_intel_0x0b(ci);
   1848      1.111   msaitoh 	else if (ci->ci_max_cpuid >= 4)
   1849       1.88   msaitoh 		identifycpu_cpuids_intel_0x04(ci);
   1850       1.88   msaitoh 
   1851       1.44   msaitoh 	aprint_verbose("%s: Cluster/Package ID %u\n", cpuname,
   1852       1.44   msaitoh 	    ci->ci_packageid);
   1853       1.88   msaitoh 	aprint_verbose("%s: Core ID %u\n", cpuname, ci->ci_coreid);
   1854       1.88   msaitoh 	aprint_verbose("%s: SMT ID %u\n", cpuname, ci->ci_smtid);
   1855       1.88   msaitoh }
   1856       1.88   msaitoh 
   1857       1.88   msaitoh static void
   1858       1.96   mlelstv identifycpu_cpuids_amd(struct cpu_info *ci)
   1859       1.96   mlelstv {
   1860       1.96   mlelstv 	const char *cpuname = ci->ci_dev;
   1861       1.96   mlelstv 	u_int lp_max, core_max;
   1862       1.96   mlelstv 	int n, cpu_family, apic_id, smt_bits, core_bits = 0;
   1863       1.96   mlelstv 	uint32_t descs[4];
   1864       1.96   mlelstv 
   1865       1.96   mlelstv 	apic_id = ci->ci_initapicid;
   1866       1.96   mlelstv 	cpu_family = CPUID_TO_FAMILY(ci->ci_signature);
   1867       1.96   mlelstv 
   1868       1.96   mlelstv 	if (cpu_family < 0xf)
   1869       1.96   mlelstv 		return;
   1870       1.96   mlelstv 
   1871       1.96   mlelstv 	if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
   1872       1.96   mlelstv 		x86_cpuid(1, descs);
   1873       1.96   mlelstv 		lp_max = __SHIFTOUT(descs[1], CPUID_HTT_CORES);
   1874       1.96   mlelstv 
   1875      1.111   msaitoh 		if (cpu_family >= 0x10 && ci->ci_max_ext_cpuid >= 0x8000008) {
   1876       1.96   mlelstv 			x86_cpuid(0x8000008, descs);
   1877       1.96   mlelstv 			core_max = (descs[2] & 0xff) + 1;
   1878       1.96   mlelstv 			n = (descs[2] >> 12) & 0x0f;
   1879       1.96   mlelstv 			if (n != 0)
   1880       1.96   mlelstv 				core_bits = n;
   1881       1.96   mlelstv 		}
   1882       1.96   mlelstv 	} else {
   1883       1.96   mlelstv 		lp_max = 1;
   1884       1.96   mlelstv 	}
   1885       1.96   mlelstv 	core_max = lp_max;
   1886       1.96   mlelstv 
   1887       1.96   mlelstv 	smt_bits = ilog2((lp_max / core_max) - 1) + 1;
   1888       1.96   mlelstv 	if (core_bits == 0)
   1889       1.96   mlelstv 		core_bits = ilog2(core_max - 1) + 1;
   1890       1.96   mlelstv 
   1891       1.99   mlelstv #if 0 /* MSRs need kernel mode */
   1892       1.96   mlelstv 	if (cpu_family < 0x11) {
   1893       1.96   mlelstv 		const uint64_t reg = rdmsr(MSR_NB_CFG);
   1894       1.96   mlelstv 		if ((reg & NB_CFG_INITAPICCPUIDLO) == 0) {
   1895       1.96   mlelstv 			const u_int node_id = apic_id & __BITS(0, 2);
   1896       1.96   mlelstv 			apic_id = (cpu_family == 0xf) ?
   1897       1.96   mlelstv 				(apic_id >> core_bits) | (node_id << core_bits) :
   1898       1.96   mlelstv 				(apic_id >> 5) | (node_id << 2);
   1899       1.96   mlelstv 		}
   1900       1.96   mlelstv 	}
   1901       1.99   mlelstv #endif
   1902       1.96   mlelstv 
   1903      1.123       mrg 	if (cpu_family >= 0x17) {
   1904       1.96   mlelstv 		x86_cpuid(0x8000001e, descs);
   1905       1.96   mlelstv 		const u_int threads = ((descs[1] >> 8) & 0xff) + 1;
   1906       1.96   mlelstv 		smt_bits = ilog2(threads);
   1907       1.96   mlelstv 		core_bits -= smt_bits;
   1908       1.96   mlelstv 	}
   1909       1.96   mlelstv 
   1910       1.96   mlelstv 	if (smt_bits + core_bits) {
   1911       1.96   mlelstv 		if (smt_bits + core_bits < 32)
   1912       1.96   mlelstv 			ci->ci_packageid = 0;
   1913       1.96   mlelstv 	}
   1914       1.96   mlelstv 	if (core_bits) {
   1915       1.96   mlelstv 		u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
   1916       1.96   mlelstv 		ci->ci_coreid = __SHIFTOUT(apic_id, core_mask);
   1917       1.96   mlelstv 	}
   1918       1.96   mlelstv 	if (smt_bits) {
   1919       1.96   mlelstv 		u_int smt_mask = __BITS(0, smt_bits - 1);
   1920       1.96   mlelstv 		ci->ci_smtid = __SHIFTOUT(apic_id, smt_mask);
   1921       1.96   mlelstv 	}
   1922       1.96   mlelstv 
   1923       1.96   mlelstv 	aprint_verbose("%s: Cluster/Package ID %u\n", cpuname,
   1924       1.96   mlelstv 	    ci->ci_packageid);
   1925       1.96   mlelstv 	aprint_verbose("%s: Core ID %u\n", cpuname, ci->ci_coreid);
   1926       1.96   mlelstv 	aprint_verbose("%s: SMT ID %u\n", cpuname, ci->ci_smtid);
   1927       1.96   mlelstv }
   1928       1.96   mlelstv 
   1929       1.96   mlelstv static void
   1930       1.88   msaitoh identifycpu_cpuids(struct cpu_info *ci)
   1931       1.88   msaitoh {
   1932       1.88   msaitoh 	const char *cpuname = ci->ci_dev;
   1933       1.44   msaitoh 
   1934       1.88   msaitoh 	aprint_verbose("%s: Initial APIC ID %u\n", cpuname, ci->ci_initapicid);
   1935       1.88   msaitoh 	ci->ci_packageid = ci->ci_initapicid;
   1936       1.88   msaitoh 	ci->ci_coreid = 0;
   1937       1.88   msaitoh 	ci->ci_smtid = 0;
   1938       1.44   msaitoh 
   1939       1.88   msaitoh 	if (cpu_vendor == CPUVENDOR_INTEL)
   1940       1.88   msaitoh 		identifycpu_cpuids_intel(ci);
   1941       1.96   mlelstv 	else if (cpu_vendor == CPUVENDOR_AMD)
   1942       1.96   mlelstv 		identifycpu_cpuids_amd(ci);
   1943       1.44   msaitoh }
   1944       1.44   msaitoh 
   1945       1.44   msaitoh void
   1946       1.44   msaitoh identifycpu(int fd, const char *cpuname)
   1947       1.44   msaitoh {
   1948       1.44   msaitoh 	const char *name = "", *modifier, *vendorname, *brand = "";
   1949       1.44   msaitoh 	int class = CPUCLASS_386;
   1950       1.44   msaitoh 	unsigned int i;
   1951       1.44   msaitoh 	int modif, family;
   1952       1.44   msaitoh 	const struct cpu_cpuid_nameclass *cpup = NULL;
   1953       1.44   msaitoh 	const struct cpu_cpuid_family *cpufam;
   1954       1.44   msaitoh 	struct cpu_info *ci, cistore;
   1955       1.62   msaitoh 	u_int descs[4];
   1956       1.44   msaitoh 	size_t sz;
   1957       1.44   msaitoh 	struct cpu_ucode_version ucode;
   1958       1.44   msaitoh 	union {
   1959       1.44   msaitoh 		struct cpu_ucode_version_amd amd;
   1960       1.44   msaitoh 		struct cpu_ucode_version_intel1 intel1;
   1961       1.44   msaitoh 	} ucvers;
   1962       1.44   msaitoh 
   1963       1.44   msaitoh 	ci = &cistore;
   1964       1.44   msaitoh 	cpu_probe_base_features(ci, cpuname);
   1965      1.111   msaitoh 	dump_descs(0x00000000, ci->ci_max_cpuid, cpuname, "basic");
   1966       1.93   msaitoh 	if ((ci->ci_feat_val[1] & CPUID2_RAZ) != 0) {
   1967       1.93   msaitoh 		x86_cpuid(0x40000000, descs);
   1968       1.93   msaitoh 		dump_descs(0x40000000, descs[0], cpuname, "hypervisor");
   1969       1.62   msaitoh 	}
   1970      1.111   msaitoh 	dump_descs(0x80000000, ci->ci_max_ext_cpuid, cpuname, "extended");
   1971       1.62   msaitoh 
   1972       1.60   msaitoh 	cpu_probe_hv_features(ci, cpuname);
   1973       1.44   msaitoh 	cpu_probe_features(ci);
   1974        1.1        ad 
   1975       1.34       dsl 	if (ci->ci_cpu_type >= 0) {
   1976       1.51   msaitoh 		/* Old pre-cpuid instruction cpu */
   1977       1.34       dsl 		if (ci->ci_cpu_type >= (int)__arraycount(i386_nocpuid_cpus))
   1978       1.34       dsl 			errx(1, "unknown cpu type %d", ci->ci_cpu_type);
   1979       1.34       dsl 		name = i386_nocpuid_cpus[ci->ci_cpu_type].cpu_name;
   1980       1.34       dsl 		cpu_vendor = i386_nocpuid_cpus[ci->ci_cpu_type].cpu_vendor;
   1981       1.34       dsl 		vendorname = i386_nocpuid_cpus[ci->ci_cpu_type].cpu_vendorname;
   1982       1.34       dsl 		class = i386_nocpuid_cpus[ci->ci_cpu_type].cpu_class;
   1983       1.34       dsl 		ci->ci_info = i386_nocpuid_cpus[ci->ci_cpu_type].cpu_info;
   1984        1.1        ad 		modifier = "";
   1985        1.1        ad 	} else {
   1986       1.51   msaitoh 		/* CPU which support cpuid instruction */
   1987        1.1        ad 		modif = (ci->ci_signature >> 12) & 0x3;
   1988       1.37       dsl 		family = ci->ci_family;
   1989        1.1        ad 		if (family < CPU_MINFAMILY)
   1990        1.1        ad 			errx(1, "identifycpu: strange family value");
   1991       1.37       dsl 		if (family > CPU_MAXFAMILY)
   1992       1.37       dsl 			family = CPU_MAXFAMILY;
   1993        1.1        ad 
   1994       1.36       dsl 		for (i = 0; i < __arraycount(i386_cpuid_cpus); i++) {
   1995        1.1        ad 			if (!strncmp((char *)ci->ci_vendor,
   1996        1.1        ad 			    i386_cpuid_cpus[i].cpu_id, 12)) {
   1997        1.1        ad 				cpup = &i386_cpuid_cpus[i];
   1998        1.1        ad 				break;
   1999        1.1        ad 			}
   2000        1.1        ad 		}
   2001        1.1        ad 
   2002        1.1        ad 		if (cpup == NULL) {
   2003        1.1        ad 			cpu_vendor = CPUVENDOR_UNKNOWN;
   2004        1.1        ad 			if (ci->ci_vendor[0] != '\0')
   2005        1.1        ad 				vendorname = (char *)&ci->ci_vendor[0];
   2006        1.1        ad 			else
   2007        1.1        ad 				vendorname = "Unknown";
   2008        1.1        ad 			class = family - 3;
   2009        1.1        ad 			modifier = "";
   2010        1.1        ad 			name = "";
   2011        1.1        ad 			ci->ci_info = NULL;
   2012        1.1        ad 		} else {
   2013        1.1        ad 			cpu_vendor = cpup->cpu_vendor;
   2014        1.1        ad 			vendorname = cpup->cpu_vendorname;
   2015        1.1        ad 			modifier = modifiers[modif];
   2016        1.1        ad 			cpufam = &cpup->cpu_family[family - CPU_MINFAMILY];
   2017       1.37       dsl 			name = cpufam->cpu_models[ci->ci_model];
   2018       1.18  pgoyette 			if (name == NULL || *name == '\0')
   2019       1.85   msaitoh 				name = cpufam->cpu_model_default;
   2020        1.1        ad 			class = cpufam->cpu_class;
   2021        1.1        ad 			ci->ci_info = cpufam->cpu_info;
   2022        1.1        ad 
   2023        1.1        ad 			if (cpu_vendor == CPUVENDOR_INTEL) {
   2024       1.37       dsl 				if (ci->ci_family == 6 && ci->ci_model >= 5) {
   2025        1.1        ad 					const char *tmp;
   2026        1.1        ad 					tmp = intel_family6_name(ci);
   2027        1.1        ad 					if (tmp != NULL)
   2028        1.1        ad 						name = tmp;
   2029        1.1        ad 				}
   2030       1.37       dsl 				if (ci->ci_family == 15 &&
   2031        1.1        ad 				    ci->ci_brand_id <
   2032        1.1        ad 				    __arraycount(i386_intel_brand) &&
   2033        1.1        ad 				    i386_intel_brand[ci->ci_brand_id])
   2034        1.1        ad 					name =
   2035       1.85   msaitoh 					    i386_intel_brand[ci->ci_brand_id];
   2036        1.1        ad 			}
   2037        1.1        ad 
   2038        1.1        ad 			if (cpu_vendor == CPUVENDOR_AMD) {
   2039       1.37       dsl 				if (ci->ci_family == 6 && ci->ci_model >= 6) {
   2040        1.1        ad 					if (ci->ci_brand_id == 1)
   2041      1.103   msaitoh 						/*
   2042      1.103   msaitoh 						 * It's Duron. We override the
   2043        1.1        ad 						 * name, since it might have
   2044        1.1        ad 						 * been misidentified as Athlon.
   2045        1.1        ad 						 */
   2046        1.1        ad 						name =
   2047        1.1        ad 						    amd_brand[ci->ci_brand_id];
   2048        1.1        ad 					else
   2049        1.1        ad 						brand = amd_brand_name;
   2050        1.1        ad 				}
   2051       1.50   msaitoh 				if (CPUID_TO_BASEFAMILY(ci->ci_signature)
   2052       1.50   msaitoh 				    == 0xf) {
   2053       1.37       dsl 					/* Identify AMD64 CPU names.  */
   2054        1.1        ad 					const char *tmp;
   2055        1.1        ad 					tmp = amd_amd64_name(ci);
   2056        1.1        ad 					if (tmp != NULL)
   2057        1.1        ad 						name = tmp;
   2058        1.1        ad 				}
   2059        1.1        ad 			}
   2060      1.103   msaitoh 
   2061       1.37       dsl 			if (cpu_vendor == CPUVENDOR_IDT && ci->ci_family >= 6)
   2062        1.1        ad 				vendorname = "VIA";
   2063        1.1        ad 		}
   2064        1.1        ad 	}
   2065        1.1        ad 
   2066        1.1        ad 	ci->ci_cpu_class = class;
   2067        1.1        ad 
   2068        1.1        ad 	sz = sizeof(ci->ci_tsc_freq);
   2069        1.1        ad 	(void)sysctlbyname("machdep.tsc_freq", &ci->ci_tsc_freq, &sz, NULL, 0);
   2070       1.26       chs 	sz = sizeof(use_pae);
   2071       1.26       chs 	(void)sysctlbyname("machdep.pae", &use_pae, &sz, NULL, 0);
   2072       1.26       chs 	largepagesize = (use_pae ? 2 * 1024 * 1024 : 4 * 1024 * 1024);
   2073        1.1        ad 
   2074       1.38       dsl 	/*
   2075       1.38       dsl 	 * The 'cpu_brand_string' is much more useful than the 'cpu_model'
   2076       1.38       dsl 	 * we try to determine from the family/model values.
   2077       1.38       dsl 	 */
   2078       1.38       dsl 	if (*cpu_brand_string != '\0')
   2079       1.38       dsl 		aprint_normal("%s: \"%s\"\n", cpuname, cpu_brand_string);
   2080       1.38       dsl 
   2081       1.38       dsl 	aprint_normal("%s: %s", cpuname, vendorname);
   2082       1.38       dsl 	if (*modifier)
   2083       1.38       dsl 		aprint_normal(" %s", modifier);
   2084       1.38       dsl 	if (*name)
   2085       1.38       dsl 		aprint_normal(" %s", name);
   2086       1.38       dsl 	if (*brand)
   2087       1.38       dsl 		aprint_normal(" %s", brand);
   2088       1.38       dsl 	aprint_normal(" (%s-class)", classnames[class]);
   2089        1.1        ad 
   2090        1.1        ad 	if (ci->ci_tsc_freq != 0)
   2091       1.63   msaitoh 		aprint_normal(", %ju.%02ju MHz",
   2092       1.28     joerg 		    ((uintmax_t)ci->ci_tsc_freq + 4999) / 1000000,
   2093       1.28     joerg 		    (((uintmax_t)ci->ci_tsc_freq + 4999) / 10000) % 100);
   2094       1.63   msaitoh 	aprint_normal("\n");
   2095       1.38       dsl 
   2096      1.112   msaitoh 	(void)cpu_tsc_freq_cpuid(ci);
   2097      1.112   msaitoh 
   2098       1.38       dsl 	aprint_normal_dev(ci->ci_dev, "family %#x model %#x stepping %#x",
   2099       1.50   msaitoh 	    ci->ci_family, ci->ci_model, CPUID_TO_STEPPING(ci->ci_signature));
   2100        1.1        ad 	if (ci->ci_signature != 0)
   2101       1.38       dsl 		aprint_normal(" (id %#x)", ci->ci_signature);
   2102        1.1        ad 	aprint_normal("\n");
   2103        1.1        ad 
   2104        1.1        ad 	if (ci->ci_info)
   2105        1.1        ad 		(*ci->ci_info)(ci);
   2106        1.1        ad 
   2107       1.18  pgoyette 	/*
   2108       1.18  pgoyette 	 * display CPU feature flags
   2109       1.18  pgoyette 	 */
   2110       1.18  pgoyette 
   2111       1.38       dsl 	print_bits(cpuname, "features", CPUID_FLAGS1, ci->ci_feat_val[0]);
   2112       1.38       dsl 	print_bits(cpuname, "features1", CPUID2_FLAGS1, ci->ci_feat_val[1]);
   2113       1.18  pgoyette 
   2114       1.38       dsl 	/* These next two are actually common definitions! */
   2115       1.38       dsl 	print_bits(cpuname, "features2",
   2116       1.38       dsl 	    cpu_vendor == CPUVENDOR_INTEL ? CPUID_INTEL_EXT_FLAGS
   2117       1.38       dsl 		: CPUID_EXT_FLAGS, ci->ci_feat_val[2]);
   2118       1.38       dsl 	print_bits(cpuname, "features3",
   2119       1.38       dsl 	    cpu_vendor == CPUVENDOR_INTEL ? CPUID_INTEL_FLAGS4
   2120       1.38       dsl 		: CPUID_AMD_FLAGS4, ci->ci_feat_val[3]);
   2121       1.38       dsl 
   2122       1.38       dsl 	print_bits(cpuname, "padloack features", CPUID_FLAGS_PADLOCK,
   2123       1.38       dsl 	    ci->ci_feat_val[4]);
   2124       1.76   msaitoh 	if ((cpu_vendor == CPUVENDOR_INTEL) || (cpu_vendor == CPUVENDOR_AMD))
   2125       1.76   msaitoh 		print_bits(cpuname, "features5", CPUID_SEF_FLAGS,
   2126       1.76   msaitoh 		    ci->ci_feat_val[5]);
   2127       1.86   msaitoh 	if ((cpu_vendor == CPUVENDOR_INTEL) || (cpu_vendor == CPUVENDOR_AMD))
   2128       1.76   msaitoh 		print_bits(cpuname, "features6", CPUID_SEF_FLAGS1,
   2129       1.76   msaitoh 		    ci->ci_feat_val[6]);
   2130       1.79   msaitoh 
   2131       1.86   msaitoh 	if (cpu_vendor == CPUVENDOR_INTEL)
   2132       1.86   msaitoh 		print_bits(cpuname, "features7", CPUID_SEF_FLAGS2,
   2133       1.86   msaitoh 		    ci->ci_feat_val[7]);
   2134       1.79   msaitoh 
   2135       1.86   msaitoh 	print_bits(cpuname, "xsave features", XCR0_FLAGS1, ci->ci_feat_val[8]);
   2136       1.38       dsl 	print_bits(cpuname, "xsave instructions", CPUID_PES1_FLAGS,
   2137       1.86   msaitoh 	    ci->ci_feat_val[9]);
   2138       1.38       dsl 
   2139       1.38       dsl 	if (ci->ci_max_xsave != 0) {
   2140       1.38       dsl 		aprint_normal("%s: xsave area size: current %d, maximum %d",
   2141       1.85   msaitoh 		    cpuname, ci->ci_cur_xsave, ci->ci_max_xsave);
   2142       1.38       dsl 		aprint_normal(", xgetbv %sabled\n",
   2143       1.38       dsl 		    ci->ci_feat_val[1] & CPUID2_OSXSAVE ? "en" : "dis");
   2144       1.38       dsl 		if (ci->ci_feat_val[1] & CPUID2_OSXSAVE)
   2145       1.38       dsl 			print_bits(cpuname, "enabled xsave", XCR0_FLAGS1,
   2146       1.38       dsl 			    x86_xgetbv());
   2147       1.12    cegger 	}
   2148        1.1        ad 
   2149       1.54   msaitoh 	x86_print_cache_and_tlb_info(ci);
   2150        1.1        ad 
   2151      1.114      maxv 	if (ci->ci_max_cpuid >= 3 && (ci->ci_feat_val[0] & CPUID_PSN)) {
   2152        1.1        ad 		aprint_verbose("%s: serial number %04X-%04X-%04X-%04X-%04X-%04X\n",
   2153        1.1        ad 		    cpuname,
   2154        1.1        ad 		    ci->ci_cpu_serial[0] / 65536, ci->ci_cpu_serial[0] % 65536,
   2155        1.1        ad 		    ci->ci_cpu_serial[1] / 65536, ci->ci_cpu_serial[1] % 65536,
   2156        1.1        ad 		    ci->ci_cpu_serial[2] / 65536, ci->ci_cpu_serial[2] % 65536);
   2157        1.1        ad 	}
   2158        1.1        ad 
   2159       1.71   msaitoh 	if (ci->ci_cpu_class == CPUCLASS_386)
   2160        1.1        ad 		errx(1, "NetBSD requires an 80486 or later processor");
   2161        1.1        ad 
   2162       1.34       dsl 	if (ci->ci_cpu_type == CPU_486DLC) {
   2163        1.1        ad #ifndef CYRIX_CACHE_WORKS
   2164        1.1        ad 		aprint_error("WARNING: CYRIX 486DLC CACHE UNCHANGED.\n");
   2165        1.1        ad #else
   2166        1.1        ad #ifndef CYRIX_CACHE_REALLY_WORKS
   2167        1.1        ad 		aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED IN HOLD-FLUSH MODE.\n");
   2168        1.1        ad #else
   2169        1.1        ad 		aprint_error("WARNING: CYRIX 486DLC CACHE ENABLED.\n");
   2170        1.1        ad #endif
   2171        1.1        ad #endif
   2172        1.1        ad 	}
   2173        1.1        ad 
   2174        1.1        ad 	/*
   2175        1.1        ad 	 * Everything past this point requires a Pentium or later.
   2176        1.1        ad 	 */
   2177      1.111   msaitoh 	if (ci->ci_max_cpuid < 0)
   2178        1.1        ad 		return;
   2179        1.1        ad 
   2180        1.1        ad 	identifycpu_cpuids(ci);
   2181        1.1        ad 
   2182      1.111   msaitoh 	if ((ci->ci_max_cpuid >= 5)
   2183       1.89   msaitoh 	    && ((cpu_vendor == CPUVENDOR_INTEL)
   2184       1.89   msaitoh 		|| (cpu_vendor == CPUVENDOR_AMD))) {
   2185       1.89   msaitoh 		uint16_t lmin, lmax;
   2186       1.89   msaitoh 		x86_cpuid(5, descs);
   2187      1.103   msaitoh 
   2188       1.89   msaitoh 		print_bits(cpuname, "MONITOR/MWAIT extensions",
   2189       1.89   msaitoh 		    CPUID_MON_FLAGS, descs[2]);
   2190       1.89   msaitoh 		lmin = __SHIFTOUT(descs[0], CPUID_MON_MINSIZE);
   2191       1.89   msaitoh 		lmax = __SHIFTOUT(descs[1], CPUID_MON_MAXSIZE);
   2192       1.89   msaitoh 		aprint_normal("%s: monitor-line size %hu", cpuname, lmin);
   2193       1.89   msaitoh 		if (lmin != lmax)
   2194       1.89   msaitoh 			aprint_normal("-%hu", lmax);
   2195       1.89   msaitoh 		aprint_normal("\n");
   2196       1.89   msaitoh 
   2197       1.89   msaitoh 		for (i = 0; i <= 7; i++) {
   2198       1.89   msaitoh 			unsigned int num = CPUID_MON_SUBSTATE(descs[3], i);
   2199       1.89   msaitoh 
   2200       1.89   msaitoh 			if (num != 0)
   2201       1.89   msaitoh 				aprint_normal("%s: C%u substates %u\n",
   2202       1.89   msaitoh 				    cpuname, i, num);
   2203       1.89   msaitoh 		}
   2204       1.89   msaitoh 	}
   2205      1.111   msaitoh 	if ((ci->ci_max_cpuid >= 6)
   2206       1.86   msaitoh 	    && ((cpu_vendor == CPUVENDOR_INTEL)
   2207       1.86   msaitoh 		|| (cpu_vendor == CPUVENDOR_AMD))) {
   2208       1.86   msaitoh 		x86_cpuid(6, descs);
   2209       1.86   msaitoh 		print_bits(cpuname, "DSPM-eax", CPUID_DSPM_FLAGS, descs[0]);
   2210       1.86   msaitoh 		print_bits(cpuname, "DSPM-ecx", CPUID_DSPM_FLAGS1, descs[2]);
   2211       1.86   msaitoh 	}
   2212      1.111   msaitoh 	if ((ci->ci_max_cpuid >= 7)
   2213       1.87   msaitoh 	    && ((cpu_vendor == CPUVENDOR_INTEL)
   2214       1.87   msaitoh 		|| (cpu_vendor == CPUVENDOR_AMD))) {
   2215  1.133.2.1    martin 		unsigned int maxsubleaf;
   2216  1.133.2.1    martin 
   2217       1.87   msaitoh 		x86_cpuid(7, descs);
   2218  1.133.2.1    martin 		maxsubleaf = descs[0];
   2219       1.87   msaitoh 		aprint_verbose("%s: SEF highest subleaf %08x\n",
   2220  1.133.2.1    martin 		    cpuname, maxsubleaf);
   2221  1.133.2.1    martin 		if (maxsubleaf >= 1) {
   2222      1.115   msaitoh 			x86_cpuid2(7, 1, descs);
   2223      1.115   msaitoh 			print_bits(cpuname, "SEF-subleaf1-eax",
   2224      1.115   msaitoh 			    CPUID_SEF1_FLAGS_A, descs[0]);
   2225  1.133.2.1    martin 			print_bits(cpuname, "SEF-subleaf1-ebx",
   2226  1.133.2.1    martin 			    CPUID_SEF1_FLAGS_B, descs[1]);
   2227  1.133.2.1    martin 			print_bits(cpuname, "SEF-subleaf1-edx",
   2228  1.133.2.1    martin 			    CPUID_SEF1_FLAGS_D, descs[3]);
   2229  1.133.2.1    martin 		}
   2230  1.133.2.1    martin 		if (maxsubleaf >= 2) {
   2231  1.133.2.1    martin 			x86_cpuid2(7, 2, descs);
   2232  1.133.2.1    martin 			print_bits(cpuname, "SEF-subleaf2-edx",
   2233  1.133.2.1    martin 			    CPUID_SEF2_FLAGS_D, descs[3]);
   2234      1.115   msaitoh 		}
   2235       1.87   msaitoh 	}
   2236       1.87   msaitoh 
   2237      1.115   msaitoh 	if ((cpu_vendor == CPUVENDOR_INTEL) || (cpu_vendor == CPUVENDOR_AMD)) {
   2238      1.111   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x80000007)
   2239       1.22    cegger 			powernow_probe(ci);
   2240       1.22    cegger 
   2241      1.111   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x80000008) {
   2242      1.105   msaitoh 			x86_cpuid(0x80000008, descs);
   2243      1.105   msaitoh 			print_bits(cpuname, "AMD Extended features",
   2244      1.105   msaitoh 			    CPUID_CAPEX_FLAGS, descs[1]);
   2245      1.105   msaitoh 		}
   2246      1.115   msaitoh 	}
   2247      1.105   msaitoh 
   2248      1.115   msaitoh 	if (cpu_vendor == CPUVENDOR_AMD) {
   2249      1.130   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x80000021) {
   2250      1.130   msaitoh 			x86_cpuid(0x80000021, descs);
   2251      1.133   msaitoh 			print_bits(cpuname, "AMD Extended features2",
   2252      1.130   msaitoh 			    CPUID_AMDEXT2_FLAGS, descs[0]);
   2253      1.130   msaitoh 		}
   2254      1.130   msaitoh 
   2255      1.129   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x80000007) {
   2256      1.129   msaitoh 			x86_cpuid(0x80000007, descs);
   2257      1.129   msaitoh 			print_bits(cpuname, "RAS features",
   2258      1.129   msaitoh 			    CPUID_RAS_FLAGS, descs[1]);
   2259      1.129   msaitoh 		}
   2260      1.111   msaitoh 		if ((ci->ci_max_ext_cpuid >= 0x8000000a)
   2261       1.85   msaitoh 		    && (ci->ci_feat_val[3] & CPUID_SVM) != 0) {
   2262       1.86   msaitoh 			x86_cpuid(0x8000000a, descs);
   2263       1.15      yamt 			aprint_verbose("%s: SVM Rev. %d\n", cpuname,
   2264       1.86   msaitoh 			    descs[0] & 0xf);
   2265       1.86   msaitoh 			aprint_verbose("%s: SVM NASID %d\n", cpuname,
   2266       1.86   msaitoh 			    descs[1]);
   2267       1.85   msaitoh 			print_bits(cpuname, "SVM features",
   2268       1.86   msaitoh 			    CPUID_AMD_SVM_FLAGS, descs[3]);
   2269       1.15      yamt 		}
   2270      1.129   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x8000001b) {
   2271      1.129   msaitoh 			x86_cpuid(0x8000001b, descs);
   2272      1.132   msaitoh 			print_bits(cpuname, "IBS features",
   2273      1.129   msaitoh 			    CPUID_IBS_FLAGS, descs[0]);
   2274      1.129   msaitoh 		}
   2275      1.111   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x8000001f) {
   2276      1.107   msaitoh 			x86_cpuid(0x8000001f, descs);
   2277      1.107   msaitoh 			print_bits(cpuname, "Encrypted Memory features",
   2278      1.107   msaitoh 			    CPUID_AMD_ENCMEM_FLAGS, descs[0]);
   2279      1.107   msaitoh 		}
   2280      1.131   msaitoh 		if (ci->ci_max_ext_cpuid >= 0x80000022) {
   2281      1.131   msaitoh 			uint8_t ncore, nnb, nlbrs;
   2282      1.131   msaitoh 
   2283      1.131   msaitoh 			x86_cpuid(0x80000022, descs);
   2284      1.131   msaitoh 			print_bits(cpuname, "Perfmon:",
   2285      1.131   msaitoh 			    CPUID_AXPERF_FLAGS, descs[0]);
   2286      1.131   msaitoh 
   2287      1.131   msaitoh 			ncore = __SHIFTOUT(descs[1], CPUID_AXPERF_NCPC);
   2288      1.131   msaitoh 			nnb = __SHIFTOUT(descs[1], CPUID_AXPERF_NNBPC);
   2289      1.131   msaitoh 			nlbrs = __SHIFTOUT(descs[1], CPUID_AXPERF_NLBRSTACK);
   2290      1.131   msaitoh 			aprint_verbose("%s: Perfmon: counters: "
   2291      1.131   msaitoh 			    "Core %hhu, Northbridge %hhu\n", cpuname,
   2292      1.131   msaitoh 			    ncore, nnb);
   2293      1.131   msaitoh 			aprint_verbose("%s: Perfmon: LBR Stack %hhu entries\n",
   2294      1.131   msaitoh 			    cpuname, nlbrs);
   2295      1.131   msaitoh 		}
   2296       1.39      yamt 	} else if (cpu_vendor == CPUVENDOR_INTEL) {
   2297      1.126   msaitoh 		if (ci->ci_max_cpuid >= 0x0a) {
   2298      1.128   msaitoh 			unsigned int pmcver, ncounter, veclen;
   2299      1.128   msaitoh 
   2300      1.126   msaitoh 			x86_cpuid(0x0a, descs);
   2301      1.128   msaitoh 			pmcver = __SHIFTOUT(descs[0], CPUID_PERF_VERSION);
   2302      1.128   msaitoh 			ncounter = __SHIFTOUT(descs[0], CPUID_PERF_NGPPC);
   2303      1.128   msaitoh 			veclen = __SHIFTOUT(descs[0], CPUID_PERF_BVECLEN);
   2304      1.128   msaitoh 			aprint_verbose("%s: Perfmon: Ver. %u",
   2305      1.128   msaitoh 			    cpuname, pmcver);
   2306      1.128   msaitoh 			if (((pmcver >= 3) && (pmcver <= 4)) ||
   2307      1.128   msaitoh 			    ((pmcver >= 5) &&
   2308      1.128   msaitoh 				(descs[3] & CPUID_PERF_ANYTHREADDEPR) == 0))
   2309      1.128   msaitoh 				aprint_verbose(" <ANYTHREAD>\n");
   2310      1.128   msaitoh 			else
   2311      1.128   msaitoh 				aprint_verbose("\n");
   2312      1.128   msaitoh 
   2313      1.128   msaitoh 			aprint_verbose("%s: Perfmon: General: "
   2314      1.128   msaitoh 			    "bitwidth %u, %u counters\n", cpuname,
   2315      1.128   msaitoh 			    (uint32_t)__SHIFTOUT(descs[0], CPUID_PERF_NBWGPPC),
   2316      1.128   msaitoh 			    ncounter);
   2317      1.128   msaitoh 			/* Invert logic for the output */
   2318      1.128   msaitoh 			descs[1] ^= __BITS(veclen - 1, 0);
   2319      1.128   msaitoh 			/*
   2320      1.128   msaitoh 			 * Mask unrelated bits. An hypervisor reduces the
   2321      1.128   msaitoh 			 * vector and set bit(s) out of the vector.
   2322      1.128   msaitoh 			 */
   2323      1.128   msaitoh 			descs[1] &= __BITS(veclen - 1, 0);
   2324      1.128   msaitoh 			print_bits(cpuname, "Perfmon: General: avail",
   2325      1.126   msaitoh 			    CPUID_PERF_FLAGS1, descs[1]);
   2326      1.128   msaitoh 
   2327      1.128   msaitoh 			if (pmcver >= 2) {
   2328      1.128   msaitoh 				ncounter = __SHIFTOUT(descs[3],
   2329      1.128   msaitoh 				    CPUID_PERF_NFFPC);
   2330      1.128   msaitoh 				aprint_verbose("%s: Perfmon: Fixed: "
   2331      1.128   msaitoh 				    "bitwidth %u, %u counters\n", cpuname,
   2332      1.128   msaitoh 				    (uint32_t)__SHIFTOUT(descs[3],
   2333      1.128   msaitoh 					CPUID_PERF_NBWFFPC),
   2334      1.128   msaitoh 				    ncounter);
   2335      1.128   msaitoh 				if (pmcver <= 4)
   2336      1.128   msaitoh 					descs[2] = __BITS(ncounter - 1, 0);
   2337      1.128   msaitoh 				print_bits(cpuname, "Perfmon: Fixed: avail",
   2338      1.128   msaitoh 				    CPUID_PERF_FLAGS2, descs[2]);
   2339      1.128   msaitoh 			}
   2340       1.39      yamt 		}
   2341      1.127   msaitoh 		if (ci->ci_max_cpuid >= 0x1a) {
   2342      1.127   msaitoh 			x86_cpuid(0x1a, descs);
   2343      1.127   msaitoh 			if (descs[0] != 0) {
   2344      1.127   msaitoh 				aprint_verbose("%s: Hybrid: Core type %02x, "
   2345      1.127   msaitoh 				    "Native Model ID %07x\n",
   2346      1.127   msaitoh 				    cpuname,
   2347      1.127   msaitoh 				    (uint8_t)__SHIFTOUT(descs[0],
   2348      1.127   msaitoh 					CPUID_HYBRID_CORETYPE),
   2349      1.127   msaitoh 				    (uint32_t)__SHIFTOUT(descs[0],
   2350      1.127   msaitoh 					CPUID_HYBRID_NATIVEID));
   2351      1.127   msaitoh 			}
   2352      1.127   msaitoh 		}
   2353        1.1        ad 	}
   2354        1.1        ad 
   2355        1.1        ad #ifdef INTEL_ONDEMAND_CLOCKMOD
   2356        1.1        ad 	clockmod_init();
   2357        1.1        ad #endif
   2358        1.2        ad 
   2359       1.32  drochner 	if (cpu_vendor == CPUVENDOR_AMD)
   2360       1.32  drochner 		ucode.loader_version = CPU_UCODE_LOADER_AMD;
   2361       1.32  drochner 	else if (cpu_vendor == CPUVENDOR_INTEL)
   2362       1.32  drochner 		ucode.loader_version = CPU_UCODE_LOADER_INTEL1;
   2363       1.32  drochner 	else
   2364       1.32  drochner 		return;
   2365       1.35       dsl 
   2366       1.32  drochner 	ucode.data = &ucvers;
   2367       1.35       dsl 	if (ioctl(fd, IOC_CPU_UCODE_GET_VERSION, &ucode) < 0) {
   2368       1.35       dsl #ifdef __i386__
   2369       1.35       dsl 		struct cpu_ucode_version_64 ucode_64;
   2370       1.35       dsl 		if (errno != ENOTTY)
   2371       1.35       dsl 			return;
   2372       1.35       dsl 		/* Try the 64 bit ioctl */
   2373       1.35       dsl 		memset(&ucode_64, 0, sizeof ucode_64);
   2374       1.35       dsl 		ucode_64.data = &ucvers;
   2375       1.35       dsl 		ucode_64.loader_version = ucode.loader_version;
   2376       1.35       dsl 		if (ioctl(fd, IOC_CPU_UCODE_GET_VERSION_64, &ucode_64) < 0)
   2377       1.35       dsl 			return;
   2378       1.64   msaitoh #else
   2379       1.64   msaitoh 		return;
   2380       1.35       dsl #endif
   2381       1.35       dsl 	}
   2382       1.35       dsl 
   2383       1.32  drochner 	if (cpu_vendor == CPUVENDOR_AMD)
   2384       1.32  drochner 		printf("%s: UCode version: 0x%"PRIx64"\n", cpuname, ucvers.amd.version);
   2385       1.32  drochner 	else if (cpu_vendor == CPUVENDOR_INTEL)
   2386       1.32  drochner 		printf("%s: microcode version 0x%x, platform ID %d\n", cpuname,
   2387       1.85   msaitoh 		    ucvers.intel1.ucodeversion, ucvers.intel1.platformid);
   2388        1.1        ad }
   2389        1.1        ad 
   2390        1.1        ad static const char *
   2391        1.1        ad print_cache_config(struct cpu_info *ci, int cache_tag, const char *name,
   2392        1.1        ad     const char *sep)
   2393        1.1        ad {
   2394        1.1        ad 	struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag];
   2395        1.7  christos 	char human_num[HUMAN_BUFSIZE];
   2396        1.1        ad 
   2397        1.1        ad 	if (cai->cai_totalsize == 0)
   2398        1.1        ad 		return sep;
   2399        1.1        ad 
   2400        1.1        ad 	if (sep == NULL)
   2401        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "");
   2402        1.1        ad 	else
   2403        1.1        ad 		aprint_verbose("%s", sep);
   2404        1.1        ad 	if (name != NULL)
   2405        1.1        ad 		aprint_verbose("%s ", name);
   2406        1.1        ad 
   2407        1.1        ad 	if (cai->cai_string != NULL) {
   2408        1.1        ad 		aprint_verbose("%s ", cai->cai_string);
   2409        1.1        ad 	} else {
   2410        1.8  christos 		(void)humanize_number(human_num, sizeof(human_num),
   2411       1.85   msaitoh 		    cai->cai_totalsize, "B", HN_AUTOSCALE, HN_NOSPACE);
   2412        1.7  christos 		aprint_verbose("%s %dB/line ", human_num, cai->cai_linesize);
   2413        1.1        ad 	}
   2414        1.1        ad 	switch (cai->cai_associativity) {
   2415       1.85   msaitoh 	case	0:
   2416        1.1        ad 		aprint_verbose("disabled");
   2417        1.1        ad 		break;
   2418       1.85   msaitoh 	case	1:
   2419        1.1        ad 		aprint_verbose("direct-mapped");
   2420        1.1        ad 		break;
   2421        1.1        ad 	case 0xff:
   2422        1.1        ad 		aprint_verbose("fully associative");
   2423        1.1        ad 		break;
   2424        1.1        ad 	default:
   2425        1.1        ad 		aprint_verbose("%d-way", cai->cai_associativity);
   2426        1.1        ad 		break;
   2427        1.1        ad 	}
   2428        1.1        ad 	return ", ";
   2429        1.1        ad }
   2430        1.1        ad 
   2431        1.1        ad static const char *
   2432        1.1        ad print_tlb_config(struct cpu_info *ci, int cache_tag, const char *name,
   2433        1.1        ad     const char *sep)
   2434        1.1        ad {
   2435        1.1        ad 	struct x86_cache_info *cai = &ci->ci_cinfo[cache_tag];
   2436        1.7  christos 	char human_num[HUMAN_BUFSIZE];
   2437        1.1        ad 
   2438        1.1        ad 	if (cai->cai_totalsize == 0)
   2439        1.1        ad 		return sep;
   2440        1.1        ad 
   2441        1.1        ad 	if (sep == NULL)
   2442        1.1        ad 		aprint_verbose_dev(ci->ci_dev, "");
   2443        1.1        ad 	else
   2444        1.1        ad 		aprint_verbose("%s", sep);
   2445      1.119   msaitoh 	if ((name != NULL) && (sep == NULL))
   2446        1.1        ad 		aprint_verbose("%s ", name);
   2447        1.1        ad 
   2448        1.1        ad 	if (cai->cai_string != NULL) {
   2449        1.1        ad 		aprint_verbose("%s", cai->cai_string);
   2450        1.1        ad 	} else {
   2451        1.7  christos 		(void)humanize_number(human_num, sizeof(human_num),
   2452       1.85   msaitoh 		    cai->cai_linesize, "B", HN_AUTOSCALE, HN_NOSPACE);
   2453        1.7  christos 		aprint_verbose("%d %s entries ", cai->cai_totalsize,
   2454        1.7  christos 		    human_num);
   2455        1.1        ad 		switch (cai->cai_associativity) {
   2456        1.1        ad 		case 0:
   2457        1.1        ad 			aprint_verbose("disabled");
   2458        1.1        ad 			break;
   2459        1.1        ad 		case 1:
   2460        1.1        ad 			aprint_verbose("direct-mapped");
   2461        1.1        ad 			break;
   2462        1.1        ad 		case 0xff:
   2463        1.1        ad 			aprint_verbose("fully associative");
   2464        1.1        ad 			break;
   2465        1.1        ad 		default:
   2466        1.1        ad 			aprint_verbose("%d-way", cai->cai_associativity);
   2467        1.1        ad 			break;
   2468        1.1        ad 		}
   2469        1.1        ad 	}
   2470        1.1        ad 	return ", ";
   2471        1.1        ad }
   2472        1.1        ad 
   2473        1.1        ad static void
   2474       1.54   msaitoh x86_print_cache_and_tlb_info(struct cpu_info *ci)
   2475        1.1        ad {
   2476       1.47       mrg 	const char *sep = NULL;
   2477        1.1        ad 
   2478        1.1        ad 	if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 ||
   2479        1.1        ad 	    ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) {
   2480      1.118   msaitoh 		sep = print_cache_config(ci, CAI_ICACHE, "I-cache:", NULL);
   2481      1.118   msaitoh 		sep = print_cache_config(ci, CAI_DCACHE, "D-cache:", sep);
   2482        1.1        ad 		if (sep != NULL)
   2483        1.1        ad 			aprint_verbose("\n");
   2484        1.1        ad 	}
   2485        1.1        ad 	if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) {
   2486      1.118   msaitoh 		sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache:", NULL);
   2487        1.1        ad 		if (sep != NULL)
   2488        1.1        ad 			aprint_verbose("\n");
   2489        1.1        ad 	}
   2490       1.26       chs 	if (ci->ci_cinfo[CAI_L3CACHE].cai_totalsize != 0) {
   2491      1.118   msaitoh 		sep = print_cache_config(ci, CAI_L3CACHE, "L3 cache:", NULL);
   2492       1.26       chs 		if (sep != NULL)
   2493       1.26       chs 			aprint_verbose("\n");
   2494       1.26       chs 	}
   2495       1.46   msaitoh 	if (ci->ci_cinfo[CAI_PREFETCH].cai_linesize != 0) {
   2496       1.46   msaitoh 		aprint_verbose_dev(ci->ci_dev, "%dB prefetching",
   2497       1.85   msaitoh 		    ci->ci_cinfo[CAI_PREFETCH].cai_linesize);
   2498       1.46   msaitoh 		if (sep != NULL)
   2499       1.46   msaitoh 			aprint_verbose("\n");
   2500       1.46   msaitoh 	}
   2501      1.119   msaitoh 
   2502      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_ITLB, "ITLB:", NULL);
   2503      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_ITLB2, "ITLB:", sep);
   2504      1.124   msaitoh 	sep = print_tlb_config(ci, CAI_L1_1GBITLB, "ITLB:", sep);
   2505      1.119   msaitoh 	if (sep != NULL)
   2506      1.119   msaitoh 		aprint_verbose("\n");
   2507      1.119   msaitoh 
   2508      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_DTLB, "DTLB:", NULL);
   2509      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_DTLB2, "DTLB:", sep);
   2510      1.124   msaitoh 	sep = print_tlb_config(ci, CAI_L1_1GBDTLB, "DTLB:", sep);
   2511      1.119   msaitoh 	if (sep != NULL)
   2512      1.119   msaitoh 		aprint_verbose("\n");
   2513      1.119   msaitoh 
   2514      1.120   msaitoh 	sep = print_tlb_config(ci, CAI_L1_LD_TLB, "Load only TLB:", NULL);
   2515      1.120   msaitoh 	if (sep != NULL)
   2516      1.120   msaitoh 		aprint_verbose("\n");
   2517      1.120   msaitoh 
   2518      1.120   msaitoh 	sep = print_tlb_config(ci, CAI_L1_ST_TLB, "Store only TLB:", NULL);
   2519      1.120   msaitoh 	if (sep != NULL)
   2520      1.120   msaitoh 		aprint_verbose("\n");
   2521      1.120   msaitoh 
   2522      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_ITLB, "L2 ITLB:", NULL);
   2523      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_ITLB2, "L2 ITLB:", sep);
   2524      1.124   msaitoh 	sep = print_tlb_config(ci, CAI_L2_1GBITLB, "L2 ITLB:", sep);
   2525      1.119   msaitoh 	if (sep != NULL)
   2526      1.119   msaitoh 		aprint_verbose("\n");
   2527      1.119   msaitoh 
   2528      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_DTLB, "L2 DTLB:", NULL);
   2529      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_DTLB2, "L2 DTLB:", sep);
   2530      1.124   msaitoh 	sep = print_tlb_config(ci, CAI_L2_1GBDTLB, "L2 DTLB:", sep);
   2531      1.119   msaitoh 	if (sep != NULL)
   2532      1.119   msaitoh 		aprint_verbose("\n");
   2533      1.119   msaitoh 
   2534      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_STLB, "L2 STLB:", NULL);
   2535      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_STLB2, "L2 STLB:", sep);
   2536      1.119   msaitoh 	sep = print_tlb_config(ci, CAI_L2_STLB3, "L2 STLB:", sep);
   2537      1.119   msaitoh 	if (sep != NULL)
   2538      1.119   msaitoh 		aprint_verbose("\n");
   2539        1.1        ad }
   2540        1.5        ad 
   2541        1.5        ad static void
   2542        1.5        ad powernow_probe(struct cpu_info *ci)
   2543        1.5        ad {
   2544        1.5        ad 	uint32_t regs[4];
   2545       1.14  christos 	char buf[256];
   2546        1.5        ad 
   2547        1.5        ad 	x86_cpuid(0x80000007, regs);
   2548        1.5        ad 
   2549       1.14  christos 	snprintb(buf, sizeof(buf), CPUID_APM_FLAGS, regs[3]);
   2550      1.110   msaitoh 	aprint_normal_dev(ci->ci_dev, "Power Management features: %s\n", buf);
   2551        1.5        ad }
   2552       1.32  drochner 
   2553       1.80       mrg bool
   2554       1.80       mrg identifycpu_bind(void)
   2555       1.80       mrg {
   2556       1.80       mrg 
   2557       1.80       mrg 	return true;
   2558       1.80       mrg }
   2559       1.80       mrg 
   2560       1.32  drochner int
   2561       1.32  drochner ucodeupdate_check(int fd, struct cpu_ucode *uc)
   2562       1.32  drochner {
   2563       1.32  drochner 	struct cpu_info ci;
   2564       1.32  drochner 	int loader_version, res;
   2565       1.32  drochner 	struct cpu_ucode_version versreq;
   2566       1.32  drochner 
   2567       1.34       dsl 	cpu_probe_base_features(&ci, "unknown");
   2568       1.34       dsl 
   2569       1.32  drochner 	if (!strcmp((char *)ci.ci_vendor, "AuthenticAMD"))
   2570       1.32  drochner 		loader_version = CPU_UCODE_LOADER_AMD;
   2571       1.32  drochner 	else if (!strcmp((char *)ci.ci_vendor, "GenuineIntel"))
   2572       1.32  drochner 		loader_version = CPU_UCODE_LOADER_INTEL1;
   2573       1.32  drochner 	else
   2574       1.32  drochner 		return -1;
   2575       1.32  drochner 
   2576       1.32  drochner 	/* check whether the kernel understands this loader version */
   2577       1.32  drochner 	versreq.loader_version = loader_version;
   2578       1.32  drochner 	versreq.data = 0;
   2579       1.32  drochner 	res = ioctl(fd, IOC_CPU_UCODE_GET_VERSION, &versreq);
   2580       1.32  drochner 	if (res)
   2581       1.32  drochner 		return -1;
   2582       1.32  drochner 
   2583       1.32  drochner 	switch (loader_version) {
   2584       1.32  drochner 	case CPU_UCODE_LOADER_AMD:
   2585       1.32  drochner 		if (uc->cpu_nr != -1) {
   2586       1.32  drochner 			/* printf? */
   2587       1.32  drochner 			return -1;
   2588       1.32  drochner 		}
   2589       1.32  drochner 		uc->cpu_nr = CPU_UCODE_ALL_CPUS;
   2590       1.32  drochner 		break;
   2591       1.32  drochner 	case CPU_UCODE_LOADER_INTEL1:
   2592       1.32  drochner 		if (uc->cpu_nr == -1)
   2593       1.32  drochner 			uc->cpu_nr = CPU_UCODE_ALL_CPUS; /* for Xen */
   2594       1.32  drochner 		else
   2595       1.32  drochner 			uc->cpu_nr = CPU_UCODE_CURRENT_CPU;
   2596       1.32  drochner 		break;
   2597       1.32  drochner 	default: /* can't happen */
   2598       1.32  drochner 		return -1;
   2599       1.32  drochner 	}
   2600       1.32  drochner 	uc->loader_version = loader_version;
   2601       1.32  drochner 	return 0;
   2602       1.32  drochner }
   2603