blob: ed73091d3dd0158b1271e7d72738130aecae7c07 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/smp.h>
2#include <linux/timex.h>
3#include <linux/string.h>
4#include <asm/semaphore.h>
5#include <linux/seq_file.h>
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -08006#include <linux/cpufreq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8/*
9 * Get CPU information for use by the procfs.
10 */
11static int show_cpuinfo(struct seq_file *m, void *v)
12{
13 /*
14 * These flag bits must match the definitions in <asm/cpufeature.h>.
15 * NULL means this bit is undefined or reserved; either way it doesn't
16 * have meaning as far as Linux is concerned. Note that it's important
17 * to realize there is a difference between this table and CPUID -- if
18 * applications want to get the raw CPUID data, they should access
19 * /dev/cpu/<cpu_nr>/cpuid instead.
20 */
Andreas Mohr7f35bf92006-06-27 02:53:45 -070021 static const char * const x86_cap_flags[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 /* Intel-defined */
23 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
24 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
25 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
26 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe",
27
28 /* AMD-defined */
Zwane Mwaikambo3c3b73b2005-05-01 08:58:51 -070029 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 NULL, NULL, NULL, "syscall", NULL, NULL, NULL, NULL,
31 NULL, NULL, NULL, "mp", "nx", NULL, "mmxext", NULL,
H. Peter Anvinec481532007-07-11 12:18:29 -070032 NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm",
33 "3dnowext", "3dnow",
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35 /* Transmeta-defined */
36 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
37 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
38 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
39 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
40
41 /* Other (Linux-defined) */
42 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
43 NULL, NULL, NULL, NULL,
H. Peter Anvinec481532007-07-11 12:18:29 -070044 "constant_tsc", "up", NULL, "arch_perfmon",
45 "pebs", "bts", NULL, "sync_rdtsc",
46 "rep_good", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
48
49 /* Intel-defined (#2) */
Andi Kleen9d95dd82006-03-25 16:31:22 +010050 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
Dave Jonesdcf10302006-09-26 10:52:42 +020051 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
Andi Kleenf790cd32007-02-13 13:26:25 +010052 NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
54
55 /* VIA/Cyrix/Centaur-defined */
56 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
Michal Ludvig224f6112006-06-23 02:04:32 -070057 "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
59 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
60
61 /* AMD-defined (#2) */
H. Peter Anvinec481532007-07-11 12:18:29 -070062 "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8_legacy",
63 "altmovcr8", "abm", "sse4a",
64 "misalignsse", "3dnowprefetch",
65 "osvw", "ibs", NULL, NULL, NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
67 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
68 };
Andreas Mohr7f35bf92006-06-27 02:53:45 -070069 static const char * const x86_power_flags[] = {
Andi Kleen3f98bc42006-01-11 22:42:51 +010070 "ts", /* temperature sensor */
71 "fid", /* frequency id control */
72 "vid", /* voltage id control */
73 "ttp", /* thermal trip */
74 "tm",
75 "stc",
Andi Kleenf790cd32007-02-13 13:26:25 +010076 "100mhzsteps",
77 "hwpstate",
Joerg Roedeld8243952007-05-02 19:27:09 +020078 "", /* constant_tsc - moved to flags */
Andi Kleenf790cd32007-02-13 13:26:25 +010079 /* nothing */
Andi Kleen3f98bc42006-01-11 22:42:51 +010080 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 struct cpuinfo_x86 *c = v;
82 int i, n = c - cpu_data;
83 int fpu_exception;
84
85#ifdef CONFIG_SMP
86 if (!cpu_online(n))
87 return 0;
88#endif
89 seq_printf(m, "processor\t: %d\n"
90 "vendor_id\t: %s\n"
91 "cpu family\t: %d\n"
92 "model\t\t: %d\n"
93 "model name\t: %s\n",
94 n,
95 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
96 c->x86,
97 c->x86_model,
98 c->x86_model_id[0] ? c->x86_model_id : "unknown");
99
100 if (c->x86_mask || c->cpuid_level >= 0)
101 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
102 else
103 seq_printf(m, "stepping\t: unknown\n");
104
105 if ( cpu_has(c, X86_FEATURE_TSC) ) {
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -0800106 unsigned int freq = cpufreq_quick_get(n);
107 if (!freq)
108 freq = cpu_khz;
Andrew Mortona3a255e2005-06-23 00:08:34 -0700109 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -0800110 freq / 1000, (freq % 1000));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 }
112
113 /* Cache size */
114 if (c->x86_cache_size >= 0)
115 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
116#ifdef CONFIG_X86_HT
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100117 if (c->x86_max_cores * smp_num_siblings > 1) {
Rohit Seth4b89aff2006-06-27 02:53:46 -0700118 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100119 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
Rohit Seth4b89aff2006-06-27 02:53:46 -0700120 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100121 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
Andi Kleendb468682005-04-16 15:24:51 -0700122 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#endif
124
125 /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
126 fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
127 seq_printf(m, "fdiv_bug\t: %s\n"
128 "hlt_bug\t\t: %s\n"
129 "f00f_bug\t: %s\n"
130 "coma_bug\t: %s\n"
131 "fpu\t\t: %s\n"
132 "fpu_exception\t: %s\n"
133 "cpuid level\t: %d\n"
134 "wp\t\t: %s\n"
135 "flags\t\t:",
136 c->fdiv_bug ? "yes" : "no",
137 c->hlt_works_ok ? "no" : "yes",
138 c->f00f_bug ? "yes" : "no",
139 c->coma_bug ? "yes" : "no",
140 c->hard_math ? "yes" : "no",
141 fpu_exception ? "yes" : "no",
142 c->cpuid_level,
143 c->wp_works_ok ? "yes" : "no");
144
145 for ( i = 0 ; i < 32*NCAPINTS ; i++ )
146 if ( test_bit(i, c->x86_capability) &&
147 x86_cap_flags[i] != NULL )
148 seq_printf(m, " %s", x86_cap_flags[i]);
149
Andi Kleen3f98bc42006-01-11 22:42:51 +0100150 for (i = 0; i < 32; i++)
151 if (c->x86_power & (1 << i)) {
152 if (i < ARRAY_SIZE(x86_power_flags) &&
153 x86_power_flags[i])
154 seq_printf(m, "%s%s",
155 x86_power_flags[i][0]?" ":"",
156 x86_power_flags[i]);
157 else
158 seq_printf(m, " [%d]", i);
159 }
160
Andi Kleen770d1322006-12-07 02:14:05 +0100161 seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 c->loops_per_jiffy/(500000/HZ),
163 (c->loops_per_jiffy/(5000/HZ)) % 100);
Andi Kleen770d1322006-12-07 02:14:05 +0100164 seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
Andi Kleen3dd9d512005-04-16 15:25:15 -0700165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 return 0;
167}
168
169static void *c_start(struct seq_file *m, loff_t *pos)
170{
171 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
172}
173static void *c_next(struct seq_file *m, void *v, loff_t *pos)
174{
175 ++*pos;
176 return c_start(m, pos);
177}
178static void c_stop(struct seq_file *m, void *v)
179{
180}
181struct seq_operations cpuinfo_op = {
182 .start = c_start,
183 .next = c_next,
184 .stop = c_stop,
185 .show = show_cpuinfo,
186};