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 (via_feature_rng != 0 || via_feature_xcrypt != 0)
917 print_via_padlock_info();
919 if (cpu_feature2 & CPUID2_VMX)
922 if ((cpu_feature & CPUID_HTT) &&
923 cpu_vendor_id == CPU_VENDOR_AMD)
924 cpu_feature &= ~CPUID_HTT;
927 * If this CPU supports P-state invariant TSC then
928 * mention the capability.
930 if (tsc_is_invariant) {
931 printf("\n TSC: P-state invariant");
933 printf(", performance statistics");
938 } else if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
939 printf(" DIR=0x%04x", cyrix_did);
940 printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12);
941 printf(" Revision=%u", (cyrix_did & 0x0f00) >> 8);
942 #ifndef CYRIX_CACHE_REALLY_WORKS
943 if (cpu == CPU_M1 && (cyrix_did & 0xff00) < 0x1700)
944 printf("\n CPU cache: write-through mode");
949 /* Avoid ugly blank lines: only print newline when we have to. */
950 if (*cpu_vendor || cpu_id)
956 if (cpu_vendor_id == CPU_VENDOR_AMD)
958 else if (cpu_vendor_id == CPU_VENDOR_INTEL)
961 else if (cpu_vendor_id == CPU_VENDOR_TRANSMETA)
962 print_transmeta_info();
967 panicifcpuunsupported(void)
972 #if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
973 #error This kernel is not configured for one of the supported CPUs
977 #else /* __amd64__ */
979 #error "You need to specify a cpu type"
983 * Now that we have told the user what they have,
984 * let them know if that machine type isn't configured.
988 case CPUCLASS_286: /* a 286 should not make it this far, anyway */
990 #if !defined(I486_CPU)
993 #if !defined(I586_CPU)
996 #if !defined(I686_CPU)
999 #else /* __amd64__ */
1005 panic("CPU class not configured");
1012 static volatile u_int trap_by_rdmsr;
1015 * Special exception 6 handler.
1016 * The rdmsr instruction generates invalid opcodes fault on 486-class
1017 * Cyrix CPU. Stacked eip register points the rdmsr instruction in the
1018 * function identblue() when this handler is called. Stacked eip should
1021 inthand_t bluetrap6;
1022 #ifdef __GNUCLIKE_ASM
1027 .type " __XSTRING(CNAME(bluetrap6)) ",@function \n\
1028 " __XSTRING(CNAME(bluetrap6)) ": \n\
1030 movl $0xa8c1d," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1031 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1037 * Special exception 13 handler.
1038 * Accessing non-existent MSR generates general protection fault.
1040 inthand_t bluetrap13;
1041 #ifdef __GNUCLIKE_ASM
1046 .type " __XSTRING(CNAME(bluetrap13)) ",@function \n\
1047 " __XSTRING(CNAME(bluetrap13)) ": \n\
1049 movl $0xa89c4," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1050 popl %eax /* discard error code */ \n\
1051 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1057 * Distinguish IBM Blue Lightning CPU from Cyrix CPUs that does not
1058 * support cpuid instruction. This function should be called after
1059 * loading interrupt descriptor table register.
1061 * I don't like this method that handles fault, but I couldn't get
1062 * information for any other methods. Does blue giant know?
1071 * Cyrix 486-class CPU does not support rdmsr instruction.
1072 * The rdmsr instruction generates invalid opcode fault, and exception
1073 * will be trapped by bluetrap6() on Cyrix 486-class CPU. The
1074 * bluetrap6() set the magic number to trap_by_rdmsr.
1076 setidt(IDT_UD, bluetrap6, SDT_SYS386TGT, SEL_KPL,
1077 GSEL(GCODE_SEL, SEL_KPL));
1080 * Certain BIOS disables cpuid instruction of Cyrix 6x86MX CPU.
1081 * In this case, rdmsr generates general protection fault, and
1082 * exception will be trapped by bluetrap13().
1084 setidt(IDT_GP, bluetrap13, SDT_SYS386TGT, SEL_KPL,
1085 GSEL(GCODE_SEL, SEL_KPL));
1087 rdmsr(0x1002); /* Cyrix CPU generates fault. */
1089 if (trap_by_rdmsr == 0xa8c1d)
1090 return IDENTBLUE_CYRIX486;
1091 else if (trap_by_rdmsr == 0xa89c4)
1092 return IDENTBLUE_CYRIXM2;
1093 return IDENTBLUE_IBMCPU;
1098 * identifycyrix() set lower 16 bits of cyrix_did as follows:
1100 * F E D C B A 9 8 7 6 5 4 3 2 1 0
1101 * +-------+-------+---------------+
1102 * | SID | RID | Device ID |
1103 * | (DIR 1) | (DIR 0) |
1104 * +-------+-------+---------------+
1109 register_t saveintr;
1110 int ccr2_test = 0, dir_test = 0;
1113 saveintr = intr_disable();
1115 ccr2 = read_cyrix_reg(CCR2);
1116 write_cyrix_reg(CCR2, ccr2 ^ CCR2_LOCK_NW);
1117 read_cyrix_reg(CCR2);
1118 if (read_cyrix_reg(CCR2) != ccr2)
1120 write_cyrix_reg(CCR2, ccr2);
1122 ccr3 = read_cyrix_reg(CCR3);
1123 write_cyrix_reg(CCR3, ccr3 ^ CCR3_MAPEN3);
1124 read_cyrix_reg(CCR3);
1125 if (read_cyrix_reg(CCR3) != ccr3)
1126 dir_test = 1; /* CPU supports DIRs. */
1127 write_cyrix_reg(CCR3, ccr3);
1130 /* Device ID registers are available. */
1131 cyrix_did = read_cyrix_reg(DIR1) << 8;
1132 cyrix_did += read_cyrix_reg(DIR0);
1133 } else if (ccr2_test)
1134 cyrix_did = 0x0010; /* 486S A-step */
1136 cyrix_did = 0x00ff; /* Old 486SLC/DLC and TI486SXLC/SXL */
1138 intr_restore(saveintr);
1142 /* Update TSC freq with the value indicated by the caller. */
1144 tsc_freq_changed(void *arg __unused, const struct cf_level *level, int status)
1147 /* If there was an error during the transition, don't do anything. */
1151 /* Total setting for this level gives the new frequency in MHz. */
1152 hw_clockrate = level->total_set.freq;
1156 hook_tsc_freq(void *arg __unused)
1159 if (tsc_is_invariant)
1162 tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
1163 tsc_freq_changed, NULL, EVENTHANDLER_PRI_ANY);
1166 SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
1169 * Final stage of CPU identification.
1173 finishidentcpu(void)
1179 u_int regs[4], cpu_stdext_disable;
1187 ((u_int *)&cpu_vendor)[0] = regs[1];
1188 ((u_int *)&cpu_vendor)[1] = regs[3];
1189 ((u_int *)&cpu_vendor)[2] = regs[2];
1190 cpu_vendor[12] = '\0';
1194 cpu_procinfo = regs[1];
1195 cpu_feature = regs[3];
1196 cpu_feature2 = regs[2];
1199 cpu_vendor_id = find_cpu_vendor_id();
1202 * Clear "Limit CPUID Maxval" bit and get the largest standard CPUID
1203 * function number again if it is set from BIOS. It is necessary
1204 * for probing correct CPU topology later.
1205 * XXX This is only done on the BSP package.
1207 if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4 &&
1208 ((CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x3) ||
1209 (CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) >= 0xe))) {
1211 msr = rdmsr(MSR_IA32_MISC_ENABLE);
1212 if ((msr & 0x400000ULL) != 0) {
1213 wrmsr(MSR_IA32_MISC_ENABLE, msr & ~0x400000ULL);
1219 if (cpu_high >= 5 && (cpu_feature2 & CPUID2_MON) != 0) {
1221 cpu_mon_mwait_flags = regs[2];
1222 cpu_mon_min_size = regs[0] & CPUID5_MON_MIN_SIZE;
1223 cpu_mon_max_size = regs[1] & CPUID5_MON_MAX_SIZE;
1226 if (cpu_high >= 7) {
1227 cpuid_count(7, 0, regs);
1228 cpu_stdext_feature = regs[1];
1231 * Some hypervisors fail to filter out unsupported
1232 * extended features. For now, disable the
1233 * extensions, activation of which requires setting a
1234 * bit in CR4, and which VM monitors do not support.
1236 if (cpu_feature2 & CPUID2_HV) {
1237 cpu_stdext_disable = CPUID_STDEXT_FSGSBASE |
1240 cpu_stdext_disable = 0;
1241 TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable);
1242 cpu_stdext_feature &= ~cpu_stdext_disable;
1247 (cpu_vendor_id == CPU_VENDOR_INTEL ||
1248 cpu_vendor_id == CPU_VENDOR_AMD ||
1249 cpu_vendor_id == CPU_VENDOR_TRANSMETA ||
1250 cpu_vendor_id == CPU_VENDOR_CENTAUR ||
1251 cpu_vendor_id == CPU_VENDOR_NSC)) {
1252 do_cpuid(0x80000000, regs);
1253 if (regs[0] >= 0x80000000)
1254 cpu_exthigh = regs[0];
1257 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
1258 cpu_vendor_id == CPU_VENDOR_AMD ||
1259 cpu_vendor_id == CPU_VENDOR_CENTAUR) {
1260 do_cpuid(0x80000000, regs);
1261 cpu_exthigh = regs[0];
1264 if (cpu_exthigh >= 0x80000001) {
1265 do_cpuid(0x80000001, regs);
1266 amd_feature = regs[3] & ~(cpu_feature & 0x0183f3ff);
1267 amd_feature2 = regs[2];
1269 if (cpu_exthigh >= 0x80000007) {
1270 do_cpuid(0x80000007, regs);
1271 amd_pminfo = regs[3];
1273 if (cpu_exthigh >= 0x80000008) {
1274 do_cpuid(0x80000008, regs);
1275 cpu_procinfo2 = regs[2];
1279 if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
1280 if (cpu == CPU_486) {
1282 * These conditions are equivalent to:
1283 * - CPU does not support cpuid instruction.
1284 * - Cyrix/IBM CPU is detected.
1286 if (identblue() == IDENTBLUE_IBMCPU) {
1287 strcpy(cpu_vendor, "IBM");
1288 cpu_vendor_id = CPU_VENDOR_IBM;
1293 switch (cpu_id & 0xf00) {
1296 * Cyrix's datasheet does not describe DIRs.
1297 * Therefor, I assume it does not have them
1298 * and use the result of the cpuid instruction.
1299 * XXX they seem to have it for now at least. -Peter
1307 * This routine contains a trick.
1308 * Don't check (cpu_id & 0x00f0) == 0x50 to detect M2, now.
1310 switch (cyrix_did & 0x00f0) {
1319 if ((cyrix_did & 0x000f) < 8)
1332 /* M2 and later CPUs are treated as M2. */
1336 * enable cpuid instruction.
1338 ccr3 = read_cyrix_reg(CCR3);
1339 write_cyrix_reg(CCR3, CCR3_MAPEN0);
1340 write_cyrix_reg(CCR4, read_cyrix_reg(CCR4) | CCR4_CPUID);
1341 write_cyrix_reg(CCR3, ccr3);
1344 cpu_high = regs[0]; /* eax */
1346 cpu_id = regs[0]; /* eax */
1347 cpu_feature = regs[3]; /* edx */
1351 } else if (cpu == CPU_486 && *cpu_vendor == '\0') {
1353 * There are BlueLightning CPUs that do not change
1354 * undefined flags by dividing 5 by 2. In this case,
1355 * the CPU identification routine in locore.s leaves
1356 * cpu_vendor null string and puts CPU_486 into the
1359 if (identblue() == IDENTBLUE_IBMCPU) {
1360 strcpy(cpu_vendor, "IBM");
1361 cpu_vendor_id = CPU_VENDOR_IBM;
1368 cpu = CPU_CLAWHAMMER;
1373 find_cpu_vendor_id(void)
1377 for (i = 0; i < sizeof(cpu_vendors) / sizeof(cpu_vendors[0]); i++)
1378 if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0)
1379 return (cpu_vendors[i].vendor_id);
1384 print_AMD_assoc(int i)
1387 printf(", fully associative\n");
1389 printf(", %d-way associative\n", i);
1393 print_AMD_l2_assoc(int i)
1396 case 0: printf(", disabled/not present\n"); break;
1397 case 1: printf(", direct mapped\n"); break;
1398 case 2: printf(", 2-way associative\n"); break;
1399 case 4: printf(", 4-way associative\n"); break;
1400 case 6: printf(", 8-way associative\n"); break;
1401 case 8: printf(", 16-way associative\n"); break;
1402 case 15: printf(", fully associative\n"); break;
1403 default: printf(", reserved configuration\n"); break;
1408 print_AMD_info(void)
1415 if (cpu_exthigh >= 0x80000005) {
1416 do_cpuid(0x80000005, regs);
1417 printf("L1 2MB data TLB: %d entries", (regs[0] >> 16) & 0xff);
1418 print_AMD_assoc(regs[0] >> 24);
1420 printf("L1 2MB instruction TLB: %d entries", regs[0] & 0xff);
1421 print_AMD_assoc((regs[0] >> 8) & 0xff);
1423 printf("L1 4KB data TLB: %d entries", (regs[1] >> 16) & 0xff);
1424 print_AMD_assoc(regs[1] >> 24);
1426 printf("L1 4KB instruction TLB: %d entries", regs[1] & 0xff);
1427 print_AMD_assoc((regs[1] >> 8) & 0xff);
1429 printf("L1 data cache: %d kbytes", regs[2] >> 24);
1430 printf(", %d bytes/line", regs[2] & 0xff);
1431 printf(", %d lines/tag", (regs[2] >> 8) & 0xff);
1432 print_AMD_assoc((regs[2] >> 16) & 0xff);
1434 printf("L1 instruction cache: %d kbytes", regs[3] >> 24);
1435 printf(", %d bytes/line", regs[3] & 0xff);
1436 printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
1437 print_AMD_assoc((regs[3] >> 16) & 0xff);
1440 if (cpu_exthigh >= 0x80000006) {
1441 do_cpuid(0x80000006, regs);
1442 if ((regs[0] >> 16) != 0) {
1443 printf("L2 2MB data TLB: %d entries",
1444 (regs[0] >> 16) & 0xfff);
1445 print_AMD_l2_assoc(regs[0] >> 28);
1446 printf("L2 2MB instruction TLB: %d entries",
1448 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1450 printf("L2 2MB unified TLB: %d entries",
1452 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1454 if ((regs[1] >> 16) != 0) {
1455 printf("L2 4KB data TLB: %d entries",
1456 (regs[1] >> 16) & 0xfff);
1457 print_AMD_l2_assoc(regs[1] >> 28);
1459 printf("L2 4KB instruction TLB: %d entries",
1460 (regs[1] >> 16) & 0xfff);
1461 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1463 printf("L2 4KB unified TLB: %d entries",
1464 (regs[1] >> 16) & 0xfff);
1465 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1467 printf("L2 unified cache: %d kbytes", regs[2] >> 16);
1468 printf(", %d bytes/line", regs[2] & 0xff);
1469 printf(", %d lines/tag", (regs[2] >> 8) & 0x0f);
1470 print_AMD_l2_assoc((regs[2] >> 12) & 0x0f);
1474 if (((cpu_id & 0xf00) == 0x500)
1475 && (((cpu_id & 0x0f0) > 0x80)
1476 || (((cpu_id & 0x0f0) == 0x80)
1477 && (cpu_id & 0x00f) > 0x07))) {
1478 /* K6-2(new core [Stepping 8-F]), K6-III or later */
1479 amd_whcr = rdmsr(0xc0000082);
1480 if (!(amd_whcr & (0x3ff << 22))) {
1481 printf("Write Allocate Disable\n");
1483 printf("Write Allocate Enable Limit: %dM bytes\n",
1484 (u_int32_t)((amd_whcr & (0x3ff << 22)) >> 22) * 4);
1485 printf("Write Allocate 15-16M bytes: %s\n",
1486 (amd_whcr & (1 << 16)) ? "Enable" : "Disable");
1488 } else if (((cpu_id & 0xf00) == 0x500)
1489 && ((cpu_id & 0x0f0) > 0x50)) {
1490 /* K6, K6-2(old core) */
1491 amd_whcr = rdmsr(0xc0000082);
1492 if (!(amd_whcr & (0x7f << 1))) {
1493 printf("Write Allocate Disable\n");
1495 printf("Write Allocate Enable Limit: %dM bytes\n",
1496 (u_int32_t)((amd_whcr & (0x7f << 1)) >> 1) * 4);
1497 printf("Write Allocate 15-16M bytes: %s\n",
1498 (amd_whcr & 0x0001) ? "Enable" : "Disable");
1499 printf("Hardware Write Allocate Control: %s\n",
1500 (amd_whcr & 0x0100) ? "Enable" : "Disable");
1505 * Opteron Rev E shows a bug as in very rare occasions a read memory
1506 * barrier is not performed as expected if it is followed by a
1507 * non-atomic read-modify-write instruction.
1508 * As long as that bug pops up very rarely (intensive machine usage
1509 * on other operating systems generally generates one unexplainable
1510 * crash any 2 months) and as long as a model specific fix would be
1511 * impratical at this stage, print out a warning string if the broken
1512 * model and family are identified.
1514 if (CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x20 &&
1515 CPUID_TO_MODEL(cpu_id) <= 0x3f)
1516 printf("WARNING: This architecture revision has known SMP "
1517 "hardware bugs which may cause random instability\n");
1521 print_INTEL_info(void)
1524 u_int rounds, regnum;
1525 u_int nwaycode, nway;
1527 if (cpu_high >= 2) {
1530 do_cpuid(0x2, regs);
1531 if (rounds == 0 && (rounds = (regs[0] & 0xff)) == 0)
1532 break; /* we have a buggy CPU */
1534 for (regnum = 0; regnum <= 3; ++regnum) {
1535 if (regs[regnum] & (1<<31))
1538 print_INTEL_TLB(regs[regnum] & 0xff);
1539 print_INTEL_TLB((regs[regnum] >> 8) & 0xff);
1540 print_INTEL_TLB((regs[regnum] >> 16) & 0xff);
1541 print_INTEL_TLB((regs[regnum] >> 24) & 0xff);
1543 } while (--rounds > 0);
1546 if (cpu_exthigh >= 0x80000006) {
1547 do_cpuid(0x80000006, regs);
1548 nwaycode = (regs[2] >> 12) & 0x0f;
1549 if (nwaycode >= 0x02 && nwaycode <= 0x08)
1550 nway = 1 << (nwaycode / 2);
1553 printf("L2 cache: %u kbytes, %u-way associative, %u bytes/line\n",
1554 (regs[2] >> 16) & 0xffff, nway, regs[2] & 0xff);
1559 print_INTEL_TLB(u_int data)
1567 printf("Instruction TLB: 4 KB pages, 4-way set associative, 32 entries\n");
1570 printf("Instruction TLB: 4 MB pages, fully associative, 2 entries\n");
1573 printf("Data TLB: 4 KB pages, 4-way set associative, 64 entries\n");
1576 printf("Data TLB: 4 MB Pages, 4-way set associative, 8 entries\n");
1579 printf("1st-level instruction cache: 8 KB, 4-way set associative, 32 byte line size\n");
1582 printf("1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size\n");
1585 printf("1st-level data cache: 8 KB, 2-way set associative, 32 byte line size\n");
1588 printf("1st-level data cache: 16 KB, 4-way set associative, 32 byte line size\n");
1591 printf("3rd-level cache: 512 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1594 printf("3rd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1597 printf("3rd-level cache: 2 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1600 printf("3rd-level cache: 4 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1603 printf("1st-level data cache: 32 KB, 8-way set associative, 64 byte line size\n");
1606 printf("1st-level instruction cache: 32 KB, 8-way set associative, 64 byte line size\n");
1609 printf("2nd-level cache: 128 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1612 printf("2nd-level cache: 128 KB, 2-way set associative, sectored cache, 64 byte line size\n");
1615 printf("2nd-level cache: 256 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1618 printf("2nd-level cache: 128 KB, 4-way set associative, 32 byte line size\n");
1621 printf("2nd-level cache: 256 KB, 4-way set associative, 32 byte line size\n");
1624 printf("2nd-level cache: 512 KB, 4-way set associative, 32 byte line size\n");
1627 printf("2nd-level cache: 1 MB, 4-way set associative, 32 byte line size\n");
1630 printf("2nd-level cache: 2 MB, 4-way set associative, 32 byte line size\n");
1633 printf("3rd-level cache: 4 MB, 4-way set associative, 64 byte line size\n");
1636 printf("3rd-level cache: 8 MB, 8-way set associative, 64 byte line size\n");
1639 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 64 entries\n");
1642 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 128 entries\n");
1645 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 256 entries\n");
1648 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 64 entries\n");
1651 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 128 entries\n");
1654 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 256 entries\n");
1657 printf("1st-level data cache: 16 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1660 printf("1st-level data cache: 8 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1663 printf("1st-level data cache: 16 KB, 4-way set associative, sectored cache, 64 byte line size\n");
1666 printf("1st-level data cache: 32 KB, 4 way set associative, sectored cache, 64 byte line size\n");
1669 printf("Trace cache: 12K-uops, 8-way set associative\n");
1672 printf("Trace cache: 16K-uops, 8-way set associative\n");
1675 printf("Trace cache: 32K-uops, 8-way set associative\n");
1678 printf("2nd-level cache: 1 MB, 4-way set associative, 64-byte line size\n");
1681 printf("2nd-level cache: 128 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1684 printf("2nd-level cache: 256 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1687 printf("2nd-level cache: 512 KB, 8-way set associative, sectored cache, 64 byte line size\n");
1690 printf("2nd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
1693 printf("2nd-level cache: 2-MB, 8-way set associative, 64-byte line size\n");
1696 printf("2nd-level cache: 512-KB, 2-way set associative, 64-byte line size\n");
1699 printf("2nd-level cache: 256 KB, 8-way set associative, 32 byte line size\n");
1702 printf("2nd-level cache: 512 KB, 8-way set associative, 32 byte line size\n");
1705 printf("2nd-level cache: 1 MB, 8-way set associative, 32 byte line size\n");
1708 printf("2nd-level cache: 2 MB, 8-way set associative, 32 byte line size\n");
1711 printf("2nd-level cache: 512 KB, 4-way set associative, 64 byte line size\n");
1714 printf("2nd-level cache: 1 MB, 8-way set associative, 64 byte line size\n");
1717 printf("Instruction TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
1720 printf("Data TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
1727 print_transmeta_info(void)
1729 u_int regs[4], nreg = 0;
1731 do_cpuid(0x80860000, regs);
1733 if (nreg >= 0x80860001) {
1734 do_cpuid(0x80860001, regs);
1735 printf(" Processor revision %u.%u.%u.%u\n",
1736 (regs[1] >> 24) & 0xff,
1737 (regs[1] >> 16) & 0xff,
1738 (regs[1] >> 8) & 0xff,
1741 if (nreg >= 0x80860002) {
1742 do_cpuid(0x80860002, regs);
1743 printf(" Code Morphing Software revision %u.%u.%u-%u-%u\n",
1744 (regs[1] >> 24) & 0xff,
1745 (regs[1] >> 16) & 0xff,
1746 (regs[1] >> 8) & 0xff,
1750 if (nreg >= 0x80860006) {
1752 do_cpuid(0x80860003, (u_int*) &info[0]);
1753 do_cpuid(0x80860004, (u_int*) &info[16]);
1754 do_cpuid(0x80860005, (u_int*) &info[32]);
1755 do_cpuid(0x80860006, (u_int*) &info[48]);
1757 printf(" %s\n", info);
1763 print_via_padlock_info(void)
1767 do_cpuid(0xc0000001, regs);
1768 printf("\n VIA Padlock Features=0x%b", regs[3],
1772 "\011AES-CTR" /* ACE2 */
1773 "\013SHA1,SHA256" /* PHE */
1779 vmx_settable(uint64_t basic, int msr, int true_msr)
1783 if (basic & (1ULL << 55))
1784 val = rdmsr(true_msr);
1788 /* Just report the controls that can be set to 1. */
1793 print_vmx_info(void)
1795 uint64_t basic, msr;
1796 uint32_t entry, exit, mask, pin, proc, proc2;
1799 printf("\n VT-x: ");
1800 msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
1801 if (!(msr & IA32_FEATURE_CONTROL_VMX_EN))
1802 printf("(disabled in BIOS) ");
1803 basic = rdmsr(MSR_VMX_BASIC);
1804 pin = vmx_settable(basic, MSR_VMX_PINBASED_CTLS,
1805 MSR_VMX_TRUE_PINBASED_CTLS);
1806 proc = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS,
1807 MSR_VMX_TRUE_PROCBASED_CTLS);
1808 if (proc & PROCBASED_SECONDARY_CONTROLS)
1809 proc2 = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS2,
1810 MSR_VMX_PROCBASED_CTLS2);
1813 exit = vmx_settable(basic, MSR_VMX_EXIT_CTLS, MSR_VMX_TRUE_EXIT_CTLS);
1814 entry = vmx_settable(basic, MSR_VMX_ENTRY_CTLS, MSR_VMX_TRUE_ENTRY_CTLS);
1818 if (exit & VM_EXIT_SAVE_PAT && exit & VM_EXIT_LOAD_PAT &&
1819 entry & VM_ENTRY_LOAD_PAT) {
1820 printf("%sPAT", comma ? "," : "");
1823 if (proc & PROCBASED_HLT_EXITING) {
1824 printf("%sHLT", comma ? "," : "");
1827 if (proc & PROCBASED_MTF) {
1828 printf("%sMTF", comma ? "," : "");
1831 if (proc & PROCBASED_PAUSE_EXITING) {
1832 printf("%sPAUSE", comma ? "," : "");
1835 if (proc2 & PROCBASED2_ENABLE_EPT) {
1836 printf("%sEPT", comma ? "," : "");
1839 if (proc2 & PROCBASED2_UNRESTRICTED_GUEST) {
1840 printf("%sUG", comma ? "," : "");
1843 if (proc2 & PROCBASED2_ENABLE_VPID) {
1844 printf("%sVPID", comma ? "," : "");
1847 if (proc & PROCBASED_USE_TPR_SHADOW &&
1848 proc2 & PROCBASED2_VIRTUALIZE_APIC_ACCESSES &&
1849 proc2 & PROCBASED2_VIRTUALIZE_X2APIC_MODE &&
1850 proc2 & PROCBASED2_APIC_REGISTER_VIRTUALIZATION &&
1851 proc2 & PROCBASED2_VIRTUAL_INTERRUPT_DELIVERY) {
1852 printf("%sVID", comma ? "," : "");
1854 if (pin & PINBASED_POSTED_INTERRUPT)
1855 printf(",PostIntr");
1861 printf("Basic Features=0x%b", mask,
1863 "\02132PA" /* 32-bit physical addresses */
1864 "\022SMM" /* SMM dual-monitor */
1865 "\027INS/OUTS" /* VM-exit info for INS and OUTS */
1866 "\030TRUE" /* TRUE_CTLS MSRs */
1868 printf("\n Pin-Based Controls=0x%b", pin,
1870 "\001ExtINT" /* External-interrupt exiting */
1871 "\004NMI" /* NMI exiting */
1872 "\006VNMI" /* Virtual NMIs */
1873 "\007PreTmr" /* Activate VMX-preemption timer */
1874 "\010PostIntr" /* Process posted interrupts */
1876 printf("\n Primary Processor Controls=0x%b", proc,
1878 "\003INTWIN" /* Interrupt-window exiting */
1879 "\004TSCOff" /* Use TSC offsetting */
1880 "\010HLT" /* HLT exiting */
1881 "\012INVLPG" /* INVLPG exiting */
1882 "\013MWAIT" /* MWAIT exiting */
1883 "\014RDPMC" /* RDPMC exiting */
1884 "\015RDTSC" /* RDTSC exiting */
1885 "\020CR3-LD" /* CR3-load exiting */
1886 "\021CR3-ST" /* CR3-store exiting */
1887 "\024CR8-LD" /* CR8-load exiting */
1888 "\025CR8-ST" /* CR8-store exiting */
1889 "\026TPR" /* Use TPR shadow */
1890 "\027NMIWIN" /* NMI-window exiting */
1891 "\030MOV-DR" /* MOV-DR exiting */
1892 "\031IO" /* Unconditional I/O exiting */
1893 "\032IOmap" /* Use I/O bitmaps */
1894 "\034MTF" /* Monitor trap flag */
1895 "\035MSRmap" /* Use MSR bitmaps */
1896 "\036MONITOR" /* MONITOR exiting */
1897 "\037PAUSE" /* PAUSE exiting */
1899 if (proc & PROCBASED_SECONDARY_CONTROLS)
1900 printf("\n Secondary Processor Controls=0x%b", proc2,
1902 "\001APIC" /* Virtualize APIC accesses */
1903 "\002EPT" /* Enable EPT */
1904 "\003DT" /* Descriptor-table exiting */
1905 "\004RDTSCP" /* Enable RDTSCP */
1906 "\005x2APIC" /* Virtualize x2APIC mode */
1907 "\006VPID" /* Enable VPID */
1908 "\007WBINVD" /* WBINVD exiting */
1909 "\010UG" /* Unrestricted guest */
1910 "\011APIC-reg" /* APIC-register virtualization */
1911 "\012VID" /* Virtual-interrupt delivery */
1912 "\013PAUSE-loop" /* PAUSE-loop exiting */
1913 "\014RDRAND" /* RDRAND exiting */
1914 "\015INVPCID" /* Enable INVPCID */
1915 "\016VMFUNC" /* Enable VM functions */
1916 "\017VMCS" /* VMCS shadowing */
1917 "\020EPT#VE" /* EPT-violation #VE */
1918 "\021XSAVES" /* Enable XSAVES/XRSTORS */
1920 printf("\n Exit Controls=0x%b", mask,
1922 "\003DR" /* Save debug controls */
1923 /* Ignore Host address-space size */
1924 "\015PERF" /* Load MSR_PERF_GLOBAL_CTRL */
1925 "\020AckInt" /* Acknowledge interrupt on exit */
1926 "\023PAT-SV" /* Save MSR_PAT */
1927 "\024PAT-LD" /* Load MSR_PAT */
1928 "\025EFER-SV" /* Save MSR_EFER */
1929 "\026EFER-LD" /* Load MSR_EFER */
1930 "\027PTMR-SV" /* Save VMX-preemption timer value */
1932 printf("\n Entry Controls=0x%b", mask,
1934 "\003DR" /* Save debug controls */
1935 /* Ignore IA-32e mode guest */
1936 /* Ignore Entry to SMM */
1937 /* Ignore Deactivate dual-monitor treatment */
1938 "\016PERF" /* Load MSR_PERF_GLOBAL_CTRL */
1939 "\017PAT" /* Load MSR_PAT */
1940 "\020EFER" /* Load MSR_EFER */
1942 if (proc & PROCBASED_SECONDARY_CONTROLS &&
1943 (proc2 & (PROCBASED2_ENABLE_EPT | PROCBASED2_ENABLE_VPID)) != 0) {
1944 msr = rdmsr(MSR_VMX_EPT_VPID_CAP);
1946 printf("\n EPT Features=0x%b", mask,
1948 "\001XO" /* Execute-only translations */
1949 "\007PW4" /* Page-walk length of 4 */
1950 "\011UC" /* EPT paging-structure mem can be UC */
1951 "\017WB" /* EPT paging-structure mem can be WB */
1952 "\0212M" /* EPT PDE can map a 2-Mbyte page */
1953 "\0221G" /* EPT PDPTE can map a 1-Gbyte page */
1954 "\025INVEPT" /* INVEPT is supported */
1955 "\026AD" /* Accessed and dirty flags for EPT */
1956 "\032single" /* INVEPT single-context type */
1957 "\033all" /* INVEPT all-context type */
1960 printf("\n VPID Features=0x%b", mask,
1962 "\001INVVPID" /* INVVPID is supported */
1963 "\011individual" /* INVVPID individual-address type */
1964 "\012single" /* INVVPID single-context type */
1965 "\013all" /* INVVPID all-context type */
1966 /* INVVPID single-context-retaining-globals type */
1967 "\014single-globals"