2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * Copyright (c) 1997 KATO Takenori.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * from: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
46 #include <sys/param.h>
49 #include <sys/eventhandler.h>
50 #include <sys/systm.h>
51 #include <sys/kernel.h>
52 #include <sys/sysctl.h>
53 #include <sys/power.h>
55 #include <machine/asmacros.h>
56 #include <machine/clock.h>
57 #include <machine/cputypes.h>
58 #include <machine/frame.h>
59 #include <machine/intr_machdep.h>
60 #include <machine/md_var.h>
61 #include <machine/segments.h>
62 #include <machine/specialreg.h>
64 #include <amd64/vmm/intel/vmx_controls.h>
65 #include <x86/isa/icu.h>
68 #define IDENTBLUE_CYRIX486 0
69 #define IDENTBLUE_IBMCPU 1
70 #define IDENTBLUE_CYRIXM2 2
72 static void identifycyrix(void);
73 static void print_transmeta_info(void);
75 static u_int find_cpu_vendor_id(void);
76 static void print_AMD_info(void);
77 static void print_INTEL_info(void);
78 static void print_INTEL_TLB(u_int data);
79 static void print_via_padlock_info(void);
80 static void print_vmx_info(void);
83 char machine[] = MACHINE;
87 extern int adaptive_machine_arch;
91 sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
94 static const char machine32[] = "i386";
99 if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch)
100 error = SYSCTL_OUT(req, machine32, sizeof(machine32));
103 error = SYSCTL_OUT(req, machine, sizeof(machine));
107 SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD,
108 NULL, 0, sysctl_hw_machine, "A", "Machine class");
110 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
111 machine, 0, "Machine class");
114 static char cpu_model[128];
115 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
116 cpu_model, 0, "Machine model");
118 static int hw_clockrate;
119 SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
120 &hw_clockrate, 0, "CPU instruction clock rate");
122 static eventhandler_tag tsc_post_tag;
124 static char cpu_brand[48];
127 #define MAX_BRAND_INDEX 8
129 static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = {
133 "Intel Pentium III Xeon",
147 { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */
148 { "i386SX", CPUCLASS_386 }, /* CPU_386SX */
149 { "i386DX", CPUCLASS_386 }, /* CPU_386 */
150 { "i486SX", CPUCLASS_486 }, /* CPU_486SX */
151 { "i486DX", CPUCLASS_486 }, /* CPU_486 */
152 { "Pentium", CPUCLASS_586 }, /* CPU_586 */
153 { "Cyrix 486", CPUCLASS_486 }, /* CPU_486DLC */
154 { "Pentium Pro", CPUCLASS_686 }, /* CPU_686 */
155 { "Cyrix 5x86", CPUCLASS_486 }, /* CPU_M1SC */
156 { "Cyrix 6x86", CPUCLASS_486 }, /* CPU_M1 */
157 { "Blue Lightning", CPUCLASS_486 }, /* CPU_BLUE */
158 { "Cyrix 6x86MX", CPUCLASS_686 }, /* CPU_M2 */
159 { "NexGen 586", CPUCLASS_386 }, /* CPU_NX586 (XXX) */
160 { "Cyrix 486S/DX", CPUCLASS_486 }, /* CPU_CY486DX */
161 { "Pentium II", CPUCLASS_686 }, /* CPU_PII */
162 { "Pentium III", CPUCLASS_686 }, /* CPU_PIII */
163 { "Pentium 4", CPUCLASS_686 }, /* CPU_P4 */
165 { "Clawhammer", CPUCLASS_K8 }, /* CPU_CLAWHAMMER */
166 { "Sledgehammer", CPUCLASS_K8 }, /* CPU_SLEDGEHAMMER */
174 { INTEL_VENDOR_ID, CPU_VENDOR_INTEL }, /* GenuineIntel */
175 { AMD_VENDOR_ID, CPU_VENDOR_AMD }, /* AuthenticAMD */
176 { CENTAUR_VENDOR_ID, CPU_VENDOR_CENTAUR }, /* CentaurHauls */
178 { NSC_VENDOR_ID, CPU_VENDOR_NSC }, /* Geode by NSC */
179 { CYRIX_VENDOR_ID, CPU_VENDOR_CYRIX }, /* CyrixInstead */
180 { TRANSMETA_VENDOR_ID, CPU_VENDOR_TRANSMETA }, /* GenuineTMx86 */
181 { SIS_VENDOR_ID, CPU_VENDOR_SIS }, /* SiS SiS SiS */
182 { UMC_VENDOR_ID, CPU_VENDOR_UMC }, /* UMC UMC UMC */
183 { NEXGEN_VENDOR_ID, CPU_VENDOR_NEXGEN }, /* NexGenDriven */
184 { RISE_VENDOR_ID, CPU_VENDOR_RISE }, /* RiseRiseRise */
186 /* XXX CPUID 8000_0000h and 8086_0000h, not 0000_0000h */
187 { "TransmetaCPU", CPU_VENDOR_TRANSMETA },
198 cpu_class = cpus[cpu].cpu_class;
200 strncpy(cpu_model, cpus[cpu].cpu_name, sizeof (cpu_model));
202 /* Check for extended CPUID information and a processor name. */
203 if (cpu_exthigh >= 0x80000004) {
205 for (i = 0x80000002; i < 0x80000005; i++) {
207 memcpy(brand, regs, sizeof(regs));
208 brand += sizeof(regs);
212 switch (cpu_vendor_id) {
213 case CPU_VENDOR_INTEL:
215 if ((cpu_id & 0xf00) > 0x300) {
220 switch (cpu_id & 0x3000) {
222 strcpy(cpu_model, "Overdrive ");
225 strcpy(cpu_model, "Dual ");
229 switch (cpu_id & 0xf00) {
231 strcat(cpu_model, "i486 ");
232 /* Check the particular flavor of 486 */
233 switch (cpu_id & 0xf0) {
236 strcat(cpu_model, "DX");
239 strcat(cpu_model, "SX");
242 strcat(cpu_model, "DX2");
245 strcat(cpu_model, "SL");
248 strcat(cpu_model, "SX2");
252 "DX2 Write-Back Enhanced");
255 strcat(cpu_model, "DX4");
260 /* Check the particular flavor of 586 */
261 strcat(cpu_model, "Pentium");
262 switch (cpu_id & 0xf0) {
264 strcat(cpu_model, " A-step");
267 strcat(cpu_model, "/P5");
270 strcat(cpu_model, "/P54C");
273 strcat(cpu_model, "/P24T");
276 strcat(cpu_model, "/P55C");
279 strcat(cpu_model, "/P54C");
282 strcat(cpu_model, "/P55C (quarter-micron)");
288 #if defined(I586_CPU) && !defined(NO_F00F_HACK)
290 * XXX - If/when Intel fixes the bug, this
291 * should also check the version of the
292 * CPU, not just that it's a Pentium.
298 /* Check the particular flavor of 686 */
299 switch (cpu_id & 0xf0) {
301 strcat(cpu_model, "Pentium Pro A-step");
304 strcat(cpu_model, "Pentium Pro");
310 "Pentium II/Pentium II Xeon/Celeron");
318 "Pentium III/Pentium III Xeon/Celeron");
322 strcat(cpu_model, "Unknown 80686");
327 strcat(cpu_model, "Pentium 4");
331 strcat(cpu_model, "unknown");
336 * If we didn't get a brand name from the extended
337 * CPUID, try to look it up in the brand table.
339 if (cpu_high > 0 && *cpu_brand == '\0') {
340 brand_index = cpu_procinfo & CPUID_BRAND_INDEX;
341 if (brand_index <= MAX_BRAND_INDEX &&
342 cpu_brandtable[brand_index] != NULL)
344 cpu_brandtable[brand_index]);
348 /* Please make up your mind folks! */
349 strcat(cpu_model, "EM64T");
354 * Values taken from AMD Processor Recognition
355 * http://www.amd.com/K6/k6docs/pdf/20734g.pdf
356 * (also describes ``Features'' encodings.
358 strcpy(cpu_model, "AMD ");
360 switch (cpu_id & 0xFF0) {
362 strcat(cpu_model, "Standard Am486DX");
365 strcat(cpu_model, "Enhanced Am486DX2 Write-Through");
368 strcat(cpu_model, "Enhanced Am486DX2 Write-Back");
371 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Through");
374 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Back");
377 strcat(cpu_model, "Am5x86 Write-Through");
380 strcat(cpu_model, "Am5x86 Write-Back");
383 strcat(cpu_model, "K5 model 0");
386 strcat(cpu_model, "K5 model 1");
389 strcat(cpu_model, "K5 PR166 (model 2)");
392 strcat(cpu_model, "K5 PR200 (model 3)");
395 strcat(cpu_model, "K6");
398 strcat(cpu_model, "K6 266 (model 1)");
401 strcat(cpu_model, "K6-2");
404 strcat(cpu_model, "K6-III");
407 strcat(cpu_model, "Geode LX");
410 strcat(cpu_model, "Unknown");
414 if ((cpu_id & 0xf00) == 0xf00)
415 strcat(cpu_model, "AMD64 Processor");
417 strcat(cpu_model, "Unknown");
421 case CPU_VENDOR_CYRIX:
422 strcpy(cpu_model, "Cyrix ");
423 switch (cpu_id & 0xff0) {
425 strcat(cpu_model, "MediaGX");
428 strcat(cpu_model, "6x86");
431 cpu_class = CPUCLASS_586;
432 strcat(cpu_model, "GXm");
435 strcat(cpu_model, "6x86MX");
439 * Even though CPU supports the cpuid
440 * instruction, it can be disabled.
441 * Therefore, this routine supports all Cyrix
444 switch (cyrix_did & 0xf0) {
446 switch (cyrix_did & 0x0f) {
448 strcat(cpu_model, "486SLC");
451 strcat(cpu_model, "486DLC");
454 strcat(cpu_model, "486SLC2");
457 strcat(cpu_model, "486DLC2");
460 strcat(cpu_model, "486SRx");
463 strcat(cpu_model, "486DRx");
466 strcat(cpu_model, "486SRx2");
469 strcat(cpu_model, "486DRx2");
472 strcat(cpu_model, "486SRu");
475 strcat(cpu_model, "486DRu");
478 strcat(cpu_model, "486SRu2");
481 strcat(cpu_model, "486DRu2");
484 strcat(cpu_model, "Unknown");
489 switch (cyrix_did & 0x0f) {
491 strcat(cpu_model, "486S");
494 strcat(cpu_model, "486S2");
497 strcat(cpu_model, "486Se");
500 strcat(cpu_model, "486S2e");
503 strcat(cpu_model, "486DX");
506 strcat(cpu_model, "486DX2");
509 strcat(cpu_model, "486DX4");
512 strcat(cpu_model, "Unknown");
517 if ((cyrix_did & 0x0f) < 8)
518 strcat(cpu_model, "6x86"); /* Where did you get it? */
520 strcat(cpu_model, "5x86");
523 strcat(cpu_model, "6x86");
526 if ((cyrix_did & 0xf000) == 0x3000) {
527 cpu_class = CPUCLASS_586;
528 strcat(cpu_model, "GXm");
530 strcat(cpu_model, "MediaGX");
533 strcat(cpu_model, "6x86MX");
536 switch (cyrix_did & 0x0f) {
538 strcat(cpu_model, "Overdrive CPU");
541 strcpy(cpu_model, "Texas Instruments 486SXL");
544 strcat(cpu_model, "486SLC/DLC");
547 strcat(cpu_model, "Unknown");
552 strcat(cpu_model, "Unknown");
558 case CPU_VENDOR_RISE:
559 strcpy(cpu_model, "Rise ");
560 switch (cpu_id & 0xff0) {
561 case 0x500: /* 6401 and 6441 (Kirin) */
562 case 0x520: /* 6510 (Lynx) */
563 strcat(cpu_model, "mP6");
566 strcat(cpu_model, "Unknown");
570 case CPU_VENDOR_CENTAUR:
572 switch (cpu_id & 0xff0) {
574 strcpy(cpu_model, "IDT WinChip C6");
577 strcpy(cpu_model, "IDT WinChip 2");
580 strcpy(cpu_model, "IDT WinChip 3");
583 strcpy(cpu_model, "VIA C3 Samuel");
587 strcpy(cpu_model, "VIA C3 Ezra");
589 strcpy(cpu_model, "VIA C3 Samuel 2");
592 strcpy(cpu_model, "VIA C3 Ezra-T");
595 strcpy(cpu_model, "VIA C3 Nehemiah");
599 strcpy(cpu_model, "VIA C7 Esther");
602 strcpy(cpu_model, "VIA Nano");
605 strcpy(cpu_model, "VIA/IDT Unknown");
608 strcpy(cpu_model, "VIA ");
609 if ((cpu_id & 0xff0) == 0x6f0)
610 strcat(cpu_model, "Nano Processor");
612 strcat(cpu_model, "Unknown");
617 strcpy(cpu_model, "Blue Lightning CPU");
620 switch (cpu_id & 0xff0) {
622 strcpy(cpu_model, "Geode SC1100");
626 strcpy(cpu_model, "Geode/NSC unknown");
632 strcat(cpu_model, "Unknown");
637 * Replace cpu_model with cpu_brand minus leading spaces if
641 while (*brand == ' ')
644 strcpy(cpu_model, brand);
646 printf("%s (", cpu_model);
648 hw_clockrate = (tsc_freq + 5000) / 1000000;
649 printf("%jd.%02d-MHz ",
650 (intmax_t)(tsc_freq + 4999) / 1000000,
651 (u_int)((tsc_freq + 4999) / 10000) % 100);
661 #if defined(I486_CPU)
666 #if defined(I586_CPU)
671 #if defined(I686_CPU)
682 printf("Unknown"); /* will panic below... */
684 printf("-class CPU)\n");
686 printf(" Origin=\"%s\"", cpu_vendor);
688 printf(" Id=0x%x", cpu_id);
690 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
691 cpu_vendor_id == CPU_VENDOR_AMD ||
692 cpu_vendor_id == CPU_VENDOR_CENTAUR ||
694 cpu_vendor_id == CPU_VENDOR_TRANSMETA ||
695 cpu_vendor_id == CPU_VENDOR_RISE ||
696 cpu_vendor_id == CPU_VENDOR_NSC ||
697 (cpu_vendor_id == CPU_VENDOR_CYRIX && ((cpu_id & 0xf00) > 0x500)) ||
700 printf(" Family=0x%x", CPUID_TO_FAMILY(cpu_id));
701 printf(" Model=0x%x", CPUID_TO_MODEL(cpu_id));
702 printf(" Stepping=%u", cpu_id & CPUID_STEPPING);
704 if (cpu_vendor_id == CPU_VENDOR_CYRIX)
705 printf("\n DIR=0x%04x", cyrix_did);
709 * AMD CPUID Specification
710 * http://support.amd.com/us/Embedded_TechDocs/25481.pdf
712 * Intel Processor Identification and CPUID Instruction
713 * http://www.intel.com/assets/pdf/appnote/241618.pdf
718 * Here we should probably set up flags indicating
719 * whether or not various features are available.
720 * The interesting ones are probably VME, PSE, PAE,
721 * and PGE. The code already assumes without bothering
722 * to check that all CPUs >= Pentium have a TSC and
725 printf("\n Features=0x%b", cpu_feature,
727 "\001FPU" /* Integral FPU */
728 "\002VME" /* Extended VM86 mode support */
729 "\003DE" /* Debugging Extensions (CR4.DE) */
730 "\004PSE" /* 4MByte page tables */
731 "\005TSC" /* Timestamp counter */
732 "\006MSR" /* Machine specific registers */
733 "\007PAE" /* Physical address extension */
734 "\010MCE" /* Machine Check support */
735 "\011CX8" /* CMPEXCH8 instruction */
736 "\012APIC" /* SMP local APIC */
737 "\013oldMTRR" /* Previous implementation of MTRR */
738 "\014SEP" /* Fast System Call */
739 "\015MTRR" /* Memory Type Range Registers */
740 "\016PGE" /* PG_G (global bit) support */
741 "\017MCA" /* Machine Check Architecture */
742 "\020CMOV" /* CMOV instruction */
743 "\021PAT" /* Page attributes table */
744 "\022PSE36" /* 36 bit address space support */
745 "\023PN" /* Processor Serial number */
746 "\024CLFLUSH" /* Has the CLFLUSH instruction */
748 "\026DTS" /* Debug Trace Store */
749 "\027ACPI" /* ACPI support */
750 "\030MMX" /* MMX instructions */
751 "\031FXSR" /* FXSAVE/FXRSTOR */
752 "\032SSE" /* Streaming SIMD Extensions */
753 "\033SSE2" /* Streaming SIMD Extensions #2 */
754 "\034SS" /* Self snoop */
755 "\035HTT" /* Hyperthreading (see EBX bit 16-23) */
756 "\036TM" /* Thermal Monitor clock slowdown */
757 "\037IA64" /* CPU can execute IA64 instructions */
758 "\040PBE" /* Pending Break Enable */
761 if (cpu_feature2 != 0) {
762 printf("\n Features2=0x%b", cpu_feature2,
764 "\001SSE3" /* SSE3 */
765 "\002PCLMULQDQ" /* Carry-Less Mul Quadword */
766 "\003DTES64" /* 64-bit Debug Trace */
767 "\004MON" /* MONITOR/MWAIT Instructions */
768 "\005DS_CPL" /* CPL Qualified Debug Store */
769 "\006VMX" /* Virtual Machine Extensions */
770 "\007SMX" /* Safer Mode Extensions */
771 "\010EST" /* Enhanced SpeedStep */
772 "\011TM2" /* Thermal Monitor 2 */
773 "\012SSSE3" /* SSSE3 */
774 "\013CNXT-ID" /* L1 context ID available */
776 "\015FMA" /* Fused Multiply Add */
777 "\016CX16" /* CMPXCHG16B Instruction */
778 "\017xTPR" /* Send Task Priority Messages*/
779 "\020PDCM" /* Perf/Debug Capability MSR */
781 "\022PCID" /* Process-context Identifiers*/
782 "\023DCA" /* Direct Cache Access */
783 "\024SSE4.1" /* SSE 4.1 */
784 "\025SSE4.2" /* SSE 4.2 */
785 "\026x2APIC" /* xAPIC Extensions */
786 "\027MOVBE" /* MOVBE Instruction */
787 "\030POPCNT" /* POPCNT Instruction */
788 "\031TSCDLT" /* TSC-Deadline Timer */
789 "\032AESNI" /* AES Crypto */
790 "\033XSAVE" /* XSAVE/XRSTOR States */
791 "\034OSXSAVE" /* OS-Enabled State Management*/
792 "\035AVX" /* Advanced Vector Extensions */
793 "\036F16C" /* Half-precision conversions */
794 "\037RDRAND" /* RDRAND Instruction */
795 "\040HV" /* Hypervisor */
799 if (amd_feature != 0) {
800 printf("\n AMD Features=0x%b", amd_feature,
802 "\001<s0>" /* Same */
803 "\002<s1>" /* Same */
804 "\003<s2>" /* Same */
805 "\004<s3>" /* Same */
806 "\005<s4>" /* Same */
807 "\006<s5>" /* Same */
808 "\007<s6>" /* Same */
809 "\010<s7>" /* Same */
810 "\011<s8>" /* Same */
811 "\012<s9>" /* Same */
812 "\013<b10>" /* Undefined */
813 "\014SYSCALL" /* Have SYSCALL/SYSRET */
814 "\015<s12>" /* Same */
815 "\016<s13>" /* Same */
816 "\017<s14>" /* Same */
817 "\020<s15>" /* Same */
818 "\021<s16>" /* Same */
819 "\022<s17>" /* Same */
820 "\023<b18>" /* Reserved, unknown */
821 "\024MP" /* Multiprocessor Capable */
822 "\025NX" /* Has EFER.NXE, NX */
823 "\026<b21>" /* Undefined */
824 "\027MMX+" /* AMD MMX Extensions */
825 "\030<s23>" /* Same */
826 "\031<s24>" /* Same */
827 "\032FFXSR" /* Fast FXSAVE/FXRSTOR */
828 "\033Page1GB" /* 1-GB large page support */
829 "\034RDTSCP" /* RDTSCP */
830 "\035<b28>" /* Undefined */
831 "\036LM" /* 64 bit long mode */
832 "\0373DNow!+" /* AMD 3DNow! Extensions */
833 "\0403DNow!" /* AMD 3DNow! */
837 if (amd_feature2 != 0) {
838 printf("\n AMD Features2=0x%b", amd_feature2,
840 "\001LAHF" /* LAHF/SAHF in long mode */
841 "\002CMP" /* CMP legacy */
842 "\003SVM" /* Secure Virtual Mode */
843 "\004ExtAPIC" /* Extended APIC register */
844 "\005CR8" /* CR8 in legacy mode */
845 "\006ABM" /* LZCNT instruction */
846 "\007SSE4A" /* SSE4A */
847 "\010MAS" /* Misaligned SSE mode */
848 "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */
849 "\012OSVW" /* OS visible workaround */
850 "\013IBS" /* Instruction based sampling */
851 "\014XOP" /* XOP extended instructions */
852 "\015SKINIT" /* SKINIT/STGI */
853 "\016WDT" /* Watchdog timer */
855 "\020LWP" /* Lightweight Profiling */
856 "\021FMA4" /* 4-operand FMA instructions */
857 "\022TCE" /* Translation Cache Extension */
859 "\024NodeId" /* NodeId MSR support */
861 "\026TBM" /* Trailing Bit Manipulation */
862 "\027Topology" /* Topology Extensions */
863 "\030PCXC" /* Core perf count */
864 "\031PNXC" /* NB perf count */
866 "\033DBE" /* Data Breakpoint extension */
867 "\034PTSC" /* Performance TSC */
868 "\035PL2I" /* L2I perf count */
875 if (cpu_stdext_feature != 0) {
876 printf("\n Structured Extended Features=0x%b",
879 /* RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
882 /* Bit Manipulation Instructions */
884 /* Hardware Lock Elision */
886 /* Advanced Vector Instructions 2 */
888 /* Supervisor Mode Execution Prot. */
890 /* Bit Manipulation Instructions */
893 /* Invalidate Processor Context ID */
895 /* Restricted Transactional Memory */
897 /* Intel Memory Protection Extensions */
899 /* AVX512 Foundation */
905 /* Supervisor Mode Access Prevention */
916 if ((cpu_feature2 & CPUID2_XSAVE) != 0) {
917 cpuid_count(0xd, 0x1, regs);
919 printf("\n XSAVE Features=0x%b",
929 if (via_feature_rng != 0 || via_feature_xcrypt != 0)
930 print_via_padlock_info();
932 if (cpu_feature2 & CPUID2_VMX)
935 if ((cpu_feature & CPUID_HTT) &&
936 cpu_vendor_id == CPU_VENDOR_AMD)
937 cpu_feature &= ~CPUID_HTT;
940 * If this CPU supports P-state invariant TSC then
941 * mention the capability.
943 if (tsc_is_invariant) {
944 printf("\n TSC: P-state invariant");
946 printf(", performance statistics");
951 } else if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
952 printf(" DIR=0x%04x", cyrix_did);
953 printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12);
954 printf(" Revision=%u", (cyrix_did & 0x0f00) >> 8);
955 #ifndef CYRIX_CACHE_REALLY_WORKS
956 if (cpu == CPU_M1 && (cyrix_did & 0xff00) < 0x1700)
957 printf("\n CPU cache: write-through mode");
962 /* Avoid ugly blank lines: only print newline when we have to. */
963 if (*cpu_vendor || cpu_id)
969 if (cpu_vendor_id == CPU_VENDOR_AMD)
971 else if (cpu_vendor_id == CPU_VENDOR_INTEL)
974 else if (cpu_vendor_id == CPU_VENDOR_TRANSMETA)
975 print_transmeta_info();
980 panicifcpuunsupported(void)
985 #if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
986 #error This kernel is not configured for one of the supported CPUs
990 #else /* __amd64__ */
992 #error "You need to specify a cpu type"
996 * Now that we have told the user what they have,
997 * let them know if that machine type isn't configured.
1001 case CPUCLASS_286: /* a 286 should not make it this far, anyway */
1003 #if !defined(I486_CPU)
1006 #if !defined(I586_CPU)
1009 #if !defined(I686_CPU)
1012 #else /* __amd64__ */
1018 panic("CPU class not configured");
1025 static volatile u_int trap_by_rdmsr;
1028 * Special exception 6 handler.
1029 * The rdmsr instruction generates invalid opcodes fault on 486-class
1030 * Cyrix CPU. Stacked eip register points the rdmsr instruction in the
1031 * function identblue() when this handler is called. Stacked eip should
1034 inthand_t bluetrap6;
1035 #ifdef __GNUCLIKE_ASM
1040 .type " __XSTRING(CNAME(bluetrap6)) ",@function \n\
1041 " __XSTRING(CNAME(bluetrap6)) ": \n\
1043 movl $0xa8c1d," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1044 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1050 * Special exception 13 handler.
1051 * Accessing non-existent MSR generates general protection fault.
1053 inthand_t bluetrap13;
1054 #ifdef __GNUCLIKE_ASM
1059 .type " __XSTRING(CNAME(bluetrap13)) ",@function \n\
1060 " __XSTRING(CNAME(bluetrap13)) ": \n\
1062 movl $0xa89c4," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1063 popl %eax /* discard error code */ \n\
1064 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1070 * Distinguish IBM Blue Lightning CPU from Cyrix CPUs that does not
1071 * support cpuid instruction. This function should be called after
1072 * loading interrupt descriptor table register.
1074 * I don't like this method that handles fault, but I couldn't get
1075 * information for any other methods. Does blue giant know?
1084 * Cyrix 486-class CPU does not support rdmsr instruction.
1085 * The rdmsr instruction generates invalid opcode fault, and exception
1086 * will be trapped by bluetrap6() on Cyrix 486-class CPU. The
1087 * bluetrap6() set the magic number to trap_by_rdmsr.
1089 setidt(IDT_UD, bluetrap6, SDT_SYS386TGT, SEL_KPL,
1090 GSEL(GCODE_SEL, SEL_KPL));
1093 * Certain BIOS disables cpuid instruction of Cyrix 6x86MX CPU.
1094 * In this case, rdmsr generates general protection fault, and
1095 * exception will be trapped by bluetrap13().
1097 setidt(IDT_GP, bluetrap13, SDT_SYS386TGT, SEL_KPL,
1098 GSEL(GCODE_SEL, SEL_KPL));
1100 rdmsr(0x1002); /* Cyrix CPU generates fault. */
1102 if (trap_by_rdmsr == 0xa8c1d)
1103 return IDENTBLUE_CYRIX486;
1104 else if (trap_by_rdmsr == 0xa89c4)
1105 return IDENTBLUE_CYRIXM2;
1106 return IDENTBLUE_IBMCPU;
1111 * identifycyrix() set lower 16 bits of cyrix_did as follows:
1113 * F E D C B A 9 8 7 6 5 4 3 2 1 0
1114 * +-------+-------+---------------+
1115 * | SID | RID | Device ID |
1116 * | (DIR 1) | (DIR 0) |
1117 * +-------+-------+---------------+
1122 register_t saveintr;
1123 int ccr2_test = 0, dir_test = 0;
1126 saveintr = intr_disable();
1128 ccr2 = read_cyrix_reg(CCR2);
1129 write_cyrix_reg(CCR2, ccr2 ^ CCR2_LOCK_NW);
1130 read_cyrix_reg(CCR2);
1131 if (read_cyrix_reg(CCR2) != ccr2)
1133 write_cyrix_reg(CCR2, ccr2);
1135 ccr3 = read_cyrix_reg(CCR3);
1136 write_cyrix_reg(CCR3, ccr3 ^ CCR3_MAPEN3);
1137 read_cyrix_reg(CCR3);
1138 if (read_cyrix_reg(CCR3) != ccr3)
1139 dir_test = 1; /* CPU supports DIRs. */
1140 write_cyrix_reg(CCR3, ccr3);
1143 /* Device ID registers are available. */
1144 cyrix_did = read_cyrix_reg(DIR1) << 8;
1145 cyrix_did += read_cyrix_reg(DIR0);
1146 } else if (ccr2_test)
1147 cyrix_did = 0x0010; /* 486S A-step */
1149 cyrix_did = 0x00ff; /* Old 486SLC/DLC and TI486SXLC/SXL */
1151 intr_restore(saveintr);
1155 /* Update TSC freq with the value indicated by the caller. */
1157 tsc_freq_changed(void *arg __unused, const struct cf_level *level, int status)
1160 /* If there was an error during the transition, don't do anything. */
1164 /* Total setting for this level gives the new frequency in MHz. */
1165 hw_clockrate = level->total_set.freq;
1169 hook_tsc_freq(void *arg __unused)
1172 if (tsc_is_invariant)
1175 tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
1176 tsc_freq_changed, NULL, EVENTHANDLER_PRI_ANY);
1179 SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
1182 * Final stage of CPU identification.
1186 finishidentcpu(void)
1192 u_int regs[4], cpu_stdext_disable;
1200 ((u_int *)&cpu_vendor)[0] = regs[1];
1201 ((u_int *)&cpu_vendor)[1] = regs[3];
1202 ((u_int *)&cpu_vendor)[2] = regs[2];
1203 cpu_vendor[12] = '\0';
1207 cpu_procinfo = regs[1];
1208 cpu_feature = regs[3];
1209 cpu_feature2 = regs[2];
1212 cpu_vendor_id = find_cpu_vendor_id();
1215 * Clear "Limit CPUID Maxval" bit and get the largest standard CPUID
1216 * function number again if it is set from BIOS. It is necessary
1217 * for probing correct CPU topology later.
1218 * XXX This is only done on the BSP package.
1220 if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4 &&
1221 ((CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x3) ||
1222 (CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) >= 0xe))) {
1224 msr = rdmsr(MSR_IA32_MISC_ENABLE);
1225 if ((msr & 0x400000ULL) != 0) {
1226 wrmsr(MSR_IA32_MISC_ENABLE, msr & ~0x400000ULL);
1232 if (cpu_high >= 5 && (cpu_feature2 & CPUID2_MON) != 0) {
1234 cpu_mon_mwait_flags = regs[2];
1235 cpu_mon_min_size = regs[0] & CPUID5_MON_MIN_SIZE;
1236 cpu_mon_max_size = regs[1] & CPUID5_MON_MAX_SIZE;
1239 if (cpu_high >= 7) {
1240 cpuid_count(7, 0, regs);
1241 cpu_stdext_feature = regs[1];
1244 * Some hypervisors fail to filter out unsupported
1245 * extended features. For now, disable the
1246 * extensions, activation of which requires setting a
1247 * bit in CR4, and which VM monitors do not support.
1249 if (cpu_feature2 & CPUID2_HV) {
1250 cpu_stdext_disable = CPUID_STDEXT_FSGSBASE |
1253 cpu_stdext_disable = 0;
1254 TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable);
1255 cpu_stdext_feature &= ~cpu_stdext_disable;
1260 (cpu_vendor_id == CPU_VENDOR_INTEL ||
1261 cpu_vendor_id == CPU_VENDOR_AMD ||
1262 cpu_vendor_id == CPU_VENDOR_TRANSMETA ||
1263 cpu_vendor_id == CPU_VENDOR_CENTAUR ||
1264 cpu_vendor_id == CPU_VENDOR_NSC)) {
1265 do_cpuid(0x80000000, regs);
1266 if (regs[0] >= 0x80000000)
1267 cpu_exthigh = regs[0];
1270 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
1271 cpu_vendor_id == CPU_VENDOR_AMD ||
1272 cpu_vendor_id == CPU_VENDOR_CENTAUR) {
1273 do_cpuid(0x80000000, regs);
1274 cpu_exthigh = regs[0];
1277 if (cpu_exthigh >= 0x80000001) {
1278 do_cpuid(0x80000001, regs);
1279 amd_feature = regs[3] & ~(cpu_feature & 0x0183f3ff);
1280 amd_feature2 = regs[2];
1282 if (cpu_exthigh >= 0x80000007) {
1283 do_cpuid(0x80000007, regs);
1284 amd_pminfo = regs[3];
1286 if (cpu_exthigh >= 0x80000008) {
1287 do_cpuid(0x80000008, regs);
1288 cpu_procinfo2 = regs[2];
1292 if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
1293 if (cpu == CPU_486) {
1295 * These conditions are equivalent to:
1296 * - CPU does not support cpuid instruction.
1297 * - Cyrix/IBM CPU is detected.
1299 if (identblue() == IDENTBLUE_IBMCPU) {
1300 strcpy(cpu_vendor, "IBM");
1301 cpu_vendor_id = CPU_VENDOR_IBM;
1306 switch (cpu_id & 0xf00) {
1309 * Cyrix's datasheet does not describe DIRs.
1310 * Therefor, I assume it does not have them
1311 * and use the result of the cpuid instruction.
1312 * XXX they seem to have it for now at least. -Peter
1320 * This routine contains a trick.
1321 * Don't check (cpu_id & 0x00f0) == 0x50 to detect M2, now.
1323 switch (cyrix_did & 0x00f0) {
1332 if ((cyrix_did & 0x000f) < 8)
1345 /* M2 and later CPUs are treated as M2. */
1349 * enable cpuid instruction.
1351 ccr3 = read_cyrix_reg(CCR3);
1352 write_cyrix_reg(CCR3, CCR3_MAPEN0);
1353 write_cyrix_reg(CCR4, read_cyrix_reg(CCR4) | CCR4_CPUID);
1354 write_cyrix_reg(CCR3, ccr3);
1357 cpu_high = regs[0]; /* eax */
1359 cpu_id = regs[0]; /* eax */
1360 cpu_feature = regs[3]; /* edx */
1364 } else if (cpu == CPU_486 && *cpu_vendor == '\0') {
1366 * There are BlueLightning CPUs that do not change
1367 * undefined flags by dividing 5 by 2. In this case,
1368 * the CPU identification routine in locore.s leaves
1369 * cpu_vendor null string and puts CPU_486 into the
1372 if (identblue() == IDENTBLUE_IBMCPU) {
1373 strcpy(cpu_vendor, "IBM");
1374 cpu_vendor_id = CPU_VENDOR_IBM;
1381 cpu = CPU_CLAWHAMMER;
1386 find_cpu_vendor_id(void)
1390 for (i = 0; i < sizeof(cpu_vendors) / sizeof(cpu_vendors[0]); i++)
1391 if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0)
1392 return (cpu_vendors[i].vendor_id);
1397 print_AMD_assoc(int i)
1400 printf(", fully associative\n");
1402 printf(", %d-way associative\n", i);
1406 print_AMD_l2_assoc(int i)
1409 case 0: printf(", disabled/not present\n"); break;
1410 case 1: printf(", direct mapped\n"); break;
1411 case 2: printf(", 2-way associative\n"); break;
1412 case 4: printf(", 4-way associative\n"); break;
1413 case 6: printf(", 8-way associative\n"); break;
1414 case 8: printf(", 16-way associative\n"); break;
1415 case 15: printf(", fully associative\n"); break;
1416 default: printf(", reserved configuration\n"); break;
1421 print_AMD_info(void)
1428 if (cpu_exthigh >= 0x80000005) {
1429 do_cpuid(0x80000005, regs);
1430 printf("L1 2MB data TLB: %d entries", (regs[0] >> 16) & 0xff);
1431 print_AMD_assoc(regs[0] >> 24);
1433 printf("L1 2MB instruction TLB: %d entries", regs[0] & 0xff);
1434 print_AMD_assoc((regs[0] >> 8) & 0xff);
1436 printf("L1 4KB data TLB: %d entries", (regs[1] >> 16) & 0xff);
1437 print_AMD_assoc(regs[1] >> 24);
1439 printf("L1 4KB instruction TLB: %d entries", regs[1] & 0xff);
1440 print_AMD_assoc((regs[1] >> 8) & 0xff);
1442 printf("L1 data cache: %d kbytes", regs[2] >> 24);
1443 printf(", %d bytes/line", regs[2] & 0xff);
1444 printf(", %d lines/tag", (regs[2] >> 8) & 0xff);
1445 print_AMD_assoc((regs[2] >> 16) & 0xff);
1447 printf("L1 instruction cache: %d kbytes", regs[3] >> 24);
1448 printf(", %d bytes/line", regs[3] & 0xff);
1449 printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
1450 print_AMD_assoc((regs[3] >> 16) & 0xff);
1453 if (cpu_exthigh >= 0x80000006) {
1454 do_cpuid(0x80000006, regs);
1455 if ((regs[0] >> 16) != 0) {
1456 printf("L2 2MB data TLB: %d entries",
1457 (regs[0] >> 16) & 0xfff);
1458 print_AMD_l2_assoc(regs[0] >> 28);
1459 printf("L2 2MB instruction TLB: %d entries",
1461 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1463 printf("L2 2MB unified TLB: %d entries",
1465 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1467 if ((regs[1] >> 16) != 0) {
1468 printf("L2 4KB data TLB: %d entries",
1469 (regs[1] >> 16) & 0xfff);
1470 print_AMD_l2_assoc(regs[1] >> 28);
1472 printf("L2 4KB instruction TLB: %d entries",
1473 (regs[1] >> 16) & 0xfff);
1474 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1476 printf("L2 4KB unified TLB: %d entries",
1477 (regs[1] >> 16) & 0xfff);
1478 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1480 printf("L2 unified cache: %d kbytes", regs[2] >> 16);
1481 printf(", %d bytes/line", regs[2] & 0xff);
1482 printf(", %d lines/tag", (regs[2] >> 8) & 0x0f);
1483 print_AMD_l2_assoc((regs[2] >> 12) & 0x0f);
1487 if (((cpu_id & 0xf00) == 0x500)
1488 && (((cpu_id & 0x0f0) > 0x80)
1489 || (((cpu_id & 0x0f0) == 0x80)
1490 && (cpu_id & 0x00f) > 0x07))) {
1491 /* K6-2(new core [Stepping 8-F]), K6-III or later */
1492 amd_whcr = rdmsr(0xc0000082);
1493 if (!(amd_whcr & (0x3ff << 22))) {
1494 printf("Write Allocate Disable\n");
1496 printf("Write Allocate Enable Limit: %dM bytes\n",
1497 (u_int32_t)((amd_whcr & (0x3ff << 22)) >> 22) * 4);
1498 printf("Write Allocate 15-16M bytes: %s\n",
1499 (amd_whcr & (1 << 16)) ? "Enable" : "Disable");
1501 } else if (((cpu_id & 0xf00) == 0x500)
1502 && ((cpu_id & 0x0f0) > 0x50)) {
1503 /* K6, K6-2(old core) */
1504 amd_whcr = rdmsr(0xc0000082);
1505 if (!(amd_whcr & (0x7f << 1))) {
1506 printf("Write Allocate Disable\n");
1508 printf("Write Allocate Enable Limit: %dM bytes\n",
1509 (u_int32_t)((amd_whcr & (0x7f << 1)) >> 1) * 4);
1510 printf("Write Allocate 15-16M bytes: %s\n",
1511 (amd_whcr & 0x0001) ? "Enable" : "Disable");
1512 printf("Hardware Write Allocate Control: %s\n",
1513 (amd_whcr & 0x0100) ? "Enable" : "Disable");
1518 * Opteron Rev E shows a bug as in very rare occasions a read memory
1519 * barrier is not performed as expected if it is followed by a
1520 * non-atomic read-modify-write instruction.
1521 * As long as that bug pops up very rarely (intensive machine usage
1522 * on other operating systems generally generates one unexplainable
1523 * crash any 2 months) and as long as a model specific fix would be
1524 * impratical at this stage, print out a warning string if the broken
1525 * model and family are identified.
1527 if (CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x20 &&
1528 CPUID_TO_MODEL(cpu_id) <= 0x3f)
1529 printf("WARNING: This architecture revision has known SMP "
1530 "hardware bugs which may cause random instability\n");
1534 print_INTEL_info(void)
1537 u_int rounds, regnum;
1538 u_int nwaycode, nway;
1540 if (cpu_high >= 2) {
1543 do_cpuid(0x2, regs);
1544 if (rounds == 0 && (rounds = (regs[0] & 0xff)) == 0)
1545 break; /* we have a buggy CPU */
1547 for (regnum = 0; regnum <= 3; ++regnum) {
1548 if (regs[regnum] & (1<<31))
1551 print_INTEL_TLB(regs[regnum] & 0xff);
1552 print_INTEL_TLB((regs[regnum] >> 8) & 0xff);
1553 print_INTEL_TLB((regs[regnum] >> 16) & 0xff);
1554 print_INTEL_TLB((regs[regnum] >> 24) & 0xff);
1556 } while (--rounds > 0);
1559 if (cpu_exthigh >= 0x80000006) {
1560 do_cpuid(0x80000006, regs);
1561 nwaycode = (regs[2] >> 12) & 0x0f;
1562 if (nwaycode >= 0x02 && nwaycode <= 0x08)
1563 nway = 1 << (nwaycode / 2);
1566 printf("L2 cache: %u kbytes, %u-way associative, %u bytes/line\n",
1567 (regs[2] >> 16) & 0xffff, nway, regs[2] & 0xff);
1572 print_INTEL_TLB(u_int data)
1580 printf("Instruction TLB: 4 KB pages, 4-way set associative, 32 entries\n");
1583 printf("Instruction TLB: 4 MB pages, fully associative, 2 entries\n");
1586 printf("Data TLB: 4 KB pages, 4-way set associative, 64 entries\n");
1589 printf("Data TLB: 4 MB Pages, 4-way set associative, 8 entries\n");
1592 printf("1st-level instruction cache: 8 KB, 4-way set associative, 32 byte line size\n");
1595 printf("1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size\n");
1598 printf("1st-level data cache: 8 KB, 2-way set associative, 32 byte line size\n");
1601 printf("1st-level data cache: 16 KB, 4-way set associative, 32 byte line size\n");
1604 printf("3rd-level cache: 512 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1607 printf("3rd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1610 printf("3rd-level cache: 2 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1613 printf("3rd-level cache: 4 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1616 printf("1st-level data cache: 32 KB, 8-way set associative, 64 byte line size\n");
1619 printf("1st-level instruction cache: 32 KB, 8-way set associative, 64 byte line size\n");
1622 printf("2nd-level cache: 128 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1625 printf("2nd-level cache: 128 KB, 2-way set associative, sectored cache, 64 byte line size\n");
1628 printf("2nd-level cache: 256 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1631 printf("2nd-level cache: 128 KB, 4-way set associative, 32 byte line size\n");
1634 printf("2nd-level cache: 256 KB, 4-way set associative, 32 byte line size\n");
1637 printf("2nd-level cache: 512 KB, 4-way set associative, 32 byte line size\n");
1640 printf("2nd-level cache: 1 MB, 4-way set associative, 32 byte line size\n");
1643 printf("2nd-level cache: 2 MB, 4-way set associative, 32 byte line size\n");
1646 printf("3rd-level cache: 4 MB, 4-way set associative, 64 byte line size\n");
1649 printf("3rd-level cache: 8 MB, 8-way set associative, 64 byte line size\n");
1652 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 64 entries\n");
1655 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 128 entries\n");
1658 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 256 entries\n");
1661 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 64 entries\n");
1664 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 128 entries\n");
1667 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 256 entries\n");
1670 printf("1st-level data cache: 16 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1673 printf("1st-level data cache: 8 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1676 printf("1st-level data cache: 16 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1679 printf("1st-level data cache: 32 KB, 4 way set associative, sectored cache, 64 byte line size\n");
1682 printf("Trace cache: 12K-uops, 8-way set associative\n");
1685 printf("Trace cache: 16K-uops, 8-way set associative\n");
1688 printf("Trace cache: 32K-uops, 8-way set associative\n");
1691 printf("2nd-level cache: 1 MB, 4-way set associative, 64-byte line size\n");
1694 printf("2nd-level cache: 128 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1697 printf("2nd-level cache: 256 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1700 printf("2nd-level cache: 512 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1703 printf("2nd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1706 printf("2nd-level cache: 2-MB, 8-way set associative, 64-byte line size\n");
1709 printf("2nd-level cache: 512-KB, 2-way set associative, 64-byte line size\n");
1712 printf("2nd-level cache: 256 KB, 8-way set associative, 32 byte line size\n");
1715 printf("2nd-level cache: 512 KB, 8-way set associative, 32 byte line size\n");
1718 printf("2nd-level cache: 1 MB, 8-way set associative, 32 byte line size\n");
1721 printf("2nd-level cache: 2 MB, 8-way set associative, 32 byte line size\n");
1724 printf("2nd-level cache: 512 KB, 4-way set associative, 64 byte line size\n");
1727 printf("2nd-level cache: 1 MB, 8-way set associative, 64 byte line size\n");
1730 printf("Instruction TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
1733 printf("Data TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
1740 print_transmeta_info(void)
1742 u_int regs[4], nreg = 0;
1744 do_cpuid(0x80860000, regs);
1746 if (nreg >= 0x80860001) {
1747 do_cpuid(0x80860001, regs);
1748 printf(" Processor revision %u.%u.%u.%u\n",
1749 (regs[1] >> 24) & 0xff,
1750 (regs[1] >> 16) & 0xff,
1751 (regs[1] >> 8) & 0xff,
1754 if (nreg >= 0x80860002) {
1755 do_cpuid(0x80860002, regs);
1756 printf(" Code Morphing Software revision %u.%u.%u-%u-%u\n",
1757 (regs[1] >> 24) & 0xff,
1758 (regs[1] >> 16) & 0xff,
1759 (regs[1] >> 8) & 0xff,
1763 if (nreg >= 0x80860006) {
1765 do_cpuid(0x80860003, (u_int*) &info[0]);
1766 do_cpuid(0x80860004, (u_int*) &info[16]);
1767 do_cpuid(0x80860005, (u_int*) &info[32]);
1768 do_cpuid(0x80860006, (u_int*) &info[48]);
1770 printf(" %s\n", info);
1776 print_via_padlock_info(void)
1780 do_cpuid(0xc0000001, regs);
1781 printf("\n VIA Padlock Features=0x%b", regs[3],
1785 "\011AES-CTR" /* ACE2 */
1786 "\013SHA1,SHA256" /* PHE */
1792 vmx_settable(uint64_t basic, int msr, int true_msr)
1796 if (basic & (1ULL << 55))
1797 val = rdmsr(true_msr);
1801 /* Just report the controls that can be set to 1. */
1806 print_vmx_info(void)
1808 uint64_t basic, msr;
1809 uint32_t entry, exit, mask, pin, proc, proc2;
1812 printf("\n VT-x: ");
1813 msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
1814 if (!(msr & IA32_FEATURE_CONTROL_VMX_EN))
1815 printf("(disabled in BIOS) ");
1816 basic = rdmsr(MSR_VMX_BASIC);
1817 pin = vmx_settable(basic, MSR_VMX_PINBASED_CTLS,
1818 MSR_VMX_TRUE_PINBASED_CTLS);
1819 proc = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS,
1820 MSR_VMX_TRUE_PROCBASED_CTLS);
1821 if (proc & PROCBASED_SECONDARY_CONTROLS)
1822 proc2 = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS2,
1823 MSR_VMX_PROCBASED_CTLS2);
1826 exit = vmx_settable(basic, MSR_VMX_EXIT_CTLS, MSR_VMX_TRUE_EXIT_CTLS);
1827 entry = vmx_settable(basic, MSR_VMX_ENTRY_CTLS, MSR_VMX_TRUE_ENTRY_CTLS);
1831 if (exit & VM_EXIT_SAVE_PAT && exit & VM_EXIT_LOAD_PAT &&
1832 entry & VM_ENTRY_LOAD_PAT) {
1833 printf("%sPAT", comma ? "," : "");
1836 if (proc & PROCBASED_HLT_EXITING) {
1837 printf("%sHLT", comma ? "," : "");
1840 if (proc & PROCBASED_MTF) {
1841 printf("%sMTF", comma ? "," : "");
1844 if (proc & PROCBASED_PAUSE_EXITING) {
1845 printf("%sPAUSE", comma ? "," : "");
1848 if (proc2 & PROCBASED2_ENABLE_EPT) {
1849 printf("%sEPT", comma ? "," : "");
1852 if (proc2 & PROCBASED2_UNRESTRICTED_GUEST) {
1853 printf("%sUG", comma ? "," : "");
1856 if (proc2 & PROCBASED2_ENABLE_VPID) {
1857 printf("%sVPID", comma ? "," : "");
1860 if (proc & PROCBASED_USE_TPR_SHADOW &&
1861 proc2 & PROCBASED2_VIRTUALIZE_APIC_ACCESSES &&
1862 proc2 & PROCBASED2_VIRTUALIZE_X2APIC_MODE &&
1863 proc2 & PROCBASED2_APIC_REGISTER_VIRTUALIZATION &&
1864 proc2 & PROCBASED2_VIRTUAL_INTERRUPT_DELIVERY) {
1865 printf("%sVID", comma ? "," : "");
1867 if (pin & PINBASED_POSTED_INTERRUPT)
1868 printf(",PostIntr");
1874 printf("Basic Features=0x%b", mask,
1876 "\02132PA" /* 32-bit physical addresses */
1877 "\022SMM" /* SMM dual-monitor */
1878 "\027INS/OUTS" /* VM-exit info for INS and OUTS */
1879 "\030TRUE" /* TRUE_CTLS MSRs */
1881 printf("\n Pin-Based Controls=0x%b", pin,
1883 "\001ExtINT" /* External-interrupt exiting */
1884 "\004NMI" /* NMI exiting */
1885 "\006VNMI" /* Virtual NMIs */
1886 "\007PreTmr" /* Activate VMX-preemption timer */
1887 "\010PostIntr" /* Process posted interrupts */
1889 printf("\n Primary Processor Controls=0x%b", proc,
1891 "\003INTWIN" /* Interrupt-window exiting */
1892 "\004TSCOff" /* Use TSC offsetting */
1893 "\010HLT" /* HLT exiting */
1894 "\012INVLPG" /* INVLPG exiting */
1895 "\013MWAIT" /* MWAIT exiting */
1896 "\014RDPMC" /* RDPMC exiting */
1897 "\015RDTSC" /* RDTSC exiting */
1898 "\020CR3-LD" /* CR3-load exiting */
1899 "\021CR3-ST" /* CR3-store exiting */
1900 "\024CR8-LD" /* CR8-load exiting */
1901 "\025CR8-ST" /* CR8-store exiting */
1902 "\026TPR" /* Use TPR shadow */
1903 "\027NMIWIN" /* NMI-window exiting */
1904 "\030MOV-DR" /* MOV-DR exiting */
1905 "\031IO" /* Unconditional I/O exiting */
1906 "\032IOmap" /* Use I/O bitmaps */
1907 "\034MTF" /* Monitor trap flag */
1908 "\035MSRmap" /* Use MSR bitmaps */
1909 "\036MONITOR" /* MONITOR exiting */
1910 "\037PAUSE" /* PAUSE exiting */
1912 if (proc & PROCBASED_SECONDARY_CONTROLS)
1913 printf("\n Secondary Processor Controls=0x%b", proc2,
1915 "\001APIC" /* Virtualize APIC accesses */
1916 "\002EPT" /* Enable EPT */
1917 "\003DT" /* Descriptor-table exiting */
1918 "\004RDTSCP" /* Enable RDTSCP */
1919 "\005x2APIC" /* Virtualize x2APIC mode */
1920 "\006VPID" /* Enable VPID */
1921 "\007WBINVD" /* WBINVD exiting */
1922 "\010UG" /* Unrestricted guest */
1923 "\011APIC-reg" /* APIC-register virtualization */
1924 "\012VID" /* Virtual-interrupt delivery */
1925 "\013PAUSE-loop" /* PAUSE-loop exiting */
1926 "\014RDRAND" /* RDRAND exiting */
1927 "\015INVPCID" /* Enable INVPCID */
1928 "\016VMFUNC" /* Enable VM functions */
1929 "\017VMCS" /* VMCS shadowing */
1930 "\020EPT#VE" /* EPT-violation #VE */
1931 "\021XSAVES" /* Enable XSAVES/XRSTORS */
1933 printf("\n Exit Controls=0x%b", mask,
1935 "\003DR" /* Save debug controls */
1936 /* Ignore Host address-space size */
1937 "\015PERF" /* Load MSR_PERF_GLOBAL_CTRL */
1938 "\020AckInt" /* Acknowledge interrupt on exit */
1939 "\023PAT-SV" /* Save MSR_PAT */
1940 "\024PAT-LD" /* Load MSR_PAT */
1941 "\025EFER-SV" /* Save MSR_EFER */
1942 "\026EFER-LD" /* Load MSR_EFER */
1943 "\027PTMR-SV" /* Save VMX-preemption timer value */
1945 printf("\n Entry Controls=0x%b", mask,
1947 "\003DR" /* Save debug controls */
1948 /* Ignore IA-32e mode guest */
1949 /* Ignore Entry to SMM */
1950 /* Ignore Deactivate dual-monitor treatment */
1951 "\016PERF" /* Load MSR_PERF_GLOBAL_CTRL */
1952 "\017PAT" /* Load MSR_PAT */
1953 "\020EFER" /* Load MSR_EFER */
1955 if (proc & PROCBASED_SECONDARY_CONTROLS &&
1956 (proc2 & (PROCBASED2_ENABLE_EPT | PROCBASED2_ENABLE_VPID)) != 0) {
1957 msr = rdmsr(MSR_VMX_EPT_VPID_CAP);
1959 printf("\n EPT Features=0x%b", mask,
1961 "\001XO" /* Execute-only translations */
1962 "\007PW4" /* Page-walk length of 4 */
1963 "\011UC" /* EPT paging-structure mem can be UC */
1964 "\017WB" /* EPT paging-structure mem can be WB */
1965 "\0212M" /* EPT PDE can map a 2-Mbyte page */
1966 "\0221G" /* EPT PDPTE can map a 1-Gbyte page */
1967 "\025INVEPT" /* INVEPT is supported */
1968 "\026AD" /* Accessed and dirty flags for EPT */
1969 "\032single" /* INVEPT single-context type */
1970 "\033all" /* INVEPT all-context type */
1973 printf("\n VPID Features=0x%b", mask,
1975 "\001INVVPID" /* INVVPID is supported */
1976 "\011individual" /* INVVPID individual-address type */
1977 "\012single" /* INVVPID single-context type */
1978 "\013all" /* INVVPID all-context type */
1979 /* INVVPID single-context-retaining-globals type */
1980 "\014single-globals"