identcpu.c revision 340609
1/*- 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. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * William Jolitz. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 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. 25 * 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 36 * SUCH DAMAGE. 37 * 38 * from: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp 39 */ 40 41#include <sys/cdefs.h> 42__FBSDID("$FreeBSD: stable/11/sys/x86/x86/identcpu.c 340609 2018-11-19 06:07:17Z kib $"); 43 44#include "opt_cpu.h" 45 46#include <sys/param.h> 47#include <sys/bus.h> 48#include <sys/cpu.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> 55 56#include <machine/asmacros.h> 57#include <machine/clock.h> 58#include <machine/cputypes.h> 59#include <machine/frame.h> 60#include <machine/intr_machdep.h> 61#include <machine/md_var.h> 62#include <machine/segments.h> 63#include <machine/specialreg.h> 64 65#include <amd64/vmm/intel/vmx_controls.h> 66#include <x86/isa/icu.h> 67#include <x86/vmware.h> 68 69#ifdef __i386__ 70#define IDENTBLUE_CYRIX486 0 71#define IDENTBLUE_IBMCPU 1 72#define IDENTBLUE_CYRIXM2 2 73 74static void identifycyrix(void); 75static void print_transmeta_info(void); 76#endif 77static u_int find_cpu_vendor_id(void); 78static void print_AMD_info(void); 79static void print_INTEL_info(void); 80static void print_INTEL_TLB(u_int data); 81static void print_hypervisor_info(void); 82static void print_svm_info(void); 83static void print_via_padlock_info(void); 84static void print_vmx_info(void); 85 86#ifdef __i386__ 87int cpu; /* Are we 386, 386sx, 486, etc? */ 88int cpu_class; 89#endif 90u_int cpu_feature; /* Feature flags */ 91u_int cpu_feature2; /* Feature flags */ 92u_int amd_feature; /* AMD feature flags */ 93u_int amd_feature2; /* AMD feature flags */ 94u_int amd_pminfo; /* AMD advanced power management info */ 95u_int amd_extended_feature_extensions; 96u_int via_feature_rng; /* VIA RNG features */ 97u_int via_feature_xcrypt; /* VIA ACE features */ 98u_int cpu_high; /* Highest arg to CPUID */ 99u_int cpu_exthigh; /* Highest arg to extended CPUID */ 100u_int cpu_id; /* Stepping ID */ 101u_int cpu_procinfo; /* HyperThreading Info / Brand Index / CLFUSH */ 102u_int cpu_procinfo2; /* Multicore info */ 103char cpu_vendor[20]; /* CPU Origin code */ 104u_int cpu_vendor_id; /* CPU vendor ID */ 105u_int cpu_fxsr; /* SSE enabled */ 106u_int cpu_mxcsr_mask; /* Valid bits in mxcsr */ 107u_int cpu_clflush_line_size = 32; 108u_int cpu_stdext_feature; /* %ebx */ 109u_int cpu_stdext_feature2; /* %ecx */ 110u_int cpu_stdext_feature3; /* %edx */ 111uint64_t cpu_ia32_arch_caps; 112u_int cpu_max_ext_state_size; 113u_int cpu_mon_mwait_flags; /* MONITOR/MWAIT flags (CPUID.05H.ECX) */ 114u_int cpu_mon_min_size; /* MONITOR minimum range size, bytes */ 115u_int cpu_mon_max_size; /* MONITOR minimum range size, bytes */ 116u_int cpu_maxphyaddr; /* Max phys addr width in bits */ 117char machine[] = MACHINE; 118 119SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD, 120 &via_feature_rng, 0, 121 "VIA RNG feature available in CPU"); 122SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD, 123 &via_feature_xcrypt, 0, 124 "VIA xcrypt feature available in CPU"); 125 126#ifdef __amd64__ 127#ifdef SCTL_MASK32 128extern int adaptive_machine_arch; 129#endif 130 131static int 132sysctl_hw_machine(SYSCTL_HANDLER_ARGS) 133{ 134#ifdef SCTL_MASK32 135 static const char machine32[] = "i386"; 136#endif 137 int error; 138 139#ifdef SCTL_MASK32 140 if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch) 141 error = SYSCTL_OUT(req, machine32, sizeof(machine32)); 142 else 143#endif 144 error = SYSCTL_OUT(req, machine, sizeof(machine)); 145 return (error); 146 147} 148SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD | 149 CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A", "Machine class"); 150#else 151SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, 152 machine, 0, "Machine class"); 153#endif 154 155static char cpu_model[128]; 156SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD | CTLFLAG_MPSAFE, 157 cpu_model, 0, "Machine model"); 158 159static int hw_clockrate; 160SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD, 161 &hw_clockrate, 0, "CPU instruction clock rate"); 162 163u_int hv_high; 164char hv_vendor[16]; 165SYSCTL_STRING(_hw, OID_AUTO, hv_vendor, CTLFLAG_RD | CTLFLAG_MPSAFE, hv_vendor, 166 0, "Hypervisor vendor"); 167 168static eventhandler_tag tsc_post_tag; 169 170static char cpu_brand[48]; 171 172#ifdef __i386__ 173#define MAX_BRAND_INDEX 8 174 175static const char *cpu_brandtable[MAX_BRAND_INDEX + 1] = { 176 NULL, /* No brand */ 177 "Intel Celeron", 178 "Intel Pentium III", 179 "Intel Pentium III Xeon", 180 NULL, 181 NULL, 182 NULL, 183 NULL, 184 "Intel Pentium 4" 185}; 186 187static struct { 188 char *cpu_name; 189 int cpu_class; 190} cpus[] = { 191 { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */ 192 { "i386SX", CPUCLASS_386 }, /* CPU_386SX */ 193 { "i386DX", CPUCLASS_386 }, /* CPU_386 */ 194 { "i486SX", CPUCLASS_486 }, /* CPU_486SX */ 195 { "i486DX", CPUCLASS_486 }, /* CPU_486 */ 196 { "Pentium", CPUCLASS_586 }, /* CPU_586 */ 197 { "Cyrix 486", CPUCLASS_486 }, /* CPU_486DLC */ 198 { "Pentium Pro", CPUCLASS_686 }, /* CPU_686 */ 199 { "Cyrix 5x86", CPUCLASS_486 }, /* CPU_M1SC */ 200 { "Cyrix 6x86", CPUCLASS_486 }, /* CPU_M1 */ 201 { "Blue Lightning", CPUCLASS_486 }, /* CPU_BLUE */ 202 { "Cyrix 6x86MX", CPUCLASS_686 }, /* CPU_M2 */ 203 { "NexGen 586", CPUCLASS_386 }, /* CPU_NX586 (XXX) */ 204 { "Cyrix 486S/DX", CPUCLASS_486 }, /* CPU_CY486DX */ 205 { "Pentium II", CPUCLASS_686 }, /* CPU_PII */ 206 { "Pentium III", CPUCLASS_686 }, /* CPU_PIII */ 207 { "Pentium 4", CPUCLASS_686 }, /* CPU_P4 */ 208}; 209#endif 210 211static struct { 212 char *vendor; 213 u_int vendor_id; 214} cpu_vendors[] = { 215 { INTEL_VENDOR_ID, CPU_VENDOR_INTEL }, /* GenuineIntel */ 216 { AMD_VENDOR_ID, CPU_VENDOR_AMD }, /* AuthenticAMD */ 217 { CENTAUR_VENDOR_ID, CPU_VENDOR_CENTAUR }, /* CentaurHauls */ 218#ifdef __i386__ 219 { NSC_VENDOR_ID, CPU_VENDOR_NSC }, /* Geode by NSC */ 220 { CYRIX_VENDOR_ID, CPU_VENDOR_CYRIX }, /* CyrixInstead */ 221 { TRANSMETA_VENDOR_ID, CPU_VENDOR_TRANSMETA }, /* GenuineTMx86 */ 222 { SIS_VENDOR_ID, CPU_VENDOR_SIS }, /* SiS SiS SiS */ 223 { UMC_VENDOR_ID, CPU_VENDOR_UMC }, /* UMC UMC UMC */ 224 { NEXGEN_VENDOR_ID, CPU_VENDOR_NEXGEN }, /* NexGenDriven */ 225 { RISE_VENDOR_ID, CPU_VENDOR_RISE }, /* RiseRiseRise */ 226#if 0 227 /* XXX CPUID 8000_0000h and 8086_0000h, not 0000_0000h */ 228 { "TransmetaCPU", CPU_VENDOR_TRANSMETA }, 229#endif 230#endif 231}; 232 233void 234printcpuinfo(void) 235{ 236 u_int regs[4], i; 237 char *brand; 238 239 printf("CPU: "); 240#ifdef __i386__ 241 cpu_class = cpus[cpu].cpu_class; 242 strncpy(cpu_model, cpus[cpu].cpu_name, sizeof (cpu_model)); 243#else 244 strncpy(cpu_model, "Hammer", sizeof (cpu_model)); 245#endif 246 247 /* Check for extended CPUID information and a processor name. */ 248 if (cpu_exthigh >= 0x80000004) { 249 brand = cpu_brand; 250 for (i = 0x80000002; i < 0x80000005; i++) { 251 do_cpuid(i, regs); 252 memcpy(brand, regs, sizeof(regs)); 253 brand += sizeof(regs); 254 } 255 } 256 257 switch (cpu_vendor_id) { 258 case CPU_VENDOR_INTEL: 259#ifdef __i386__ 260 if ((cpu_id & 0xf00) > 0x300) { 261 u_int brand_index; 262 263 cpu_model[0] = '\0'; 264 265 switch (cpu_id & 0x3000) { 266 case 0x1000: 267 strcpy(cpu_model, "Overdrive "); 268 break; 269 case 0x2000: 270 strcpy(cpu_model, "Dual "); 271 break; 272 } 273 274 switch (cpu_id & 0xf00) { 275 case 0x400: 276 strcat(cpu_model, "i486 "); 277 /* Check the particular flavor of 486 */ 278 switch (cpu_id & 0xf0) { 279 case 0x00: 280 case 0x10: 281 strcat(cpu_model, "DX"); 282 break; 283 case 0x20: 284 strcat(cpu_model, "SX"); 285 break; 286 case 0x30: 287 strcat(cpu_model, "DX2"); 288 break; 289 case 0x40: 290 strcat(cpu_model, "SL"); 291 break; 292 case 0x50: 293 strcat(cpu_model, "SX2"); 294 break; 295 case 0x70: 296 strcat(cpu_model, 297 "DX2 Write-Back Enhanced"); 298 break; 299 case 0x80: 300 strcat(cpu_model, "DX4"); 301 break; 302 } 303 break; 304 case 0x500: 305 /* Check the particular flavor of 586 */ 306 strcat(cpu_model, "Pentium"); 307 switch (cpu_id & 0xf0) { 308 case 0x00: 309 strcat(cpu_model, " A-step"); 310 break; 311 case 0x10: 312 strcat(cpu_model, "/P5"); 313 break; 314 case 0x20: 315 strcat(cpu_model, "/P54C"); 316 break; 317 case 0x30: 318 strcat(cpu_model, "/P24T"); 319 break; 320 case 0x40: 321 strcat(cpu_model, "/P55C"); 322 break; 323 case 0x70: 324 strcat(cpu_model, "/P54C"); 325 break; 326 case 0x80: 327 strcat(cpu_model, "/P55C (quarter-micron)"); 328 break; 329 default: 330 /* nothing */ 331 break; 332 } 333#if defined(I586_CPU) && !defined(NO_F00F_HACK) 334 /* 335 * XXX - If/when Intel fixes the bug, this 336 * should also check the version of the 337 * CPU, not just that it's a Pentium. 338 */ 339 has_f00f_bug = 1; 340#endif 341 break; 342 case 0x600: 343 /* Check the particular flavor of 686 */ 344 switch (cpu_id & 0xf0) { 345 case 0x00: 346 strcat(cpu_model, "Pentium Pro A-step"); 347 break; 348 case 0x10: 349 strcat(cpu_model, "Pentium Pro"); 350 break; 351 case 0x30: 352 case 0x50: 353 case 0x60: 354 strcat(cpu_model, 355 "Pentium II/Pentium II Xeon/Celeron"); 356 cpu = CPU_PII; 357 break; 358 case 0x70: 359 case 0x80: 360 case 0xa0: 361 case 0xb0: 362 strcat(cpu_model, 363 "Pentium III/Pentium III Xeon/Celeron"); 364 cpu = CPU_PIII; 365 break; 366 default: 367 strcat(cpu_model, "Unknown 80686"); 368 break; 369 } 370 break; 371 case 0xf00: 372 strcat(cpu_model, "Pentium 4"); 373 cpu = CPU_P4; 374 break; 375 default: 376 strcat(cpu_model, "unknown"); 377 break; 378 } 379 380 /* 381 * If we didn't get a brand name from the extended 382 * CPUID, try to look it up in the brand table. 383 */ 384 if (cpu_high > 0 && *cpu_brand == '\0') { 385 brand_index = cpu_procinfo & CPUID_BRAND_INDEX; 386 if (brand_index <= MAX_BRAND_INDEX && 387 cpu_brandtable[brand_index] != NULL) 388 strcpy(cpu_brand, 389 cpu_brandtable[brand_index]); 390 } 391 } 392#else 393 /* Please make up your mind folks! */ 394 strcat(cpu_model, "EM64T"); 395#endif 396 break; 397 case CPU_VENDOR_AMD: 398 /* 399 * Values taken from AMD Processor Recognition 400 * http://www.amd.com/K6/k6docs/pdf/20734g.pdf 401 * (also describes ``Features'' encodings. 402 */ 403 strcpy(cpu_model, "AMD "); 404#ifdef __i386__ 405 switch (cpu_id & 0xFF0) { 406 case 0x410: 407 strcat(cpu_model, "Standard Am486DX"); 408 break; 409 case 0x430: 410 strcat(cpu_model, "Enhanced Am486DX2 Write-Through"); 411 break; 412 case 0x470: 413 strcat(cpu_model, "Enhanced Am486DX2 Write-Back"); 414 break; 415 case 0x480: 416 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Through"); 417 break; 418 case 0x490: 419 strcat(cpu_model, "Enhanced Am486DX4/Am5x86 Write-Back"); 420 break; 421 case 0x4E0: 422 strcat(cpu_model, "Am5x86 Write-Through"); 423 break; 424 case 0x4F0: 425 strcat(cpu_model, "Am5x86 Write-Back"); 426 break; 427 case 0x500: 428 strcat(cpu_model, "K5 model 0"); 429 break; 430 case 0x510: 431 strcat(cpu_model, "K5 model 1"); 432 break; 433 case 0x520: 434 strcat(cpu_model, "K5 PR166 (model 2)"); 435 break; 436 case 0x530: 437 strcat(cpu_model, "K5 PR200 (model 3)"); 438 break; 439 case 0x560: 440 strcat(cpu_model, "K6"); 441 break; 442 case 0x570: 443 strcat(cpu_model, "K6 266 (model 1)"); 444 break; 445 case 0x580: 446 strcat(cpu_model, "K6-2"); 447 break; 448 case 0x590: 449 strcat(cpu_model, "K6-III"); 450 break; 451 case 0x5a0: 452 strcat(cpu_model, "Geode LX"); 453 break; 454 default: 455 strcat(cpu_model, "Unknown"); 456 break; 457 } 458#else 459 if ((cpu_id & 0xf00) == 0xf00) 460 strcat(cpu_model, "AMD64 Processor"); 461 else 462 strcat(cpu_model, "Unknown"); 463#endif 464 break; 465#ifdef __i386__ 466 case CPU_VENDOR_CYRIX: 467 strcpy(cpu_model, "Cyrix "); 468 switch (cpu_id & 0xff0) { 469 case 0x440: 470 strcat(cpu_model, "MediaGX"); 471 break; 472 case 0x520: 473 strcat(cpu_model, "6x86"); 474 break; 475 case 0x540: 476 cpu_class = CPUCLASS_586; 477 strcat(cpu_model, "GXm"); 478 break; 479 case 0x600: 480 strcat(cpu_model, "6x86MX"); 481 break; 482 default: 483 /* 484 * Even though CPU supports the cpuid 485 * instruction, it can be disabled. 486 * Therefore, this routine supports all Cyrix 487 * CPUs. 488 */ 489 switch (cyrix_did & 0xf0) { 490 case 0x00: 491 switch (cyrix_did & 0x0f) { 492 case 0x00: 493 strcat(cpu_model, "486SLC"); 494 break; 495 case 0x01: 496 strcat(cpu_model, "486DLC"); 497 break; 498 case 0x02: 499 strcat(cpu_model, "486SLC2"); 500 break; 501 case 0x03: 502 strcat(cpu_model, "486DLC2"); 503 break; 504 case 0x04: 505 strcat(cpu_model, "486SRx"); 506 break; 507 case 0x05: 508 strcat(cpu_model, "486DRx"); 509 break; 510 case 0x06: 511 strcat(cpu_model, "486SRx2"); 512 break; 513 case 0x07: 514 strcat(cpu_model, "486DRx2"); 515 break; 516 case 0x08: 517 strcat(cpu_model, "486SRu"); 518 break; 519 case 0x09: 520 strcat(cpu_model, "486DRu"); 521 break; 522 case 0x0a: 523 strcat(cpu_model, "486SRu2"); 524 break; 525 case 0x0b: 526 strcat(cpu_model, "486DRu2"); 527 break; 528 default: 529 strcat(cpu_model, "Unknown"); 530 break; 531 } 532 break; 533 case 0x10: 534 switch (cyrix_did & 0x0f) { 535 case 0x00: 536 strcat(cpu_model, "486S"); 537 break; 538 case 0x01: 539 strcat(cpu_model, "486S2"); 540 break; 541 case 0x02: 542 strcat(cpu_model, "486Se"); 543 break; 544 case 0x03: 545 strcat(cpu_model, "486S2e"); 546 break; 547 case 0x0a: 548 strcat(cpu_model, "486DX"); 549 break; 550 case 0x0b: 551 strcat(cpu_model, "486DX2"); 552 break; 553 case 0x0f: 554 strcat(cpu_model, "486DX4"); 555 break; 556 default: 557 strcat(cpu_model, "Unknown"); 558 break; 559 } 560 break; 561 case 0x20: 562 if ((cyrix_did & 0x0f) < 8) 563 strcat(cpu_model, "6x86"); /* Where did you get it? */ 564 else 565 strcat(cpu_model, "5x86"); 566 break; 567 case 0x30: 568 strcat(cpu_model, "6x86"); 569 break; 570 case 0x40: 571 if ((cyrix_did & 0xf000) == 0x3000) { 572 cpu_class = CPUCLASS_586; 573 strcat(cpu_model, "GXm"); 574 } else 575 strcat(cpu_model, "MediaGX"); 576 break; 577 case 0x50: 578 strcat(cpu_model, "6x86MX"); 579 break; 580 case 0xf0: 581 switch (cyrix_did & 0x0f) { 582 case 0x0d: 583 strcat(cpu_model, "Overdrive CPU"); 584 break; 585 case 0x0e: 586 strcpy(cpu_model, "Texas Instruments 486SXL"); 587 break; 588 case 0x0f: 589 strcat(cpu_model, "486SLC/DLC"); 590 break; 591 default: 592 strcat(cpu_model, "Unknown"); 593 break; 594 } 595 break; 596 default: 597 strcat(cpu_model, "Unknown"); 598 break; 599 } 600 break; 601 } 602 break; 603 case CPU_VENDOR_RISE: 604 strcpy(cpu_model, "Rise "); 605 switch (cpu_id & 0xff0) { 606 case 0x500: /* 6401 and 6441 (Kirin) */ 607 case 0x520: /* 6510 (Lynx) */ 608 strcat(cpu_model, "mP6"); 609 break; 610 default: 611 strcat(cpu_model, "Unknown"); 612 } 613 break; 614#endif 615 case CPU_VENDOR_CENTAUR: 616#ifdef __i386__ 617 switch (cpu_id & 0xff0) { 618 case 0x540: 619 strcpy(cpu_model, "IDT WinChip C6"); 620 break; 621 case 0x580: 622 strcpy(cpu_model, "IDT WinChip 2"); 623 break; 624 case 0x590: 625 strcpy(cpu_model, "IDT WinChip 3"); 626 break; 627 case 0x660: 628 strcpy(cpu_model, "VIA C3 Samuel"); 629 break; 630 case 0x670: 631 if (cpu_id & 0x8) 632 strcpy(cpu_model, "VIA C3 Ezra"); 633 else 634 strcpy(cpu_model, "VIA C3 Samuel 2"); 635 break; 636 case 0x680: 637 strcpy(cpu_model, "VIA C3 Ezra-T"); 638 break; 639 case 0x690: 640 strcpy(cpu_model, "VIA C3 Nehemiah"); 641 break; 642 case 0x6a0: 643 case 0x6d0: 644 strcpy(cpu_model, "VIA C7 Esther"); 645 break; 646 case 0x6f0: 647 strcpy(cpu_model, "VIA Nano"); 648 break; 649 default: 650 strcpy(cpu_model, "VIA/IDT Unknown"); 651 } 652#else 653 strcpy(cpu_model, "VIA "); 654 if ((cpu_id & 0xff0) == 0x6f0) 655 strcat(cpu_model, "Nano Processor"); 656 else 657 strcat(cpu_model, "Unknown"); 658#endif 659 break; 660#ifdef __i386__ 661 case CPU_VENDOR_IBM: 662 strcpy(cpu_model, "Blue Lightning CPU"); 663 break; 664 case CPU_VENDOR_NSC: 665 switch (cpu_id & 0xff0) { 666 case 0x540: 667 strcpy(cpu_model, "Geode SC1100"); 668 cpu = CPU_GEODE1100; 669 break; 670 default: 671 strcpy(cpu_model, "Geode/NSC unknown"); 672 break; 673 } 674 break; 675#endif 676 default: 677 strcat(cpu_model, "Unknown"); 678 break; 679 } 680 681 /* 682 * Replace cpu_model with cpu_brand minus leading spaces if 683 * we have one. 684 */ 685 brand = cpu_brand; 686 while (*brand == ' ') 687 ++brand; 688 if (*brand != '\0') 689 strcpy(cpu_model, brand); 690 691 printf("%s (", cpu_model); 692 if (tsc_freq != 0) { 693 hw_clockrate = (tsc_freq + 5000) / 1000000; 694 printf("%jd.%02d-MHz ", 695 (intmax_t)(tsc_freq + 4999) / 1000000, 696 (u_int)((tsc_freq + 4999) / 10000) % 100); 697 } 698#ifdef __i386__ 699 switch(cpu_class) { 700 case CPUCLASS_286: 701 printf("286"); 702 break; 703 case CPUCLASS_386: 704 printf("386"); 705 break; 706#if defined(I486_CPU) 707 case CPUCLASS_486: 708 printf("486"); 709 break; 710#endif 711#if defined(I586_CPU) 712 case CPUCLASS_586: 713 printf("586"); 714 break; 715#endif 716#if defined(I686_CPU) 717 case CPUCLASS_686: 718 printf("686"); 719 break; 720#endif 721 default: 722 printf("Unknown"); /* will panic below... */ 723 } 724#else 725 printf("K8"); 726#endif 727 printf("-class CPU)\n"); 728 if (*cpu_vendor) 729 printf(" Origin=\"%s\"", cpu_vendor); 730 if (cpu_id) 731 printf(" Id=0x%x", cpu_id); 732 733 if (cpu_vendor_id == CPU_VENDOR_INTEL || 734 cpu_vendor_id == CPU_VENDOR_AMD || 735 cpu_vendor_id == CPU_VENDOR_CENTAUR || 736#ifdef __i386__ 737 cpu_vendor_id == CPU_VENDOR_TRANSMETA || 738 cpu_vendor_id == CPU_VENDOR_RISE || 739 cpu_vendor_id == CPU_VENDOR_NSC || 740 (cpu_vendor_id == CPU_VENDOR_CYRIX && ((cpu_id & 0xf00) > 0x500)) || 741#endif 742 0) { 743 printf(" Family=0x%x", CPUID_TO_FAMILY(cpu_id)); 744 printf(" Model=0x%x", CPUID_TO_MODEL(cpu_id)); 745 printf(" Stepping=%u", cpu_id & CPUID_STEPPING); 746#ifdef __i386__ 747 if (cpu_vendor_id == CPU_VENDOR_CYRIX) 748 printf("\n DIR=0x%04x", cyrix_did); 749#endif 750 751 /* 752 * AMD CPUID Specification 753 * http://support.amd.com/us/Embedded_TechDocs/25481.pdf 754 * 755 * Intel Processor Identification and CPUID Instruction 756 * http://www.intel.com/assets/pdf/appnote/241618.pdf 757 */ 758 if (cpu_high > 0) { 759 760 /* 761 * Here we should probably set up flags indicating 762 * whether or not various features are available. 763 * The interesting ones are probably VME, PSE, PAE, 764 * and PGE. The code already assumes without bothering 765 * to check that all CPUs >= Pentium have a TSC and 766 * MSRs. 767 */ 768 printf("\n Features=0x%b", cpu_feature, 769 "\020" 770 "\001FPU" /* Integral FPU */ 771 "\002VME" /* Extended VM86 mode support */ 772 "\003DE" /* Debugging Extensions (CR4.DE) */ 773 "\004PSE" /* 4MByte page tables */ 774 "\005TSC" /* Timestamp counter */ 775 "\006MSR" /* Machine specific registers */ 776 "\007PAE" /* Physical address extension */ 777 "\010MCE" /* Machine Check support */ 778 "\011CX8" /* CMPEXCH8 instruction */ 779 "\012APIC" /* SMP local APIC */ 780 "\013oldMTRR" /* Previous implementation of MTRR */ 781 "\014SEP" /* Fast System Call */ 782 "\015MTRR" /* Memory Type Range Registers */ 783 "\016PGE" /* PG_G (global bit) support */ 784 "\017MCA" /* Machine Check Architecture */ 785 "\020CMOV" /* CMOV instruction */ 786 "\021PAT" /* Page attributes table */ 787 "\022PSE36" /* 36 bit address space support */ 788 "\023PN" /* Processor Serial number */ 789 "\024CLFLUSH" /* Has the CLFLUSH instruction */ 790 "\025<b20>" 791 "\026DTS" /* Debug Trace Store */ 792 "\027ACPI" /* ACPI support */ 793 "\030MMX" /* MMX instructions */ 794 "\031FXSR" /* FXSAVE/FXRSTOR */ 795 "\032SSE" /* Streaming SIMD Extensions */ 796 "\033SSE2" /* Streaming SIMD Extensions #2 */ 797 "\034SS" /* Self snoop */ 798 "\035HTT" /* Hyperthreading (see EBX bit 16-23) */ 799 "\036TM" /* Thermal Monitor clock slowdown */ 800 "\037IA64" /* CPU can execute IA64 instructions */ 801 "\040PBE" /* Pending Break Enable */ 802 ); 803 804 if (cpu_feature2 != 0) { 805 printf("\n Features2=0x%b", cpu_feature2, 806 "\020" 807 "\001SSE3" /* SSE3 */ 808 "\002PCLMULQDQ" /* Carry-Less Mul Quadword */ 809 "\003DTES64" /* 64-bit Debug Trace */ 810 "\004MON" /* MONITOR/MWAIT Instructions */ 811 "\005DS_CPL" /* CPL Qualified Debug Store */ 812 "\006VMX" /* Virtual Machine Extensions */ 813 "\007SMX" /* Safer Mode Extensions */ 814 "\010EST" /* Enhanced SpeedStep */ 815 "\011TM2" /* Thermal Monitor 2 */ 816 "\012SSSE3" /* SSSE3 */ 817 "\013CNXT-ID" /* L1 context ID available */ 818 "\014SDBG" /* IA32 silicon debug */ 819 "\015FMA" /* Fused Multiply Add */ 820 "\016CX16" /* CMPXCHG16B Instruction */ 821 "\017xTPR" /* Send Task Priority Messages*/ 822 "\020PDCM" /* Perf/Debug Capability MSR */ 823 "\021<b16>" 824 "\022PCID" /* Process-context Identifiers*/ 825 "\023DCA" /* Direct Cache Access */ 826 "\024SSE4.1" /* SSE 4.1 */ 827 "\025SSE4.2" /* SSE 4.2 */ 828 "\026x2APIC" /* xAPIC Extensions */ 829 "\027MOVBE" /* MOVBE Instruction */ 830 "\030POPCNT" /* POPCNT Instruction */ 831 "\031TSCDLT" /* TSC-Deadline Timer */ 832 "\032AESNI" /* AES Crypto */ 833 "\033XSAVE" /* XSAVE/XRSTOR States */ 834 "\034OSXSAVE" /* OS-Enabled State Management*/ 835 "\035AVX" /* Advanced Vector Extensions */ 836 "\036F16C" /* Half-precision conversions */ 837 "\037RDRAND" /* RDRAND Instruction */ 838 "\040HV" /* Hypervisor */ 839 ); 840 } 841 842 if (amd_feature != 0) { 843 printf("\n AMD Features=0x%b", amd_feature, 844 "\020" /* in hex */ 845 "\001<s0>" /* Same */ 846 "\002<s1>" /* Same */ 847 "\003<s2>" /* Same */ 848 "\004<s3>" /* Same */ 849 "\005<s4>" /* Same */ 850 "\006<s5>" /* Same */ 851 "\007<s6>" /* Same */ 852 "\010<s7>" /* Same */ 853 "\011<s8>" /* Same */ 854 "\012<s9>" /* Same */ 855 "\013<b10>" /* Undefined */ 856 "\014SYSCALL" /* Have SYSCALL/SYSRET */ 857 "\015<s12>" /* Same */ 858 "\016<s13>" /* Same */ 859 "\017<s14>" /* Same */ 860 "\020<s15>" /* Same */ 861 "\021<s16>" /* Same */ 862 "\022<s17>" /* Same */ 863 "\023<b18>" /* Reserved, unknown */ 864 "\024MP" /* Multiprocessor Capable */ 865 "\025NX" /* Has EFER.NXE, NX */ 866 "\026<b21>" /* Undefined */ 867 "\027MMX+" /* AMD MMX Extensions */ 868 "\030<s23>" /* Same */ 869 "\031<s24>" /* Same */ 870 "\032FFXSR" /* Fast FXSAVE/FXRSTOR */ 871 "\033Page1GB" /* 1-GB large page support */ 872 "\034RDTSCP" /* RDTSCP */ 873 "\035<b28>" /* Undefined */ 874 "\036LM" /* 64 bit long mode */ 875 "\0373DNow!+" /* AMD 3DNow! Extensions */ 876 "\0403DNow!" /* AMD 3DNow! */ 877 ); 878 } 879 880 if (amd_feature2 != 0) { 881 printf("\n AMD Features2=0x%b", amd_feature2, 882 "\020" 883 "\001LAHF" /* LAHF/SAHF in long mode */ 884 "\002CMP" /* CMP legacy */ 885 "\003SVM" /* Secure Virtual Mode */ 886 "\004ExtAPIC" /* Extended APIC register */ 887 "\005CR8" /* CR8 in legacy mode */ 888 "\006ABM" /* LZCNT instruction */ 889 "\007SSE4A" /* SSE4A */ 890 "\010MAS" /* Misaligned SSE mode */ 891 "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */ 892 "\012OSVW" /* OS visible workaround */ 893 "\013IBS" /* Instruction based sampling */ 894 "\014XOP" /* XOP extended instructions */ 895 "\015SKINIT" /* SKINIT/STGI */ 896 "\016WDT" /* Watchdog timer */ 897 "\017<b14>" 898 "\020LWP" /* Lightweight Profiling */ 899 "\021FMA4" /* 4-operand FMA instructions */ 900 "\022TCE" /* Translation Cache Extension */ 901 "\023<b18>" 902 "\024NodeId" /* NodeId MSR support */ 903 "\025<b20>" 904 "\026TBM" /* Trailing Bit Manipulation */ 905 "\027Topology" /* Topology Extensions */ 906 "\030PCXC" /* Core perf count */ 907 "\031PNXC" /* NB perf count */ 908 "\032<b25>" 909 "\033DBE" /* Data Breakpoint extension */ 910 "\034PTSC" /* Performance TSC */ 911 "\035PL2I" /* L2I perf count */ 912 "\036MWAITX" /* MONITORX/MWAITX instructions */ 913 "\037<b30>" 914 "\040<b31>" 915 ); 916 } 917 918 if (cpu_stdext_feature != 0) { 919 printf("\n Structured Extended Features=0x%b", 920 cpu_stdext_feature, 921 "\020" 922 /* RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */ 923 "\001FSGSBASE" 924 "\002TSCADJ" 925 "\003SGX" 926 /* Bit Manipulation Instructions */ 927 "\004BMI1" 928 /* Hardware Lock Elision */ 929 "\005HLE" 930 /* Advanced Vector Instructions 2 */ 931 "\006AVX2" 932 /* FDP_EXCPTN_ONLY */ 933 "\007FDPEXC" 934 /* Supervisor Mode Execution Prot. */ 935 "\010SMEP" 936 /* Bit Manipulation Instructions */ 937 "\011BMI2" 938 "\012ERMS" 939 /* Invalidate Processor Context ID */ 940 "\013INVPCID" 941 /* Restricted Transactional Memory */ 942 "\014RTM" 943 "\015PQM" 944 "\016NFPUSG" 945 /* Intel Memory Protection Extensions */ 946 "\017MPX" 947 "\020PQE" 948 /* AVX512 Foundation */ 949 "\021AVX512F" 950 "\022AVX512DQ" 951 /* Enhanced NRBG */ 952 "\023RDSEED" 953 /* ADCX + ADOX */ 954 "\024ADX" 955 /* Supervisor Mode Access Prevention */ 956 "\025SMAP" 957 "\026AVX512IFMA" 958 "\027PCOMMIT" 959 "\030CLFLUSHOPT" 960 "\031CLWB" 961 "\032PROCTRACE" 962 "\033AVX512PF" 963 "\034AVX512ER" 964 "\035AVX512CD" 965 "\036SHA" 966 "\037AVX512BW" 967 "\040AVX512VL" 968 ); 969 } 970 971 if (cpu_stdext_feature2 != 0) { 972 printf("\n Structured Extended Features2=0x%b", 973 cpu_stdext_feature2, 974 "\020" 975 "\001PREFETCHWT1" 976 "\002AVX512VBMI" 977 "\003UMIP" 978 "\004PKU" 979 "\005OSPKE" 980 "\027RDPID" 981 "\037SGXLC" 982 ); 983 } 984 985 if (cpu_stdext_feature3 != 0) { 986 printf("\n Structured Extended Features3=0x%b", 987 cpu_stdext_feature3, 988 "\020" 989 "\033IBPB" 990 "\034STIBP" 991 "\035L1DFL" 992 "\036ARCH_CAP" 993 "\040SSBD" 994 ); 995 } 996 997 if ((cpu_feature2 & CPUID2_XSAVE) != 0) { 998 cpuid_count(0xd, 0x1, regs); 999 if (regs[0] != 0) { 1000 printf("\n XSAVE Features=0x%b", 1001 regs[0], 1002 "\020" 1003 "\001XSAVEOPT" 1004 "\002XSAVEC" 1005 "\003XINUSE" 1006 "\004XSAVES"); 1007 } 1008 } 1009 1010 if (cpu_ia32_arch_caps != 0) { 1011 printf("\n IA32_ARCH_CAPS=0x%b", 1012 (u_int)cpu_ia32_arch_caps, 1013 "\020" 1014 "\001RDCL_NO" 1015 "\002IBRS_ALL" 1016 "\003RSBA" 1017 "\004SKIP_L1DFL_VME" 1018 "\005SSB_NO" 1019 ); 1020 } 1021 1022 if (amd_extended_feature_extensions != 0) { 1023 printf("\n " 1024 "AMD Extended Feature Extensions ID EBX=" 1025 "0x%b", amd_extended_feature_extensions, 1026 "\020" 1027 "\001CLZERO" 1028 "\002IRPerf" 1029 "\003XSaveErPtr"); 1030 } 1031 1032 if (via_feature_rng != 0 || via_feature_xcrypt != 0) 1033 print_via_padlock_info(); 1034 1035 if (cpu_feature2 & CPUID2_VMX) 1036 print_vmx_info(); 1037 1038 if (amd_feature2 & AMDID2_SVM) 1039 print_svm_info(); 1040 1041 if ((cpu_feature & CPUID_HTT) && 1042 cpu_vendor_id == CPU_VENDOR_AMD) 1043 cpu_feature &= ~CPUID_HTT; 1044 1045 /* 1046 * If this CPU supports P-state invariant TSC then 1047 * mention the capability. 1048 */ 1049 if (tsc_is_invariant) { 1050 printf("\n TSC: P-state invariant"); 1051 if (tsc_perf_stat) 1052 printf(", performance statistics"); 1053 } 1054 } 1055#ifdef __i386__ 1056 } else if (cpu_vendor_id == CPU_VENDOR_CYRIX) { 1057 printf(" DIR=0x%04x", cyrix_did); 1058 printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12); 1059 printf(" Revision=%u", (cyrix_did & 0x0f00) >> 8); 1060#ifndef CYRIX_CACHE_REALLY_WORKS 1061 if (cpu == CPU_M1 && (cyrix_did & 0xff00) < 0x1700) 1062 printf("\n CPU cache: write-through mode"); 1063#endif 1064#endif 1065 } 1066 1067 /* Avoid ugly blank lines: only print newline when we have to. */ 1068 if (*cpu_vendor || cpu_id) 1069 printf("\n"); 1070 1071 if (bootverbose) { 1072 if (cpu_vendor_id == CPU_VENDOR_AMD) 1073 print_AMD_info(); 1074 else if (cpu_vendor_id == CPU_VENDOR_INTEL) 1075 print_INTEL_info(); 1076#ifdef __i386__ 1077 else if (cpu_vendor_id == CPU_VENDOR_TRANSMETA) 1078 print_transmeta_info(); 1079#endif 1080 } 1081 1082 print_hypervisor_info(); 1083} 1084 1085#ifdef __i386__ 1086void 1087panicifcpuunsupported(void) 1088{ 1089 1090#if !defined(lint) 1091#if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU) 1092#error This kernel is not configured for one of the supported CPUs 1093#endif 1094#else /* lint */ 1095#endif /* lint */ 1096 /* 1097 * Now that we have told the user what they have, 1098 * let them know if that machine type isn't configured. 1099 */ 1100 switch (cpu_class) { 1101 case CPUCLASS_286: /* a 286 should not make it this far, anyway */ 1102 case CPUCLASS_386: 1103#if !defined(I486_CPU) 1104 case CPUCLASS_486: 1105#endif 1106#if !defined(I586_CPU) 1107 case CPUCLASS_586: 1108#endif 1109#if !defined(I686_CPU) 1110 case CPUCLASS_686: 1111#endif 1112 panic("CPU class not configured"); 1113 default: 1114 break; 1115 } 1116} 1117 1118static volatile u_int trap_by_rdmsr; 1119 1120/* 1121 * Special exception 6 handler. 1122 * The rdmsr instruction generates invalid opcodes fault on 486-class 1123 * Cyrix CPU. Stacked eip register points the rdmsr instruction in the 1124 * function identblue() when this handler is called. Stacked eip should 1125 * be advanced. 1126 */ 1127inthand_t bluetrap6; 1128#ifdef __GNUCLIKE_ASM 1129__asm 1130(" \n\ 1131 .text \n\ 1132 .p2align 2,0x90 \n\ 1133 .type " __XSTRING(CNAME(bluetrap6)) ",@function \n\ 1134" __XSTRING(CNAME(bluetrap6)) ": \n\ 1135 ss \n\ 1136 movl $0xa8c1d," __XSTRING(CNAME(trap_by_rdmsr)) " \n\ 1137 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\ 1138 iret \n\ 1139"); 1140#endif 1141 1142/* 1143 * Special exception 13 handler. 1144 * Accessing non-existent MSR generates general protection fault. 1145 */ 1146inthand_t bluetrap13; 1147#ifdef __GNUCLIKE_ASM 1148__asm 1149(" \n\ 1150 .text \n\ 1151 .p2align 2,0x90 \n\ 1152 .type " __XSTRING(CNAME(bluetrap13)) ",@function \n\ 1153" __XSTRING(CNAME(bluetrap13)) ": \n\ 1154 ss \n\ 1155 movl $0xa89c4," __XSTRING(CNAME(trap_by_rdmsr)) " \n\ 1156 popl %eax /* discard error code */ \n\ 1157 addl $2, (%esp) /* rdmsr is a 2-byte instruction */ \n\ 1158 iret \n\ 1159"); 1160#endif 1161 1162/* 1163 * Distinguish IBM Blue Lightning CPU from Cyrix CPUs that does not 1164 * support cpuid instruction. This function should be called after 1165 * loading interrupt descriptor table register. 1166 * 1167 * I don't like this method that handles fault, but I couldn't get 1168 * information for any other methods. Does blue giant know? 1169 */ 1170static int 1171identblue(void) 1172{ 1173 1174 trap_by_rdmsr = 0; 1175 1176 /* 1177 * Cyrix 486-class CPU does not support rdmsr instruction. 1178 * The rdmsr instruction generates invalid opcode fault, and exception 1179 * will be trapped by bluetrap6() on Cyrix 486-class CPU. The 1180 * bluetrap6() set the magic number to trap_by_rdmsr. 1181 */ 1182 setidt(IDT_UD, bluetrap6, SDT_SYS386TGT, SEL_KPL, 1183 GSEL(GCODE_SEL, SEL_KPL)); 1184 1185 /* 1186 * Certain BIOS disables cpuid instruction of Cyrix 6x86MX CPU. 1187 * In this case, rdmsr generates general protection fault, and 1188 * exception will be trapped by bluetrap13(). 1189 */ 1190 setidt(IDT_GP, bluetrap13, SDT_SYS386TGT, SEL_KPL, 1191 GSEL(GCODE_SEL, SEL_KPL)); 1192 1193 rdmsr(0x1002); /* Cyrix CPU generates fault. */ 1194 1195 if (trap_by_rdmsr == 0xa8c1d) 1196 return IDENTBLUE_CYRIX486; 1197 else if (trap_by_rdmsr == 0xa89c4) 1198 return IDENTBLUE_CYRIXM2; 1199 return IDENTBLUE_IBMCPU; 1200} 1201 1202 1203/* 1204 * identifycyrix() set lower 16 bits of cyrix_did as follows: 1205 * 1206 * F E D C B A 9 8 7 6 5 4 3 2 1 0 1207 * +-------+-------+---------------+ 1208 * | SID | RID | Device ID | 1209 * | (DIR 1) | (DIR 0) | 1210 * +-------+-------+---------------+ 1211 */ 1212static void 1213identifycyrix(void) 1214{ 1215 register_t saveintr; 1216 int ccr2_test = 0, dir_test = 0; 1217 u_char ccr2, ccr3; 1218 1219 saveintr = intr_disable(); 1220 1221 ccr2 = read_cyrix_reg(CCR2); 1222 write_cyrix_reg(CCR2, ccr2 ^ CCR2_LOCK_NW); 1223 read_cyrix_reg(CCR2); 1224 if (read_cyrix_reg(CCR2) != ccr2) 1225 ccr2_test = 1; 1226 write_cyrix_reg(CCR2, ccr2); 1227 1228 ccr3 = read_cyrix_reg(CCR3); 1229 write_cyrix_reg(CCR3, ccr3 ^ CCR3_MAPEN3); 1230 read_cyrix_reg(CCR3); 1231 if (read_cyrix_reg(CCR3) != ccr3) 1232 dir_test = 1; /* CPU supports DIRs. */ 1233 write_cyrix_reg(CCR3, ccr3); 1234 1235 if (dir_test) { 1236 /* Device ID registers are available. */ 1237 cyrix_did = read_cyrix_reg(DIR1) << 8; 1238 cyrix_did += read_cyrix_reg(DIR0); 1239 } else if (ccr2_test) 1240 cyrix_did = 0x0010; /* 486S A-step */ 1241 else 1242 cyrix_did = 0x00ff; /* Old 486SLC/DLC and TI486SXLC/SXL */ 1243 1244 intr_restore(saveintr); 1245} 1246#endif 1247 1248/* Update TSC freq with the value indicated by the caller. */ 1249static void 1250tsc_freq_changed(void *arg __unused, const struct cf_level *level, int status) 1251{ 1252 1253 /* If there was an error during the transition, don't do anything. */ 1254 if (status != 0) 1255 return; 1256 1257 /* Total setting for this level gives the new frequency in MHz. */ 1258 hw_clockrate = level->total_set.freq; 1259} 1260 1261static void 1262hook_tsc_freq(void *arg __unused) 1263{ 1264 1265 if (tsc_is_invariant) 1266 return; 1267 1268 tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change, 1269 tsc_freq_changed, NULL, EVENTHANDLER_PRI_ANY); 1270} 1271 1272SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL); 1273 1274static const char *const vm_bnames[] = { 1275 "QEMU", /* QEMU */ 1276 "Plex86", /* Plex86 */ 1277 "Bochs", /* Bochs */ 1278 "Xen", /* Xen */ 1279 "BHYVE", /* bhyve */ 1280 "Seabios", /* KVM */ 1281 NULL 1282}; 1283 1284static const char *const vm_pnames[] = { 1285 "VMware Virtual Platform", /* VMWare VM */ 1286 "Virtual Machine", /* Microsoft VirtualPC */ 1287 "VirtualBox", /* Sun xVM VirtualBox */ 1288 "Parallels Virtual Platform", /* Parallels VM */ 1289 "KVM", /* KVM */ 1290 NULL 1291}; 1292 1293void 1294identify_hypervisor(void) 1295{ 1296 u_int regs[4]; 1297 char *p; 1298 int i; 1299 1300 /* 1301 * [RFC] CPUID usage for interaction between Hypervisors and Linux. 1302 * http://lkml.org/lkml/2008/10/1/246 1303 * 1304 * KB1009458: Mechanisms to determine if software is running in 1305 * a VMware virtual machine 1306 * http://kb.vmware.com/kb/1009458 1307 */ 1308 if (cpu_feature2 & CPUID2_HV) { 1309 vm_guest = VM_GUEST_VM; 1310 do_cpuid(0x40000000, regs); 1311 1312 /* 1313 * KVM from Linux kernels prior to commit 1314 * 57c22e5f35aa4b9b2fe11f73f3e62bbf9ef36190 set %eax 1315 * to 0 rather than a valid hv_high value. Check for 1316 * the KVM signature bytes and fixup %eax to the 1317 * highest supported leaf in that case. 1318 */ 1319 if (regs[0] == 0 && regs[1] == 0x4b4d564b && 1320 regs[2] == 0x564b4d56 && regs[3] == 0x0000004d) 1321 regs[0] = 0x40000001; 1322 1323 if (regs[0] >= 0x40000000) { 1324 hv_high = regs[0]; 1325 ((u_int *)&hv_vendor)[0] = regs[1]; 1326 ((u_int *)&hv_vendor)[1] = regs[2]; 1327 ((u_int *)&hv_vendor)[2] = regs[3]; 1328 hv_vendor[12] = '\0'; 1329 if (strcmp(hv_vendor, "VMwareVMware") == 0) 1330 vm_guest = VM_GUEST_VMWARE; 1331 else if (strcmp(hv_vendor, "Microsoft Hv") == 0) 1332 vm_guest = VM_GUEST_HV; 1333 else if (strcmp(hv_vendor, "KVMKVMKVM") == 0) 1334 vm_guest = VM_GUEST_KVM; 1335 else if (strcmp(hv_vendor, "bhyve bhyve") == 0) 1336 vm_guest = VM_GUEST_BHYVE; 1337 } 1338 return; 1339 } 1340 1341 /* 1342 * Examine SMBIOS strings for older hypervisors. 1343 */ 1344 p = kern_getenv("smbios.system.serial"); 1345 if (p != NULL) { 1346 if (strncmp(p, "VMware-", 7) == 0 || strncmp(p, "VMW", 3) == 0) { 1347 vmware_hvcall(VMW_HVCMD_GETVERSION, regs); 1348 if (regs[1] == VMW_HVMAGIC) { 1349 vm_guest = VM_GUEST_VMWARE; 1350 freeenv(p); 1351 return; 1352 } 1353 } 1354 freeenv(p); 1355 } 1356 1357 /* 1358 * XXX: Some of these entries may not be needed since they were 1359 * added to FreeBSD before the checks above. 1360 */ 1361 p = kern_getenv("smbios.bios.vendor"); 1362 if (p != NULL) { 1363 for (i = 0; vm_bnames[i] != NULL; i++) 1364 if (strcmp(p, vm_bnames[i]) == 0) { 1365 vm_guest = VM_GUEST_VM; 1366 freeenv(p); 1367 return; 1368 } 1369 freeenv(p); 1370 } 1371 p = kern_getenv("smbios.system.product"); 1372 if (p != NULL) { 1373 for (i = 0; vm_pnames[i] != NULL; i++) 1374 if (strcmp(p, vm_pnames[i]) == 0) { 1375 vm_guest = VM_GUEST_VM; 1376 freeenv(p); 1377 return; 1378 } 1379 freeenv(p); 1380 } 1381} 1382 1383bool 1384fix_cpuid(void) 1385{ 1386 uint64_t msr; 1387 1388 /* 1389 * Clear "Limit CPUID Maxval" bit and return true if the caller should 1390 * get the largest standard CPUID function number again if it is set 1391 * from BIOS. It is necessary for probing correct CPU topology later 1392 * and for the correct operation of the AVX-aware userspace. 1393 */ 1394 if (cpu_vendor_id == CPU_VENDOR_INTEL && 1395 ((CPUID_TO_FAMILY(cpu_id) == 0xf && 1396 CPUID_TO_MODEL(cpu_id) >= 0x3) || 1397 (CPUID_TO_FAMILY(cpu_id) == 0x6 && 1398 CPUID_TO_MODEL(cpu_id) >= 0xe))) { 1399 msr = rdmsr(MSR_IA32_MISC_ENABLE); 1400 if ((msr & IA32_MISC_EN_LIMCPUID) != 0) { 1401 msr &= ~IA32_MISC_EN_LIMCPUID; 1402 wrmsr(MSR_IA32_MISC_ENABLE, msr); 1403 return (true); 1404 } 1405 } 1406 1407 /* 1408 * Re-enable AMD Topology Extension that could be disabled by BIOS 1409 * on some notebook processors. Without the extension it's really 1410 * hard to determine the correct CPU cache topology. 1411 * See BIOS and Kernel Developer���s Guide (BKDG) for AMD Family 15h 1412 * Models 60h-6Fh Processors, Publication # 50742. 1413 */ 1414 if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_AMD && 1415 CPUID_TO_FAMILY(cpu_id) == 0x15) { 1416 msr = rdmsr(MSR_EXTFEATURES); 1417 if ((msr & ((uint64_t)1 << 54)) == 0) { 1418 msr |= (uint64_t)1 << 54; 1419 wrmsr(MSR_EXTFEATURES, msr); 1420 return (true); 1421 } 1422 } 1423 return (false); 1424} 1425 1426void 1427identify_cpu1(void) 1428{ 1429 u_int regs[4]; 1430 1431 do_cpuid(0, regs); 1432 cpu_high = regs[0]; 1433 ((u_int *)&cpu_vendor)[0] = regs[1]; 1434 ((u_int *)&cpu_vendor)[1] = regs[3]; 1435 ((u_int *)&cpu_vendor)[2] = regs[2]; 1436 cpu_vendor[12] = '\0'; 1437 1438 do_cpuid(1, regs); 1439 cpu_id = regs[0]; 1440 cpu_procinfo = regs[1]; 1441 cpu_feature = regs[3]; 1442 cpu_feature2 = regs[2]; 1443} 1444 1445void 1446identify_cpu2(void) 1447{ 1448 u_int regs[4], cpu_stdext_disable; 1449 1450 if (cpu_high >= 7) { 1451 cpuid_count(7, 0, regs); 1452 cpu_stdext_feature = regs[1]; 1453 1454 /* 1455 * Some hypervisors failed to filter out unsupported 1456 * extended features. Allow to disable the 1457 * extensions, activation of which requires setting a 1458 * bit in CR4, and which VM monitors do not support. 1459 */ 1460 cpu_stdext_disable = 0; 1461 TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable); 1462 cpu_stdext_feature &= ~cpu_stdext_disable; 1463 1464 cpu_stdext_feature2 = regs[2]; 1465 cpu_stdext_feature3 = regs[3]; 1466 1467 if ((cpu_stdext_feature3 & CPUID_STDEXT3_ARCH_CAP) != 0) 1468 cpu_ia32_arch_caps = rdmsr(MSR_IA32_ARCH_CAP); 1469 } 1470} 1471 1472/* 1473 * Final stage of CPU identification. 1474 */ 1475void 1476finishidentcpu(void) 1477{ 1478 u_int regs[4]; 1479#ifdef __i386__ 1480 u_char ccr3; 1481#endif 1482 1483 cpu_vendor_id = find_cpu_vendor_id(); 1484 1485 if (fix_cpuid()) { 1486 do_cpuid(0, regs); 1487 cpu_high = regs[0]; 1488 } 1489 1490 if (cpu_high >= 5 && (cpu_feature2 & CPUID2_MON) != 0) { 1491 do_cpuid(5, regs); 1492 cpu_mon_mwait_flags = regs[2]; 1493 cpu_mon_min_size = regs[0] & CPUID5_MON_MIN_SIZE; 1494 cpu_mon_max_size = regs[1] & CPUID5_MON_MAX_SIZE; 1495 } 1496 1497 identify_cpu2(); 1498 1499#ifdef __i386__ 1500 if (cpu_high > 0 && 1501 (cpu_vendor_id == CPU_VENDOR_INTEL || 1502 cpu_vendor_id == CPU_VENDOR_AMD || 1503 cpu_vendor_id == CPU_VENDOR_TRANSMETA || 1504 cpu_vendor_id == CPU_VENDOR_CENTAUR || 1505 cpu_vendor_id == CPU_VENDOR_NSC)) { 1506 do_cpuid(0x80000000, regs); 1507 if (regs[0] >= 0x80000000) 1508 cpu_exthigh = regs[0]; 1509 } 1510#else 1511 if (cpu_vendor_id == CPU_VENDOR_INTEL || 1512 cpu_vendor_id == CPU_VENDOR_AMD || 1513 cpu_vendor_id == CPU_VENDOR_CENTAUR) { 1514 do_cpuid(0x80000000, regs); 1515 cpu_exthigh = regs[0]; 1516 } 1517#endif 1518 if (cpu_exthigh >= 0x80000001) { 1519 do_cpuid(0x80000001, regs); 1520 amd_feature = regs[3] & ~(cpu_feature & 0x0183f3ff); 1521 amd_feature2 = regs[2]; 1522 } 1523 if (cpu_exthigh >= 0x80000007) { 1524 do_cpuid(0x80000007, regs); 1525 amd_pminfo = regs[3]; 1526 } 1527 if (cpu_exthigh >= 0x80000008) { 1528 do_cpuid(0x80000008, regs); 1529 cpu_maxphyaddr = regs[0] & 0xff; 1530 amd_extended_feature_extensions = regs[1]; 1531 cpu_procinfo2 = regs[2]; 1532 } else { 1533 cpu_maxphyaddr = (cpu_feature & CPUID_PAE) != 0 ? 36 : 32; 1534 } 1535 1536#ifdef __i386__ 1537 if (cpu_vendor_id == CPU_VENDOR_CYRIX) { 1538 if (cpu == CPU_486) { 1539 /* 1540 * These conditions are equivalent to: 1541 * - CPU does not support cpuid instruction. 1542 * - Cyrix/IBM CPU is detected. 1543 */ 1544 if (identblue() == IDENTBLUE_IBMCPU) { 1545 strcpy(cpu_vendor, "IBM"); 1546 cpu_vendor_id = CPU_VENDOR_IBM; 1547 cpu = CPU_BLUE; 1548 return; 1549 } 1550 } 1551 switch (cpu_id & 0xf00) { 1552 case 0x600: 1553 /* 1554 * Cyrix's datasheet does not describe DIRs. 1555 * Therefor, I assume it does not have them 1556 * and use the result of the cpuid instruction. 1557 * XXX they seem to have it for now at least. -Peter 1558 */ 1559 identifycyrix(); 1560 cpu = CPU_M2; 1561 break; 1562 default: 1563 identifycyrix(); 1564 /* 1565 * This routine contains a trick. 1566 * Don't check (cpu_id & 0x00f0) == 0x50 to detect M2, now. 1567 */ 1568 switch (cyrix_did & 0x00f0) { 1569 case 0x00: 1570 case 0xf0: 1571 cpu = CPU_486DLC; 1572 break; 1573 case 0x10: 1574 cpu = CPU_CY486DX; 1575 break; 1576 case 0x20: 1577 if ((cyrix_did & 0x000f) < 8) 1578 cpu = CPU_M1; 1579 else 1580 cpu = CPU_M1SC; 1581 break; 1582 case 0x30: 1583 cpu = CPU_M1; 1584 break; 1585 case 0x40: 1586 /* MediaGX CPU */ 1587 cpu = CPU_M1SC; 1588 break; 1589 default: 1590 /* M2 and later CPUs are treated as M2. */ 1591 cpu = CPU_M2; 1592 1593 /* 1594 * enable cpuid instruction. 1595 */ 1596 ccr3 = read_cyrix_reg(CCR3); 1597 write_cyrix_reg(CCR3, CCR3_MAPEN0); 1598 write_cyrix_reg(CCR4, read_cyrix_reg(CCR4) | CCR4_CPUID); 1599 write_cyrix_reg(CCR3, ccr3); 1600 1601 do_cpuid(0, regs); 1602 cpu_high = regs[0]; /* eax */ 1603 do_cpuid(1, regs); 1604 cpu_id = regs[0]; /* eax */ 1605 cpu_feature = regs[3]; /* edx */ 1606 break; 1607 } 1608 } 1609 } else if (cpu == CPU_486 && *cpu_vendor == '\0') { 1610 /* 1611 * There are BlueLightning CPUs that do not change 1612 * undefined flags by dividing 5 by 2. In this case, 1613 * the CPU identification routine in locore.s leaves 1614 * cpu_vendor null string and puts CPU_486 into the 1615 * cpu. 1616 */ 1617 if (identblue() == IDENTBLUE_IBMCPU) { 1618 strcpy(cpu_vendor, "IBM"); 1619 cpu_vendor_id = CPU_VENDOR_IBM; 1620 cpu = CPU_BLUE; 1621 return; 1622 } 1623 } 1624#endif 1625} 1626 1627int 1628pti_get_default(void) 1629{ 1630 1631 if (strcmp(cpu_vendor, AMD_VENDOR_ID) == 0) 1632 return (0); 1633 if ((cpu_ia32_arch_caps & IA32_ARCH_CAP_RDCL_NO) != 0) 1634 return (0); 1635 return (1); 1636} 1637 1638static u_int 1639find_cpu_vendor_id(void) 1640{ 1641 int i; 1642 1643 for (i = 0; i < nitems(cpu_vendors); i++) 1644 if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0) 1645 return (cpu_vendors[i].vendor_id); 1646 return (0); 1647} 1648 1649static void 1650print_AMD_assoc(int i) 1651{ 1652 if (i == 255) 1653 printf(", fully associative\n"); 1654 else 1655 printf(", %d-way associative\n", i); 1656} 1657 1658static void 1659print_AMD_l2_assoc(int i) 1660{ 1661 switch (i & 0x0f) { 1662 case 0: printf(", disabled/not present\n"); break; 1663 case 1: printf(", direct mapped\n"); break; 1664 case 2: printf(", 2-way associative\n"); break; 1665 case 4: printf(", 4-way associative\n"); break; 1666 case 6: printf(", 8-way associative\n"); break; 1667 case 8: printf(", 16-way associative\n"); break; 1668 case 15: printf(", fully associative\n"); break; 1669 default: printf(", reserved configuration\n"); break; 1670 } 1671} 1672 1673static void 1674print_AMD_info(void) 1675{ 1676#ifdef __i386__ 1677 uint64_t amd_whcr; 1678#endif 1679 u_int regs[4]; 1680 1681 if (cpu_exthigh >= 0x80000005) { 1682 do_cpuid(0x80000005, regs); 1683 printf("L1 2MB data TLB: %d entries", (regs[0] >> 16) & 0xff); 1684 print_AMD_assoc(regs[0] >> 24); 1685 1686 printf("L1 2MB instruction TLB: %d entries", regs[0] & 0xff); 1687 print_AMD_assoc((regs[0] >> 8) & 0xff); 1688 1689 printf("L1 4KB data TLB: %d entries", (regs[1] >> 16) & 0xff); 1690 print_AMD_assoc(regs[1] >> 24); 1691 1692 printf("L1 4KB instruction TLB: %d entries", regs[1] & 0xff); 1693 print_AMD_assoc((regs[1] >> 8) & 0xff); 1694 1695 printf("L1 data cache: %d kbytes", regs[2] >> 24); 1696 printf(", %d bytes/line", regs[2] & 0xff); 1697 printf(", %d lines/tag", (regs[2] >> 8) & 0xff); 1698 print_AMD_assoc((regs[2] >> 16) & 0xff); 1699 1700 printf("L1 instruction cache: %d kbytes", regs[3] >> 24); 1701 printf(", %d bytes/line", regs[3] & 0xff); 1702 printf(", %d lines/tag", (regs[3] >> 8) & 0xff); 1703 print_AMD_assoc((regs[3] >> 16) & 0xff); 1704 } 1705 1706 if (cpu_exthigh >= 0x80000006) { 1707 do_cpuid(0x80000006, regs); 1708 if ((regs[0] >> 16) != 0) { 1709 printf("L2 2MB data TLB: %d entries", 1710 (regs[0] >> 16) & 0xfff); 1711 print_AMD_l2_assoc(regs[0] >> 28); 1712 printf("L2 2MB instruction TLB: %d entries", 1713 regs[0] & 0xfff); 1714 print_AMD_l2_assoc((regs[0] >> 28) & 0xf); 1715 } else { 1716 printf("L2 2MB unified TLB: %d entries", 1717 regs[0] & 0xfff); 1718 print_AMD_l2_assoc((regs[0] >> 28) & 0xf); 1719 } 1720 if ((regs[1] >> 16) != 0) { 1721 printf("L2 4KB data TLB: %d entries", 1722 (regs[1] >> 16) & 0xfff); 1723 print_AMD_l2_assoc(regs[1] >> 28); 1724 1725 printf("L2 4KB instruction TLB: %d entries", 1726 (regs[1] >> 16) & 0xfff); 1727 print_AMD_l2_assoc((regs[1] >> 28) & 0xf); 1728 } else { 1729 printf("L2 4KB unified TLB: %d entries", 1730 (regs[1] >> 16) & 0xfff); 1731 print_AMD_l2_assoc((regs[1] >> 28) & 0xf); 1732 } 1733 printf("L2 unified cache: %d kbytes", regs[2] >> 16); 1734 printf(", %d bytes/line", regs[2] & 0xff); 1735 printf(", %d lines/tag", (regs[2] >> 8) & 0x0f); 1736 print_AMD_l2_assoc((regs[2] >> 12) & 0x0f); 1737 } 1738 1739#ifdef __i386__ 1740 if (((cpu_id & 0xf00) == 0x500) 1741 && (((cpu_id & 0x0f0) > 0x80) 1742 || (((cpu_id & 0x0f0) == 0x80) 1743 && (cpu_id & 0x00f) > 0x07))) { 1744 /* K6-2(new core [Stepping 8-F]), K6-III or later */ 1745 amd_whcr = rdmsr(0xc0000082); 1746 if (!(amd_whcr & (0x3ff << 22))) { 1747 printf("Write Allocate Disable\n"); 1748 } else { 1749 printf("Write Allocate Enable Limit: %dM bytes\n", 1750 (u_int32_t)((amd_whcr & (0x3ff << 22)) >> 22) * 4); 1751 printf("Write Allocate 15-16M bytes: %s\n", 1752 (amd_whcr & (1 << 16)) ? "Enable" : "Disable"); 1753 } 1754 } else if (((cpu_id & 0xf00) == 0x500) 1755 && ((cpu_id & 0x0f0) > 0x50)) { 1756 /* K6, K6-2(old core) */ 1757 amd_whcr = rdmsr(0xc0000082); 1758 if (!(amd_whcr & (0x7f << 1))) { 1759 printf("Write Allocate Disable\n"); 1760 } else { 1761 printf("Write Allocate Enable Limit: %dM bytes\n", 1762 (u_int32_t)((amd_whcr & (0x7f << 1)) >> 1) * 4); 1763 printf("Write Allocate 15-16M bytes: %s\n", 1764 (amd_whcr & 0x0001) ? "Enable" : "Disable"); 1765 printf("Hardware Write Allocate Control: %s\n", 1766 (amd_whcr & 0x0100) ? "Enable" : "Disable"); 1767 } 1768 } 1769#endif 1770 /* 1771 * Opteron Rev E shows a bug as in very rare occasions a read memory 1772 * barrier is not performed as expected if it is followed by a 1773 * non-atomic read-modify-write instruction. 1774 * As long as that bug pops up very rarely (intensive machine usage 1775 * on other operating systems generally generates one unexplainable 1776 * crash any 2 months) and as long as a model specific fix would be 1777 * impractical at this stage, print out a warning string if the broken 1778 * model and family are identified. 1779 */ 1780 if (CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x20 && 1781 CPUID_TO_MODEL(cpu_id) <= 0x3f) 1782 printf("WARNING: This architecture revision has known SMP " 1783 "hardware bugs which may cause random instability\n"); 1784} 1785 1786static void 1787print_INTEL_info(void) 1788{ 1789 u_int regs[4]; 1790 u_int rounds, regnum; 1791 u_int nwaycode, nway; 1792 1793 if (cpu_high >= 2) { 1794 rounds = 0; 1795 do { 1796 do_cpuid(0x2, regs); 1797 if (rounds == 0 && (rounds = (regs[0] & 0xff)) == 0) 1798 break; /* we have a buggy CPU */ 1799 1800 for (regnum = 0; regnum <= 3; ++regnum) { 1801 if (regs[regnum] & (1<<31)) 1802 continue; 1803 if (regnum != 0) 1804 print_INTEL_TLB(regs[regnum] & 0xff); 1805 print_INTEL_TLB((regs[regnum] >> 8) & 0xff); 1806 print_INTEL_TLB((regs[regnum] >> 16) & 0xff); 1807 print_INTEL_TLB((regs[regnum] >> 24) & 0xff); 1808 } 1809 } while (--rounds > 0); 1810 } 1811 1812 if (cpu_exthigh >= 0x80000006) { 1813 do_cpuid(0x80000006, regs); 1814 nwaycode = (regs[2] >> 12) & 0x0f; 1815 if (nwaycode >= 0x02 && nwaycode <= 0x08) 1816 nway = 1 << (nwaycode / 2); 1817 else 1818 nway = 0; 1819 printf("L2 cache: %u kbytes, %u-way associative, %u bytes/line\n", 1820 (regs[2] >> 16) & 0xffff, nway, regs[2] & 0xff); 1821 } 1822} 1823 1824static void 1825print_INTEL_TLB(u_int data) 1826{ 1827 switch (data) { 1828 case 0x0: 1829 case 0x40: 1830 default: 1831 break; 1832 case 0x1: 1833 printf("Instruction TLB: 4 KB pages, 4-way set associative, 32 entries\n"); 1834 break; 1835 case 0x2: 1836 printf("Instruction TLB: 4 MB pages, fully associative, 2 entries\n"); 1837 break; 1838 case 0x3: 1839 printf("Data TLB: 4 KB pages, 4-way set associative, 64 entries\n"); 1840 break; 1841 case 0x4: 1842 printf("Data TLB: 4 MB Pages, 4-way set associative, 8 entries\n"); 1843 break; 1844 case 0x6: 1845 printf("1st-level instruction cache: 8 KB, 4-way set associative, 32 byte line size\n"); 1846 break; 1847 case 0x8: 1848 printf("1st-level instruction cache: 16 KB, 4-way set associative, 32 byte line size\n"); 1849 break; 1850 case 0x9: 1851 printf("1st-level instruction cache: 32 KB, 4-way set associative, 64 byte line size\n"); 1852 break; 1853 case 0xa: 1854 printf("1st-level data cache: 8 KB, 2-way set associative, 32 byte line size\n"); 1855 break; 1856 case 0xb: 1857 printf("Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries\n"); 1858 break; 1859 case 0xc: 1860 printf("1st-level data cache: 16 KB, 4-way set associative, 32 byte line size\n"); 1861 break; 1862 case 0xd: 1863 printf("1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size"); 1864 break; 1865 case 0xe: 1866 printf("1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size\n"); 1867 break; 1868 case 0x1d: 1869 printf("2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size\n"); 1870 break; 1871 case 0x21: 1872 printf("2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size\n"); 1873 break; 1874 case 0x22: 1875 printf("3rd-level cache: 512 KB, 4-way set associative, sectored cache, 64 byte line size\n"); 1876 break; 1877 case 0x23: 1878 printf("3rd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n"); 1879 break; 1880 case 0x24: 1881 printf("2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size\n"); 1882 break; 1883 case 0x25: 1884 printf("3rd-level cache: 2 MB, 8-way set associative, sectored cache, 64 byte line size\n"); 1885 break; 1886 case 0x29: 1887 printf("3rd-level cache: 4 MB, 8-way set associative, sectored cache, 64 byte line size\n"); 1888 break; 1889 case 0x2c: 1890 printf("1st-level data cache: 32 KB, 8-way set associative, 64 byte line size\n"); 1891 break; 1892 case 0x30: 1893 printf("1st-level instruction cache: 32 KB, 8-way set associative, 64 byte line size\n"); 1894 break; 1895 case 0x39: /* De-listed in SDM rev. 54 */ 1896 printf("2nd-level cache: 128 KB, 4-way set associative, sectored cache, 64 byte line size\n"); 1897 break; 1898 case 0x3b: /* De-listed in SDM rev. 54 */ 1899 printf("2nd-level cache: 128 KB, 2-way set associative, sectored cache, 64 byte line size\n"); 1900 break; 1901 case 0x3c: /* De-listed in SDM rev. 54 */ 1902 printf("2nd-level cache: 256 KB, 4-way set associative, sectored cache, 64 byte line size\n"); 1903 break; 1904 case 0x41: 1905 printf("2nd-level cache: 128 KB, 4-way set associative, 32 byte line size\n"); 1906 break; 1907 case 0x42: 1908 printf("2nd-level cache: 256 KB, 4-way set associative, 32 byte line size\n"); 1909 break; 1910 case 0x43: 1911 printf("2nd-level cache: 512 KB, 4-way set associative, 32 byte line size\n"); 1912 break; 1913 case 0x44: 1914 printf("2nd-level cache: 1 MB, 4-way set associative, 32 byte line size\n"); 1915 break; 1916 case 0x45: 1917 printf("2nd-level cache: 2 MB, 4-way set associative, 32 byte line size\n"); 1918 break; 1919 case 0x46: 1920 printf("3rd-level cache: 4 MB, 4-way set associative, 64 byte line size\n"); 1921 break; 1922 case 0x47: 1923 printf("3rd-level cache: 8 MB, 8-way set associative, 64 byte line size\n"); 1924 break; 1925 case 0x48: 1926 printf("2nd-level cache: 3MByte, 12-way set associative, 64 byte line size\n"); 1927 break; 1928 case 0x49: 1929 if (CPUID_TO_FAMILY(cpu_id) == 0xf && 1930 CPUID_TO_MODEL(cpu_id) == 0x6) 1931 printf("3rd-level cache: 4MB, 16-way set associative, 64-byte line size\n"); 1932 else 1933 printf("2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size"); 1934 break; 1935 case 0x4a: 1936 printf("3rd-level cache: 6MByte, 12-way set associative, 64 byte line size\n"); 1937 break; 1938 case 0x4b: 1939 printf("3rd-level cache: 8MByte, 16-way set associative, 64 byte line size\n"); 1940 break; 1941 case 0x4c: 1942 printf("3rd-level cache: 12MByte, 12-way set associative, 64 byte line size\n"); 1943 break; 1944 case 0x4d: 1945 printf("3rd-level cache: 16MByte, 16-way set associative, 64 byte line size\n"); 1946 break; 1947 case 0x4e: 1948 printf("2nd-level cache: 6MByte, 24-way set associative, 64 byte line size\n"); 1949 break; 1950 case 0x4f: 1951 printf("Instruction TLB: 4 KByte pages, 32 entries\n"); 1952 break; 1953 case 0x50: 1954 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 64 entries\n"); 1955 break; 1956 case 0x51: 1957 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 128 entries\n"); 1958 break; 1959 case 0x52: 1960 printf("Instruction TLB: 4 KB, 2 MB or 4 MB pages, fully associative, 256 entries\n"); 1961 break; 1962 case 0x55: 1963 printf("Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries\n"); 1964 break; 1965 case 0x56: 1966 printf("Data TLB0: 4 MByte pages, 4-way set associative, 16 entries\n"); 1967 break; 1968 case 0x57: 1969 printf("Data TLB0: 4 KByte pages, 4-way associative, 16 entries\n"); 1970 break; 1971 case 0x59: 1972 printf("Data TLB0: 4 KByte pages, fully associative, 16 entries\n"); 1973 break; 1974 case 0x5a: 1975 printf("Data TLB0: 2-MByte or 4 MByte pages, 4-way set associative, 32 entries\n"); 1976 break; 1977 case 0x5b: 1978 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 64 entries\n"); 1979 break; 1980 case 0x5c: 1981 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 128 entries\n"); 1982 break; 1983 case 0x5d: 1984 printf("Data TLB: 4 KB or 4 MB pages, fully associative, 256 entries\n"); 1985 break; 1986 case 0x60: 1987 printf("1st-level data cache: 16 KB, 8-way set associative, sectored cache, 64 byte line size\n"); 1988 break; 1989 case 0x61: 1990 printf("Instruction TLB: 4 KByte pages, fully associative, 48 entries\n"); 1991 break; 1992 case 0x63: 1993 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"); 1994 break; 1995 case 0x64: 1996 printf("Data TLB: 4 KBytes pages, 4-way set associative, 512 entries\n"); 1997 break; 1998 case 0x66: 1999 printf("1st-level data cache: 8 KB, 4-way set associative, sectored cache, 64 byte line size\n"); 2000 break; 2001 case 0x67: 2002 printf("1st-level data cache: 16 KB, 4-way set associative, sectored cache, 64 byte line size\n"); 2003 break; 2004 case 0x68: 2005 printf("1st-level data cache: 32 KB, 4 way set associative, sectored cache, 64 byte line size\n"); 2006 break; 2007 case 0x6a: 2008 printf("uTLB: 4KByte pages, 8-way set associative, 64 entries\n"); 2009 break; 2010 case 0x6b: 2011 printf("DTLB: 4KByte pages, 8-way set associative, 256 entries\n"); 2012 break; 2013 case 0x6c: 2014 printf("DTLB: 2M/4M pages, 8-way set associative, 128 entries\n"); 2015 break; 2016 case 0x6d: 2017 printf("DTLB: 1 GByte pages, fully associative, 16 entries\n"); 2018 break; 2019 case 0x70: 2020 printf("Trace cache: 12K-uops, 8-way set associative\n"); 2021 break; 2022 case 0x71: 2023 printf("Trace cache: 16K-uops, 8-way set associative\n"); 2024 break; 2025 case 0x72: 2026 printf("Trace cache: 32K-uops, 8-way set associative\n"); 2027 break; 2028 case 0x76: 2029 printf("Instruction TLB: 2M/4M pages, fully associative, 8 entries\n"); 2030 break; 2031 case 0x78: 2032 printf("2nd-level cache: 1 MB, 4-way set associative, 64-byte line size\n"); 2033 break; 2034 case 0x79: 2035 printf("2nd-level cache: 128 KB, 8-way set associative, sectored cache, 64 byte line size\n"); 2036 break; 2037 case 0x7a: 2038 printf("2nd-level cache: 256 KB, 8-way set associative, sectored cache, 64 byte line size\n"); 2039 break; 2040 case 0x7b: 2041 printf("2nd-level cache: 512 KB, 8-way set associative, sectored cache, 64 byte line size\n"); 2042 break; 2043 case 0x7c: 2044 printf("2nd-level cache: 1 MB, 8-way set associative, sectored cache, 64 byte line size\n"); 2045 break; 2046 case 0x7d: 2047 printf("2nd-level cache: 2-MB, 8-way set associative, 64-byte line size\n"); 2048 break; 2049 case 0x7f: 2050 printf("2nd-level cache: 512-KB, 2-way set associative, 64-byte line size\n"); 2051 break; 2052 case 0x80: 2053 printf("2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size\n"); 2054 break; 2055 case 0x82: 2056 printf("2nd-level cache: 256 KB, 8-way set associative, 32 byte line size\n"); 2057 break; 2058 case 0x83: 2059 printf("2nd-level cache: 512 KB, 8-way set associative, 32 byte line size\n"); 2060 break; 2061 case 0x84: 2062 printf("2nd-level cache: 1 MB, 8-way set associative, 32 byte line size\n"); 2063 break; 2064 case 0x85: 2065 printf("2nd-level cache: 2 MB, 8-way set associative, 32 byte line size\n"); 2066 break; 2067 case 0x86: 2068 printf("2nd-level cache: 512 KB, 4-way set associative, 64 byte line size\n"); 2069 break; 2070 case 0x87: 2071 printf("2nd-level cache: 1 MB, 8-way set associative, 64 byte line size\n"); 2072 break; 2073 case 0xa0: 2074 printf("DTLB: 4k pages, fully associative, 32 entries\n"); 2075 break; 2076 case 0xb0: 2077 printf("Instruction TLB: 4 KB Pages, 4-way set associative, 128 entries\n"); 2078 break; 2079 case 0xb1: 2080 printf("Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries\n"); 2081 break; 2082 case 0xb2: 2083 printf("Instruction TLB: 4KByte pages, 4-way set associative, 64 entries\n"); 2084 break; 2085 case 0xb3: 2086 printf("Data TLB: 4 KB Pages, 4-way set associative, 128 entries\n"); 2087 break; 2088 case 0xb4: 2089 printf("Data TLB1: 4 KByte pages, 4-way associative, 256 entries\n"); 2090 break; 2091 case 0xb5: 2092 printf("Instruction TLB: 4KByte pages, 8-way set associative, 64 entries\n"); 2093 break; 2094 case 0xb6: 2095 printf("Instruction TLB: 4KByte pages, 8-way set associative, 128 entries\n"); 2096 break; 2097 case 0xba: 2098 printf("Data TLB1: 4 KByte pages, 4-way associative, 64 entries\n"); 2099 break; 2100 case 0xc0: 2101 printf("Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries\n"); 2102 break; 2103 case 0xc1: 2104 printf("Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries\n"); 2105 break; 2106 case 0xc2: 2107 printf("DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries\n"); 2108 break; 2109 case 0xc3: 2110 printf("Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, 1536 entries. Also 1GBbyte pages, 4-way, 16 entries\n"); 2111 break; 2112 case 0xc4: 2113 printf("DTLB: 2M/4M Byte pages, 4-way associative, 32 entries\n"); 2114 break; 2115 case 0xca: 2116 printf("Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries\n"); 2117 break; 2118 case 0xd0: 2119 printf("3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size\n"); 2120 break; 2121 case 0xd1: 2122 printf("3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size\n"); 2123 break; 2124 case 0xd2: 2125 printf("3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size\n"); 2126 break; 2127 case 0xd6: 2128 printf("3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size\n"); 2129 break; 2130 case 0xd7: 2131 printf("3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size\n"); 2132 break; 2133 case 0xd8: 2134 printf("3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size\n"); 2135 break; 2136 case 0xdc: 2137 printf("3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size\n"); 2138 break; 2139 case 0xdd: 2140 printf("3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size\n"); 2141 break; 2142 case 0xde: 2143 printf("3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size\n"); 2144 break; 2145 case 0xe2: 2146 printf("3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size\n"); 2147 break; 2148 case 0xe3: 2149 printf("3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size\n"); 2150 break; 2151 case 0xe4: 2152 printf("3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size\n"); 2153 break; 2154 case 0xea: 2155 printf("3rd-level cache: 12MByte, 24-way set associative, 64 byte line size\n"); 2156 break; 2157 case 0xeb: 2158 printf("3rd-level cache: 18MByte, 24-way set associative, 64 byte line size\n"); 2159 break; 2160 case 0xec: 2161 printf("3rd-level cache: 24MByte, 24-way set associative, 64 byte line size\n"); 2162 break; 2163 case 0xf0: 2164 printf("64-Byte prefetching\n"); 2165 break; 2166 case 0xf1: 2167 printf("128-Byte prefetching\n"); 2168 break; 2169 } 2170} 2171 2172static void 2173print_svm_info(void) 2174{ 2175 u_int features, regs[4]; 2176 uint64_t msr; 2177 int comma; 2178 2179 printf("\n SVM: "); 2180 do_cpuid(0x8000000A, regs); 2181 features = regs[3]; 2182 2183 msr = rdmsr(MSR_VM_CR); 2184 if ((msr & VM_CR_SVMDIS) == VM_CR_SVMDIS) 2185 printf("(disabled in BIOS) "); 2186 2187 if (!bootverbose) { 2188 comma = 0; 2189 if (features & (1 << 0)) { 2190 printf("%sNP", comma ? "," : ""); 2191 comma = 1; 2192 } 2193 if (features & (1 << 3)) { 2194 printf("%sNRIP", comma ? "," : ""); 2195 comma = 1; 2196 } 2197 if (features & (1 << 5)) { 2198 printf("%sVClean", comma ? "," : ""); 2199 comma = 1; 2200 } 2201 if (features & (1 << 6)) { 2202 printf("%sAFlush", comma ? "," : ""); 2203 comma = 1; 2204 } 2205 if (features & (1 << 7)) { 2206 printf("%sDAssist", comma ? "," : ""); 2207 comma = 1; 2208 } 2209 printf("%sNAsids=%d", comma ? "," : "", regs[1]); 2210 return; 2211 } 2212 2213 printf("Features=0x%b", features, 2214 "\020" 2215 "\001NP" /* Nested paging */ 2216 "\002LbrVirt" /* LBR virtualization */ 2217 "\003SVML" /* SVM lock */ 2218 "\004NRIPS" /* NRIP save */ 2219 "\005TscRateMsr" /* MSR based TSC rate control */ 2220 "\006VmcbClean" /* VMCB clean bits */ 2221 "\007FlushByAsid" /* Flush by ASID */ 2222 "\010DecodeAssist" /* Decode assist */ 2223 "\011<b8>" 2224 "\012<b9>" 2225 "\013PauseFilter" /* PAUSE intercept filter */ 2226 "\014<b11>" 2227 "\015PauseFilterThreshold" /* PAUSE filter threshold */ 2228 "\016AVIC" /* virtual interrupt controller */ 2229 ); 2230 printf("\nRevision=%d, ASIDs=%d", regs[0] & 0xff, regs[1]); 2231} 2232 2233#ifdef __i386__ 2234static void 2235print_transmeta_info(void) 2236{ 2237 u_int regs[4], nreg = 0; 2238 2239 do_cpuid(0x80860000, regs); 2240 nreg = regs[0]; 2241 if (nreg >= 0x80860001) { 2242 do_cpuid(0x80860001, regs); 2243 printf(" Processor revision %u.%u.%u.%u\n", 2244 (regs[1] >> 24) & 0xff, 2245 (regs[1] >> 16) & 0xff, 2246 (regs[1] >> 8) & 0xff, 2247 regs[1] & 0xff); 2248 } 2249 if (nreg >= 0x80860002) { 2250 do_cpuid(0x80860002, regs); 2251 printf(" Code Morphing Software revision %u.%u.%u-%u-%u\n", 2252 (regs[1] >> 24) & 0xff, 2253 (regs[1] >> 16) & 0xff, 2254 (regs[1] >> 8) & 0xff, 2255 regs[1] & 0xff, 2256 regs[2]); 2257 } 2258 if (nreg >= 0x80860006) { 2259 char info[65]; 2260 do_cpuid(0x80860003, (u_int*) &info[0]); 2261 do_cpuid(0x80860004, (u_int*) &info[16]); 2262 do_cpuid(0x80860005, (u_int*) &info[32]); 2263 do_cpuid(0x80860006, (u_int*) &info[48]); 2264 info[64] = 0; 2265 printf(" %s\n", info); 2266 } 2267} 2268#endif 2269 2270static void 2271print_via_padlock_info(void) 2272{ 2273 u_int regs[4]; 2274 2275 do_cpuid(0xc0000001, regs); 2276 printf("\n VIA Padlock Features=0x%b", regs[3], 2277 "\020" 2278 "\003RNG" /* RNG */ 2279 "\007AES" /* ACE */ 2280 "\011AES-CTR" /* ACE2 */ 2281 "\013SHA1,SHA256" /* PHE */ 2282 "\015RSA" /* PMM */ 2283 ); 2284} 2285 2286static uint32_t 2287vmx_settable(uint64_t basic, int msr, int true_msr) 2288{ 2289 uint64_t val; 2290 2291 if (basic & (1ULL << 55)) 2292 val = rdmsr(true_msr); 2293 else 2294 val = rdmsr(msr); 2295 2296 /* Just report the controls that can be set to 1. */ 2297 return (val >> 32); 2298} 2299 2300static void 2301print_vmx_info(void) 2302{ 2303 uint64_t basic, msr; 2304 uint32_t entry, exit, mask, pin, proc, proc2; 2305 int comma; 2306 2307 printf("\n VT-x: "); 2308 msr = rdmsr(MSR_IA32_FEATURE_CONTROL); 2309 if (!(msr & IA32_FEATURE_CONTROL_VMX_EN)) 2310 printf("(disabled in BIOS) "); 2311 basic = rdmsr(MSR_VMX_BASIC); 2312 pin = vmx_settable(basic, MSR_VMX_PINBASED_CTLS, 2313 MSR_VMX_TRUE_PINBASED_CTLS); 2314 proc = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS, 2315 MSR_VMX_TRUE_PROCBASED_CTLS); 2316 if (proc & PROCBASED_SECONDARY_CONTROLS) 2317 proc2 = vmx_settable(basic, MSR_VMX_PROCBASED_CTLS2, 2318 MSR_VMX_PROCBASED_CTLS2); 2319 else 2320 proc2 = 0; 2321 exit = vmx_settable(basic, MSR_VMX_EXIT_CTLS, MSR_VMX_TRUE_EXIT_CTLS); 2322 entry = vmx_settable(basic, MSR_VMX_ENTRY_CTLS, MSR_VMX_TRUE_ENTRY_CTLS); 2323 2324 if (!bootverbose) { 2325 comma = 0; 2326 if (exit & VM_EXIT_SAVE_PAT && exit & VM_EXIT_LOAD_PAT && 2327 entry & VM_ENTRY_LOAD_PAT) { 2328 printf("%sPAT", comma ? "," : ""); 2329 comma = 1; 2330 } 2331 if (proc & PROCBASED_HLT_EXITING) { 2332 printf("%sHLT", comma ? "," : ""); 2333 comma = 1; 2334 } 2335 if (proc & PROCBASED_MTF) { 2336 printf("%sMTF", comma ? "," : ""); 2337 comma = 1; 2338 } 2339 if (proc & PROCBASED_PAUSE_EXITING) { 2340 printf("%sPAUSE", comma ? "," : ""); 2341 comma = 1; 2342 } 2343 if (proc2 & PROCBASED2_ENABLE_EPT) { 2344 printf("%sEPT", comma ? "," : ""); 2345 comma = 1; 2346 } 2347 if (proc2 & PROCBASED2_UNRESTRICTED_GUEST) { 2348 printf("%sUG", comma ? "," : ""); 2349 comma = 1; 2350 } 2351 if (proc2 & PROCBASED2_ENABLE_VPID) { 2352 printf("%sVPID", comma ? "," : ""); 2353 comma = 1; 2354 } 2355 if (proc & PROCBASED_USE_TPR_SHADOW && 2356 proc2 & PROCBASED2_VIRTUALIZE_APIC_ACCESSES && 2357 proc2 & PROCBASED2_VIRTUALIZE_X2APIC_MODE && 2358 proc2 & PROCBASED2_APIC_REGISTER_VIRTUALIZATION && 2359 proc2 & PROCBASED2_VIRTUAL_INTERRUPT_DELIVERY) { 2360 printf("%sVID", comma ? "," : ""); 2361 comma = 1; 2362 if (pin & PINBASED_POSTED_INTERRUPT) 2363 printf(",PostIntr"); 2364 } 2365 return; 2366 } 2367 2368 mask = basic >> 32; 2369 printf("Basic Features=0x%b", mask, 2370 "\020" 2371 "\02132PA" /* 32-bit physical addresses */ 2372 "\022SMM" /* SMM dual-monitor */ 2373 "\027INS/OUTS" /* VM-exit info for INS and OUTS */ 2374 "\030TRUE" /* TRUE_CTLS MSRs */ 2375 ); 2376 printf("\n Pin-Based Controls=0x%b", pin, 2377 "\020" 2378 "\001ExtINT" /* External-interrupt exiting */ 2379 "\004NMI" /* NMI exiting */ 2380 "\006VNMI" /* Virtual NMIs */ 2381 "\007PreTmr" /* Activate VMX-preemption timer */ 2382 "\010PostIntr" /* Process posted interrupts */ 2383 ); 2384 printf("\n Primary Processor Controls=0x%b", proc, 2385 "\020" 2386 "\003INTWIN" /* Interrupt-window exiting */ 2387 "\004TSCOff" /* Use TSC offsetting */ 2388 "\010HLT" /* HLT exiting */ 2389 "\012INVLPG" /* INVLPG exiting */ 2390 "\013MWAIT" /* MWAIT exiting */ 2391 "\014RDPMC" /* RDPMC exiting */ 2392 "\015RDTSC" /* RDTSC exiting */ 2393 "\020CR3-LD" /* CR3-load exiting */ 2394 "\021CR3-ST" /* CR3-store exiting */ 2395 "\024CR8-LD" /* CR8-load exiting */ 2396 "\025CR8-ST" /* CR8-store exiting */ 2397 "\026TPR" /* Use TPR shadow */ 2398 "\027NMIWIN" /* NMI-window exiting */ 2399 "\030MOV-DR" /* MOV-DR exiting */ 2400 "\031IO" /* Unconditional I/O exiting */ 2401 "\032IOmap" /* Use I/O bitmaps */ 2402 "\034MTF" /* Monitor trap flag */ 2403 "\035MSRmap" /* Use MSR bitmaps */ 2404 "\036MONITOR" /* MONITOR exiting */ 2405 "\037PAUSE" /* PAUSE exiting */ 2406 ); 2407 if (proc & PROCBASED_SECONDARY_CONTROLS) 2408 printf("\n Secondary Processor Controls=0x%b", proc2, 2409 "\020" 2410 "\001APIC" /* Virtualize APIC accesses */ 2411 "\002EPT" /* Enable EPT */ 2412 "\003DT" /* Descriptor-table exiting */ 2413 "\004RDTSCP" /* Enable RDTSCP */ 2414 "\005x2APIC" /* Virtualize x2APIC mode */ 2415 "\006VPID" /* Enable VPID */ 2416 "\007WBINVD" /* WBINVD exiting */ 2417 "\010UG" /* Unrestricted guest */ 2418 "\011APIC-reg" /* APIC-register virtualization */ 2419 "\012VID" /* Virtual-interrupt delivery */ 2420 "\013PAUSE-loop" /* PAUSE-loop exiting */ 2421 "\014RDRAND" /* RDRAND exiting */ 2422 "\015INVPCID" /* Enable INVPCID */ 2423 "\016VMFUNC" /* Enable VM functions */ 2424 "\017VMCS" /* VMCS shadowing */ 2425 "\020EPT#VE" /* EPT-violation #VE */ 2426 "\021XSAVES" /* Enable XSAVES/XRSTORS */ 2427 ); 2428 printf("\n Exit Controls=0x%b", mask, 2429 "\020" 2430 "\003DR" /* Save debug controls */ 2431 /* Ignore Host address-space size */ 2432 "\015PERF" /* Load MSR_PERF_GLOBAL_CTRL */ 2433 "\020AckInt" /* Acknowledge interrupt on exit */ 2434 "\023PAT-SV" /* Save MSR_PAT */ 2435 "\024PAT-LD" /* Load MSR_PAT */ 2436 "\025EFER-SV" /* Save MSR_EFER */ 2437 "\026EFER-LD" /* Load MSR_EFER */ 2438 "\027PTMR-SV" /* Save VMX-preemption timer value */ 2439 ); 2440 printf("\n Entry Controls=0x%b", mask, 2441 "\020" 2442 "\003DR" /* Save debug controls */ 2443 /* Ignore IA-32e mode guest */ 2444 /* Ignore Entry to SMM */ 2445 /* Ignore Deactivate dual-monitor treatment */ 2446 "\016PERF" /* Load MSR_PERF_GLOBAL_CTRL */ 2447 "\017PAT" /* Load MSR_PAT */ 2448 "\020EFER" /* Load MSR_EFER */ 2449 ); 2450 if (proc & PROCBASED_SECONDARY_CONTROLS && 2451 (proc2 & (PROCBASED2_ENABLE_EPT | PROCBASED2_ENABLE_VPID)) != 0) { 2452 msr = rdmsr(MSR_VMX_EPT_VPID_CAP); 2453 mask = msr; 2454 printf("\n EPT Features=0x%b", mask, 2455 "\020" 2456 "\001XO" /* Execute-only translations */ 2457 "\007PW4" /* Page-walk length of 4 */ 2458 "\011UC" /* EPT paging-structure mem can be UC */ 2459 "\017WB" /* EPT paging-structure mem can be WB */ 2460 "\0212M" /* EPT PDE can map a 2-Mbyte page */ 2461 "\0221G" /* EPT PDPTE can map a 1-Gbyte page */ 2462 "\025INVEPT" /* INVEPT is supported */ 2463 "\026AD" /* Accessed and dirty flags for EPT */ 2464 "\032single" /* INVEPT single-context type */ 2465 "\033all" /* INVEPT all-context type */ 2466 ); 2467 mask = msr >> 32; 2468 printf("\n VPID Features=0x%b", mask, 2469 "\020" 2470 "\001INVVPID" /* INVVPID is supported */ 2471 "\011individual" /* INVVPID individual-address type */ 2472 "\012single" /* INVVPID single-context type */ 2473 "\013all" /* INVVPID all-context type */ 2474 /* INVVPID single-context-retaining-globals type */ 2475 "\014single-globals" 2476 ); 2477 } 2478} 2479 2480static void 2481print_hypervisor_info(void) 2482{ 2483 2484 if (*hv_vendor) 2485 printf("Hypervisor: Origin = \"%s\"\n", hv_vendor); 2486} 2487