blob: 47e3ebbfb28df3755ab08e7c129363561192c88b [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,
Andi Kleenf790cd32007-02-13 13:26:25 +010032 NULL, "fxsr_opt", "pdpe1gb", "rdtscp", NULL, "lm", "3dnowext", "3dnow",
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34 /* Transmeta-defined */
35 "recovery", "longrun", NULL, "lrti", NULL, NULL, NULL, NULL,
36 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
37 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
38 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
39
40 /* Other (Linux-defined) */
41 "cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
42 NULL, NULL, NULL, NULL,
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -080043 "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
46
47 /* Intel-defined (#2) */
Andi Kleen9d95dd82006-03-25 16:31:22 +010048 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
Dave Jonesdcf10302006-09-26 10:52:42 +020049 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
Andi Kleenf790cd32007-02-13 13:26:25 +010050 NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt",
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
52
53 /* VIA/Cyrix/Centaur-defined */
54 NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
Michal Ludvig224f6112006-06-23 02:04:32 -070055 "ace2", "ace2_en", "phe", "phe_en", "pmm", "pmm_en", NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
57 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
58
59 /* AMD-defined (#2) */
Andi Kleenf790cd32007-02-13 13:26:25 +010060 "lahf_lm", "cmp_legacy", "svm", "extapic", "cr8legacy", "abm",
61 "sse4a", "misalignsse",
62 "3dnowprefetch", "osvw", "ibs", NULL, NULL, NULL, NULL, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
64 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
65 };
Andreas Mohr7f35bf92006-06-27 02:53:45 -070066 static const char * const x86_power_flags[] = {
Andi Kleen3f98bc42006-01-11 22:42:51 +010067 "ts", /* temperature sensor */
68 "fid", /* frequency id control */
69 "vid", /* voltage id control */
70 "ttp", /* thermal trip */
71 "tm",
72 "stc",
Andi Kleenf790cd32007-02-13 13:26:25 +010073 "100mhzsteps",
74 "hwpstate",
Andi Kleen3f98bc42006-01-11 22:42:51 +010075 NULL,
Andi Kleenf790cd32007-02-13 13:26:25 +010076 NULL, /* constant_tsc - moved to flags */
77 /* nothing */
Andi Kleen3f98bc42006-01-11 22:42:51 +010078 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 struct cpuinfo_x86 *c = v;
80 int i, n = c - cpu_data;
81 int fpu_exception;
82
83#ifdef CONFIG_SMP
84 if (!cpu_online(n))
85 return 0;
86#endif
87 seq_printf(m, "processor\t: %d\n"
88 "vendor_id\t: %s\n"
89 "cpu family\t: %d\n"
90 "model\t\t: %d\n"
91 "model name\t: %s\n",
92 n,
93 c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown",
94 c->x86,
95 c->x86_model,
96 c->x86_model_id[0] ? c->x86_model_id : "unknown");
97
98 if (c->x86_mask || c->cpuid_level >= 0)
99 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
100 else
101 seq_printf(m, "stepping\t: unknown\n");
102
103 if ( cpu_has(c, X86_FEATURE_TSC) ) {
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -0800104 unsigned int freq = cpufreq_quick_get(n);
105 if (!freq)
106 freq = cpu_khz;
Andrew Mortona3a255e2005-06-23 00:08:34 -0700107 seq_printf(m, "cpu MHz\t\t: %u.%03u\n",
Venkatesh Pallipadi95235ca2005-12-02 10:43:20 -0800108 freq / 1000, (freq % 1000));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 }
110
111 /* Cache size */
112 if (c->x86_cache_size >= 0)
113 seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
114#ifdef CONFIG_X86_HT
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100115 if (c->x86_max_cores * smp_num_siblings > 1) {
Rohit Seth4b89aff2006-06-27 02:53:46 -0700116 seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100117 seq_printf(m, "siblings\t: %d\n", cpus_weight(cpu_core_map[n]));
Rohit Seth4b89aff2006-06-27 02:53:46 -0700118 seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
Siddha, Suresh B94605ef2005-11-05 17:25:54 +0100119 seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
Andi Kleendb468682005-04-16 15:24:51 -0700120 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#endif
122
123 /* We use exception 16 if we have hardware math and we've either seen it or the CPU claims it is internal */
124 fpu_exception = c->hard_math && (ignore_fpu_irq || cpu_has_fpu);
125 seq_printf(m, "fdiv_bug\t: %s\n"
126 "hlt_bug\t\t: %s\n"
127 "f00f_bug\t: %s\n"
128 "coma_bug\t: %s\n"
129 "fpu\t\t: %s\n"
130 "fpu_exception\t: %s\n"
131 "cpuid level\t: %d\n"
132 "wp\t\t: %s\n"
133 "flags\t\t:",
134 c->fdiv_bug ? "yes" : "no",
135 c->hlt_works_ok ? "no" : "yes",
136 c->f00f_bug ? "yes" : "no",
137 c->coma_bug ? "yes" : "no",
138 c->hard_math ? "yes" : "no",
139 fpu_exception ? "yes" : "no",
140 c->cpuid_level,
141 c->wp_works_ok ? "yes" : "no");
142
143 for ( i = 0 ; i < 32*NCAPINTS ; i++ )
144 if ( test_bit(i, c->x86_capability) &&
145 x86_cap_flags[i] != NULL )
146 seq_printf(m, " %s", x86_cap_flags[i]);
147
Andi Kleen3f98bc42006-01-11 22:42:51 +0100148 for (i = 0; i < 32; i++)
149 if (c->x86_power & (1 << i)) {
150 if (i < ARRAY_SIZE(x86_power_flags) &&
151 x86_power_flags[i])
152 seq_printf(m, "%s%s",
153 x86_power_flags[i][0]?" ":"",
154 x86_power_flags[i]);
155 else
156 seq_printf(m, " [%d]", i);
157 }
158
Andi Kleen770d1322006-12-07 02:14:05 +0100159 seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 c->loops_per_jiffy/(500000/HZ),
161 (c->loops_per_jiffy/(5000/HZ)) % 100);
Andi Kleen770d1322006-12-07 02:14:05 +0100162 seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
Andi Kleen3dd9d512005-04-16 15:25:15 -0700163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 return 0;
165}
166
167static void *c_start(struct seq_file *m, loff_t *pos)
168{
169 return *pos < NR_CPUS ? cpu_data + *pos : NULL;
170}
171static void *c_next(struct seq_file *m, void *v, loff_t *pos)
172{
173 ++*pos;
174 return c_start(m, pos);
175}
176static void c_stop(struct seq_file *m, void *v)
177{
178}
179struct seq_operations cpuinfo_op = {
180 .start = c_start,
181 .next = c_next,
182 .stop = c_stop,
183 .show = show_cpuinfo,
184};