Print this page
3408 detect socket type of newer AMD CPUs
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/cpuid_subr.c
          +++ new/usr/src/uts/i86pc/os/cpuid_subr.c
↓ open down ↓ 21 lines elided ↑ open up ↑
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   * Portions Copyright 2009 Advanced Micro Devices, Inc.
  29   29   */
  30   30  
  31   31  /*
       32 + * Copyright 2012 Jens Elkner <jel+illumos@cs.uni-magdeburg.de>
       33 + * Copyright 2012 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
       34 + */
       35 +
       36 +/*
  32   37   * Support functions that interpret CPUID and similar information.
  33   38   * These should not be used from anywhere other than cpuid.c and
  34   39   * cmi_hw.c - as such we will not list them in any header file
  35   40   * such as x86_archext.h.
  36   41   *
  37   42   * In cpuid.c we process CPUID information for each cpu_t instance
  38   43   * we're presented with, and stash this raw information and material
  39   44   * derived from it in per-cpu_t structures.
  40   45   *
  41   46   * If we are virtualized then the CPUID information derived from CPUID
↓ open down ↓ 15 lines elided ↑ open up ↑
  57   62  #include <sys/hypervisor.h>
  58   63  #endif
  59   64  
  60   65  /*
  61   66   * AMD socket types.
  62   67   * First index :
  63   68   *              0 for family 0xf, revs B thru E
  64   69   *              1 for family 0xf, revs F and G
  65   70   *              2 for family 0x10
  66   71   *              3 for family 0x11
  67      - * Second index by (model & 0x3) for family 0fh
  68      - * or CPUID bits for later families
       72 + *              4 for family 0x12
       73 + *              5 for family 0x14
       74 + *              6 for family 0x15, models 00 - 0f
       75 + *              7 for family 0x15, models 10 - 1f
       76 + * Second index by (model & 0x3) for family 0fh,
       77 + * CPUID pkg bits (Fn8000_0001_EBX[31:28]) for later families.
  69   78   */
  70      -static uint32_t amd_skts[4][8] = {
       79 +static uint32_t amd_skts[8][8] = {
  71   80          /*
  72   81           * Family 0xf revisions B through E
  73   82           */
  74   83  #define A_SKTS_0                        0
  75   84          {
  76   85                  X86_SOCKET_754,         /* 0b000 */
  77   86                  X86_SOCKET_940,         /* 0b001 */
  78   87                  X86_SOCKET_754,         /* 0b010 */
  79   88                  X86_SOCKET_939,         /* 0b011 */
  80   89                  X86_SOCKET_UNKNOWN,     /* 0b100 */
↓ open down ↓ 14 lines elided ↑ open up ↑
  95  104                  X86_SOCKET_UNKNOWN,     /* 0b101 */
  96  105                  X86_SOCKET_UNKNOWN,     /* 0b110 */
  97  106                  X86_SOCKET_UNKNOWN      /* 0b111 */
  98  107          },
  99  108          /*
 100  109           * Family 0x10
 101  110           */
 102  111  #define A_SKTS_2                        2
 103  112          {
 104  113                  X86_SOCKET_F1207,       /* 0b000 */
 105      -                X86_SOCKET_AM,          /* 0b001 */
      114 +                X86_SOCKET_AM2R2,       /* 0b001 */
 106  115                  X86_SOCKET_S1g3,        /* 0b010 */
 107  116                  X86_SOCKET_G34,         /* 0b011 */
 108  117                  X86_SOCKET_ASB2,        /* 0b100 */
 109  118                  X86_SOCKET_C32,         /* 0b101 */
 110  119                  X86_SOCKET_UNKNOWN,     /* 0b110 */
 111  120                  X86_SOCKET_UNKNOWN      /* 0b111 */
 112  121          },
 113  122  
 114  123          /*
 115  124           * Family 0x11
↓ open down ↓ 1 lines elided ↑ open up ↑
 117  126  #define A_SKTS_3                        3
 118  127          {
 119  128                  X86_SOCKET_UNKNOWN,     /* 0b000 */
 120  129                  X86_SOCKET_UNKNOWN,     /* 0b001 */
 121  130                  X86_SOCKET_S1g2,        /* 0b010 */
 122  131                  X86_SOCKET_UNKNOWN,     /* 0b011 */
 123  132                  X86_SOCKET_UNKNOWN,     /* 0b100 */
 124  133                  X86_SOCKET_UNKNOWN,     /* 0b101 */
 125  134                  X86_SOCKET_UNKNOWN,     /* 0b110 */
 126  135                  X86_SOCKET_UNKNOWN      /* 0b111 */
 127      -        }
      136 +        },
      137 +
      138 +        /*
      139 +         * Family 0x12
      140 +         */
      141 +#define A_SKTS_4                        4
      142 +        {
      143 +                X86_SOCKET_UNKNOWN,     /* 0b000 */
      144 +                X86_SOCKET_FS1,         /* 0b001 */
      145 +                X86_SOCKET_FM1,         /* 0b010 */
      146 +                X86_SOCKET_UNKNOWN,     /* 0b011 */
      147 +                X86_SOCKET_UNKNOWN,     /* 0b100 */
      148 +                X86_SOCKET_UNKNOWN,     /* 0b101 */
      149 +                X86_SOCKET_UNKNOWN,     /* 0b110 */
      150 +                X86_SOCKET_UNKNOWN      /* 0b111 */
      151 +        },
      152 +
      153 +        /*
      154 +         * Family 0x14
      155 +         */
      156 +#define A_SKTS_5                        5
      157 +        {
      158 +                X86_SOCKET_FT1,         /* 0b000 */
      159 +                X86_SOCKET_UNKNOWN,     /* 0b001 */
      160 +                X86_SOCKET_UNKNOWN,     /* 0b010 */
      161 +                X86_SOCKET_UNKNOWN,     /* 0b011 */
      162 +                X86_SOCKET_UNKNOWN,     /* 0b100 */
      163 +                X86_SOCKET_UNKNOWN,     /* 0b101 */
      164 +                X86_SOCKET_UNKNOWN,     /* 0b110 */
      165 +                X86_SOCKET_UNKNOWN      /* 0b111 */
      166 +        },
      167 +
      168 +        /*
      169 +         * Family 0x15 models 00 - 0f
      170 +         */
      171 +#define A_SKTS_6                        6
      172 +        {
      173 +                X86_SOCKET_UNKNOWN,     /* 0b000 */
      174 +                X86_SOCKET_AM3R2,       /* 0b001 */
      175 +                X86_SOCKET_UNKNOWN,     /* 0b010 */
      176 +                X86_SOCKET_G34,         /* 0b011 */
      177 +                X86_SOCKET_UNKNOWN,     /* 0b100 */
      178 +                X86_SOCKET_C32,         /* 0b101 */
      179 +                X86_SOCKET_UNKNOWN,     /* 0b110 */
      180 +                X86_SOCKET_UNKNOWN      /* 0b111 */
      181 +        },
      182 +
      183 +        /*
      184 +         * Family 0x15 models 10 - 1f
      185 +         */
      186 +#define A_SKTS_7                        7
      187 +        {
      188 +                X86_SOCKET_FP2,         /* 0b000 */
      189 +                X86_SOCKET_FS1R2,       /* 0b001 */
      190 +                X86_SOCKET_FM2,         /* 0b010 */
      191 +                X86_SOCKET_UNKNOWN,     /* 0b011 */
      192 +                X86_SOCKET_UNKNOWN,     /* 0b100 */
      193 +                X86_SOCKET_UNKNOWN,     /* 0b101 */
      194 +                X86_SOCKET_UNKNOWN,     /* 0b110 */
      195 +                X86_SOCKET_UNKNOWN      /* 0b111 */
      196 +        },
      197 +
 128  198  };
 129  199  
 130  200  struct amd_sktmap_s {
 131  201          uint32_t        skt_code;
 132  202          char            sktstr[16];
 133  203  };
 134      -static struct amd_sktmap_s amd_sktmap[15] = {
      204 +static struct amd_sktmap_s amd_sktmap[23] = {
 135  205          { X86_SOCKET_754,       "754" },
 136  206          { X86_SOCKET_939,       "939" },
 137  207          { X86_SOCKET_940,       "940" },
 138  208          { X86_SOCKET_S1g1,      "S1g1" },
 139  209          { X86_SOCKET_AM2,       "AM2" },
 140  210          { X86_SOCKET_F1207,     "F(1207)" },
 141  211          { X86_SOCKET_S1g2,      "S1g2" },
 142  212          { X86_SOCKET_S1g3,      "S1g3" },
 143  213          { X86_SOCKET_AM,        "AM" },
 144  214          { X86_SOCKET_AM2R2,     "AM2r2" },
 145  215          { X86_SOCKET_AM3,       "AM3" },
 146  216          { X86_SOCKET_G34,       "G34" },
 147  217          { X86_SOCKET_ASB2,      "ASB2" },
 148  218          { X86_SOCKET_C32,       "C32" },
      219 +        { X86_SOCKET_FT1,       "FT1" },
      220 +        { X86_SOCKET_FM1,       "FM1" },
      221 +        { X86_SOCKET_FS1,       "FS1" },
      222 +        { X86_SOCKET_AM3R2,     "AM3r2" },
      223 +        { X86_SOCKET_FP2,       "FP2" },
      224 +        { X86_SOCKET_FS1R2,     "FS1r2" },
      225 +        { X86_SOCKET_FM2,       "FM2" },
 149  226          { X86_SOCKET_UNKNOWN,   "Unknown" }
 150  227  };
 151  228  
 152  229  /*
 153  230   * Table for mapping AMD Family 0xf and AMD Family 0x10 model/stepping
 154  231   * combination to chip "revision" and socket type.
 155  232   *
 156  233   * The first member of this array that matches a given family, extended model
 157  234   * plus model range, and stepping range will be considered a match.
 158  235   */
↓ open down ↓ 54 lines elided ↑ open up ↑
 213  290          { 0x10, 0x00, 0x00, 0x0, 0x2, X86_CHIPREV_AMD_10_REV_A, "A", A_SKTS_2 },
 214  291  
 215  292          /*
 216  293           * Rev B has model 2 and steppings 0/1/0xa/2 for DR-{B0,B1,BA,B2}.
 217  294           * Give all of model 2 stepping range to rev B.
 218  295           */
 219  296          { 0x10, 0x02, 0x02, 0x0, 0xf, X86_CHIPREV_AMD_10_REV_B, "B", A_SKTS_2 },
 220  297  
 221  298          /*
 222  299           * Rev C has models 4-6 (depending on L3 cache configuration)
 223      -         * Give all of models 4-6 stepping range to rev C.
      300 +         * Give all of models 4-6 stepping range 0-2 to rev C2.
 224  301           */
 225      -        { 0x10, 0x04, 0x06, 0x0, 0xf, X86_CHIPREV_AMD_10_REV_C, "C", A_SKTS_2 },
      302 +        { 0x10, 0x4, 0x6, 0x0, 0x2, X86_CHIPREV_AMD_10_REV_C2, "C2", A_SKTS_2 },
 226  303  
 227  304          /*
      305 +         * Rev C has models 4-6 (depending on L3 cache configuration)
      306 +         * Give all of models 4-6 stepping range >= 3 to rev C3.
      307 +         */
      308 +        { 0x10, 0x4, 0x6, 0x3, 0xf, X86_CHIPREV_AMD_10_REV_C3, "C3", A_SKTS_2 },
      309 +
      310 +        /*
 228  311           * Rev D has models 8 and 9
 229      -         * Give all of model 8 and 9 stepping range to rev D.
      312 +         * Give all of model 8 and 9 stepping 0 to rev D0.
 230  313           */
 231      -        { 0x10, 0x08, 0x09, 0x0, 0xf, X86_CHIPREV_AMD_10_REV_D, "D", A_SKTS_2 },
      314 +        { 0x10, 0x8, 0x9, 0x0, 0x0, X86_CHIPREV_AMD_10_REV_D0, "D0", A_SKTS_2 },
 232  315  
 233  316          /*
      317 +         * Rev D has models 8 and 9
      318 +         * Give all of model 8 and 9 stepping range >= 1 to rev D1.
      319 +         */
      320 +        { 0x10, 0x8, 0x9, 0x1, 0xf, X86_CHIPREV_AMD_10_REV_D1, "D1", A_SKTS_2 },
      321 +
      322 +        /*
      323 +         * Rev E has models A and stepping 0
      324 +         * Give all of model A stepping range to rev E.
      325 +         */
      326 +        { 0x10, 0xA, 0xA, 0x0, 0xf, X86_CHIPREV_AMD_10_REV_E, "E", A_SKTS_2 },
      327 +
      328 +        /*
 234  329           * =============== AuthenticAMD Family 0x11 ===============
 235  330           */
 236      -        { 0x11, 0x03, 0x3, 0x0, 0xf, X86_CHIPREV_AMD_11, "B", A_SKTS_3 },
      331 +        { 0x11, 0x03, 0x03, 0x0, 0xf, X86_CHIPREV_AMD_11_REV_B, "B", A_SKTS_3 },
      332 +
      333 +        /*
      334 +         * =============== AuthenticAMD Family 0x12 ===============
      335 +         */
      336 +        { 0x12, 0x01, 0x01, 0x0, 0xf, X86_CHIPREV_AMD_12_REV_B, "B", A_SKTS_4 },
      337 +
      338 +        /*
      339 +         * =============== AuthenticAMD Family 0x14 ===============
      340 +         */
      341 +        { 0x14, 0x01, 0x01, 0x0, 0xf, X86_CHIPREV_AMD_14_REV_B, "B", A_SKTS_5 },
      342 +        { 0x14, 0x02, 0x02, 0x0, 0xf, X86_CHIPREV_AMD_14_REV_C, "C", A_SKTS_5 },
      343 +
      344 +        /*
      345 +         * =============== AuthenticAMD Family 0x15 ===============
      346 +         */
      347 +        { 0x15, 0x01, 0x01, 0x2, 0x2, X86_CHIPREV_AMD_15OR_REV_B2, "B2",
      348 +            A_SKTS_6 },
      349 +        { 0x15, 0x10, 0x10, 0x1, 0x1, X86_CHIPREV_AMD_15TN_REV_A1, "A1",
      350 +            A_SKTS_7 },
 237  351  };
 238  352  
 239  353  static void
 240  354  synth_amd_info(uint_t family, uint_t model, uint_t step,
 241  355      uint32_t *skt_p, uint32_t *chiprev_p, const char **chiprevstr_p)
 242  356  {
 243  357          const struct amd_rev_mapent *rmp;
 244  358          int found = 0;
 245  359          int i;
 246  360  
↓ open down ↓ 44 lines elided ↑ open up ↑
 291  405  
 292  406                          cp.cp_eax = 0x80000001;
 293  407                          (void) __cpuid_insn(&cp);
 294  408  
 295  409                          /* PkgType bits */
 296  410                          idx = BITX(cp.cp_ebx, 31, 28);
 297  411  
 298  412                          if (idx > 7) {
 299  413                                  /* Reserved bits */
 300  414                                  *skt_p = X86_SOCKET_UNKNOWN;
 301      -                        } else if (family == 0x10 &&
 302      -                            amd_skts[rmp->rm_sktidx][idx] ==
 303      -                            X86_SOCKET_AM) {
      415 +                        } else {
      416 +                                *skt_p = amd_skts[rmp->rm_sktidx][idx];
      417 +                        }
      418 +                        if (family == 0x10) {
 304  419                                  /*
 305  420                                   * Look at Ddr3Mode bit of DRAM Configuration
 306  421                                   * High Register to decide whether this is
 307      -                                 * AM2r2 (aka AM2+) or AM3.
      422 +                                 * actually AM3 or S1g4.
 308  423                                   */
 309  424                                  uint32_t val;
 310  425  
 311  426                                  val = pci_getl_func(0, 24, 2, 0x94);
 312      -                                if (BITX(val, 8, 8))
 313      -                                        *skt_p = X86_SOCKET_AM3;
 314      -                                else
 315      -                                        *skt_p = X86_SOCKET_AM2R2;
 316      -                        } else {
 317      -                                *skt_p = amd_skts[rmp->rm_sktidx][idx];
      427 +                                if (BITX(val, 8, 8)) {
      428 +                                        if (*skt_p == X86_SOCKET_AM2R2)
      429 +                                                *skt_p = X86_SOCKET_AM3;
      430 +                                        else if (*skt_p == X86_SOCKET_S1g3)
      431 +                                                *skt_p = X86_SOCKET_S1g4;
      432 +                                }
 318  433                          }
 319  434                  }
 320  435          }
 321  436  }
 322  437  
 323  438  uint32_t
 324  439  _cpuid_skt(uint_t vendor, uint_t family, uint_t model, uint_t step)
 325  440  {
 326  441          uint32_t skt = X86_SOCKET_UNKNOWN;
 327  442  
↓ open down ↓ 113 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX