Skip to content

Commit 47f10a3

Browse files
He ChenKAGA-KOKO
authored andcommitted
x86/cpuid: Cleanup cpuid_regs definitions
cpuid_regs is defined multiple times as structure and enum. Rename the enum and move all of it to processor.h so we don't end up with more instances. Rename the misnomed register enumeration from CR_* to the obvious CPUID_*. [ tglx: Rewrote changelog ] Signed-off-by: He Chen <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Luwei Kang <[email protected]> Cc: [email protected] Cc: Radim Krčmář <[email protected]> Cc: Piotr Luc <[email protected]> Cc: Paolo Bonzini <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent a25f094 commit 47f10a3

File tree

4 files changed

+41
-47
lines changed

4 files changed

+41
-47
lines changed

arch/x86/events/intel/pt.c

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ static DEFINE_PER_CPU(struct pt, pt_ctx);
3636

3737
static struct pt_pmu pt_pmu;
3838

39-
enum cpuid_regs {
40-
CR_EAX = 0,
41-
CR_ECX,
42-
CR_EDX,
43-
CR_EBX
44-
};
45-
4639
/*
4740
* Capabilities of Intel PT hardware, such as number of address bits or
4841
* supported output schemes, are cached and exported to userspace as "caps"
@@ -64,21 +57,21 @@ static struct pt_cap_desc {
6457
u8 reg;
6558
u32 mask;
6659
} pt_caps[] = {
67-
PT_CAP(max_subleaf, 0, CR_EAX, 0xffffffff),
68-
PT_CAP(cr3_filtering, 0, CR_EBX, BIT(0)),
69-
PT_CAP(psb_cyc, 0, CR_EBX, BIT(1)),
70-
PT_CAP(ip_filtering, 0, CR_EBX, BIT(2)),
71-
PT_CAP(mtc, 0, CR_EBX, BIT(3)),
72-
PT_CAP(ptwrite, 0, CR_EBX, BIT(4)),
73-
PT_CAP(power_event_trace, 0, CR_EBX, BIT(5)),
74-
PT_CAP(topa_output, 0, CR_ECX, BIT(0)),
75-
PT_CAP(topa_multiple_entries, 0, CR_ECX, BIT(1)),
76-
PT_CAP(single_range_output, 0, CR_ECX, BIT(2)),
77-
PT_CAP(payloads_lip, 0, CR_ECX, BIT(31)),
78-
PT_CAP(num_address_ranges, 1, CR_EAX, 0x3),
79-
PT_CAP(mtc_periods, 1, CR_EAX, 0xffff0000),
80-
PT_CAP(cycle_thresholds, 1, CR_EBX, 0xffff),
81-
PT_CAP(psb_periods, 1, CR_EBX, 0xffff0000),
60+
PT_CAP(max_subleaf, 0, CPUID_EAX, 0xffffffff),
61+
PT_CAP(cr3_filtering, 0, CPUID_EBX, BIT(0)),
62+
PT_CAP(psb_cyc, 0, CPUID_EBX, BIT(1)),
63+
PT_CAP(ip_filtering, 0, CPUID_EBX, BIT(2)),
64+
PT_CAP(mtc, 0, CPUID_EBX, BIT(3)),
65+
PT_CAP(ptwrite, 0, CPUID_EBX, BIT(4)),
66+
PT_CAP(power_event_trace, 0, CPUID_EBX, BIT(5)),
67+
PT_CAP(topa_output, 0, CPUID_ECX, BIT(0)),
68+
PT_CAP(topa_multiple_entries, 0, CPUID_ECX, BIT(1)),
69+
PT_CAP(single_range_output, 0, CPUID_ECX, BIT(2)),
70+
PT_CAP(payloads_lip, 0, CPUID_ECX, BIT(31)),
71+
PT_CAP(num_address_ranges, 1, CPUID_EAX, 0x3),
72+
PT_CAP(mtc_periods, 1, CPUID_EAX, 0xffff0000),
73+
PT_CAP(cycle_thresholds, 1, CPUID_EBX, 0xffff),
74+
PT_CAP(psb_periods, 1, CPUID_EBX, 0xffff0000),
8275
};
8376

8477
static u32 pt_cap_get(enum pt_capabilities cap)
@@ -213,10 +206,10 @@ static int __init pt_pmu_hw_init(void)
213206

214207
for (i = 0; i < PT_CPUID_LEAVES; i++) {
215208
cpuid_count(20, i,
216-
&pt_pmu.caps[CR_EAX + i*PT_CPUID_REGS_NUM],
217-
&pt_pmu.caps[CR_EBX + i*PT_CPUID_REGS_NUM],
218-
&pt_pmu.caps[CR_ECX + i*PT_CPUID_REGS_NUM],
219-
&pt_pmu.caps[CR_EDX + i*PT_CPUID_REGS_NUM]);
209+
&pt_pmu.caps[CPUID_EAX + i*PT_CPUID_REGS_NUM],
210+
&pt_pmu.caps[CPUID_EBX + i*PT_CPUID_REGS_NUM],
211+
&pt_pmu.caps[CPUID_ECX + i*PT_CPUID_REGS_NUM],
212+
&pt_pmu.caps[CPUID_EDX + i*PT_CPUID_REGS_NUM]);
220213
}
221214

222215
ret = -ENOMEM;

arch/x86/include/asm/processor.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ struct cpuinfo_x86 {
137137
u32 microcode;
138138
};
139139

140+
struct cpuid_regs {
141+
u32 eax, ebx, ecx, edx;
142+
};
143+
144+
enum cpuid_regs_idx {
145+
CPUID_EAX = 0,
146+
CPUID_EBX,
147+
CPUID_ECX,
148+
CPUID_EDX,
149+
};
150+
140151
#define X86_VENDOR_INTEL 0
141152
#define X86_VENDOR_CYRIX 1
142153
#define X86_VENDOR_AMD 2

arch/x86/kernel/cpu/scattered.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,21 @@ struct cpuid_bit {
1717
u32 sub_leaf;
1818
};
1919

20-
enum cpuid_regs {
21-
CR_EAX = 0,
22-
CR_ECX,
23-
CR_EDX,
24-
CR_EBX
25-
};
26-
2720
void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
2821
{
2922
u32 max_level;
3023
u32 regs[4];
3124
const struct cpuid_bit *cb;
3225

3326
static const struct cpuid_bit cpuid_bits[] = {
34-
{ X86_FEATURE_INTEL_PT, CR_EBX,25, 0x00000007, 0 },
35-
{ X86_FEATURE_AVX512_4VNNIW, CR_EDX, 2, 0x00000007, 0 },
36-
{ X86_FEATURE_AVX512_4FMAPS, CR_EDX, 3, 0x00000007, 0 },
37-
{ X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 },
38-
{ X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 },
39-
{ X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 },
40-
{ X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 },
41-
{ X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 },
27+
{ X86_FEATURE_INTEL_PT, CPUID_EBX, 25, 0x00000007, 0 },
28+
{ X86_FEATURE_AVX512_4VNNIW, CPUID_EDX, 2, 0x00000007, 0 },
29+
{ X86_FEATURE_AVX512_4FMAPS, CPUID_EDX, 3, 0x00000007, 0 },
30+
{ X86_FEATURE_APERFMPERF, CPUID_ECX, 0, 0x00000006, 0 },
31+
{ X86_FEATURE_EPB, CPUID_ECX, 3, 0x00000006, 0 },
32+
{ X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 },
33+
{ X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 },
34+
{ X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 },
4235
{ 0, 0, 0, 0, 0 }
4336
};
4437

@@ -50,8 +43,9 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
5043
max_level > (cb->level | 0xffff))
5144
continue;
5245

53-
cpuid_count(cb->level, cb->sub_leaf, &regs[CR_EAX],
54-
&regs[CR_EBX], &regs[CR_ECX], &regs[CR_EDX]);
46+
cpuid_count(cb->level, cb->sub_leaf, &regs[CPUID_EAX],
47+
&regs[CPUID_EBX], &regs[CPUID_ECX],
48+
&regs[CPUID_EDX]);
5549

5650
if (regs[cb->reg] & (1 << cb->bit))
5751
set_cpu_cap(c, cb->feature);

arch/x86/kernel/cpuid.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646

4747
static struct class *cpuid_class;
4848

49-
struct cpuid_regs {
50-
u32 eax, ebx, ecx, edx;
51-
};
52-
5349
static void cpuid_smp_cpuid(void *cmd_block)
5450
{
5551
struct cpuid_regs *cmd = (struct cpuid_regs *)cmd_block;

0 commit comments

Comments
 (0)