This source file includes following definitions.
- x86_match_cpu
- x86_match_cpu_with_stepping
- x86_cpu_has_min_microcode_rev
1
2 #include <asm/cpu_device_id.h>
3 #include <asm/cpufeature.h>
4 #include <linux/cpu.h>
5 #include <linux/export.h>
6 #include <linux/slab.h>
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
33 {
34 const struct x86_cpu_id *m;
35 struct cpuinfo_x86 *c = &boot_cpu_data;
36
37 for (m = match;
38 m->vendor | m->family | m->model | m->steppings | m->feature;
39 m++) {
40 if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)
41 continue;
42 if (m->family != X86_FAMILY_ANY && c->x86 != m->family)
43 continue;
44 if (m->model != X86_MODEL_ANY && c->x86_model != m->model)
45 continue;
46 if (m->steppings != X86_STEPPING_ANY &&
47 !(BIT(c->x86_stepping) & m->steppings))
48 continue;
49 if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
50 continue;
51 return m;
52 }
53 return NULL;
54 }
55 EXPORT_SYMBOL(x86_match_cpu);
56
57 static const struct x86_cpu_desc *
58 x86_match_cpu_with_stepping(const struct x86_cpu_desc *match)
59 {
60 struct cpuinfo_x86 *c = &boot_cpu_data;
61 const struct x86_cpu_desc *m;
62
63 for (m = match; m->x86_family | m->x86_model; m++) {
64 if (c->x86_vendor != m->x86_vendor)
65 continue;
66 if (c->x86 != m->x86_family)
67 continue;
68 if (c->x86_model != m->x86_model)
69 continue;
70 if (c->x86_stepping != m->x86_stepping)
71 continue;
72 return m;
73 }
74 return NULL;
75 }
76
77 bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table)
78 {
79 const struct x86_cpu_desc *res = x86_match_cpu_with_stepping(table);
80
81 if (!res || res->x86_microcode_rev > boot_cpu_data.microcode)
82 return false;
83
84 return true;
85 }
86 EXPORT_SYMBOL_GPL(x86_cpu_has_min_microcode_rev);