aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2022-06-23 16:20:59 -0700
committerAndi Kleen <ak@linux.intel.com>2022-06-27 17:20:58 -0700
commit9aee26472b2b544c55770eb485148cf37edabff1 (patch)
tree5a6d49bec37bac818a13df399e1714f3f53ac575
parentb5c36e814fc68017615801c27dde883d766f0342 (diff)
downloadmcelog-9aee26472b2b544c55770eb485148cf37edabff1.tar.gz
mcelog: Add CPU model numbers to table and generate switch function
Replace the massive if/else function that maps family 6 model numbers to internal CPU_* enum values with an auto-generated function. Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r--Makefile10
-rw-r--r--cputype.table64
-rw-r--r--intel.c71
-rwxr-xr-xmkcputype16
4 files changed, 58 insertions, 103 deletions
diff --git a/Makefile b/Makefile
index f0d7bcd..c134d15 100644
--- a/Makefile
+++ b/Makefile
@@ -37,9 +37,10 @@ OBJ := p4.o k8.o mcelog.o dmi.o tsc.o core2.o bitfield.o intel.o \
sandy-bridge.o ivy-bridge.o haswell.o \
broadwell_de.o broadwell_epex.o skylake_xeon.o \
denverton.o i10nm.o \
- msr.o bus.o unknown.o
+ msr.o bus.o unknown.o lookup_intel_cputype.o
CLEAN := mcelog dmi tsc dbquery .depend .depend.X dbquery.o \
- version.o version.c version.tmp cputype.h cputype.tmp
+ version.o version.c version.tmp cputype.h cputype.tmp \
+ lookup_intel_cputype.c lookup_intel_cputype.tmp
DOC := mce.pdf
ADD_DEFINES :=
@@ -102,12 +103,15 @@ version.tmp: FORCE
version.c: version.tmp
cmp version.tmp version.c || mv version.tmp version.c
-cputype.tmp: FORCE
+cputype.tmp lookup_intel_cputype.tmp: FORCE
./mkcputype
cputype.h: cputype.tmp
cmp cputype.tmp cputype.h || mv cputype.tmp cputype.h
+lookup_intel_cputype.c: lookup_intel_cputype.tmp
+ cmp lookup_intel_cputype.c lookup_intel_cputype.tmp || mv lookup_intel_cputype.tmp lookup_intel_cputype.c
+
.depend: ${SRC}
touch cputype.h
${CC} -MM -I. ${SRC} > .depend.X && mv .depend.X .depend
diff --git a/cputype.table b/cputype.table
index f2ceb5f..82bd450 100644
--- a/cputype.table
+++ b/cputype.table
@@ -1,32 +1,32 @@
-CPU_ALDERLAKE|
-CPU_ATOM|
-CPU_BROADWELL|
-CPU_BROADWELL_DE|
-CPU_BROADWELL_EPEX|
-CPU_COMETLAKE|
-CPU_CORE2|
-CPU_DENVERTON|
-CPU_DUNNINGTON|
-CPU_HASWELL|
-CPU_HASWELL_EPEX|
-CPU_ICELAKE|
-CPU_ICELAKE_DE|
-CPU_ICELAKE_XEON|
-CPU_IVY_BRIDGE|
-CPU_IVY_BRIDGE_EPEX|
-CPU_KABYLAKE|
-CPU_KNIGHTS_LANDING|
-CPU_KNIGHTS_MILL|
-CPU_LAKEFIELD|
-CPU_NEHALEM|
-CPU_P6OLD|
-CPU_RAPTORLAKE|
-CPU_ROCKETLAKE|
-CPU_SANDY_BRIDGE|
-CPU_SANDY_BRIDGE_EP|
-CPU_SAPPHIRERAPIDS|
-CPU_SKYLAKE|
-CPU_SKYLAKE_XEON|
-CPU_TIGERLAKE|
-CPU_TREMONT_D|
-CPU_XEON75XX|
+CPU_ALDERLAKE|0x97,0x9A,0xBE
+CPU_ATOM|0x1c,0x26,0x27,0x35,0x36,0x37,0x4a,0x4c,0x4d,0x5a,0x5d
+CPU_BROADWELL|0x3d
+CPU_BROADWELL_DE|0x56
+CPU_BROADWELL_EPEX|0x4f
+CPU_COMETLAKE|0xa5,0xa6
+CPU_CORE2|0xf,0x17
+CPU_DENVERTON|0x5f
+CPU_DUNNINGTON|0x1d
+CPU_HASWELL|0x3c,0x45,0x46
+CPU_HASWELL_EPEX|0x3f
+CPU_ICELAKE|0x7D,0x7E,0x9D
+CPU_ICELAKE_DE|0x6C
+CPU_ICELAKE_XEON|0x6A
+CPU_IVY_BRIDGE|0x3a
+CPU_IVY_BRIDGE_EPEX|0x3e
+CPU_KABYLAKE|0x8E,0x9E
+CPU_KNIGHTS_LANDING|0x57
+CPU_KNIGHTS_MILL|0x85
+CPU_LAKEFIELD|0x8A
+CPU_NEHALEM|0x1a,0x2c,0x1e,0x25
+CPU_P6OLD|0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE
+CPU_RAPTORLAKE|0xb7
+CPU_ROCKETLAKE|0xA7
+CPU_SANDY_BRIDGE|0x2a
+CPU_SANDY_BRIDGE_EP|0x2d
+CPU_SAPPHIRERAPIDS|0x8F
+CPU_SKYLAKE|0x4e,0x5e
+CPU_SKYLAKE_XEON|0x55
+CPU_TIGERLAKE|0x8C,0x8D
+CPU_TREMONT_D|0x86
+CPU_XEON75XX|0x2e,0x2f
diff --git a/intel.c b/intel.c
index 8ac47f8..450d603 100644
--- a/intel.c
+++ b/intel.c
@@ -59,74 +59,9 @@ enum cputype select_intel_cputype(int family, int model)
if (model >= 0x1a && model != 28)
memory_error_support = 1;
- if (model < 0xf)
- return CPU_P6OLD;
- else if (model == 0xf || model == 0x17) /* Merom/Penryn */
- return CPU_CORE2;
- else if (model == 0x1d)
- return CPU_DUNNINGTON;
- else if (model == 0x1a || model == 0x2c || model == 0x1e ||
- model == 0x25)
- return CPU_NEHALEM;
- else if (model == 0x2e || model == 0x2f)
- return CPU_XEON75XX;
- else if (model == 0x2a)
- return CPU_SANDY_BRIDGE;
- else if (model == 0x2d)
- return CPU_SANDY_BRIDGE_EP;
- else if (model == 0x3a)
- return CPU_IVY_BRIDGE;
- else if (model == 0x3e)
- return CPU_IVY_BRIDGE_EPEX;
- else if (model == 0x3c || model == 0x45 || model == 0x46)
- return CPU_HASWELL;
- else if (model == 0x3f)
- return CPU_HASWELL_EPEX;
- else if (model == 0x3d)
- return CPU_BROADWELL;
- else if (model == 0x4f)
- return CPU_BROADWELL_EPEX;
- else if (model == 0x56)
- return CPU_BROADWELL_DE;
- else if (model == 0x57)
- return CPU_KNIGHTS_LANDING;
- else if (model == 0x85)
- return CPU_KNIGHTS_MILL;
- else if (model == 0x1c || model == 0x26 || model == 0x27 ||
- model == 0x35 || model == 0x36 || model == 0x36 ||
- model == 0x37 || model == 0x4a || model == 0x4c ||
- model == 0x4d || model == 0x5a || model == 0x5d)
- return CPU_ATOM;
- else if (model == 0x4e || model == 0x5e)
- return CPU_SKYLAKE;
- else if (model == 0x55)
- return CPU_SKYLAKE_XEON;
- else if (model == 0x8E || model == 0x9E)
- return CPU_KABYLAKE;
- else if (model == 0x5f)
- return CPU_DENVERTON;
- else if (model == 0x7D || model == 0x7E || model == 0x9D)
- return CPU_ICELAKE;
- else if (model == 0x6A)
- return CPU_ICELAKE_XEON;
- else if (model == 0x6C)
- return CPU_ICELAKE_DE;
- else if (model == 0x86)
- return CPU_TREMONT_D;
- else if (model == 0xa5 || model == 0xa6)
- return CPU_COMETLAKE;
- else if (model == 0x8C || model == 0x8D)
- return CPU_TIGERLAKE;
- else if (model == 0xA7)
- return CPU_ROCKETLAKE;
- else if (model == 0x97 || model == 0x9A || model == 0xBE)
- return CPU_ALDERLAKE;
- else if (model == 0x8A)
- return CPU_LAKEFIELD;
- else if (model == 0x8F)
- return CPU_SAPPHIRERAPIDS;
- else if (model == 0xb7)
- return CPU_RAPTORLAKE;
+ model = lookup_intel_cputype(model);
+ if (model != -1)
+ return model;
if (model > 0x1a) {
Eprintf("Family 6 Model %u CPU: only decoding architectural errors\n",
model);
diff --git a/mkcputype b/mkcputype
index 7dd9bc3..c8e5c41 100755
--- a/mkcputype
+++ b/mkcputype
@@ -8,10 +8,26 @@ awk -F\| 'BEGIN {
print "\tCPU_INTEL," > "cputype.tmp"
print "\tCPU_P4," > "cputype.tmp"
print "\tCPU_TULSA," > "cputype.tmp"
+
+ print "/* Do not edit. Autogenerated from cputype.table */" > "lookup_intel_cputype.tmp"
+ print "#include \"cputype.h\"\n" > "lookup_intel_cputype.tmp"
+ print "enum cputype lookup_intel_cputype(int model)" > "lookup_intel_cputype.tmp"
+ print "{" > "lookup_intel_cputype.tmp"
+ print "\tswitch (model) {" > "lookup_intel_cputype.tmp"
}
{
printf("\t%s,\n", $1) > "cputype.tmp"
+
+ n = split($2, model, ",")
+ for (i = 1; i <= n; i++)
+ printf("\tcase %s:\n", model[i]) > "lookup_intel_cputype.tmp"
+ printf("\t\treturn %s;\n", $1) > "lookup_intel_cputype.tmp"
+
}
END {
printf("};\n") > "cputype.tmp"
+ printf "enum cputype lookup_intel_cputype(int model);" > "cputype.tmp"
+
+ print "\tdefault: return -1;" > "lookup_intel_cputype.tmp"
+ print "\t}\n}" > "lookup_intel_cputype.tmp"
}' cputype.table