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/limits.h>
51 #include <sys/systm.h>
52 #include <sys/kernel.h>
53 #include <sys/sysctl.h>
54 #include <sys/power.h>
59 #include <machine/asmacros.h>
60 #include <machine/clock.h>
61 #include <machine/cputypes.h>
62 #include <machine/frame.h>
63 #include <machine/intr_machdep.h>
64 #include <machine/md_var.h>
65 #include <machine/segments.h>
66 #include <machine/specialreg.h>
68 #include <amd64/vmm/intel/vmx_controls.h>
69 #include <x86/isa/icu.h>
70 #include <x86/vmware.h>
73 #define IDENTBLUE_CYRIX486 0
74 #define IDENTBLUE_IBMCPU 1
75 #define IDENTBLUE_CYRIXM2 2
77 static void identifycyrix(void);
78 static void print_transmeta_info(void);
80 static u_int find_cpu_vendor_id(void);
81 static void print_AMD_info(void);
82 static void print_INTEL_info(void);
83 static void print_INTEL_TLB(u_int data);
84 static void print_hypervisor_info(void);
85 static void print_svm_info(void);
86 static void print_via_padlock_info(void);
87 static void print_vmx_info(void);
90 int cpu; /* Are we 386, 386sx, 486, etc? */
93 u_int cpu_feature; /* Feature flags */
94 u_int cpu_feature2; /* Feature flags */
95 u_int amd_feature; /* AMD feature flags */
96 u_int amd_feature2; /* AMD feature flags */
97 u_int amd_rascap; /* AMD RAS capabilities */
98 u_int amd_pminfo; /* AMD advanced power management info */
99 u_int amd_extended_feature_extensions;
100 u_int via_feature_rng; /* VIA RNG features */
101 u_int via_feature_xcrypt; /* VIA ACE features */
102 u_int cpu_high; /* Highest arg to CPUID */
103 u_int cpu_exthigh; /* Highest arg to extended CPUID */
104 u_int cpu_id; /* Stepping ID */
105 u_int cpu_procinfo; /* HyperThreading Info / Brand Index / CLFUSH */
106 u_int cpu_procinfo2; /* Multicore info */
107 char cpu_vendor[20]; /* CPU Origin code */
108 u_int cpu_vendor_id; /* CPU vendor ID */
109 u_int cpu_fxsr; /* SSE enabled */
110 u_int cpu_mxcsr_mask; /* Valid bits in mxcsr */
111 u_int cpu_clflush_line_size = 32;
112 u_int cpu_stdext_feature; /* %ebx */
113 u_int cpu_stdext_feature2; /* %ecx */
114 u_int cpu_stdext_feature3; /* %edx */
115 uint64_t cpu_ia32_arch_caps;
116 u_int cpu_max_ext_state_size;
117 u_int cpu_mon_mwait_flags; /* MONITOR/MWAIT flags (CPUID.05H.ECX) */
118 u_int cpu_mon_min_size; /* MONITOR minimum range size, bytes */
119 u_int cpu_mon_max_size; /* MONITOR minimum range size, bytes */
120 u_int cpu_maxphyaddr; /* Max phys addr width in bits */
121 u_int cpu_power_eax; /* 06H: Power management leaf, %eax */
122 u_int cpu_power_ebx; /* 06H: Power management leaf, %eax */
123 u_int cpu_power_ecx; /* 06H: Power management leaf, %eax */
124 u_int cpu_power_edx; /* 06H: Power management leaf, %eax */
125 char machine[] = MACHINE;
127 SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD,
129 "VIA RNG feature available in CPU");
130 SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD,
131 &via_feature_xcrypt, 0,
132 "VIA xcrypt feature available in CPU");
136 extern int adaptive_machine_arch;
140 sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
143 static const char machine32[] = "i386";
148 if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch)
149 error = SYSCTL_OUT(req, machine32, sizeof(machine32));
152 error = SYSCTL_OUT(req, machine, sizeof(machine));
156 SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD |
157 CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class");
159 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
160 machine, 0, "Machine class");
163 static char cpu_model[128];
164 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD | CTLFLAG_MPSAFE,
165 cpu_model, 0, "Machine model");
167 static int hw_clockrate;
168 SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
169 &hw_clockrate, 0, "CPU instruction clock rate");
174 SYSCTL_STRING(_hw, OID_AUTO, hv_vendor, CTLFLAG_RD | CTLFLAG_MPSAFE, hv_vendor,
175 0, "Hypervisor vendor");
177 static eventhandler_tag tsc_post_tag;
179 static char cpu_brand[48];
182 #define MAX_BRAND_INDEX 8
184 static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = {
188 "Intel Pentium III Xeon",
200 { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */
201 { "i386SX", CPUCLASS_386 }, /* CPU_386SX */
202 { "i386DX", CPUCLASS_386 }, /* CPU_386 */
203 { "i486SX", CPUCLASS_486 }, /* CPU_486SX */
204 { "i486DX", CPUCLASS_486 }, /* CPU_486 */
205 { "Pentium", CPUCLASS_586 }, /* CPU_586 */
206 { "Cyrix 486", CPUCLASS_486 }, /* CPU_486DLC */
207 { "Pentium Pro", CPUCLASS_686 }, /* CPU_686 */
208 { "Cyrix 5x86", CPUCLASS_486 }, /* CPU_M1SC */
209 { "Cyrix 6x86", CPUCLASS_486 }, /* CPU_M1 */
210 { "Blue Lightning", CPUCLASS_486 }, /* CPU_BLUE */
211 { "Cyrix 6x86MX", CPUCLASS_686 }, /* CPU_M2 */
212 { "NexGen 586", CPUCLASS_386 }, /* CPU_NX586 (XXX) */
213 { "Cyrix 486S/DX", CPUCLASS_486 }, /* CPU_CY486DX */
214 { "Pentium II", CPUCLASS_686 }, /* CPU_PII */
215 { "Pentium III", CPUCLASS_686 }, /* CPU_PIII */
216 { "Pentium 4", CPUCLASS_686 }, /* CPU_P4 */
224 { INTEL_VENDOR_ID, CPU_VENDOR_INTEL }, /* GenuineIntel */
225 { AMD_VENDOR_ID, CPU_VENDOR_AMD }, /* AuthenticAMD */
226 { CENTAUR_VENDOR_ID, CPU_VENDOR_CENTAUR }, /* CentaurHauls */
228 { NSC_VENDOR_ID, CPU_VENDOR_NSC }, /* Geode by NSC */
229 { CYRIX_VENDOR_ID, CPU_VENDOR_CYRIX }, /* CyrixInstead */
230 { TRANSMETA_VENDOR_ID, CPU_VENDOR_TRANSMETA }, /* GenuineTMx86 */
231 { SIS_VENDOR_ID, CPU_VENDOR_SIS }, /* SiS SiS SiS */
232 { UMC_VENDOR_ID, CPU_VENDOR_UMC }, /* UMC UMC UMC */
233 { NEXGEN_VENDOR_ID, CPU_VENDOR_NEXGEN }, /* NexGenDriven */
234 { RISE_VENDOR_ID, CPU_VENDOR_RISE }, /* RiseRiseRise */
236 /* XXX CPUID 8000_0000h and 8086_0000h, not 0000_0000h */
237 { "TransmetaCPU", CPU_VENDOR_TRANSMETA },
250 cpu_class = cpus[cpu].cpu_class;
251 strncpy(cpu_model, cpus[cpu].cpu_name, sizeof (cpu_model));
253 strncpy(cpu_model, "Hammer", sizeof (cpu_model));
256 /* Check for extended CPUID information and a processor name. */
257 if (cpu_exthigh >= 0x80000004) {
259 for (i = 0x80000002; i < 0x80000005; i++) {
261 memcpy(brand, regs, sizeof(regs));
262 brand += sizeof(regs);
266 switch (cpu_vendor_id) {
267 case CPU_VENDOR_INTEL:
269 if ((cpu_id & 0xf00) > 0x300) {
274 switch (cpu_id & 0x3000) {
276 strcpy(cpu_model, "Overdrive ");
279 strcpy(cpu_model, "Dual ");
283 switch (cpu_id & 0xf00) {
285 strcat(cpu_model, "i486 ");
286 /* Check the particular flavor of 486 */
287 switch (cpu_id & 0xf0) {
290 strcat(cpu_model, "DX");
293 strcat(cpu_model, "SX");
296 strcat(cpu_model, "DX2");
299 strcat(cpu_model, "SL");
302 strcat(cpu_model, "SX2");
306 "DX2 Write-Back Enhanced");
309 strcat(cpu_model, "DX4");
314 /* Check the particular flavor of 586 */
315 strcat(cpu_model, "Pentium");
316 switch (cpu_id & 0xf0) {
318 strcat(cpu_model, " A-step");
321 strcat(cpu_model, "/P5");
324 strcat(cpu_model, "/P54C");
327 strcat(cpu_model, "/P24T");
330 strcat(cpu_model, "/P55C");
333 strcat(cpu_model, "/P54C");
336 strcat(cpu_model, "/P55C (quarter-micron)");
342 #if defined(I586_CPU) && !defined(NO_F00F_HACK)
344 * XXX - If/when Intel fixes the bug, this
345 * should also check the version of the
346 * CPU, not just that it's a Pentium.
352 /* Check the particular flavor of 686 */
353 switch (cpu_id & 0xf0) {
355 strcat(cpu_model, "Pentium Pro A-step");
358 strcat(cpu_model, "Pentium Pro");
364 "Pentium II/Pentium II Xeon/Celeron");
372 "Pentium III/Pentium III Xeon/Celeron");
376 strcat(cpu_model, "Unknown 80686");
381 strcat(cpu_model, "Pentium 4");
385 strcat(cpu_model, "unknown");
390 * If we didn't get a brand name from the extended
391 * CPUID, try to look it up in the brand table.
393 if (cpu_high > 0 && *cpu_brand == '\0') {
394 brand_index = cpu_procinfo & CPUID_BRAND_INDEX;
395 if (brand_index <= MAX_BRAND_INDEX &&
396 cpu_brandtable[brand_index] != NULL)
398 cpu_brandtable[brand_index]);
402 /* Please make up your mind folks! */
403 strcat(cpu_model, "EM64T");
408 * Values taken from AMD Processor Recognition
409 * http://www.amd.com/K6/k6docs/pdf/20734g.pdf
410 * (also describes ``Features'' encodings.
412 strcpy(cpu_model, "AMD ");
414 switch (cpu_id & 0xFF0) {
416 strcat(cpu_model, "Standard Am486DX");
419 strcat(cpu_model, "Enhanced Am486DX2 Write-Through");
422 strcat(cpu_model, "Enhanced Am486DX2 Write-Back");
425 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Through");
428 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Back");
431 strcat(cpu_model, "Am5x86 Write-Through");
434 strcat(cpu_model, "Am5x86 Write-Back");
437 strcat(cpu_model, "K5 model 0");
440 strcat(cpu_model, "K5 model 1");
443 strcat(cpu_model, "K5 PR166 (model 2)");
446 strcat(cpu_model, "K5 PR200 (model 3)");
449 strcat(cpu_model, "K6");
452 strcat(cpu_model, "K6 266 (model 1)");
455 strcat(cpu_model, "K6-2");
458 strcat(cpu_model, "K6-III");
461 strcat(cpu_model, "Geode LX");
464 strcat(cpu_model, "Unknown");
468 if ((cpu_id & 0xf00) == 0xf00)
469 strcat(cpu_model, "AMD64 Processor");
471 strcat(cpu_model, "Unknown");
475 case CPU_VENDOR_CYRIX:
476 strcpy(cpu_model, "Cyrix ");
477 switch (cpu_id & 0xff0) {
479 strcat(cpu_model, "MediaGX");
482 strcat(cpu_model, "6x86");
485 cpu_class = CPUCLASS_586;
486 strcat(cpu_model, "GXm");
489 strcat(cpu_model, "6x86MX");
493 * Even though CPU supports the cpuid
494 * instruction, it can be disabled.
495 * Therefore, this routine supports all Cyrix
498 switch (cyrix_did & 0xf0) {
500 switch (cyrix_did & 0x0f) {
502 strcat(cpu_model, "486SLC");
505 strcat(cpu_model, "486DLC");
508 strcat(cpu_model, "486SLC2");
511 strcat(cpu_model, "486DLC2");
514 strcat(cpu_model, "486SRx");
517 strcat(cpu_model, "486DRx");
520 strcat(cpu_model, "486SRx2");
523 strcat(cpu_model, "486DRx2");
526 strcat(cpu_model, "486SRu");
529 strcat(cpu_model, "486DRu");
532 strcat(cpu_model, "486SRu2");
535 strcat(cpu_model, "486DRu2");
538 strcat(cpu_model, "Unknown");
543 switch (cyrix_did & 0x0f) {
545 strcat(cpu_model, "486S");
548 strcat(cpu_model, "486S2");
551 strcat(cpu_model, "486Se");
554 strcat(cpu_model, "486S2e");
557 strcat(cpu_model, "486DX");
560 strcat(cpu_model, "486DX2");
563 strcat(cpu_model, "486DX4");
566 strcat(cpu_model, "Unknown");
571 if ((cyrix_did & 0x0f) < 8)
572 strcat(cpu_model, "6x86"); /* Where did you get it? */
574 strcat(cpu_model, "5x86");
577 strcat(cpu_model, "6x86");
580 if ((cyrix_did & 0xf000) == 0x3000) {
581 cpu_class = CPUCLASS_586;
582 strcat(cpu_model, "GXm");
584 strcat(cpu_model, "MediaGX");
587 strcat(cpu_model, "6x86MX");
590 switch (cyrix_did & 0x0f) {
592 strcat(cpu_model, "Overdrive CPU");
595 strcpy(cpu_model, "Texas Instruments 486SXL");
598 strcat(cpu_model, "486SLC/DLC");
601 strcat(cpu_model, "Unknown");
606 strcat(cpu_model, "Unknown");
612 case CPU_VENDOR_RISE:
613 strcpy(cpu_model, "Rise ");
614 switch (cpu_id & 0xff0) {
615 case 0x500: /* 6401 and 6441 (Kirin) */
616 case 0x520: /* 6510 (Lynx) */
617 strcat(cpu_model, "mP6");
620 strcat(cpu_model, "Unknown");
624 case CPU_VENDOR_CENTAUR:
626 switch (cpu_id & 0xff0) {
628 strcpy(cpu_model, "IDT WinChip C6");
631 strcpy(cpu_model, "IDT WinChip 2");
634 strcpy(cpu_model, "IDT WinChip 3");
637 strcpy(cpu_model, "VIA C3 Samuel");
641 strcpy(cpu_model, "VIA C3 Ezra");
643 strcpy(cpu_model, "VIA C3 Samuel 2");
646 strcpy(cpu_model, "VIA C3 Ezra-T");
649 strcpy(cpu_model, "VIA C3 Nehemiah");
653 strcpy(cpu_model, "VIA C7 Esther");
656 strcpy(cpu_model, "VIA Nano");
659 strcpy(cpu_model, "VIA/IDT Unknown");
662 strcpy(cpu_model, "VIA ");
663 if ((cpu_id & 0xff0) == 0x6f0)
664 strcat(cpu_model, "Nano Processor");
666 strcat(cpu_model, "Unknown");
671 strcpy(cpu_model, "Blue Lightning CPU");
674 switch (cpu_id & 0xff0) {
676 strcpy(cpu_model, "Geode SC1100");
680 strcpy(cpu_model, "Geode/NSC unknown");
686 strcat(cpu_model, "Unknown");
691 * Replace cpu_model with cpu_brand minus leading spaces if
695 while (*brand == ' ')
698 strcpy(cpu_model, brand);
700 printf("%s (", cpu_model);
702 hw_clockrate = (tsc_freq + 5000) / 1000000;
703 printf("%jd.%02d-MHz ",
704 (intmax_t)(tsc_freq + 4999) / 1000000,
705 (u_int)((tsc_freq + 4999) / 10000) % 100);
715 #if defined(I486_CPU)
720 #if defined(I586_CPU)
725 #if defined(I686_CPU)
731 printf("Unknown"); /* will panic below... */
736 printf("-class CPU)\n");
738 printf(" Origin=\"%s\"", cpu_vendor);
740 printf(" Id=0x%x", cpu_id);
742 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
743 cpu_vendor_id == CPU_VENDOR_AMD ||
744 cpu_vendor_id == CPU_VENDOR_CENTAUR ||
746 cpu_vendor_id == CPU_VENDOR_TRANSMETA ||
747 cpu_vendor_id == CPU_VENDOR_RISE ||
748 cpu_vendor_id == CPU_VENDOR_NSC ||
749 (cpu_vendor_id == CPU_VENDOR_CYRIX && ((cpu_id & 0xf00) > 0x500)) ||
752 printf(" Family=0x%x", CPUID_TO_FAMILY(cpu_id));
753 printf(" Model=0x%x", CPUID_TO_MODEL(cpu_id));
754 printf(" Stepping=%u", cpu_id & CPUID_STEPPING);
756 if (cpu_vendor_id == CPU_VENDOR_CYRIX)
757 printf("\n DIR=0x%04x", cyrix_did);
761 * AMD CPUID Specification
762 * http://support.amd.com/us/Embedded_TechDocs/25481.pdf
764 * Intel Processor Identification and CPUID Instruction
765 * http://www.intel.com/assets/pdf/appnote/241618.pdf
770 * Here we should probably set up flags indicating
771 * whether or not various features are available.
772 * The interesting ones are probably VME, PSE, PAE,
773 * and PGE. The code already assumes without bothering
774 * to check that all CPUs >= Pentium have a TSC and
777 printf("\n Features=0x%b", cpu_feature,
779 "\001FPU" /* Integral FPU */
780 "\002VME" /* Extended VM86 mode support */
781 "\003DE" /* Debugging Extensions (CR4.DE) */
782 "\004PSE" /* 4MByte page tables */
783 "\005TSC" /* Timestamp counter */
784 "\006MSR" /* Machine specific registers */
785 "\007PAE" /* Physical address extension */
786 "\010MCE" /* Machine Check support */
787 "\011CX8" /* CMPEXCH8 instruction */
788 "\012APIC" /* SMP local APIC */
789 "\013oldMTRR" /* Previous implementation of MTRR */
790 "\014SEP" /* Fast System Call */
791 "\015MTRR" /* Memory Type Range Registers */
792 "\016PGE" /* PG_G (global bit) support */
793 "\017MCA" /* Machine Check Architecture */
794 "\020CMOV" /* CMOV instruction */
795 "\021PAT" /* Page attributes table */
796 "\022PSE36" /* 36 bit address space support */
797 "\023PN" /* Processor Serial number */
798 "\024CLFLUSH" /* Has the CLFLUSH instruction */
800 "\026DTS" /* Debug Trace Store */
801 "\027ACPI" /* ACPI support */
802 "\030MMX" /* MMX instructions */
803 "\031FXSR" /* FXSAVE/FXRSTOR */
804 "\032SSE" /* Streaming SIMD Extensions */
805 "\033SSE2" /* Streaming SIMD Extensions #2 */
806 "\034SS" /* Self snoop */
807 "\035HTT" /* Hyperthreading (see EBX bit 16-23) */
808 "\036TM" /* Thermal Monitor clock slowdown */
809 "\037IA64" /* CPU can execute IA64 instructions */
810 "\040PBE" /* Pending Break Enable */
813 if (cpu_feature2 != 0) {
814 printf("\n Features2=0x%b", cpu_feature2,
816 "\001SSE3" /* SSE3 */
817 "\002PCLMULQDQ" /* Carry-Less Mul Quadword */
818 "\003DTES64" /* 64-bit Debug Trace */
819 "\004MON" /* MONITOR/MWAIT Instructions */
820 "\005DS_CPL" /* CPL Qualified Debug Store */
821 "\006VMX" /* Virtual Machine Extensions */
822 "\007SMX" /* Safer Mode Extensions */
823 "\010EST" /* Enhanced SpeedStep */
824 "\011TM2" /* Thermal Monitor 2 */
825 "\012SSSE3" /* SSSE3 */
826 "\013CNXT-ID" /* L1 context ID available */
827 "\014SDBG" /* IA32 silicon debug */
828 "\015FMA" /* Fused Multiply Add */
829 "\016CX16" /* CMPXCHG16B Instruction */
830 "\017xTPR" /* Send Task Priority Messages*/
831 "\020PDCM" /* Perf/Debug Capability MSR */
833 "\022PCID" /* Process-context Identifiers*/
834 "\023DCA" /* Direct Cache Access */
835 "\024SSE4.1" /* SSE 4.1 */
836 "\025SSE4.2" /* SSE 4.2 */
837 "\026x2APIC" /* xAPIC Extensions */
838 "\027MOVBE" /* MOVBE Instruction */
839 "\030POPCNT" /* POPCNT Instruction */
840 "\031TSCDLT" /* TSC-Deadline Timer */
841 "\032AESNI" /* AES Crypto */
842 "\033XSAVE" /* XSAVE/XRSTOR States */
843 "\034OSXSAVE" /* OS-Enabled State Management*/
844 "\035AVX" /* Advanced Vector Extensions */
845 "\036F16C" /* Half-precision conversions */
846 "\037RDRAND" /* RDRAND Instruction */
847 "\040HV" /* Hypervisor */
851 if (amd_feature != 0) {
852 printf("\n AMD Features=0x%b", amd_feature,
854 "\001<s0>" /* Same */
855 "\002<s1>" /* Same */
856 "\003<s2>" /* Same */
857 "\004<s3>" /* Same */
858 "\005<s4>" /* Same */
859 "\006<s5>" /* Same */
860 "\007<s6>" /* Same */
861 "\010<s7>" /* Same */
862 "\011<s8>" /* Same */
863 "\012<s9>" /* Same */
864 "\013<b10>" /* Undefined */
865 "\014SYSCALL" /* Have SYSCALL/SYSRET */
866 "\015<s12>" /* Same */
867 "\016<s13>" /* Same */
868 "\017<s14>" /* Same */
869 "\020<s15>" /* Same */
870 "\021<s16>" /* Same */
871 "\022<s17>" /* Same */
872 "\023<b18>" /* Reserved, unknown */
873 "\024MP" /* Multiprocessor Capable */
874 "\025NX" /* Has EFER.NXE, NX */
875 "\026<b21>" /* Undefined */
876 "\027MMX+" /* AMD MMX Extensions */
877 "\030<s23>" /* Same */
878 "\031<s24>" /* Same */
879 "\032FFXSR" /* Fast FXSAVE/FXRSTOR */
880 "\033Page1GB" /* 1-GB large page support */
881 "\034RDTSCP" /* RDTSCP */
882 "\035<b28>" /* Undefined */
883 "\036LM" /* 64 bit long mode */
884 "\0373DNow!+" /* AMD 3DNow! Extensions */
885 "\0403DNow!" /* AMD 3DNow! */
889 if (amd_feature2 != 0) {
890 printf("\n AMD Features2=0x%b", amd_feature2,
892 "\001LAHF" /* LAHF/SAHF in long mode */
893 "\002CMP" /* CMP legacy */
894 "\003SVM" /* Secure Virtual Mode */
895 "\004ExtAPIC" /* Extended APIC register */
896 "\005CR8" /* CR8 in legacy mode */
897 "\006ABM" /* LZCNT instruction */
898 "\007SSE4A" /* SSE4A */
899 "\010MAS" /* Misaligned SSE mode */
900 "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */
901 "\012OSVW" /* OS visible workaround */
902 "\013IBS" /* Instruction based sampling */
903 "\014XOP" /* XOP extended instructions */
904 "\015SKINIT" /* SKINIT/STGI */
905 "\016WDT" /* Watchdog timer */
907 "\020LWP" /* Lightweight Profiling */
908 "\021FMA4" /* 4-operand FMA instructions */
909 "\022TCE" /* Translation Cache Extension */
911 "\024NodeId" /* NodeId MSR support */
913 "\026TBM" /* Trailing Bit Manipulation */
914 "\027Topology" /* Topology Extensions */
915 "\030PCXC" /* Core perf count */
916 "\031PNXC" /* NB perf count */
918 "\033DBE" /* Data Breakpoint extension */
919 "\034PTSC" /* Performance TSC */
920 "\035PL2I" /* L2I perf count */
921 "\036MWAITX" /* MONITORX/MWAITX instructions */
927 if (cpu_stdext_feature != 0) {
928 printf("\n Structured Extended Features=0x%b",
931 /* RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
935 /* Bit Manipulation Instructions */
937 /* Hardware Lock Elision */
939 /* Advanced Vector Instructions 2 */
941 /* FDP_EXCPTN_ONLY */
943 /* Supervisor Mode Execution Prot. */
945 /* Bit Manipulation Instructions */
948 /* Invalidate Processor Context ID */
950 /* Restricted Transactional Memory */
954 /* Intel Memory Protection Extensions */
957 /* AVX512 Foundation */
964 /* Supervisor Mode Access Prevention */
967 /* Formerly PCOMMIT */
981 if (cpu_stdext_feature2 != 0) {
982 printf("\n Structured Extended Features2=0x%b",
997 "\016AVX512VPOPCNTDQ"
1007 if (cpu_stdext_feature3 != 0) {
1008 printf("\n Structured Extended Features3=0x%b",
1009 cpu_stdext_feature3,
1013 "\011AVX512VP2INTERSECT"
1026 if ((cpu_feature2 & CPUID2_XSAVE) != 0) {
1027 cpuid_count(0xd, 0x1, regs);
1029 printf("\n XSAVE Features=0x%b",
1039 if (cpu_ia32_arch_caps != 0) {
1040 printf("\n IA32_ARCH_CAPS=0x%b",
1041 (u_int)cpu_ia32_arch_caps,
1046 "\004SKIP_L1DFL_VME"
1054 if (amd_extended_feature_extensions != 0) {
1055 u_int amd_fe_masked;
1057 amd_fe_masked = amd_extended_feature_extensions;
1058 if ((amd_fe_masked & AMDFEID_IBRS) == 0)
1060 ~(AMDFEID_IBRS_ALWAYSON |
1061 AMDFEID_PREFER_IBRS);
1062 if ((amd_fe_masked & AMDFEID_STIBP) == 0)
1064 ~AMDFEID_STIBP_ALWAYSON;
1067 "AMD Extended Feature Extensions ID EBX="
1068 "0x%b", amd_fe_masked,
1080 "\022STIBP_ALWAYSON"
1088 if (via_feature_rng != 0 || via_feature_xcrypt != 0)
1089 print_via_padlock_info();
1091 if (cpu_feature2 & CPUID2_VMX)
1094 if (amd_feature2 & AMDID2_SVM)
1097 if ((cpu_feature & CPUID_HTT) &&
1098 cpu_vendor_id == CPU_VENDOR_AMD)
1099 cpu_feature &= ~CPUID_HTT;
1102 * If this CPU supports P-state invariant TSC then
1103 * mention the capability.
1105 if (tsc_is_invariant) {
1106 printf("\n TSC: P-state invariant");
1108 printf(", performance statistics");
1112 } else if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
1113 printf(" DIR=0x%04x", cyrix_did);
1114 printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12);
1115 printf(" Revision=%u", (cyrix_did & 0x0f00) >> 8);
1116 #ifndef CYRIX_CACHE_REALLY_WORKS
1117 if (cpu == CPU_M1 && (cyrix_did & 0xff00) < 0x1700)
1118 printf("\n CPU cache: write-through mode");
1123 /* Avoid ugly blank lines: only print newline when we have to. */
1124 if (*cpu_vendor || cpu_id)
1128 if (cpu_vendor_id == CPU_VENDOR_AMD)
1130 else if (cpu_vendor_id == CPU_VENDOR_INTEL)
1133 else if (cpu_vendor_id == CPU_VENDOR_TRANSMETA)
1134 print_transmeta_info();
1138 print_hypervisor_info();
1143 panicifcpuunsupported(void)
1147 #if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
1148 #error This kernel is not configured for one of the supported CPUs
1153 * Now that we have told the user what they have,
1154 * let them know if that machine type isn't configured.
1156 switch (cpu_class) {
1157 case CPUCLASS_286: /* a 286 should not make it this far, anyway */
1159 #if !defined(I486_CPU)
1162 #if !defined(I586_CPU)
1165 #if !defined(I686_CPU)
1168 panic("CPU class not configured");
1174 static volatile u_int trap_by_rdmsr;
1177 * Special exception 6 handler.
1178 * The rdmsr instruction generates invalid opcodes fault on 486-class
1179 * Cyrix CPU. Stacked eip register points the rdmsr instruction in the
1180 * function identblue() when this handler is called. Stacked eip should
1183 inthand_t bluetrap6;
1184 #ifdef __GNUCLIKE_ASM
1189 .type " __XSTRING(CNAME(bluetrap6)) ",@function \n\
1190 " __XSTRING(CNAME(bluetrap6)) ": \n\
1192 movl $0xa8c1d," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1193 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1199 * Special exception 13 handler.
1200 * Accessing non-existent MSR generates general protection fault.
1202 inthand_t bluetrap13;
1203 #ifdef __GNUCLIKE_ASM
1208 .type " __XSTRING(CNAME(bluetrap13)) ",@function \n\
1209 " __XSTRING(CNAME(bluetrap13)) ": \n\
1211 movl $0xa89c4," __XSTRING(CNAME(trap_by_rdmsr)) " \n\
1212 popl %eax /* discard error code */ \n\
1213 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\
1219 * Distinguish IBM Blue Lightning CPU from Cyrix CPUs that does not
1220 * support cpuid instruction. This function should be called after
1221 * loading interrupt descriptor table register.
1223 * I don't like this method that handles fault, but I couldn't get
1224 * information for any other methods. Does blue giant know?
1233 * Cyrix 486-class CPU does not support rdmsr instruction.
1234 * The rdmsr instruction generates invalid opcode fault, and exception
1235 * will be trapped by bluetrap6() on Cyrix 486-class CPU. The
1236 * bluetrap6() set the magic number to trap_by_rdmsr.
1238 setidt(IDT_UD, bluetrap6, SDT_SYS386TGT, SEL_KPL,
1239 GSEL(GCODE_SEL, SEL_KPL));
1242 * Certain BIOS disables cpuid instruction of Cyrix 6x86MX CPU.
1243 * In this case, rdmsr generates general protection fault, and
1244 * exception will be trapped by bluetrap13().
1246 setidt(IDT_GP, bluetrap13, SDT_SYS386TGT, SEL_KPL,
1247 GSEL(GCODE_SEL, SEL_KPL));
1249 rdmsr(0x1002); /* Cyrix CPU generates fault. */
1251 if (trap_by_rdmsr == 0xa8c1d)
1252 return IDENTBLUE_CYRIX486;
1253 else if (trap_by_rdmsr == 0xa89c4)
1254 return IDENTBLUE_CYRIXM2;
1255 return IDENTBLUE_IBMCPU;
1260 * identifycyrix() set lower 16 bits of cyrix_did as follows:
1262 * F E D C B A 9 8 7 6 5 4 3 2 1 0
1263 * +-------+-------+---------------+
1264 * | SID | RID | Device ID |
1265 * | (DIR 1) | (DIR 0) |
1266 * +-------+-------+---------------+
1271 register_t saveintr;
1272 int ccr2_test = 0, dir_test = 0;
1275 saveintr = intr_disable();
1277 ccr2 = read_cyrix_reg(CCR2);
1278 write_cyrix_reg(CCR2, ccr2 ^ CCR2_LOCK_NW);
1279 read_cyrix_reg(CCR2);
1280 if (read_cyrix_reg(CCR2) != ccr2)
1282 write_cyrix_reg(CCR2, ccr2);
1284 ccr3 = read_cyrix_reg(CCR3);
1285 write_cyrix_reg(CCR3, ccr3 ^ CCR3_MAPEN3);
1286 read_cyrix_reg(CCR3);
1287 if (read_cyrix_reg(CCR3) != ccr3)
1288 dir_test = 1; /* CPU supports DIRs. */
1289 write_cyrix_reg(CCR3, ccr3);
1292 /* Device ID registers are available. */
1293 cyrix_did = read_cyrix_reg(DIR1) << 8;
1294 cyrix_did += read_cyrix_reg(DIR0);
1295 } else if (ccr2_test)
1296 cyrix_did = 0x0010; /* 486S A-step */
1298 cyrix_did = 0x00ff; /* Old 486SLC/DLC and TI486SXLC/SXL */
1300 intr_restore(saveintr);
1304 /* Update TSC freq with the value indicated by the caller. */
1306 tsc_freq_changed(void *arg __unused, const struct cf_level *level, int status)
1309 /* If there was an error during the transition, don't do anything. */
1313 /* Total setting for this level gives the new frequency in MHz. */
1314 hw_clockrate = level->total_set.freq;
1318 hook_tsc_freq(void *arg __unused)
1321 if (tsc_is_invariant)
1324 tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
1325 tsc_freq_changed, NULL, EVENTHANDLER_PRI_ANY);
1328 SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
1330 static const struct {
1331 const char * vm_bname;
1334 { "QEMU", VM_GUEST_VM }, /* QEMU */
1335 { "Plex86", VM_GUEST_VM }, /* Plex86 */
1336 { "Bochs", VM_GUEST_VM }, /* Bochs */
1337 { "Xen", VM_GUEST_XEN }, /* Xen */
1338 { "BHYVE", VM_GUEST_BHYVE }, /* bhyve */
1339 { "Seabios", VM_GUEST_KVM }, /* KVM */
1342 static const struct {
1343 const char * vm_pname;
1346 { "VMware Virtual Platform", VM_GUEST_VMWARE },
1347 { "Virtual Machine", VM_GUEST_VM }, /* Microsoft VirtualPC */
1348 { "VirtualBox", VM_GUEST_VBOX },
1349 { "Parallels Virtual Platform", VM_GUEST_PARALLELS },
1350 { "KVM", VM_GUEST_KVM },
1354 const char *vm_cpuid;
1357 { "XENXENXEN", VM_GUEST_XEN }, /* XEN */
1358 { "Microsoft Hv", VM_GUEST_HV }, /* Microsoft Hyper-V */
1359 { "VMwareVMware", VM_GUEST_VMWARE }, /* VMware VM */
1360 { "KVMKVMKVM", VM_GUEST_KVM }, /* KVM */
1361 { "bhyve bhyve ", VM_GUEST_BHYVE }, /* bhyve */
1362 { "VBoxVBoxVBox", VM_GUEST_VBOX }, /* VirtualBox */
1366 identify_hypervisor_cpuid_base(void)
1368 u_int leaf, regs[4];
1372 * [RFC] CPUID usage for interaction between Hypervisors and Linux.
1373 * http://lkml.org/lkml/2008/10/1/246
1375 * KB1009458: Mechanisms to determine if software is running in
1376 * a VMware virtual machine
1377 * http://kb.vmware.com/kb/1009458
1379 * Search for a hypervisor that we recognize. If we cannot find
1380 * a specific hypervisor, return the first information about the
1381 * hypervisor that we found, as others may be able to use.
1383 for (leaf = 0x40000000; leaf < 0x40010000; leaf += 0x100) {
1384 do_cpuid(leaf, regs);
1387 * KVM from Linux kernels prior to commit
1388 * 57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190 set %eax
1389 * to 0 rather than a valid hv_high value. Check for
1390 * the KVM signature bytes and fixup %eax to the
1391 * highest supported leaf in that case.
1393 if (regs[0] == 0 && regs[1] == 0x4b4d564b &&
1394 regs[2] == 0x564b4d56 && regs[3] == 0x0000004d)
1397 if (regs[0] >= leaf) {
1398 for (i = 0; i < nitems(vm_cpuids); i++)
1399 if (strncmp((const char *)®s[1],
1400 vm_cpuids[i].vm_cpuid, 12) == 0) {
1401 vm_guest = vm_cpuids[i].vm_guest;
1406 * If this is the first entry or we found a
1407 * specific hypervisor, record the base, high value,
1408 * and vendor identifier.
1410 if (vm_guest != VM_GUEST_VM || leaf == 0x40000000) {
1413 ((u_int *)&hv_vendor)[0] = regs[1];
1414 ((u_int *)&hv_vendor)[1] = regs[2];
1415 ((u_int *)&hv_vendor)[2] = regs[3];
1416 hv_vendor[12] = '\0';
1419 * If we found a specific hypervisor, then
1422 if (vm_guest != VM_GUEST_VM)
1430 identify_hypervisor(void)
1437 * If CPUID2_HV is set, we are running in a hypervisor environment.
1439 if (cpu_feature2 & CPUID2_HV) {
1440 vm_guest = VM_GUEST_VM;
1441 identify_hypervisor_cpuid_base();
1443 /* If we have a definitive vendor, we can return now. */
1444 if (*hv_vendor != '\0')
1449 * Examine SMBIOS strings for older hypervisors.
1451 p = kern_getenv("smbios.system.serial");
1453 if (strncmp(p, "VMware-", 7) == 0 || strncmp(p, "VMW", 3) == 0) {
1454 vmware_hvcall(VMW_HVCMD_GETVERSION, regs);
1455 if (regs[1] == VMW_HVMAGIC) {
1456 vm_guest = VM_GUEST_VMWARE;
1465 * XXX: Some of these entries may not be needed since they were
1466 * added to FreeBSD before the checks above.
1468 p = kern_getenv("smbios.bios.vendor");
1470 for (i = 0; i < nitems(vm_bnames); i++)
1471 if (strcmp(p, vm_bnames[i].vm_bname) == 0) {
1472 vm_guest = vm_bnames[i].vm_guest;
1473 /* If we have a specific match, return */
1474 if (vm_guest != VM_GUEST_VM) {
1479 * We are done with bnames, but there might be
1480 * a more specific match in the pnames
1486 p = kern_getenv("smbios.system.product");
1488 for (i = 0; i < nitems(vm_pnames); i++)
1489 if (strcmp(p, vm_pnames[i].vm_pname) == 0) {
1490 vm_guest = vm_pnames[i].vm_guest;
1504 * Clear "Limit CPUID Maxval" bit and return true if the caller should
1505 * get the largest standard CPUID function number again if it is set
1506 * from BIOS. It is necessary for probing correct CPU topology later
1507 * and for the correct operation of the AVX-aware userspace.
1509 if (cpu_vendor_id == CPU_VENDOR_INTEL &&
1510 ((CPUID_TO_FAMILY(cpu_id) == 0xf &&
1511 CPUID_TO_MODEL(cpu_id) >= 0x3) ||
1512 (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
1513 CPUID_TO_MODEL(cpu_id) >= 0xe))) {
1514 msr = rdmsr(MSR_IA32_MISC_ENABLE);
1515 if ((msr & IA32_MISC_EN_LIMCPUID) != 0) {
1516 msr &= ~IA32_MISC_EN_LIMCPUID;
1517 wrmsr(MSR_IA32_MISC_ENABLE, msr);
1523 * Re-enable AMD Topology Extension that could be disabled by BIOS
1524 * on some notebook processors. Without the extension it's really
1525 * hard to determine the correct CPU cache topology.
1526 * See BIOS and Kernel Developer’s Guide (BKDG) for AMD Family 15h
1527 * Models 60h-6Fh Processors, Publication # 50742.
1529 if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_AMD &&
1530 CPUID_TO_FAMILY(cpu_id) == 0x15) {
1531 msr = rdmsr(MSR_EXTFEATURES);
1532 if ((msr & ((uint64_t)1 << 54)) == 0) {
1533 msr |= (uint64_t)1 << 54;
1534 wrmsr(MSR_EXTFEATURES, msr);
1548 ((u_int *)&cpu_vendor)[0] = regs[1];
1549 ((u_int *)&cpu_vendor)[1] = regs[3];
1550 ((u_int *)&cpu_vendor)[2] = regs[2];
1551 cpu_vendor[12] = '\0';
1555 cpu_procinfo = regs[1];
1556 cpu_feature = regs[3];
1557 cpu_feature2 = regs[2];
1563 u_int regs[4], cpu_stdext_disable;
1565 if (cpu_high >= 6) {
1566 cpuid_count(6, 0, regs);
1567 cpu_power_eax = regs[0];
1568 cpu_power_ebx = regs[1];
1569 cpu_power_ecx = regs[2];
1570 cpu_power_edx = regs[3];
1573 if (cpu_high >= 7) {
1574 cpuid_count(7, 0, regs);
1575 cpu_stdext_feature = regs[1];
1578 * Some hypervisors failed to filter out unsupported
1579 * extended features. Allow to disable the
1580 * extensions, activation of which requires setting a
1581 * bit in CR4, and which VM monitors do not support.
1583 cpu_stdext_disable = 0;
1584 TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable);
1585 cpu_stdext_feature &= ~cpu_stdext_disable;
1587 cpu_stdext_feature2 = regs[2];
1588 cpu_stdext_feature3 = regs[3];
1590 if ((cpu_stdext_feature3 & CPUID_STDEXT3_ARCH_CAP) != 0)
1591 cpu_ia32_arch_caps = rdmsr(MSR_IA32_ARCH_CAP);
1596 identify_cpu_fixup_bsp(void)
1600 cpu_vendor_id = find_cpu_vendor_id();
1609 * Final stage of CPU identification.
1612 finishidentcpu(void)
1619 identify_cpu_fixup_bsp();
1621 if (cpu_high >= 5 && (cpu_feature2 & CPUID2_MON) != 0) {
1623 cpu_mon_mwait_flags = regs[2];
1624 cpu_mon_min_size = regs[0] & CPUID5_MON_MIN_SIZE;
1625 cpu_mon_max_size = regs[1] & CPUID5_MON_MAX_SIZE;
1632 (cpu_vendor_id == CPU_VENDOR_INTEL ||
1633 cpu_vendor_id == CPU_VENDOR_AMD ||
1634 cpu_vendor_id == CPU_VENDOR_TRANSMETA ||
1635 cpu_vendor_id == CPU_VENDOR_CENTAUR ||
1636 cpu_vendor_id == CPU_VENDOR_NSC)) {
1637 do_cpuid(0x80000000, regs);
1638 if (regs[0] >= 0x80000000)
1639 cpu_exthigh = regs[0];
1642 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
1643 cpu_vendor_id == CPU_VENDOR_AMD ||
1644 cpu_vendor_id == CPU_VENDOR_CENTAUR) {
1645 do_cpuid(0x80000000, regs);
1646 cpu_exthigh = regs[0];
1649 if (cpu_exthigh >= 0x80000001) {
1650 do_cpuid(0x80000001, regs);
1651 amd_feature = regs[3] & ~(cpu_feature & 0x0183f3ff);
1652 amd_feature2 = regs[2];
1654 if (cpu_exthigh >= 0x80000007) {
1655 do_cpuid(0x80000007, regs);
1656 amd_rascap = regs[1];
1657 amd_pminfo = regs[3];
1659 if (cpu_exthigh >= 0x80000008) {
1660 do_cpuid(0x80000008, regs);
1661 cpu_maxphyaddr = regs[0] & 0xff;
1662 amd_extended_feature_extensions = regs[1];
1663 cpu_procinfo2 = regs[2];
1665 cpu_maxphyaddr = (cpu_feature & CPUID_PAE) != 0 ? 36 : 32;
1669 if (cpu_vendor_id == CPU_VENDOR_CYRIX) {
1670 if (cpu == CPU_486) {
1672 * These conditions are equivalent to:
1673 * - CPU does not support cpuid instruction.
1674 * - Cyrix/IBM CPU is detected.
1676 if (identblue() == IDENTBLUE_IBMCPU) {
1677 strcpy(cpu_vendor, "IBM");
1678 cpu_vendor_id = CPU_VENDOR_IBM;
1683 switch (cpu_id & 0xf00) {
1686 * Cyrix's datasheet does not describe DIRs.
1687 * Therefor, I assume it does not have them
1688 * and use the result of the cpuid instruction.
1689 * XXX they seem to have it for now at least. -Peter
1697 * This routine contains a trick.
1698 * Don't check (cpu_id & 0x00f0) == 0x50 to detect M2, now.
1700 switch (cyrix_did & 0x00f0) {
1709 if ((cyrix_did & 0x000f) < 8)
1722 /* M2 and later CPUs are treated as M2. */
1726 * enable cpuid instruction.
1728 ccr3 = read_cyrix_reg(CCR3);
1729 write_cyrix_reg(CCR3, CCR3_MAPEN0);
1730 write_cyrix_reg(CCR4, read_cyrix_reg(CCR4) | CCR4_CPUID);
1731 write_cyrix_reg(CCR3, ccr3);
1734 cpu_high = regs[0]; /* eax */
1736 cpu_id = regs[0]; /* eax */
1737 cpu_feature = regs[3]; /* edx */
1741 } else if (cpu == CPU_486 && *cpu_vendor == '\0') {
1743 * There are BlueLightning CPUs that do not change
1744 * undefined flags by dividing 5 by 2. In this case,
1745 * the CPU identification routine in locore.s leaves
1746 * cpu_vendor null string and puts CPU_486 into the
1749 if (identblue() == IDENTBLUE_IBMCPU) {
1750 strcpy(cpu_vendor, "IBM");
1751 cpu_vendor_id = CPU_VENDOR_IBM;
1760 pti_get_default(void)
1763 if (strcmp(cpu_vendor, AMD_VENDOR_ID) == 0)
1765 if ((cpu_ia32_arch_caps & IA32_ARCH_CAP_RDCL_NO) != 0)
1771 find_cpu_vendor_id(void)
1775 for (i = 0; i < nitems(cpu_vendors); i++)
1776 if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0)
1777 return (cpu_vendors[i].vendor_id);
1782 print_AMD_assoc(int i)
1785 printf(", fully associative\n");
1787 printf(", %d-way associative\n", i);
1791 print_AMD_l2_assoc(int i)
1794 case 0: printf(", disabled/not present\n"); break;
1795 case 1: printf(", direct mapped\n"); break;
1796 case 2: printf(", 2-way associative\n"); break;
1797 case 4: printf(", 4-way associative\n"); break;
1798 case 6: printf(", 8-way associative\n"); break;
1799 case 8: printf(", 16-way associative\n"); break;
1800 case 15: printf(", fully associative\n"); break;
1801 default: printf(", reserved configuration\n"); break;
1806 print_AMD_info(void)
1813 if (cpu_exthigh >= 0x80000005) {
1814 do_cpuid(0x80000005, regs);
1815 printf("L1 2MB data TLB: %d entries", (regs[0] >> 16) & 0xff);
1816 print_AMD_assoc(regs[0] >> 24);
1818 printf("L1 2MB instruction TLB: %d entries", regs[0] & 0xff);
1819 print_AMD_assoc((regs[0] >> 8) & 0xff);
1821 printf("L1 4KB data TLB: %d entries", (regs[1] >> 16) & 0xff);
1822 print_AMD_assoc(regs[1] >> 24);
1824 printf("L1 4KB instruction TLB: %d entries", regs[1] & 0xff);
1825 print_AMD_assoc((regs[1] >> 8) & 0xff);
1827 printf("L1 data cache: %d kbytes", regs[2] >> 24);
1828 printf(", %d bytes/line", regs[2] & 0xff);
1829 printf(", %d lines/tag", (regs[2] >> 8) & 0xff);
1830 print_AMD_assoc((regs[2] >> 16) & 0xff);
1832 printf("L1 instruction cache: %d kbytes", regs[3] >> 24);
1833 printf(", %d bytes/line", regs[3] & 0xff);
1834 printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
1835 print_AMD_assoc((regs[3] >> 16) & 0xff);
1838 if (cpu_exthigh >= 0x80000006) {
1839 do_cpuid(0x80000006, regs);
1840 if ((regs[0] >> 16) != 0) {
1841 printf("L2 2MB data TLB: %d entries",
1842 (regs[0] >> 16) & 0xfff);
1843 print_AMD_l2_assoc(regs[0] >> 28);
1844 printf("L2 2MB instruction TLB: %d entries",
1846 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1848 printf("L2 2MB unified TLB: %d entries",
1850 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
1852 if ((regs[1] >> 16) != 0) {
1853 printf("L2 4KB data TLB: %d entries",
1854 (regs[1] >> 16) & 0xfff);
1855 print_AMD_l2_assoc(regs[1] >> 28);
1857 printf("L2 4KB instruction TLB: %d entries",
1858 (regs[1] >> 16) & 0xfff);
1859 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1861 printf("L2 4KB unified TLB: %d entries",
1862 (regs[1] >> 16) & 0xfff);
1863 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
1865 printf("L2 unified cache: %d kbytes", regs[2] >> 16);
1866 printf(", %d bytes/line", regs[2] & 0xff);
1867 printf(", %d lines/tag", (regs[2] >> 8) & 0x0f);
1868 print_AMD_l2_assoc((regs[2] >> 12) & 0x0f);
1872 if (((cpu_id & 0xf00) == 0x500)
1873 && (((cpu_id & 0x0f0) > 0x80)
1874 || (((cpu_id & 0x0f0) == 0x80)
1875 && (cpu_id & 0x00f) > 0x07))) {
1876 /* K6-2(new core [Stepping 8-F]), K6-III or later */
1877 amd_whcr = rdmsr(0xc0000082);
1878 if (!(amd_whcr & (0x3ff << 22))) {
1879 printf("Write Allocate Disable\n");
1881 printf("Write Allocate Enable Limit: %dM bytes\n",
1882 (u_int32_t)((amd_whcr & (0x3ff << 22)) >> 22) * 4);
1883 printf("Write Allocate 15-16M bytes: %s\n",
1884 (amd_whcr & (1 << 16)) ? "Enable" : "Disable");
1886 } else if (((cpu_id & 0xf00) == 0x500)
1887 && ((cpu_id & 0x0f0) > 0x50)) {
1888 /* K6, K6-2(old core) */
1889 amd_whcr = rdmsr(0xc0000082);
1890 if (!(amd_whcr & (0x7f << 1))) {
1891 printf("Write Allocate Disable\n");
1893 printf("Write Allocate Enable Limit: %dM bytes\n",
1894 (u_int32_t)((amd_whcr & (0x7f << 1)) >> 1) * 4);
1895 printf("Write Allocate 15-16M bytes: %s\n",
1896 (amd_whcr & 0x0001) ? "Enable" : "Disable");
1897 printf("Hardware Write Allocate Control: %s\n",
1898 (amd_whcr & 0x0100) ? "Enable" : "Disable");
1903 * Opteron Rev E shows a bug as in very rare occasions a read memory
1904 * barrier is not performed as expected if it is followed by a
1905 * non-atomic read-modify-write instruction.
1906 * As long as that bug pops up very rarely (intensive machine usage
1907 * on other operating systems generally generates one unexplainable
1908 * crash any 2 months) and as long as a model specific fix would be
1909 * impractical at this stage, print out a warning string if the broken
1910 * model and family are identified.
1912 if (CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x20 &&
1913 CPUID_TO_MODEL(cpu_id) <= 0x3f)
1914 printf("WARNING: This architecture revision has known SMP "
1915 "hardware bugs which may cause random instability\n");
1919 print_INTEL_info(void)
1922 u_int rounds, regnum;
1923 u_int nwaycode, nway;
1925 if (cpu_high >= 2) {
1928 do_cpuid(0x2, regs);
1929 if (rounds == 0 && (rounds = (regs[0] & 0xff)) == 0)
1930 break; /* we have a buggy CPU */
1932 for (regnum = 0; regnum <= 3; ++regnum) {
1933 if (regs[regnum] & (1<<31))
1936 print_INTEL_TLB(regs[regnum] & 0xff);
1937 print_INTEL_TLB((regs[regnum] >> 8) & 0xff);
1938 print_INTEL_TLB((regs[regnum] >> 16) & 0xff);
1939 print_INTEL_TLB((regs[regnum] >> 24) & 0xff);
1941 } while (--rounds > 0);
1944 if (cpu_exthigh >= 0x80000006) {
1945 do_cpuid(0x80000006, regs);
1946 nwaycode = (regs[2] >> 12) & 0x0f;
1947 if (nwaycode >= 0x02 && nwaycode <= 0x08)
1948 nway = 1 << (nwaycode / 2);
1951 printf("L2 cache: %u kbytes, %u-way associative, %u bytes/line\n",
1952 (regs[2] >> 16) & 0xffff, nway, regs[2] & 0xff);
1957 print_INTEL_TLB(u_int data)
1965 printf("Instruction TLB: 4 KB pages, 4-way set associative, 32 entries\n");
1968 printf("Instruction TLB: 4 MB pages, fully associative, 2 entries\n");
1971 printf("Data TLB: 4 KB pages, 4-way set associative, 64 entries\n");
1974 printf("Data TLB: 4 MB Pages, 4-way set associative, 8 entries\n");
1977 printf("1st-level instruction cache: 8 KB, 4-way set associative, 32 byte line size\n");
1980 printf("1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size\n");
1983 printf("1st-level instruction cache: 32 KB, 4-way set associative, 64 byte line size\n");
1986 printf("1st-level data cache: 8 KB, 2-way set associative, 32 byte line size\n");
1989 printf("Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries\n");
1992 printf("1st-level data cache: 16 KB, 4-way set associative, 32 byte line size\n");
1995 printf("1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size");
1998 printf("1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size\n");
2001 printf("2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size\n");
2004 printf("2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size\n");
2007 printf("3rd-level cache: 512 KB, 4-way set associative, sectored cache, 64 byte line size\n");
2010 printf("3rd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
2013 printf("2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size\n");
2016 printf("3rd-level cache: 2 MB, 8-way set associative, sectored cache, 64 byte line size\n");
2019 printf("3rd-level cache: 4 MB, 8-way set associative, sectored cache, 64 byte line size\n");
2022 printf("1st-level data cache: 32 KB, 8-way set associative, 64 byte line size\n");
2025 printf("1st-level instruction cache: 32 KB, 8-way set associative, 64 byte line size\n");
2027 case 0x39: /* De-listed in SDM rev. 54 */
2028 printf("2nd-level cache: 128 KB, 4-way set associative, sectored cache, 64 byte line size\n");
2030 case 0x3b: /* De-listed in SDM rev. 54 */
2031 printf("2nd-level cache: 128 KB, 2-way set associative, sectored cache, 64 byte line size\n");
2033 case 0x3c: /* De-listed in SDM rev. 54 */
2034 printf("2nd-level cache: 256 KB, 4-way set associative, sectored cache, 64 byte line size\n");
2037 printf("2nd-level cache: 128 KB, 4-way set associative, 32 byte line size\n");
2040 printf("2nd-level cache: 256 KB, 4-way set associative, 32 byte line size\n");
2043 printf("2nd-level cache: 512 KB, 4-way set associative, 32 byte line size\n");
2046 printf("2nd-level cache: 1 MB, 4-way set associative, 32 byte line size\n");
2049 printf("2nd-level cache: 2 MB, 4-way set associative, 32 byte line size\n");
2052 printf("3rd-level cache: 4 MB, 4-way set associative, 64 byte line size\n");
2055 printf("3rd-level cache: 8 MB, 8-way set associative, 64 byte line size\n");
2058 printf("2nd-level cache: 3MByte, 12-way set associative, 64 byte line size\n");
2061 if (CPUID_TO_FAMILY(cpu_id) == 0xf &&
2062 CPUID_TO_MODEL(cpu_id) == 0x6)
2063 printf("3rd-level cache: 4MB, 16-way set associative, 64-byte line size\n");
2065 printf("2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size");
2068 printf("3rd-level cache: 6MByte, 12-way set associative, 64 byte line size\n");
2071 printf("3rd-level cache: 8MByte, 16-way set associative, 64 byte line size\n");
2074 printf("3rd-level cache: 12MByte, 12-way set associative, 64 byte line size\n");
2077 printf("3rd-level cache: 16MByte, 16-way set associative, 64 byte line size\n");
2080 printf("2nd-level cache: 6MByte, 24-way set associative, 64 byte line size\n");
2083 printf("Instruction TLB: 4 KByte pages, 32 entries\n");
2086 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 64 entries\n");
2089 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 128 entries\n");
2092 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 256 entries\n");
2095 printf("Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries\n");
2098 printf("Data TLB0: 4 MByte pages, 4-way set associative, 16 entries\n");
2101 printf("Data TLB0: 4 KByte pages, 4-way associative, 16 entries\n");
2104 printf("Data TLB0: 4 KByte pages, fully associative, 16 entries\n");
2107 printf("Data TLB0: 2-MByte or 4 MByte pages, 4-way set associative, 32 entries\n");
2110 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 64 entries\n");
2113 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 128 entries\n");
2116 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 256 entries\n");
2119 printf("1st-level data cache: 16 KB, 8-way set associative, sectored cache, 64 byte line size\n");
2122 printf("Instruction TLB: 4 KByte pages, fully associative, 48 entries\n");
2125 printf("Data TLB: 2 MByte or 4 MByte pages, 4-way set associative, 32 entries and a separate array with 1 GByte pages, 4-way set associative, 4 entries\n");
2128 printf("Data TLB: 4 KBytes pages, 4-way set associative, 512 entries\n");
2131 printf("1st-level data cache: 8 KB, 4-way set associative, sectored cache, 64 byte line size\n");
2134 printf("1st-level data cache: 16 KB, 4-way set associative, sectored cache, 64 byte line size\n");
2137 printf("1st-level data cache: 32 KB, 4 way set associative, sectored cache, 64 byte line size\n");
2140 printf("uTLB: 4KByte pages, 8-way set associative, 64 entries\n");
2143 printf("DTLB: 4KByte pages, 8-way set associative, 256 entries\n");
2146 printf("DTLB: 2M/4M pages, 8-way set associative, 128 entries\n");
2149 printf("DTLB: 1 GByte pages, fully associative, 16 entries\n");
2152 printf("Trace cache: 12K-uops, 8-way set associative\n");
2155 printf("Trace cache: 16K-uops, 8-way set associative\n");
2158 printf("Trace cache: 32K-uops, 8-way set associative\n");
2161 printf("Instruction TLB: 2M/4M pages, fully associative, 8 entries\n");
2164 printf("2nd-level cache: 1 MB, 4-way set associative, 64-byte line size\n");
2167 printf("2nd-level cache: 128 KB, 8-way set associative, sectored cache, 64 byte line size\n");
2170 printf("2nd-level cache: 256 KB, 8-way set associative, sectored cache, 64 byte line size\n");
2173 printf("2nd-level cache: 512 KB, 8-way set associative, sectored cache, 64 byte line size\n");
2176 printf("2nd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n");
2179 printf("2nd-level cache: 2-MB, 8-way set associative, 64-byte line size\n");
2182 printf("2nd-level cache: 512-KB, 2-way set associative, 64-byte line size\n");
2185 printf("2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size\n");
2188 printf("2nd-level cache: 256 KB, 8-way set associative, 32 byte line size\n");
2191 printf("2nd-level cache: 512 KB, 8-way set associative, 32 byte line size\n");
2194 printf("2nd-level cache: 1 MB, 8-way set associative, 32 byte line size\n");
2197 printf("2nd-level cache: 2 MB, 8-way set associative, 32 byte line size\n");
2200 printf("2nd-level cache: 512 KB, 4-way set associative, 64 byte line size\n");
2203 printf("2nd-level cache: 1 MB, 8-way set associative, 64 byte line size\n");
2206 printf("DTLB: 4k pages, fully associative, 32 entries\n");
2209 printf("Instruction TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
2212 printf("Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries\n");
2215 printf("Instruction TLB: 4KByte pages, 4-way set associative, 64 entries\n");
2218 printf("Data TLB: 4 KB Pages, 4-way set associative, 128 entries\n");
2221 printf("Data TLB1: 4 KByte pages, 4-way associative, 256 entries\n");
2224 printf("Instruction TLB: 4KByte pages, 8-way set associative, 64 entries\n");
2227 printf("Instruction TLB: 4KByte pages, 8-way set associative, 128 entries\n");
2230 printf("Data TLB1: 4 KByte pages, 4-way associative, 64 entries\n");
2233 printf("Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries\n");
2236 printf("Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries\n");
2239 printf("DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries\n");
2242 printf("Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, 1536 entries. Also 1GBbyte pages, 4-way, 16 entries\n");
2245 printf("DTLB: 2M/4M Byte pages, 4-way associative, 32 entries\n");
2248 printf("Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries\n");
2251 printf("3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size\n");
2254 printf("3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size\n");
2257 printf("3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size\n");
2260 printf("3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size\n");
2263 printf("3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size\n");
2266 printf("3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size\n");
2269 printf("3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size\n");
2272 printf("3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size\n");
2275 printf("3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size\n");
2278 printf("3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size\n");
2281 printf("3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size\n");
2284 printf("3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size\n");
2287 printf("3rd-level cache: 12MByte, 24-way set associative, 64 byte line size\n");
2290 printf("3rd-level cache: 18MByte, 24-way set associative, 64 byte line size\n");
2293 printf("3rd-level cache: 24MByte, 24-way set associative, 64 byte line size\n");
2296 printf("64-Byte prefetching\n");
2299 printf("128-Byte prefetching\n");
2305 print_svm_info(void)
2307 u_int features, regs[4];
2312 do_cpuid(0x8000000A, regs);
2315 msr = rdmsr(MSR_VM_CR);
2316 if ((msr & VM_CR_SVMDIS) == VM_CR_SVMDIS)
2317 printf("(disabled in BIOS) ");
2321 if (features & (1 << 0)) {
2322 printf("%sNP", comma ? "," : "");
2325 if (features & (1 << 3)) {
2326 printf("%sNRIP", comma ? "," : "");
2329 if (features & (1 << 5)) {
2330 printf("%sVClean", comma ? "," : "");
2333 if (features & (1 << 6)) {
2334 printf("%sAFlush", comma ? "," : "");
2337 if (features & (1 << 7)) {
2338 printf("%sDAssist", comma ? "," : "");
2341 printf("%sNAsids=%d", comma ? "," : "", regs[1]);
2345 printf("Features=0x%b", features,
2347 "\001NP" /* Nested paging */
2348 "\002LbrVirt" /* LBR virtualization */
2349 "\003SVML" /* SVM lock */
2350 "\004NRIPS" /* NRIP save */
2351 "\005TscRateMsr" /* MSR based TSC rate control */
2352 "\006VmcbClean" /* VMCB clean bits */
2353 "\007FlushByAsid" /* Flush by ASID */
2354 "\010DecodeAssist" /* Decode assist */
2357 "\013PauseFilter" /* PAUSE intercept filter */
2358 "\014EncryptedMcodePatch"
2359 "\015PauseFilterThreshold" /* PAUSE filter threshold */
2360 "\016AVIC" /* virtual interrupt controller */
2362 "\020V_VMSAVE_VMLOAD"
2364 "\022GMET" /* Guest Mode Execute Trap */
2380 printf("\nRevision=%d, ASIDs=%d", regs[0] & 0xff, regs[1]);
2385 print_transmeta_info(void)
2387 u_int regs[4], nreg = 0;
2389 do_cpuid(0x80860000, regs);
2391 if (nreg >= 0x80860001) {
2392 do_cpuid(0x80860001, regs);
2393 printf(" Processor revision %u.%u.%u.%u\n",
2394 (regs[1] >> 24) & 0xff,
2395 (regs[1] >> 16) & 0xff,
2396 (regs[1] >> 8) & 0xff,
2399 if (nreg >= 0x80860002) {
2400 do_cpuid(0x80860002, regs);
2401 printf(" Code Morphing Software revision %u.%u.%u-%u-%u\n",
2402 (regs[1] >> 24) & 0xff,
2403 (regs[1] >> 16) & 0xff,
2404 (regs[1] >> 8) & 0xff,
2408 if (nreg >= 0x80860006) {
2410 do_cpuid(0x80860003, (u_int*) &info[0]);
2411 do_cpuid(0x80860004, (u_int*) &info[16]);
2412 do_cpuid(0x80860005, (u_int*) &info[32]);
2413 do_cpuid(0x80860006, (u_int*) &info[48]);
2415 printf(" %s\n", info);
2421 print_via_padlock_info(void)
2425 do_cpuid(0xc0000001, regs);
2426 printf("\n VIA Padlock Features=0x%b", regs[3],
2430 "\011AES-CTR" /* ACE2 */
2431 "\013SHA1,SHA256" /* PHE */
2437 vmx_settable(uint64_t basic, int msr, int true_msr)
2441 if (basic & (1ULL << 55))
2442 val = rdmsr(true_msr);
2446 /* Just report the controls that can be set to 1. */
2451 print_vmx_info(void)
2453 uint64_t basic, msr;
2454 uint32_t entry, exit, mask, pin, proc, proc2;
2457 printf("\n VT-x: ");
2458 msr = rdmsr(MSR_IA32_FEATURE_CONTROL);
2459 if (!(msr & IA32_FEATURE_CONTROL_VMX_EN))
2460 printf("(disabled in BIOS) ");
2461 basic = rdmsr(MSR_VMX_BASIC);
2462 pin = vmx_settable(basic, MSR_VMX_PINBASED_CTLS,
2463 MSR_VMX_TRUE_PINBASED_CTLS);
2464 proc = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS,
2465 MSR_VMX_TRUE_PROCBASED_CTLS);
2466 if (proc & PROCBASED_SECONDARY_CONTROLS)
2467 proc2 = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS2,
2468 MSR_VMX_PROCBASED_CTLS2);
2471 exit = vmx_settable(basic, MSR_VMX_EXIT_CTLS, MSR_VMX_TRUE_EXIT_CTLS);
2472 entry = vmx_settable(basic, MSR_VMX_ENTRY_CTLS, MSR_VMX_TRUE_ENTRY_CTLS);
2476 if (exit & VM_EXIT_SAVE_PAT && exit & VM_EXIT_LOAD_PAT &&
2477 entry & VM_ENTRY_LOAD_PAT) {
2478 printf("%sPAT", comma ? "," : "");
2481 if (proc & PROCBASED_HLT_EXITING) {
2482 printf("%sHLT", comma ? "," : "");
2485 if (proc & PROCBASED_MTF) {
2486 printf("%sMTF", comma ? "," : "");
2489 if (proc & PROCBASED_PAUSE_EXITING) {
2490 printf("%sPAUSE", comma ? "," : "");
2493 if (proc2 & PROCBASED2_ENABLE_EPT) {
2494 printf("%sEPT", comma ? "," : "");
2497 if (proc2 & PROCBASED2_UNRESTRICTED_GUEST) {
2498 printf("%sUG", comma ? "," : "");
2501 if (proc2 & PROCBASED2_ENABLE_VPID) {
2502 printf("%sVPID", comma ? "," : "");
2505 if (proc & PROCBASED_USE_TPR_SHADOW &&
2506 proc2 & PROCBASED2_VIRTUALIZE_APIC_ACCESSES &&
2507 proc2 & PROCBASED2_VIRTUALIZE_X2APIC_MODE &&
2508 proc2 & PROCBASED2_APIC_REGISTER_VIRTUALIZATION &&
2509 proc2 & PROCBASED2_VIRTUAL_INTERRUPT_DELIVERY) {
2510 printf("%sVID", comma ? "," : "");
2512 if (pin & PINBASED_POSTED_INTERRUPT)
2513 printf(",PostIntr");
2519 printf("Basic Features=0x%b", mask,
2521 "\02132PA" /* 32-bit physical addresses */
2522 "\022SMM" /* SMM dual-monitor */
2523 "\027INS/OUTS" /* VM-exit info for INS and OUTS */
2524 "\030TRUE" /* TRUE_CTLS MSRs */
2526 printf("\n Pin-Based Controls=0x%b", pin,
2528 "\001ExtINT" /* External-interrupt exiting */
2529 "\004NMI" /* NMI exiting */
2530 "\006VNMI" /* Virtual NMIs */
2531 "\007PreTmr" /* Activate VMX-preemption timer */
2532 "\010PostIntr" /* Process posted interrupts */
2534 printf("\n Primary Processor Controls=0x%b", proc,
2536 "\003INTWIN" /* Interrupt-window exiting */
2537 "\004TSCOff" /* Use TSC offsetting */
2538 "\010HLT" /* HLT exiting */
2539 "\012INVLPG" /* INVLPG exiting */
2540 "\013MWAIT" /* MWAIT exiting */
2541 "\014RDPMC" /* RDPMC exiting */
2542 "\015RDTSC" /* RDTSC exiting */
2543 "\020CR3-LD" /* CR3-load exiting */
2544 "\021CR3-ST" /* CR3-store exiting */
2545 "\024CR8-LD" /* CR8-load exiting */
2546 "\025CR8-ST" /* CR8-store exiting */
2547 "\026TPR" /* Use TPR shadow */
2548 "\027NMIWIN" /* NMI-window exiting */
2549 "\030MOV-DR" /* MOV-DR exiting */
2550 "\031IO" /* Unconditional I/O exiting */
2551 "\032IOmap" /* Use I/O bitmaps */
2552 "\034MTF" /* Monitor trap flag */
2553 "\035MSRmap" /* Use MSR bitmaps */
2554 "\036MONITOR" /* MONITOR exiting */
2555 "\037PAUSE" /* PAUSE exiting */
2557 if (proc & PROCBASED_SECONDARY_CONTROLS)
2558 printf("\n Secondary Processor Controls=0x%b", proc2,
2560 "\001APIC" /* Virtualize APIC accesses */
2561 "\002EPT" /* Enable EPT */
2562 "\003DT" /* Descriptor-table exiting */
2563 "\004RDTSCP" /* Enable RDTSCP */
2564 "\005x2APIC" /* Virtualize x2APIC mode */
2565 "\006VPID" /* Enable VPID */
2566 "\007WBINVD" /* WBINVD exiting */
2567 "\010UG" /* Unrestricted guest */
2568 "\011APIC-reg" /* APIC-register virtualization */
2569 "\012VID" /* Virtual-interrupt delivery */
2570 "\013PAUSE-loop" /* PAUSE-loop exiting */
2571 "\014RDRAND" /* RDRAND exiting */
2572 "\015INVPCID" /* Enable INVPCID */
2573 "\016VMFUNC" /* Enable VM functions */
2574 "\017VMCS" /* VMCS shadowing */
2575 "\020EPT#VE" /* EPT-violation #VE */
2576 "\021XSAVES" /* Enable XSAVES/XRSTORS */
2578 printf("\n Exit Controls=0x%b", mask,
2580 "\003DR" /* Save debug controls */
2581 /* Ignore Host address-space size */
2582 "\015PERF" /* Load MSR_PERF_GLOBAL_CTRL */
2583 "\020AckInt" /* Acknowledge interrupt on exit */
2584 "\023PAT-SV" /* Save MSR_PAT */
2585 "\024PAT-LD" /* Load MSR_PAT */
2586 "\025EFER-SV" /* Save MSR_EFER */
2587 "\026EFER-LD" /* Load MSR_EFER */
2588 "\027PTMR-SV" /* Save VMX-preemption timer value */
2590 printf("\n Entry Controls=0x%b", mask,
2592 "\003DR" /* Save debug controls */
2593 /* Ignore IA-32e mode guest */
2594 /* Ignore Entry to SMM */
2595 /* Ignore Deactivate dual-monitor treatment */
2596 "\016PERF" /* Load MSR_PERF_GLOBAL_CTRL */
2597 "\017PAT" /* Load MSR_PAT */
2598 "\020EFER" /* Load MSR_EFER */
2600 if (proc & PROCBASED_SECONDARY_CONTROLS &&
2601 (proc2 & (PROCBASED2_ENABLE_EPT | PROCBASED2_ENABLE_VPID)) != 0) {
2602 msr = rdmsr(MSR_VMX_EPT_VPID_CAP);
2604 printf("\n EPT Features=0x%b", mask,
2606 "\001XO" /* Execute-only translations */
2607 "\007PW4" /* Page-walk length of 4 */
2608 "\011UC" /* EPT paging-structure mem can be UC */
2609 "\017WB" /* EPT paging-structure mem can be WB */
2610 "\0212M" /* EPT PDE can map a 2-Mbyte page */
2611 "\0221G" /* EPT PDPTE can map a 1-Gbyte page */
2612 "\025INVEPT" /* INVEPT is supported */
2613 "\026AD" /* Accessed and dirty flags for EPT */
2614 "\032single" /* INVEPT single-context type */
2615 "\033all" /* INVEPT all-context type */
2618 printf("\n VPID Features=0x%b", mask,
2620 "\001INVVPID" /* INVVPID is supported */
2621 "\011individual" /* INVVPID individual-address type */
2622 "\012single" /* INVVPID single-context type */
2623 "\013all" /* INVVPID all-context type */
2624 /* INVVPID single-context-retaining-globals type */
2625 "\014single-globals"
2631 print_hypervisor_info(void)
2634 if (*hv_vendor != '\0')
2635 printf("Hypervisor: Origin = \"%s\"\n", hv_vendor);
2639 * Returns the maximum physical address that can be used with the
2643 cpu_getmaxphyaddr(void)
2646 #if defined(__i386__)
2648 return (0xffffffff);
2650 return ((1ULL << cpu_maxphyaddr) - 1);