diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-09-04 23:09:02 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-05 03:40:47 -0400 |
commit | ba51dced0b55eb62874e1646d5eeff344c3d4e67 (patch) | |
tree | 19712a27ce22717b98344261fa0881efe1b92725 /arch/x86/kernel/cpu | |
parent | 950ad7ff6ec17fc1b47abc95c5c74628eb1adf8b (diff) |
x86: cpu/common.c, let 64-bit code have 32-bit only functions
No effect on 64-bit.
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/common_64.c | 111 |
2 files changed, 119 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index e0ca51f4f2d..9128ba0c8d3 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -93,6 +93,7 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | |||
93 | #endif | 93 | #endif |
94 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); | 94 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); |
95 | 95 | ||
96 | #ifdef CONFIG_X86_32 | ||
96 | static int cachesize_override __cpuinitdata = -1; | 97 | static int cachesize_override __cpuinitdata = -1; |
97 | static int disable_x86_serial_nr __cpuinitdata = 1; | 98 | static int disable_x86_serial_nr __cpuinitdata = 1; |
98 | 99 | ||
@@ -195,6 +196,13 @@ static int __init x86_serial_nr_setup(char *s) | |||
195 | return 1; | 196 | return 1; |
196 | } | 197 | } |
197 | __setup("serialnumber", x86_serial_nr_setup); | 198 | __setup("serialnumber", x86_serial_nr_setup); |
199 | #else | ||
200 | /* Probe for the CPUID instruction */ | ||
201 | static inline int have_cpuid_p(void) | ||
202 | { | ||
203 | return 1; | ||
204 | } | ||
205 | #endif | ||
198 | 206 | ||
199 | __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; | 207 | __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; |
200 | 208 | ||
diff --git a/arch/x86/kernel/cpu/common_64.c b/arch/x86/kernel/cpu/common_64.c index b4890504284..40c9d89cc14 100644 --- a/arch/x86/kernel/cpu/common_64.c +++ b/arch/x86/kernel/cpu/common_64.c | |||
@@ -92,6 +92,117 @@ DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { | |||
92 | #endif | 92 | #endif |
93 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); | 93 | EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); |
94 | 94 | ||
95 | #ifdef CONFIG_X86_32 | ||
96 | static int cachesize_override __cpuinitdata = -1; | ||
97 | static int disable_x86_serial_nr __cpuinitdata = 1; | ||
98 | |||
99 | static int __init cachesize_setup(char *str) | ||
100 | { | ||
101 | get_option(&str, &cachesize_override); | ||
102 | return 1; | ||
103 | } | ||
104 | __setup("cachesize=", cachesize_setup); | ||
105 | |||
106 | /* | ||
107 | * Naming convention should be: <Name> [(<Codename>)] | ||
108 | * This table only is used unless init_<vendor>() below doesn't set it; | ||
109 | * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used | ||
110 | * | ||
111 | */ | ||
112 | |||
113 | /* Look up CPU names by table lookup. */ | ||
114 | static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c) | ||
115 | { | ||
116 | struct cpu_model_info *info; | ||
117 | |||
118 | if (c->x86_model >= 16) | ||
119 | return NULL; /* Range check */ | ||
120 | |||
121 | if (!this_cpu) | ||
122 | return NULL; | ||
123 | |||
124 | info = this_cpu->c_models; | ||
125 | |||
126 | while (info && info->family) { | ||
127 | if (info->family == c->x86) | ||
128 | return info->model_names[c->x86_model]; | ||
129 | info++; | ||
130 | } | ||
131 | return NULL; /* Not found */ | ||
132 | } | ||
133 | |||
134 | static int __init x86_fxsr_setup(char *s) | ||
135 | { | ||
136 | setup_clear_cpu_cap(X86_FEATURE_FXSR); | ||
137 | setup_clear_cpu_cap(X86_FEATURE_XMM); | ||
138 | return 1; | ||
139 | } | ||
140 | __setup("nofxsr", x86_fxsr_setup); | ||
141 | |||
142 | static int __init x86_sep_setup(char *s) | ||
143 | { | ||
144 | setup_clear_cpu_cap(X86_FEATURE_SEP); | ||
145 | return 1; | ||
146 | } | ||
147 | __setup("nosep", x86_sep_setup); | ||
148 | |||
149 | /* Standard macro to see if a specific flag is changeable */ | ||
150 | static inline int flag_is_changeable_p(u32 flag) | ||
151 | { | ||
152 | u32 f1, f2; | ||
153 | |||
154 | asm("pushfl\n\t" | ||
155 | "pushfl\n\t" | ||
156 | "popl %0\n\t" | ||
157 | "movl %0,%1\n\t" | ||
158 | "xorl %2,%0\n\t" | ||
159 | "pushl %0\n\t" | ||
160 | "popfl\n\t" | ||
161 | "pushfl\n\t" | ||
162 | "popl %0\n\t" | ||
163 | "popfl\n\t" | ||
164 | : "=&r" (f1), "=&r" (f2) | ||
165 | : "ir" (flag)); | ||
166 | |||
167 | return ((f1^f2) & flag) != 0; | ||
168 | } | ||
169 | |||
170 | /* Probe for the CPUID instruction */ | ||
171 | static int __cpuinit have_cpuid_p(void) | ||
172 | { | ||
173 | return flag_is_changeable_p(X86_EFLAGS_ID); | ||
174 | } | ||
175 | |||
176 | static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) | ||
177 | { | ||
178 | if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr) { | ||
179 | /* Disable processor serial number */ | ||
180 | unsigned long lo, hi; | ||
181 | rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi); | ||
182 | lo |= 0x200000; | ||
183 | wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi); | ||
184 | printk(KERN_NOTICE "CPU serial number disabled.\n"); | ||
185 | clear_cpu_cap(c, X86_FEATURE_PN); | ||
186 | |||
187 | /* Disabling the serial number may affect the cpuid level */ | ||
188 | c->cpuid_level = cpuid_eax(0); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | static int __init x86_serial_nr_setup(char *s) | ||
193 | { | ||
194 | disable_x86_serial_nr = 0; | ||
195 | return 1; | ||
196 | } | ||
197 | __setup("serialnumber", x86_serial_nr_setup); | ||
198 | #else | ||
199 | /* Probe for the CPUID instruction */ | ||
200 | static inline int have_cpuid_p(void) | ||
201 | { | ||
202 | return 1; | ||
203 | } | ||
204 | #endif | ||
205 | |||
95 | __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; | 206 | __u32 cleared_cpu_caps[NCAPINTS] __cpuinitdata; |
96 | 207 | ||
97 | /* Current gdt points %fs at the "master" per-cpu area: after this, | 208 | /* Current gdt points %fs at the "master" per-cpu area: after this, |