History

x86/cpu: Add a steppings field to struct x86_cpu_id

Intel uses the same family/model for several CPUs. Sometimes the stepping must be checked to tell them apart. On x86 there can be at most 16 steppings. Add a steppings bitmask to x86_cpu_id and a X86_MATCH_VENDOR_FAMILY_MODEL_STEPPING_FEATURE macro and support for matching against family/model/stepping. [ bp: Massage. ]

Mark Gross committed 6 years ago

Commit e9d71441 parent ae83d0b3 files · +32 −4Browse files

Unified · Split

3 files
  1. arch/x86/include/asm/cpu_device_id.h +24 −3
  2. arch/x86/kernel/cpu/match.c +6 −1
  3. include/linux/mod_devicetable.h +2 −0
arch/x86/include/asm/cpu_device_id.h+24−3
@@ -20,12 +20,14 @@ · 19 unmodified lines
20#define X86_CENTAUR_FAM6_C7_D 0xd20#define X86_CENTAUR_FAM6_C7_D 0xd
21#define X86_CENTAUR_FAM6_NANO 0xf21#define X86_CENTAUR_FAM6_NANO 0xf
22 22
23#define X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
23/**24/**
24 * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Base macro for CPU matching25 * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
25 * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY26 * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
26 * The name is expanded to X86_VENDOR_@_vendor27 * The name is expanded to X86_VENDOR_@_vendor
27 * @_family: The family number or X86_FAMILY_ANY28 * @_family: The family number or X86_FAMILY_ANY
28 * @_model: The model number, model constant or X86_MODEL_ANY29 * @_model: The model number, model constant or X86_MODEL_ANY
30 * @_steppings: Bitmask for steppings, stepping constant or X86_STEPPING_ANY
29 * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY31 * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY
30 * @_data: Driver specific data or NULL. The internal storage32 * @_data: Driver specific data or NULL. The internal storage
31 * format is unsigned long. The supplied value, pointer33 * format is unsigned long. The supplied value, pointer
@@ -37,15 +39,34 @@ · 5 unmodified lines
37 * into another macro at the usage site for good reasons, then please39 * into another macro at the usage site for good reasons, then please
38 * start this local macro with X86_MATCH to allow easy grepping.40 * start this local macro with X86_MATCH to allow easy grepping.
39 */41 */
40#define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(_vendor, _family, _model, \42#define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
41 _feature, _data) { \43 _steppings, _feature, _data) { \
42 .vendor = X86_VENDOR_##_vendor, \44 .vendor = X86_VENDOR_##_vendor, \
43 .family = _family, \45 .family = _family, \
44 .model = _model, \46 .model = _model, \
47 .steppings = _steppings, \
45 .feature = _feature, \48 .feature = _feature, \
46 .driver_data = (unsigned long) _data \49 .driver_data = (unsigned long) _data \
47}50}
48 51
52/**
53 * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
54 * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
55 * The name is expanded to X86_VENDOR_@_vendor
56 * @_family: The family number or X86_FAMILY_ANY
57 * @_model: The model number, model constant or X86_MODEL_ANY
58 * @_feature: A X86_FEATURE bit or X86_FEATURE_ANY
59 * @_data: Driver specific data or NULL. The internal storage
60 * format is unsigned long. The supplied value, pointer
61 * etc. is casted to unsigned long internally.
62 *
63 * The steppings arguments of X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE() is
64 * set to wildcards.
65 */
66#define X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, feature, data) \
67 X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(vendor, family, model, \
68 X86_STEPPING_ANY, feature, data)
69
49/**70/**
50 * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature71 * X86_MATCH_VENDOR_FAM_FEATURE - Macro for matching vendor, family and CPU feature
51 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY72 * @vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
arch/x86/kernel/cpu/match.c+6−1
@@ -39,13 +39,18 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match) · 38 unmodified lines
39 const struct x86_cpu_id *m;39 const struct x86_cpu_id *m;
40 struct cpuinfo_x86 *c = &boot_cpu_data;40 struct cpuinfo_x86 *c = &boot_cpu_data;
41 41
42 for (m = match; m->vendor | m->family | m->model | m->feature; m++) {42 for (m = match;
43 m->vendor | m->family | m->model | m->steppings | m->feature;
44 m++) {
43 if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)45 if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)
44 continue;46 continue;
45 if (m->family != X86_FAMILY_ANY && c->x86 != m->family)47 if (m->family != X86_FAMILY_ANY && c->x86 != m->family)
46 continue;48 continue;
47 if (m->model != X86_MODEL_ANY && c->x86_model != m->model)49 if (m->model != X86_MODEL_ANY && c->x86_model != m->model)
48 continue;50 continue;
51 if (m->steppings != X86_STEPPING_ANY &&
52 !(BIT(c->x86_stepping) & m->steppings))
53 continue;
49 if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))54 if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
50 continue;55 continue;
51 return m;56 return m;
include/linux/mod_devicetable.h+2−0
@@ -663,6 +663,7 @@ struct x86_cpu_id { · 662 unmodified lines
663 __u16 vendor;663 __u16 vendor;
664 __u16 family;664 __u16 family;
665 __u16 model;665 __u16 model;
666 __u16 steppings;
666 __u16 feature; /* bit index */667 __u16 feature; /* bit index */
667 kernel_ulong_t driver_data;668 kernel_ulong_t driver_data;
668};669};
@@ -671,6 +672,7 @@ struct x86_cpu_id { · 2 unmodified lines
671#define X86_VENDOR_ANY 0xffff672#define X86_VENDOR_ANY 0xffff
672#define X86_FAMILY_ANY 0673#define X86_FAMILY_ANY 0
673#define X86_MODEL_ANY 0674#define X86_MODEL_ANY 0
675#define X86_STEPPING_ANY 0
674#define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */676#define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */
675 677
676/*678/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t