diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-08-20 06:05:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-08-27 11:12:52 -0400 |
commit | f4848472cd99487e182b64fb2a5d0e4fedbe86ad (patch) | |
tree | d407ce2579e01beca7bee81df5fa3dbfe99cc512 /arch | |
parent | 6b18ae3e2ff62daa9f181401759161dd8de0aadf (diff) |
x86: Sanitize smp_record and move it to x86_init_ops
The x86 quirkification introduced an extra ugly hackery with a
variable pointer in the mpparse code. If the pointer is initialized
then it is dereferenced and the variable set to 0 or incremented.
Create a x86_init_ops function and let the affected numaq code
hold the function. Default init is a setup noop.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/setup.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/x86_init.h | 12 | ||||
-rw-r--r-- | arch/x86/kernel/apic/numaq_32.c | 19 | ||||
-rw-r--r-- | arch/x86/kernel/mpparse.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/x86_init.c | 5 |
5 files changed, 34 insertions, 9 deletions
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index 9cba9d6ca885..bbf2dfd59b47 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h | |||
@@ -25,7 +25,6 @@ struct x86_quirks { | |||
25 | int (*mach_get_smp_config)(unsigned int early); | 25 | int (*mach_get_smp_config)(unsigned int early); |
26 | int (*mach_find_smp_config)(unsigned int reserve); | 26 | int (*mach_find_smp_config)(unsigned int reserve); |
27 | 27 | ||
28 | int *mpc_record; | ||
29 | int (*mpc_apic_id)(struct mpc_cpu *m); | 28 | int (*mpc_apic_id)(struct mpc_cpu *m); |
30 | void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name); | 29 | void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name); |
31 | void (*mpc_oem_pci_bus)(struct mpc_bus *m); | 30 | void (*mpc_oem_pci_bus)(struct mpc_bus *m); |
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index 6c084f2a6c3f..10b297b1881a 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h | |||
@@ -2,6 +2,14 @@ | |||
2 | #define _ASM_X86_PLATFORM_H | 2 | #define _ASM_X86_PLATFORM_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * struct x86_init_mpparse - platform specific mpparse ops | ||
6 | * @mpc_record: platform specific mpc record accounting | ||
7 | */ | ||
8 | struct x86_init_mpparse { | ||
9 | void (*mpc_record)(unsigned int mode); | ||
10 | }; | ||
11 | |||
12 | /** | ||
5 | * struct x86_init_resources - platform specific resource related ops | 13 | * struct x86_init_resources - platform specific resource related ops |
6 | * @probe_roms: probe BIOS roms | 14 | * @probe_roms: probe BIOS roms |
7 | * @reserve_resources: reserve the standard resources for the | 15 | * @reserve_resources: reserve the standard resources for the |
@@ -22,11 +30,13 @@ struct x86_init_resources { | |||
22 | * | 30 | * |
23 | */ | 31 | */ |
24 | struct x86_init_ops { | 32 | struct x86_init_ops { |
25 | struct x86_init_resources resources; | 33 | struct x86_init_resources resources; |
34 | struct x86_init_mpparse mpparse; | ||
26 | }; | 35 | }; |
27 | 36 | ||
28 | extern struct x86_init_ops x86_init; | 37 | extern struct x86_init_ops x86_init; |
29 | 38 | ||
30 | extern void x86_init_noop(void); | 39 | extern void x86_init_noop(void); |
40 | extern void x86_init_uint_noop(unsigned int unused); | ||
31 | 41 | ||
32 | #endif | 42 | #endif |
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c index 403c062f69e8..b5f0b1dc7dd0 100644 --- a/arch/x86/kernel/apic/numaq_32.c +++ b/arch/x86/kernel/apic/numaq_32.c | |||
@@ -66,7 +66,6 @@ struct mpc_trans { | |||
66 | unsigned short trans_reserved; | 66 | unsigned short trans_reserved; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | /* x86_quirks member */ | ||
70 | static int mpc_record; | 69 | static int mpc_record; |
71 | 70 | ||
72 | static struct mpc_trans *translation_table[MAX_MPC_ENTRY]; | 71 | static struct mpc_trans *translation_table[MAX_MPC_ENTRY]; |
@@ -177,6 +176,19 @@ static void mpc_oem_pci_bus(struct mpc_bus *m) | |||
177 | quad_local_to_mp_bus_id[quad][local] = m->busid; | 176 | quad_local_to_mp_bus_id[quad][local] = m->busid; |
178 | } | 177 | } |
179 | 178 | ||
179 | /* | ||
180 | * Called from mpparse code. | ||
181 | * mode = 0: prescan | ||
182 | * mode = 1: one mpc entry scanned | ||
183 | */ | ||
184 | static void numaq_mpc_record(unsigned int mode) | ||
185 | { | ||
186 | if (!mode) | ||
187 | mpc_record = 0; | ||
188 | else | ||
189 | mpc_record++; | ||
190 | } | ||
191 | |||
180 | static void __init MP_translation_info(struct mpc_trans *m) | 192 | static void __init MP_translation_info(struct mpc_trans *m) |
181 | { | 193 | { |
182 | printk(KERN_INFO | 194 | printk(KERN_INFO |
@@ -264,7 +276,6 @@ static struct x86_quirks numaq_x86_quirks __initdata = { | |||
264 | .arch_trap_init = NULL, | 276 | .arch_trap_init = NULL, |
265 | .mach_get_smp_config = NULL, | 277 | .mach_get_smp_config = NULL, |
266 | .mach_find_smp_config = NULL, | 278 | .mach_find_smp_config = NULL, |
267 | .mpc_record = &mpc_record, | ||
268 | .mpc_apic_id = mpc_apic_id, | 279 | .mpc_apic_id = mpc_apic_id, |
269 | .mpc_oem_bus_info = mpc_oem_bus_info, | 280 | .mpc_oem_bus_info = mpc_oem_bus_info, |
270 | .mpc_oem_pci_bus = mpc_oem_pci_bus, | 281 | .mpc_oem_pci_bus = mpc_oem_pci_bus, |
@@ -285,8 +296,10 @@ static __init void early_check_numaq(void) | |||
285 | if (smp_found_config) | 296 | if (smp_found_config) |
286 | early_get_smp_config(); | 297 | early_get_smp_config(); |
287 | 298 | ||
288 | if (found_numaq) | 299 | if (found_numaq) { |
289 | x86_quirks = &numaq_x86_quirks; | 300 | x86_quirks = &numaq_x86_quirks; |
301 | x86_init.mpparse.mpc_record = numaq_mpc_record; | ||
302 | } | ||
290 | } | 303 | } |
291 | 304 | ||
292 | int __init get_memcfg_numaq(void) | 305 | int __init get_memcfg_numaq(void) |
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c index 651c93b28862..b2179fdf0ff7 100644 --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c | |||
@@ -320,8 +320,7 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) | |||
320 | /* | 320 | /* |
321 | * Now process the configuration blocks. | 321 | * Now process the configuration blocks. |
322 | */ | 322 | */ |
323 | if (x86_quirks->mpc_record) | 323 | x86_init.mpparse.mpc_record(0); |
324 | *x86_quirks->mpc_record = 0; | ||
325 | 324 | ||
326 | while (count < mpc->length) { | 325 | while (count < mpc->length) { |
327 | switch (*mpt) { | 326 | switch (*mpt) { |
@@ -353,8 +352,7 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early) | |||
353 | count = mpc->length; | 352 | count = mpc->length; |
354 | break; | 353 | break; |
355 | } | 354 | } |
356 | if (x86_quirks->mpc_record) | 355 | x86_init.mpparse.mpc_record(1); |
357 | (*x86_quirks->mpc_record)++; | ||
358 | } | 356 | } |
359 | 357 | ||
360 | #ifdef CONFIG_X86_BIGSMP | 358 | #ifdef CONFIG_X86_BIGSMP |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 1965bff3489c..83bd5db376ba 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <asm/e820.h> | 10 | #include <asm/e820.h> |
11 | 11 | ||
12 | void __cpuinit x86_init_noop(void) { } | 12 | void __cpuinit x86_init_noop(void) { } |
13 | void __init x86_init_uint_noop(unsigned int unused) { } | ||
13 | 14 | ||
14 | /* | 15 | /* |
15 | * The platform setup functions are preset with the default functions | 16 | * The platform setup functions are preset with the default functions |
@@ -23,4 +24,8 @@ struct __initdata x86_init_ops x86_init = { | |||
23 | .reserve_ebda_region = reserve_ebda_region, | 24 | .reserve_ebda_region = reserve_ebda_region, |
24 | .memory_setup = default_machine_specific_memory_setup, | 25 | .memory_setup = default_machine_specific_memory_setup, |
25 | }, | 26 | }, |
27 | |||
28 | .mpparse = { | ||
29 | .mpc_record = x86_init_uint_noop, | ||
30 | }, | ||
26 | }; | 31 | }; |