1 /*
   2  * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef CPU_X86_VM_VERSION_X86_HPP
  26 #define CPU_X86_VM_VERSION_X86_HPP
  27 
  28 #include "runtime/abstract_vm_version.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/macros.hpp"
  31 #include "utilities/sizes.hpp"
  32 
  33 class stringStream;
  34 
  35 class VM_Version : public Abstract_VM_Version {
  36   friend class VMStructs;
  37   friend class JVMCIVMStructs;
  38 
  39  public:
  40   // cpuid result register layouts.  These are all unions of a uint32_t
  41   // (in case anyone wants access to the register as a whole) and a bitfield.
  42 
  43   union StdCpuid1Eax {
  44     uint32_t value;
  45     struct {
  46       uint32_t stepping   : 4,
  47                model      : 4,
  48                family     : 4,
  49                proc_type  : 2,
  50                           : 2,
  51                ext_model  : 4,
  52                ext_family : 8,
  53                           : 4;
  54     } bits;
  55   };
  56 
  57   union StdCpuid1Ebx { // example, unused
  58     uint32_t value;
  59     struct {
  60       uint32_t brand_id         : 8,
  61                clflush_size     : 8,
  62                threads_per_cpu  : 8,
  63                apic_id          : 8;
  64     } bits;
  65   };
  66 
  67   union StdCpuid1Ecx {
  68     uint32_t value;
  69     struct {
  70       uint32_t sse3     : 1,
  71                clmul    : 1,
  72                         : 1,
  73                monitor  : 1,
  74                         : 1,
  75                vmx      : 1,
  76                         : 1,
  77                est      : 1,
  78                         : 1,
  79                ssse3    : 1,
  80                cid      : 1,
  81                         : 1,
  82                fma      : 1,
  83                cmpxchg16: 1,
  84                         : 4,
  85                dca      : 1,
  86                sse4_1   : 1,
  87                sse4_2   : 1,
  88                         : 2,
  89                popcnt   : 1,
  90                         : 1,
  91                aes      : 1,
  92                         : 1,
  93                osxsave  : 1,
  94                avx      : 1,
  95                f16c     : 1,
  96                         : 1,
  97                hv       : 1;
  98     } bits;
  99   };
 100 
 101   union StdCpuid1Edx {
 102     uint32_t value;
 103     struct {
 104       uint32_t          : 4,
 105                tsc      : 1,
 106                         : 3,
 107                cmpxchg8 : 1,
 108                         : 6,
 109                cmov     : 1,
 110                         : 3,
 111                clflush  : 1,
 112                         : 3,
 113                mmx      : 1,
 114                fxsr     : 1,
 115                sse      : 1,
 116                sse2     : 1,
 117                         : 1,
 118                ht       : 1,
 119                         : 3;
 120     } bits;
 121   };
 122 
 123   union DcpCpuid4Eax {
 124     uint32_t value;
 125     struct {
 126       uint32_t cache_type    : 5,
 127                              : 21,
 128                cores_per_cpu : 6;
 129     } bits;
 130   };
 131 
 132   union DcpCpuid4Ebx {
 133     uint32_t value;
 134     struct {
 135       uint32_t L1_line_size  : 12,
 136                partitions    : 10,
 137                associativity : 10;
 138     } bits;
 139   };
 140 
 141   union TplCpuidBEbx {
 142     uint32_t value;
 143     struct {
 144       uint32_t logical_cpus : 16,
 145                             : 16;
 146     } bits;
 147   };
 148 
 149   union ExtCpuid1Ecx {
 150     uint32_t value;
 151     struct {
 152       uint32_t LahfSahf     : 1,
 153                CmpLegacy    : 1,
 154                             : 3,
 155                lzcnt        : 1,
 156                sse4a        : 1,
 157                misalignsse  : 1,
 158                prefetchw    : 1,
 159                             : 23;
 160     } bits;
 161   };
 162 
 163   union ExtCpuid1Edx {
 164     uint32_t value;
 165     struct {
 166       uint32_t           : 22,
 167                mmx_amd   : 1,
 168                mmx       : 1,
 169                fxsr      : 1,
 170                fxsr_opt  : 1,
 171                pdpe1gb   : 1,
 172                rdtscp    : 1,
 173                          : 1,
 174                long_mode : 1,
 175                tdnow2    : 1,
 176                tdnow     : 1;
 177     } bits;
 178   };
 179 
 180   union ExtCpuid5Ex {
 181     uint32_t value;
 182     struct {
 183       uint32_t L1_line_size : 8,
 184                L1_tag_lines : 8,
 185                L1_assoc     : 8,
 186                L1_size      : 8;
 187     } bits;
 188   };
 189 
 190   union ExtCpuid7Edx {
 191     uint32_t value;
 192     struct {
 193       uint32_t               : 8,
 194               tsc_invariance : 1,
 195                              : 23;
 196     } bits;
 197   };
 198 
 199   union ExtCpuid8Ecx {
 200     uint32_t value;
 201     struct {
 202       uint32_t cores_per_cpu : 8,
 203                              : 24;
 204     } bits;
 205   };
 206 
 207   union SefCpuid7Eax {
 208     uint32_t value;
 209   };
 210 
 211   union SefCpuid7Ebx {
 212     uint32_t value;
 213     struct {
 214       uint32_t fsgsbase : 1,
 215                         : 2,
 216                    bmi1 : 1,
 217                         : 1,
 218                    avx2 : 1,
 219                         : 2,
 220                    bmi2 : 1,
 221                    erms : 1,
 222                         : 1,
 223                     rtm : 1,
 224                         : 4,
 225                 avx512f : 1,
 226                avx512dq : 1,
 227                         : 1,
 228                     adx : 1,
 229                         : 1,
 230              avx512ifma : 1,
 231                         : 1,
 232              clflushopt : 1,
 233                    clwb : 1,
 234                         : 1,
 235                avx512pf : 1,
 236                avx512er : 1,
 237                avx512cd : 1,
 238                     sha : 1,
 239                avx512bw : 1,
 240                avx512vl : 1;
 241     } bits;
 242   };
 243 
 244   union SefCpuid7Ecx {
 245     uint32_t value;
 246     struct {
 247       uint32_t prefetchwt1 : 1,
 248                avx512_vbmi : 1,
 249                       umip : 1,
 250                        pku : 1,
 251                      ospke : 1,
 252                            : 1,
 253               avx512_vbmi2 : 1,
 254                     cet_ss : 1,
 255                       gfni : 1,
 256                       vaes : 1,
 257          avx512_vpclmulqdq : 1,
 258                avx512_vnni : 1,
 259              avx512_bitalg : 1,
 260                            : 1,
 261           avx512_vpopcntdq : 1,
 262                            : 1,
 263                            : 1,
 264                      mawau : 5,
 265                      rdpid : 1,
 266                            : 9;
 267     } bits;
 268   };
 269 
 270   union SefCpuid7Edx {
 271     uint32_t value;
 272     struct {
 273       uint32_t             : 2,
 274              avx512_4vnniw : 1,
 275              avx512_4fmaps : 1,
 276         fast_short_rep_mov : 1,
 277                            : 9,
 278                  serialize : 1,
 279                            : 5,
 280                    cet_ibt : 1,
 281                            : 2,
 282               avx512_fp16  : 1,
 283                            : 8;
 284     } bits;
 285   };
 286 
 287   union SefCpuid7SubLeaf1Eax {
 288     uint32_t value;
 289     struct {
 290       uint32_t    sha512   : 1,
 291                            : 22,
 292                   avx_ifma : 1,
 293                            : 8;
 294     } bits;
 295   };
 296 
 297   union SefCpuid7SubLeaf1Edx {
 298     uint32_t value;
 299     struct {
 300       uint32_t       : 19,
 301               avx10  : 1,
 302                      : 1,
 303               apx_f  : 1,
 304                      : 10;
 305     } bits;
 306   };
 307 
 308   union StdCpuid24MainLeafEax {
 309     uint32_t value;
 310     struct {
 311       uint32_t  sub_leaves_cnt  : 31;
 312     } bits;
 313   };
 314 
 315   union StdCpuid24MainLeafEbx {
 316     uint32_t value;
 317     struct {
 318       uint32_t  avx10_converged_isa_version  : 8,
 319                                              : 8,
 320                                              : 2,
 321                 avx10_vlen_512               : 1,
 322                                              : 13;
 323     } bits;
 324   };
 325 
 326   union ExtCpuid1EEbx {
 327     uint32_t value;
 328     struct {
 329       uint32_t                  : 8,
 330                threads_per_core : 8,
 331                                 : 16;
 332     } bits;
 333   };
 334 
 335   union XemXcr0Eax {
 336     uint32_t value;
 337     struct {
 338       uint32_t x87     : 1,
 339                sse     : 1,
 340                ymm     : 1,
 341                bndregs : 1,
 342                bndcsr  : 1,
 343                opmask  : 1,
 344                zmm512  : 1,
 345                zmm32   : 1,
 346                        : 11,
 347                apx_f   : 1,
 348                        : 12;
 349     } bits;
 350   };
 351 
 352 protected:
 353   static int _cpu;
 354   static int _model;
 355   static int _stepping;
 356 
 357   static bool _has_intel_jcc_erratum;
 358 
 359   static address   _cpuinfo_segv_addr;     // address of instruction which causes SEGV
 360   static address   _cpuinfo_cont_addr;     // address of instruction after the one which causes SEGV
 361   static address   _cpuinfo_segv_addr_apx; // address of instruction which causes APX specific SEGV
 362   static address   _cpuinfo_cont_addr_apx; // address of instruction after the one which causes APX specific SEGV
 363 
 364   /*
 365    * Update following files when declaring new flags:
 366    * test/lib-test/jdk/test/whitebox/CPUInfoTest.java
 367    * src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
 368    */
 369   enum Feature_Flag {
 370 #define CPU_FEATURE_FLAGS(decl) \
 371     decl(CX8,               cx8,               0)  /*  next bits are from cpuid 1 (EDX) */ \
 372     decl(CMOV,              cmov,              1)  \
 373     decl(FXSR,              fxsr,              2)  \
 374     decl(HT,                ht,                3)  \
 375                                                      \
 376     decl(MMX,               mmx,               4)  \
 377     decl(3DNOW_PREFETCH,    3dnowpref,         5)  /* Processor supports 3dnow prefetch and prefetchw instructions */ \
 378                                                      /* may not necessarily support other 3dnow instructions */ \
 379     decl(SSE,               sse,               6)  \
 380     decl(SSE2,              sse2,              7)  \
 381                                                      \
 382     decl(SSE3,              sse3,              8 ) /* SSE3 comes from cpuid 1 (ECX) */ \
 383     decl(SSSE3,             ssse3,             9 ) \
 384     decl(SSE4A,             sse4a,             10) \
 385     decl(SSE4_1,            sse4.1,            11) \
 386                                                      \
 387     decl(SSE4_2,            sse4.2,            12) \
 388     decl(POPCNT,            popcnt,            13) \
 389     decl(LZCNT,             lzcnt,             14) \
 390     decl(TSC,               tsc,               15) \
 391                                                      \
 392     decl(TSCINV_BIT,        tscinvbit,         16) \
 393     decl(TSCINV,            tscinv,            17) \
 394     decl(AVX,               avx,               18) \
 395     decl(AVX2,              avx2,              19) \
 396                                                      \
 397     decl(AES,               aes,               20) \
 398     decl(ERMS,              erms,              21) /* enhanced 'rep movsb/stosb' instructions */ \
 399     decl(CLMUL,             clmul,             22) /* carryless multiply for CRC */ \
 400     decl(BMI1,              bmi1,              23) \
 401                                                      \
 402     decl(BMI2,              bmi2,              24) \
 403     decl(RTM,               rtm,               25) /* Restricted Transactional Memory instructions */ \
 404     decl(ADX,               adx,               26) \
 405     decl(AVX512F,           avx512f,           27) /* AVX 512bit foundation instructions */ \
 406                                                      \
 407     decl(AVX512DQ,          avx512dq,          28) \
 408     decl(AVX512PF,          avx512pf,          29) \
 409     decl(AVX512ER,          avx512er,          30) \
 410     decl(AVX512CD,          avx512cd,          31) \
 411                                                      \
 412     decl(AVX512BW,          avx512bw,          32) /* Byte and word vector instructions */ \
 413     decl(AVX512VL,          avx512vl,          33) /* EVEX instructions with smaller vector length */ \
 414     decl(SHA,               sha,               34) /* SHA instructions */ \
 415     decl(FMA,               fma,               35) /* FMA instructions */ \
 416                                                      \
 417     decl(VZEROUPPER,        vzeroupper,        36) /* Vzeroupper instruction */ \
 418     decl(AVX512_VPOPCNTDQ,  avx512_vpopcntdq,  37) /* Vector popcount */ \
 419     decl(AVX512_VPCLMULQDQ, avx512_vpclmulqdq, 38) /* Vector carryless multiplication */ \
 420     decl(AVX512_VAES,       avx512_vaes,       39) /* Vector AES instruction */ \
 421                                                      \
 422     decl(AVX512_VNNI,       avx512_vnni,       40) /* Vector Neural Network Instructions */ \
 423     decl(FLUSH,             clflush,           41) /* flush instruction */ \
 424     decl(FLUSHOPT,          clflushopt,        42) /* flusopth instruction */ \
 425     decl(CLWB,              clwb,              43) /* clwb instruction */ \
 426                                                      \
 427     decl(AVX512_VBMI2,      avx512_vbmi2,      44) /* VBMI2 shift left double instructions */ \
 428     decl(AVX512_VBMI,       avx512_vbmi,       45) /* Vector BMI instructions */ \
 429     decl(HV,                hv,                46) /* Hypervisor instructions */ \
 430     decl(SERIALIZE,         serialize,         47) /* CPU SERIALIZE */ \
 431     decl(RDTSCP,            rdtscp,            48) /* RDTSCP instruction */ \
 432     decl(RDPID,             rdpid,             49) /* RDPID instruction */ \
 433     decl(FSRM,              fsrm,              50) /* Fast Short REP MOV */ \
 434     decl(GFNI,              gfni,              51) /* Vector GFNI instructions */ \
 435     decl(AVX512_BITALG,     avx512_bitalg,     52) /* Vector sub-word popcount and bit gather instructions */\
 436     decl(F16C,              f16c,              53) /* Half-precision and single precision FP conversion instructions*/ \
 437     decl(PKU,               pku,               54) /* Protection keys for user-mode pages */ \
 438     decl(OSPKE,             ospke,             55) /* OS enables protection keys */ \
 439     decl(CET_IBT,           cet_ibt,           56) /* Control Flow Enforcement - Indirect Branch Tracking */ \
 440     decl(CET_SS,            cet_ss,            57) /* Control Flow Enforcement - Shadow Stack */ \
 441     decl(AVX512_IFMA,       avx512_ifma,       58) /* Integer Vector FMA instructions*/ \
 442     decl(AVX_IFMA,          avx_ifma,          59) /* 256-bit VEX-coded variant of AVX512-IFMA*/ \
 443     decl(APX_F,             apx_f,             60) /* Intel Advanced Performance Extensions*/ \
 444     decl(SHA512,            sha512,            61) /* SHA512 instructions*/ \
 445     decl(AVX512_FP16,       avx512_fp16,       62) /* AVX512 FP16 ISA support*/ \
 446     decl(AVX10_1,           avx10_1,           63) /* AVX10 512 bit vector ISA Version 1 support*/ \
 447     decl(AVX10_2,           avx10_2,           64) /* AVX10 512 bit vector ISA Version 2 support*/
 448 
 449 #define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (bit),
 450     CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_FLAG)
 451 #undef DECLARE_CPU_FEATURE_FLAG
 452     MAX_CPU_FEATURES
 453   };
 454 
 455   class VM_Features {
 456     friend class VMStructs;
 457     friend class JVMCIVMStructs;
 458 
 459    private:
 460     uint64_t _features_bitmap[(MAX_CPU_FEATURES / BitsPerLong) + 1];
 461 
 462     STATIC_ASSERT(sizeof(_features_bitmap) * BitsPerByte >= MAX_CPU_FEATURES);
 463 
 464     // Number of 8-byte elements in _bitmap.
 465     constexpr static int features_bitmap_element_count() {
 466       return sizeof(_features_bitmap) / sizeof(uint64_t);
 467     }
 468 
 469     constexpr static int features_bitmap_element_shift_count() {
 470       return LogBitsPerLong;
 471     }
 472 
 473     constexpr static uint64_t features_bitmap_element_mask() {
 474       return (1ULL << features_bitmap_element_shift_count()) - 1;
 475     }
 476 
 477     static int index(Feature_Flag feature) {
 478       int idx = feature >> features_bitmap_element_shift_count();
 479       assert(idx < features_bitmap_element_count(), "Features array index out of bounds");
 480       return idx;
 481     }
 482 
 483     static uint64_t bit_mask(Feature_Flag feature) {
 484       return (1ULL << (feature & features_bitmap_element_mask()));
 485     }
 486 
 487     static int _features_bitmap_size; // for JVMCI purposes
 488 
 489    public:
 490     VM_Features() {
 491       for (int i = 0; i < features_bitmap_element_count(); i++) {
 492         _features_bitmap[i] = 0;
 493       }
 494     }
 495 
 496     void set_feature(Feature_Flag feature) {
 497       int idx = index(feature);
 498       _features_bitmap[idx] |= bit_mask(feature);
 499     }
 500 
 501     void clear_feature(VM_Version::Feature_Flag feature) {
 502       int idx = index(feature);
 503       _features_bitmap[idx] &= ~bit_mask(feature);
 504     }
 505 
 506     bool supports_feature(VM_Version::Feature_Flag feature) {
 507       int idx = index(feature);
 508       return (_features_bitmap[idx] & bit_mask(feature)) != 0;
 509     }
 510 
 511     bool supports_features(VM_Features* features_to_test) {
 512       for (int i = 0; i < features_bitmap_element_count(); i++) {
 513         if ((_features_bitmap[i] & features_to_test->_features_bitmap[i]) != features_to_test->_features_bitmap[i]) {
 514           return false;
 515        }
 516       }
 517       return true;
 518     }
 519   };
 520 
 521   // CPU feature flags vector, can be affected by VM settings.
 522   static VM_Features _features;
 523 
 524   // Original CPU feature flags vector, not affected by VM settings.
 525   static VM_Features _cpu_features;
 526 
 527   static const char* _features_names[];
 528 
 529   static void clear_cpu_features() {
 530     _features = VM_Features();
 531     _cpu_features = VM_Features();
 532   }
 533 
 534   enum Extended_Family {
 535     // AMD
 536     CPU_FAMILY_AMD_11H       = 0x11,
 537     CPU_FAMILY_AMD_17H       = 0x17, /* Zen1 & Zen2 */
 538     CPU_FAMILY_AMD_19H       = 0x19, /* Zen3 & Zen4 */
 539     // ZX
 540     CPU_FAMILY_ZX_CORE_F6    = 6,
 541     CPU_FAMILY_ZX_CORE_F7    = 7,
 542     // Intel
 543     CPU_FAMILY_INTEL_CORE    = 6,
 544     CPU_MODEL_NEHALEM        = 0x1e,
 545     CPU_MODEL_NEHALEM_EP     = 0x1a,
 546     CPU_MODEL_NEHALEM_EX     = 0x2e,
 547     CPU_MODEL_WESTMERE       = 0x25,
 548     CPU_MODEL_WESTMERE_EP    = 0x2c,
 549     CPU_MODEL_WESTMERE_EX    = 0x2f,
 550     CPU_MODEL_SANDYBRIDGE    = 0x2a,
 551     CPU_MODEL_SANDYBRIDGE_EP = 0x2d,
 552     CPU_MODEL_IVYBRIDGE_EP   = 0x3a,
 553     CPU_MODEL_HASWELL_E3     = 0x3c,
 554     CPU_MODEL_HASWELL_E7     = 0x3f,
 555     CPU_MODEL_BROADWELL      = 0x3d,
 556     CPU_MODEL_SKYLAKE        = 0x55
 557   };
 558 
 559   // cpuid information block.  All info derived from executing cpuid with
 560   // various function numbers is stored here.  Intel and AMD info is
 561   // merged in this block: accessor methods disentangle it.
 562   //
 563   // The info block is laid out in subblocks of 4 dwords corresponding to
 564   // eax, ebx, ecx and edx, whether or not they contain anything useful.
 565   class CpuidInfo {
 566   public:
 567     // cpuid function 0
 568     uint32_t std_max_function;
 569     uint32_t std_vendor_name_0;
 570     uint32_t std_vendor_name_1;
 571     uint32_t std_vendor_name_2;
 572 
 573     // cpuid function 1
 574     StdCpuid1Eax std_cpuid1_eax;
 575     StdCpuid1Ebx std_cpuid1_ebx;
 576     StdCpuid1Ecx std_cpuid1_ecx;
 577     StdCpuid1Edx std_cpuid1_edx;
 578 
 579     // cpuid function 4 (deterministic cache parameters)
 580     DcpCpuid4Eax dcp_cpuid4_eax;
 581     DcpCpuid4Ebx dcp_cpuid4_ebx;
 582     uint32_t     dcp_cpuid4_ecx; // unused currently
 583     uint32_t     dcp_cpuid4_edx; // unused currently
 584 
 585     // cpuid function 7 (structured extended features enumeration leaf)
 586     // eax = 7, ecx = 0
 587     SefCpuid7Eax sef_cpuid7_eax;
 588     SefCpuid7Ebx sef_cpuid7_ebx;
 589     SefCpuid7Ecx sef_cpuid7_ecx;
 590     SefCpuid7Edx sef_cpuid7_edx;
 591 
 592     // cpuid function 7 (structured extended features enumeration sub-leaf 1)
 593     // eax = 7, ecx = 1
 594     SefCpuid7SubLeaf1Eax sefsl1_cpuid7_eax;
 595     SefCpuid7SubLeaf1Edx sefsl1_cpuid7_edx;
 596 
 597     // cpuid function 24 converged vector ISA main leaf
 598     // eax = 24, ecx = 0
 599     StdCpuid24MainLeafEax std_cpuid24_eax;
 600     StdCpuid24MainLeafEbx std_cpuid24_ebx;
 601 
 602     // cpuid function 0xB (processor topology)
 603     // ecx = 0
 604     uint32_t     tpl_cpuidB0_eax;
 605     TplCpuidBEbx tpl_cpuidB0_ebx;
 606     uint32_t     tpl_cpuidB0_ecx; // unused currently
 607     uint32_t     tpl_cpuidB0_edx; // unused currently
 608 
 609     // ecx = 1
 610     uint32_t     tpl_cpuidB1_eax;
 611     TplCpuidBEbx tpl_cpuidB1_ebx;
 612     uint32_t     tpl_cpuidB1_ecx; // unused currently
 613     uint32_t     tpl_cpuidB1_edx; // unused currently
 614 
 615     // ecx = 2
 616     uint32_t     tpl_cpuidB2_eax;
 617     TplCpuidBEbx tpl_cpuidB2_ebx;
 618     uint32_t     tpl_cpuidB2_ecx; // unused currently
 619     uint32_t     tpl_cpuidB2_edx; // unused currently
 620 
 621     // cpuid function 0x80000000 // example, unused
 622     uint32_t ext_max_function;
 623     uint32_t ext_vendor_name_0;
 624     uint32_t ext_vendor_name_1;
 625     uint32_t ext_vendor_name_2;
 626 
 627     // cpuid function 0x80000001
 628     uint32_t     ext_cpuid1_eax; // reserved
 629     uint32_t     ext_cpuid1_ebx; // reserved
 630     ExtCpuid1Ecx ext_cpuid1_ecx;
 631     ExtCpuid1Edx ext_cpuid1_edx;
 632 
 633     // cpuid functions 0x80000002 thru 0x80000004: example, unused
 634     uint32_t proc_name_0, proc_name_1, proc_name_2, proc_name_3;
 635     uint32_t proc_name_4, proc_name_5, proc_name_6, proc_name_7;
 636     uint32_t proc_name_8, proc_name_9, proc_name_10,proc_name_11;
 637 
 638     // cpuid function 0x80000005 // AMD L1, Intel reserved
 639     uint32_t     ext_cpuid5_eax; // unused currently
 640     uint32_t     ext_cpuid5_ebx; // reserved
 641     ExtCpuid5Ex  ext_cpuid5_ecx; // L1 data cache info (AMD)
 642     ExtCpuid5Ex  ext_cpuid5_edx; // L1 instruction cache info (AMD)
 643 
 644     // cpuid function 0x80000007
 645     uint32_t     ext_cpuid7_eax; // reserved
 646     uint32_t     ext_cpuid7_ebx; // reserved
 647     uint32_t     ext_cpuid7_ecx; // reserved
 648     ExtCpuid7Edx ext_cpuid7_edx; // tscinv
 649 
 650     // cpuid function 0x80000008
 651     uint32_t     ext_cpuid8_eax; // unused currently
 652     uint32_t     ext_cpuid8_ebx; // reserved
 653     ExtCpuid8Ecx ext_cpuid8_ecx;
 654     uint32_t     ext_cpuid8_edx; // reserved
 655 
 656     // cpuid function 0x8000001E // AMD 17h
 657     uint32_t      ext_cpuid1E_eax;
 658     ExtCpuid1EEbx ext_cpuid1E_ebx; // threads per core (AMD17h)
 659     uint32_t      ext_cpuid1E_ecx;
 660     uint32_t      ext_cpuid1E_edx; // unused currently
 661 
 662     // extended control register XCR0 (the XFEATURE_ENABLED_MASK register)
 663     XemXcr0Eax   xem_xcr0_eax;
 664     uint32_t     xem_xcr0_edx; // reserved
 665 
 666     // Space to save ymm registers after signal handle
 667     int          ymm_save[8*4]; // Save ymm0, ymm7, ymm8, ymm15
 668 
 669     // Space to save zmm registers after signal handle
 670     int          zmm_save[16*4]; // Save zmm0, zmm7, zmm8, zmm31
 671 
 672     // Space to save apx registers after signal handle
 673     jlong        apx_save[2]; // Save r16 and r31
 674 
 675     VM_Features feature_flags() const;
 676 
 677     // Asserts
 678     void assert_is_initialized() const {
 679       assert(std_cpuid1_eax.bits.family != 0, "VM_Version not initialized");
 680     }
 681 
 682     // Extractors
 683     uint32_t extended_cpu_family() const {
 684       uint32_t result = std_cpuid1_eax.bits.family;
 685       result += std_cpuid1_eax.bits.ext_family;
 686       return result;
 687     }
 688 
 689     uint32_t extended_cpu_model() const {
 690       uint32_t result = std_cpuid1_eax.bits.model;
 691       result |= std_cpuid1_eax.bits.ext_model << 4;
 692       return result;
 693     }
 694 
 695     uint32_t cpu_stepping() const {
 696       uint32_t result = std_cpuid1_eax.bits.stepping;
 697       return result;
 698     }
 699   };
 700 
 701 private:
 702   // The actual cpuid info block
 703   static CpuidInfo _cpuid_info;
 704 
 705   // Extractors and predicates
 706   static uint logical_processor_count() {
 707     uint result = threads_per_core();
 708     return result;
 709   }
 710 
 711   static bool compute_has_intel_jcc_erratum();
 712 
 713   static bool os_supports_avx_vectors();
 714   static bool os_supports_apx_egprs();
 715   static void get_processor_features();
 716 
 717 public:
 718   // Offsets for cpuid asm stub
 719   static ByteSize std_cpuid0_offset() { return byte_offset_of(CpuidInfo, std_max_function); }
 720   static ByteSize std_cpuid1_offset() { return byte_offset_of(CpuidInfo, std_cpuid1_eax); }
 721   static ByteSize std_cpuid24_offset() { return byte_offset_of(CpuidInfo, std_cpuid24_eax); }
 722   static ByteSize dcp_cpuid4_offset() { return byte_offset_of(CpuidInfo, dcp_cpuid4_eax); }
 723   static ByteSize sef_cpuid7_offset() { return byte_offset_of(CpuidInfo, sef_cpuid7_eax); }
 724   static ByteSize sefsl1_cpuid7_offset() { return byte_offset_of(CpuidInfo, sefsl1_cpuid7_eax); }
 725   static ByteSize ext_cpuid1_offset() { return byte_offset_of(CpuidInfo, ext_cpuid1_eax); }
 726   static ByteSize ext_cpuid5_offset() { return byte_offset_of(CpuidInfo, ext_cpuid5_eax); }
 727   static ByteSize ext_cpuid7_offset() { return byte_offset_of(CpuidInfo, ext_cpuid7_eax); }
 728   static ByteSize ext_cpuid8_offset() { return byte_offset_of(CpuidInfo, ext_cpuid8_eax); }
 729   static ByteSize ext_cpuid1E_offset() { return byte_offset_of(CpuidInfo, ext_cpuid1E_eax); }
 730   static ByteSize tpl_cpuidB0_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB0_eax); }
 731   static ByteSize tpl_cpuidB1_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB1_eax); }
 732   static ByteSize tpl_cpuidB2_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB2_eax); }
 733   static ByteSize xem_xcr0_offset() { return byte_offset_of(CpuidInfo, xem_xcr0_eax); }
 734   static ByteSize ymm_save_offset() { return byte_offset_of(CpuidInfo, ymm_save); }
 735   static ByteSize zmm_save_offset() { return byte_offset_of(CpuidInfo, zmm_save); }
 736   static ByteSize apx_save_offset() { return byte_offset_of(CpuidInfo, apx_save); }
 737 
 738   // The value used to check ymm register after signal handle
 739   static int ymm_test_value()    { return 0xCAFEBABE; }
 740   static jlong egpr_test_value()   { return 0xCAFEBABECAFEBABELL; }
 741 
 742   static void get_cpu_info_wrapper();
 743   static void set_cpuinfo_segv_addr(address pc) { _cpuinfo_segv_addr = pc; }
 744   static bool  is_cpuinfo_segv_addr(address pc) { return _cpuinfo_segv_addr == pc; }
 745   static void set_cpuinfo_cont_addr(address pc) { _cpuinfo_cont_addr = pc; }
 746   static address  cpuinfo_cont_addr()           { return _cpuinfo_cont_addr; }
 747 
 748   static void set_cpuinfo_segv_addr_apx(address pc) { _cpuinfo_segv_addr_apx = pc; }
 749   static bool  is_cpuinfo_segv_addr_apx(address pc) { return _cpuinfo_segv_addr_apx == pc; }
 750   static void set_cpuinfo_cont_addr_apx(address pc) { _cpuinfo_cont_addr_apx = pc; }
 751   static address  cpuinfo_cont_addr_apx()           { return _cpuinfo_cont_addr_apx; }
 752 
 753   static void clear_apx_test_state();
 754 
 755   static void clean_cpuFeatures()   {
 756     VM_Version::clear_cpu_features();
 757   }
 758   static void set_avx_cpuFeatures() {
 759     _features.set_feature(CPU_SSE);
 760     _features.set_feature(CPU_SSE2);
 761     _features.set_feature(CPU_AVX);
 762     _features.set_feature(CPU_VZEROUPPER);
 763   }
 764   static void set_evex_cpuFeatures() {
 765     _features.set_feature(CPU_AVX10_1);
 766     _features.set_feature(CPU_AVX512F);
 767     _features.set_feature(CPU_SSE);
 768     _features.set_feature(CPU_SSE2);
 769     _features.set_feature(CPU_VZEROUPPER);
 770   }
 771   static void set_apx_cpuFeatures() { _features.set_feature(CPU_APX_F); }
 772   static void set_bmi_cpuFeatures() {
 773     _features.set_feature(CPU_BMI1);
 774     _features.set_feature(CPU_BMI2);
 775     _features.set_feature(CPU_LZCNT);
 776     _features.set_feature(CPU_POPCNT);
 777   }
 778 
 779   // Initialization
 780   static void initialize();
 781 
 782   // Override Abstract_VM_Version implementation
 783   static void print_platform_virtualization_info(outputStream*);
 784 
 785   //
 786   // Processor family:
 787   //       3   -  386
 788   //       4   -  486
 789   //       5   -  Pentium
 790   //       6   -  PentiumPro, Pentium II, Celeron, Xeon, Pentium III, Athlon,
 791   //              Pentium M, Core Solo, Core Duo, Core2 Duo
 792   //    family 6 model:   9,        13,       14,        15
 793   //    0x0f   -  Pentium 4, Opteron
 794   //
 795   // Note: The cpu family should be used to select between
 796   //       instruction sequences which are valid on all Intel
 797   //       processors.  Use the feature test functions below to
 798   //       determine whether a particular instruction is supported.
 799   //
 800   static void     assert_is_initialized() { _cpuid_info.assert_is_initialized(); }
 801   static uint32_t extended_cpu_family()   { return _cpuid_info.extended_cpu_family(); }
 802   static uint32_t extended_cpu_model()    { return _cpuid_info.extended_cpu_model(); }
 803   static uint32_t cpu_stepping()          { return _cpuid_info.cpu_stepping(); }
 804   static int  cpu_family()        { return _cpu;}
 805   static bool is_P6()             { return cpu_family() >= 6; }
 806   static bool is_amd()            { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA'
 807   static bool is_hygon()          { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x6F677948; } // 'ogyH'
 808   static bool is_amd_family()     { return is_amd() || is_hygon(); }
 809   static bool is_intel()          { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
 810   static bool is_zx()             { assert_is_initialized(); return (_cpuid_info.std_vendor_name_0 == 0x746e6543) || (_cpuid_info.std_vendor_name_0 == 0x68532020); } // 'tneC'||'hS  '
 811   static bool is_atom_family()    { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x36) || (extended_cpu_model() == 0x37) || (extended_cpu_model() == 0x4D))); } //Silvermont and Centerton
 812   static bool is_knights_family() { return UseKNLSetting || ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x57) || (extended_cpu_model() == 0x85))); } // Xeon Phi 3200/5200/7200 and Future Xeon Phi
 813 
 814   static bool supports_processor_topology() {
 815     return (_cpuid_info.std_max_function >= 0xB) &&
 816            // eax[4:0] | ebx[0:15] == 0 indicates invalid topology level.
 817            // Some cpus have max cpuid >= 0xB but do not support processor topology.
 818            (((_cpuid_info.tpl_cpuidB0_eax & 0x1f) | _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus) != 0);
 819   }
 820 
 821   static uint cores_per_cpu();
 822   static uint threads_per_core();
 823   static uint L1_line_size();
 824 
 825   static uint prefetch_data_size()  {
 826     return L1_line_size();
 827   }
 828 
 829   //
 830   // Feature identification which can be affected by VM settings
 831   //
 832   static bool supports_cmov()         { return _features.supports_feature(CPU_CMOV); }
 833   static bool supports_fxsr()         { return _features.supports_feature(CPU_FXSR); }
 834   static bool supports_ht()           { return _features.supports_feature(CPU_HT); }
 835   static bool supports_mmx()          { return _features.supports_feature(CPU_MMX); }
 836   static bool supports_sse()          { return _features.supports_feature(CPU_SSE); }
 837   static bool supports_sse2()         { return _features.supports_feature(CPU_SSE2); }
 838   static bool supports_sse3()         { return _features.supports_feature(CPU_SSE3); }
 839   static bool supports_ssse3()        { return _features.supports_feature(CPU_SSSE3); }
 840   static bool supports_sse4_1()       { return _features.supports_feature(CPU_SSE4_1); }
 841   static bool supports_sse4_2()       { return _features.supports_feature(CPU_SSE4_2); }
 842   static bool supports_popcnt()       { return _features.supports_feature(CPU_POPCNT); }
 843   static bool supports_avx()          { return _features.supports_feature(CPU_AVX); }
 844   static bool supports_avx2()         { return _features.supports_feature(CPU_AVX2); }
 845   static bool supports_tsc()          { return _features.supports_feature(CPU_TSC); }
 846   static bool supports_rdtscp()       { return _features.supports_feature(CPU_RDTSCP); }
 847   static bool supports_rdpid()        { return _features.supports_feature(CPU_RDPID); }
 848   static bool supports_aes()          { return _features.supports_feature(CPU_AES); }
 849   static bool supports_erms()         { return _features.supports_feature(CPU_ERMS); }
 850   static bool supports_fsrm()         { return _features.supports_feature(CPU_FSRM); }
 851   static bool supports_clmul()        { return _features.supports_feature(CPU_CLMUL); }
 852   static bool supports_rtm()          { return _features.supports_feature(CPU_RTM); }
 853   static bool supports_bmi1()         { return _features.supports_feature(CPU_BMI1); }
 854   static bool supports_bmi2()         { return _features.supports_feature(CPU_BMI2); }
 855   static bool supports_adx()          { return _features.supports_feature(CPU_ADX); }
 856   static bool supports_evex()         { return _features.supports_feature(CPU_AVX512F); }
 857   static bool supports_avx512dq()     { return _features.supports_feature(CPU_AVX512DQ); }
 858   static bool supports_avx512ifma()   { return _features.supports_feature(CPU_AVX512_IFMA); }
 859   static bool supports_avxifma()      { return _features.supports_feature(CPU_AVX_IFMA); }
 860   static bool supports_avx512pf()     { return _features.supports_feature(CPU_AVX512PF); }
 861   static bool supports_avx512er()     { return _features.supports_feature(CPU_AVX512ER); }
 862   static bool supports_avx512cd()     { return _features.supports_feature(CPU_AVX512CD); }
 863   static bool supports_avx512bw()     { return _features.supports_feature(CPU_AVX512BW); }
 864   static bool supports_avx512vl()     { return _features.supports_feature(CPU_AVX512VL); }
 865   static bool supports_avx512vlbw()   { return (supports_evex() && supports_avx512bw() && supports_avx512vl()); }
 866   static bool supports_avx512bwdq()   { return (supports_evex() && supports_avx512bw() && supports_avx512dq()); }
 867   static bool supports_avx512vldq()   { return (supports_evex() && supports_avx512dq() && supports_avx512vl()); }
 868   static bool supports_avx512vlbwdq() { return (supports_evex() && supports_avx512vl() &&
 869                                                 supports_avx512bw() && supports_avx512dq()); }
 870   static bool supports_avx512novl()   { return (supports_evex() && !supports_avx512vl()); }
 871   static bool supports_avx512nobw()   { return (supports_evex() && !supports_avx512bw()); }
 872   static bool supports_avx256only()   { return (supports_avx2() && !supports_evex()); }
 873   static bool supports_apx_f()        { return _features.supports_feature(CPU_APX_F); }
 874   static bool supports_avxonly()      { return ((supports_avx2() || supports_avx()) && !supports_evex()); }
 875   static bool supports_sha()          { return _features.supports_feature(CPU_SHA); }
 876   static bool supports_fma()          { return _features.supports_feature(CPU_FMA) && supports_avx(); }
 877   static bool supports_vzeroupper()   { return _features.supports_feature(CPU_VZEROUPPER); }
 878   static bool supports_avx512_vpopcntdq()  { return _features.supports_feature(CPU_AVX512_VPOPCNTDQ); }
 879   static bool supports_avx512_vpclmulqdq() { return _features.supports_feature(CPU_AVX512_VPCLMULQDQ); }
 880   static bool supports_avx512_vaes()  { return _features.supports_feature(CPU_AVX512_VAES); }
 881   static bool supports_gfni()         { return _features.supports_feature(CPU_GFNI); }
 882   static bool supports_avx512_vnni()  { return _features.supports_feature(CPU_AVX512_VNNI); }
 883   static bool supports_avx512_bitalg()  { return _features.supports_feature(CPU_AVX512_BITALG); }
 884   static bool supports_avx512_vbmi()  { return _features.supports_feature(CPU_AVX512_VBMI); }
 885   static bool supports_avx512_vbmi2() { return _features.supports_feature(CPU_AVX512_VBMI2); }
 886   static bool supports_avx512_fp16()  { return _features.supports_feature(CPU_AVX512_FP16); }
 887   static bool supports_hv()           { return _features.supports_feature(CPU_HV); }
 888   static bool supports_serialize()    { return _features.supports_feature(CPU_SERIALIZE); }
 889   static bool supports_f16c()         { return _features.supports_feature(CPU_F16C); }
 890   static bool supports_pku()          { return _features.supports_feature(CPU_PKU); }
 891   static bool supports_ospke()        { return _features.supports_feature(CPU_OSPKE); }
 892   static bool supports_cet_ss()       { return _features.supports_feature(CPU_CET_SS); }
 893   static bool supports_cet_ibt()      { return _features.supports_feature(CPU_CET_IBT); }
 894   static bool supports_sha512()       { return _features.supports_feature(CPU_SHA512); }
 895 
 896   // IntelĀ® AVX10 introduces a versioned approach for enumeration that is monotonically increasing, inclusive,
 897   // and supporting all vector lengths. Feature set supported by an AVX10 vector ISA version is also supported
 898   // by all the versions above it.
 899   static bool supports_avx10_1()      { return _features.supports_feature(CPU_AVX10_1);}
 900   static bool supports_avx10_2()      { return _features.supports_feature(CPU_AVX10_2);}
 901 
 902   //
 903   // Feature identification not affected by VM flags
 904   //
 905   static bool cpu_supports_evex()     { return _cpu_features.supports_feature(CPU_AVX512F); }
 906 
 907   static bool supports_avx512_simd_sort() {
 908     if (supports_avx512dq()) {
 909       // Disable AVX512 version of SIMD Sort on AMD Zen4 Processors.
 910       if (is_amd() && cpu_family() == CPU_FAMILY_AMD_19H) {
 911         return false;
 912       }
 913       return true;
 914     }
 915     return false;
 916   }
 917 
 918   // Intel features
 919   static bool is_intel_family_core() { return is_intel() &&
 920                                        extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
 921 
 922   static bool is_intel_skylake() { return is_intel_family_core() &&
 923                                           extended_cpu_model() == CPU_MODEL_SKYLAKE; }
 924 
 925 #ifdef COMPILER2
 926   // Determine if it's running on Cascade Lake using default options.
 927   static bool is_default_intel_cascade_lake();
 928 #endif
 929 
 930   static bool is_intel_cascade_lake();
 931 
 932   static int avx3_threshold();
 933 
 934   static bool is_intel_tsc_synched_at_init();
 935 
 936   static void insert_features_names(VM_Version::VM_Features features, stringStream& ss);
 937 
 938   // This checks if the JVM is potentially affected by an erratum on Intel CPUs (SKX102)
 939   // that causes unpredictable behaviour when jcc crosses 64 byte boundaries. Its microcode
 940   // mitigation causes regressions when jumps or fused conditional branches cross or end at
 941   // 32 byte boundaries.
 942   static bool has_intel_jcc_erratum() { return _has_intel_jcc_erratum; }
 943 
 944   // AMD features
 945   static bool supports_3dnow_prefetch()    { return _features.supports_feature(CPU_3DNOW_PREFETCH); }
 946   static bool supports_lzcnt()    { return _features.supports_feature(CPU_LZCNT); }
 947   static bool supports_sse4a()    { return _features.supports_feature(CPU_SSE4A); }
 948 
 949   static bool is_amd_Barcelona()  { return is_amd() &&
 950                                            extended_cpu_family() == CPU_FAMILY_AMD_11H; }
 951 
 952   // Intel and AMD newer cores support fast timestamps well
 953   static bool supports_tscinv_bit() {
 954     return _features.supports_feature(CPU_TSCINV_BIT);
 955   }
 956   static bool supports_tscinv() {
 957     return _features.supports_feature(CPU_TSCINV);
 958   }
 959 
 960   // Intel Core and newer cpus have fast IDIV instruction (excluding Atom).
 961   static bool has_fast_idiv()     { return is_intel() && cpu_family() == 6 &&
 962                                            supports_sse3() && _model != 0x1C; }
 963 
 964   static bool supports_compare_and_exchange() { return true; }
 965 
 966   static int allocate_prefetch_distance(bool use_watermark_prefetch);
 967 
 968   // SSE2 and later processors implement a 'pause' instruction
 969   // that can be used for efficient implementation of
 970   // the intrinsic for java.lang.Thread.onSpinWait()
 971   static bool supports_on_spin_wait() { return supports_sse2(); }
 972 
 973   // x86_64 supports fast class initialization checks
 974   static bool supports_fast_class_init_checks() {
 975     return true;
 976   }
 977 
 978   // x86_64 supports secondary supers table
 979   constexpr static bool supports_secondary_supers_table() {
 980     return true;
 981   }
 982 
 983   constexpr static bool supports_stack_watermark_barrier() {
 984     return true;
 985   }
 986 
 987   constexpr static bool supports_recursive_lightweight_locking() {
 988     return true;
 989   }
 990 
 991   // For AVX CPUs only. f16c support is disabled if UseAVX == 0.
 992   static bool supports_float16() {
 993     return supports_f16c() || supports_avx512vl() || supports_avx512_fp16();
 994   }
 995 
 996   // Check intrinsic support
 997   static bool is_intrinsic_supported(vmIntrinsicID id);
 998 
 999   // there are several insns to force cache line sync to memory which
1000   // we can use to ensure mapped non-volatile memory is up to date with
1001   // pending in-cache changes.
1002   //
1003   // 64 bit cpus always support clflush which writes back and evicts
1004   // on 32 bit cpus support is recorded via a feature flag
1005   //
1006   // clflushopt is optional and acts like clflush except it does
1007   // not synchronize with other memory ops. it needs a preceding
1008   // and trailing StoreStore fence
1009   //
1010   // clwb is an optional intel-specific instruction which
1011   // writes back without evicting the line. it also does not
1012   // synchronize with other memory ops. so, it needs preceding
1013   // and trailing StoreStore fences.
1014 
1015   static bool supports_clflush(); // Can't inline due to header file conflict
1016 
1017   // Note: CPU_FLUSHOPT and CPU_CLWB bits should always be zero for 32-bit
1018   static bool supports_clflushopt() { return (_features.supports_feature(CPU_FLUSHOPT)); }
1019   static bool supports_clwb() { return (_features.supports_feature(CPU_CLWB)); }
1020 
1021   // Old CPUs perform lea on AGU which causes additional latency transferring the
1022   // value from/to ALU for other operations
1023   static bool supports_fast_2op_lea() {
1024     return (is_intel() && supports_avx()) || // Sandy Bridge and above
1025            (is_amd()   && supports_avx());   // Jaguar and Bulldozer and above
1026   }
1027 
1028   // Pre Icelake Intels suffer inefficiency regarding 3-operand lea, which contains
1029   // all of base register, index register and displacement immediate, with 3 latency.
1030   // Note that when the address contains no displacement but the base register is
1031   // rbp or r13, the machine code must contain a zero displacement immediate,
1032   // effectively transform a 2-operand lea into a 3-operand lea. This can be
1033   // replaced by add-add or lea-add
1034   static bool supports_fast_3op_lea() {
1035     return supports_fast_2op_lea() &&
1036            ((is_intel() && supports_clwb() && !is_intel_skylake()) || // Icelake and above
1037             is_amd());
1038   }
1039 
1040 #ifdef __APPLE__
1041   // Is the CPU running emulated (for example macOS Rosetta running x86_64 code on M1 ARM (aarch64)
1042   static bool is_cpu_emulated();
1043 #endif
1044 
1045   // support functions for virtualization detection
1046  private:
1047   static void check_virtualizations();
1048 
1049   static const char* cpu_family_description(void);
1050   static const char* cpu_model_description(void);
1051   static const char* cpu_brand(void);
1052   static const char* cpu_brand_string(void);
1053 
1054   static int cpu_type_description(char* const buf, size_t buf_len);
1055   static int cpu_detailed_description(char* const buf, size_t buf_len);
1056   static int cpu_extended_brand_string(char* const buf, size_t buf_len);
1057 
1058   static bool cpu_is_em64t(void);
1059   static bool is_netburst(void);
1060 
1061   // Returns bytes written excluding termninating null byte.
1062   static size_t cpu_write_support_string(char* const buf, size_t buf_len);
1063   static void resolve_cpu_information_details(void);
1064   static int64_t max_qualified_cpu_freq_from_brand_string(void);
1065 
1066  public:
1067   // Offsets for cpuid asm stub brand string
1068   static ByteSize proc_name_0_offset() { return byte_offset_of(CpuidInfo, proc_name_0); }
1069   static ByteSize proc_name_1_offset() { return byte_offset_of(CpuidInfo, proc_name_1); }
1070   static ByteSize proc_name_2_offset() { return byte_offset_of(CpuidInfo, proc_name_2); }
1071   static ByteSize proc_name_3_offset() { return byte_offset_of(CpuidInfo, proc_name_3); }
1072   static ByteSize proc_name_4_offset() { return byte_offset_of(CpuidInfo, proc_name_4); }
1073   static ByteSize proc_name_5_offset() { return byte_offset_of(CpuidInfo, proc_name_5); }
1074   static ByteSize proc_name_6_offset() { return byte_offset_of(CpuidInfo, proc_name_6); }
1075   static ByteSize proc_name_7_offset() { return byte_offset_of(CpuidInfo, proc_name_7); }
1076   static ByteSize proc_name_8_offset() { return byte_offset_of(CpuidInfo, proc_name_8); }
1077   static ByteSize proc_name_9_offset() { return byte_offset_of(CpuidInfo, proc_name_9); }
1078   static ByteSize proc_name_10_offset() { return byte_offset_of(CpuidInfo, proc_name_10); }
1079   static ByteSize proc_name_11_offset() { return byte_offset_of(CpuidInfo, proc_name_11); }
1080 
1081   static int64_t maximum_qualified_cpu_frequency(void);
1082 
1083   static bool supports_tscinv_ext(void);
1084 
1085   static void initialize_tsc();
1086   static void initialize_cpu_information(void);
1087 
1088   static void get_cpu_features_name(void* features_buffer, stringStream& ss);
1089   static void get_missing_features_name(void* features_buffer, stringStream& ss);
1090 
1091   // Returns number of bytes required to store cpu features representation
1092   static int cpu_features_size();
1093 
1094   // Stores cpu features representation in the provided buffer. This representation is arch dependent.
1095   // Size of the buffer must be same as returned by cpu_features_size()
1096   static void store_cpu_features(void* buf);
1097 
1098   static bool supports_features(void* features_to_test);
1099 };
1100 
1101 #endif // CPU_X86_VM_VERSION_X86_HPP