Print this page
OS-4391 Want Broadwell Instruction support
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
OS-5192 need faster clock_gettime
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Ryan Zezeski <ryan@zinascii.com>
OS-4368 lxbrand glibc abhors CPUID limits

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/cpuid.c
          +++ new/usr/src/uts/i86pc/os/cpuid.c
↓ open down ↓ 24 lines elided ↑ open up ↑
  25   25   * Copyright 2014 Josef "Jeff" Sipek <jeffpc@josefsipek.net>
  26   26   */
  27   27  /*
  28   28   * Copyright (c) 2010, Intel Corporation.
  29   29   * All rights reserved.
  30   30   */
  31   31  /*
  32   32   * Portions Copyright 2009 Advanced Micro Devices, Inc.
  33   33   */
  34   34  /*
  35      - * Copyright (c) 2015, Joyent, Inc. All rights reserved.
       35 + * Copyright 2016 Joyent, Inc.
  36   36   */
  37   37  /*
  38   38   * Various routines to handle identification
  39   39   * and classification of x86 processors.
  40   40   */
  41   41  
  42   42  #include <sys/types.h>
  43   43  #include <sys/archsystm.h>
  44   44  #include <sys/x86_archext.h>
  45   45  #include <sys/kmem.h>
↓ open down ↓ 4 lines elided ↑ open up ↑
  50   50  #include <sys/cpuvar.h>
  51   51  #include <sys/processor.h>
  52   52  #include <sys/sysmacros.h>
  53   53  #include <sys/pg.h>
  54   54  #include <sys/fp.h>
  55   55  #include <sys/controlregs.h>
  56   56  #include <sys/bitmap.h>
  57   57  #include <sys/auxv_386.h>
  58   58  #include <sys/memnode.h>
  59   59  #include <sys/pci_cfgspace.h>
       60 +#include <sys/comm_page.h>
       61 +#include <sys/tsc.h>
  60   62  
  61   63  #ifdef __xpv
  62   64  #include <sys/hypervisor.h>
  63   65  #else
  64   66  #include <sys/ontrap.h>
  65   67  #endif
  66   68  
  67   69  /*
  68   70   * Pass 0 of cpuid feature analysis happens in locore. It contains special code
  69   71   * to recognize Cyrix processors that are not cpuid-compliant, and to deal with
↓ open down ↓ 2749 lines elided ↑ open up ↑
2819 2821  
2820 2822                  if (*ecx & CPUID_INTC_ECX_RDRAND)
2821 2823                          hwcap_flags_2 |= AV_386_2_RDRAND;
2822 2824                  if (*ebx & CPUID_INTC_EBX_7_0_ADX)
2823 2825                          hwcap_flags_2 |= AV_386_2_ADX;
2824 2826                  if (*ebx & CPUID_INTC_EBX_7_0_RDSEED)
2825 2827                          hwcap_flags_2 |= AV_386_2_RDSEED;
2826 2828  
2827 2829          }
2828 2830  
     2831 +        /* Detect systems with a potential CPUID limit  */
     2832 +        if (cpi->cpi_vendor == X86_VENDOR_Intel && cpi->cpi_maxeax < 4) {
     2833 +                cmn_err(CE_NOTE, "CPUID limit detected, "
     2834 +                    "see the CPUID(7D) man page for details\n");
     2835 +        }
     2836 +
     2837 +
2829 2838          if (cpi->cpi_xmaxeax < 0x80000001)
2830 2839                  goto pass4_done;
2831 2840  
2832 2841          switch (cpi->cpi_vendor) {
2833 2842                  struct cpuid_regs cp;
2834 2843                  uint32_t *edx, *ecx;
2835 2844  
2836 2845          case X86_VENDOR_Intel:
2837 2846                  /*
2838 2847                   * Seems like Intel duplicated what we necessary
↓ open down ↓ 1761 lines elided ↑ open up ↑
4600 4609          cpu->cpu_m.mcpu_cpi->cpi_mwait.buf_actual = NULL;
4601 4610          cpu->cpu_m.mcpu_cpi->cpi_mwait.size_actual = 0;
4602 4611  }
4603 4612  
4604 4613  void
4605 4614  patch_tsc_read(int flag)
4606 4615  {
4607 4616          size_t cnt;
4608 4617  
4609 4618          switch (flag) {
4610      -        case X86_NO_TSC:
     4619 +        case TSC_NONE:
4611 4620                  cnt = &_no_rdtsc_end - &_no_rdtsc_start;
4612 4621                  (void) memcpy((void *)tsc_read, (void *)&_no_rdtsc_start, cnt);
4613 4622                  break;
4614      -        case X86_HAVE_TSCP:
4615      -                cnt = &_tscp_end - &_tscp_start;
4616      -                (void) memcpy((void *)tsc_read, (void *)&_tscp_start, cnt);
4617      -                break;
4618      -        case X86_TSC_MFENCE:
     4623 +        case TSC_RDTSC_MFENCE:
4619 4624                  cnt = &_tsc_mfence_end - &_tsc_mfence_start;
4620 4625                  (void) memcpy((void *)tsc_read,
4621 4626                      (void *)&_tsc_mfence_start, cnt);
4622 4627                  break;
4623      -        case X86_TSC_LFENCE:
     4628 +        case TSC_RDTSC_LFENCE:
4624 4629                  cnt = &_tsc_lfence_end - &_tsc_lfence_start;
4625 4630                  (void) memcpy((void *)tsc_read,
4626 4631                      (void *)&_tsc_lfence_start, cnt);
4627 4632                  break;
     4633 +        case TSC_TSCP:
     4634 +                cnt = &_tscp_end - &_tscp_start;
     4635 +                (void) memcpy((void *)tsc_read, (void *)&_tscp_start, cnt);
     4636 +                break;
4628 4637          default:
     4638 +                /* Bail for unexpected TSC types. (TSC_NONE covers 0) */
     4639 +                cmn_err(CE_PANIC, "Unrecogized TSC type: %d", flag);
4629 4640                  break;
4630 4641          }
     4642 +        tsc_type = flag;
4631 4643  }
4632 4644  
4633 4645  int
4634 4646  cpuid_deep_cstates_supported(void)
4635 4647  {
4636 4648          struct cpuid_info *cpi;
4637 4649          struct cpuid_regs regs;
4638 4650  
4639 4651          ASSERT(cpuid_checkpass(CPU, 1));
4640 4652  
↓ open down ↓ 259 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX