Skip to content

Commit b0a59d1

Browse files
Ahmed S. DarwishKAGA-KOKO
authored andcommitted
tools/x86/kcpuid: Recognize all leaves with subleaves
cpuid.csv will be extended in further commits with all-publicly-known CPUID leaves and bitfields. Thus, modify has_subleafs() to identify all known leaves with subleaves. Remove the redundant "is_amd" check since all x86 vendors already report the maxium supported extended leaf at leaf 0x80000000 EAX register. The extra mentioned leaves are: - Leaf 0x12, Intel Software Guard Extensions (SGX) enumeration - Leaf 0x14, Intel process trace (PT) enumeration - Leaf 0x17, Intel SoC vendor attributes enumeration - Leaf 0x1b, Intel PCONFIG (Platform configuration) enumeration - Leaf 0x1d, Intel AMX (Advanced Matrix Extensions) tile information - Leaf 0x1f, Intel v2 extended topology enumeration - Leaf 0x23, Intel ArchPerfmonExt (Architectural PMU ext) enumeration - Leaf 0x80000020, AMD Platform QoS extended features enumeration - Leaf 0x80000026, AMD v2 extended topology enumeration Set the 'max_subleaf' variable for all the newly marked leaves with extra subleaves. Ideally, this should be fetched from the CSV file instead, but the current kcpuid code architecture has two runs: one run to serially invoke the cpuid instructions and save all the output in-memory, and one run to parse this in-memory output through the CSV specification. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 9ecbc60 commit b0a59d1

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

tools/arch/x86/kcpuid/kcpuid.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,17 @@ static inline void cpuid(u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
9898

9999
static inline bool has_subleafs(u32 f)
100100
{
101-
if (f == 0x7 || f == 0xd)
102-
return true;
103-
104-
if (is_amd) {
105-
if (f == 0x8000001d)
101+
u32 with_subleaves[] = {
102+
0x4, 0x7, 0xb, 0xd, 0xf, 0x10, 0x12,
103+
0x14, 0x17, 0x18, 0x1b, 0x1d, 0x1f, 0x23,
104+
0x8000001d, 0x80000020, 0x80000026,
105+
};
106+
107+
for (unsigned i = 0; i < ARRAY_SIZE(with_subleaves); i++)
108+
if (f == with_subleaves[i])
106109
return true;
107-
return false;
108-
}
109110

110-
switch (f) {
111-
case 0x4:
112-
case 0xb:
113-
case 0xf:
114-
case 0x10:
115-
case 0x14:
116-
case 0x18:
117-
case 0x1f:
118-
return true;
119-
default:
120-
return false;
121-
}
111+
return false;
122112
}
123113

124114
static void leaf_print_raw(struct subleaf *leaf)
@@ -253,11 +243,18 @@ struct cpuid_range *setup_cpuid_range(u32 input_eax)
253243
* Some can provide the exact number of subleafs,
254244
* others have to be tried (0xf)
255245
*/
256-
if (f == 0x7 || f == 0x14 || f == 0x17 || f == 0x18)
246+
if (f == 0x7 || f == 0x14 || f == 0x17 || f == 0x18 || f == 0x1d)
257247
max_subleaf = min((eax & 0xff) + 1, max_subleaf);
258-
259248
if (f == 0xb)
260249
max_subleaf = 2;
250+
if (f == 0x1f)
251+
max_subleaf = 6;
252+
if (f == 0x23)
253+
max_subleaf = 4;
254+
if (f == 0x80000020)
255+
max_subleaf = 4;
256+
if (f == 0x80000026)
257+
max_subleaf = 5;
261258

262259
for (subleaf = 1; subleaf < max_subleaf; subleaf++) {
263260
eax = f;

0 commit comments

Comments
 (0)