NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: bin/41289: usr.sbin/cpuctl does not correctly identify new Intel CPUs



On Tue, 28 Apr 2009, matthew green wrote:

The following reply was made to PR bin/41289; it has been noted by GNATS.

From: matthew green <mrg%eterna.com.au@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: re: bin/41289: usr.sbin/cpuctl does not correctly identify new Intel 
CPUs
Date: Tue, 28 Apr 2009 10:06:52 +1000

hmm, i thought i send a PR about this already, but apparently not.

this is an ugly patch i've been using... it needs work before i was
even going to consider commiting it however..

Yeah, that's a bit ugly and it assumes that family 6 is the only one
that will ever have extended models.

I was thinking more along the lines of adding a pointer to the existing entries. This would point to an array of arbitrary number of

        struct ext_model_names {
                int ext_model;
                const char *ext_name[MAX_MODEL];
        }

(with the end of array indicated by ext_model == 0).

Then the probe routine can check the extended model (in pseudocode)

        if (CPUID2EXTMODEL(xxx) != 0)
                if (ext_model_ptr != NULL)
                        scan thru *ext_model_ptr for matching ext_model
                        select proper name
                else
                        /* extended id, but no extension names */
                        use a default value
        else
                do-what-we-do-already





.mrg.


Index: arch/i386.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/cpuctl/arch/i386.c,v
retrieving revision 1.16
diff -p -r1.16 i386.c
*** arch/i386.c 16 Mar 2009 12:25:40 -0000      1.16
--- arch/i386.c 28 Apr 2009 00:06:24 -0000
*************** struct cpu_cpuid_nameclass {
*** 133,139 ****
                void (*cpu_setup)(struct cpu_info *);
                void (*cpu_probe)(struct cpu_info *);
                void (*cpu_info)(struct cpu_info *);
!       } cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1];
  };

  static const struct x86_cache_info intel_cpuid_cache_info[] = 
INTEL_CACHE_INFO;
--- 133,139 ----
                void (*cpu_setup)(struct cpu_info *);
                void (*cpu_probe)(struct cpu_info *);
                void (*cpu_info)(struct cpu_info *);
!       } cpu_family[CPU_MAXFAMILY - CPU_MINFAMILY + 1 /* XXX */ + 1];
  };

  static const struct x86_cache_info intel_cpuid_cache_info[] = 
INTEL_CACHE_INFO;
*************** const struct cpu_cpuid_nameclass i386_cp
*** 303,308 ****
--- 303,323 ----
                        NULL,
                        intel_family_new_probe,
                        NULL,
+               },
+               /* Extended Model 1, Family 6 */
+               {
+                       CPUCLASS_686,
+                       {
+                               0, 0, 0, 0, 0, 0, 0,
+                               "Core2 (Yorkfield)",
+                               0, 0,
+                               "Core2 (Wolfdale)",
+                               0, 0, 0, 0, 0,
+                               "Core2"       /* Default */
+                       },
+                       NULL,
+                       intel_family_new_probe,
+                       NULL,
                } }
        },
        {
*************** identifycpu(const char *cpuname)
*** 1183,1189 ****
  {
        const char *name, *modifier, *vendorname, *brand = "";
        int class = CPUCLASS_386, i, xmax;
!       int modif, family, model;
        const struct cpu_cpuid_nameclass *cpup = NULL;
        const struct cpu_cpuid_family *cpufam;
        const char *feature_str[5];
--- 1198,1204 ----
  {
        const char *name, *modifier, *vendorname, *brand = "";
        int class = CPUCLASS_386, i, xmax;
!       int modif, family, model, extmodel;
        const struct cpu_cpuid_nameclass *cpup = NULL;
        const struct cpu_cpuid_family *cpufam;
        const char *feature_str[5];
*************** identifycpu(const char *cpuname)
*** 1216,1221 ****
--- 1231,1237 ----
                family = CPUID2FAMILY(ci->ci_signature);
                if (family < CPU_MINFAMILY)
                        errx(1, "identifycpu: strange family value");
+               extmodel = CPUID2EXTMODEL(ci->ci_signature);
                model = CPUID2MODEL(ci->ci_signature);

                for (i = 0; i < xmax; i++) {
*************** identifycpu(const char *cpuname)
*** 1242,1248 ****
                        cpu_vendor = cpup->cpu_vendor;
                        vendorname = cpup->cpu_vendorname;
                        modifier = modifiers[modif];
!                       if (family > CPU_MAXFAMILY) {
                                family = CPU_MAXFAMILY;
                                model = CPU_DEFMODEL;
                        } else if (model > CPU_MAXMODEL)
--- 1258,1270 ----
                        cpu_vendor = cpup->cpu_vendor;
                        vendorname = cpup->cpu_vendorname;
                        modifier = modifiers[modif];
!                       if (cpu_vendor == CPUVENDOR_INTEL) {
!                               /* XXX */
!                               if (extmodel == 1 && family == 6) {
!                                       family = CPU_MAXFAMILY + 1;
!                                       model = 
CPUID2STEPPING(ci->ci_signature);
!                               }
!                       } else if (family > CPU_MAXFAMILY) {
                                family = CPU_MAXFAMILY;
                                model = CPU_DEFMODEL;
                        } else if (model > CPU_MAXMODEL)



-------------------------------------------------------------------------
|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:      |
| Customer Service | FA29 0E3B 35AF E8AE 6651 |  paul at whooppee.com   |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index