x86: Report Intel platform_id in /proc/cpuinfo
Subsystems (2)
PATCH 1/1 x86: Report Intel platform_id in /proc/cpuinfo
From: Andi Kleen <[email protected]>
We have a need to distinguish systems based on their platform ID. For example this is useful to distinguish systems with L4 cache versus ones without.
There is a 3 bit identifier (also called processor flags) in the IA32_PLATFORM_ID MSR that can give a more fine grained identification of the CPU than just the model number/stepping.
IA32_PLATFORM_ID is architectural.
The processor flags are already used in the microcode driver. The MSR can be also accessed through /dev/cpu/*/msr, but that requires root and is awkward.
This patch just exports the value retrieved by the microcode driver in /proc/cpuinfo. If the microcode driver is disabled it won't be shown, but that seems reasonable.
v2: Handle 0 platform_id. Fix commit message.
--- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/cpu/microcode/intel.c | 2 ++ arch/x86/kernel/cpu/proc.c | 2 ++ 3 files changed, 6 insertions(+)
arch/x86/include/asm/processor.h +2 -0
@@ -136,6 +136,8 @@ struct cpuinfo_x86 {/* Index into per_cpu list: */ u16 cpu_index;u32 microcode; +u32 platform_id; +u8 has_platform_id; };#define X86_VENDOR_INTEL 0
arch/x86/kernel/cpu/microcode/intel.c +2 -0
@@ -812,6 +812,8 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)/* get processor flags from MSR 0x17 */ rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); csig->pf =1 << ((val[1 ] >>18 ) &7 ); +cpu_data (cpu_num).platform_id = (val[1 ] >>18 ) &7 ; +cpu_data (cpu_num).has_platform_id = true; } csig->rev = c->microcode;
arch/x86/kernel/cpu/proc.c +2 -0
@@ -76,6 +76,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m,"stepping\t: unknown\n" );if (c->microcode)seq_printf (m,"microcode\t: 0x%x\n" , c->microcode); +if (c->has_platform_id) +seq_printf (m,"platform_id\t: %d\n" , c->platform_id);if (cpu_has (c,X86_FEATURE_TSC )) {unsigned int freq =cpufreq_quick_get (cpu);
Signature · 1 line
2.8.3
Andi Kleen <[email protected]> writes:
Ping! Any comments on this patch?
Quoted 68 lines
From: Andi Kleen <[email protected]>
We have a need to distinguish systems based on their platform ID. For example this is useful to distinguish systems with L4 cache versus ones without.
There is a 3 bit identifier (also called processor flags) in the
IA32_PLATFORM_IDMSR that can give a more fine grained identification of the CPU than just the model number/stepping.
IA32_PLATFORM_IDis architectural.The processor flags are already used in the microcode driver. The MSR can be also accessed through
/dev/cpu/*/msr, but that requires root and is awkward.This patch just exports the value retrieved by the microcode driver in
/proc/cpuinfo. If the microcode driver is disabled it won't be shown, but that seems reasonable.v2: Handle 0
platform_id. Fix commit message.Signed-off-by Andi Kleen <[email protected]>--- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/cpu/microcode/intel.c | 2 ++ arch/x86/kernel/cpu/proc.c | 2 ++ 3 files changed, 6 insertions(+)arch/x86/include/asm/processor.h +2
-0@@ -136,6 +136,8 @@ struct cpuinfo_x86 {/* Index into per_cpu list: */ u16 cpu_index;u32 microcode; +u32 platform_id; +u8 has_platform_id; };#define X86_VENDOR_INTEL 0arch/x86/kernel/cpu/microcode/intel.c +2
-0@@ -812,6 +812,8 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)/* get processor flags from MSR 0x17 */ rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); csig->pf =1 << ((val[1 ] >>18 ) &7 ); +cpu_data (cpu_num).platform_id = (val[1 ] >>18 ) &7 ; +cpu_data (cpu_num).has_platform_id = true; } csig->rev = c->microcode;arch/x86/kernel/cpu/proc.c +2
-0@@ -76,6 +76,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)seq_puts (m,"stepping\t: unknown\n" );if (c->microcode)seq_printf (m,"microcode\t: 0x%x\n" , c->microcode); +if (c->has_platform_id) +seq_printf (m,"platform_id\t: %d\n" , c->platform_id);if (cpu_has (c,X86_FEATURE_TSC )) {unsigned int freq =cpufreq_quick_get (cpu);
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 3 lines · Andi Kleen
Andi Kleen <[email protected]> writes:
Ping! Any comments on this patch?
Well, FWIW, it looks good enough to me.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
On Thu, 2 Jun 2016, Andi Kleen wrote:
Sorry for answering late. This got stuck in my backlog forever.
arch/x86/kernel/cpu/microcode/intel.c static int collect_cpu_info(int cpu_num, struct cpu_signature *csig) · line 816
Quoted 10 lines
arch/x86/kernel/cpu/microcode/intel.c +2
-0@@ -812,6 +812,8 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)/* get processor flags from MSR 0x17 */ rdmsr (MSR_IA32_PLATFORM_ID , val[0 ], val[1 ]); csig->pf =1 << ((val[1 ] >>18 ) &7 ); +cpu_data (cpu_num).platform_id = (val[1 ] >>18 ) &7 ; +cpu_data (cpu_num).has_platform_id = true;
Please move that evaluation to arch/x86/kernel/cpu/intel.c and let the micro code driver use the information from cpu_data.
Thanks,
tglx